@fjell/client-api 4.3.3 → 4.4.0

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 (77) hide show
  1. package/babel.config.cjs +14 -0
  2. package/dist/{src/AItemAPI.d.ts → AItemAPI.d.ts} +4 -4
  3. package/dist/AItemAPI.js +45 -0
  4. package/dist/{src/CItemAPI.d.ts → CItemAPI.d.ts} +5 -5
  5. package/dist/CItemAPI.js +27 -0
  6. package/dist/{src/ClientApi.d.ts → ClientApi.d.ts} +2 -2
  7. package/dist/{src/ClientApiOptions.d.ts → ClientApiOptions.d.ts} +2 -2
  8. package/dist/{src/PItemAPI.d.ts → PItemAPI.d.ts} +4 -5
  9. package/dist/PItemAPI.js +38 -0
  10. package/dist/{src/Utilities.d.ts → Utilities.d.ts} +1 -1
  11. package/dist/Utilities.js +153 -0
  12. package/dist/index.d.ts +6 -0
  13. package/dist/index.js +3 -0
  14. package/dist/logger.d.ts +2 -0
  15. package/dist/logger.js +6 -0
  16. package/dist/{src/ops → ops}/action.d.ts +4 -4
  17. package/dist/ops/action.js +20 -0
  18. package/dist/{src/ops → ops}/all.d.ts +4 -5
  19. package/dist/ops/all.js +24 -0
  20. package/dist/{src/ops → ops}/allAction.d.ts +4 -4
  21. package/dist/ops/allAction.js +23 -0
  22. package/dist/{src/ops → ops}/create.d.ts +4 -4
  23. package/dist/ops/create.js +22 -0
  24. package/dist/{src/ops → ops}/find.d.ts +4 -4
  25. package/dist/ops/find.js +25 -0
  26. package/dist/{src/ops → ops}/get.d.ts +4 -4
  27. package/dist/ops/get.js +18 -0
  28. package/dist/{src/ops → ops}/index.d.ts +5 -5
  29. package/dist/ops/index.js +26 -0
  30. package/dist/{src/ops → ops}/one.d.ts +4 -4
  31. package/dist/ops/one.js +29 -0
  32. package/dist/{src/ops → ops}/remove.d.ts +4 -4
  33. package/dist/ops/remove.js +18 -0
  34. package/dist/{src/ops → ops}/update.d.ts +4 -4
  35. package/dist/ops/update.js +19 -0
  36. package/package.json +29 -24
  37. package/src/index.ts +7 -4
  38. package/dist/src/AItemAPI.js +0 -39
  39. package/dist/src/AItemAPI.js.map +0 -1
  40. package/dist/src/CItemAPI.js +0 -20
  41. package/dist/src/CItemAPI.js.map +0 -1
  42. package/dist/src/ClientApi.js +0 -2
  43. package/dist/src/ClientApi.js.map +0 -1
  44. package/dist/src/ClientApiOptions.js +0 -2
  45. package/dist/src/ClientApiOptions.js.map +0 -1
  46. package/dist/src/PItemAPI.js +0 -30
  47. package/dist/src/PItemAPI.js.map +0 -1
  48. package/dist/src/Utilities.js +0 -110
  49. package/dist/src/Utilities.js.map +0 -1
  50. package/dist/src/index.d.ts +0 -4
  51. package/dist/src/index.js +0 -3
  52. package/dist/src/index.js.map +0 -1
  53. package/dist/src/logger.d.ts +0 -2
  54. package/dist/src/logger.js +0 -4
  55. package/dist/src/logger.js.map +0 -1
  56. package/dist/src/ops/action.js +0 -11
  57. package/dist/src/ops/action.js.map +0 -1
  58. package/dist/src/ops/all.js +0 -15
  59. package/dist/src/ops/all.js.map +0 -1
  60. package/dist/src/ops/allAction.js +0 -14
  61. package/dist/src/ops/allAction.js.map +0 -1
  62. package/dist/src/ops/create.js +0 -14
  63. package/dist/src/ops/create.js.map +0 -1
  64. package/dist/src/ops/find.js +0 -15
  65. package/dist/src/ops/find.js.map +0 -1
  66. package/dist/src/ops/get.js +0 -11
  67. package/dist/src/ops/get.js.map +0 -1
  68. package/dist/src/ops/index.js +0 -23
  69. package/dist/src/ops/index.js.map +0 -1
  70. package/dist/src/ops/one.js +0 -20
  71. package/dist/src/ops/one.js.map +0 -1
  72. package/dist/src/ops/remove.js +0 -11
  73. package/dist/src/ops/remove.js.map +0 -1
  74. package/dist/src/ops/update.js +0 -11
  75. package/dist/src/ops/update.js.map +0 -1
  76. package/dist/tsconfig.tsbuildinfo +0 -1
  77. package/eslint.config.mjs +0 -70
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ presets: [
3
+ ['@babel/preset-env', { targets: { node: 'current' } }],
4
+ '@babel/preset-typescript'
5
+ ],
6
+ overrides: [
7
+ {
8
+ test: /node_modules[\\/](?:@fjell[\\/](core|http-api|logging))/,
9
+ presets: [
10
+ ['@babel/preset-env', { targets: { node: 'current' } }]
11
+ ]
12
+ }
13
+ ]
14
+ };
@@ -1,7 +1,7 @@
1
- import { Item, QueryParams } from "@fjell/core";
2
- import { HttpApi } from "@fjell/http-api";
3
- import { ClientApiOptions } from "./ClientApiOptions";
4
- import { ClientApi } from "./ClientApi";
1
+ import { Item, QueryParams } from '@fjell/core';
2
+ import { HttpApi } from '@fjell/http-api';
3
+ import { ClientApiOptions } from './ClientApiOptions';
4
+ import { ClientApi } from './ClientApi';
5
5
  export type PathNamesArray<L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> = ([L5] extends [never] ? ([L4] extends [never] ? ([L3] extends [never] ? ([L2] extends [never] ? ([L1] extends [never] ? [
6
6
  string
7
7
  ] : [
@@ -0,0 +1,45 @@
1
+ import { getOperations } from './ops/index.js';
2
+ import { createUtilities } from './Utilities.js';
3
+ import LibLogger from './logger.js';
4
+
5
+ const logger = LibLogger.get('AItemAPI');
6
+ const finderToParams = (finder, finderParams)=>{
7
+ return {
8
+ finder,
9
+ finderParams: JSON.stringify(finderParams)
10
+ };
11
+ };
12
+ const createAItemAPI = (api, pkType, pathNames, options)=>{
13
+ logger.default('createAItemAPI', {
14
+ pkType,
15
+ pathNames,
16
+ options
17
+ });
18
+ let mergedOptions;
19
+ const defaultOptions = {
20
+ readAuthenticated: true,
21
+ allAuthenticated: true,
22
+ writeAuthenticated: true
23
+ };
24
+ if (options) {
25
+ mergedOptions = Object.assign({}, defaultOptions, options);
26
+ } else {
27
+ mergedOptions = defaultOptions;
28
+ }
29
+ const utilities = createUtilities(pkType, pathNames);
30
+ const operations = getOperations(api, mergedOptions, utilities);
31
+ return {
32
+ action: operations.action,
33
+ all: operations.all,
34
+ allAction: operations.allAction,
35
+ create: operations.create,
36
+ find: operations.find,
37
+ get: operations.get,
38
+ one: operations.one,
39
+ remove: operations.remove,
40
+ update: operations.update
41
+ };
42
+ };
43
+
44
+ export { createAItemAPI, finderToParams };
45
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQUl0ZW1BUEkuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
@@ -1,8 +1,8 @@
1
- import { ComKey, Item, ItemQuery, LocKeyArray, PriKey, TypesProperties } from "@fjell/core";
2
- import { DeleteMethodOptions, GetMethodOptions, HttpApi, PostMethodOptions, PutMethodOptions } from "@fjell/http-api";
3
- import { PathNamesArray } from "./AItemAPI";
4
- import { ClientApi } from "./ClientApi";
5
- import { ClientApiOptions } from "./ClientApiOptions";
1
+ import { ComKey, Item, ItemQuery, LocKeyArray, PriKey, TypesProperties } from '@fjell/core';
2
+ import { DeleteMethodOptions, GetMethodOptions, HttpApi, PostMethodOptions, PutMethodOptions } from '@fjell/http-api';
3
+ import { PathNamesArray } from './AItemAPI';
4
+ import { ClientApi } from './ClientApi';
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
7
  action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any, options: Partial<PostMethodOptions>) => Promise<V>;
8
8
  all: (query: ItemQuery, options: Partial<GetMethodOptions>, locations: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
@@ -0,0 +1,27 @@
1
+ import { createAItemAPI } from './AItemAPI.js';
2
+ import LibLogger from './logger.js';
3
+
4
+ const logger = LibLogger.get('CItemAPI');
5
+ const createCItemApi = (api, type, pathNames, options)=>{
6
+ logger.default('createCItemApi', {
7
+ api,
8
+ type,
9
+ pathNames,
10
+ options
11
+ });
12
+ const aItemAPI = createAItemAPI(api, type, pathNames, options);
13
+ return {
14
+ action: aItemAPI.action,
15
+ all: aItemAPI.all,
16
+ allAction: aItemAPI.allAction,
17
+ one: aItemAPI.one,
18
+ get: aItemAPI.get,
19
+ create: aItemAPI.create,
20
+ remove: aItemAPI.remove,
21
+ update: aItemAPI.update,
22
+ find: aItemAPI.find
23
+ };
24
+ };
25
+
26
+ export { createCItemApi };
27
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ0l0ZW1BUEkuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
@@ -1,5 +1,5 @@
1
- import { ComKey, Item, ItemQuery, LocKeyArray, PriKey, TypesProperties } from "@fjell/core";
2
- import { DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from "@fjell/http-api";
1
+ import { ComKey, Item, ItemQuery, LocKeyArray, PriKey, TypesProperties } from '@fjell/core';
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
4
  action: (ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body: any, options: Partial<PostMethodOptions>) => Promise<V>;
5
5
  all: (query: ItemQuery, options: Partial<GetMethodOptions>, locations: LocKeyArray<L1, L2, L3, L4, L5> | []) => Promise<V[]>;
@@ -1,5 +1,5 @@
1
- import { Item } from "@fjell/core";
2
- import { ClientApi } from "./ClientApi";
1
+ import { Item } from '@fjell/core';
2
+ import { ClientApi } from './ClientApi';
3
3
  export interface ClientApiOptions {
4
4
  readAuthenticated?: boolean;
5
5
  allAuthenticated?: boolean;
@@ -1,8 +1,7 @@
1
- import { ComKey, Item, ItemQuery, PriKey, TypesProperties } from "@fjell/core";
2
- import { HttpApi } from "@fjell/http-api";
3
- import { ClientApi } from "./ClientApi";
4
- import { DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from "@fjell/http-api";
5
- import { ClientApiOptions } from "./ClientApiOptions";
1
+ import { ComKey, Item, ItemQuery, PriKey, TypesProperties } from '@fjell/core';
2
+ import { HttpApi, DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from '@fjell/http-api';
3
+ import { ClientApi } from './ClientApi';
4
+ import { ClientApiOptions } from './ClientApiOptions';
6
5
  export interface PItemApi<V extends Item<S>, S extends string> extends ClientApi<V, S> {
7
6
  action: (ik: PriKey<S> | ComKey<S, never, never, never, never, never>, action: string, body: any, options: Partial<PostMethodOptions>, locations?: []) => Promise<V>;
8
7
  all: (query: ItemQuery, options: Partial<GetMethodOptions>, locations?: []) => Promise<V[]>;
@@ -0,0 +1,38 @@
1
+ import { createAItemAPI } from './AItemAPI.js';
2
+ import LibLogger from './logger.js';
3
+
4
+ const logger = LibLogger.get('PItemAPI');
5
+ const createPItemApi = (api, type, pathName, options)=>{
6
+ logger.default('createPItemApi', {
7
+ type,
8
+ pathName,
9
+ options
10
+ });
11
+ const aItemAPI = createAItemAPI(api, type, [
12
+ pathName
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, []);
23
+ return {
24
+ ...aItemAPI,
25
+ action,
26
+ all,
27
+ allAction,
28
+ one,
29
+ get,
30
+ create,
31
+ remove,
32
+ update,
33
+ find
34
+ };
35
+ };
36
+
37
+ export { createPItemApi };
38
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUEl0ZW1BUEkuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
@@ -1,4 +1,4 @@
1
- import { ComKey, Item, LocKeyArray, PriKey } from "@fjell/core";
1
+ import { ComKey, Item, LocKeyArray, PriKey } from '@fjell/core';
2
2
  export interface Utilities<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> {
3
3
  verifyLocations: (locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | never) => boolean;
4
4
  processOne: (apiCall: Promise<V>) => Promise<V>;
@@ -0,0 +1,153 @@
1
+ import { validatePK, generateKeyArray, isPriKey } from '@fjell/core';
2
+ import LibLogger from './logger.js';
3
+ import deepmerge from 'deepmerge';
4
+
5
+ const logger = LibLogger.get('client-api', 'Utility');
6
+ const createUtilities = (pkType, pathNames)=>{
7
+ logger.default('createUtilities', {
8
+ pkType,
9
+ pathNames
10
+ });
11
+ const verifyLocations = (locations)=>{
12
+ if (locations && locations.length < pathNames.length - 1) {
13
+ throw new Error('Not enough locations for pathNames: locations:' + locations.length + ' pathNames:' + pathNames.length);
14
+ }
15
+ return true;
16
+ };
17
+ const processOne = async (apiCall)=>{
18
+ logger.default('processOne', {
19
+ apiCall
20
+ });
21
+ const response = await apiCall;
22
+ logger.default('processOne response', {
23
+ response: JSON.stringify(response, null, 2)
24
+ });
25
+ return convertDoc(response);
26
+ };
27
+ const processArray = async (api)=>{
28
+ logger.default('processArray', {
29
+ api
30
+ });
31
+ const response = await api;
32
+ logger.default('processArray response', {
33
+ response: JSON.stringify(response, null, 2)
34
+ });
35
+ if (response && Array.isArray(response)) {
36
+ return response.map((subjectChat)=>convertDoc(subjectChat));
37
+ } else {
38
+ logger.error('Response was not an array', {
39
+ response
40
+ });
41
+ throw new Error('Response was not an array');
42
+ }
43
+ };
44
+ const convertDoc = (doc)=>{
45
+ logger.default('convertDoc', {
46
+ doc
47
+ });
48
+ // console.log(JSON.stringify(doc, null, 2));
49
+ if (doc && doc.events) {
50
+ const events = doc.events;
51
+ for(const key in events){
52
+ events[key] = deepmerge(events[key], {
53
+ at: events[key].at ? new Date(events[key].at) : null
54
+ });
55
+ }
56
+ return doc;
57
+ } else {
58
+ return doc;
59
+ }
60
+ };
61
+ const getPath = (key)=>{
62
+ const localPathNames = [
63
+ ...pathNames
64
+ ];
65
+ logger.default('getPath', {
66
+ key,
67
+ pathNames: localPathNames
68
+ });
69
+ // console.log('getPath key: ' + JSON.stringify(key));
70
+ const keys = generateKeyArray(key);
71
+ // console.log('getPath keys: ' + JSON.stringify(keys));
72
+ // console.log('getPath pathNames: ' + JSON.stringify(pathNames));
73
+ let path = addPath('', keys, localPathNames);
74
+ // If there is only one collection left in the collections array, this means that
75
+ // we received LocKeys and we need to add the last collection to the reference
76
+ if (localPathNames.length === 1) {
77
+ path = `${path}/${localPathNames[0]}`;
78
+ }
79
+ logger.default('getPath created', {
80
+ key,
81
+ path
82
+ });
83
+ return path;
84
+ };
85
+ const addPath = (base, keys, localPathNames)=>{
86
+ logger.default('addPath', {
87
+ base,
88
+ keys,
89
+ pathNames: localPathNames
90
+ });
91
+ if (keys.length < localPathNames.length - 1) {
92
+ logger.error('addPath should never have keys with a length less than the length of pathNames - 1', {
93
+ keys,
94
+ localPathNames
95
+ });
96
+ 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));
97
+ } else if (keys.length > localPathNames.length) {
98
+ logger.error('addPath should never have keys with a length greater than the length of pathNames', {
99
+ keys,
100
+ pathNames
101
+ });
102
+ 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));
103
+ }
104
+ if (keys.length === 0) {
105
+ // If you've recursively consumed all of the keys, return the base.
106
+ logger.default('addPath returning base', {
107
+ base
108
+ });
109
+ return base;
110
+ } else {
111
+ // Retrieve the next key and collection, and create the next base
112
+ let nextBase;
113
+ const key = keys.pop();
114
+ const pathName = localPathNames.pop();
115
+ if (isPriKey(key)) {
116
+ const PriKey = key;
117
+ nextBase = `${base}/${pathName}/${PriKey.pk}`;
118
+ logger.default('Adding Path for PK', {
119
+ pathName,
120
+ PriKey,
121
+ nextBase
122
+ });
123
+ } else {
124
+ const LocKey = key;
125
+ nextBase = `${base}/${pathName}/${LocKey.lk}`;
126
+ logger.default('Retrieving Collection for LK', {
127
+ pathName,
128
+ LocKey
129
+ });
130
+ }
131
+ logger.default('calling addPath recursively', {
132
+ nextBase,
133
+ keys,
134
+ localPathNames
135
+ });
136
+ return addPath(nextBase, keys, localPathNames);
137
+ }
138
+ };
139
+ const validatePK$1 = (item)=>{
140
+ return validatePK(item, pkType);
141
+ };
142
+ return {
143
+ verifyLocations,
144
+ processOne,
145
+ convertDoc,
146
+ processArray,
147
+ getPath,
148
+ validatePK: validatePK$1
149
+ };
150
+ };
151
+
152
+ export { createUtilities };
153
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVXRpbGl0aWVzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -0,0 +1,6 @@
1
+ export type { CItemApi } from './CItemAPI';
2
+ export type { PItemApi } from './PItemAPI';
3
+ export type { ClientApi } from './ClientApi';
4
+ export type { ClientApiOptions } from './ClientApiOptions';
5
+ export { createCItemApi } from './CItemAPI';
6
+ export { createPItemApi } from './PItemAPI';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { createCItemApi } from './CItemAPI.js';
2
+ export { createPItemApi } from './PItemAPI.js';
3
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOyJ9
@@ -0,0 +1,2 @@
1
+ declare const LibLogger: import('@fjell/logging').Logger;
2
+ export default LibLogger;
package/dist/logger.js ADDED
@@ -0,0 +1,6 @@
1
+ import Logging from '@fjell/logging';
2
+
3
+ const LibLogger = Logging.getLogger('@fjellproject/client-api');
4
+
5
+ export { LibLogger as default };
6
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nZ2VyLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7OyJ9
@@ -1,5 +1,5 @@
1
- import { ComKey, Item, PriKey } from "@fjell/core";
2
- import { HttpApi, PostMethodOptions } from "@fjell/http-api";
3
- import { ClientApiOptions } from "../ClientApiOptions";
4
- import { Utilities } from "../Utilities";
1
+ import { ComKey, Item, PriKey } from '@fjell/core';
2
+ import { HttpApi, PostMethodOptions } from '@fjell/http-api';
3
+ import { ClientApiOptions } from '../ClientApiOptions';
4
+ import { Utilities } from '../Utilities';
5
5
  export declare const getActionOperation: <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: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>, action: string, body?: any, options?: Partial<PostMethodOptions>) => Promise<V>;
@@ -0,0 +1,20 @@
1
+ import LibLogger from '../logger.js';
2
+
3
+ const logger = LibLogger.get('client-api', 'ops', 'action');
4
+ const getActionOperation = (api, apiOptions, utilities)=>{
5
+ const action = async (ik, action, body = {}, options = {})=>{
6
+ logger.default('action', {
7
+ ik,
8
+ action,
9
+ body
10
+ });
11
+ const requestOptions = Object.assign({}, options, {
12
+ isAuthenticated: apiOptions.writeAuthenticated
13
+ });
14
+ return utilities.validatePK(await utilities.processOne(api.httpPost(`${utilities.getPath(ik)}/${action}`, body, requestOptions)));
15
+ };
16
+ return action;
17
+ };
18
+
19
+ export { getActionOperation };
20
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWN0aW9uLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
@@ -1,6 +1,5 @@
1
- import { Item, ItemQuery, LocKeyArray } from "@fjell/core";
2
- import { HttpApi } from "@fjell/http-api";
3
- import { ClientApiOptions } from "../ClientApiOptions";
4
- import { Utilities } from "../Utilities";
5
- import { GetMethodOptions } from "@fjell/http-api";
1
+ import { Item, ItemQuery, LocKeyArray } from '@fjell/core';
2
+ import { HttpApi, GetMethodOptions } from '@fjell/http-api';
3
+ import { ClientApiOptions } from '../ClientApiOptions';
4
+ import { Utilities } from '../Utilities';
6
5
  export declare const getAllOperation: <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[]>;
@@ -0,0 +1,24 @@
1
+ import { queryToParams } from '@fjell/core';
2
+ import LibLogger from '../logger.js';
3
+
4
+ const logger = LibLogger.get('client-api', 'ops', 'all');
5
+ const getAllOperation = (api, apiOptions, utilities)=>{
6
+ const all = async (query = {}, options = {}, locations = [])=>{
7
+ logger.default('all', {
8
+ query,
9
+ locations
10
+ });
11
+ utilities.verifyLocations(locations);
12
+ const loc = locations;
13
+ const params = queryToParams(query);
14
+ const requestOptions = Object.assign({}, options, {
15
+ isAuthenticated: apiOptions.allAuthenticated,
16
+ params
17
+ });
18
+ return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
19
+ };
20
+ return all;
21
+ };
22
+
23
+ export { getAllOperation };
24
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWxsLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1,5 +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";
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
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,23 @@
1
+ import LibLogger from '../logger.js';
2
+
3
+ const logger = LibLogger.get('client-api', 'ops', 'allAction');
4
+ const getAllActionOperation = (api, apiOptions, utilities)=>{
5
+ const allAction = async (action, body = {}, options = {}, locations = [])=>{
6
+ logger.default('allAction', {
7
+ action,
8
+ body,
9
+ locations
10
+ });
11
+ utilities.verifyLocations(locations);
12
+ const loc = locations;
13
+ const requestOptions = Object.assign({}, options, {
14
+ isAuthenticated: apiOptions.writeAuthenticated
15
+ });
16
+ // TODO: This should respond to either a single object, or multiple objects in an array.
17
+ return utilities.validatePK(await utilities.processArray(api.httpPost(utilities.getPath(loc), body, requestOptions)));
18
+ };
19
+ return allAction;
20
+ };
21
+
22
+ export { getAllActionOperation };
23
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWxsQWN0aW9uLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
@@ -1,5 +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";
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
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,22 @@
1
+ import LibLogger from '../logger.js';
2
+
3
+ const logger = LibLogger.get('client-api', 'ops', 'create');
4
+ const getCreateOperation = (api, apiOptions, utilities)=>{
5
+ const create = async (item, options = {}, locations = [])=>{
6
+ logger.default('create', {
7
+ item,
8
+ locations
9
+ });
10
+ utilities.verifyLocations(locations);
11
+ const loc = locations;
12
+ const requestOptions = Object.assign({}, options, {
13
+ isAuthenticated: apiOptions.writeAuthenticated
14
+ });
15
+ const created = utilities.validatePK(await utilities.processOne(api.httpPost(utilities.getPath(loc), item, requestOptions)));
16
+ return created;
17
+ };
18
+ return create;
19
+ };
20
+
21
+ export { getCreateOperation };
22
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
@@ -1,5 +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";
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
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,25 @@
1
+ import { finderToParams } from '../AItemAPI.js';
2
+ import LibLogger from '../logger.js';
3
+
4
+ const logger = LibLogger.get('client-api', 'ops', 'find');
5
+ const getFindOperation = (api, apiOptions, utilities)=>{
6
+ const find = async (finder, finderParams, options = {}, locations = [])=>{
7
+ logger.default('find', {
8
+ finder,
9
+ finderParams,
10
+ locations
11
+ });
12
+ utilities.verifyLocations(locations);
13
+ const loc = locations;
14
+ const params = finderToParams(finder, finderParams);
15
+ const requestOptions = Object.assign({}, options, {
16
+ isAuthenticated: apiOptions.allAuthenticated,
17
+ params
18
+ });
19
+ return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
20
+ };
21
+ return find;
22
+ };
23
+
24
+ export { getFindOperation };
25
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmluZC5qcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
@@ -1,5 +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";
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
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,18 @@
1
+ import LibLogger from '../logger.js';
2
+
3
+ const logger = LibLogger.get('client-api', 'ops', 'get');
4
+ const getGetOperation = (api, apiOptions, utilities)=>{
5
+ const get = async (ik, options = {})=>{
6
+ logger.default('get', {
7
+ ik
8
+ });
9
+ const requestOptions = Object.assign({}, options, {
10
+ isAuthenticated: apiOptions.readAuthenticated
11
+ });
12
+ return utilities.validatePK(await utilities.processOne(api.httpGet(utilities.getPath(ik), requestOptions)));
13
+ };
14
+ return get;
15
+ };
16
+
17
+ export { getGetOperation };
18
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0LmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
@@ -1,6 +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";
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
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,26 @@
1
+ import { getAllOperation } from './all.js';
2
+ import { getActionOperation } from './action.js';
3
+ import { getAllActionOperation } from './allAction.js';
4
+ import { getOneOperation } from './one.js';
5
+ import { getCreateOperation } from './create.js';
6
+ import { getUpdateOperation } from './update.js';
7
+ import { getGetOperation } from './get.js';
8
+ import { getRemoveOperation } from './remove.js';
9
+ import { getFindOperation } from './find.js';
10
+
11
+ const getOperations = (api, apiOptions, utilities)=>{
12
+ return {
13
+ action: getActionOperation(api, apiOptions, utilities),
14
+ all: getAllOperation(api, apiOptions, utilities),
15
+ allAction: getAllActionOperation(api, apiOptions, utilities),
16
+ create: getCreateOperation(api, apiOptions, utilities),
17
+ find: getFindOperation(api, apiOptions, utilities),
18
+ get: getGetOperation(api, apiOptions, utilities),
19
+ one: getOneOperation(api, apiOptions, utilities),
20
+ remove: getRemoveOperation(api, apiOptions, utilities),
21
+ update: getUpdateOperation(api, apiOptions, utilities)
22
+ };
23
+ };
24
+
25
+ export { getOperations };
26
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==