@fjell/client-api 4.2.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.
Files changed (76) hide show
  1. package/LICENSE +202 -0
  2. package/dist/src/AItemAPI.d.ts +34 -0
  3. package/dist/src/AItemAPI.js +39 -0
  4. package/dist/src/AItemAPI.js.map +1 -0
  5. package/dist/src/CItemAPI.d.ts +16 -0
  6. package/dist/src/CItemAPI.js +20 -0
  7. package/dist/src/CItemAPI.js.map +1 -0
  8. package/dist/src/ClientApi.d.ts +13 -0
  9. package/dist/src/ClientApi.js +2 -0
  10. package/dist/src/ClientApi.js.map +1 -0
  11. package/dist/src/ClientApiOptions.d.ts +8 -0
  12. package/dist/src/ClientApiOptions.js +2 -0
  13. package/dist/src/ClientApiOptions.js.map +1 -0
  14. package/dist/src/PItemAPI.d.ts +17 -0
  15. package/dist/src/PItemAPI.js +30 -0
  16. package/dist/src/PItemAPI.js.map +1 -0
  17. package/dist/src/Utilities.d.ts +10 -0
  18. package/dist/src/Utilities.js +110 -0
  19. package/dist/src/Utilities.js.map +1 -0
  20. package/dist/src/index.d.ts +4 -0
  21. package/dist/src/index.js +3 -0
  22. package/dist/src/index.js.map +1 -0
  23. package/dist/src/logger.d.ts +2 -0
  24. package/dist/src/logger.js +4 -0
  25. package/dist/src/logger.js.map +1 -0
  26. package/dist/src/ops/action.d.ts +5 -0
  27. package/dist/src/ops/action.js +11 -0
  28. package/dist/src/ops/action.js.map +1 -0
  29. package/dist/src/ops/all.d.ts +6 -0
  30. package/dist/src/ops/all.js +15 -0
  31. package/dist/src/ops/all.js.map +1 -0
  32. package/dist/src/ops/allAction.d.ts +5 -0
  33. package/dist/src/ops/allAction.js +14 -0
  34. package/dist/src/ops/allAction.js.map +1 -0
  35. package/dist/src/ops/create.d.ts +5 -0
  36. package/dist/src/ops/create.js +14 -0
  37. package/dist/src/ops/create.js.map +1 -0
  38. package/dist/src/ops/find.d.ts +5 -0
  39. package/dist/src/ops/find.js +15 -0
  40. package/dist/src/ops/find.js.map +1 -0
  41. package/dist/src/ops/get.d.ts +5 -0
  42. package/dist/src/ops/get.js +11 -0
  43. package/dist/src/ops/get.js.map +1 -0
  44. package/dist/src/ops/index.d.ts +6 -0
  45. package/dist/src/ops/index.js +23 -0
  46. package/dist/src/ops/index.js.map +1 -0
  47. package/dist/src/ops/one.d.ts +5 -0
  48. package/dist/src/ops/one.js +20 -0
  49. package/dist/src/ops/one.js.map +1 -0
  50. package/dist/src/ops/remove.d.ts +5 -0
  51. package/dist/src/ops/remove.js +11 -0
  52. package/dist/src/ops/remove.js.map +1 -0
  53. package/dist/src/ops/update.d.ts +5 -0
  54. package/dist/src/ops/update.js +11 -0
  55. package/dist/src/ops/update.js.map +1 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -0
  57. package/eslint.config.mjs +70 -0
  58. package/package.json +51 -0
  59. package/src/AItemAPI.ts +87 -0
  60. package/src/CItemAPI.ts +107 -0
  61. package/src/ClientApi.ts +59 -0
  62. package/src/ClientApiOptions.ts +17 -0
  63. package/src/PItemAPI.ts +171 -0
  64. package/src/Utilities.ts +183 -0
  65. package/src/index.ts +4 -0
  66. package/src/logger.ts +5 -0
  67. package/src/ops/action.ts +52 -0
  68. package/src/ops/all.ts +52 -0
  69. package/src/ops/allAction.ts +53 -0
  70. package/src/ops/create.ts +50 -0
  71. package/src/ops/find.ts +52 -0
  72. package/src/ops/get.ts +45 -0
  73. package/src/ops/index.ts +77 -0
  74. package/src/ops/one.ts +64 -0
  75. package/src/ops/remove.ts +41 -0
  76. package/src/ops/update.ts +47 -0
