@fjell/client-api 4.4.0 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.kodrdriv/config.yaml +10 -0
- package/.kodrdriv/context/content.md +1 -0
- package/dist/AItemAPI.js +1 -1
- package/dist/AItemAPI.js.map +1 -0
- package/dist/CItemAPI.d.ts +9 -9
- package/dist/CItemAPI.js +1 -1
- package/dist/CItemAPI.js.map +1 -0
- package/dist/ClientApi.d.ts +9 -9
- package/dist/PItemAPI.d.ts +10 -10
- package/dist/PItemAPI.js +1 -1
- package/dist/PItemAPI.js.map +1 -0
- package/dist/Utilities.js +1 -1
- package/dist/Utilities.js.map +1 -0
- package/dist/index.cjs +427 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -0
- package/dist/logger.js +2 -2
- package/dist/logger.js.map +1 -0
- package/dist/ops/action.js +1 -1
- package/dist/ops/action.js.map +1 -0
- package/dist/ops/all.js +1 -1
- package/dist/ops/all.js.map +1 -0
- package/dist/ops/allAction.js +1 -1
- package/dist/ops/allAction.js.map +1 -0
- package/dist/ops/create.js +1 -1
- package/dist/ops/create.js.map +1 -0
- package/dist/ops/find.js +1 -1
- package/dist/ops/find.js.map +1 -0
- package/dist/ops/get.js +1 -1
- package/dist/ops/get.js.map +1 -0
- package/dist/ops/index.js +1 -1
- package/dist/ops/index.js.map +1 -0
- package/dist/ops/one.d.ts +1 -1
- package/dist/ops/one.js +2 -2
- package/dist/ops/one.js.map +1 -0
- package/dist/ops/remove.js +1 -1
- package/dist/ops/remove.js.map +1 -0
- package/dist/ops/update.js +1 -1
- package/dist/ops/update.js.map +1 -0
- package/package.json +25 -25
- package/src/CItemAPI.ts +14 -19
- package/src/ClientApi.ts +14 -14
- package/src/PItemAPI.ts +32 -35
- package/src/Utilities.ts +47 -47
- package/src/logger.ts +1 -1
- package/src/ops/one.ts +22 -23
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This the Fjell library that provides a framework for client-side APIs
|
package/dist/AItemAPI.js
CHANGED
|
@@ -42,4 +42,4 @@ const createAItemAPI = (api, pkType, pathNames, options)=>{
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export { createAItemAPI, finderToParams };
|
|
45
|
-
//# sourceMappingURL=
|
|
45
|
+
//# sourceMappingURL=AItemAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AItemAPI.js","sources":["../src/AItemAPI.ts"],"sourcesContent":["import { Item, QueryParams } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"./ClientApiOptions\";\nimport { getOperations } from \"./ops\";\nimport { createUtilities } from \"./Utilities\";\nimport { ClientApi } from \"./ClientApi\";\n\nimport LibLogger from \"@/logger\";\n\nconst logger = LibLogger.get('AItemAPI');\n\nexport type PathNamesArray<\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> =\n ([L5] extends [never] ?\n ([L4] extends [never] ?\n ([L3] extends [never] ?\n ([L2] extends [never] ?\n ([L1] extends [never] ?\n [string] :\n [string, string]) :\n [string, string, string]) :\n [string, string, string, string]) :\n [string, string, string, string, string]) :\n [string, string, string, string, string, string]);\n\nexport const finderToParams = (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>\n): QueryParams => {\n return {\n finder,\n finderParams: JSON.stringify(finderParams),\n };\n};\n\nexport const createAItemAPI = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n api: HttpApi,\n pkType: S,\n pathNames: PathNamesArray<L1, L2, L3, L4, L5>,\n options?: ClientApiOptions,\n ): ClientApi<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createAItemAPI', { pkType, pathNames, options });\n\n let mergedOptions: ClientApiOptions;\n \n const defaultOptions: ClientApiOptions = {\n readAuthenticated: true,\n allAuthenticated: true,\n writeAuthenticated: true,\n };\n\n if (options) {\n mergedOptions = Object.assign({}, defaultOptions, options);\n } else {\n mergedOptions = defaultOptions;\n }\n\n const utilities = createUtilities<V, S, L1, L2, L3, L4, L5>(pkType, pathNames);\n const operations = getOperations<V, S, L1, L2, L3, L4, L5>(api, mergedOptions, utilities);\n\n return {\n action: operations.action,\n all: operations.all,\n allAction: operations.allAction,\n create: operations.create,\n find: operations.find,\n get: operations.get,\n one: operations.one,\n remove: operations.remove,\n update: operations.update,\n }\n}"],"names":["logger","LibLogger","get","finderToParams","finder","finderParams","JSON","stringify","createAItemAPI","api","pkType","pathNames","options","default","mergedOptions","defaultOptions","readAuthenticated","allAuthenticated","writeAuthenticated","Object","assign","utilities","createUtilities","operations","getOperations","action","all","allAction","create","find","one","remove","update"],"mappings":";;;;AAUA,MAAMA,MAAAA,GAASC,SAAUC,CAAAA,GAAG,CAAC,UAAA,CAAA;AAqBtB,MAAMC,cAAiB,GAAA,CAC5BC,MACAC,EAAAA,YAAAA,GAAAA;IAEA,OAAO;AACLD,QAAAA,MAAAA;QACAC,YAAcC,EAAAA,IAAAA,CAAKC,SAAS,CAACF,YAAAA;AAC/B,KAAA;AACF;AAEaG,MAAAA,cAAAA,GAAiB,CAS1BC,GAAAA,EACAC,QACAC,SACAC,EAAAA,OAAAA,GAAAA;IAGFZ,MAAOa,CAAAA,OAAO,CAAC,gBAAkB,EAAA;AAAEH,QAAAA,MAAAA;AAAQC,QAAAA,SAAAA;AAAWC,QAAAA;AAAQ,KAAA,CAAA;IAE9D,IAAIE,aAAAA;AAEJ,IAAA,MAAMC,cAAmC,GAAA;QACvCC,iBAAmB,EAAA,IAAA;QACnBC,gBAAkB,EAAA,IAAA;QAClBC,kBAAoB,EAAA;AACtB,KAAA;AAEA,IAAA,IAAIN,OAAS,EAAA;AACXE,QAAAA,aAAAA,GAAgBK,MAAOC,CAAAA,MAAM,CAAC,IAAIL,cAAgBH,EAAAA,OAAAA,CAAAA;KAC7C,MAAA;QACLE,aAAgBC,GAAAA,cAAAA;AAClB;IAEA,MAAMM,SAAAA,GAAaC,gBAA0CZ,MAAQC,EAAAA,SAAAA,CAAAA;IACrE,MAAMY,UAAAA,GAAaC,aAAwCf,CAAAA,GAAAA,EAAKK,aAAeO,EAAAA,SAAAA,CAAAA;IAE/E,OAAO;AACLI,QAAAA,MAAAA,EAAQF,WAAWE,MAAM;AACzBC,QAAAA,GAAAA,EAAKH,WAAWG,GAAG;AACnBC,QAAAA,SAAAA,EAAWJ,WAAWI,SAAS;AAC/BC,QAAAA,MAAAA,EAAQL,WAAWK,MAAM;AACzBC,QAAAA,IAAAA,EAAMN,WAAWM,IAAI;AACrB3B,QAAAA,GAAAA,EAAKqB,WAAWrB,GAAG;AACnB4B,QAAAA,GAAAA,EAAKP,WAAWO,GAAG;AACnBC,QAAAA,MAAAA,EAAQR,WAAWQ,MAAM;AACzBC,QAAAA,MAAAA,EAAQT,WAAWS;AACrB,KAAA;AACF;;;;"}
|
package/dist/CItemAPI.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { PathNamesArray } from './AItemAPI';
|
|
|
4
4
|
import { ClientApi } from './ClientApi';
|
|
5
5
|
import { ClientApiOptions } from './ClientApiOptions';
|
|
6
6
|
export interface CItemApi<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends ClientApi<V, S, L1, L2, L3, L4, L5> {
|
|
7
|
-
action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any, options
|
|
8
|
-
all: (query: ItemQuery, options
|
|
9
|
-
allAction: (action: string, body: any, options
|
|
10
|
-
get: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, options
|
|
11
|
-
create: (item: TypesProperties<V, S, L1, L2, L3, L4, L5>, options
|
|
12
|
-
remove: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, options
|
|
13
|
-
update: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: TypesProperties<V, S, L1, L2, L3, L4, L5>, options
|
|
14
|
-
find: (finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, options
|
|
7
|
+
action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any, options?: Partial<PostMethodOptions>) => Promise<V>;
|
|
8
|
+
all: (query: ItemQuery, options?: Partial<GetMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
|
|
9
|
+
allAction: (action: string, body: any, options?: Partial<PostMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
|
|
10
|
+
get: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, options?: Partial<GetMethodOptions>) => Promise<V | null>;
|
|
11
|
+
create: (item: TypesProperties<V, S, L1, L2, L3, L4, L5>, options?: Partial<PostMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
|
|
12
|
+
remove: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, options?: Partial<DeleteMethodOptions>) => Promise<boolean>;
|
|
13
|
+
update: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: TypesProperties<V, S, L1, L2, L3, L4, L5>, options?: Partial<PutMethodOptions>) => Promise<V>;
|
|
14
|
+
find: (finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, options?: Partial<GetMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
|
|
15
15
|
}
|
|
16
|
-
export declare const createCItemApi: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(api: HttpApi, type: S, pathNames: PathNamesArray<L1, L2, L3, L4, L5>, options
|
|
16
|
+
export declare const createCItemApi: <V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(api: HttpApi, type: S, pathNames: PathNamesArray<L1, L2, L3, L4, L5>, options?: ClientApiOptions) => CItemApi<V, S, L1, L2, L3, L4, L5>;
|
package/dist/CItemAPI.js
CHANGED
|
@@ -24,4 +24,4 @@ const createCItemApi = (api, type, pathNames, options)=>{
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export { createCItemApi };
|
|
27
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=CItemAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CItemAPI.js","sources":["../src/CItemAPI.ts"],"sourcesContent":["\nimport {\n ComKey,\n Item,\n ItemQuery,\n LocKeyArray,\n PriKey,\n TypesProperties\n} from \"@fjell/core\";\nimport {\n DeleteMethodOptions,\n GetMethodOptions,\n HttpApi,\n PostMethodOptions,\n PutMethodOptions,\n} from \"@fjell/http-api\";\nimport { createAItemAPI, PathNamesArray } from \"./AItemAPI\";\n\nimport { ClientApi } from \"./ClientApi\";\nimport { ClientApiOptions } from \"./ClientApiOptions\";\nimport LibLogger from \"@/logger\";\n\nconst logger = LibLogger.get('CItemAPI');\n\nexport interface CItemApi<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> extends ClientApi<V, S, L1, L2, L3, L4, L5> {\n action: (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n action: string,\n body: any,\n options?: Partial<PostMethodOptions>\n ) => Promise<V>;\n all: (\n query: ItemQuery,\n options?: Partial<GetMethodOptions>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ) => Promise<V[]>;\n allAction: (\n action: string,\n body: any,\n options?: Partial<PostMethodOptions>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ) => Promise<V[]>;\n get: (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n options?: Partial<GetMethodOptions>,\n ) => Promise<V | null>;\n create: (\n item: TypesProperties<V, S, L1, L2, L3, L4, L5>,\n options?: Partial<PostMethodOptions>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ) => Promise<V>;\n remove: (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n options?: Partial<DeleteMethodOptions>\n ) => Promise<boolean>;\n update: (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n item: TypesProperties<V, S, L1, L2, L3, L4, L5>,\n options?: Partial<PutMethodOptions>\n ) => Promise<V>;\n find: (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n options?: Partial<GetMethodOptions>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ) => Promise<V[]>;\n};\n\nexport const createCItemApi = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(api: HttpApi, type: S, pathNames: PathNamesArray<L1, L2, L3, L4, L5>, options?: ClientApiOptions): CItemApi<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createCItemApi', { api, type, pathNames, options });\n\n const aItemAPI = createAItemAPI(api, type, pathNames, options);\n\n return {\n action: aItemAPI.action,\n all: aItemAPI.all,\n allAction: aItemAPI.allAction,\n one: aItemAPI.one,\n get: aItemAPI.get,\n create: aItemAPI.create,\n remove: aItemAPI.remove,\n update: aItemAPI.update,\n find: aItemAPI.find,\n } as unknown as CItemApi<V, S, L1, L2, L3, L4, L5>;\n}\n"],"names":["logger","LibLogger","get","createCItemApi","api","type","pathNames","options","default","aItemAPI","createAItemAPI","action","all","allAction","one","create","remove","update","find"],"mappings":";;;AAsBA,MAAMA,MAAAA,GAASC,SAAUC,CAAAA,GAAG,CAAC,UAAA,CAAA;AAsDhBC,MAAAA,cAAAA,GAAiB,CAQ5BC,GAAAA,EAAcC,MAASC,SAA+CC,EAAAA,OAAAA,GAAAA;IAEtEP,MAAOQ,CAAAA,OAAO,CAAC,gBAAkB,EAAA;AAAEJ,QAAAA,GAAAA;AAAKC,QAAAA,IAAAA;AAAMC,QAAAA,SAAAA;AAAWC,QAAAA;AAAQ,KAAA,CAAA;AAEjE,IAAA,MAAME,QAAWC,GAAAA,cAAAA,CAAeN,GAAKC,EAAAA,IAAAA,EAAMC,SAAWC,EAAAA,OAAAA,CAAAA;IAEtD,OAAO;AACLI,QAAAA,MAAAA,EAAQF,SAASE,MAAM;AACvBC,QAAAA,GAAAA,EAAKH,SAASG,GAAG;AACjBC,QAAAA,SAAAA,EAAWJ,SAASI,SAAS;AAC7BC,QAAAA,GAAAA,EAAKL,SAASK,GAAG;AACjBZ,QAAAA,GAAAA,EAAKO,SAASP,GAAG;AACjBa,QAAAA,MAAAA,EAAQN,SAASM,MAAM;AACvBC,QAAAA,MAAAA,EAAQP,SAASO,MAAM;AACvBC,QAAAA,MAAAA,EAAQR,SAASQ,MAAM;AACvBC,QAAAA,IAAAA,EAAMT,SAASS;AACjB,KAAA;AACF;;;;"}
|
package/dist/ClientApi.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ComKey, Item, ItemQuery, LocKeyArray, PriKey, TypesProperties } from '@fjell/core';
|
|
2
2
|
import { DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from '@fjell/http-api';
|
|
3
3
|
export interface ClientApi<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
|
|
4
|
-
action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any, options
|
|
5
|
-
all: (query: ItemQuery, options
|
|
6
|
-
allAction: (action: string, body: any, options
|
|
7
|
-
create: (item: TypesProperties<V, S, L1, L2, L3, L4, L5>, options
|
|
8
|
-
find: (finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, options
|
|
9
|
-
get: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, options
|
|
10
|
-
one: (query: ItemQuery, options
|
|
11
|
-
remove: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, options
|
|
12
|
-
update: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: TypesProperties<V, S, L1, L2, L3, L4, L5>, options
|
|
4
|
+
action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any, options?: Partial<PostMethodOptions>) => Promise<V>;
|
|
5
|
+
all: (query: ItemQuery, options?: Partial<GetMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
|
|
6
|
+
allAction: (action: string, body: any, options?: Partial<PostMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
|
|
7
|
+
create: (item: TypesProperties<V, S, L1, L2, L3, L4, L5>, options?: Partial<PostMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
|
|
8
|
+
find: (finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, options?: Partial<GetMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
|
|
9
|
+
get: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, options?: Partial<GetMethodOptions>) => Promise<V | null>;
|
|
10
|
+
one: (query: ItemQuery, options?: Partial<GetMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V | null>;
|
|
11
|
+
remove: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, options?: Partial<DeleteMethodOptions>) => Promise<boolean>;
|
|
12
|
+
update: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: TypesProperties<V, S, L1, L2, L3, L4, L5>, options?: Partial<PutMethodOptions>) => Promise<V>;
|
|
13
13
|
}
|
package/dist/PItemAPI.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import { HttpApi, DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutM
|
|
|
3
3
|
import { ClientApi } from './ClientApi';
|
|
4
4
|
import { ClientApiOptions } from './ClientApiOptions';
|
|
5
5
|
export interface PItemApi<V extends Item<S>, S extends string> extends ClientApi<V, S> {
|
|
6
|
-
action: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, action: string, body: any, options
|
|
7
|
-
all: (query: ItemQuery, options
|
|
8
|
-
allAction: (action: string, body: any, options
|
|
9
|
-
one: (query: ItemQuery, options
|
|
10
|
-
get: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, options
|
|
11
|
-
create: (item: TypesProperties<V, S>, options
|
|
12
|
-
remove: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, options
|
|
13
|
-
update: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, item: TypesProperties<V, S>, options
|
|
14
|
-
find: (finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, options
|
|
6
|
+
action: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, action: string, body: any, options?: Partial<PostMethodOptions>, locations?: []) => Promise<V>;
|
|
7
|
+
all: (query: ItemQuery, options?: Partial<GetMethodOptions>, locations?: []) => Promise<V[]>;
|
|
8
|
+
allAction: (action: string, body: any, options?: Partial<PostMethodOptions>) => Promise<V[]>;
|
|
9
|
+
one: (query: ItemQuery, options?: Partial<GetMethodOptions>) => Promise<V | null>;
|
|
10
|
+
get: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, options?: Partial<GetMethodOptions>, locations?: []) => Promise<V | null>;
|
|
11
|
+
create: (item: TypesProperties<V, S>, options?: Partial<PostMethodOptions>, locations?: []) => Promise<V>;
|
|
12
|
+
remove: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, options?: Partial<DeleteMethodOptions>, locations?: []) => Promise<boolean>;
|
|
13
|
+
update: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, item: TypesProperties<V, S>, options?: Partial<PutMethodOptions>, locations?: []) => Promise<V>;
|
|
14
|
+
find: (finder: string, finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, options?: Partial<GetMethodOptions>, locations?: []) => Promise<V[]>;
|
|
15
15
|
}
|
|
16
|
-
export declare const createPItemApi: <V extends Item<S>, S extends string>(api: HttpApi, type: S, pathName: string, options
|
|
16
|
+
export declare const createPItemApi: <V extends Item<S>, S extends string>(api: HttpApi, type: S, pathName: string, options?: ClientApiOptions) => PItemApi<V, S>;
|
package/dist/PItemAPI.js
CHANGED
|
@@ -35,4 +35,4 @@ const createPItemApi = (api, type, pathName, options)=>{
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export { createPItemApi };
|
|
38
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=PItemAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PItemAPI.js","sources":["../src/PItemAPI.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport { ComKey, Item, ItemProperties, ItemQuery, PriKey, TypesProperties } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\nimport { createAItemAPI, PathNamesArray } from \"./AItemAPI\";\nimport { ClientApi } from \"./ClientApi\";\n\nimport { DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from \"@fjell/http-api\";\nimport { ClientApiOptions } from \"./ClientApiOptions\";\nimport LibLogger from \"@/logger\";\nconst logger = LibLogger.get('PItemAPI');\n\nexport interface PItemApi<\n V extends Item<S>,\n S extends string\n> extends ClientApi<V, S> {\n\n action: (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n action: string,\n body: any,\n options?: Partial<PostMethodOptions>,\n locations?: []\n ) => Promise<V>;\n\n all: (\n query: ItemQuery,\n options?: Partial<GetMethodOptions>,\n locations?: []\n ) => Promise<V[]>;\n\n allAction: (\n action: string,\n body: any,\n options?: Partial<PostMethodOptions>\n ) => Promise<V[]>;\n\n one: (\n query: ItemQuery,\n options?: Partial<GetMethodOptions>\n ) => Promise<V | null>;\n\n get: (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n options?: Partial<GetMethodOptions>,\n locations?: []\n ) => Promise<V | null>;\n\n create: (\n item: TypesProperties<V, S>,\n options?: Partial<PostMethodOptions>,\n locations?: []\n ) => Promise<V>;\n\n remove: (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n options?: Partial<DeleteMethodOptions>,\n locations?: []\n ) => Promise<boolean>;\n\n update: (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n item: TypesProperties<V, S>,\n options?: Partial<PutMethodOptions>,\n locations?: []\n ) => Promise<V>;\n\n find: (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n options?: Partial<GetMethodOptions>,\n locations?: []\n ) => Promise<V[]>;\n}\n\nexport const createPItemApi = <V extends Item<S>, S extends string>(\n api: HttpApi,\n type: S,\n pathName: string,\n options?: ClientApiOptions\n): PItemApi<V, S> => {\n\n logger.default('createPItemApi', { type, pathName, options });\n\n const aItemAPI = createAItemAPI<V, S>(api, type, [pathName], options);\n\n const action =\n async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n action: string,\n body: any = {},\n options: Partial<PostMethodOptions> = {},\n ): Promise<V> =>\n await aItemAPI.action(ik, action, body, options) as V;\n\n const all =\n async (\n query: ItemQuery = {} as ItemQuery,\n options: Partial<GetMethodOptions> = {},\n ): Promise<V[]> =>\n await aItemAPI.all(query, options, []) as V[];\n\n const allAction =\n async (\n action: string,\n body: any = {},\n options: Partial<PostMethodOptions> = {},\n ): Promise<V[]> =>\n await aItemAPI.allAction(action, body, options, []) as V[];\n\n const one =\n async (\n query: ItemQuery = {} as ItemQuery,\n options: Partial<GetMethodOptions> = {},\n ): Promise<V | null> =>\n await aItemAPI.one(query, options, []) as V | null;\n\n const get =\n async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n options: Partial<GetMethodOptions> = {},\n ): Promise<V | null> =>\n await aItemAPI.get(ik, options) as V | null;\n\n const create =\n async (\n item: TypesProperties<V, S>,\n options: Partial<PostMethodOptions> = {},\n ): Promise<V> =>\n await aItemAPI.create(item, options, []) as V;\n\n const remove =\n async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n options: Partial<DeleteMethodOptions> = {},\n ): Promise<boolean> =>\n await aItemAPI.remove(ik, options) as boolean;\n\n const update =\n async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n item: TypesProperties<V, S>,\n options: Partial<PutMethodOptions> = {},\n ): Promise<V> =>\n await aItemAPI.update(ik, item, options) as V;\n\n const find =\n async (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n options: Partial<GetMethodOptions> = {},\n ): Promise<V[]> =>\n await aItemAPI.find(finder, finderParams, options, []) as V[];\n\n return {\n ...aItemAPI,\n action,\n all,\n allAction,\n one,\n get,\n create,\n remove,\n update,\n find,\n };\n\n};\n"],"names":["logger","LibLogger","get","createPItemApi","api","type","pathName","options","default","aItemAPI","createAItemAPI","action","ik","body","all","query","allAction","one","create","item","remove","update","find","finder","finderParams"],"mappings":";;;AAUA,MAAMA,MAAAA,GAASC,SAAUC,CAAAA,GAAG,CAAC,UAAA,CAAA;AAiEhBC,MAAAA,cAAAA,GAAiB,CAC5BC,GAAAA,EACAC,MACAC,QACAC,EAAAA,OAAAA,GAAAA;IAGAP,MAAOQ,CAAAA,OAAO,CAAC,gBAAkB,EAAA;AAAEH,QAAAA,IAAAA;AAAMC,QAAAA,QAAAA;AAAUC,QAAAA;AAAQ,KAAA,CAAA;IAE3D,MAAME,QAAAA,GAAWC,cAAqBN,CAAAA,GAAAA,EAAKC,IAAM,EAAA;AAACC,QAAAA;KAA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AAAA,CAAAA;AAEpC,IAAA,MAAMe,IACJ,GAAA,OACEC,MACAC,EAAAA,YAAAA,EACAjB,UAAqC,EAAE,GAEvC,MAAME,SAASa,IAAI,CAACC,MAAQC,EAAAA,YAAAA,EAAcjB,SAAS,EAAE,CAAA;IAEzD,OAAO;AACL,QAAA,GAAGE,QAAQ;AACXE,QAAAA,MAAAA;AACAG,QAAAA,GAAAA;AACAE,QAAAA,SAAAA;AACAC,QAAAA,GAAAA;AACAf,QAAAA,GAAAA;AACAgB,QAAAA,MAAAA;AACAE,QAAAA,MAAAA;AACAC,QAAAA,MAAAA;AACAC,QAAAA;AACF,KAAA;AAEF;;;;"}
|
package/dist/Utilities.js
CHANGED
|
@@ -150,4 +150,4 @@ const createUtilities = (pkType, pathNames)=>{
|
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
export { createUtilities };
|
|
153
|
-
//# sourceMappingURL=
|
|
153
|
+
//# sourceMappingURL=Utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utilities.js","sources":["../src/Utilities.ts"],"sourcesContent":["import {\n ComKey,\n validatePK as coreValidatePK,\n generateKeyArray,\n isPriKey,\n Item,\n LocKey,\n LocKeyArray,\n PriKey,\n} from \"@fjell/core\";\n\nimport LibLogger from \"@/logger\";\nimport deepmerge from \"deepmerge\";\n\nconst logger = LibLogger.get('client-api', 'Utility');\n\nexport interface Utilities<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> {\n verifyLocations: (locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | never) => boolean;\n processOne: (apiCall: Promise<V>) => Promise<V>;\n processArray: (api: Promise<V[]>) => Promise<V[]>;\n convertDoc: (doc: V) => V;\n getPath: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S> | LocKeyArray<L1, L2, L3, L4, L5> | []) => string;\n validatePK: (item: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[]) =>\n Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[];\n}\n\nexport const createUtilities = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(pkType: S, pathNames: string[]): Utilities<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createUtilities', { pkType, pathNames });\n\n const verifyLocations = (\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | never,\n ): boolean => {\n\n if (locations && locations.length < pathNames.length - 1) {\n throw new Error('Not enough locations for pathNames: locations:'\n + locations.length + ' pathNames:' + pathNames.length);\n }\n return true;\n }\n\n const processOne = async (\n apiCall: Promise<V>,\n ): Promise<V> => {\n logger.default('processOne', { apiCall });\n const response = await apiCall;\n logger.default('processOne response', { response: JSON.stringify(response, null, 2) });\n return convertDoc(response);\n };\n\n const processArray = async (\n api: Promise<V[]>,\n ): Promise<V[]> => {\n logger.default('processArray', { api });\n const response = await api;\n logger.default('processArray response', { response: JSON.stringify(response, null, 2) });\n if (response && Array.isArray(response)) {\n return response.map((subjectChat: V) =>\n convertDoc(subjectChat),\n ) as unknown as V[];\n } else {\n logger.error('Response was not an array', { response });\n throw new Error('Response was not an array');\n }\n };\n\n const convertDoc = (doc: V): V => {\n logger.default('convertDoc', { doc });\n // console.log(JSON.stringify(doc, null, 2));\n if (doc && doc.events) {\n const events = doc.events;\n for (const key in events) {\n events[key] = deepmerge(events[key], { at: events[key].at ? new Date(events[key].at) : null });\n }\n\n return doc as unknown as V;\n } else {\n return doc;\n }\n };\n\n const getPath =\n (\n key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S> | LocKeyArray<L1, L2, L3, L4, L5> | [],\n ):\n string => {\n\n const localPathNames = [...pathNames];\n logger.default('getPath', { key, pathNames: localPathNames });\n\n // console.log('getPath key: ' + JSON.stringify(key));\n\n const keys = generateKeyArray(key);\n\n // console.log('getPath keys: ' + JSON.stringify(keys));\n // console.log('getPath pathNames: ' + JSON.stringify(pathNames));\n\n let path: string = addPath('', keys, localPathNames);\n\n // If there is only one collection left in the collections array, this means that\n // we received LocKeys and we need to add the last collection to the reference\n if (localPathNames.length === 1) {\n path = `${path}/${localPathNames[0]}`;\n }\n\n logger.default('getPath created', { key, path });\n\n return path;\n };\n\n const addPath = (\n base: string,\n keys: Array<PriKey<S> | LocKey<L1 | L2 | L3 | L4 | L5>>,\n localPathNames: string[],\n ): string => {\n logger.default('addPath', { base, keys, pathNames: localPathNames });\n if (keys.length < localPathNames.length - 1) {\n logger.error('addPath should never have keys with a length less than the length of pathNames - 1',\n { keys, localPathNames });\n throw new Error('addPath should never have keys with a length less than the length of pathNames - 1: '\n + keys.length + ' ' + localPathNames.length + ' ' + JSON.stringify(keys, localPathNames));\n } else if (keys.length > localPathNames.length) {\n logger.error('addPath should never have keys with a length greater than the length of pathNames',\n { keys, pathNames });\n throw new Error('addPath should never have keys with a length greater than the length of pathNames: '\n + keys.length + ' ' + localPathNames.length + ' ' + JSON.stringify(keys, localPathNames));\n }\n if (keys.length === 0) {\n // If you've recursively consumed all of the keys, return the base.\n logger.default('addPath returning base', { base });\n return base;\n } else {\n // Retrieve the next key and collection, and create the next base\n let nextBase: string;\n const key = keys.pop();\n const pathName = localPathNames.pop();\n if (isPriKey(key)) {\n const PriKey = key as PriKey<S>;\n nextBase = `${base}/${pathName}/${PriKey.pk}`;\n logger.default('Adding Path for PK', { pathName, PriKey, nextBase });\n } else {\n const LocKey = key as LocKey<L1 | L2 | L3 | L4 | L5>;\n nextBase = `${base}/${pathName}/${LocKey.lk}`;\n logger.default('Retrieving Collection for LK', { pathName, LocKey });\n }\n\n logger.default('calling addPath recursively', { nextBase, keys, localPathNames });\n return addPath(nextBase, keys, localPathNames);\n }\n\n }\n\n const validatePK = (\n item: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[]):\n Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[] => {\n return coreValidatePK<S, L1, L2, L3, L4, L5>(item, pkType);\n }\n\n return {\n verifyLocations,\n processOne,\n convertDoc,\n processArray,\n getPath,\n validatePK,\n }\n}\n"],"names":["logger","LibLogger","get","createUtilities","pkType","pathNames","default","verifyLocations","locations","length","Error","processOne","apiCall","response","JSON","stringify","convertDoc","processArray","api","Array","isArray","map","subjectChat","error","doc","events","key","deepmerge","at","Date","getPath","localPathNames","keys","generateKeyArray","path","addPath","base","nextBase","pop","pathName","isPriKey","PriKey","pk","LocKey","lk","validatePK","item","coreValidatePK"],"mappings":";;;;AAcA,MAAMA,MAASC,GAAAA,SAAAA,CAAUC,GAAG,CAAC,YAAc,EAAA,SAAA,CAAA;AAoBpC,MAAMC,eAAkB,GAAA,CAQ7BC,MAAWC,EAAAA,SAAAA,GAAAA;IAEXL,MAAOM,CAAAA,OAAO,CAAC,iBAAmB,EAAA;AAAEF,QAAAA,MAAAA;AAAQC,QAAAA;AAAU,KAAA,CAAA;AAEtD,IAAA,MAAME,kBAAkB,CACtBC,SAAAA,GAAAA;AAGA,QAAA,IAAIA,aAAaA,SAAUC,CAAAA,MAAM,GAAGJ,SAAUI,CAAAA,MAAM,GAAG,CAAG,EAAA;YACxD,MAAM,IAAIC,MAAM,gDACZF,GAAAA,SAAAA,CAAUC,MAAM,GAAG,aAAA,GAAgBJ,UAAUI,MAAM,CAAA;AACzD;QACA,OAAO,IAAA;AACT,KAAA;AAEA,IAAA,MAAME,aAAa,OACjBC,OAAAA,GAAAA;QAEAZ,MAAOM,CAAAA,OAAO,CAAC,YAAc,EAAA;AAAEM,YAAAA;AAAQ,SAAA,CAAA;AACvC,QAAA,MAAMC,WAAW,MAAMD,OAAAA;QACvBZ,MAAOM,CAAAA,OAAO,CAAC,qBAAuB,EAAA;AAAEO,YAAAA,QAAAA,EAAUC,IAAKC,CAAAA,SAAS,CAACF,QAAAA,EAAU,I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AS,CAAC,EAAEI,MAAOC,CAAAA,EAAE,CAAE,CAAA;gBAC7C5C,MAAOM,CAAAA,OAAO,CAAC,8BAAgC,EAAA;AAAEiC,oBAAAA,QAAAA;AAAUI,oBAAAA;AAAO,iBAAA,CAAA;AACpE;YAEA3C,MAAOM,CAAAA,OAAO,CAAC,6BAA+B,EAAA;AAAE+B,gBAAAA,QAAAA;AAAUL,gBAAAA,IAAAA;AAAMD,gBAAAA;AAAe,aAAA,CAAA;YAC/E,OAAOI,OAAAA,CAAQE,UAAUL,IAAMD,EAAAA,cAAAA,CAAAA;AACjC;AAEF,KAAA;AAEA,IAAA,MAAMc,eAAa,CACjBC,IAAAA,GAAAA;AAEA,QAAA,OAAOC,WAAsCD,IAAM1C,EAAAA,MAAAA,CAAAA;AACrD,KAAA;IAEA,OAAO;AACLG,QAAAA,eAAAA;AACAI,QAAAA,UAAAA;AACAK,QAAAA,UAAAA;AACAC,QAAAA,YAAAA;AACAa,QAAAA,OAAAA;AACAe,oBAAAA;AACF,KAAA;AACF;;;;"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const core = require('@fjell/core');
|
|
6
|
+
const Logging = require('@fjell/logging');
|
|
7
|
+
const deepmerge = require('deepmerge');
|
|
8
|
+
|
|
9
|
+
const LibLogger = Logging.getLogger('@fjell/client-api');
|
|
10
|
+
|
|
11
|
+
const logger$c = LibLogger.get('client-api', 'ops', 'all');
|
|
12
|
+
const getAllOperation = (api, apiOptions, utilities)=>{
|
|
13
|
+
const all = async (query = {}, options = {}, locations = [])=>{
|
|
14
|
+
logger$c.default('all', {
|
|
15
|
+
query,
|
|
16
|
+
locations
|
|
17
|
+
});
|
|
18
|
+
utilities.verifyLocations(locations);
|
|
19
|
+
const loc = locations;
|
|
20
|
+
const params = core.queryToParams(query);
|
|
21
|
+
const requestOptions = Object.assign({}, options, {
|
|
22
|
+
isAuthenticated: apiOptions.allAuthenticated,
|
|
23
|
+
params
|
|
24
|
+
});
|
|
25
|
+
return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
|
|
26
|
+
};
|
|
27
|
+
return all;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const logger$b = LibLogger.get('client-api', 'ops', 'action');
|
|
31
|
+
const getActionOperation = (api, apiOptions, utilities)=>{
|
|
32
|
+
const action = async (ik, action, body = {}, options = {})=>{
|
|
33
|
+
logger$b.default('action', {
|
|
34
|
+
ik,
|
|
35
|
+
action,
|
|
36
|
+
body
|
|
37
|
+
});
|
|
38
|
+
const requestOptions = Object.assign({}, options, {
|
|
39
|
+
isAuthenticated: apiOptions.writeAuthenticated
|
|
40
|
+
});
|
|
41
|
+
return utilities.validatePK(await utilities.processOne(api.httpPost(`${utilities.getPath(ik)}/${action}`, body, requestOptions)));
|
|
42
|
+
};
|
|
43
|
+
return action;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const logger$a = LibLogger.get('client-api', 'ops', 'allAction');
|
|
47
|
+
const getAllActionOperation = (api, apiOptions, utilities)=>{
|
|
48
|
+
const allAction = async (action, body = {}, options = {}, locations = [])=>{
|
|
49
|
+
logger$a.default('allAction', {
|
|
50
|
+
action,
|
|
51
|
+
body,
|
|
52
|
+
locations
|
|
53
|
+
});
|
|
54
|
+
utilities.verifyLocations(locations);
|
|
55
|
+
const loc = locations;
|
|
56
|
+
const requestOptions = Object.assign({}, options, {
|
|
57
|
+
isAuthenticated: apiOptions.writeAuthenticated
|
|
58
|
+
});
|
|
59
|
+
// TODO: This should respond to either a single object, or multiple objects in an array.
|
|
60
|
+
return utilities.validatePK(await utilities.processArray(api.httpPost(utilities.getPath(loc), body, requestOptions)));
|
|
61
|
+
};
|
|
62
|
+
return allAction;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const logger$9 = LibLogger.get('client-api', 'ops', 'one');
|
|
66
|
+
const getOneOperation = (api, apiOptions, utilities)=>{
|
|
67
|
+
const one = async (query = {}, options = {}, locations = [])=>{
|
|
68
|
+
logger$9.default('one', {
|
|
69
|
+
query,
|
|
70
|
+
locations
|
|
71
|
+
});
|
|
72
|
+
utilities.verifyLocations(locations);
|
|
73
|
+
const loc = locations;
|
|
74
|
+
const params = core.queryToParams(query);
|
|
75
|
+
const requestOptions = Object.assign({}, options, {
|
|
76
|
+
isAuthenticated: apiOptions.readAuthenticated,
|
|
77
|
+
params
|
|
78
|
+
});
|
|
79
|
+
let item = null;
|
|
80
|
+
const items = utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
|
|
81
|
+
if (items.length > 0) {
|
|
82
|
+
item = items[0];
|
|
83
|
+
}
|
|
84
|
+
return item;
|
|
85
|
+
};
|
|
86
|
+
return one;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const logger$8 = LibLogger.get('client-api', 'ops', 'create');
|
|
90
|
+
const getCreateOperation = (api, apiOptions, utilities)=>{
|
|
91
|
+
const create = async (item, options = {}, locations = [])=>{
|
|
92
|
+
logger$8.default('create', {
|
|
93
|
+
item,
|
|
94
|
+
locations
|
|
95
|
+
});
|
|
96
|
+
utilities.verifyLocations(locations);
|
|
97
|
+
const loc = locations;
|
|
98
|
+
const requestOptions = Object.assign({}, options, {
|
|
99
|
+
isAuthenticated: apiOptions.writeAuthenticated
|
|
100
|
+
});
|
|
101
|
+
const created = utilities.validatePK(await utilities.processOne(api.httpPost(utilities.getPath(loc), item, requestOptions)));
|
|
102
|
+
return created;
|
|
103
|
+
};
|
|
104
|
+
return create;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const logger$7 = LibLogger.get('client-api', 'ops', 'update');
|
|
108
|
+
const getUpdateOperation = (api, apiOptions, utilities)=>{
|
|
109
|
+
const update = async (ik, item, options = {})=>{
|
|
110
|
+
logger$7.default('update', {
|
|
111
|
+
ik,
|
|
112
|
+
item
|
|
113
|
+
});
|
|
114
|
+
const requestOptions = Object.assign({}, options, {
|
|
115
|
+
isAuthenticated: apiOptions.writeAuthenticated
|
|
116
|
+
});
|
|
117
|
+
return utilities.validatePK(await utilities.processOne(api.httpPut(utilities.getPath(ik), item, requestOptions)));
|
|
118
|
+
};
|
|
119
|
+
return update;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const logger$6 = LibLogger.get('client-api', 'ops', 'get');
|
|
123
|
+
const getGetOperation = (api, apiOptions, utilities)=>{
|
|
124
|
+
const get = async (ik, options = {})=>{
|
|
125
|
+
logger$6.default('get', {
|
|
126
|
+
ik
|
|
127
|
+
});
|
|
128
|
+
const requestOptions = Object.assign({}, options, {
|
|
129
|
+
isAuthenticated: apiOptions.readAuthenticated
|
|
130
|
+
});
|
|
131
|
+
return utilities.validatePK(await utilities.processOne(api.httpGet(utilities.getPath(ik), requestOptions)));
|
|
132
|
+
};
|
|
133
|
+
return get;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const logger$5 = LibLogger.get('client-api', 'ops', 'remove');
|
|
137
|
+
const getRemoveOperation = (api, apiOptions, utilities)=>{
|
|
138
|
+
const remove = async (ik, options = {})=>{
|
|
139
|
+
logger$5.default('remove', {
|
|
140
|
+
ik
|
|
141
|
+
});
|
|
142
|
+
const requestOptions = Object.assign({}, options, {
|
|
143
|
+
isAuthenticated: apiOptions.writeAuthenticated
|
|
144
|
+
});
|
|
145
|
+
return api.httpDelete(utilities.getPath(ik), requestOptions);
|
|
146
|
+
};
|
|
147
|
+
return remove;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const logger$4 = LibLogger.get('client-api', 'ops', 'find');
|
|
151
|
+
const getFindOperation = (api, apiOptions, utilities)=>{
|
|
152
|
+
const find = async (finder, finderParams, options = {}, locations = [])=>{
|
|
153
|
+
logger$4.default('find', {
|
|
154
|
+
finder,
|
|
155
|
+
finderParams,
|
|
156
|
+
locations
|
|
157
|
+
});
|
|
158
|
+
utilities.verifyLocations(locations);
|
|
159
|
+
const loc = locations;
|
|
160
|
+
const params = finderToParams(finder, finderParams);
|
|
161
|
+
const requestOptions = Object.assign({}, options, {
|
|
162
|
+
isAuthenticated: apiOptions.allAuthenticated,
|
|
163
|
+
params
|
|
164
|
+
});
|
|
165
|
+
return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
|
|
166
|
+
};
|
|
167
|
+
return find;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const getOperations = (api, apiOptions, utilities)=>{
|
|
171
|
+
return {
|
|
172
|
+
action: getActionOperation(api, apiOptions, utilities),
|
|
173
|
+
all: getAllOperation(api, apiOptions, utilities),
|
|
174
|
+
allAction: getAllActionOperation(api, apiOptions, utilities),
|
|
175
|
+
create: getCreateOperation(api, apiOptions, utilities),
|
|
176
|
+
find: getFindOperation(api, apiOptions, utilities),
|
|
177
|
+
get: getGetOperation(api, apiOptions, utilities),
|
|
178
|
+
one: getOneOperation(api, apiOptions, utilities),
|
|
179
|
+
remove: getRemoveOperation(api, apiOptions, utilities),
|
|
180
|
+
update: getUpdateOperation(api, apiOptions, utilities)
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const logger$3 = LibLogger.get('client-api', 'Utility');
|
|
185
|
+
const createUtilities = (pkType, pathNames)=>{
|
|
186
|
+
logger$3.default('createUtilities', {
|
|
187
|
+
pkType,
|
|
188
|
+
pathNames
|
|
189
|
+
});
|
|
190
|
+
const verifyLocations = (locations)=>{
|
|
191
|
+
if (locations && locations.length < pathNames.length - 1) {
|
|
192
|
+
throw new Error('Not enough locations for pathNames: locations:' + locations.length + ' pathNames:' + pathNames.length);
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
};
|
|
196
|
+
const processOne = async (apiCall)=>{
|
|
197
|
+
logger$3.default('processOne', {
|
|
198
|
+
apiCall
|
|
199
|
+
});
|
|
200
|
+
const response = await apiCall;
|
|
201
|
+
logger$3.default('processOne response', {
|
|
202
|
+
response: JSON.stringify(response, null, 2)
|
|
203
|
+
});
|
|
204
|
+
return convertDoc(response);
|
|
205
|
+
};
|
|
206
|
+
const processArray = async (api)=>{
|
|
207
|
+
logger$3.default('processArray', {
|
|
208
|
+
api
|
|
209
|
+
});
|
|
210
|
+
const response = await api;
|
|
211
|
+
logger$3.default('processArray response', {
|
|
212
|
+
response: JSON.stringify(response, null, 2)
|
|
213
|
+
});
|
|
214
|
+
if (response && Array.isArray(response)) {
|
|
215
|
+
return response.map((subjectChat)=>convertDoc(subjectChat));
|
|
216
|
+
} else {
|
|
217
|
+
logger$3.error('Response was not an array', {
|
|
218
|
+
response
|
|
219
|
+
});
|
|
220
|
+
throw new Error('Response was not an array');
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const convertDoc = (doc)=>{
|
|
224
|
+
logger$3.default('convertDoc', {
|
|
225
|
+
doc
|
|
226
|
+
});
|
|
227
|
+
// console.log(JSON.stringify(doc, null, 2));
|
|
228
|
+
if (doc && doc.events) {
|
|
229
|
+
const events = doc.events;
|
|
230
|
+
for(const key in events){
|
|
231
|
+
events[key] = deepmerge(events[key], {
|
|
232
|
+
at: events[key].at ? new Date(events[key].at) : null
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return doc;
|
|
236
|
+
} else {
|
|
237
|
+
return doc;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
const getPath = (key)=>{
|
|
241
|
+
const localPathNames = [
|
|
242
|
+
...pathNames
|
|
243
|
+
];
|
|
244
|
+
logger$3.default('getPath', {
|
|
245
|
+
key,
|
|
246
|
+
pathNames: localPathNames
|
|
247
|
+
});
|
|
248
|
+
// console.log('getPath key: ' + JSON.stringify(key));
|
|
249
|
+
const keys = core.generateKeyArray(key);
|
|
250
|
+
// console.log('getPath keys: ' + JSON.stringify(keys));
|
|
251
|
+
// console.log('getPath pathNames: ' + JSON.stringify(pathNames));
|
|
252
|
+
let path = addPath('', keys, localPathNames);
|
|
253
|
+
// If there is only one collection left in the collections array, this means that
|
|
254
|
+
// we received LocKeys and we need to add the last collection to the reference
|
|
255
|
+
if (localPathNames.length === 1) {
|
|
256
|
+
path = `${path}/${localPathNames[0]}`;
|
|
257
|
+
}
|
|
258
|
+
logger$3.default('getPath created', {
|
|
259
|
+
key,
|
|
260
|
+
path
|
|
261
|
+
});
|
|
262
|
+
return path;
|
|
263
|
+
};
|
|
264
|
+
const addPath = (base, keys, localPathNames)=>{
|
|
265
|
+
logger$3.default('addPath', {
|
|
266
|
+
base,
|
|
267
|
+
keys,
|
|
268
|
+
pathNames: localPathNames
|
|
269
|
+
});
|
|
270
|
+
if (keys.length < localPathNames.length - 1) {
|
|
271
|
+
logger$3.error('addPath should never have keys with a length less than the length of pathNames - 1', {
|
|
272
|
+
keys,
|
|
273
|
+
localPathNames
|
|
274
|
+
});
|
|
275
|
+
throw new Error('addPath should never have keys with a length less than the length of pathNames - 1: ' + keys.length + ' ' + localPathNames.length + ' ' + JSON.stringify(keys, localPathNames));
|
|
276
|
+
} else if (keys.length > localPathNames.length) {
|
|
277
|
+
logger$3.error('addPath should never have keys with a length greater than the length of pathNames', {
|
|
278
|
+
keys,
|
|
279
|
+
pathNames
|
|
280
|
+
});
|
|
281
|
+
throw new Error('addPath should never have keys with a length greater than the length of pathNames: ' + keys.length + ' ' + localPathNames.length + ' ' + JSON.stringify(keys, localPathNames));
|
|
282
|
+
}
|
|
283
|
+
if (keys.length === 0) {
|
|
284
|
+
// If you've recursively consumed all of the keys, return the base.
|
|
285
|
+
logger$3.default('addPath returning base', {
|
|
286
|
+
base
|
|
287
|
+
});
|
|
288
|
+
return base;
|
|
289
|
+
} else {
|
|
290
|
+
// Retrieve the next key and collection, and create the next base
|
|
291
|
+
let nextBase;
|
|
292
|
+
const key = keys.pop();
|
|
293
|
+
const pathName = localPathNames.pop();
|
|
294
|
+
if (core.isPriKey(key)) {
|
|
295
|
+
const PriKey = key;
|
|
296
|
+
nextBase = `${base}/${pathName}/${PriKey.pk}`;
|
|
297
|
+
logger$3.default('Adding Path for PK', {
|
|
298
|
+
pathName,
|
|
299
|
+
PriKey,
|
|
300
|
+
nextBase
|
|
301
|
+
});
|
|
302
|
+
} else {
|
|
303
|
+
const LocKey = key;
|
|
304
|
+
nextBase = `${base}/${pathName}/${LocKey.lk}`;
|
|
305
|
+
logger$3.default('Retrieving Collection for LK', {
|
|
306
|
+
pathName,
|
|
307
|
+
LocKey
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
logger$3.default('calling addPath recursively', {
|
|
311
|
+
nextBase,
|
|
312
|
+
keys,
|
|
313
|
+
localPathNames
|
|
314
|
+
});
|
|
315
|
+
return addPath(nextBase, keys, localPathNames);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
const validatePK = (item)=>{
|
|
319
|
+
return core.validatePK(item, pkType);
|
|
320
|
+
};
|
|
321
|
+
return {
|
|
322
|
+
verifyLocations,
|
|
323
|
+
processOne,
|
|
324
|
+
convertDoc,
|
|
325
|
+
processArray,
|
|
326
|
+
getPath,
|
|
327
|
+
validatePK
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const logger$2 = LibLogger.get('AItemAPI');
|
|
332
|
+
const finderToParams = (finder, finderParams)=>{
|
|
333
|
+
return {
|
|
334
|
+
finder,
|
|
335
|
+
finderParams: JSON.stringify(finderParams)
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
const createAItemAPI = (api, pkType, pathNames, options)=>{
|
|
339
|
+
logger$2.default('createAItemAPI', {
|
|
340
|
+
pkType,
|
|
341
|
+
pathNames,
|
|
342
|
+
options
|
|
343
|
+
});
|
|
344
|
+
let mergedOptions;
|
|
345
|
+
const defaultOptions = {
|
|
346
|
+
readAuthenticated: true,
|
|
347
|
+
allAuthenticated: true,
|
|
348
|
+
writeAuthenticated: true
|
|
349
|
+
};
|
|
350
|
+
if (options) {
|
|
351
|
+
mergedOptions = Object.assign({}, defaultOptions, options);
|
|
352
|
+
} else {
|
|
353
|
+
mergedOptions = defaultOptions;
|
|
354
|
+
}
|
|
355
|
+
const utilities = createUtilities(pkType, pathNames);
|
|
356
|
+
const operations = getOperations(api, mergedOptions, utilities);
|
|
357
|
+
return {
|
|
358
|
+
action: operations.action,
|
|
359
|
+
all: operations.all,
|
|
360
|
+
allAction: operations.allAction,
|
|
361
|
+
create: operations.create,
|
|
362
|
+
find: operations.find,
|
|
363
|
+
get: operations.get,
|
|
364
|
+
one: operations.one,
|
|
365
|
+
remove: operations.remove,
|
|
366
|
+
update: operations.update
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const logger$1 = LibLogger.get('CItemAPI');
|
|
371
|
+
const createCItemApi = (api, type, pathNames, options)=>{
|
|
372
|
+
logger$1.default('createCItemApi', {
|
|
373
|
+
api,
|
|
374
|
+
type,
|
|
375
|
+
pathNames,
|
|
376
|
+
options
|
|
377
|
+
});
|
|
378
|
+
const aItemAPI = createAItemAPI(api, type, pathNames, options);
|
|
379
|
+
return {
|
|
380
|
+
action: aItemAPI.action,
|
|
381
|
+
all: aItemAPI.all,
|
|
382
|
+
allAction: aItemAPI.allAction,
|
|
383
|
+
one: aItemAPI.one,
|
|
384
|
+
get: aItemAPI.get,
|
|
385
|
+
create: aItemAPI.create,
|
|
386
|
+
remove: aItemAPI.remove,
|
|
387
|
+
update: aItemAPI.update,
|
|
388
|
+
find: aItemAPI.find
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const logger = LibLogger.get('PItemAPI');
|
|
393
|
+
const createPItemApi = (api, type, pathName, options)=>{
|
|
394
|
+
logger.default('createPItemApi', {
|
|
395
|
+
type,
|
|
396
|
+
pathName,
|
|
397
|
+
options
|
|
398
|
+
});
|
|
399
|
+
const aItemAPI = createAItemAPI(api, type, [
|
|
400
|
+
pathName
|
|
401
|
+
], options);
|
|
402
|
+
const action = async (ik, action, body = {}, options = {})=>await aItemAPI.action(ik, action, body, options);
|
|
403
|
+
const all = async (query = {}, options = {})=>await aItemAPI.all(query, options, []);
|
|
404
|
+
const allAction = async (action, body = {}, options = {})=>await aItemAPI.allAction(action, body, options, []);
|
|
405
|
+
const one = async (query = {}, options = {})=>await aItemAPI.one(query, options, []);
|
|
406
|
+
const get = async (ik, options = {})=>await aItemAPI.get(ik, options);
|
|
407
|
+
const create = async (item, options = {})=>await aItemAPI.create(item, options, []);
|
|
408
|
+
const remove = async (ik, options = {})=>await aItemAPI.remove(ik, options);
|
|
409
|
+
const update = async (ik, item, options = {})=>await aItemAPI.update(ik, item, options);
|
|
410
|
+
const find = async (finder, finderParams, options = {})=>await aItemAPI.find(finder, finderParams, options, []);
|
|
411
|
+
return {
|
|
412
|
+
...aItemAPI,
|
|
413
|
+
action,
|
|
414
|
+
all,
|
|
415
|
+
allAction,
|
|
416
|
+
one,
|
|
417
|
+
get,
|
|
418
|
+
create,
|
|
419
|
+
remove,
|
|
420
|
+
update,
|
|
421
|
+
find
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
exports.createCItemApi = createCItemApi;
|
|
426
|
+
exports.createPItemApi = createPItemApi;
|
|
427
|
+
//# sourceMappingURL=index.cjs.map
|