- Service Worker

- Indexdb
This commit is contained in:
Paolo Arena
2019-02-02 20:13:06 +01:00
parent 484439efe0
commit 3c6b2c7bef
41 changed files with 762 additions and 755 deletions

View File

@@ -1,5 +1,5 @@
export interface ITodo {
_id?: number,
_id?: string,
userId: string
category?: string
descr?: string,
@@ -10,8 +10,8 @@ export interface ITodo {
completed_at: any,
expiring_at: any,
enableExpiring?: boolean,
id_prev?: number,
id_next?: number,
id_prev?: string,
id_next?: string,
modified?: boolean,
pos?: number,
progress?: number

View File

@@ -3,7 +3,7 @@ export * from './GlobalStore'
export * from './signin-option'
export * from './signup-option'
export * from './key-value'
export * from './payload'
// export * from './payload'
export * from './Categories'
export * from './Todos'

View File

@@ -1,4 +0,0 @@
export { IPayload } from './payload'
export { IPayloadMessage } from './payload-message'
export * from './payload-mapper'

View File

@@ -1,80 +0,0 @@
import { AxiosError, AxiosResponse } from 'axios'
import { PayloadMessageTypes } from 'common'
import { IPayload } from './payload'
export { PayloadMessageTypes } from '../../common/message'
export class PayloadMapper {
private fromError<T>(o: Error): IPayload<T> {
return {
data: null,
message: {
messageTypeId: PayloadMessageTypes.error,
text: o.message,
title: o.name
}
}
}
private fromAxiosError<T>(o: AxiosError): IPayload<T> {
let data: T = null
if (o.response && isAxiosResponse(o.response))
data = this.fromAxiosResponse<T>(o.response).data
return {
data: data,
message: {
messageTypeId: PayloadMessageTypes.error,
text: o.message,
title: 'Code:' + o.code + '. ' + o.name
}
}
}
private fromAxiosResponse<T>(o: AxiosResponse): IPayload<T> {
let value: IPayload<T> = null
if (isPayload<T>(o.data))
value = o.data
else
value = {
data: <any>o.data,
message: {
messageTypeId: PayloadMessageTypes.success,
text: null
}
}
return value
}
public fromObject<T>(o: any): IPayload<T> {
if (isAxiosError(o))
return this.fromAxiosError<T>(o)
if (o instanceof Error)
return this.fromError<T>(o)
if (isAxiosResponse(o))
return this.fromAxiosResponse<T>(o)
return null
}
}
function isAxiosResponse(o: any): o is AxiosResponse {
return o instanceof Object && 'data' in o && 'config' in o && 'status' in o && 'statusText' in o && 'headers' in o
}
function isAxiosError(o: any): o is AxiosError {
return o instanceof Object && o instanceof Error && 'config' in o
}
function isPayload<T>(o: any): o is IPayload<T> {
return o instanceof Object && 'data' in o && 'message' in o
}

View File

@@ -1,6 +0,0 @@
export interface IPayloadMessage {
text: string
title?: string
messageTypeId: string
}

View File

@@ -1,8 +0,0 @@
import { IPayloadMessage } from './payload-message'
export interface IPayload<T> {
data: T
message: IPayloadMessage
}