@fjell/client-api 4.4.1 → 4.4.3

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.
Files changed (71) hide show
  1. package/dist/AItemAPI.js +8 -1
  2. package/dist/AItemAPI.js.map +1 -1
  3. package/dist/CItemAPI.d.ts +12 -9
  4. package/dist/CItemAPI.js +4 -1
  5. package/dist/CItemAPI.js.map +1 -1
  6. package/dist/ClientApi.d.ts +12 -10
  7. package/dist/ClientApiOptions.d.ts +5 -0
  8. package/dist/PItemAPI.d.ts +13 -10
  9. package/dist/PItemAPI.js +16 -10
  10. package/dist/PItemAPI.js.map +1 -1
  11. package/dist/index.cjs +173 -73
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/ops/action.d.ts +2 -2
  14. package/dist/ops/action.js +6 -5
  15. package/dist/ops/action.js.map +1 -1
  16. package/dist/ops/all.d.ts +2 -2
  17. package/dist/ops/all.js +7 -6
  18. package/dist/ops/all.js.map +1 -1
  19. package/dist/ops/allAction.d.ts +2 -2
  20. package/dist/ops/allAction.js +6 -5
  21. package/dist/ops/allAction.js.map +1 -1
  22. package/dist/ops/allFacet.d.ts +5 -0
  23. package/dist/ops/allFacet.js +24 -0
  24. package/dist/ops/allFacet.js.map +1 -0
  25. package/dist/ops/create.d.ts +2 -2
  26. package/dist/ops/create.js +6 -5
  27. package/dist/ops/create.js.map +1 -1
  28. package/dist/ops/facet.d.ts +5 -0
  29. package/dist/ops/facet.js +34 -0
  30. package/dist/ops/facet.js.map +1 -0
  31. package/dist/ops/find.d.ts +2 -2
  32. package/dist/ops/find.js +10 -9
  33. package/dist/ops/find.js.map +1 -1
  34. package/dist/ops/findOne.d.ts +5 -0
  35. package/dist/ops/findOne.js +27 -0
  36. package/dist/ops/findOne.js.map +1 -0
  37. package/dist/ops/get.d.ts +2 -2
  38. package/dist/ops/get.js +6 -5
  39. package/dist/ops/get.js.map +1 -1
  40. package/dist/ops/index.js +6 -0
  41. package/dist/ops/index.js.map +1 -1
  42. package/dist/ops/one.d.ts +2 -2
  43. package/dist/ops/one.js +7 -6
  44. package/dist/ops/one.js.map +1 -1
  45. package/dist/ops/remove.d.ts +2 -2
  46. package/dist/ops/remove.js +6 -5
  47. package/dist/ops/remove.js.map +1 -1
  48. package/dist/ops/update.d.ts +2 -2
  49. package/dist/ops/update.js +6 -5
  50. package/dist/ops/update.js.map +1 -1
  51. package/dist/util/general.d.ts +4 -0
  52. package/package.json +6 -6
  53. package/src/AItemAPI.ts +17 -9
  54. package/src/CItemAPI.ts +22 -16
  55. package/src/ClientApi.ts +59 -54
  56. package/src/ClientApiOptions.ts +5 -0
  57. package/src/PItemAPI.ts +56 -42
  58. package/src/ops/action.ts +19 -23
  59. package/src/ops/all.ts +17 -19
  60. package/src/ops/allAction.ts +18 -21
  61. package/src/ops/allFacet.ts +46 -0
  62. package/src/ops/create.ts +21 -23
  63. package/src/ops/facet.ts +58 -0
  64. package/src/ops/find.ts +20 -23
  65. package/src/ops/findOne.ts +51 -0
  66. package/src/ops/get.ts +17 -20
  67. package/src/ops/index.ts +80 -61
  68. package/src/ops/one.ts +3 -5
  69. package/src/ops/remove.ts +17 -20
  70. package/src/ops/update.ts +17 -19
  71. package/src/util/general.ts +65 -0
