@fjell/client-api 4.4.13 → 4.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AItemAPI.d.ts +4 -4
- package/dist/CItemAPI.d.ts +5 -5
- package/dist/ClientApi.d.ts +1 -1
- package/dist/ClientApiOptions.d.ts +3 -3
- package/dist/Instance.d.ts +3 -3
- package/dist/InstanceFactory.d.ts +3 -3
- package/dist/PItemAPI.d.ts +4 -4
- package/dist/Utilities.d.ts +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +544 -5
- package/dist/index.js.map +7 -1
- package/dist/logger.d.ts +1 -1
- package/dist/ops/action.d.ts +4 -4
- package/dist/ops/all.d.ts +4 -4
- package/dist/ops/allAction.d.ts +4 -4
- package/dist/ops/allFacet.d.ts +4 -4
- package/dist/ops/create.d.ts +4 -4
- package/dist/ops/facet.d.ts +4 -4
- package/dist/ops/find.d.ts +4 -4
- package/dist/ops/findOne.d.ts +4 -4
- package/dist/ops/get.d.ts +4 -4
- package/dist/ops/index.d.ts +5 -5
- package/dist/ops/one.d.ts +4 -4
- package/dist/ops/remove.d.ts +4 -4
- package/dist/ops/update.d.ts +4 -4
- package/package.json +8 -11
- package/vitest.config.ts +25 -0
- package/dist/AItemAPI.js +0 -52
- package/dist/AItemAPI.js.map +0 -1
- package/dist/CItemAPI.js +0 -30
- package/dist/CItemAPI.js.map +0 -1
- package/dist/Instance.js +0 -19
- package/dist/Instance.js.map +0 -1
- package/dist/InstanceFactory.js +0 -19
- package/dist/InstanceFactory.js.map +0 -1
- package/dist/PItemAPI.js +0 -44
- package/dist/PItemAPI.js.map +0 -1
- package/dist/Registry.js +0 -31
- package/dist/Registry.js.map +0 -1
- package/dist/Utilities.js +0 -153
- package/dist/Utilities.js.map +0 -1
- package/dist/index.cjs +0 -586
- package/dist/index.cjs.map +0 -1
- package/dist/logger.js +0 -6
- package/dist/logger.js.map +0 -1
- package/dist/ops/action.js +0 -21
- package/dist/ops/action.js.map +0 -1
- package/dist/ops/all.js +0 -25
- package/dist/ops/all.js.map +0 -1
- package/dist/ops/allAction.js +0 -24
- package/dist/ops/allAction.js.map +0 -1
- package/dist/ops/allFacet.js +0 -24
- package/dist/ops/allFacet.js.map +0 -1
- package/dist/ops/create.js +0 -23
- package/dist/ops/create.js.map +0 -1
- package/dist/ops/facet.js +0 -34
- package/dist/ops/facet.js.map +0 -1
- package/dist/ops/find.js +0 -26
- package/dist/ops/find.js.map +0 -1
- package/dist/ops/findOne.js +0 -27
- package/dist/ops/findOne.js.map +0 -1
- package/dist/ops/get.js +0 -19
- package/dist/ops/get.js.map +0 -1
- package/dist/ops/index.js +0 -32
- package/dist/ops/index.js.map +0 -1
- package/dist/ops/one.js +0 -30
- package/dist/ops/one.js.map +0 -1
- package/dist/ops/remove.js +0 -19
- package/dist/ops/remove.js.map +0 -1
- package/dist/ops/update.js +0 -20
- package/dist/ops/update.js.map +0 -1
- package/docs/docs.config.ts +0 -77
- package/docs/index.html +0 -18
- package/docs/package.json +0 -34
- package/docs/public/README.md +0 -165
- package/docs/public/api-reference.md +0 -408
- package/docs/public/examples-README.md +0 -387
- package/docs/public/fjell-icon.svg +0 -1
- package/docs/public/package.json +0 -5
- package/docs/src/index.css +0 -34
- package/docs/src/main.tsx +0 -12
- package/docs/src/test/setup.ts +0 -1
- package/docs/src/types.d.ts +0 -44
- package/docs/tsconfig.node.json +0 -13
- package/docs/vitest.config.ts +0 -14
- package/examples/README.md +0 -387
- package/examples/enterprise-example.ts +0 -852
- package/examples/multi-level-keys.ts +0 -467
- package/examples/simple-example.ts +0 -346
package/dist/index.cjs
DELETED
|
@@ -1,586 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const core = require('@fjell/core');
|
|
6
|
-
const Logging = require('@fjell/logging');
|
|
7
|
-
const deepmerge = require('deepmerge');
|
|
8
|
-
const registry = require('@fjell/registry');
|
|
9
|
-
|
|
10
|
-
const LibLogger = Logging.getLogger('@fjell/client-api');
|
|
11
|
-
|
|
12
|
-
const logger$i = LibLogger.get('client-api', 'ops', 'all');
|
|
13
|
-
const getAllOperation = (api, apiOptions, utilities)=>{
|
|
14
|
-
const all = async (query = {}, locations = [])=>{
|
|
15
|
-
utilities.verifyLocations(locations);
|
|
16
|
-
const loc = locations;
|
|
17
|
-
const params = core.queryToParams(query);
|
|
18
|
-
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
19
|
-
isAuthenticated: apiOptions.allAuthenticated,
|
|
20
|
-
params
|
|
21
|
-
});
|
|
22
|
-
logger$i.default('all', {
|
|
23
|
-
query,
|
|
24
|
-
locations,
|
|
25
|
-
requestOptions
|
|
26
|
-
});
|
|
27
|
-
return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
|
|
28
|
-
};
|
|
29
|
-
return all;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const logger$h = LibLogger.get('client-api', 'ops', 'action');
|
|
33
|
-
const getActionOperation = (api, apiOptions, utilities)=>{
|
|
34
|
-
const action = async (ik, action, body = {})=>{
|
|
35
|
-
const requestOptions = Object.assign({}, apiOptions.postOptions, {
|
|
36
|
-
isAuthenticated: apiOptions.writeAuthenticated
|
|
37
|
-
});
|
|
38
|
-
logger$h.default('action', {
|
|
39
|
-
ik,
|
|
40
|
-
action,
|
|
41
|
-
body,
|
|
42
|
-
requestOptions
|
|
43
|
-
});
|
|
44
|
-
return utilities.validatePK(await utilities.processOne(api.httpPost(`${utilities.getPath(ik)}/${action}`, body, requestOptions)));
|
|
45
|
-
};
|
|
46
|
-
return action;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const logger$g = LibLogger.get('client-api', 'ops', 'allAction');
|
|
50
|
-
const getAllActionOperation = (api, apiOptions, utilities)=>{
|
|
51
|
-
const allAction = async (action, body = {}, locations = [])=>{
|
|
52
|
-
const requestOptions = Object.assign({}, apiOptions.postOptions, {
|
|
53
|
-
isAuthenticated: apiOptions.writeAuthenticated
|
|
54
|
-
});
|
|
55
|
-
logger$g.default('allAction', {
|
|
56
|
-
action,
|
|
57
|
-
body,
|
|
58
|
-
locations,
|
|
59
|
-
requestOptions
|
|
60
|
-
});
|
|
61
|
-
utilities.verifyLocations(locations);
|
|
62
|
-
const loc = locations;
|
|
63
|
-
// TODO: This should respond to either a single object, or multiple objects in an array.
|
|
64
|
-
return utilities.validatePK(await utilities.processArray(api.httpPost(utilities.getPath(loc), body, requestOptions)));
|
|
65
|
-
};
|
|
66
|
-
return allAction;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const logger$f = LibLogger.get('client-api', 'ops', 'one');
|
|
70
|
-
const getOneOperation = (api, apiOptions, utilities)=>{
|
|
71
|
-
const one = async (query = {}, locations = [])=>{
|
|
72
|
-
utilities.verifyLocations(locations);
|
|
73
|
-
const loc = locations;
|
|
74
|
-
const params = core.queryToParams(query);
|
|
75
|
-
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
76
|
-
isAuthenticated: apiOptions.readAuthenticated,
|
|
77
|
-
params
|
|
78
|
-
});
|
|
79
|
-
logger$f.default('one', {
|
|
80
|
-
query,
|
|
81
|
-
locations,
|
|
82
|
-
requestOptions
|
|
83
|
-
});
|
|
84
|
-
let item = null;
|
|
85
|
-
const items = utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
|
|
86
|
-
if (items.length > 0) {
|
|
87
|
-
item = items[0];
|
|
88
|
-
}
|
|
89
|
-
return item;
|
|
90
|
-
};
|
|
91
|
-
return one;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const logger$e = LibLogger.get('client-api', 'ops', 'create');
|
|
95
|
-
const getCreateOperation = (api, apiOptions, utilities)=>{
|
|
96
|
-
const create = async (item, locations = [])=>{
|
|
97
|
-
const requestOptions = Object.assign({}, apiOptions.postOptions, {
|
|
98
|
-
isAuthenticated: apiOptions.writeAuthenticated
|
|
99
|
-
});
|
|
100
|
-
logger$e.default('create', {
|
|
101
|
-
item,
|
|
102
|
-
locations,
|
|
103
|
-
requestOptions
|
|
104
|
-
});
|
|
105
|
-
utilities.verifyLocations(locations);
|
|
106
|
-
const loc = locations;
|
|
107
|
-
const created = utilities.validatePK(await utilities.processOne(api.httpPost(utilities.getPath(loc), item, requestOptions)));
|
|
108
|
-
return created;
|
|
109
|
-
};
|
|
110
|
-
return create;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const logger$d = LibLogger.get('client-api', 'ops', 'update');
|
|
114
|
-
const getUpdateOperation = (api, apiOptions, utilities)=>{
|
|
115
|
-
const update = async (ik, item)=>{
|
|
116
|
-
const requestOptions = Object.assign({}, apiOptions.putOptions, {
|
|
117
|
-
isAuthenticated: apiOptions.writeAuthenticated
|
|
118
|
-
});
|
|
119
|
-
logger$d.default('update', {
|
|
120
|
-
ik,
|
|
121
|
-
item,
|
|
122
|
-
requestOptions
|
|
123
|
-
});
|
|
124
|
-
return utilities.validatePK(await utilities.processOne(api.httpPut(utilities.getPath(ik), item, requestOptions)));
|
|
125
|
-
};
|
|
126
|
-
return update;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const logger$c = LibLogger.get('client-api', 'ops', 'get');
|
|
130
|
-
const getGetOperation = (api, apiOptions, utilities)=>{
|
|
131
|
-
const get = async (ik)=>{
|
|
132
|
-
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
133
|
-
isAuthenticated: apiOptions.readAuthenticated
|
|
134
|
-
});
|
|
135
|
-
logger$c.default('get', {
|
|
136
|
-
ik,
|
|
137
|
-
requestOptions
|
|
138
|
-
});
|
|
139
|
-
return utilities.validatePK(await utilities.processOne(api.httpGet(utilities.getPath(ik), requestOptions)));
|
|
140
|
-
};
|
|
141
|
-
return get;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const logger$b = LibLogger.get('client-api', 'ops', 'remove');
|
|
145
|
-
const getRemoveOperation = (api, apiOptions, utilities)=>{
|
|
146
|
-
const remove = async (ik)=>{
|
|
147
|
-
const requestOptions = Object.assign({}, apiOptions.deleteOptions, {
|
|
148
|
-
isAuthenticated: apiOptions.writeAuthenticated
|
|
149
|
-
});
|
|
150
|
-
logger$b.default('remove', {
|
|
151
|
-
ik,
|
|
152
|
-
requestOptions
|
|
153
|
-
});
|
|
154
|
-
return api.httpDelete(utilities.getPath(ik), requestOptions);
|
|
155
|
-
};
|
|
156
|
-
return remove;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const logger$a = LibLogger.get('client-api', 'ops', 'find');
|
|
160
|
-
const getFindOperation = (api, apiOptions, utilities)=>{
|
|
161
|
-
const find = async (finder, finderParams = {}, locations = [])=>{
|
|
162
|
-
utilities.verifyLocations(locations);
|
|
163
|
-
const loc = locations;
|
|
164
|
-
const mergedParams = finderToParams(finder, finderParams);
|
|
165
|
-
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
166
|
-
isAuthenticated: apiOptions.allAuthenticated,
|
|
167
|
-
params: mergedParams
|
|
168
|
-
});
|
|
169
|
-
logger$a.default('find', {
|
|
170
|
-
finder,
|
|
171
|
-
finderParams,
|
|
172
|
-
locations,
|
|
173
|
-
requestOptions
|
|
174
|
-
});
|
|
175
|
-
return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)));
|
|
176
|
-
};
|
|
177
|
-
return find;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const logger$9 = LibLogger.get('client-api', 'ops', 'find');
|
|
181
|
-
const getFindOneOperation = (api, apiOptions, utilities)=>{
|
|
182
|
-
const findOne = async (finder, finderParams = {}, locations = [])=>{
|
|
183
|
-
utilities.verifyLocations(locations);
|
|
184
|
-
const loc = locations;
|
|
185
|
-
const params = finderToParams(finder, finderParams);
|
|
186
|
-
params.one = true;
|
|
187
|
-
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
188
|
-
isAuthenticated: apiOptions.allAuthenticated,
|
|
189
|
-
params
|
|
190
|
-
});
|
|
191
|
-
logger$9.default('findOne', {
|
|
192
|
-
finder,
|
|
193
|
-
finderParams,
|
|
194
|
-
locations,
|
|
195
|
-
requestOptions
|
|
196
|
-
});
|
|
197
|
-
return utilities.validatePK(await utilities.processArray(api.httpGet(utilities.getPath(loc), requestOptions)))[0];
|
|
198
|
-
};
|
|
199
|
-
return findOne;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const logger$8 = LibLogger.get('client-api', 'ops', 'facet');
|
|
203
|
-
const getFacetOperation = (api, apiOptions, utilities)=>{
|
|
204
|
-
/**
|
|
205
|
-
* Executes a facet operation on an item.
|
|
206
|
-
*
|
|
207
|
-
* A facet is a piece of information that is related to an item - it represents
|
|
208
|
-
* a specific aspect or characteristic of the item. Unlike actions which may
|
|
209
|
-
* return items or perform operations, facets are informational queries that
|
|
210
|
-
* return data about a particular facet of an item.
|
|
211
|
-
*
|
|
212
|
-
* @param ik - The item key (composite or primary key) identifying the item
|
|
213
|
-
* @param facet - The name of the facet to query
|
|
214
|
-
* @param body - Optional request body for the facet operation
|
|
215
|
-
* @param options - Optional HTTP request options
|
|
216
|
-
* @returns Promise resolving to the facet data
|
|
217
|
-
*/ const facet = async (ik, facet, params = {})=>{
|
|
218
|
-
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
219
|
-
isAuthenticated: apiOptions.writeAuthenticated,
|
|
220
|
-
params
|
|
221
|
-
});
|
|
222
|
-
logger$8.default('facet', {
|
|
223
|
-
ik,
|
|
224
|
-
facet,
|
|
225
|
-
requestOptions
|
|
226
|
-
});
|
|
227
|
-
return api.httpGet(`${utilities.getPath(ik)}/${facet}`, requestOptions);
|
|
228
|
-
};
|
|
229
|
-
return facet;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
const logger$7 = LibLogger.get('client-api', 'ops', 'allFacet');
|
|
233
|
-
const getAllFacetOperation = (api, apiOptions, utilities)=>{
|
|
234
|
-
const allFacet = async (facet, params = {}, locations = [])=>{
|
|
235
|
-
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
236
|
-
isAuthenticated: apiOptions.writeAuthenticated,
|
|
237
|
-
params
|
|
238
|
-
});
|
|
239
|
-
logger$7.default('allFacet', {
|
|
240
|
-
facet,
|
|
241
|
-
locations,
|
|
242
|
-
requestOptions
|
|
243
|
-
});
|
|
244
|
-
utilities.verifyLocations(locations);
|
|
245
|
-
const loc = locations;
|
|
246
|
-
// TODO: This should respond to either a single object, or multiple objects in an array.
|
|
247
|
-
return api.httpGet(utilities.getPath(loc), requestOptions);
|
|
248
|
-
};
|
|
249
|
-
return allFacet;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const getOperations = (api, apiOptions, utilities)=>{
|
|
253
|
-
return {
|
|
254
|
-
action: getActionOperation(api, apiOptions, utilities),
|
|
255
|
-
all: getAllOperation(api, apiOptions, utilities),
|
|
256
|
-
allAction: getAllActionOperation(api, apiOptions, utilities),
|
|
257
|
-
allFacet: getAllFacetOperation(api, apiOptions, utilities),
|
|
258
|
-
create: getCreateOperation(api, apiOptions, utilities),
|
|
259
|
-
facet: getFacetOperation(api, apiOptions, utilities),
|
|
260
|
-
findOne: getFindOneOperation(api, apiOptions, utilities),
|
|
261
|
-
find: getFindOperation(api, apiOptions, utilities),
|
|
262
|
-
get: getGetOperation(api, apiOptions, utilities),
|
|
263
|
-
one: getOneOperation(api, apiOptions, utilities),
|
|
264
|
-
remove: getRemoveOperation(api, apiOptions, utilities),
|
|
265
|
-
update: getUpdateOperation(api, apiOptions, utilities)
|
|
266
|
-
};
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
const logger$6 = LibLogger.get('client-api', 'Utility');
|
|
270
|
-
const createUtilities = (pkType, pathNames)=>{
|
|
271
|
-
logger$6.default('createUtilities', {
|
|
272
|
-
pkType,
|
|
273
|
-
pathNames
|
|
274
|
-
});
|
|
275
|
-
const verifyLocations = (locations)=>{
|
|
276
|
-
if (locations && locations.length < pathNames.length - 1) {
|
|
277
|
-
throw new Error('Not enough locations for pathNames: locations:' + locations.length + ' pathNames:' + pathNames.length);
|
|
278
|
-
}
|
|
279
|
-
return true;
|
|
280
|
-
};
|
|
281
|
-
const processOne = async (apiCall)=>{
|
|
282
|
-
logger$6.default('processOne', {
|
|
283
|
-
apiCall
|
|
284
|
-
});
|
|
285
|
-
const response = await apiCall;
|
|
286
|
-
logger$6.default('processOne response', {
|
|
287
|
-
response: JSON.stringify(response, null, 2)
|
|
288
|
-
});
|
|
289
|
-
return convertDoc(response);
|
|
290
|
-
};
|
|
291
|
-
const processArray = async (api)=>{
|
|
292
|
-
logger$6.default('processArray', {
|
|
293
|
-
api
|
|
294
|
-
});
|
|
295
|
-
const response = await api;
|
|
296
|
-
logger$6.default('processArray response', {
|
|
297
|
-
response: JSON.stringify(response, null, 2)
|
|
298
|
-
});
|
|
299
|
-
if (response && Array.isArray(response)) {
|
|
300
|
-
return response.map((subjectChat)=>convertDoc(subjectChat));
|
|
301
|
-
} else {
|
|
302
|
-
logger$6.error('Response was not an array', {
|
|
303
|
-
response
|
|
304
|
-
});
|
|
305
|
-
throw new Error('Response was not an array');
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
const convertDoc = (doc)=>{
|
|
309
|
-
logger$6.default('convertDoc', {
|
|
310
|
-
doc
|
|
311
|
-
});
|
|
312
|
-
// console.log(JSON.stringify(doc, null, 2));
|
|
313
|
-
if (doc && doc.events) {
|
|
314
|
-
const events = doc.events;
|
|
315
|
-
for(const key in events){
|
|
316
|
-
events[key] = deepmerge(events[key], {
|
|
317
|
-
at: events[key].at ? new Date(events[key].at) : null
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
return doc;
|
|
321
|
-
} else {
|
|
322
|
-
return doc;
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
const getPath = (key)=>{
|
|
326
|
-
const localPathNames = [
|
|
327
|
-
...pathNames
|
|
328
|
-
];
|
|
329
|
-
logger$6.default('getPath', {
|
|
330
|
-
key,
|
|
331
|
-
pathNames: localPathNames
|
|
332
|
-
});
|
|
333
|
-
// console.log('getPath key: ' + JSON.stringify(key));
|
|
334
|
-
const keys = core.generateKeyArray(key);
|
|
335
|
-
// console.log('getPath keys: ' + JSON.stringify(keys));
|
|
336
|
-
// console.log('getPath pathNames: ' + JSON.stringify(pathNames));
|
|
337
|
-
let path = addPath('', keys, localPathNames);
|
|
338
|
-
// If there is only one collection left in the collections array, this means that
|
|
339
|
-
// we received LocKeys and we need to add the last collection to the reference
|
|
340
|
-
if (localPathNames.length === 1) {
|
|
341
|
-
path = `${path}/${localPathNames[0]}`;
|
|
342
|
-
}
|
|
343
|
-
logger$6.default('getPath created', {
|
|
344
|
-
key,
|
|
345
|
-
path
|
|
346
|
-
});
|
|
347
|
-
return path;
|
|
348
|
-
};
|
|
349
|
-
const addPath = (base, keys, localPathNames)=>{
|
|
350
|
-
logger$6.default('addPath', {
|
|
351
|
-
base,
|
|
352
|
-
keys,
|
|
353
|
-
pathNames: localPathNames
|
|
354
|
-
});
|
|
355
|
-
if (keys.length < localPathNames.length - 1) {
|
|
356
|
-
logger$6.error('addPath should never have keys with a length less than the length of pathNames - 1', {
|
|
357
|
-
keys,
|
|
358
|
-
localPathNames
|
|
359
|
-
});
|
|
360
|
-
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));
|
|
361
|
-
} else if (keys.length > localPathNames.length) {
|
|
362
|
-
logger$6.error('addPath should never have keys with a length greater than the length of pathNames', {
|
|
363
|
-
keys,
|
|
364
|
-
pathNames
|
|
365
|
-
});
|
|
366
|
-
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));
|
|
367
|
-
}
|
|
368
|
-
if (keys.length === 0) {
|
|
369
|
-
// If you've recursively consumed all of the keys, return the base.
|
|
370
|
-
logger$6.default('addPath returning base', {
|
|
371
|
-
base
|
|
372
|
-
});
|
|
373
|
-
return base;
|
|
374
|
-
} else {
|
|
375
|
-
// Retrieve the next key and collection, and create the next base
|
|
376
|
-
let nextBase;
|
|
377
|
-
const key = keys.pop();
|
|
378
|
-
const pathName = localPathNames.pop();
|
|
379
|
-
if (core.isPriKey(key)) {
|
|
380
|
-
const PriKey = key;
|
|
381
|
-
nextBase = `${base}/${pathName}/${PriKey.pk}`;
|
|
382
|
-
logger$6.default('Adding Path for PK', {
|
|
383
|
-
pathName,
|
|
384
|
-
PriKey,
|
|
385
|
-
nextBase
|
|
386
|
-
});
|
|
387
|
-
} else {
|
|
388
|
-
const LocKey = key;
|
|
389
|
-
nextBase = `${base}/${pathName}/${LocKey.lk}`;
|
|
390
|
-
logger$6.default('Retrieving Collection for LK', {
|
|
391
|
-
pathName,
|
|
392
|
-
LocKey
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
logger$6.default('calling addPath recursively', {
|
|
396
|
-
nextBase,
|
|
397
|
-
keys,
|
|
398
|
-
localPathNames
|
|
399
|
-
});
|
|
400
|
-
return addPath(nextBase, keys, localPathNames);
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
const validatePK = (item)=>{
|
|
404
|
-
return core.validatePK(item, pkType);
|
|
405
|
-
};
|
|
406
|
-
return {
|
|
407
|
-
verifyLocations,
|
|
408
|
-
processOne,
|
|
409
|
-
convertDoc,
|
|
410
|
-
processArray,
|
|
411
|
-
getPath,
|
|
412
|
-
validatePK
|
|
413
|
-
};
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
const logger$5 = LibLogger.get('AItemAPI');
|
|
417
|
-
const finderToParams = (finder, finderParams)=>{
|
|
418
|
-
return {
|
|
419
|
-
finder,
|
|
420
|
-
finderParams: JSON.stringify(finderParams)
|
|
421
|
-
};
|
|
422
|
-
};
|
|
423
|
-
const createAItemAPI = (api, pkType, pathNames, options)=>{
|
|
424
|
-
logger$5.default('createAItemAPI', {
|
|
425
|
-
pkType,
|
|
426
|
-
pathNames,
|
|
427
|
-
options
|
|
428
|
-
});
|
|
429
|
-
let mergedOptions;
|
|
430
|
-
const defaultOptions = {
|
|
431
|
-
readAuthenticated: true,
|
|
432
|
-
allAuthenticated: true,
|
|
433
|
-
writeAuthenticated: true,
|
|
434
|
-
getOptions: {},
|
|
435
|
-
postOptions: {},
|
|
436
|
-
putOptions: {},
|
|
437
|
-
deleteOptions: {}
|
|
438
|
-
};
|
|
439
|
-
if (options) {
|
|
440
|
-
mergedOptions = Object.assign({}, defaultOptions, options);
|
|
441
|
-
} else {
|
|
442
|
-
mergedOptions = defaultOptions;
|
|
443
|
-
}
|
|
444
|
-
const utilities = createUtilities(pkType, pathNames);
|
|
445
|
-
const operations = getOperations(api, mergedOptions, utilities);
|
|
446
|
-
return {
|
|
447
|
-
action: operations.action,
|
|
448
|
-
all: operations.all,
|
|
449
|
-
allAction: operations.allAction,
|
|
450
|
-
allFacet: operations.allFacet,
|
|
451
|
-
create: operations.create,
|
|
452
|
-
facet: operations.facet,
|
|
453
|
-
find: operations.find,
|
|
454
|
-
findOne: operations.findOne,
|
|
455
|
-
get: operations.get,
|
|
456
|
-
one: operations.one,
|
|
457
|
-
remove: operations.remove,
|
|
458
|
-
update: operations.update
|
|
459
|
-
};
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
const logger$4 = LibLogger.get('CItemAPI');
|
|
463
|
-
const createCItemApi = (api, type, pathNames, options)=>{
|
|
464
|
-
logger$4.default('createCItemApi', {
|
|
465
|
-
api,
|
|
466
|
-
type,
|
|
467
|
-
pathNames,
|
|
468
|
-
options
|
|
469
|
-
});
|
|
470
|
-
const aItemAPI = createAItemAPI(api, type, pathNames, options);
|
|
471
|
-
return {
|
|
472
|
-
action: aItemAPI.action,
|
|
473
|
-
all: aItemAPI.all,
|
|
474
|
-
allAction: aItemAPI.allAction,
|
|
475
|
-
allFacet: aItemAPI.allFacet,
|
|
476
|
-
one: aItemAPI.one,
|
|
477
|
-
get: aItemAPI.get,
|
|
478
|
-
create: aItemAPI.create,
|
|
479
|
-
remove: aItemAPI.remove,
|
|
480
|
-
update: aItemAPI.update,
|
|
481
|
-
facet: aItemAPI.facet,
|
|
482
|
-
find: aItemAPI.find,
|
|
483
|
-
findOne: aItemAPI.findOne
|
|
484
|
-
};
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
const logger$3 = LibLogger.get('PItemAPI');
|
|
488
|
-
const createPItemApi = (api, type, pathName, options)=>{
|
|
489
|
-
logger$3.default('createPItemApi', {
|
|
490
|
-
type,
|
|
491
|
-
pathName,
|
|
492
|
-
options
|
|
493
|
-
});
|
|
494
|
-
const aItemAPI = createAItemAPI(api, type, [
|
|
495
|
-
pathName
|
|
496
|
-
], options);
|
|
497
|
-
const action = async (ik, action, body = {})=>await aItemAPI.action(ik, action, body);
|
|
498
|
-
const all = async (query = {})=>await aItemAPI.all(query, []);
|
|
499
|
-
const allAction = async (action, body = {})=>await aItemAPI.allAction(action, body, []);
|
|
500
|
-
const allFacet = async (facet, params = {})=>await aItemAPI.allFacet(facet, params);
|
|
501
|
-
const one = async (query = {})=>await aItemAPI.one(query, []);
|
|
502
|
-
const get = async (ik)=>await aItemAPI.get(ik);
|
|
503
|
-
const create = async (item)=>await aItemAPI.create(item, []);
|
|
504
|
-
const remove = async (ik)=>await aItemAPI.remove(ik);
|
|
505
|
-
const update = async (ik, item)=>await aItemAPI.update(ik, item);
|
|
506
|
-
const facet = async (ik, facet, params = {})=>await aItemAPI.facet(ik, facet, params);
|
|
507
|
-
const find = async (finder, finderParams = {})=>await aItemAPI.find(finder, finderParams);
|
|
508
|
-
const findOne = async (finder, finderParams = {})=>await aItemAPI.findOne(finder, finderParams);
|
|
509
|
-
return {
|
|
510
|
-
...aItemAPI,
|
|
511
|
-
action,
|
|
512
|
-
all,
|
|
513
|
-
allAction,
|
|
514
|
-
allFacet,
|
|
515
|
-
one,
|
|
516
|
-
get,
|
|
517
|
-
create,
|
|
518
|
-
remove,
|
|
519
|
-
update,
|
|
520
|
-
facet,
|
|
521
|
-
find,
|
|
522
|
-
findOne
|
|
523
|
-
};
|
|
524
|
-
};
|
|
525
|
-
|
|
526
|
-
const logger$2 = LibLogger.get("Instance");
|
|
527
|
-
const createInstance = (registry$1, coordinate, clientApi)=>{
|
|
528
|
-
logger$2.debug("createInstance", {
|
|
529
|
-
coordinate,
|
|
530
|
-
clientApi,
|
|
531
|
-
registry: registry$1
|
|
532
|
-
});
|
|
533
|
-
const baseInstance = registry.createInstance(registry$1, coordinate);
|
|
534
|
-
return {
|
|
535
|
-
...baseInstance,
|
|
536
|
-
clientApi
|
|
537
|
-
};
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
const logger$1 = LibLogger.get("InstanceFactory");
|
|
541
|
-
/**
|
|
542
|
-
* Factory function for creating client-api instances
|
|
543
|
-
*/ const createInstanceFactory = (clientApi)=>{
|
|
544
|
-
return (coordinate, context)=>{
|
|
545
|
-
logger$1.debug("Creating client-api instance", {
|
|
546
|
-
coordinate,
|
|
547
|
-
registry: context.registry,
|
|
548
|
-
clientApi
|
|
549
|
-
});
|
|
550
|
-
return createInstance(context.registry, coordinate, clientApi);
|
|
551
|
-
};
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
const logger = LibLogger.get("Registry");
|
|
555
|
-
/**
|
|
556
|
-
* Factory function for creating client-api registries
|
|
557
|
-
*/ const createRegistryFactory = ()=>{
|
|
558
|
-
return (type, registryHub)=>{
|
|
559
|
-
if (type !== 'client-api') {
|
|
560
|
-
throw new Error(`Client API registry factory can only create 'client-api' type registries, got: ${type}`);
|
|
561
|
-
}
|
|
562
|
-
logger.debug("Creating client-api registry", {
|
|
563
|
-
type,
|
|
564
|
-
registryHub
|
|
565
|
-
});
|
|
566
|
-
const baseRegistry = registry.createRegistry(type, registryHub);
|
|
567
|
-
// Cast to Registry for type safety
|
|
568
|
-
return baseRegistry;
|
|
569
|
-
};
|
|
570
|
-
};
|
|
571
|
-
/**
|
|
572
|
-
* Creates a new client-api registry instance
|
|
573
|
-
*/ const createRegistry = (registryHub)=>{
|
|
574
|
-
const baseRegistry = registry.createRegistry('client-api', registryHub);
|
|
575
|
-
return {
|
|
576
|
-
...baseRegistry
|
|
577
|
-
};
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
exports.createCItemApi = createCItemApi;
|
|
581
|
-
exports.createInstance = createInstance;
|
|
582
|
-
exports.createInstanceFactory = createInstanceFactory;
|
|
583
|
-
exports.createPItemApi = createPItemApi;
|
|
584
|
-
exports.createRegistry = createRegistry;
|
|
585
|
-
exports.createRegistryFactory = createRegistryFactory;
|
|
586
|
-
//# sourceMappingURL=index.cjs.map
|