@fjell/client-api 4.4.6 → 4.4.7
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/Instance.d.ts +19 -0
- package/dist/Instance.js +19 -0
- package/dist/Instance.js.map +1 -0
- package/dist/InstanceFactory.d.ts +8 -0
- package/dist/InstanceFactory.js +19 -0
- package/dist/InstanceFactory.js.map +1 -0
- package/dist/Registry.d.ts +15 -0
- package/dist/Registry.js +31 -0
- package/dist/Registry.js.map +1 -0
- package/dist/index.cjs +106 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/examples/README.md +387 -0
- package/examples/enterprise-example.ts +852 -0
- package/examples/multi-level-keys.ts +467 -0
- package/examples/simple-example.ts +346 -0
- package/package.json +4 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Item } from '@fjell/core';
|
|
2
|
+
import { Instance as BaseInstance, Coordinate, Registry } from '@fjell/registry';
|
|
3
|
+
import { ClientApi } from './ClientApi';
|
|
4
|
+
/**
|
|
5
|
+
* The Client API Instance interface represents a client API model instance that extends the base Instance
|
|
6
|
+
* from @fjell/registry and adds client API operations for interacting with remote data.
|
|
7
|
+
*
|
|
8
|
+
* The interface extends the base Instance (which provides coordinate and registry) with:
|
|
9
|
+
* - clientApi: Provides methods for interacting with remote data through HTTP APIs (get, create, update, etc.)
|
|
10
|
+
*
|
|
11
|
+
* @template V - The type of the data model item, extending Item
|
|
12
|
+
* @template S - The string literal type representing the model's key type
|
|
13
|
+
* @template L1-L5 - Optional string literal types for location hierarchy levels
|
|
14
|
+
*/
|
|
15
|
+
export interface Instance<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> extends BaseInstance<S, L1, L2, L3, L4, L5> {
|
|
16
|
+
/** The client API object that provides methods for interacting with remote data */
|
|
17
|
+
clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>;
|
|
18
|
+
}
|
|
19
|
+
export declare const createInstance: <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>(registry: Registry, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>) => Instance<V, S, L1, L2, L3, L4, L5>;
|
package/dist/Instance.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import LibLogger from './logger.js';
|
|
2
|
+
import { createInstance as createInstance$1 } from '@fjell/registry';
|
|
3
|
+
|
|
4
|
+
const logger = LibLogger.get("Instance");
|
|
5
|
+
const createInstance = (registry, coordinate, clientApi)=>{
|
|
6
|
+
logger.debug("createInstance", {
|
|
7
|
+
coordinate,
|
|
8
|
+
clientApi,
|
|
9
|
+
registry
|
|
10
|
+
});
|
|
11
|
+
const baseInstance = createInstance$1(registry, coordinate);
|
|
12
|
+
return {
|
|
13
|
+
...baseInstance,
|
|
14
|
+
clientApi
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { createInstance };
|
|
19
|
+
//# sourceMappingURL=Instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Instance.js","sources":["../src/Instance.ts"],"sourcesContent":["\nimport LibLogger from \"@/logger\";\nimport { Item } from \"@fjell/core\";\nimport { Instance as BaseInstance, Coordinate, createInstance as createBaseInstance, Registry } from \"@fjell/registry\";\nimport { ClientApi } from \"./ClientApi\";\n\nconst logger = LibLogger.get(\"Instance\");\n\n/**\n * The Client API Instance interface represents a client API model instance that extends the base Instance\n * from @fjell/registry and adds client API operations for interacting with remote data.\n *\n * The interface extends the base Instance (which provides coordinate and registry) with:\n * - clientApi: Provides methods for interacting with remote data through HTTP APIs (get, create, update, etc.)\n *\n * @template V - The type of the data model item, extending Item\n * @template S - The string literal type representing the model's key type\n * @template L1-L5 - Optional string literal types for location hierarchy levels\n */\nexport interface Instance<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> extends BaseInstance<S, L1, L2, L3, L4, L5> {\n /** The client API object that provides methods for interacting with remote data */\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>;\n}\n\nexport const createInstance = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n registry: Registry,\n coordinate: Coordinate<S, L1, L2, L3, L4, L5>,\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>,\n ): Instance<V, S, L1, L2, L3, L4, L5> => {\n logger.debug(\"createInstance\", { coordinate, clientApi, registry });\n const baseInstance = createBaseInstance(registry, coordinate);\n return { ...baseInstance, clientApi };\n}\n"],"names":["logger","LibLogger","get","createInstance","registry","coordinate","clientApi","debug","baseInstance","createBaseInstance"],"mappings":";;;AAMA,MAAMA,MAAAA,GAASC,SAAAA,CAAUC,GAAG,CAAC,UAAA,CAAA;AA0BtB,MAAMC,cAAAA,GAAiB,CAS1BC,QAAAA,EACAC,UAAAA,EACAC,SAAAA,GAAAA;IAEFN,MAAAA,CAAOO,KAAK,CAAC,gBAAA,EAAkB;AAAEF,QAAAA,UAAAA;AAAYC,QAAAA,SAAAA;AAAWF,QAAAA;AAAS,KAAA,CAAA;IACjE,MAAMI,YAAAA,GAAeC,iBAAmBL,QAAAA,EAAUC,UAAAA,CAAAA;IAClD,OAAO;AAAE,QAAA,GAAGG,YAAY;AAAEF,QAAAA;AAAU,KAAA;AACtC;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Item } from '@fjell/core';
|
|
2
|
+
import { ClientApi } from './ClientApi';
|
|
3
|
+
import { InstanceFactory as BaseInstanceFactory } from '@fjell/registry';
|
|
4
|
+
export type InstanceFactory<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> = (clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>) => BaseInstanceFactory<S, L1, L2, L3, L4, L5>;
|
|
5
|
+
/**
|
|
6
|
+
* Factory function for creating client-api instances
|
|
7
|
+
*/
|
|
8
|
+
export declare const createInstanceFactory: <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>(clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>) => BaseInstanceFactory<S, L1, L2, L3, L4, L5>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createInstance } from './Instance.js';
|
|
2
|
+
import LibLogger from './logger.js';
|
|
3
|
+
|
|
4
|
+
const logger = LibLogger.get("InstanceFactory");
|
|
5
|
+
/**
|
|
6
|
+
* Factory function for creating client-api instances
|
|
7
|
+
*/ const createInstanceFactory = (clientApi)=>{
|
|
8
|
+
return (coordinate, context)=>{
|
|
9
|
+
logger.debug("Creating client-api instance", {
|
|
10
|
+
coordinate,
|
|
11
|
+
registry: context.registry,
|
|
12
|
+
clientApi
|
|
13
|
+
});
|
|
14
|
+
return createInstance(context.registry, coordinate, clientApi);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { createInstanceFactory };
|
|
19
|
+
//# sourceMappingURL=InstanceFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstanceFactory.js","sources":["../src/InstanceFactory.ts"],"sourcesContent":["import { Item } from \"@fjell/core\";\nimport { ClientApi } from \"./ClientApi\";\nimport { InstanceFactory as BaseInstanceFactory, Registry, RegistryHub } from \"@fjell/registry\";\nimport { createInstance, Instance } from \"./Instance\";\nimport { Coordinate } from \"@fjell/registry\";\nimport LibLogger from \"@/logger\";\n\nconst logger = LibLogger.get(\"InstanceFactory\");\n\nexport type InstanceFactory<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> = (\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>\n) => BaseInstanceFactory<S, L1, L2, L3, L4, L5>;\n\n/**\n * Factory function for creating client-api instances\n */\nexport const createInstanceFactory = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>\n ): BaseInstanceFactory<S, L1, L2, L3, L4, L5> => {\n return (coordinate: Coordinate<S, L1, L2, L3, L4, L5>, context: { registry: Registry, registryHub?: RegistryHub }) => {\n logger.debug(\"Creating client-api instance\", { coordinate, registry: context.registry, clientApi });\n\n return createInstance(context.registry, coordinate, clientApi) as Instance<V, S, L1, L2, L3, L4, L5>;\n };\n};\n"],"names":["logger","LibLogger","get","createInstanceFactory","clientApi","coordinate","context","debug","registry","createInstance"],"mappings":";;;AAOA,MAAMA,MAAAA,GAASC,SAAAA,CAAUC,GAAG,CAAC,iBAAA,CAAA;AAc7B;;IAGO,MAAMC,qBAAAA,GAAwB,CASjCC,SAAAA,GAAAA;AAEF,IAAA,OAAO,CAACC,UAAAA,EAA+CC,OAAAA,GAAAA;QACrDN,MAAAA,CAAOO,KAAK,CAAC,8BAAA,EAAgC;AAAEF,YAAAA,UAAAA;AAAYG,YAAAA,QAAAA,EAAUF,QAAQE,QAAQ;AAAEJ,YAAAA;AAAU,SAAA,CAAA;AAEjG,QAAA,OAAOK,cAAAA,CAAeH,OAAAA,CAAQE,QAAQ,EAAEH,UAAAA,EAAYD,SAAAA,CAAAA;AACtD,IAAA,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Registry as BaseRegistry, RegistryFactory, RegistryHub } from '@fjell/registry';
|
|
2
|
+
/**
|
|
3
|
+
* Extended Registry interface for client-api-specific functionality
|
|
4
|
+
*/
|
|
5
|
+
export interface Registry extends BaseRegistry {
|
|
6
|
+
type: 'client-api';
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Factory function for creating client-api registries
|
|
10
|
+
*/
|
|
11
|
+
export declare const createRegistryFactory: () => RegistryFactory;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new client-api registry instance
|
|
14
|
+
*/
|
|
15
|
+
export declare const createRegistry: (registryHub?: RegistryHub) => Registry;
|
package/dist/Registry.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import LibLogger from './logger.js';
|
|
2
|
+
import { createRegistry as createRegistry$1 } from '@fjell/registry';
|
|
3
|
+
|
|
4
|
+
const logger = LibLogger.get("Registry");
|
|
5
|
+
/**
|
|
6
|
+
* Factory function for creating client-api registries
|
|
7
|
+
*/ const createRegistryFactory = ()=>{
|
|
8
|
+
return (type, registryHub)=>{
|
|
9
|
+
if (type !== 'client-api') {
|
|
10
|
+
throw new Error(`Client API registry factory can only create 'client-api' type registries, got: ${type}`);
|
|
11
|
+
}
|
|
12
|
+
logger.debug("Creating client-api registry", {
|
|
13
|
+
type,
|
|
14
|
+
registryHub
|
|
15
|
+
});
|
|
16
|
+
const baseRegistry = createRegistry$1(type, registryHub);
|
|
17
|
+
// Cast to Registry for type safety
|
|
18
|
+
return baseRegistry;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new client-api registry instance
|
|
23
|
+
*/ const createRegistry = (registryHub)=>{
|
|
24
|
+
const baseRegistry = createRegistry$1('client-api', registryHub);
|
|
25
|
+
return {
|
|
26
|
+
...baseRegistry
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { createRegistry, createRegistryFactory };
|
|
31
|
+
//# sourceMappingURL=Registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Registry.js","sources":["../src/Registry.ts"],"sourcesContent":["import LibLogger from '@/logger';\nimport {\n Registry as BaseRegistry,\n createRegistry as createBaseRegistry,\n RegistryFactory,\n RegistryHub\n} from '@fjell/registry';\n\nconst logger = LibLogger.get(\"Registry\");\n\n/**\n * Extended Registry interface for client-api-specific functionality\n */\nexport interface Registry extends BaseRegistry {\n type: 'client-api';\n}\n\n/**\n * Factory function for creating client-api registries\n */\nexport const createRegistryFactory = (): RegistryFactory => {\n return (type: string, registryHub?: RegistryHub): BaseRegistry => {\n if (type !== 'client-api') {\n throw new Error(`Client API registry factory can only create 'client-api' type registries, got: ${type}`);\n }\n\n logger.debug(\"Creating client-api registry\", { type, registryHub });\n\n const baseRegistry = createBaseRegistry(type, registryHub);\n\n // Cast to Registry for type safety\n return baseRegistry as Registry;\n };\n};\n\n/**\n * Creates a new client-api registry instance\n */\nexport const createRegistry = (registryHub?: RegistryHub): Registry => {\n const baseRegistry = createBaseRegistry('client-api', registryHub);\n\n return {\n ...baseRegistry,\n } as Registry;\n};\n"],"names":["logger","LibLogger","get","createRegistryFactory","type","registryHub","Error","debug","baseRegistry","createBaseRegistry","createRegistry"],"mappings":";;;AAQA,MAAMA,MAAAA,GAASC,SAAAA,CAAUC,GAAG,CAAC,UAAA,CAAA;AAS7B;;UAGaC,qBAAAA,GAAwB,IAAA;AACnC,IAAA,OAAO,CAACC,IAAAA,EAAcC,WAAAA,GAAAA;AACpB,QAAA,IAAID,SAAS,YAAA,EAAc;AACzB,YAAA,MAAM,IAAIE,KAAAA,CAAM,CAAC,+EAA+E,EAAEF,IAAAA,CAAAA,CAAM,CAAA;AAC1G,QAAA;QAEAJ,MAAAA,CAAOO,KAAK,CAAC,8BAAA,EAAgC;AAAEH,YAAAA,IAAAA;AAAMC,YAAAA;AAAY,SAAA,CAAA;QAEjE,MAAMG,YAAAA,GAAeC,iBAAmBL,IAAAA,EAAMC,WAAAA,CAAAA;;QAG9C,OAAOG,YAAAA;AACT,IAAA,CAAA;AACF;AAEA;;IAGO,MAAME,cAAAA,GAAiB,CAACL,WAAAA,GAAAA;IAC7B,MAAMG,YAAAA,GAAeC,iBAAmB,YAAA,EAAcJ,WAAAA,CAAAA;IAEtD,OAAO;AACL,QAAA,GAAGG;AACL,KAAA;AACF;;;;"}
|
package/dist/index.cjs
CHANGED
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const core = require('@fjell/core');
|
|
6
6
|
const Logging = require('@fjell/logging');
|
|
7
7
|
const deepmerge = require('deepmerge');
|
|
8
|
+
const registry = require('@fjell/registry');
|
|
8
9
|
|
|
9
10
|
const LibLogger = Logging.getLogger('@fjell/client-api');
|
|
10
11
|
|
|
11
|
-
const logger$
|
|
12
|
+
const logger$i = LibLogger.get('client-api', 'ops', 'all');
|
|
12
13
|
const getAllOperation = (api, apiOptions, utilities)=>{
|
|
13
14
|
const all = async (query = {}, locations = [])=>{
|
|
14
15
|
utilities.verifyLocations(locations);
|
|
@@ -18,7 +19,7 @@ const getAllOperation = (api, apiOptions, utilities)=>{
|
|
|
18
19
|
isAuthenticated: apiOptions.allAuthenticated,
|
|
19
20
|
params
|
|
20
21
|
});
|
|
21
|
-
logger$
|
|
22
|
+
logger$i.default('all', {
|
|
22
23
|
query,
|
|
23
24
|
locations,
|
|
24
25
|
requestOptions
|
|
@@ -28,13 +29,13 @@ const getAllOperation = (api, apiOptions, utilities)=>{
|
|
|
28
29
|
return all;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
const logger$
|
|
32
|
+
const logger$h = LibLogger.get('client-api', 'ops', 'action');
|
|
32
33
|
const getActionOperation = (api, apiOptions, utilities)=>{
|
|
33
34
|
const action = async (ik, action, body = {})=>{
|
|
34
35
|
const requestOptions = Object.assign({}, apiOptions.postOptions, {
|
|
35
36
|
isAuthenticated: apiOptions.writeAuthenticated
|
|
36
37
|
});
|
|
37
|
-
logger$
|
|
38
|
+
logger$h.default('action', {
|
|
38
39
|
ik,
|
|
39
40
|
action,
|
|
40
41
|
body,
|
|
@@ -45,13 +46,13 @@ const getActionOperation = (api, apiOptions, utilities)=>{
|
|
|
45
46
|
return action;
|
|
46
47
|
};
|
|
47
48
|
|
|
48
|
-
const logger$
|
|
49
|
+
const logger$g = LibLogger.get('client-api', 'ops', 'allAction');
|
|
49
50
|
const getAllActionOperation = (api, apiOptions, utilities)=>{
|
|
50
51
|
const allAction = async (action, body = {}, locations = [])=>{
|
|
51
52
|
const requestOptions = Object.assign({}, apiOptions.postOptions, {
|
|
52
53
|
isAuthenticated: apiOptions.writeAuthenticated
|
|
53
54
|
});
|
|
54
|
-
logger$
|
|
55
|
+
logger$g.default('allAction', {
|
|
55
56
|
action,
|
|
56
57
|
body,
|
|
57
58
|
locations,
|
|
@@ -65,7 +66,7 @@ const getAllActionOperation = (api, apiOptions, utilities)=>{
|
|
|
65
66
|
return allAction;
|
|
66
67
|
};
|
|
67
68
|
|
|
68
|
-
const logger$
|
|
69
|
+
const logger$f = LibLogger.get('client-api', 'ops', 'one');
|
|
69
70
|
const getOneOperation = (api, apiOptions, utilities)=>{
|
|
70
71
|
const one = async (query = {}, locations = [])=>{
|
|
71
72
|
utilities.verifyLocations(locations);
|
|
@@ -75,7 +76,7 @@ const getOneOperation = (api, apiOptions, utilities)=>{
|
|
|
75
76
|
isAuthenticated: apiOptions.readAuthenticated,
|
|
76
77
|
params
|
|
77
78
|
});
|
|
78
|
-
logger$
|
|
79
|
+
logger$f.default('one', {
|
|
79
80
|
query,
|
|
80
81
|
locations,
|
|
81
82
|
requestOptions
|
|
@@ -90,13 +91,13 @@ const getOneOperation = (api, apiOptions, utilities)=>{
|
|
|
90
91
|
return one;
|
|
91
92
|
};
|
|
92
93
|
|
|
93
|
-
const logger$
|
|
94
|
+
const logger$e = LibLogger.get('client-api', 'ops', 'create');
|
|
94
95
|
const getCreateOperation = (api, apiOptions, utilities)=>{
|
|
95
96
|
const create = async (item, locations = [])=>{
|
|
96
97
|
const requestOptions = Object.assign({}, apiOptions.postOptions, {
|
|
97
98
|
isAuthenticated: apiOptions.writeAuthenticated
|
|
98
99
|
});
|
|
99
|
-
logger$
|
|
100
|
+
logger$e.default('create', {
|
|
100
101
|
item,
|
|
101
102
|
locations,
|
|
102
103
|
requestOptions
|
|
@@ -109,13 +110,13 @@ const getCreateOperation = (api, apiOptions, utilities)=>{
|
|
|
109
110
|
return create;
|
|
110
111
|
};
|
|
111
112
|
|
|
112
|
-
const logger$
|
|
113
|
+
const logger$d = LibLogger.get('client-api', 'ops', 'update');
|
|
113
114
|
const getUpdateOperation = (api, apiOptions, utilities)=>{
|
|
114
115
|
const update = async (ik, item)=>{
|
|
115
116
|
const requestOptions = Object.assign({}, apiOptions.putOptions, {
|
|
116
117
|
isAuthenticated: apiOptions.writeAuthenticated
|
|
117
118
|
});
|
|
118
|
-
logger$
|
|
119
|
+
logger$d.default('update', {
|
|
119
120
|
ik,
|
|
120
121
|
item,
|
|
121
122
|
requestOptions
|
|
@@ -125,13 +126,13 @@ const getUpdateOperation = (api, apiOptions, utilities)=>{
|
|
|
125
126
|
return update;
|
|
126
127
|
};
|
|
127
128
|
|
|
128
|
-
const logger$
|
|
129
|
+
const logger$c = LibLogger.get('client-api', 'ops', 'get');
|
|
129
130
|
const getGetOperation = (api, apiOptions, utilities)=>{
|
|
130
131
|
const get = async (ik)=>{
|
|
131
132
|
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
132
133
|
isAuthenticated: apiOptions.readAuthenticated
|
|
133
134
|
});
|
|
134
|
-
logger$
|
|
135
|
+
logger$c.default('get', {
|
|
135
136
|
ik,
|
|
136
137
|
requestOptions
|
|
137
138
|
});
|
|
@@ -140,13 +141,13 @@ const getGetOperation = (api, apiOptions, utilities)=>{
|
|
|
140
141
|
return get;
|
|
141
142
|
};
|
|
142
143
|
|
|
143
|
-
const logger$
|
|
144
|
+
const logger$b = LibLogger.get('client-api', 'ops', 'remove');
|
|
144
145
|
const getRemoveOperation = (api, apiOptions, utilities)=>{
|
|
145
146
|
const remove = async (ik)=>{
|
|
146
147
|
const requestOptions = Object.assign({}, apiOptions.deleteOptions, {
|
|
147
148
|
isAuthenticated: apiOptions.writeAuthenticated
|
|
148
149
|
});
|
|
149
|
-
logger$
|
|
150
|
+
logger$b.default('remove', {
|
|
150
151
|
ik,
|
|
151
152
|
requestOptions
|
|
152
153
|
});
|
|
@@ -155,7 +156,7 @@ const getRemoveOperation = (api, apiOptions, utilities)=>{
|
|
|
155
156
|
return remove;
|
|
156
157
|
};
|
|
157
158
|
|
|
158
|
-
const logger$
|
|
159
|
+
const logger$a = LibLogger.get('client-api', 'ops', 'find');
|
|
159
160
|
const getFindOperation = (api, apiOptions, utilities)=>{
|
|
160
161
|
const find = async (finder, finderParams = {}, locations = [])=>{
|
|
161
162
|
utilities.verifyLocations(locations);
|
|
@@ -165,7 +166,7 @@ const getFindOperation = (api, apiOptions, utilities)=>{
|
|
|
165
166
|
isAuthenticated: apiOptions.allAuthenticated,
|
|
166
167
|
params: mergedParams
|
|
167
168
|
});
|
|
168
|
-
logger$
|
|
169
|
+
logger$a.default('find', {
|
|
169
170
|
finder,
|
|
170
171
|
finderParams,
|
|
171
172
|
locations,
|
|
@@ -176,7 +177,7 @@ const getFindOperation = (api, apiOptions, utilities)=>{
|
|
|
176
177
|
return find;
|
|
177
178
|
};
|
|
178
179
|
|
|
179
|
-
const logger$
|
|
180
|
+
const logger$9 = LibLogger.get('client-api', 'ops', 'find');
|
|
180
181
|
const getFindOneOperation = (api, apiOptions, utilities)=>{
|
|
181
182
|
const findOne = async (finder, finderParams = {}, locations = [])=>{
|
|
182
183
|
utilities.verifyLocations(locations);
|
|
@@ -187,7 +188,7 @@ const getFindOneOperation = (api, apiOptions, utilities)=>{
|
|
|
187
188
|
isAuthenticated: apiOptions.allAuthenticated,
|
|
188
189
|
params
|
|
189
190
|
});
|
|
190
|
-
logger$
|
|
191
|
+
logger$9.default('findOne', {
|
|
191
192
|
finder,
|
|
192
193
|
finderParams,
|
|
193
194
|
locations,
|
|
@@ -198,7 +199,7 @@ const getFindOneOperation = (api, apiOptions, utilities)=>{
|
|
|
198
199
|
return findOne;
|
|
199
200
|
};
|
|
200
201
|
|
|
201
|
-
const logger$
|
|
202
|
+
const logger$8 = LibLogger.get('client-api', 'ops', 'facet');
|
|
202
203
|
const getFacetOperation = (api, apiOptions, utilities)=>{
|
|
203
204
|
/**
|
|
204
205
|
* Executes a facet operation on an item.
|
|
@@ -218,7 +219,7 @@ const getFacetOperation = (api, apiOptions, utilities)=>{
|
|
|
218
219
|
isAuthenticated: apiOptions.writeAuthenticated,
|
|
219
220
|
params
|
|
220
221
|
});
|
|
221
|
-
logger$
|
|
222
|
+
logger$8.default('facet', {
|
|
222
223
|
ik,
|
|
223
224
|
facet,
|
|
224
225
|
requestOptions
|
|
@@ -228,14 +229,14 @@ const getFacetOperation = (api, apiOptions, utilities)=>{
|
|
|
228
229
|
return facet;
|
|
229
230
|
};
|
|
230
231
|
|
|
231
|
-
const logger$
|
|
232
|
+
const logger$7 = LibLogger.get('client-api', 'ops', 'allFacet');
|
|
232
233
|
const getAllFacetOperation = (api, apiOptions, utilities)=>{
|
|
233
234
|
const allFacet = async (facet, params = {}, locations = [])=>{
|
|
234
235
|
const requestOptions = Object.assign({}, apiOptions.getOptions, {
|
|
235
236
|
isAuthenticated: apiOptions.writeAuthenticated,
|
|
236
237
|
params
|
|
237
238
|
});
|
|
238
|
-
logger$
|
|
239
|
+
logger$7.default('allFacet', {
|
|
239
240
|
facet,
|
|
240
241
|
locations,
|
|
241
242
|
requestOptions
|
|
@@ -265,9 +266,9 @@ const getOperations = (api, apiOptions, utilities)=>{
|
|
|
265
266
|
};
|
|
266
267
|
};
|
|
267
268
|
|
|
268
|
-
const logger$
|
|
269
|
+
const logger$6 = LibLogger.get('client-api', 'Utility');
|
|
269
270
|
const createUtilities = (pkType, pathNames)=>{
|
|
270
|
-
logger$
|
|
271
|
+
logger$6.default('createUtilities', {
|
|
271
272
|
pkType,
|
|
272
273
|
pathNames
|
|
273
274
|
});
|
|
@@ -278,34 +279,34 @@ const createUtilities = (pkType, pathNames)=>{
|
|
|
278
279
|
return true;
|
|
279
280
|
};
|
|
280
281
|
const processOne = async (apiCall)=>{
|
|
281
|
-
logger$
|
|
282
|
+
logger$6.default('processOne', {
|
|
282
283
|
apiCall
|
|
283
284
|
});
|
|
284
285
|
const response = await apiCall;
|
|
285
|
-
logger$
|
|
286
|
+
logger$6.default('processOne response', {
|
|
286
287
|
response: JSON.stringify(response, null, 2)
|
|
287
288
|
});
|
|
288
289
|
return convertDoc(response);
|
|
289
290
|
};
|
|
290
291
|
const processArray = async (api)=>{
|
|
291
|
-
logger$
|
|
292
|
+
logger$6.default('processArray', {
|
|
292
293
|
api
|
|
293
294
|
});
|
|
294
295
|
const response = await api;
|
|
295
|
-
logger$
|
|
296
|
+
logger$6.default('processArray response', {
|
|
296
297
|
response: JSON.stringify(response, null, 2)
|
|
297
298
|
});
|
|
298
299
|
if (response && Array.isArray(response)) {
|
|
299
300
|
return response.map((subjectChat)=>convertDoc(subjectChat));
|
|
300
301
|
} else {
|
|
301
|
-
logger$
|
|
302
|
+
logger$6.error('Response was not an array', {
|
|
302
303
|
response
|
|
303
304
|
});
|
|
304
305
|
throw new Error('Response was not an array');
|
|
305
306
|
}
|
|
306
307
|
};
|
|
307
308
|
const convertDoc = (doc)=>{
|
|
308
|
-
logger$
|
|
309
|
+
logger$6.default('convertDoc', {
|
|
309
310
|
doc
|
|
310
311
|
});
|
|
311
312
|
// console.log(JSON.stringify(doc, null, 2));
|
|
@@ -325,7 +326,7 @@ const createUtilities = (pkType, pathNames)=>{
|
|
|
325
326
|
const localPathNames = [
|
|
326
327
|
...pathNames
|
|
327
328
|
];
|
|
328
|
-
logger$
|
|
329
|
+
logger$6.default('getPath', {
|
|
329
330
|
key,
|
|
330
331
|
pathNames: localPathNames
|
|
331
332
|
});
|
|
@@ -339,26 +340,26 @@ const createUtilities = (pkType, pathNames)=>{
|
|
|
339
340
|
if (localPathNames.length === 1) {
|
|
340
341
|
path = `${path}/${localPathNames[0]}`;
|
|
341
342
|
}
|
|
342
|
-
logger$
|
|
343
|
+
logger$6.default('getPath created', {
|
|
343
344
|
key,
|
|
344
345
|
path
|
|
345
346
|
});
|
|
346
347
|
return path;
|
|
347
348
|
};
|
|
348
349
|
const addPath = (base, keys, localPathNames)=>{
|
|
349
|
-
logger$
|
|
350
|
+
logger$6.default('addPath', {
|
|
350
351
|
base,
|
|
351
352
|
keys,
|
|
352
353
|
pathNames: localPathNames
|
|
353
354
|
});
|
|
354
355
|
if (keys.length < localPathNames.length - 1) {
|
|
355
|
-
logger$
|
|
356
|
+
logger$6.error('addPath should never have keys with a length less than the length of pathNames - 1', {
|
|
356
357
|
keys,
|
|
357
358
|
localPathNames
|
|
358
359
|
});
|
|
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));
|
|
360
361
|
} else if (keys.length > localPathNames.length) {
|
|
361
|
-
logger$
|
|
362
|
+
logger$6.error('addPath should never have keys with a length greater than the length of pathNames', {
|
|
362
363
|
keys,
|
|
363
364
|
pathNames
|
|
364
365
|
});
|
|
@@ -366,7 +367,7 @@ const createUtilities = (pkType, pathNames)=>{
|
|
|
366
367
|
}
|
|
367
368
|
if (keys.length === 0) {
|
|
368
369
|
// If you've recursively consumed all of the keys, return the base.
|
|
369
|
-
logger$
|
|
370
|
+
logger$6.default('addPath returning base', {
|
|
370
371
|
base
|
|
371
372
|
});
|
|
372
373
|
return base;
|
|
@@ -378,7 +379,7 @@ const createUtilities = (pkType, pathNames)=>{
|
|
|
378
379
|
if (core.isPriKey(key)) {
|
|
379
380
|
const PriKey = key;
|
|
380
381
|
nextBase = `${base}/${pathName}/${PriKey.pk}`;
|
|
381
|
-
logger$
|
|
382
|
+
logger$6.default('Adding Path for PK', {
|
|
382
383
|
pathName,
|
|
383
384
|
PriKey,
|
|
384
385
|
nextBase
|
|
@@ -386,12 +387,12 @@ const createUtilities = (pkType, pathNames)=>{
|
|
|
386
387
|
} else {
|
|
387
388
|
const LocKey = key;
|
|
388
389
|
nextBase = `${base}/${pathName}/${LocKey.lk}`;
|
|
389
|
-
logger$
|
|
390
|
+
logger$6.default('Retrieving Collection for LK', {
|
|
390
391
|
pathName,
|
|
391
392
|
LocKey
|
|
392
393
|
});
|
|
393
394
|
}
|
|
394
|
-
logger$
|
|
395
|
+
logger$6.default('calling addPath recursively', {
|
|
395
396
|
nextBase,
|
|
396
397
|
keys,
|
|
397
398
|
localPathNames
|
|
@@ -412,7 +413,7 @@ const createUtilities = (pkType, pathNames)=>{
|
|
|
412
413
|
};
|
|
413
414
|
};
|
|
414
415
|
|
|
415
|
-
const logger$
|
|
416
|
+
const logger$5 = LibLogger.get('AItemAPI');
|
|
416
417
|
const finderToParams = (finder, finderParams)=>{
|
|
417
418
|
return {
|
|
418
419
|
finder,
|
|
@@ -420,7 +421,7 @@ const finderToParams = (finder, finderParams)=>{
|
|
|
420
421
|
};
|
|
421
422
|
};
|
|
422
423
|
const createAItemAPI = (api, pkType, pathNames, options)=>{
|
|
423
|
-
logger$
|
|
424
|
+
logger$5.default('createAItemAPI', {
|
|
424
425
|
pkType,
|
|
425
426
|
pathNames,
|
|
426
427
|
options
|
|
@@ -458,9 +459,9 @@ const createAItemAPI = (api, pkType, pathNames, options)=>{
|
|
|
458
459
|
};
|
|
459
460
|
};
|
|
460
461
|
|
|
461
|
-
const logger$
|
|
462
|
+
const logger$4 = LibLogger.get('CItemAPI');
|
|
462
463
|
const createCItemApi = (api, type, pathNames, options)=>{
|
|
463
|
-
logger$
|
|
464
|
+
logger$4.default('createCItemApi', {
|
|
464
465
|
api,
|
|
465
466
|
type,
|
|
466
467
|
pathNames,
|
|
@@ -483,9 +484,9 @@ const createCItemApi = (api, type, pathNames, options)=>{
|
|
|
483
484
|
};
|
|
484
485
|
};
|
|
485
486
|
|
|
486
|
-
const logger = LibLogger.get('PItemAPI');
|
|
487
|
+
const logger$3 = LibLogger.get('PItemAPI');
|
|
487
488
|
const createPItemApi = (api, type, pathName, options)=>{
|
|
488
|
-
logger.default('createPItemApi', {
|
|
489
|
+
logger$3.default('createPItemApi', {
|
|
489
490
|
type,
|
|
490
491
|
pathName,
|
|
491
492
|
options
|
|
@@ -522,6 +523,64 @@ const createPItemApi = (api, type, pathName, options)=>{
|
|
|
522
523
|
};
|
|
523
524
|
};
|
|
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
|
+
|
|
525
580
|
exports.createCItemApi = createCItemApi;
|
|
581
|
+
exports.createInstance = createInstance;
|
|
582
|
+
exports.createInstanceFactory = createInstanceFactory;
|
|
526
583
|
exports.createPItemApi = createPItemApi;
|
|
584
|
+
exports.createRegistry = createRegistry;
|
|
585
|
+
exports.createRegistryFactory = createRegistryFactory;
|
|
527
586
|
//# sourceMappingURL=index.cjs.map
|