@fjell/cache 4.6.13 → 4.6.15
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/Aggregator.d.ts +3 -3
- package/dist/Cache.d.ts +6 -6
- package/dist/CacheMap.d.ts +1 -1
- package/dist/Instance.d.ts +5 -5
- package/dist/InstanceFactory.d.ts +3 -3
- package/dist/Operations.d.ts +4 -4
- package/dist/index.js +715 -0
- package/dist/index.js.map +7 -0
- package/dist/logger.d.ts +1 -1
- package/dist/ops/action.d.ts +3 -3
- package/dist/ops/all.d.ts +3 -3
- package/dist/ops/allAction.d.ts +3 -3
- package/dist/ops/allFacet.d.ts +3 -3
- package/dist/ops/create.d.ts +3 -3
- package/dist/ops/facet.d.ts +3 -3
- package/dist/ops/find.d.ts +3 -3
- package/dist/ops/findOne.d.ts +3 -3
- package/dist/ops/get.d.ts +3 -3
- package/dist/ops/one.d.ts +3 -3
- package/dist/ops/remove.d.ts +3 -3
- package/dist/ops/reset.d.ts +3 -3
- package/dist/ops/retrieve.d.ts +3 -3
- package/dist/ops/set.d.ts +2 -2
- package/dist/ops/update.d.ts +3 -3
- package/package.json +8 -12
- package/dist/Aggregator.cjs.js +0 -322
- package/dist/Aggregator.es.js +0 -317
- package/dist/Cache.cjs.js +0 -35
- package/dist/Cache.es.js +0 -30
- package/dist/CacheMap.cjs.js +0 -170
- package/dist/CacheMap.es.js +0 -166
- package/dist/Instance.cjs.js +0 -23
- package/dist/Instance.es.js +0 -18
- package/dist/InstanceFactory.cjs.js +0 -35
- package/dist/InstanceFactory.es.js +0 -31
- package/dist/Operations.cjs.js +0 -43
- package/dist/Operations.es.js +0 -39
- package/dist/Registry.cjs.js +0 -36
- package/dist/Registry.es.js +0 -31
- package/dist/index.cjs +0 -940
- package/dist/index.cjs.js +0 -26
- package/dist/index.cjs.map +0 -1
- package/dist/index.es.js +0 -8
- package/dist/logger.cjs.js +0 -10
- package/dist/logger.es.js +0 -6
- package/dist/ops/action.cjs.js +0 -28
- package/dist/ops/action.es.js +0 -24
- package/dist/ops/all.cjs.js +0 -33
- package/dist/ops/all.es.js +0 -29
- package/dist/ops/allAction.cjs.js +0 -35
- package/dist/ops/allAction.es.js +0 -31
- package/dist/ops/allFacet.cjs.js +0 -22
- package/dist/ops/allFacet.es.js +0 -18
- package/dist/ops/create.cjs.js +0 -23
- package/dist/ops/create.es.js +0 -19
- package/dist/ops/facet.cjs.js +0 -21
- package/dist/ops/facet.es.js +0 -17
- package/dist/ops/find.cjs.js +0 -26
- package/dist/ops/find.es.js +0 -22
- package/dist/ops/findOne.cjs.js +0 -24
- package/dist/ops/findOne.es.js +0 -20
- package/dist/ops/get.cjs.js +0 -38
- package/dist/ops/get.es.js +0 -34
- package/dist/ops/one.cjs.js +0 -33
- package/dist/ops/one.es.js +0 -29
- package/dist/ops/remove.cjs.js +0 -30
- package/dist/ops/remove.es.js +0 -26
- package/dist/ops/reset.cjs.js +0 -15
- package/dist/ops/reset.es.js +0 -11
- package/dist/ops/retrieve.cjs.js +0 -37
- package/dist/ops/retrieve.es.js +0 -33
- package/dist/ops/set.cjs.js +0 -71
- package/dist/ops/set.es.js +0 -67
- package/dist/ops/update.cjs.js +0 -34
- package/dist/ops/update.es.js +0 -30
- package/docs/docs.config.ts +0 -75
- package/docs/index.html +0 -18
- package/docs/package.json +0 -34
- package/docs/public/README.md +0 -96
- package/docs/public/examples-README.md +0 -302
- package/docs/public/test.txt +0 -0
- package/docs/src/index.css +0 -3
- package/docs/src/main.tsx +0 -12
- package/docs/src/test/setup.ts +0 -1
- package/docs/tsconfig.node.json +0 -15
- package/examples/README.md +0 -302
- package/examples/aggregator-example.ts +0 -329
- package/examples/basic-cache-example.ts +0 -270
- package/examples/cache-map-example.ts +0 -265
- package/vitest.config.ts +0 -44
package/dist/CacheMap.cjs.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const core = require('@fjell/core');
|
|
6
|
-
const logger$1 = require('./logger.cjs.js');
|
|
7
|
-
|
|
8
|
-
function _define_property(obj, key, value) {
|
|
9
|
-
if (key in obj) {
|
|
10
|
-
Object.defineProperty(obj, key, {
|
|
11
|
-
value: value,
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true
|
|
15
|
-
});
|
|
16
|
-
} else {
|
|
17
|
-
obj[key] = value;
|
|
18
|
-
}
|
|
19
|
-
return obj;
|
|
20
|
-
}
|
|
21
|
-
const logger = logger$1.default.get("CacheMap");
|
|
22
|
-
// Normalize a key value to string for consistent comparison and hashing
|
|
23
|
-
const normalizeKeyValue = (value)=>{
|
|
24
|
-
return String(value);
|
|
25
|
-
};
|
|
26
|
-
// Normalized hash function for Dictionary that converts pk/lk values to strings
|
|
27
|
-
const createNormalizedHashFunction = ()=>{
|
|
28
|
-
return (key)=>{
|
|
29
|
-
if (typeof key === 'object' && key !== null) {
|
|
30
|
-
// Create a normalized version of the key with string values
|
|
31
|
-
const normalizedKey = JSON.parse(JSON.stringify(key));
|
|
32
|
-
// Normalize pk values
|
|
33
|
-
if ('pk' in normalizedKey && normalizedKey.pk !== null) {
|
|
34
|
-
normalizedKey.pk = normalizeKeyValue(normalizedKey.pk);
|
|
35
|
-
}
|
|
36
|
-
// Normalize lk values
|
|
37
|
-
if ('lk' in normalizedKey && normalizedKey.lk !== null) {
|
|
38
|
-
normalizedKey.lk = normalizeKeyValue(normalizedKey.lk);
|
|
39
|
-
}
|
|
40
|
-
// Normalize loc array lk values
|
|
41
|
-
if ('loc' in normalizedKey && Array.isArray(normalizedKey.loc)) {
|
|
42
|
-
normalizedKey.loc = normalizedKey.loc.map((locItem)=>{
|
|
43
|
-
if (locItem && 'lk' in locItem && locItem.lk !== null) {
|
|
44
|
-
return {
|
|
45
|
-
...locItem,
|
|
46
|
-
lk: normalizeKeyValue(locItem.lk)
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return locItem;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return JSON.stringify(normalizedKey);
|
|
53
|
-
}
|
|
54
|
-
return JSON.stringify(key);
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
// Helper function to normalize and compare location key arrays
|
|
58
|
-
const isLocKeyArrayEqual = (a, b)=>{
|
|
59
|
-
if (a.length !== b.length) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
for(let i = 0; i < a.length; i++){
|
|
63
|
-
const normalizedA = normalizeLocKeyItem(a[i]);
|
|
64
|
-
const normalizedB = normalizeLocKeyItem(b[i]);
|
|
65
|
-
if (JSON.stringify(normalizedA) !== JSON.stringify(normalizedB)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
};
|
|
71
|
-
// Helper function to normalize a location key item
|
|
72
|
-
const normalizeLocKeyItem = (item)=>{
|
|
73
|
-
if (typeof item === 'object' && item !== null) {
|
|
74
|
-
const normalized = {
|
|
75
|
-
...item
|
|
76
|
-
};
|
|
77
|
-
if ('lk' in normalized && normalized.lk !== null) {
|
|
78
|
-
normalized.lk = normalizeKeyValue(normalized.lk);
|
|
79
|
-
}
|
|
80
|
-
return normalized;
|
|
81
|
-
}
|
|
82
|
-
return item;
|
|
83
|
-
};
|
|
84
|
-
// const isObj = (x: any) => typeof x === "object" && x !== null;
|
|
85
|
-
// const intersection = (a: object, b: object): object => {
|
|
86
|
-
// const result: { [key: string]: any } = {}
|
|
87
|
-
// if (([a, b]).every(isObj)) {
|
|
88
|
-
// Object.keys(a).forEach((key) => {
|
|
89
|
-
// // @ts-ignore
|
|
90
|
-
// const value = a[key]
|
|
91
|
-
// // @ts-ignore
|
|
92
|
-
// const other = b[key]
|
|
93
|
-
// if (isObj(value)) {
|
|
94
|
-
// result[key] = intersection(value, other)
|
|
95
|
-
// } else if (value === other) {
|
|
96
|
-
// result[key] = value
|
|
97
|
-
// }
|
|
98
|
-
// })
|
|
99
|
-
// }
|
|
100
|
-
// return result
|
|
101
|
-
// }
|
|
102
|
-
// const removeEmptyObjects = (obj: object): object => {
|
|
103
|
-
// const result: { [key: string]: any } = {}
|
|
104
|
-
// Object.keys(obj).forEach((key) => {
|
|
105
|
-
// // @ts-ignore
|
|
106
|
-
// const value = obj[key];
|
|
107
|
-
// if (isObj(value)) {
|
|
108
|
-
// const nested = removeEmptyObjects(value);
|
|
109
|
-
// if (Object.keys(nested).length > 0) {
|
|
110
|
-
// result[key] = nested
|
|
111
|
-
// }
|
|
112
|
-
// } else if (value !== null) {
|
|
113
|
-
// result[key] = value
|
|
114
|
-
// }
|
|
115
|
-
// });
|
|
116
|
-
// return result;
|
|
117
|
-
// }
|
|
118
|
-
class CacheMap extends core.Dictionary {
|
|
119
|
-
get(key) {
|
|
120
|
-
return super.get(key);
|
|
121
|
-
}
|
|
122
|
-
allIn(locations) {
|
|
123
|
-
if (locations.length === 0) {
|
|
124
|
-
logger.debug('Returning all items, LocKeys is empty');
|
|
125
|
-
return this.values();
|
|
126
|
-
} else {
|
|
127
|
-
const locKeys = locations;
|
|
128
|
-
logger.debug('allIn', {
|
|
129
|
-
locKeys,
|
|
130
|
-
keys: this.keys().length
|
|
131
|
-
});
|
|
132
|
-
return this.keys().filter((key)=>key && core.isComKey(key)).filter((key)=>{
|
|
133
|
-
const ComKey = key;
|
|
134
|
-
logger.debug('Comparing Location Keys', {
|
|
135
|
-
locKeys,
|
|
136
|
-
ComKey
|
|
137
|
-
});
|
|
138
|
-
return isLocKeyArrayEqual(locKeys, ComKey.loc);
|
|
139
|
-
}).map((key)=>this.get(key));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// TODO: Can we do case insensitive matching?
|
|
143
|
-
contains(query, locations) {
|
|
144
|
-
logger.debug('contains', {
|
|
145
|
-
query,
|
|
146
|
-
locations
|
|
147
|
-
});
|
|
148
|
-
const items = this.allIn(locations);
|
|
149
|
-
return items.some((item)=>core.isQueryMatch(item, query));
|
|
150
|
-
}
|
|
151
|
-
queryIn(query, locations = []) {
|
|
152
|
-
logger.debug('queryIn', {
|
|
153
|
-
query,
|
|
154
|
-
locations
|
|
155
|
-
});
|
|
156
|
-
const items = this.allIn(locations);
|
|
157
|
-
return items.filter((item)=>core.isQueryMatch(item, query));
|
|
158
|
-
}
|
|
159
|
-
clone() {
|
|
160
|
-
const clone = new CacheMap(this.types, this.map);
|
|
161
|
-
return clone;
|
|
162
|
-
}
|
|
163
|
-
constructor(types, map){
|
|
164
|
-
super(map, createNormalizedHashFunction()), _define_property(this, "types", void 0);
|
|
165
|
-
this.types = types;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
exports.CacheMap = CacheMap;
|
|
170
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGVNYXAuY2pzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
|
package/dist/CacheMap.es.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Dictionary, isComKey, isQueryMatch } from '@fjell/core';
|
|
2
|
-
import LibLogger from './logger.es.js';
|
|
3
|
-
|
|
4
|
-
function _define_property(obj, key, value) {
|
|
5
|
-
if (key in obj) {
|
|
6
|
-
Object.defineProperty(obj, key, {
|
|
7
|
-
value: value,
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true
|
|
11
|
-
});
|
|
12
|
-
} else {
|
|
13
|
-
obj[key] = value;
|
|
14
|
-
}
|
|
15
|
-
return obj;
|
|
16
|
-
}
|
|
17
|
-
const logger = LibLogger.get("CacheMap");
|
|
18
|
-
// Normalize a key value to string for consistent comparison and hashing
|
|
19
|
-
const normalizeKeyValue = (value)=>{
|
|
20
|
-
return String(value);
|
|
21
|
-
};
|
|
22
|
-
// Normalized hash function for Dictionary that converts pk/lk values to strings
|
|
23
|
-
const createNormalizedHashFunction = ()=>{
|
|
24
|
-
return (key)=>{
|
|
25
|
-
if (typeof key === 'object' && key !== null) {
|
|
26
|
-
// Create a normalized version of the key with string values
|
|
27
|
-
const normalizedKey = JSON.parse(JSON.stringify(key));
|
|
28
|
-
// Normalize pk values
|
|
29
|
-
if ('pk' in normalizedKey && normalizedKey.pk !== null) {
|
|
30
|
-
normalizedKey.pk = normalizeKeyValue(normalizedKey.pk);
|
|
31
|
-
}
|
|
32
|
-
// Normalize lk values
|
|
33
|
-
if ('lk' in normalizedKey && normalizedKey.lk !== null) {
|
|
34
|
-
normalizedKey.lk = normalizeKeyValue(normalizedKey.lk);
|
|
35
|
-
}
|
|
36
|
-
// Normalize loc array lk values
|
|
37
|
-
if ('loc' in normalizedKey && Array.isArray(normalizedKey.loc)) {
|
|
38
|
-
normalizedKey.loc = normalizedKey.loc.map((locItem)=>{
|
|
39
|
-
if (locItem && 'lk' in locItem && locItem.lk !== null) {
|
|
40
|
-
return {
|
|
41
|
-
...locItem,
|
|
42
|
-
lk: normalizeKeyValue(locItem.lk)
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return locItem;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return JSON.stringify(normalizedKey);
|
|
49
|
-
}
|
|
50
|
-
return JSON.stringify(key);
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
// Helper function to normalize and compare location key arrays
|
|
54
|
-
const isLocKeyArrayEqual = (a, b)=>{
|
|
55
|
-
if (a.length !== b.length) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
for(let i = 0; i < a.length; i++){
|
|
59
|
-
const normalizedA = normalizeLocKeyItem(a[i]);
|
|
60
|
-
const normalizedB = normalizeLocKeyItem(b[i]);
|
|
61
|
-
if (JSON.stringify(normalizedA) !== JSON.stringify(normalizedB)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return true;
|
|
66
|
-
};
|
|
67
|
-
// Helper function to normalize a location key item
|
|
68
|
-
const normalizeLocKeyItem = (item)=>{
|
|
69
|
-
if (typeof item === 'object' && item !== null) {
|
|
70
|
-
const normalized = {
|
|
71
|
-
...item
|
|
72
|
-
};
|
|
73
|
-
if ('lk' in normalized && normalized.lk !== null) {
|
|
74
|
-
normalized.lk = normalizeKeyValue(normalized.lk);
|
|
75
|
-
}
|
|
76
|
-
return normalized;
|
|
77
|
-
}
|
|
78
|
-
return item;
|
|
79
|
-
};
|
|
80
|
-
// const isObj = (x: any) => typeof x === "object" && x !== null;
|
|
81
|
-
// const intersection = (a: object, b: object): object => {
|
|
82
|
-
// const result: { [key: string]: any } = {}
|
|
83
|
-
// if (([a, b]).every(isObj)) {
|
|
84
|
-
// Object.keys(a).forEach((key) => {
|
|
85
|
-
// // @ts-ignore
|
|
86
|
-
// const value = a[key]
|
|
87
|
-
// // @ts-ignore
|
|
88
|
-
// const other = b[key]
|
|
89
|
-
// if (isObj(value)) {
|
|
90
|
-
// result[key] = intersection(value, other)
|
|
91
|
-
// } else if (value === other) {
|
|
92
|
-
// result[key] = value
|
|
93
|
-
// }
|
|
94
|
-
// })
|
|
95
|
-
// }
|
|
96
|
-
// return result
|
|
97
|
-
// }
|
|
98
|
-
// const removeEmptyObjects = (obj: object): object => {
|
|
99
|
-
// const result: { [key: string]: any } = {}
|
|
100
|
-
// Object.keys(obj).forEach((key) => {
|
|
101
|
-
// // @ts-ignore
|
|
102
|
-
// const value = obj[key];
|
|
103
|
-
// if (isObj(value)) {
|
|
104
|
-
// const nested = removeEmptyObjects(value);
|
|
105
|
-
// if (Object.keys(nested).length > 0) {
|
|
106
|
-
// result[key] = nested
|
|
107
|
-
// }
|
|
108
|
-
// } else if (value !== null) {
|
|
109
|
-
// result[key] = value
|
|
110
|
-
// }
|
|
111
|
-
// });
|
|
112
|
-
// return result;
|
|
113
|
-
// }
|
|
114
|
-
class CacheMap extends Dictionary {
|
|
115
|
-
get(key) {
|
|
116
|
-
return super.get(key);
|
|
117
|
-
}
|
|
118
|
-
allIn(locations) {
|
|
119
|
-
if (locations.length === 0) {
|
|
120
|
-
logger.debug('Returning all items, LocKeys is empty');
|
|
121
|
-
return this.values();
|
|
122
|
-
} else {
|
|
123
|
-
const locKeys = locations;
|
|
124
|
-
logger.debug('allIn', {
|
|
125
|
-
locKeys,
|
|
126
|
-
keys: this.keys().length
|
|
127
|
-
});
|
|
128
|
-
return this.keys().filter((key)=>key && isComKey(key)).filter((key)=>{
|
|
129
|
-
const ComKey = key;
|
|
130
|
-
logger.debug('Comparing Location Keys', {
|
|
131
|
-
locKeys,
|
|
132
|
-
ComKey
|
|
133
|
-
});
|
|
134
|
-
return isLocKeyArrayEqual(locKeys, ComKey.loc);
|
|
135
|
-
}).map((key)=>this.get(key));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// TODO: Can we do case insensitive matching?
|
|
139
|
-
contains(query, locations) {
|
|
140
|
-
logger.debug('contains', {
|
|
141
|
-
query,
|
|
142
|
-
locations
|
|
143
|
-
});
|
|
144
|
-
const items = this.allIn(locations);
|
|
145
|
-
return items.some((item)=>isQueryMatch(item, query));
|
|
146
|
-
}
|
|
147
|
-
queryIn(query, locations = []) {
|
|
148
|
-
logger.debug('queryIn', {
|
|
149
|
-
query,
|
|
150
|
-
locations
|
|
151
|
-
});
|
|
152
|
-
const items = this.allIn(locations);
|
|
153
|
-
return items.filter((item)=>isQueryMatch(item, query));
|
|
154
|
-
}
|
|
155
|
-
clone() {
|
|
156
|
-
const clone = new CacheMap(this.types, this.map);
|
|
157
|
-
return clone;
|
|
158
|
-
}
|
|
159
|
-
constructor(types, map){
|
|
160
|
-
super(map, createNormalizedHashFunction()), _define_property(this, "types", void 0);
|
|
161
|
-
this.types = types;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export { CacheMap };
|
|
166
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FjaGVNYXAuZXMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|
package/dist/Instance.cjs.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const logger$1 = require('./logger.cjs.js');
|
|
6
|
-
const Cache = require('./Cache.cjs.js');
|
|
7
|
-
|
|
8
|
-
const logger = logger$1.default.get("Instance");
|
|
9
|
-
const createInstance = async (registry, coordinate, api)=>{
|
|
10
|
-
logger.debug("createInstance", {
|
|
11
|
-
coordinate,
|
|
12
|
-
api,
|
|
13
|
-
registry
|
|
14
|
-
});
|
|
15
|
-
return await Cache.createCache(api, coordinate, registry);
|
|
16
|
-
};
|
|
17
|
-
const isInstance = (instance)=>{
|
|
18
|
-
return instance !== null && typeof instance === 'object' && 'coordinate' in instance && 'registry' in instance && 'api' in instance && 'cacheMap' in instance && 'operations' in instance;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.createInstance = createInstance;
|
|
22
|
-
exports.isInstance = isInstance;
|
|
23
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW5zdGFuY2UuY2pzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
|
package/dist/Instance.es.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import LibLogger from './logger.es.js';
|
|
2
|
-
import { createCache } from './Cache.es.js';
|
|
3
|
-
|
|
4
|
-
const logger = LibLogger.get("Instance");
|
|
5
|
-
const createInstance = async (registry, coordinate, api)=>{
|
|
6
|
-
logger.debug("createInstance", {
|
|
7
|
-
coordinate,
|
|
8
|
-
api,
|
|
9
|
-
registry
|
|
10
|
-
});
|
|
11
|
-
return await createCache(api, coordinate, registry);
|
|
12
|
-
};
|
|
13
|
-
const isInstance = (instance)=>{
|
|
14
|
-
return instance !== null && typeof instance === 'object' && 'coordinate' in instance && 'registry' in instance && 'api' in instance && 'cacheMap' in instance && 'operations' in instance;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { createInstance, isInstance };
|
|
18
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW5zdGFuY2UuZXMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7In0=
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const CacheMap = require('./CacheMap.cjs.js');
|
|
6
|
-
const Operations = require('./Operations.cjs.js');
|
|
7
|
-
const logger$1 = require('./logger.cjs.js');
|
|
8
|
-
|
|
9
|
-
const logger = logger$1.default.get("InstanceFactory");
|
|
10
|
-
/**
|
|
11
|
-
* Factory function for creating cache instances
|
|
12
|
-
*/ const createInstanceFactory = (api)=>{
|
|
13
|
-
return (coordinate, context)=>{
|
|
14
|
-
logger.debug("Creating cache instance", {
|
|
15
|
-
coordinate,
|
|
16
|
-
registry: context.registry,
|
|
17
|
-
api
|
|
18
|
-
});
|
|
19
|
-
// Since InstanceFactory must be synchronous but our createInstance is async,
|
|
20
|
-
// we need to create a special cache instance synchronously and defer the async initialization
|
|
21
|
-
const cacheMap = new CacheMap.CacheMap(coordinate.kta);
|
|
22
|
-
const pkType = coordinate.kta[0];
|
|
23
|
-
const operations = Operations.createOperations(api, coordinate, cacheMap, pkType);
|
|
24
|
-
return {
|
|
25
|
-
coordinate,
|
|
26
|
-
registry: context.registry,
|
|
27
|
-
api,
|
|
28
|
-
cacheMap,
|
|
29
|
-
operations
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.createInstanceFactory = createInstanceFactory;
|
|
35
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW5zdGFuY2VGYWN0b3J5LmNqcy5qcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { CacheMap } from './CacheMap.es.js';
|
|
2
|
-
import { createOperations } from './Operations.es.js';
|
|
3
|
-
import LibLogger from './logger.es.js';
|
|
4
|
-
|
|
5
|
-
const logger = LibLogger.get("InstanceFactory");
|
|
6
|
-
/**
|
|
7
|
-
* Factory function for creating cache instances
|
|
8
|
-
*/ const createInstanceFactory = (api)=>{
|
|
9
|
-
return (coordinate, context)=>{
|
|
10
|
-
logger.debug("Creating cache instance", {
|
|
11
|
-
coordinate,
|
|
12
|
-
registry: context.registry,
|
|
13
|
-
api
|
|
14
|
-
});
|
|
15
|
-
// Since InstanceFactory must be synchronous but our createInstance is async,
|
|
16
|
-
// we need to create a special cache instance synchronously and defer the async initialization
|
|
17
|
-
const cacheMap = new CacheMap(coordinate.kta);
|
|
18
|
-
const pkType = coordinate.kta[0];
|
|
19
|
-
const operations = createOperations(api, coordinate, cacheMap, pkType);
|
|
20
|
-
return {
|
|
21
|
-
coordinate,
|
|
22
|
-
registry: context.registry,
|
|
23
|
-
api,
|
|
24
|
-
cacheMap,
|
|
25
|
-
operations
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { createInstanceFactory };
|
|
31
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW5zdGFuY2VGYWN0b3J5LmVzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
|
package/dist/Operations.cjs.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const all = require('./ops/all.cjs.js');
|
|
6
|
-
const one = require('./ops/one.cjs.js');
|
|
7
|
-
const create = require('./ops/create.cjs.js');
|
|
8
|
-
const get = require('./ops/get.cjs.js');
|
|
9
|
-
const retrieve = require('./ops/retrieve.cjs.js');
|
|
10
|
-
const remove = require('./ops/remove.cjs.js');
|
|
11
|
-
const update = require('./ops/update.cjs.js');
|
|
12
|
-
const action = require('./ops/action.cjs.js');
|
|
13
|
-
const allAction = require('./ops/allAction.cjs.js');
|
|
14
|
-
const facet = require('./ops/facet.cjs.js');
|
|
15
|
-
const allFacet = require('./ops/allFacet.cjs.js');
|
|
16
|
-
const find = require('./ops/find.cjs.js');
|
|
17
|
-
const findOne = require('./ops/findOne.cjs.js');
|
|
18
|
-
const set = require('./ops/set.cjs.js');
|
|
19
|
-
const reset = require('./ops/reset.cjs.js');
|
|
20
|
-
|
|
21
|
-
// Import all operation functions
|
|
22
|
-
const createOperations = (api, coordinate, cacheMap, pkType)=>{
|
|
23
|
-
return {
|
|
24
|
-
all: (query, locations)=>all.all(api, cacheMap, pkType, query, locations),
|
|
25
|
-
one: (query, locations)=>one.one(api, cacheMap, pkType, query, locations),
|
|
26
|
-
create: (item, locations)=>create.create(api, cacheMap, pkType, item, locations),
|
|
27
|
-
get: (key)=>get.get(api, cacheMap, pkType, key),
|
|
28
|
-
retrieve: (key)=>retrieve.retrieve(api, cacheMap, pkType, key),
|
|
29
|
-
remove: (key)=>remove.remove(api, cacheMap, key),
|
|
30
|
-
update: (key, item)=>update.update(api, cacheMap, pkType, key, item),
|
|
31
|
-
action: (key, actionName, body)=>action.action(api, cacheMap, pkType, key, actionName, body),
|
|
32
|
-
allAction: (actionName, body, locations)=>allAction.allAction(api, cacheMap, pkType, actionName, body, locations),
|
|
33
|
-
facet: (key, facetName, params)=>facet.facet(api, cacheMap, key, facetName, params),
|
|
34
|
-
allFacet: (facetName, params, locations)=>allFacet.allFacet(api, cacheMap, facetName, params, locations),
|
|
35
|
-
find: (finder, params, locations)=>find.find(api, cacheMap, pkType, finder, params, locations),
|
|
36
|
-
findOne: (finder, params, locations)=>findOne.findOne(api, cacheMap, pkType, finder, params, locations),
|
|
37
|
-
set: (key, item)=>set.set(cacheMap, pkType, key, item),
|
|
38
|
-
reset: ()=>reset.reset(coordinate)
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.createOperations = createOperations;
|
|
43
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiT3BlcmF0aW9ucy5janMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|
package/dist/Operations.es.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { all } from './ops/all.es.js';
|
|
2
|
-
import { one } from './ops/one.es.js';
|
|
3
|
-
import { create } from './ops/create.es.js';
|
|
4
|
-
import { get } from './ops/get.es.js';
|
|
5
|
-
import { retrieve } from './ops/retrieve.es.js';
|
|
6
|
-
import { remove } from './ops/remove.es.js';
|
|
7
|
-
import { update } from './ops/update.es.js';
|
|
8
|
-
import { action } from './ops/action.es.js';
|
|
9
|
-
import { allAction } from './ops/allAction.es.js';
|
|
10
|
-
import { facet } from './ops/facet.es.js';
|
|
11
|
-
import { allFacet } from './ops/allFacet.es.js';
|
|
12
|
-
import { find } from './ops/find.es.js';
|
|
13
|
-
import { findOne } from './ops/findOne.es.js';
|
|
14
|
-
import { set } from './ops/set.es.js';
|
|
15
|
-
import { reset } from './ops/reset.es.js';
|
|
16
|
-
|
|
17
|
-
// Import all operation functions
|
|
18
|
-
const createOperations = (api, coordinate, cacheMap, pkType)=>{
|
|
19
|
-
return {
|
|
20
|
-
all: (query, locations)=>all(api, cacheMap, pkType, query, locations),
|
|
21
|
-
one: (query, locations)=>one(api, cacheMap, pkType, query, locations),
|
|
22
|
-
create: (item, locations)=>create(api, cacheMap, pkType, item, locations),
|
|
23
|
-
get: (key)=>get(api, cacheMap, pkType, key),
|
|
24
|
-
retrieve: (key)=>retrieve(api, cacheMap, pkType, key),
|
|
25
|
-
remove: (key)=>remove(api, cacheMap, key),
|
|
26
|
-
update: (key, item)=>update(api, cacheMap, pkType, key, item),
|
|
27
|
-
action: (key, actionName, body)=>action(api, cacheMap, pkType, key, actionName, body),
|
|
28
|
-
allAction: (actionName, body, locations)=>allAction(api, cacheMap, pkType, actionName, body, locations),
|
|
29
|
-
facet: (key, facetName, params)=>facet(api, cacheMap, key, facetName, params),
|
|
30
|
-
allFacet: (facetName, params, locations)=>allFacet(api, cacheMap, facetName, params, locations),
|
|
31
|
-
find: (finder, params, locations)=>find(api, cacheMap, pkType, finder, params, locations),
|
|
32
|
-
findOne: (finder, params, locations)=>findOne(api, cacheMap, pkType, finder, params, locations),
|
|
33
|
-
set: (key, item)=>set(cacheMap, pkType, key, item),
|
|
34
|
-
reset: ()=>reset(coordinate)
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { createOperations };
|
|
39
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiT3BlcmF0aW9ucy5lcy5qcyIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==
|
package/dist/Registry.cjs.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const logger$1 = require('./logger.cjs.js');
|
|
6
|
-
const registry = require('@fjell/registry');
|
|
7
|
-
|
|
8
|
-
const logger = logger$1.default.get("Registry");
|
|
9
|
-
/**
|
|
10
|
-
* Factory function for creating cache registries
|
|
11
|
-
*/ const createRegistryFactory = ()=>{
|
|
12
|
-
return (type, registryHub)=>{
|
|
13
|
-
if (type !== 'cache') {
|
|
14
|
-
throw new Error(`Cache registry factory can only create 'cache' type registries, got: ${type}`);
|
|
15
|
-
}
|
|
16
|
-
logger.debug("Creating cache registry", {
|
|
17
|
-
type,
|
|
18
|
-
registryHub
|
|
19
|
-
});
|
|
20
|
-
const baseRegistry = registry.createRegistry(type, registryHub);
|
|
21
|
-
// Cast to Registry for type safety
|
|
22
|
-
return baseRegistry;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new cache registry instance
|
|
27
|
-
*/ const createRegistry = (registryHub)=>{
|
|
28
|
-
const baseRegistry = registry.createRegistry('cache', registryHub);
|
|
29
|
-
return {
|
|
30
|
-
...baseRegistry
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.createRegistry = createRegistry;
|
|
35
|
-
exports.createRegistryFactory = createRegistryFactory;
|
|
36
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUmVnaXN0cnkuY2pzLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|
package/dist/Registry.es.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import LibLogger from './logger.es.js';
|
|
2
|
-
import { createRegistry as createRegistry$1 } from '@fjell/registry';
|
|
3
|
-
|
|
4
|
-
const logger = LibLogger.get("Registry");
|
|
5
|
-
/**
|
|
6
|
-
* Factory function for creating cache registries
|
|
7
|
-
*/ const createRegistryFactory = ()=>{
|
|
8
|
-
return (type, registryHub)=>{
|
|
9
|
-
if (type !== 'cache') {
|
|
10
|
-
throw new Error(`Cache registry factory can only create 'cache' type registries, got: ${type}`);
|
|
11
|
-
}
|
|
12
|
-
logger.debug("Creating cache 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 cache registry instance
|
|
23
|
-
*/ const createRegistry = (registryHub)=>{
|
|
24
|
-
const baseRegistry = createRegistry$1('cache', registryHub);
|
|
25
|
-
return {
|
|
26
|
-
...baseRegistry
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { createRegistry, createRegistryFactory };
|
|
31
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUmVnaXN0cnkuZXMuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OyJ9
|