package/dist/AItemAPI.js CHANGED
@@ -19,7 +19,11 @@ const createAItemAPI = (api, pkType, pathNames, options)=>{
19
19
  const defaultOptions = {
20
20
  readAuthenticated: true,
21
21
  allAuthenticated: true,
22
- writeAuthenticated: true
22
+ writeAuthenticated: true,
23
+ getOptions: {},
24
+ postOptions: {},
25
+ putOptions: {},
26
+ deleteOptions: {}
23
27
  };
24
28
  if (options) {
25
29
  mergedOptions = Object.assign({}, defaultOptions, options);
@@ -32,8 +36,11 @@ const createAItemAPI = (api, pkType, pathNames, options)=>{
32
36
  action: operations.action,
33
37
  all: operations.all,
34
38
  allAction: operations.allAction,
39
+ allFacet: operations.allFacet,
35
40
  create: operations.create,
41
+ facet: operations.facet,
36
42
  find: operations.find,
43
+ findOne: operations.findOne,
37
44
  get: operations.get,
38
45
  one: operations.one,
39
46
  remove: operations.remove,
@@ -1 +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;;;;"}
1
+ {"version":3,"file":"AItemAPI.js","sources":["../src/AItemAPI.ts"],"sourcesContent":["/* eslint-disable indent */\nimport { 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 getOptions: {},\n postOptions: {},\n putOptions: {},\n deleteOptions: {},\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 allFacet: operations.allFacet,\n create: operations.create,\n facet: operations.facet,\n find: operations.find,\n findOne: operations.findOne,\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","getOptions","postOptions","putOptions","deleteOptions","Object","assign","utilities","createUtilities","operations","getOperations","action","all","allAction","allFacet","create","facet","find","findOne","one","remove","update"],"mappings":";;;;AAWA,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,CAS5BC,GAAAA,EACAC,QACAC,SACAC,EAAAA,OAAAA,GAAAA;IAGAZ,MAA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,WAAWY;AACrB,KAAA;AACF;;;;"}
@@ -1,16 +1,19 @@
1
1
  import { ComKey, Item, ItemQuery, LocKeyArray, PriKey, TypesProperties } from '@fjell/core';
2
- import { DeleteMethodOptions, GetMethodOptions, HttpApi, PostMethodOptions, PutMethodOptions } from '@fjell/http-api';
2
+ import { HttpApi } from '@fjell/http-api';
3
3
  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?: 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[]>;
7
+ action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any) => Promise<V>;
8
+ all: (query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
9
+ allAction: (action: string, body?: any, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
10
+ allFacet: (facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<any>;
11
+ get: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<V | null>;
12
+ create: (item: TypesProperties<V, S, L1, L2, L3, L4, L5>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
13
+ remove: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<boolean>;
14
+ update: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: TypesProperties<V, S, L1, L2, L3, L4, L5>) => Promise<V>;
15
+ facet: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<any>;
16
+ find: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
17
+ findOne: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
15
18
  }
16
19
  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
@@ -14,12 +14,15 @@ const createCItemApi = (api, type, pathNames, options)=>{
14
14
  action: aItemAPI.action,
15
15
  all: aItemAPI.all,
16
16
  allAction: aItemAPI.allAction,
17
+ allFacet: aItemAPI.allFacet,
17
18
  one: aItemAPI.one,
18
19
  get: aItemAPI.get,
19
20
  create: aItemAPI.create,
20
21
  remove: aItemAPI.remove,
21
22
  update: aItemAPI.update,
22
- find: aItemAPI.find
23
+ facet: aItemAPI.facet,
24
+ find: aItemAPI.find,
25
+ findOne: aItemAPI.findOne
23
26
  };
24
27
  };
25
28
 
@@ -1 +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;;;;"}
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 HttpApi\n} from \"@fjell/http-api\";\nimport { createAItemAPI, PathNamesArray } from \"./AItemAPI\";\n\nimport LibLogger from \"@/logger\";\nimport { ClientApi } from \"./ClientApi\";\nimport { ClientApiOptions } from \"./ClientApiOptions\";\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 ) => Promise<V>;\n all: (\n query: ItemQuery,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ) => Promise<V[]>;\n allAction: (\n action: string,\n body?: any,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ) => Promise<V[]>;\n allFacet: (\n facet: string,\n params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ) => Promise<any>;\n get: (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n ) => Promise<V | null>;\n create: (\n item: TypesProperties<V, S, L1, L2, L3, L4, L5>,\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 ) => 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 ) => Promise<V>;\n facet: (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n facet: string,\n params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n ) => Promise<any>;\n find: (\n finder: string,\n finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ) => Promise<V[]>;\n findOne: (\n finder: string,\n finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\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 allFacet: aItemAPI.allFacet,\n one: aItemAPI.one,\n get: aItemAPI.get,\n create: aItemAPI.create,\n remove: aItemAPI.remove,\n update: aItemAPI.update,\n facet: aItemAPI.facet,\n find: aItemAPI.find,\n findOne: aItemAPI.findOne,\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","allFacet","one","create","remove","update","facet","find","findOne"],"mappings":";;;AAkBA,MAAMA,MAAAA,GAASC,SAAUC,CAAAA,GAAG,CAAC,UAAA,CAAA;AA6DhBC,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,QAAAA,EAAUL,SAASK,QAAQ;AAC3BC,QAAAA,GAAAA,EAAKN,SAASM,GAAG;AACjBb,QAAAA,GAAAA,EAAKO,SAASP,GAAG;AACjBc,QAAAA,MAAAA,EAAQP,SAASO,MAAM;AACvBC,QAAAA,MAAAA,EAAQR,SAASQ,MAAM;AACvBC,QAAAA,MAAAA,EAAQT,SAASS,MAAM;AACvBC,QAAAA,KAAAA,EAAOV,SAASU,KAAK;AACrBC,QAAAA,IAAAA,EAAMX,SAASW,IAAI;AACnBC,QAAAA,OAAAA,EAASZ,SAASY;AACpB,KAAA;AACF;;;;"}
@@ -1,13 +1,15 @@
1
1
  import { ComKey, Item, ItemQuery, LocKeyArray, PriKey, TypesProperties } from '@fjell/core';