@@ -0,0 +1,15 @@
1
+ import { queryToParams, } from "@fjell/core";
2
+ import LibLogger from "../logger";
3
+ const logger = LibLogger.get('client-api', 'ops', 'all');
4
+ export const getAllOperation = (api, apiOptions, utilities) => {
5
+ const all = async (query = {}, options = {}, locations = []) => {
6
+ logger.default('all', { query, locations });
7
+ utilities.verifyLocations(locations);
8
+ const loc = locations;
9
+ const params = queryToParams(query);
10
+ const requestOptions = Object.assign({}, options, { isAuthenticated: apiOptions.allAuthenticated, params });
11
+ return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
12
+ };
13
+ return all;
14
+ };
15
+ //# sourceMappingURL=all.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"all.js","sourceRoot":"","sources":["../../../src/ops/all.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,GACd,MAAM,aAAa,CAAC;AAIrB,OAAO,SAAS,MAAM,UAAU,CAAC;AAIjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG,CAQ3B,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAE9C,EAAE;IAEJ,MAAM,GAAG,GAAG,KAAK,EACf,QAAmB,EAAe,EAClC,UAAqC,EAAE,EACvC,YAAkD,EAAE,EACtC,EAAE;QAChB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC5C,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACrC,MAAM,GAAG,GAAyC,SAAS,CAAC;QAE5D,MAAM,MAAM,GAAgB,aAAa,CAAC,KAAK,CAAC,CAAC;QAEjD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC;QAE5G,OAAO,SAAS,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,YAAY,CACtD,GAAG,CAAC,OAAO,CACT,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EACtB,cAAc,CACf,CAAC,CAAQ,CAAC;IACf,CAAC,CAAA;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Item, LocKeyArray } from "@fjell/core";
2
+ import { HttpApi, PostMethodOptions } from "@fjell/http-api";
3
+ import { ClientApiOptions } from "../ClientApiOptions";
4
+ import { Utilities } from "../Utilities";
5
+ export declare const getAllActionOperation: <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>(api: HttpApi, apiOptions: ClientApiOptions, utilities: Utilities<V, S, L1, L2, L3, L4, L5>) => (action: string, body?: any, options?: Partial<PostMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
@@ -0,0 +1,14 @@
1
+ import LibLogger from "../logger";
2
+ const logger = LibLogger.get('client-api', 'ops', 'allAction');
3
+ export const getAllActionOperation = (api, apiOptions, utilities) => {
4
+ const allAction = async (action, body = {}, options = {}, locations = []) => {
5
+ logger.default('allAction', { action, body, locations });
6
+ utilities.verifyLocations(locations);
7
+ const loc = locations;
8
+ const requestOptions = Object.assign({}, options, { isAuthenticated: apiOptions.writeAuthenticated });
9
+ // TODO: This should respond to either a single object, or multiple objects in an array.
10
+ return utilities.validatePK(await utilities.processArray(api.httpPost(utilities.getPath(loc), body, requestOptions)));
11
+ };
12
+ return allAction;
13
+ };
14
+ //# sourceMappingURL=allAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allAction.js","sourceRoot":"","sources":["../../../src/ops/allAction.ts"],"names":[],"mappings":"AAOA,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAQjC,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAE9C,EAAE;IAEJ,MAAM,SAAS,GAAG,KAAK,EACrB,MAAc,EACd,OAAY,EAAE,EACd,UAAsC,EAAE,EACxC,YAAkD,EAAE,EACtC,EAAE;QAChB,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACzD,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAErC,MAAM,GAAG,GAAyC,SAAS,CAAC;QAE5D,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAEtG,wFAAwF;QACxF,OAAO,SAAS,CAAC,UAAU,CACzB,MAAM,SAAS,CAAC,YAAY,CAC1B,GAAG,CAAC,QAAQ,CACV,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EACtB,IAAI,EACJ,cAAc,CACf,CACF,CAAQ,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Item, ItemProperties, LocKeyArray } from "@fjell/core";
2
+ import { HttpApi, PostMethodOptions } from "@fjell/http-api";
3
+ import { ClientApiOptions } from "../ClientApiOptions";
4
+ import { Utilities } from "../Utilities";
5
+ export declare const getCreateOperation: <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>(api: HttpApi, apiOptions: ClientApiOptions, utilities: Utilities<V, S, L1, L2, L3, L4, L5>) => (item: ItemProperties<S, L1, L2, L3, L4, L5>, options?: Partial<PostMethodOptions>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V>;
@@ -0,0 +1,14 @@
1
+ import LibLogger from "../logger";
2
+ const logger = LibLogger.get('client-api', 'ops', 'create');
3
+ export const getCreateOperation = (api, apiOptions, utilities) => {
4
+ const create = async (item, options = {}, locations = []) => {
5
+ logger.default('create', { item, locations });
6
+ utilities.verifyLocations(locations);
7
+ const loc = locations;
8
+ const requestOptions = Object.assign({}, options, { isAuthenticated: apiOptions.writeAuthenticated });
9
+ const created = utilities.validatePK(await utilities.processOne(api.httpPost(utilities.getPath(loc), item, requestOptions)));
10
+ return created;
11
+ };
12
+ return create;
13
+ };
14
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/ops/create.ts"],"names":[],"mappings":"AAQA,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAQ9B,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAE9C,EAAE;IAEJ,MAAM,MAAM,GAAG,KAAK,EAClB,IAA2C,EAC3C,UAAsC,EAAE,EACxC,YAAkD,EAAE,EACxC,EAAE;QACd,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC9C,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAErC,MAAM,GAAG,GAAyC,SAAS,CAAC;QAC5D,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAEtG,MAAM,OAAO,GACT,SAAS,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAC1D,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EACtB,IAAI,EACJ,cAAc,CACf,CAAC,CAAM,CAAC;QACb,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Item, LocKeyArray } from "@fjell/core";
2
+ import { GetMethodOptions, HttpApi } from "@fjell/http-api";
3
+ import { ClientApiOptions } from "../ClientApiOptions";
4
+ import { Utilities } from "../Utilities";
5
+ export declare const getFindOperation: <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>(api: HttpApi, apiOptions: ClientApiOptions, utilities: Utilities<V, S, L1, L2, L3, L4, L5>) => (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[]>;
@@ -0,0 +1,15 @@
1
+ import { finderToParams } from "../AItemAPI";
2
+ import LibLogger from "../logger";
3
+ const logger = LibLogger.get('client-api', 'ops', 'find');
4
+ export const getFindOperation = (api, apiOptions, utilities) => {
5
+ const find = async (finder, finderParams, options = {}, locations = []) => {
6
+ logger.default('find', { finder, finderParams, locations });
7
+ utilities.verifyLocations(locations);
8
+ const loc = locations;
9
+ const params = finderToParams(finder, finderParams);
10
+ const requestOptions = Object.assign({}, options, { isAuthenticated: apiOptions.allAuthenticated, params });
11
+ return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
12
+ };
13
+ return find;
14
+ };
15
+ //# sourceMappingURL=find.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find.js","sourceRoot":"","sources":["../../../src/ops/find.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAQ5B,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAE9C,EAAE;IAEJ,MAAM,IAAI,GAAG,KAAK,EAChB,MAAc,EACd,YAAwG,EACxG,UAAqC,EAAE,EACvC,YAAkD,EAAE,EACtC,EAAE;QAChB,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC;QAC5D,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACrC,MAAM,GAAG,GAAyC,SAAS,CAAC;QAE5D,MAAM,MAAM,GAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAEjE,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC;QAE5G,OAAO,SAAS,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,YAAY,CACtD,GAAG,CAAC,OAAO,CACT,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EACtB,cAAc,CACf,CAAC,CAAQ,CAAC;IACf,CAAC,CAAA;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ComKey, Item, PriKey } from "@fjell/core";
2
+ import { GetMethodOptions, HttpApi } from "@fjell/http-api";
3
+ import { ClientApiOptions } from "../ClientApiOptions";
4
+ import { Utilities } from "../Utilities";
5
+ export declare const getGetOperation: <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>(api: HttpApi, apiOptions: ClientApiOptions, utilities: Utilities<V, S, L1, L2, L3, L4, L5>) => (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, options?: Partial<GetMethodOptions>) => Promise<V | null>;
@@ -0,0 +1,11 @@
1
+ import LibLogger from "../logger";
2
+ const logger = LibLogger.get('client-api', 'ops', 'get');
3
+ export const getGetOperation = (api, apiOptions, utilities) => {
4
+ const get = async (ik, options = {}) => {
5
+ logger.default('get', { ik });
6
+ const requestOptions = Object.assign({}, options, { isAuthenticated: apiOptions.readAuthenticated });
7
+ return utilities.validatePK(await utilities.processOne(api.httpGet(utilities.getPath(ik), requestOptions)));
8
+ };
9
+ return get;
10
+ };
11
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/ops/get.ts"],"names":[],"mappings":"AAQA,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG,CAQ3B,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAE9C,EAAE;IAEJ,MAAM,GAAG,GAAG,KAAK,EACf,EAA4D,EAC5D,UAAqC,EAAE,EACpB,EAAE;QACrB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAE9B,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAErG,OAAO,SAAS,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,UAAU,CACpD,GAAG,CAAC,OAAO,CACT,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EACrB,cAAc,CACf,CAAC,CAAM,CAAC;IACb,CAAC,CAAA;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { Item } from "@fjell/core";
2
+ import { Utilities } from "../Utilities";
3
+ import { HttpApi } from "@fjell/http-api";
4
+ import { ClientApiOptions } from "../ClientApiOptions";
5
+ import { ClientApi } from "../ClientApi";
6
+ export declare const getOperations: <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>(api: HttpApi, apiOptions: ClientApiOptions, utilities: Utilities<V, S, L1, L2, L3, L4, L5>) => ClientApi<V, S, L1, L2, L3, L4, L5>;
@@ -0,0 +1,23 @@
1
+ import { getAllOperation } from "./all";
2
+ import { getActionOperation } from "./action";
3
+ import { getAllActionOperation } from "./allAction";
4
+ import { getOneOperation } from "./one";
5
+ import { getCreateOperation } from "./create";
6
+ import { getUpdateOperation } from "./update";
7
+ import { getGetOperation } from "./get";
8
+ import { getRemoveOperation } from "./remove";
9
+ import { getFindOperation } from "./find";
10
+ export const getOperations = (api, apiOptions, utilities) => {
11
+ return {
12
+ action: getActionOperation(api, apiOptions, utilities),
13
+ all: getAllOperation(api, apiOptions, utilities),
14
+ allAction: getAllActionOperation(api, apiOptions, utilities),
15
+ create: getCreateOperation(api, apiOptions, utilities),
16
+ find: getFindOperation(api, apiOptions, utilities),
17
+ get: getGetOperation(api, apiOptions, utilities),
18
+ one: getOneOperation(api, apiOptions, utilities),
19
+ remove: getRemoveOperation(api, apiOptions, utilities),
20
+ update: getUpdateOperation(api, apiOptions, utilities),
21
+ };
22
+ };
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ops/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAIzC,MAAM,CAAC,MAAM,aAAa,GAC1B,CAQI,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAET,EAAE;IACzC,OAAO;QACL,MAAM,EAAE,kBAAkB,CACxB,GAAG,EACH,UAAU,EACV,SAAS,CACV;QACD,GAAG,EAAE,eAAe,CAClB,GAAG,EACH,UAAU,EACV,SAAS,CACV;QACD,SAAS,EAAE,qBAAqB,CAC9B,GAAG,EACH,UAAU,EACV,SAAS,CACV;QACD,MAAM,EAAE,kBAAkB,CACxB,GAAG,EACH,UAAU,EACV,SAAS,CACV;QACD,IAAI,EAAE,gBAAgB,CACpB,GAAG,EACH,UAAU,EACV,SAAS,CACV;QACD,GAAG,EAAE,eAAe,CAClB,GAAG,EACH,UAAU,EACV,SAAS,CACV;QACD,GAAG,EAAE,eAAe,CAClB,GAAG,EACH,UAAU,EACV,SAAS,CACV;QACD,MAAM,EAAE,kBAAkB,CACxB,GAAG,EACH,UAAU,EACV,SAAS,CACV;QACD,MAAM,EAAE,kBAAkB,CACxB,GAAG,EACH,UAAU,EACV,SAAS,CACV;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Item, ItemQuery, LocKeyArray } from "@fjell/core";
2
+ import { GetMethodOptions, HttpApi } from "@fjell/http-api";
3
+ import { ClientApiOptions } from "../ClientApiOptions";
4
+ import { Utilities } from "../Utilities";
5
+ export declare const getOneOperation: <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>(api: HttpApi, apiOptions: ClientApiOptions, utilities: Utilities<V, S, L1, L2, L3, L4, L5>) => (query: ItemQuery, options: Partial<GetMethodOptions>, locations: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V | null>;
@@ -0,0 +1,20 @@
1
+ import { queryToParams } from "@fjell/core";
2
+ import LibLogger from "../logger";
3
+ const logger = LibLogger.get('client-api', 'ops', 'one');
4
+ export const getOneOperation = (api, apiOptions, utilities) => {
5
+ const one = async (query = {}, options = {}, locations) => {
6
+ logger.default('one', { query, locations });
7
+ utilities.verifyLocations(locations);
8
+ const loc = locations;
9
+ const params = queryToParams(query);
10
+ const requestOptions = Object.assign({}, options, { isAuthenticated: apiOptions.readAuthenticated, params });
11
+ let item = null;
12
+ const items = utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
13
+ if (items.length > 0) {
14
+ item = items[0];
15
+ }
16
+ return item;
17
+ };
18
+ return one;
19
+ };
20
+ //# sourceMappingURL=one.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one.js","sourceRoot":"","sources":["../../../src/ops/one.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,aAAa,EACd,MAAM,aAAa,CAAC;AAIrB,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG,CAQ3B,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAMzB,EAAE;IAEzB,MAAM,GAAG,GAAG,KAAK,EACf,QAAmB,EAAe,EAClC,UAAqC,EAAE,EACvC,SAA+C,EAC5B,EAAE;QACrB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC5C,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAErC,MAAM,GAAG,GAAyC,SAAS,CAAC;QAE5D,MAAM,MAAM,GAAgB,aAAa,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC,CAAC;QAE7G,IAAI,IAAI,GAAa,IAAI,CAAC;QAE1B,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,YAAY,CAC7D,GAAG,CAAC,OAAO,CACT,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EACtB,cAAc,CACf,CAAC,CAAQ,CAAC;QAEb,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,IAAS,CAAC;IACnB,CAAC,CAAA;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ComKey, Item, PriKey } from "@fjell/core";
2
+ import { DeleteMethodOptions, HttpApi } from "@fjell/http-api";
3
+ import { ClientApiOptions } from "../ClientApiOptions";
4
+ import { Utilities } from "../Utilities";
5
+ export declare const getRemoveOperation: <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>(api: HttpApi, apiOptions: ClientApiOptions, utilities: Utilities<V, S, L1, L2, L3, L4, L5>) => (ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, options?: Partial<DeleteMethodOptions>) => Promise<boolean>;
@@ -0,0 +1,11 @@
1
+ import LibLogger from "../logger";
2
+ const logger = LibLogger.get('client-api', 'ops', 'remove');
3
+ export const getRemoveOperation = (api, apiOptions, utilities) => {
4
+ const remove = async (ik, options = {}) => {
5
+ logger.default('remove', { ik });
6
+ const requestOptions = Object.assign({}, options, { isAuthenticated: apiOptions.writeAuthenticated });
7
+ return api.httpDelete(utilities.getPath(ik), requestOptions);
8
+ };
9
+ return remove;
10
+ };
11
+ //# sourceMappingURL=remove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../src/ops/remove.ts"],"names":[],"mappings":"AAQA,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAQ9B,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAE9C,EAAE;IAEJ,MAAM,MAAM,GAAG,KAAK,EAClB,EAA6C,EAC7C,UAAwC,EAAE,EACxB,EAAE;QACpB,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAEjC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAEtG,OAAO,GAAG,CAAC,UAAU,CAAU,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC;IACxE,CAAC,CAAA;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ComKey, Item, ItemProperties, PriKey } from "@fjell/core";
2
+ import { HttpApi, PutMethodOptions } from "@fjell/http-api";
3
+ import { ClientApiOptions } from "../ClientApiOptions";
4
+ import { Utilities } from "../Utilities";
5
+ export declare const getUpdateOperation: <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>(api: HttpApi, apiOptions: ClientApiOptions, utilities: Utilities<V, S, L1, L2, L3, L4, L5>) => (ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, item: ItemProperties<S, L1, L2, L3, L4, L5>, options?: Partial<PutMethodOptions>) => Promise<V>;
@@ -0,0 +1,11 @@
1
+ import LibLogger from "../logger";
2
+ const logger = LibLogger.get('client-api', 'ops', 'update');
3
+ export const getUpdateOperation = (api, apiOptions, utilities) => {
4
+ const update = async (ik, item, options = {}) => {
5
+ logger.default('update', { ik, item });
6
+ const requestOptions = Object.assign({}, options, { isAuthenticated: apiOptions.writeAuthenticated });
7
+ return utilities.validatePK(await utilities.processOne(api.httpPut(utilities.getPath(ik), item, requestOptions)));
8
+ };
9
+ return update;
10
+ };
11
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/ops/update.ts"],"names":[],"mappings":"AASA,OAAO,SAAS,MAAM,UAAU,CAAC;AAGjC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAQ9B,GAAY,EACZ,UAA4B,EAC5B,SAA8C,EAE9C,EAAE;IAEJ,MAAM,MAAM,GAAG,KAAK,EAClB,EAA6C,EAC7C,IAA2C,EAC3C,UAAqC,EAAE,EAC3B,EAAE;QACd,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAEtG,OAAO,SAAS,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,UAAU,CACpD,GAAG,CAAC,OAAO,CACT,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EACrB,IAAI,EACJ,cAAc,CACf,CAAC,CAAM,CAAC;IACb,CAAC,CAAA;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ {"root":["../src/AItemAPI.ts","../src/CItemAPI.ts","../src/ClientApi.ts","../src/ClientApiOptions.ts","../src/PItemAPI.ts","../src/Utilities.ts","../src/index.ts","../src/logger.ts","../src/ops/action.ts","../src/ops/all.ts","../src/ops/allAction.ts","../src/ops/create.ts","../src/ops/find.ts","../src/ops/get.ts","../src/ops/index.ts","../src/ops/one.ts","../src/ops/remove.ts","../src/ops/update.ts","../tests/AItemAPI.test.ts","../tests/CItemAPI.test.ts","../tests/PItemAPI.test.ts","../tests/Utilities.test.ts","../tests/noop.test.ts"],"version":"5.7.3"}
@@ -0,0 +1,70 @@
1
+ import typescriptEslint from "@typescript-eslint/eslint-plugin";
2
+ import tsParser from "@typescript-eslint/parser";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import js from "@eslint/js";
6
+ import { FlatCompat } from "@eslint/eslintrc";
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ const compat = new FlatCompat({
11
+ baseDirectory: __dirname,
12
+ recommendedConfig: js.configs.recommended,
13
+ allConfig: js.configs.all
14
+ });
15
+
16
+ export default [{
17
+ ignores: ["**/dist", "**/node_modules"],
18
+ }, ...compat.extends("plugin:@typescript-eslint/recommended"), {
19
+ plugins: {
20
+ "@typescript-eslint": typescriptEslint,
21
+ },
22
+
23
+ languageOptions: {
24
+ parser: tsParser,
25
+ },
26
+
27
+ rules: {
28
+ "@typescript-eslint/no-unused-expressions": "off",
29
+ "no-console": 0,
30
+ "no-unused-vars": "off",
31
+
32
+ "max-len": ["error", {
33
+ code: 120,
34
+ }],
35
+
36
+ "max-depth": ["error", 4],
37
+ "max-params": ["error", 4],
38
+ "max-lines": ["error", 500],
39
+
40
+ "no-multiple-empty-lines": ["error", {
41
+ max: 1,
42
+ maxEOF: 1,
43
+ }],
44
+
45
+ "no-trailing-spaces": ["error", {
46
+ skipBlankLines: true,
47
+ }],
48
+
49
+ indent: ["error", 2, {
50
+ SwitchCase: 1,
51
+ }],
52
+
53
+ "sort-imports": ["error", {
54
+ ignoreCase: true,
55
+ ignoreDeclarationSort: true,
56
+ ignoreMemberSort: false,
57
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
58
+ }],
59
+
60
+ "no-var": "error",
61
+ "no-undefined": "error",
62
+ "@typescript-eslint/no-unused-vars": "error",
63
+ "@typescript-eslint/ban-ts-comment": "off",
64
+ "@typescript-eslint/no-explicit-any": "off",
65
+
66
+ "no-restricted-imports": ["error", {
67
+ patterns: ["..*", "src/*"],
68
+ }],
69
+ },
70
+ }];
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@fjell/client-api",
3
+ "description": "Client API for Fjell",
4
+ "version": "4.2.1",
5
+ "license": "Apache-2.0",
6
+ "main": "./dist/src/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/src/index.d.ts",
10
+ "require": "./dist/src/index.js",
11
+ "default": "./dist/src/index.js"
12
+ }
13
+ },
14
+ "type": "module",
15
+ "scripts": {
16
+ "lint": "eslint .",
17
+ "dev": "concurrently \"tsc --watch\" \"tsc-alias -w\"",
18
+ "build": "yarn run lint && tsc --build --verbose --force && tsc-alias -p tsconfig.json",
19
+ "clean": "rimraf dist",
20
+ "test": "yarn run lint && NODE_OPTIONS='--experimental-require-module' yarn run jest --coverage"
21
+ },
22
+ "devDependencies": {
23
+ "@babel/core": "^7.26.9",
24
+ "@babel/preset-env": "^7.26.9",
25
+ "@babel/preset-typescript": "^7.26.0",
26
+ "@jest/globals": "^29.7.0",
27
+ "@tsconfig/recommended": "^1.0.8",
28
+ "@types/jest": "^29.5.14",
29
+ "@types/luxon": "^3.4.2",
30
+ "@typescript-eslint/eslint-plugin": "^8.24.1",
31
+ "@typescript-eslint/parser": "^8.24.1",
32
+ "babel-jest": "^29.7.0",
33
+ "concurrently": "^9.1.2",
34
+ "eslint": "^9.21.0",
35
+ "jest": "^29.7.0",
36
+ "rimraf": "^6.0.1",
37
+ "ts-jest": "^29.2.5",
38
+ "tsc-alias": "^1.8.10",
39
+ "typescript": "^5.7.3"
40
+ },
41
+ "dependencies": {
42
+ "@fjell/core": "^4.3.1",
43
+ "@fjell/http-api": "^4.3.0",
44
+ "@fjell/logging": "^4.3.4"
45
+ },
46
+ "packageManager": "yarn@4.6.0",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/getfjell/client-api.git"
50
+ }
51
+ }
@@ -0,0 +1,87 @@
1
+ import { Item, QueryParams } from "@fjell/core";
2
+ import { HttpApi } from "@fjell/http-api";
3
+
4
+ import { ClientApiOptions } from "./ClientApiOptions";
5
+ import { getOperations } from "./ops";
6
+ import { createUtilities } from "./Utilities";
7
+ import { ClientApi } from "./ClientApi";
8
+
9
+ import LibLogger from "@/logger";
10
+
11
+ const logger = LibLogger.get('AItemAPI');
12
+
13
+ export type PathNamesArray<
14
+ L1 extends string = never,
15
+ L2 extends string = never,
16
+ L3 extends string = never,
17
+ L4 extends string = never,
18
+ L5 extends string = never
19
+ > =
20
+ ([L5] extends [never] ?
21
+ ([L4] extends [never] ?
22
+ ([L3] extends [never] ?
23
+ ([L2] extends [never] ?
24
+ ([L1] extends [never] ?
25
+ [string] :
26
+ [string, string]) :
27
+ [string, string, string]) :
28
+ [string, string, string, string]) :
29
+ [string, string, string, string, string]) :
30
+ [string, string, string, string, string, string]);
31
+
32
+ export const finderToParams = (
33
+ finder: string,
34
+ finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>
35
+ ): QueryParams => {
36
+ return {
37
+ finder,
38
+ finderParams: JSON.stringify(finderParams),
39
+ };
40
+ };
41
+
42
+ export const createAItemAPI = <
43
+ V extends Item<S, L1, L2, L3, L4, L5>,
44
+ S extends string,
45
+ L1 extends string = never,
46
+ L2 extends string = never,
47
+ L3 extends string = never,
48
+ L4 extends string = never,
49
+ L5 extends string = never
50
+ >(
51
+ api: HttpApi,
52
+ pkType: S,
53
+ pathNames: PathNamesArray<L1, L2, L3, L4, L5>,
54
+ options?: ClientApiOptions,
55
+ ): ClientApi<V, S, L1, L2, L3, L4, L5> => {
56
+
57
+ logger.default('createAItemAPI', { pkType, pathNames, options });
58
+
59
+ let mergedOptions: ClientApiOptions;
60
+
61
+ const defaultOptions: ClientApiOptions = {
62
+ readAuthenticated: true,
63
+ allAuthenticated: true,
64
+ writeAuthenticated: true,
65
+ };
66
+
67
+ if (options) {
68
+ mergedOptions = Object.assign({}, defaultOptions, options);
69
+ } else {
70
+ mergedOptions = defaultOptions;
71
+ }
72
+
73
+ const utilities = createUtilities<V, S, L1, L2, L3, L4, L5>(pkType, pathNames);
74
+ const operations = getOperations<V, S, L1, L2, L3, L4, L5>(api, mergedOptions, utilities);
75
+
76
+ return {
77
+ action: operations.action,
78
+ all: operations.all,
79
+ allAction: operations.allAction,
80
+ create: operations.create,
81
+ find: operations.find,
82
+ get: operations.get,
83
+ one: operations.one,
84
+ remove: operations.remove,
85
+ update: operations.update,
86
+ }
87
+ }
@@ -0,0 +1,107 @@
1
+
2
+ import {
3
+ ComKey,
4
+ Item,
5
+ ItemQuery,
6
+ LocKeyArray,
7
+ PriKey,
8
+ TypesProperties
9
+ } from "@fjell/core";
10
+ import {
11
+ DeleteMethodOptions,
12
+ GetMethodOptions,
13
+ HttpApi,
14
+ PostMethodOptions,
15
+ PutMethodOptions,
16
+ } from "@fjell/http-api";
17
+ import { createAItemAPI, PathNamesArray } from "./AItemAPI";
18
+
19
+ import { ClientApi } from "./ClientApi";
20
+ import { ClientApiOptions } from "./ClientApiOptions";
21
+ import LibLogger from "@/logger";
22
+
23
+ const logger = LibLogger.get('CItemAPI');
24
+
25
+ export interface CItemApi<
26
+ V extends Item<S, L1, L2, L3, L4, L5>,
27
+ S extends string,
28
+ L1 extends string,
29
+ L2 extends string = never,
30
+ L3 extends string = never,
31
+ L4 extends string = never,
32
+ L5 extends string = never
33
+ > extends ClientApi<V, S, L1, L2, L3, L4, L5> {
34
+ action: (
35
+ ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
36
+ action: string,
37
+ body: any,
38
+ options: Partial<PostMethodOptions>
39
+ ) => Promise<V>;
40
+ all: (
41
+ query: ItemQuery,
42
+ options: Partial<GetMethodOptions>,
43
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
44
+ ) => Promise<V[]>;
45
+ allAction: (
46
+ action: string,
47
+ body: any,
48
+ options: Partial<PostMethodOptions>,
49
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
50
+ ) => Promise<V[]>;
51
+ get: (
52
+ ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
53
+ options: Partial<GetMethodOptions>,
54
+ ) => Promise<V | null>;
55
+ create: (
56
+ item: TypesProperties<V, S, L1, L2, L3, L4, L5>,
57
+ options: Partial<PostMethodOptions>,
58
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
59
+ ) => Promise<V>;
60
+ remove: (
61
+ ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
62
+ options: Partial<DeleteMethodOptions>
63
+ ) => Promise<boolean>;
64
+ update: (
65
+ ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
66
+ item: TypesProperties<V, S, L1, L2, L3, L4, L5>,
67
+ options: Partial<PutMethodOptions>
68
+ ) => Promise<V>;
69
+ find: (
70
+ finder: string,
71
+ finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
72
+ options: Partial<GetMethodOptions>,
73
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
74
+ ) => Promise<V[]>;
75
+ };
76
+
77
+ export const createCItemApi = <
78
+ V extends Item<S, L1, L2, L3, L4, L5>,
79
+ S extends string,
80
+ L1 extends string,
81
+ L2 extends string = never,
82
+ L3 extends string = never,
83
+ L4 extends string = never,
84
+ L5 extends string = never
85
+ >(
86
+ api: HttpApi,
87
+ type: S,
88
+ pathNames: PathNamesArray<L1, L2, L3, L4, L5>,
89
+ options: ClientApiOptions
90
+ ): CItemApi<V, S, L1, L2, L3, L4, L5> => {
91
+
92
+ logger.default('createCItemApi', { api, type, pathNames, options });
93
+
94
+ const aItemAPI = createAItemAPI(api, type, pathNames, options);
95
+
96
+ return {
97
+ action: aItemAPI.action,
98
+ all: aItemAPI.all,
99
+ allAction: aItemAPI.allAction,
100
+ one: aItemAPI.one,
101
+ get: aItemAPI.get,
102
+ create: aItemAPI.create,
103
+ remove: aItemAPI.remove,
104
+ update: aItemAPI.update,
105
+ find: aItemAPI.find,
106
+ } as unknown as CItemApi<V, S, L1, L2, L3, L4, L5>;
107
+ }
@@ -0,0 +1,59 @@
1
+ import { ComKey, Item, ItemQuery, LocKeyArray, PriKey, TypesProperties } from "@fjell/core";
2
+ import { DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from "@fjell/http-api";
3
+
4
+ export interface ClientApi<
5
+ V extends Item<S, L1, L2, L3, L4, L5>,
6
+ S extends string,
7
+ L1 extends string = never,
8
+ L2 extends string = never,
9
+ L3 extends string = never,
10
+ L4 extends string = never,
11
+ L5 extends string = never
12
+ > {
13
+ action: (
14
+ ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
15
+ action: string,
16
+ body: any,
17
+ options: Partial<PostMethodOptions>,
18
+ ) => Promise<V>;
19
+ all: (
20
+ query: ItemQuery,
21
+ options: Partial<GetMethodOptions>,
22
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
23
+ ) => Promise<V[]>;
24
+ allAction: (
25
+ action: string,
26
+ body: any,
27
+ options: Partial<PostMethodOptions>,
28
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
29
+ ) => Promise<V[]>;
30
+ create: (
31
+ item: TypesProperties<V, S, L1, L2, L3, L4, L5>,
32
+ options: Partial<PostMethodOptions>,
33
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
34
+ ) => Promise<V>;
35
+ find: (
36
+ finder: string,
37
+ finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
38
+ options: Partial<GetMethodOptions>,
39
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
40
+ ) => Promise<V[]>;
41
+ get: (
42
+ ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
43
+ options: Partial<GetMethodOptions>,
44
+ ) => Promise<V | null>;
45
+ one: (
46
+ query: ItemQuery,
47
+ options: Partial<GetMethodOptions>,
48
+ locations: LocKeyArray<L1, L2, L3, L4, L5> | []
49
+ ) => Promise<V | null>;
50
+ remove: (
51
+ ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
52
+ options: Partial<DeleteMethodOptions>
53
+ ) => Promise<boolean>;
54
+ update: (
55
+ ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
56
+ item: TypesProperties<V, S, L1, L2, L3, L4, L5>,
57
+ options: Partial<PutMethodOptions>
58
+ ) => Promise<V>;
59
+ }