2
- import { DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from '@fjell/http-api';
3
2
  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?: 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>;
3
+ action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body?: any) => Promise<V>;
4
+ all: (query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
5
+ allAction: (action: string, body?: any, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
6
+ allFacet: (facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<any>;
7
+ create: (item: TypesProperties<V, S, L1, L2, L3, L4, L5>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
8
+ facet: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<any>;
9
+ find: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
10
+ findOne: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
11
+ get: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<V | null>;
12
+ one: (query: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V | null>;
13
+ remove: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => Promise<boolean>;
14
+ update: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, item: TypesProperties<V, S, L1, L2, L3, L4, L5>) => Promise<V>;
13
15
  }
@@ -1,8 +1,13 @@
1
1
  import { Item } from '@fjell/core';
2
2
  import { ClientApi } from './ClientApi';
3
+ import { DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from '@fjell/http-api';
3
4
  export interface ClientApiOptions {
4
5
  readAuthenticated?: boolean;
5
6
  allAuthenticated?: boolean;
6
7
  writeAuthenticated?: boolean;
7
8
  parentApi?: ClientApi<Item<string, string | never, string | never, string | never, string | never, string | never>, string, string | never, string | never, string | never, string | never, string | never>;
9
+ getOptions?: Partial<GetMethodOptions>;
10
+ postOptions?: Partial<PostMethodOptions>;
11
+ putOptions?: Partial<PutMethodOptions>;
12
+ deleteOptions?: Partial<DeleteMethodOptions>;
8
13
  }
@@ -1,16 +1,19 @@
1
1
  import { ComKey, Item, ItemQuery, PriKey, TypesProperties } from '@fjell/core';
2
- import { HttpApi, DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from '@fjell/http-api';
2
+ import { HttpApi } from '@fjell/http-api';
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?: 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[]>;
6
+ action: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, action: string, body: any) => Promise<V>;
7
+ all: (query: ItemQuery) => Promise<V[]>;
8
+ allAction: (action: string, body?: any) => Promise<V[]>;
9
+ allFacet: (facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<any>;
10
+ one: (query: ItemQuery) => Promise<V | null>;
11
+ get: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>) => Promise<V | null>;
12
+ create: (item: TypesProperties<V, S>) => Promise<V>;
13
+ remove: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>) => Promise<boolean>;
14
+ update: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, item: TypesProperties<V, S>) => Promise<V>;
15
+ facet: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, facet: string, params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<any>;
16
+ find: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<V[]>;
17
+ findOne: (finder: string, finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>) => Promise<V>;
15
18
  }
16
19
  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
@@ -11,26 +11,32 @@ const createPItemApi = (api, type, pathName, options)=>{
11
11
  const aItemAPI = createAItemAPI(api, type, [
12
12
  pathName
13
13
  ], options);
14
- const action = async (ik, action, body = {}, options = {})=>await aItemAPI.action(ik, action, body, options);
15
- const all = async (query = {}, options = {})=>await aItemAPI.all(query, options, []);
16
- const allAction = async (action, body = {}, options = {})=>await aItemAPI.allAction(action, body, options, []);
17
- const one = async (query = {}, options = {})=>await aItemAPI.one(query, options, []);
18
- const get = async (ik, options = {})=>await aItemAPI.get(ik, options);
19
- const create = async (item, options = {})=>await aItemAPI.create(item, options, []);
20
- const remove = async (ik, options = {})=>await aItemAPI.remove(ik, options);
21
- const update = async (ik, item, options = {})=>await aItemAPI.update(ik, item, options);
22
- const find = async (finder, finderParams, options = {})=>await aItemAPI.find(finder, finderParams, options, []);
14
+ const action = async (ik, action, body = {})=>await aItemAPI.action(ik, action, body);
15
+ const all = async (query = {})=>await aItemAPI.all(query, []);
16
+ const allAction = async (action, body = {})=>await aItemAPI.allAction(action, body, []);
17
+ const allFacet = async (facet, params = {})=>await aItemAPI.allFacet(facet, params);
18
+ const one = async (query = {})=>await aItemAPI.one(query, []);
19
+ const get = async (ik)=>await aItemAPI.get(ik);
20
+ const create = async (item)=>await aItemAPI.create(item, []);
21
+ const remove = async (ik)=>await aItemAPI.remove(ik);
22
+ const update = async (ik, item)=>await aItemAPI.update(ik, item);
23
+ const facet = async (ik, facet, params = {})=>await aItemAPI.facet(ik, facet, params);
24
+ const find = async (finder, finderParams = {})=>await aItemAPI.find(finder, finderParams);
25
+ const findOne = async (finder, finderParams = {})=>await aItemAPI.findOne(finder, finderParams);
23
26
  return {
24
27
  ...aItemAPI,
25
28
  action,
26
29
  all,
27
30
  allAction,
31
+ allFacet,
28
32
  one,
29
33
  get,
30
34
  create,
31
35
  remove,
32
36
  update,
33
- find
37
+ facet,
38
+ find,
39
+ findOne
34
40
  };
35
41
  };
36
42
 
@@ -1 +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;A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AAA,OACET,EACAO,EAAAA,IAAAA,EACAZ,OAAqC,GAAA,EAAE,GAEvC,MAAME,QAAAA,CAASY,MAAM,CAACT,IAAIO,IAAMZ,EAAAA,OAAAA,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;;;;"}
1
+ {"version":3,"file":"PItemAPI.js","sources":["../src/PItemAPI.ts"],"sourcesContent":["\nimport { ComKey, Item, ItemQuery, PriKey, TypesProperties } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\nimport { createAItemAPI } from \"./AItemAPI\";\nimport { ClientApi } from \"./ClientApi\";\n\nimport LibLogger from \"@/logger\";\nimport { ClientApiOptions } from \"./ClientApiOptions\";\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 ) => Promise<V>;\n\n all: (\n query: ItemQuery,\n ) => Promise<V[]>;\n\n allAction: (\n action: string,\n body?: any,\n ) => Promise<V[]>;\n\n allFacet: (\n facet: string,\n params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n ) => Promise<any>;\n\n one: (\n query: ItemQuery,\n ) => Promise<V | null>;\n\n get: (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n ) => Promise<V | null>;\n\n create: (\n item: TypesProperties<V, S>,\n ) => Promise<V>;\n\n remove: (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n ) => Promise<boolean>;\n\n update: (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n item: TypesProperties<V, S>,\n ) => Promise<V>;\n\n facet: (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n facet: string,\n params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n ) => Promise<any>;\n\n find: (\n finder: string,\n finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n ) => Promise<V[]>;\n\n findOne: (\n finder: string,\n finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\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 ): Promise<V> =>\n await aItemAPI.action(ik, action, body) as V;\n\n const all =\n async (\n query: ItemQuery = {} as ItemQuery,\n ): Promise<V[]> =>\n await aItemAPI.all(query, []) as V[];\n\n const allAction =\n async (\n action: string,\n body: any = {},\n ): Promise<V[]> =>\n await aItemAPI.allAction(action, body, []) as V[];\n\n const allFacet =\n async (\n facet: string,\n params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n ): Promise<any> =>\n await aItemAPI.allFacet(facet, params) as any;\n\n const one =\n async (\n query: ItemQuery = {} as ItemQuery,\n ): Promise<V | null> =>\n await aItemAPI.one(query, []) as V | null;\n\n const get =\n async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n ): Promise<V | null> =>\n await aItemAPI.get(ik) as V | null;\n\n const create =\n async (\n item: TypesProperties<V, S>,\n ): Promise<V> =>\n await aItemAPI.create(item, []) as V;\n\n const remove =\n async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n ): Promise<boolean> =>\n await aItemAPI.remove(ik) 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 ): Promise<V> =>\n await aItemAPI.update(ik, item) as V;\n\n const facet =\n async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n facet: string,\n params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n ): Promise<any> =>\n await aItemAPI.facet(ik, facet, params) as any;\n\n const find =\n async (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n ): Promise<V[]> =>\n await aItemAPI.find(finder, finderParams) as V[];\n\n const findOne =\n async (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n ): Promise<V> =>\n await aItemAPI.findOne(finder, finderParams) as V;\n\n return {\n ...aItemAPI,\n action,\n all,\n allAction,\n allFacet,\n one,\n get,\n create,\n remove,\n update,\n facet,\n find,\n findOne,\n };\n\n};\n"],"names":["logger","LibLogger","get","createPItemApi","api","type","pathName","options","default","aItemAPI","createAItemAPI","action","ik","body","all","query","allAction","allFacet","facet","params","one","create","item","remove","update","find","finder","finderParams","findOne"],"mappings":";;;AAQA,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;KAAS,EAAEC,OAAAA,CAAAA;AAE7D,IAAA,MAAMI,M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