@fjell/core 4.4.72 → 4.4.74
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/README.md +6 -6
- package/dist/AItemService.d.ts +1 -1
- package/dist/Coordinate.d.ts +1 -6
- package/dist/event/emitter.d.ts +1 -2
- package/dist/event/events.d.ts +1 -2
- package/dist/event/matching.d.ts +1 -1
- package/dist/event/subscription.d.ts +1 -2
- package/dist/index.d.ts +7 -20
- package/dist/index.js +980 -1008
- package/dist/item/IFactory.d.ts +1 -2
- package/dist/item/IQFactory.d.ts +1 -1
- package/dist/item/IQUtils.d.ts +1 -2
- package/dist/item/IUtils.d.ts +1 -7
- package/dist/key/KUtils.d.ts +3 -3
- package/dist/operations/OperationContext.d.ts +1 -1
- package/dist/operations/index.d.ts +1 -0
- package/dist/operations/wrappers/createActionWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createAllActionWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createAllFacetWrapper.d.ts +1 -2
- package/dist/operations/wrappers/createAllWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createCreateWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createFacetWrapper.d.ts +1 -2
- package/dist/operations/wrappers/createFindOneWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createFindWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createGetWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createOneWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createRemoveWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createUpdateWrapper.d.ts +1 -3
- package/dist/operations/wrappers/createUpsertWrapper.d.ts +1 -3
- package/dist/operations/wrappers/types.d.ts +1 -1
- package/package.json +4 -7
- package/dist/item/ItemQuery.d.ts +0 -62
- package/dist/items.d.ts +0 -74
- package/dist/keys.d.ts +0 -66
- package/dist/operations/Operations.d.ts +0 -530
- package/dist/operations/contained.d.ts +0 -65
- package/dist/operations/methods.d.ts +0 -204
- package/dist/operations/primary.d.ts +0 -57
- package/dist/operations/specialized.d.ts +0 -41
- package/dist/validation/ItemValidator.d.ts +0 -43
- package/dist/validation/KeyValidator.d.ts +0 -56
- package/dist/validation/LocationValidator.d.ts +0 -39
- package/dist/validation/QueryValidator.d.ts +0 -57
- package/dist/validation/index.d.ts +0 -17
- package/dist/validation/index.js +0 -592
- package/dist/validation/schema.d.ts +0 -23
- package/dist/validation/types.d.ts +0 -69
package/dist/index.js
CHANGED
|
@@ -3,84 +3,14 @@ import Logging from "@fjell/logging";
|
|
|
3
3
|
var LibLogger = Logging.getLogger("@fjell/core");
|
|
4
4
|
var logger_default = LibLogger;
|
|
5
5
|
|
|
6
|
-
// src/
|
|
7
|
-
var logger = logger_default.get("
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
hashFunction = (key) => JSON.stringify(key);
|
|
11
|
-
constructor(map, hashFunction) {
|
|
12
|
-
if (hashFunction) {
|
|
13
|
-
this.hashFunction = hashFunction;
|
|
14
|
-
}
|
|
15
|
-
if (map) {
|
|
16
|
-
Object.entries(map).forEach(([hashedKey, value]) => {
|
|
17
|
-
try {
|
|
18
|
-
const originalKey = JSON.parse(hashedKey);
|
|
19
|
-
this.map[hashedKey] = { originalKey, value };
|
|
20
|
-
} catch {
|
|
21
|
-
logger.warning("Cannot recover original key from legacy map entry", { hashedKey });
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
set(key, item) {
|
|
27
|
-
logger.trace("set", { key, item });
|
|
28
|
-
const hashedKey = this.hashFunction(key);
|
|
29
|
-
this.map[hashedKey] = { originalKey: key, value: item };
|
|
30
|
-
}
|
|
31
|
-
get(key) {
|
|
32
|
-
logger.trace("get", { key });
|
|
33
|
-
const hashedKey = this.hashFunction(key);
|
|
34
|
-
const entry = this.map[hashedKey];
|
|
35
|
-
return entry && this.keysEqual(entry.originalKey, key) ? entry.value : null;
|
|
36
|
-
}
|
|
37
|
-
keysEqual(key1, key2) {
|
|
38
|
-
return key1 === key2;
|
|
39
|
-
}
|
|
40
|
-
delete(key) {
|
|
41
|
-
logger.trace("delete", { key });
|
|
42
|
-
const hashedKey = this.hashFunction(key);
|
|
43
|
-
delete this.map[hashedKey];
|
|
44
|
-
}
|
|
45
|
-
keys() {
|
|
46
|
-
return Object.values(this.map).map((entry) => entry.originalKey);
|
|
47
|
-
}
|
|
48
|
-
values() {
|
|
49
|
-
return Object.values(this.map).map((entry) => entry.value);
|
|
50
|
-
}
|
|
51
|
-
includesKey(key) {
|
|
52
|
-
const hashedKey = this.hashFunction(key);
|
|
53
|
-
const entry = this.map[hashedKey];
|
|
54
|
-
return entry ? this.keysEqual(entry.originalKey, key) : false;
|
|
55
|
-
}
|
|
56
|
-
clone() {
|
|
57
|
-
const clonedMap = {};
|
|
58
|
-
Object.entries(this.map).forEach(([hashedKey, entry]) => {
|
|
59
|
-
clonedMap[hashedKey] = entry.value;
|
|
60
|
-
});
|
|
61
|
-
const clone = new _Dictionary(clonedMap, this.hashFunction);
|
|
62
|
-
clone.map = Object.assign({}, this.map);
|
|
63
|
-
return clone;
|
|
64
|
-
}
|
|
6
|
+
// src/key/KUtils.ts
|
|
7
|
+
var logger = logger_default.get("KUtils");
|
|
8
|
+
var isComKey = (key) => {
|
|
9
|
+
return key !== null && typeof key === "object" && "kt" in key && "pk" in key && "loc" in key && Array.isArray(key.loc) && key.loc.length > 0;
|
|
65
10
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var logger2 = logger_default.get("Coordinate");
|
|
69
|
-
var createCoordinate = (kta, scopes = []) => {
|
|
70
|
-
const ktArray = Array.isArray(kta) ? kta : [kta];
|
|
71
|
-
const toString = () => {
|
|
72
|
-
logger2.debug("toString", { kta, scopes });
|
|
73
|
-
return `${ktArray.join(", ")} - ${scopes.join(", ")}`;
|
|
74
|
-
};
|
|
75
|
-
logger2.debug("createCoordinate", { kta: ktArray, scopes, toString });
|
|
76
|
-
return { kta: ktArray, scopes, toString };
|
|
11
|
+
var isPriKey = (key) => {
|
|
12
|
+
return key !== null && typeof key === "object" && "kt" in key && "pk" in key && (!("loc" in key) || !key.loc || Array.isArray(key.loc) && key.loc.length === 0);
|
|
77
13
|
};
|
|
78
|
-
|
|
79
|
-
// src/item/IFactory.ts
|
|
80
|
-
import deepmerge from "deepmerge";
|
|
81
|
-
|
|
82
|
-
// src/key/KUtils.ts
|
|
83
|
-
var logger3 = logger_default.get("KUtils");
|
|
84
14
|
var normalizeKeyValue = (value) => {
|
|
85
15
|
return String(value);
|
|
86
16
|
};
|
|
@@ -108,15 +38,15 @@ var createNormalizedHashFunction = () => {
|
|
|
108
38
|
};
|
|
109
39
|
};
|
|
110
40
|
var isPriKeyEqualNormalized = (a, b) => {
|
|
111
|
-
|
|
41
|
+
logger.trace("isPriKeyEqualNormalized", { a, b });
|
|
112
42
|
return a && b && normalizeKeyValue(a.pk) === normalizeKeyValue(b.pk) && a.kt === b.kt;
|
|
113
43
|
};
|
|
114
44
|
var isLocKeyEqualNormalized = (a, b) => {
|
|
115
|
-
|
|
45
|
+
logger.trace("isLocKeyEqualNormalized", { a, b });
|
|
116
46
|
return a && b && normalizeKeyValue(a.lk) === normalizeKeyValue(b.lk) && a.kt === b.kt;
|
|
117
47
|
};
|
|
118
48
|
var isComKeyEqualNormalized = (a, b) => {
|
|
119
|
-
|
|
49
|
+
logger.trace("isComKeyEqualNormalized", { a, b });
|
|
120
50
|
if (a && b && isPriKeyEqualNormalized({ kt: a.kt, pk: a.pk }, { kt: b.kt, pk: b.pk })) {
|
|
121
51
|
if (a.loc.length === b.loc.length) {
|
|
122
52
|
for (let i = 0; i < a.loc.length; i++) {
|
|
@@ -133,7 +63,7 @@ var isComKeyEqualNormalized = (a, b) => {
|
|
|
133
63
|
}
|
|
134
64
|
};
|
|
135
65
|
var isItemKeyEqualNormalized = (a, b) => {
|
|
136
|
-
|
|
66
|
+
logger.trace("isItemKeyEqualNormalized", { a, b });
|
|
137
67
|
if (isComKey(a) && isComKey(b)) {
|
|
138
68
|
return isComKeyEqualNormalized(a, b);
|
|
139
69
|
} else if (isPriKey(a) && isPriKey(b)) {
|
|
@@ -147,7 +77,7 @@ var isItemKeyEqualNormalized = (a, b) => {
|
|
|
147
77
|
}
|
|
148
78
|
};
|
|
149
79
|
var isItemKeyEqual = (a, b) => {
|
|
150
|
-
|
|
80
|
+
logger.trace("isKeyEqual", { a, b });
|
|
151
81
|
if (isComKey(a) && isComKey(b)) {
|
|
152
82
|
return isComKeyEqual(a, b);
|
|
153
83
|
} else if (isPriKey(a) && isPriKey(b)) {
|
|
@@ -161,15 +91,15 @@ var isItemKeyEqual = (a, b) => {
|
|
|
161
91
|
}
|
|
162
92
|
};
|
|
163
93
|
var isPriKeyEqual = (a, b) => {
|
|
164
|
-
|
|
94
|
+
logger.trace("isPriKeyEqual", { a, b });
|
|
165
95
|
return a && b && a.pk === b.pk && a.kt === b.kt;
|
|
166
96
|
};
|
|
167
97
|
var isLocKeyEqual = (a, b) => {
|
|
168
|
-
|
|
98
|
+
logger.trace("isLocKeyEqual", { a, b });
|
|
169
99
|
return a && b && a.lk === b.lk && a.kt === b.kt;
|
|
170
100
|
};
|
|
171
101
|
var isComKeyEqual = (a, b) => {
|
|
172
|
-
|
|
102
|
+
logger.trace("isComKeyEqual", { a, b });
|
|
173
103
|
if (a && b && isPriKeyEqual({ kt: a.kt, pk: a.pk }, { kt: b.kt, pk: b.pk })) {
|
|
174
104
|
if (a.loc.length === b.loc.length) {
|
|
175
105
|
for (let i = 0; i < a.loc.length; i++) {
|
|
@@ -186,23 +116,15 @@ var isComKeyEqual = (a, b) => {
|
|
|
186
116
|
}
|
|
187
117
|
};
|
|
188
118
|
var isItemKey = (key) => {
|
|
189
|
-
|
|
119
|
+
logger.trace("isItemKey", { key });
|
|
190
120
|
return key !== void 0 && (isComKey(key) || isPriKey(key));
|
|
191
121
|
};
|
|
192
|
-
var isComKey = (key) => {
|
|
193
|
-
logger3.trace("isComKey", { key });
|
|
194
|
-
return key !== void 0 && (key.pk !== void 0 && key.kt !== void 0) && (key.loc !== void 0 && Array.isArray(key.loc));
|
|
195
|
-
};
|
|
196
|
-
var isPriKey = (key) => {
|
|
197
|
-
logger3.trace("isPriKey", { key });
|
|
198
|
-
return key !== void 0 && (key.pk !== void 0 && key.kt !== void 0) && key.loc === void 0;
|
|
199
|
-
};
|
|
200
122
|
var isLocKey = (key) => {
|
|
201
|
-
|
|
123
|
+
logger.trace("isLocKey", { key });
|
|
202
124
|
return key !== void 0 && (key.lk !== void 0 && key.kt !== void 0);
|
|
203
125
|
};
|
|
204
126
|
var generateKeyArray = (key) => {
|
|
205
|
-
|
|
127
|
+
logger.trace("generateKeyArray", { key });
|
|
206
128
|
const keys = [];
|
|
207
129
|
if (isComKey(key) || isPriKey(key)) {
|
|
208
130
|
if (isComKey(key)) {
|
|
@@ -223,7 +145,7 @@ var generateKeyArray = (key) => {
|
|
|
223
145
|
return keys;
|
|
224
146
|
};
|
|
225
147
|
var constructPriKey = (pk, kt) => {
|
|
226
|
-
|
|
148
|
+
logger.trace("constructPriKey", { pk, kt });
|
|
227
149
|
let pri;
|
|
228
150
|
if (typeof pk === "string" || typeof pk === "number") {
|
|
229
151
|
pri = { kt, pk };
|
|
@@ -234,7 +156,7 @@ var constructPriKey = (pk, kt) => {
|
|
|
234
156
|
};
|
|
235
157
|
var cPK = constructPriKey;
|
|
236
158
|
var toKeyTypeArray = (ik) => {
|
|
237
|
-
|
|
159
|
+
logger.trace("toKeyTypeArray", { ik });
|
|
238
160
|
if (isComKey(ik)) {
|
|
239
161
|
const ck = ik;
|
|
240
162
|
return [ck.kt, ...ck.loc.map((l) => l.kt)];
|
|
@@ -243,7 +165,7 @@ var toKeyTypeArray = (ik) => {
|
|
|
243
165
|
}
|
|
244
166
|
};
|
|
245
167
|
var extractKeyTypeArray = (key) => {
|
|
246
|
-
|
|
168
|
+
logger.trace("extractKeyTypeArray", { key });
|
|
247
169
|
if (isComKey(key)) {
|
|
248
170
|
const ck = key;
|
|
249
171
|
return [ck.kt, ...ck.loc.map((l) => l.kt)];
|
|
@@ -252,12 +174,12 @@ var extractKeyTypeArray = (key) => {
|
|
|
252
174
|
} else if (Array.isArray(key)) {
|
|
253
175
|
return key.map((locKey) => locKey.kt);
|
|
254
176
|
} else {
|
|
255
|
-
|
|
177
|
+
logger.warning("extractKeyTypeArray: Unknown key type", { key });
|
|
256
178
|
return [];
|
|
257
179
|
}
|
|
258
180
|
};
|
|
259
181
|
var abbrevIK = (ik) => {
|
|
260
|
-
|
|
182
|
+
logger.trace("abbrevIK", { ik });
|
|
261
183
|
if (ik) {
|
|
262
184
|
if (isComKey(ik)) {
|
|
263
185
|
const ck = ik;
|
|
@@ -270,7 +192,7 @@ var abbrevIK = (ik) => {
|
|
|
270
192
|
}
|
|
271
193
|
};
|
|
272
194
|
var abbrevLKA = (keyArray) => {
|
|
273
|
-
|
|
195
|
+
logger.trace("abbrevLKA", { keyArray });
|
|
274
196
|
if (keyArray === void 0 || keyArray === null) {
|
|
275
197
|
return "null LKA";
|
|
276
198
|
} else {
|
|
@@ -284,7 +206,7 @@ var abbrevLKA = (keyArray) => {
|
|
|
284
206
|
}
|
|
285
207
|
};
|
|
286
208
|
var primaryType = (ik) => {
|
|
287
|
-
|
|
209
|
+
logger.trace("primaryType", { ik });
|
|
288
210
|
if (isComKey(ik)) {
|
|
289
211
|
return ik.kt;
|
|
290
212
|
} else {
|
|
@@ -292,7 +214,7 @@ var primaryType = (ik) => {
|
|
|
292
214
|
}
|
|
293
215
|
};
|
|
294
216
|
var itemKeyToLocKeyArray = (ik) => {
|
|
295
|
-
|
|
217
|
+
logger.trace("itemKeyToLocKeyArray", { ik: abbrevIK(ik) });
|
|
296
218
|
let lka = [];
|
|
297
219
|
if (isComKey(ik)) {
|
|
298
220
|
const ck = ik;
|
|
@@ -301,12 +223,12 @@ var itemKeyToLocKeyArray = (ik) => {
|
|
|
301
223
|
const pk = ik;
|
|
302
224
|
lka = [{ kt: pk.kt, lk: pk.pk }];
|
|
303
225
|
}
|
|
304
|
-
|
|
226
|
+
logger.trace("itemKeyToLocKeyArray Results", { ik: abbrevIK(ik), lka: abbrevLKA(lka) });
|
|
305
227
|
return lka;
|
|
306
228
|
};
|
|
307
229
|
var ikToLKA = itemKeyToLocKeyArray;
|
|
308
230
|
var locKeyArrayToItemKey = (lka) => {
|
|
309
|
-
|
|
231
|
+
logger.trace("locKeyArrayToItemKey", { lka: abbrevLKA(lka) });
|
|
310
232
|
if (lka && lka.length === 1) {
|
|
311
233
|
const priKey = cPK(lka[0].lk, lka[0].kt);
|
|
312
234
|
return priKey;
|
|
@@ -316,7 +238,9 @@ var locKeyArrayToItemKey = (lka) => {
|
|
|
316
238
|
const comKey = { kt: priKey.kt, pk: priKey.pk, loc: locs };
|
|
317
239
|
return comKey;
|
|
318
240
|
} else {
|
|
319
|
-
throw new Error(
|
|
241
|
+
throw new Error(
|
|
242
|
+
"locKeyArrayToItemKey: lka is undefined or empty. Expected non-empty LocKeyArray. Suggestion: Ensure you are passing a valid location key array, not undefined/null/empty array."
|
|
243
|
+
);
|
|
320
244
|
}
|
|
321
245
|
};
|
|
322
246
|
var isValidPriKey = (key) => {
|
|
@@ -334,96 +258,13 @@ var isValidComKey = (key) => {
|
|
|
334
258
|
return key !== void 0 && key !== null && isValidPriKey(key) && isValidLocKeyArray(key.loc);
|
|
335
259
|
};
|
|
336
260
|
var isValidItemKey = (key) => {
|
|
261
|
+
if (key === null) throw new Error("Key cannot be null");
|
|
262
|
+
if (key === void 0) return false;
|
|
337
263
|
return isComKey(key) && isValidComKey(key) || isPriKey(key) && isValidPriKey(key);
|
|
338
264
|
};
|
|
339
265
|
var lkaToIK = locKeyArrayToItemKey;
|
|
340
266
|
|
|
341
|
-
//
|
|
342
|
-
var IFactory = class _IFactory {
|
|
343
|
-
item = {};
|
|
344
|
-
constructor(props = {}) {
|
|
345
|
-
this.item = deepmerge(this.item, props);
|
|
346
|
-
}
|
|
347
|
-
addRef(i, name) {
|
|
348
|
-
const ik = i.key;
|
|
349
|
-
const refName = name || primaryType(ik);
|
|
350
|
-
if (!this.item.refs) {
|
|
351
|
-
this.item.refs = {};
|
|
352
|
-
}
|
|
353
|
-
this.item.refs[refName] = ik;
|
|
354
|
-
return this;
|
|
355
|
-
}
|
|
356
|
-
static addRef(i, name) {
|
|
357
|
-
return new _IFactory().addRef(i, name);
|
|
358
|
-
}
|
|
359
|
-
addDefaultEvents() {
|
|
360
|
-
if (!this.item.events) {
|
|
361
|
-
this.item.events = {};
|
|
362
|
-
}
|
|
363
|
-
const now = /* @__PURE__ */ new Date();
|
|
364
|
-
if (!this.item.events.created) {
|
|
365
|
-
this.item.events.created = { at: now };
|
|
366
|
-
}
|
|
367
|
-
if (!this.item.events.updated) {
|
|
368
|
-
this.item.events.updated = { at: now };
|
|
369
|
-
}
|
|
370
|
-
if (!this.item.events.deleted) {
|
|
371
|
-
this.item.events.deleted = { at: null };
|
|
372
|
-
}
|
|
373
|
-
return this;
|
|
374
|
-
}
|
|
375
|
-
addEvent(name, at, by) {
|
|
376
|
-
if (!this.item.events) {
|
|
377
|
-
this.item.events = {};
|
|
378
|
-
}
|
|
379
|
-
this.item.events[name] = { at, by };
|
|
380
|
-
return this;
|
|
381
|
-
}
|
|
382
|
-
static addEvent(name, at, by) {
|
|
383
|
-
return new _IFactory().addEvent(name, at, by);
|
|
384
|
-
}
|
|
385
|
-
addProp(name, value) {
|
|
386
|
-
this.item[name] = value;
|
|
387
|
-
return this;
|
|
388
|
-
}
|
|
389
|
-
static addProp(name, value) {
|
|
390
|
-
return new _IFactory().addProp(name, value);
|
|
391
|
-
}
|
|
392
|
-
addProps(props) {
|
|
393
|
-
this.item = deepmerge(this.item, props);
|
|
394
|
-
return this;
|
|
395
|
-
}
|
|
396
|
-
static addProps(props) {
|
|
397
|
-
return new _IFactory().addProps(props);
|
|
398
|
-
}
|
|
399
|
-
toItem() {
|
|
400
|
-
return this.item;
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
// src/AItemService.ts
|
|
405
|
-
var AItemService = class {
|
|
406
|
-
pkType;
|
|
407
|
-
parentService = null;
|
|
408
|
-
constructor(pkType, parentService) {
|
|
409
|
-
this.pkType = pkType;
|
|
410
|
-
if (parentService) {
|
|
411
|
-
this.parentService = parentService;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
getPkType = () => {
|
|
415
|
-
return this.pkType;
|
|
416
|
-
};
|
|
417
|
-
getKeyTypes = () => {
|
|
418
|
-
let keyTypes = [this.getPkType()];
|
|
419
|
-
if (this.parentService) {
|
|
420
|
-
keyTypes = keyTypes.concat(this.parentService.getKeyTypes());
|
|
421
|
-
}
|
|
422
|
-
return keyTypes;
|
|
423
|
-
};
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
// src/item/ItemQuery.ts
|
|
267
|
+
// node_modules/@fjell/types/dist/chunk-5M6KJZFD.js
|
|
427
268
|
var isCondition = (condition) => {
|
|
428
269
|
return (typeof condition.column === "string" && (Array.isArray(condition.value) && condition.value.every((item) => typeof item === "string")) || Array.isArray(condition.value) && condition.value.every((item) => typeof item === "number") || typeof condition.value === "string" || typeof condition.value === "number" || typeof condition.value === "boolean" || condition.value instanceof Date || condition.value === null) && (condition.operator ? typeof condition.operator === "string" : true);
|
|
429
270
|
};
|
|
@@ -548,62 +389,220 @@ var IQFactory = class _IQFactory {
|
|
|
548
389
|
}
|
|
549
390
|
};
|
|
550
391
|
|
|
551
|
-
// src/item/
|
|
552
|
-
import
|
|
553
|
-
var
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
params.compoundCondition = JSON.stringify(query.compoundCondition);
|
|
558
|
-
}
|
|
559
|
-
if (query.refs) {
|
|
560
|
-
params.refs = JSON.stringify(query.refs);
|
|
561
|
-
}
|
|
562
|
-
if (query.limit) {
|
|
563
|
-
params.limit = query.limit;
|
|
564
|
-
}
|
|
565
|
-
if (query.offset) {
|
|
566
|
-
params.offset = query.offset;
|
|
392
|
+
// src/item/IFactory.ts
|
|
393
|
+
import deepmerge from "deepmerge";
|
|
394
|
+
var IFactory = class _IFactory {
|
|
395
|
+
item = {};
|
|
396
|
+
constructor(props = {}) {
|
|
397
|
+
this.item = deepmerge(this.item, props);
|
|
567
398
|
}
|
|
568
|
-
|
|
569
|
-
|
|
399
|
+
addRef(i, name) {
|
|
400
|
+
const ik = i.key;
|
|
401
|
+
const refName = name || primaryType(ik);
|
|
402
|
+
if (!this.item.refs) {
|
|
403
|
+
this.item.refs = {};
|
|
404
|
+
}
|
|
405
|
+
this.item.refs[refName] = ik;
|
|
406
|
+
return this;
|
|
570
407
|
}
|
|
571
|
-
|
|
572
|
-
|
|
408
|
+
static addRef(i, name) {
|
|
409
|
+
return new _IFactory().addRef(i, name);
|
|
573
410
|
}
|
|
574
|
-
|
|
575
|
-
|
|
411
|
+
addDefaultEvents() {
|
|
412
|
+
if (!this.item.events) {
|
|
413
|
+
this.item.events = {};
|
|
414
|
+
}
|
|
415
|
+
const now = /* @__PURE__ */ new Date();
|
|
416
|
+
if (!this.item.events.created) {
|
|
417
|
+
this.item.events.created = { at: now };
|
|
418
|
+
}
|
|
419
|
+
if (!this.item.events.updated) {
|
|
420
|
+
this.item.events.updated = { at: now };
|
|
421
|
+
}
|
|
422
|
+
if (!this.item.events.deleted) {
|
|
423
|
+
this.item.events.deleted = { at: null };
|
|
424
|
+
}
|
|
425
|
+
return this;
|
|
576
426
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
if (typeof value === "string") {
|
|
581
|
-
const parsedDate = luxon.DateTime.fromISO(value);
|
|
582
|
-
if (parsedDate.isValid) {
|
|
583
|
-
return parsedDate.toJSDate();
|
|
584
|
-
;
|
|
427
|
+
addEvent(name, at, by) {
|
|
428
|
+
if (!this.item.events) {
|
|
429
|
+
this.item.events = {};
|
|
585
430
|
}
|
|
431
|
+
this.item.events[name] = { at, by };
|
|
432
|
+
return this;
|
|
586
433
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
var paramsToQuery = (params) => {
|
|
590
|
-
const query = {};
|
|
591
|
-
if (params.compoundCondition) {
|
|
592
|
-
query.compoundCondition = JSON.parse(params.compoundCondition);
|
|
434
|
+
static addEvent(name, at, by) {
|
|
435
|
+
return new _IFactory().addEvent(name, at, by);
|
|
593
436
|
}
|
|
594
|
-
|
|
595
|
-
|
|
437
|
+
addProp(name, value) {
|
|
438
|
+
this.item[name] = value;
|
|
439
|
+
return this;
|
|
596
440
|
}
|
|
597
|
-
|
|
598
|
-
|
|
441
|
+
static addProp(name, value) {
|
|
442
|
+
return new _IFactory().addProp(name, value);
|
|
599
443
|
}
|
|
600
|
-
|
|
601
|
-
|
|
444
|
+
addProps(props) {
|
|
445
|
+
this.item = deepmerge(this.item, props);
|
|
446
|
+
return this;
|
|
602
447
|
}
|
|
603
|
-
|
|
604
|
-
|
|
448
|
+
static addProps(props) {
|
|
449
|
+
return new _IFactory().addProps(props);
|
|
605
450
|
}
|
|
606
|
-
|
|
451
|
+
toItem() {
|
|
452
|
+
return this.item;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
// src/AItemService.ts
|
|
457
|
+
var AItemService = class {
|
|
458
|
+
pkType;
|
|
459
|
+
parentService = null;
|
|
460
|
+
constructor(pkType, parentService) {
|
|
461
|
+
this.pkType = pkType;
|
|
462
|
+
if (parentService) {
|
|
463
|
+
this.parentService = parentService;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
getPkType = () => {
|
|
467
|
+
return this.pkType;
|
|
468
|
+
};
|
|
469
|
+
getKeyTypes = () => {
|
|
470
|
+
let keyTypes = [this.getPkType()];
|
|
471
|
+
if (this.parentService) {
|
|
472
|
+
keyTypes = keyTypes.concat(this.parentService.getKeyTypes());
|
|
473
|
+
}
|
|
474
|
+
return keyTypes;
|
|
475
|
+
};
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// src/Coordinate.ts
|
|
479
|
+
var logger2 = logger_default.get("Coordinate");
|
|
480
|
+
var createCoordinate = (kta, scopes = []) => {
|
|
481
|
+
const ktArray = Array.isArray(kta) ? kta : [kta];
|
|
482
|
+
const toString = () => {
|
|
483
|
+
logger2.debug("toString", { kta, scopes });
|
|
484
|
+
return `${ktArray.join(", ")} - ${scopes.join(", ")}`;
|
|
485
|
+
};
|
|
486
|
+
logger2.debug("createCoordinate", { kta: ktArray, scopes, toString });
|
|
487
|
+
return { kta: ktArray, scopes, toString };
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// src/dictionary.ts
|
|
491
|
+
var logger3 = logger_default.get("Dictionary");
|
|
492
|
+
var Dictionary = class _Dictionary {
|
|
493
|
+
map = {};
|
|
494
|
+
hashFunction = (key) => JSON.stringify(key);
|
|
495
|
+
constructor(map, hashFunction) {
|
|
496
|
+
if (hashFunction) {
|
|
497
|
+
this.hashFunction = hashFunction;
|
|
498
|
+
}
|
|
499
|
+
if (map) {
|
|
500
|
+
Object.entries(map).forEach(([hashedKey, value]) => {
|
|
501
|
+
try {
|
|
502
|
+
const originalKey = JSON.parse(hashedKey);
|
|
503
|
+
this.map[hashedKey] = { originalKey, value };
|
|
504
|
+
} catch {
|
|
505
|
+
logger3.warning("Cannot recover original key from legacy map entry", { hashedKey });
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
set(key, item) {
|
|
511
|
+
logger3.trace("set", { key, item });
|
|
512
|
+
const hashedKey = this.hashFunction(key);
|
|
513
|
+
this.map[hashedKey] = { originalKey: key, value: item };
|
|
514
|
+
}
|
|
515
|
+
get(key) {
|
|
516
|
+
logger3.trace("get", { key });
|
|
517
|
+
const hashedKey = this.hashFunction(key);
|
|
518
|
+
const entry = this.map[hashedKey];
|
|
519
|
+
return entry && this.keysEqual(entry.originalKey, key) ? entry.value : null;
|
|
520
|
+
}
|
|
521
|
+
keysEqual(key1, key2) {
|
|
522
|
+
return key1 === key2;
|
|
523
|
+
}
|
|
524
|
+
delete(key) {
|
|
525
|
+
logger3.trace("delete", { key });
|
|
526
|
+
const hashedKey = this.hashFunction(key);
|
|
527
|
+
delete this.map[hashedKey];
|
|
528
|
+
}
|
|
529
|
+
keys() {
|
|
530
|
+
return Object.values(this.map).map((entry) => entry.originalKey);
|
|
531
|
+
}
|
|
532
|
+
values() {
|
|
533
|
+
return Object.values(this.map).map((entry) => entry.value);
|
|
534
|
+
}
|
|
535
|
+
includesKey(key) {
|
|
536
|
+
const hashedKey = this.hashFunction(key);
|
|
537
|
+
const entry = this.map[hashedKey];
|
|
538
|
+
return entry ? this.keysEqual(entry.originalKey, key) : false;
|
|
539
|
+
}
|
|
540
|
+
clone() {
|
|
541
|
+
const clonedMap = {};
|
|
542
|
+
Object.entries(this.map).forEach(([hashedKey, entry]) => {
|
|
543
|
+
clonedMap[hashedKey] = entry.value;
|
|
544
|
+
});
|
|
545
|
+
const clone = new _Dictionary(clonedMap, this.hashFunction);
|
|
546
|
+
clone.map = Object.assign({}, this.map);
|
|
547
|
+
return clone;
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
// src/item/IQUtils.ts
|
|
552
|
+
import * as luxon from "luxon";
|
|
553
|
+
var logger4 = logger_default.get("IQUtils");
|
|
554
|
+
var queryToParams = (query) => {
|
|
555
|
+
const params = {};
|
|
556
|
+
if (query.compoundCondition) {
|
|
557
|
+
params.compoundCondition = JSON.stringify(query.compoundCondition);
|
|
558
|
+
}
|
|
559
|
+
if (query.refs) {
|
|
560
|
+
params.refs = JSON.stringify(query.refs);
|
|
561
|
+
}
|
|
562
|
+
if (query.limit) {
|
|
563
|
+
params.limit = query.limit;
|
|
564
|
+
}
|
|
565
|
+
if (query.offset) {
|
|
566
|
+
params.offset = query.offset;
|
|
567
|
+
}
|
|
568
|
+
if (query.aggs) {
|
|
569
|
+
params.aggs = JSON.stringify(query.aggs);
|
|
570
|
+
}
|
|
571
|
+
if (query.events) {
|
|
572
|
+
params.events = JSON.stringify(query.events);
|
|
573
|
+
}
|
|
574
|
+
if (query.orderBy) {
|
|
575
|
+
params.orderBy = JSON.stringify(query.orderBy);
|
|
576
|
+
}
|
|
577
|
+
return params;
|
|
578
|
+
};
|
|
579
|
+
var dateTimeReviver = function(key, value) {
|
|
580
|
+
if (typeof value === "string") {
|
|
581
|
+
const parsedDate = luxon.DateTime.fromISO(value);
|
|
582
|
+
if (parsedDate.isValid) {
|
|
583
|
+
return parsedDate.toJSDate();
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return value;
|
|
587
|
+
};
|
|
588
|
+
var paramsToQuery = (params) => {
|
|
589
|
+
const query = {};
|
|
590
|
+
if (params.compoundCondition) {
|
|
591
|
+
query.compoundCondition = JSON.parse(params.compoundCondition);
|
|
592
|
+
}
|
|
593
|
+
if (params.refs) {
|
|
594
|
+
query.refs = JSON.parse(params.refs);
|
|
595
|
+
}
|
|
596
|
+
if (params.limit) {
|
|
597
|
+
query.limit = Number(params.limit);
|
|
598
|
+
}
|
|
599
|
+
if (params.offset) {
|
|
600
|
+
query.offset = Number(params.offset);
|
|
601
|
+
}
|
|
602
|
+
if (params.aggs) {
|
|
603
|
+
query.aggs = JSON.parse(params.aggs);
|
|
604
|
+
}
|
|
605
|
+
if (params.events) {
|
|
607
606
|
query.events = JSON.parse(params.events, dateTimeReviver);
|
|
608
607
|
}
|
|
609
608
|
if (params.orderBy) {
|
|
@@ -814,51 +813,6 @@ var abbrevCondition = (condition) => {
|
|
|
814
813
|
}
|
|
815
814
|
};
|
|
816
815
|
|
|
817
|
-
// src/validation/ItemValidator.ts
|
|
818
|
-
var logger5 = logger_default.get("validation", "ItemValidator");
|
|
819
|
-
var validatePKForItem = (item, pkType) => {
|
|
820
|
-
if (!item) {
|
|
821
|
-
logger5.error("Validating PK, Item is undefined", { item });
|
|
822
|
-
throw new Error("Validating PK, Item is undefined");
|
|
823
|
-
}
|
|
824
|
-
if (!item.key) {
|
|
825
|
-
logger5.error("Validating PK, Item does not have a key", { item });
|
|
826
|
-
throw new Error("Validating PK, Item does not have a key");
|
|
827
|
-
}
|
|
828
|
-
const keyTypeArray = toKeyTypeArray(item.key);
|
|
829
|
-
if (keyTypeArray[0] !== pkType) {
|
|
830
|
-
logger5.error("Key Type Array Mismatch", { keyTypeArray, pkType });
|
|
831
|
-
throw new Error(`Item does not have the correct primary key type. Expected ${pkType}, got ${keyTypeArray[0]}`);
|
|
832
|
-
}
|
|
833
|
-
return item;
|
|
834
|
-
};
|
|
835
|
-
var validatePK = (input, pkType) => {
|
|
836
|
-
logger5.trace("Checking Return Type", { input });
|
|
837
|
-
if (Array.isArray(input)) {
|
|
838
|
-
return input.map((item) => validatePKForItem(item, pkType));
|
|
839
|
-
}
|
|
840
|
-
return validatePKForItem(input, pkType);
|
|
841
|
-
};
|
|
842
|
-
var validateKeys = (item, keyTypes) => {
|
|
843
|
-
logger5.trace("Checking Return Type", { item });
|
|
844
|
-
if (!item) {
|
|
845
|
-
throw new Error("validating keys, item is undefined");
|
|
846
|
-
}
|
|
847
|
-
if (!item.key) {
|
|
848
|
-
throw new Error("validating keys, item does not have a key: " + JSON.stringify(item));
|
|
849
|
-
}
|
|
850
|
-
const keyTypeArray = toKeyTypeArray(item.key);
|
|
851
|
-
if (keyTypeArray.length !== keyTypes.length) {
|
|
852
|
-
throw new Error(`Item does not have the correct number of keys. Expected ${keyTypes.length}, but got ${keyTypeArray.length}`);
|
|
853
|
-
}
|
|
854
|
-
const match = JSON.stringify(keyTypeArray) === JSON.stringify(keyTypes);
|
|
855
|
-
if (!match) {
|
|
856
|
-
logger5.error("Key Type Array Mismatch", { keyTypeArray, thisKeyTypes: keyTypes });
|
|
857
|
-
throw new Error(`Item does not have the correct key types. Expected [${keyTypes.join(", ")}], but got [${keyTypeArray.join(", ")}]`);
|
|
858
|
-
}
|
|
859
|
-
return item;
|
|
860
|
-
};
|
|
861
|
-
|
|
862
816
|
// src/item/IUtils.ts
|
|
863
817
|
var isPriItem = (item) => {
|
|
864
818
|
return !!(item && item.key && isPriKey(item.key));
|
|
@@ -867,71 +821,328 @@ var isComItem = (item) => {
|
|
|
867
821
|
return !!(item && item.key && isComKey(item.key));
|
|
868
822
|
};
|
|
869
823
|
|
|
870
|
-
// src/
|
|
871
|
-
var
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
coordinate: keyTypeArray
|
|
883
|
-
});
|
|
884
|
-
if (actualLocationTypes.length > expectedLocationTypes.length) {
|
|
885
|
-
logger6.error("Location key array has too many elements", {
|
|
886
|
-
expected: expectedLocationTypes.length,
|
|
887
|
-
actual: actualLocationTypes.length,
|
|
888
|
-
expectedTypes: expectedLocationTypes,
|
|
889
|
-
actualTypes: actualLocationTypes,
|
|
890
|
-
coordinate,
|
|
891
|
-
operation
|
|
892
|
-
});
|
|
893
|
-
throw new Error(
|
|
894
|
-
`Invalid location key array for ${operation}: Expected at most ${expectedLocationTypes.length} location keys (hierarchy: [${expectedLocationTypes.join(", ")}]), but received ${actualLocationTypes.length} (types: [${actualLocationTypes.join(", ")}])`
|
|
895
|
-
);
|
|
896
|
-
}
|
|
897
|
-
for (let i = 0; i < actualLocationTypes.length; i++) {
|
|
898
|
-
if (expectedLocationTypes[i] !== actualLocationTypes[i]) {
|
|
899
|
-
logger6.error("Location key array order mismatch", {
|
|
900
|
-
position: i,
|
|
901
|
-
expected: expectedLocationTypes[i],
|
|
902
|
-
actual: actualLocationTypes[i],
|
|
903
|
-
expectedHierarchy: expectedLocationTypes,
|
|
904
|
-
actualOrder: actualLocationTypes,
|
|
905
|
-
coordinate,
|
|
906
|
-
operation
|
|
907
|
-
});
|
|
908
|
-
throw new Error(
|
|
909
|
-
`Invalid location key array order for ${operation}: At position ${i}, expected key type "${expectedLocationTypes[i]}" but received "${actualLocationTypes[i]}". Location keys must be ordered according to the hierarchy: [${expectedLocationTypes.join(", ")}]. Received order: [${actualLocationTypes.join(", ")}]`
|
|
910
|
-
);
|
|
824
|
+
// src/errors/ActionError.ts
|
|
825
|
+
var ActionError = class extends Error {
|
|
826
|
+
constructor(errorInfo, cause) {
|
|
827
|
+
super(errorInfo.message);
|
|
828
|
+
this.errorInfo = errorInfo;
|
|
829
|
+
this.name = "ActionError";
|
|
830
|
+
this.cause = cause;
|
|
831
|
+
if (!this.errorInfo.technical) {
|
|
832
|
+
this.errorInfo.technical = { timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
833
|
+
}
|
|
834
|
+
if (!this.errorInfo.technical.timestamp) {
|
|
835
|
+
this.errorInfo.technical.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
911
836
|
}
|
|
912
837
|
}
|
|
913
|
-
|
|
838
|
+
toJSON() {
|
|
839
|
+
return this.errorInfo;
|
|
840
|
+
}
|
|
914
841
|
};
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
842
|
+
|
|
843
|
+
// src/errors/ValidationError.ts
|
|
844
|
+
var ValidationError = class extends ActionError {
|
|
845
|
+
fieldErrors;
|
|
846
|
+
constructor(message, validOptions, suggestedAction, conflictingValue, fieldErrors) {
|
|
847
|
+
super({
|
|
848
|
+
code: "VALIDATION_ERROR",
|
|
849
|
+
message,
|
|
850
|
+
operation: { type: "create", name: "", params: {} },
|
|
851
|
+
// Will be filled by wrapper
|
|
852
|
+
context: { itemType: "" },
|
|
853
|
+
// Will be filled by wrapper
|
|
854
|
+
details: {
|
|
855
|
+
validOptions,
|
|
856
|
+
suggestedAction: suggestedAction || (validOptions && validOptions.length > 0 ? `Valid options are: ${validOptions.join(", ")}. Please use one of these values.` : "Check the validation requirements and ensure all fields meet the required format, type, and constraints."),
|
|
857
|
+
retryable: true,
|
|
858
|
+
conflictingValue,
|
|
859
|
+
fieldErrors
|
|
860
|
+
},
|
|
861
|
+
technical: {
|
|
862
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
this.fieldErrors = fieldErrors;
|
|
866
|
+
if (fieldErrors) {
|
|
867
|
+
if (!this.errorInfo.details) this.errorInfo.details = {};
|
|
868
|
+
this.errorInfo.details.fieldErrors = fieldErrors;
|
|
869
|
+
}
|
|
924
870
|
}
|
|
925
871
|
};
|
|
926
872
|
|
|
927
|
-
// src/
|
|
928
|
-
var
|
|
873
|
+
// src/errors/NotFoundError.ts
|
|
874
|
+
var NotFoundError = class extends ActionError {
|
|
875
|
+
constructor(message, itemType, key) {
|
|
876
|
+
super({
|
|
877
|
+
code: "NOT_FOUND",
|
|
878
|
+
message,
|
|
879
|
+
operation: { type: "get", name: "", params: {} },
|
|
880
|
+
context: {
|
|
881
|
+
itemType,
|
|
882
|
+
key: typeof key === "object" ? key : { primary: key }
|
|
883
|
+
},
|
|
884
|
+
details: {
|
|
885
|
+
suggestedAction: "Verify the item ID/key is correct, check if the item was deleted, or create the item if it should exist.",
|
|
886
|
+
retryable: false
|
|
887
|
+
},
|
|
888
|
+
technical: {
|
|
889
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
this.name = "NotFoundError";
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
// src/errors/BusinessLogicError.ts
|
|
897
|
+
var BusinessLogicError = class extends ActionError {
|
|
898
|
+
constructor(message, suggestedAction, retryable = false) {
|
|
899
|
+
super({
|
|
900
|
+
code: "BUSINESS_LOGIC_ERROR",
|
|
901
|
+
message,
|
|
902
|
+
operation: { type: "action", name: "", params: {} },
|
|
903
|
+
context: { itemType: "" },
|
|
904
|
+
details: {
|
|
905
|
+
suggestedAction: suggestedAction || "Review the business logic requirements and ensure all conditions are met before retrying.",
|
|
906
|
+
retryable
|
|
907
|
+
},
|
|
908
|
+
technical: {
|
|
909
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
// src/errors/PermissionError.ts
|
|
916
|
+
var PermissionError = class extends ActionError {
|
|
917
|
+
constructor(message, requiredPermission, currentPermissions) {
|
|
918
|
+
super({
|
|
919
|
+
code: "PERMISSION_DENIED",
|
|
920
|
+
message,
|
|
921
|
+
operation: { type: "action", name: "", params: {} },
|
|
922
|
+
context: {
|
|
923
|
+
itemType: "",
|
|
924
|
+
...requiredPermission && { requiredPermission }
|
|
925
|
+
},
|
|
926
|
+
details: {
|
|
927
|
+
...requiredPermission && {
|
|
928
|
+
suggestedAction: `Required permission: ${requiredPermission}`,
|
|
929
|
+
expectedValue: requiredPermission
|
|
930
|
+
},
|
|
931
|
+
...currentPermissions && { conflictingValue: currentPermissions },
|
|
932
|
+
retryable: false
|
|
933
|
+
},
|
|
934
|
+
technical: {
|
|
935
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
// src/errors/DuplicateError.ts
|
|
942
|
+
var DuplicateError = class extends ActionError {
|
|
943
|
+
constructor(message, existingItemIdOrKey, duplicateField) {
|
|
944
|
+
let existingItemId = null;
|
|
945
|
+
let keyInfo = null;
|
|
946
|
+
if (typeof existingItemIdOrKey === "object" && existingItemIdOrKey !== null) {
|
|
947
|
+
existingItemId = existingItemIdOrKey.pk || existingItemIdOrKey.id || existingItemIdOrKey.primary || null;
|
|
948
|
+
if (existingItemId !== null) {
|
|
949
|
+
keyInfo = {
|
|
950
|
+
primary: existingItemId,
|
|
951
|
+
...existingItemIdOrKey
|
|
952
|
+
};
|
|
953
|
+
} else {
|
|
954
|
+
keyInfo = existingItemIdOrKey;
|
|
955
|
+
}
|
|
956
|
+
} else if (typeof existingItemIdOrKey !== "undefined") {
|
|
957
|
+
existingItemId = existingItemIdOrKey;
|
|
958
|
+
keyInfo = { primary: existingItemId };
|
|
959
|
+
}
|
|
960
|
+
super({
|
|
961
|
+
code: "DUPLICATE_ERROR",
|
|
962
|
+
message,
|
|
963
|
+
operation: { type: "create", name: "", params: {} },
|
|
964
|
+
context: {
|
|
965
|
+
itemType: "",
|
|
966
|
+
...keyInfo && { key: keyInfo },
|
|
967
|
+
...existingItemId && {
|
|
968
|
+
affectedItems: [{
|
|
969
|
+
id: existingItemId,
|
|
970
|
+
type: "",
|
|
971
|
+
displayName: `Existing item with ${duplicateField || "key"}`
|
|
972
|
+
}]
|
|
973
|
+
}
|
|
974
|
+
},
|
|
975
|
+
details: {
|
|
976
|
+
suggestedAction: duplicateField ? `An item with this ${duplicateField} already exists. Use a different ${duplicateField} value or update the existing item.` : "An item with this key already exists. Use a different key or update the existing item using upsert.",
|
|
977
|
+
retryable: false,
|
|
978
|
+
conflictingValue: duplicateField
|
|
979
|
+
},
|
|
980
|
+
technical: {
|
|
981
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
// src/operations/errorEnhancer.ts
|
|
988
|
+
async function executeWithContext(operation, context) {
|
|
989
|
+
try {
|
|
990
|
+
return await operation();
|
|
991
|
+
} catch (error) {
|
|
992
|
+
throw enhanceError(error, context);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
function executeWithContextSync(operation, context) {
|
|
996
|
+
try {
|
|
997
|
+
return operation();
|
|
998
|
+
} catch (error) {
|
|
999
|
+
throw enhanceError(error, context);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
function enhanceError(error, context) {
|
|
1003
|
+
if (!(error instanceof ActionError)) {
|
|
1004
|
+
return error;
|
|
1005
|
+
}
|
|
1006
|
+
error.errorInfo.operation = {
|
|
1007
|
+
type: context.operationType,
|
|
1008
|
+
name: context.operationName,
|
|
1009
|
+
params: context.params
|
|
1010
|
+
};
|
|
1011
|
+
if (!error.errorInfo.context.itemType) {
|
|
1012
|
+
error.errorInfo.context.itemType = context.itemType;
|
|
1013
|
+
}
|
|
1014
|
+
if (context.key) {
|
|
1015
|
+
const existingKey = error.errorInfo.context.key;
|
|
1016
|
+
const hasNoPrimaryKey = !existingKey || typeof existingKey.primary === "undefined";
|
|
1017
|
+
const hasNoCompositeKey = !existingKey || !existingKey.composite;
|
|
1018
|
+
const shouldOverride = hasNoPrimaryKey && hasNoCompositeKey;
|
|
1019
|
+
if (shouldOverride) {
|
|
1020
|
+
error.errorInfo.context.key = extractKeyInfo(context.key);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
if (context.locations && context.locations.length > 0 && !error.errorInfo.context.parentLocation) {
|
|
1024
|
+
error.errorInfo.context.parentLocation = {
|
|
1025
|
+
id: context.locations[0].lk,
|
|
1026
|
+
type: context.locations[0].kt
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
return error;
|
|
1030
|
+
}
|
|
1031
|
+
function extractKeyInfo(key) {
|
|
1032
|
+
if ("loc" in key) {
|
|
1033
|
+
const ktaArray = Array.isArray(key.kt) ? key.kt : [key.kt];
|
|
1034
|
+
const locations = Array.isArray(key.loc) ? key.loc : [];
|
|
1035
|
+
return {
|
|
1036
|
+
composite: {
|
|
1037
|
+
sk: key.pk,
|
|
1038
|
+
kta: ktaArray,
|
|
1039
|
+
locations: locations.map((loc) => ({
|
|
1040
|
+
lk: loc.lk,
|
|
1041
|
+
kt: loc.kt
|
|
1042
|
+
}))
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
} else if ("pk" in key) {
|
|
1046
|
+
return { primary: key.pk };
|
|
1047
|
+
}
|
|
1048
|
+
return { primary: JSON.stringify(key) };
|
|
1049
|
+
}
|
|
1050
|
+
function isActionError(error) {
|
|
1051
|
+
return error instanceof ActionError;
|
|
1052
|
+
}
|
|
1053
|
+
function getErrorInfo(error) {
|
|
1054
|
+
if (isActionError(error)) {
|
|
1055
|
+
return error.toJSON();
|
|
1056
|
+
}
|
|
1057
|
+
if (error instanceof Error) {
|
|
1058
|
+
return {
|
|
1059
|
+
code: "UNKNOWN_ERROR",
|
|
1060
|
+
message: error.message,
|
|
1061
|
+
technical: {
|
|
1062
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1063
|
+
stackTrace: error.stack
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
return {
|
|
1068
|
+
code: "UNKNOWN_ERROR",
|
|
1069
|
+
message: String(error),
|
|
1070
|
+
technical: {
|
|
1071
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// node_modules/@fjell/validation/dist/index.js
|
|
1077
|
+
import Logging2 from "@fjell/logging";
|
|
1078
|
+
import Logging22 from "@fjell/logging";
|
|
1079
|
+
import Logging3 from "@fjell/logging";
|
|
1080
|
+
import Logging4 from "@fjell/logging";
|
|
1081
|
+
var logger5 = Logging2.getLogger("validation.LocationValidator");
|
|
1082
|
+
var validateLocations = (locations, coordinate, operation) => {
|
|
1083
|
+
if (!locations || locations.length === 0) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const keyTypeArray = coordinate.kta;
|
|
1087
|
+
const expectedLocationTypes = keyTypeArray.slice(1);
|
|
1088
|
+
const actualLocationTypes = locations.map((loc) => loc.kt);
|
|
1089
|
+
logger5.debug(`Validating locations for ${operation}`, {
|
|
1090
|
+
expected: expectedLocationTypes,
|
|
1091
|
+
actual: actualLocationTypes,
|
|
1092
|
+
coordinate: keyTypeArray
|
|
1093
|
+
});
|
|
1094
|
+
if (actualLocationTypes.length > expectedLocationTypes.length) {
|
|
1095
|
+
logger5.error("Location key array has too many elements", {
|
|
1096
|
+
expected: expectedLocationTypes.length,
|
|
1097
|
+
actual: actualLocationTypes.length,
|
|
1098
|
+
expectedTypes: expectedLocationTypes,
|
|
1099
|
+
actualTypes: actualLocationTypes,
|
|
1100
|
+
coordinate,
|
|
1101
|
+
operation
|
|
1102
|
+
});
|
|
1103
|
+
throw new Error(
|
|
1104
|
+
`Invalid location key array for ${operation}: Expected at most ${expectedLocationTypes.length} location keys (hierarchy: [${expectedLocationTypes.join(", ")}]), but received ${actualLocationTypes.length} (types: [${actualLocationTypes.join(", ")}])`
|
|
1105
|
+
);
|
|
1106
|
+
}
|
|
1107
|
+
for (let i = 0; i < actualLocationTypes.length; i++) {
|
|
1108
|
+
if (expectedLocationTypes[i] !== actualLocationTypes[i]) {
|
|
1109
|
+
logger5.error("Location key array order mismatch", {
|
|
1110
|
+
position: i,
|
|
1111
|
+
expected: expectedLocationTypes[i],
|
|
1112
|
+
actual: actualLocationTypes[i],
|
|
1113
|
+
expectedHierarchy: expectedLocationTypes,
|
|
1114
|
+
actualOrder: actualLocationTypes,
|
|
1115
|
+
coordinate,
|
|
1116
|
+
operation
|
|
1117
|
+
});
|
|
1118
|
+
throw new Error(
|
|
1119
|
+
`Invalid location key array order for ${operation}: At position ${i}, expected key type "${expectedLocationTypes[i]}" but received "${actualLocationTypes[i]}". Location keys must be ordered according to the hierarchy: [${expectedLocationTypes.join(", ")}]. Received order: [${actualLocationTypes.join(", ")}]`
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
logger5.debug(`Location key array validation passed for ${operation}`, { locations });
|
|
1124
|
+
};
|
|
1125
|
+
var isComKey3 = (key) => {
|
|
1126
|
+
return typeof key !== "undefined" && (typeof key.pk !== "undefined" && typeof key.kt !== "undefined") && (typeof key.loc !== "undefined" && Array.isArray(key.loc));
|
|
1127
|
+
};
|
|
1128
|
+
var isPriKey3 = (key) => {
|
|
1129
|
+
return typeof key !== "undefined" && (typeof key.pk !== "undefined" && typeof key.kt !== "undefined") && typeof key.loc === "undefined";
|
|
1130
|
+
};
|
|
1131
|
+
var toKeyTypeArray2 = (ik) => {
|
|
1132
|
+
if (isComKey3(ik)) {
|
|
1133
|
+
const ck = ik;
|
|
1134
|
+
return [ck.kt, ...ck.loc.map((l) => l.kt)];
|
|
1135
|
+
} else {
|
|
1136
|
+
return [ik.kt];
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
var logger22 = Logging22.getLogger("validation.KeyValidator");
|
|
929
1140
|
var validateLocationKeyOrder = (key, coordinate, operation) => {
|
|
930
1141
|
const keyTypeArray = coordinate.kta;
|
|
931
1142
|
const expectedLocationTypes = keyTypeArray.slice(1);
|
|
932
1143
|
const actualLocationTypes = key.loc.map((loc) => loc.kt);
|
|
933
1144
|
if (expectedLocationTypes.length !== actualLocationTypes.length) {
|
|
934
|
-
|
|
1145
|
+
logger22.error("Location key array length mismatch", {
|
|
935
1146
|
expected: expectedLocationTypes.length,
|
|
936
1147
|
actual: actualLocationTypes.length,
|
|
937
1148
|
key,
|
|
@@ -958,7 +1169,7 @@ ${actualOrder}`
|
|
|
958
1169
|
}
|
|
959
1170
|
for (let i = 0; i < expectedLocationTypes.length; i++) {
|
|
960
1171
|
if (expectedLocationTypes[i] !== actualLocationTypes[i]) {
|
|
961
|
-
|
|
1172
|
+
logger22.error("Location key array order mismatch", {
|
|
962
1173
|
position: i,
|
|
963
1174
|
expected: expectedLocationTypes[i],
|
|
964
1175
|
actual: actualLocationTypes[i],
|
|
@@ -989,7 +1200,7 @@ Tip: Location keys must be ordered according to the hierarchy: [${expectedLocati
|
|
|
989
1200
|
}
|
|
990
1201
|
};
|
|
991
1202
|
var validateKey = (key, coordinate, operation) => {
|
|
992
|
-
|
|
1203
|
+
logger22.debug(`Validating key for ${operation}`, { key, coordinate: coordinate.kta });
|
|
993
1204
|
if (!key || key === null) {
|
|
994
1205
|
throw new Error(
|
|
995
1206
|
`Invalid key structure for ${operation} operation.
|
|
@@ -1002,10 +1213,10 @@ Valid key formats:
|
|
|
1002
1213
|
);
|
|
1003
1214
|
}
|
|
1004
1215
|
const isCompositeLibrary = coordinate.kta.length > 1;
|
|
1005
|
-
const keyIsComposite =
|
|
1006
|
-
const keyIsPrimary =
|
|
1216
|
+
const keyIsComposite = isComKey3(key);
|
|
1217
|
+
const keyIsPrimary = isPriKey3(key);
|
|
1007
1218
|
if (isCompositeLibrary && !keyIsComposite) {
|
|
1008
|
-
|
|
1219
|
+
logger22.error(`Composite library received primary key in ${operation}`, { key, coordinate });
|
|
1009
1220
|
const keyTypeArray = coordinate.kta;
|
|
1010
1221
|
throw new Error(
|
|
1011
1222
|
`Invalid key type for ${operation} operation.
|
|
@@ -1033,7 +1244,7 @@ Example correct usage:
|
|
|
1033
1244
|
);
|
|
1034
1245
|
}
|
|
1035
1246
|
if (!isCompositeLibrary && keyIsComposite) {
|
|
1036
|
-
|
|
1247
|
+
logger22.error(`Primary library received composite key in ${operation}`, { key, coordinate });
|
|
1037
1248
|
const keyTypeArray = coordinate.kta;
|
|
1038
1249
|
throw new Error(
|
|
1039
1250
|
`Invalid key type for ${operation} operation.
|
|
@@ -1051,7 +1262,7 @@ Example correct usage:
|
|
|
1051
1262
|
);
|
|
1052
1263
|
}
|
|
1053
1264
|
if (!keyIsPrimary && !keyIsComposite) {
|
|
1054
|
-
|
|
1265
|
+
logger22.error(`Invalid key structure in ${operation}`, { key, coordinate });
|
|
1055
1266
|
throw new Error(
|
|
1056
1267
|
`Invalid key structure for ${operation} operation.
|
|
1057
1268
|
|
|
@@ -1067,7 +1278,7 @@ Valid key formats:
|
|
|
1067
1278
|
}
|
|
1068
1279
|
const expectedKeyType = coordinate.kta[0];
|
|
1069
1280
|
if (key.kt !== expectedKeyType) {
|
|
1070
|
-
|
|
1281
|
+
logger22.error(`Key type mismatch in ${operation}`, {
|
|
1071
1282
|
expected: expectedKeyType,
|
|
1072
1283
|
received: key.kt,
|
|
1073
1284
|
key,
|
|
@@ -1086,64 +1297,70 @@ Example correct usage:
|
|
|
1086
1297
|
if (keyIsComposite) {
|
|
1087
1298
|
const comKey = key;
|
|
1088
1299
|
if (comKey.loc.length === 0) {
|
|
1089
|
-
|
|
1300
|
+
logger22.debug(`Empty loc array detected in ${operation} - will search across all locations`, { key });
|
|
1090
1301
|
} else {
|
|
1091
1302
|
validateLocationKeyOrder(comKey, coordinate, operation);
|
|
1092
1303
|
}
|
|
1093
1304
|
}
|
|
1094
|
-
|
|
1305
|
+
logger22.debug(`Key validation passed for ${operation}`, { key });
|
|
1095
1306
|
};
|
|
1096
|
-
var
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1307
|
+
var logger32 = Logging3.getLogger("validation.ItemValidator");
|
|
1308
|
+
var validatePKForItem = (item, pkType) => {
|
|
1309
|
+
if (!item) {
|
|
1310
|
+
logger32.error("Item validation failed - item is undefined", {
|
|
1311
|
+
component: "core",
|
|
1312
|
+
operation: "validatePK",
|
|
1313
|
+
expectedType: pkType,
|
|
1314
|
+
item,
|
|
1315
|
+
suggestion: "Ensure the operation returns a valid item object, not undefined/null"
|
|
1316
|
+
});
|
|
1317
|
+
throw new Error(
|
|
1318
|
+
`Item validation failed: item is undefined. Expected item of type '${pkType}'. This usually indicates a database operation returned null/undefined unexpectedly.`
|
|
1319
|
+
);
|
|
1102
1320
|
}
|
|
1103
|
-
if (key
|
|
1321
|
+
if (!item.key) {
|
|
1322
|
+
logger32.error("Item validation failed - item missing key", {
|
|
1323
|
+
component: "core",
|
|
1324
|
+
operation: "validatePK",
|
|
1325
|
+
expectedType: pkType,
|
|
1326
|
+
item,
|
|
1327
|
+
suggestion: "Ensure the item has a valid key property with kt and pk fields"
|
|
1328
|
+
});
|
|
1104
1329
|
throw new Error(
|
|
1105
|
-
`
|
|
1106
|
-
Expected: '${expectedType}'
|
|
1107
|
-
Received: '${key.kt}'`
|
|
1330
|
+
`Item validation failed: item does not have a key property. Expected key with type '${pkType}'. Item: ${JSON.stringify(item)}. This indicates a database processing error.`
|
|
1108
1331
|
);
|
|
1109
1332
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
if (key.kt !== coordinate.kta[0]) {
|
|
1333
|
+
const keyTypeArray = toKeyTypeArray2(item.key);
|
|
1334
|
+
if (keyTypeArray[0] !== pkType) {
|
|
1335
|
+
logger32.error("Key type mismatch during validation", {
|
|
1336
|
+
component: "core",
|
|
1337
|
+
operation: "validatePK",
|
|
1338
|
+
expectedType: pkType,
|
|
1339
|
+
actualType: keyTypeArray[0],
|
|
1340
|
+
keyTypeArray,
|
|
1341
|
+
itemKey: item.key,
|
|
1342
|
+
suggestion: `Ensure the item key has kt: '${pkType}', not '${keyTypeArray[0]}'`
|
|
1343
|
+
});
|
|
1122
1344
|
throw new Error(
|
|
1123
|
-
`
|
|
1124
|
-
Expected: '${coordinate.kta[0]}'
|
|
1125
|
-
Received: '${key.kt}'`
|
|
1345
|
+
`Item has incorrect primary key type. Expected '${pkType}', got '${keyTypeArray[0]}'. Key: ${JSON.stringify(item.key)}. This indicates a data model mismatch.`
|
|
1126
1346
|
);
|
|
1127
1347
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
if (key.loc.length > 0) {
|
|
1135
|
-
validateLocationKeyOrder(key, coordinate, operation);
|
|
1348
|
+
return item;
|
|
1349
|
+
};
|
|
1350
|
+
var validatePK = (input, pkType) => {
|
|
1351
|
+
logger32.trace("Checking Return Type", { input });
|
|
1352
|
+
if (Array.isArray(input)) {
|
|
1353
|
+
return input.map((item) => validatePKForItem(item, pkType));
|
|
1136
1354
|
}
|
|
1355
|
+
return validatePKForItem(input, pkType);
|
|
1137
1356
|
};
|
|
1138
|
-
|
|
1139
|
-
// src/validation/QueryValidator.ts
|
|
1140
|
-
var logger8 = logger_default.get("validation", "QueryValidator");
|
|
1357
|
+
var logger42 = Logging4.getLogger("validation.QueryValidator");
|
|
1141
1358
|
var validateQuery = (query, operation) => {
|
|
1142
1359
|
if (typeof query === "undefined" || query === null) {
|
|
1143
1360
|
return;
|
|
1144
1361
|
}
|
|
1145
1362
|
if (typeof query !== "object") {
|
|
1146
|
-
|
|
1363
|
+
logger42.error(`Invalid query type for ${operation}`, { query, type: typeof query });
|
|
1147
1364
|
throw new Error(
|
|
1148
1365
|
`[${operation}] Invalid query parameter.
|
|
1149
1366
|
|
|
@@ -1157,7 +1374,7 @@ Example valid queries:
|
|
|
1157
1374
|
);
|
|
1158
1375
|
}
|
|
1159
1376
|
if (Array.isArray(query)) {
|
|
1160
|
-
|
|
1377
|
+
logger42.error(`Query cannot be an array for ${operation}`, { query });
|
|
1161
1378
|
throw new Error(
|
|
1162
1379
|
`[${operation}] Invalid query parameter.
|
|
1163
1380
|
|
|
@@ -1165,14 +1382,14 @@ Query cannot be an array.
|
|
|
1165
1382
|
Received: ${JSON.stringify(query)}`
|
|
1166
1383
|
);
|
|
1167
1384
|
}
|
|
1168
|
-
|
|
1385
|
+
logger42.debug(`Query validation passed for ${operation}`, { query });
|
|
1169
1386
|
};
|
|
1170
1387
|
var validateOperationParams = (params, operation) => {
|
|
1171
1388
|
if (typeof params === "undefined") {
|
|
1172
1389
|
return;
|
|
1173
1390
|
}
|
|
1174
1391
|
if (params === null) {
|
|
1175
|
-
|
|
1392
|
+
logger42.error(`Params cannot be null for ${operation}`, { params });
|
|
1176
1393
|
throw new Error(
|
|
1177
1394
|
`[${operation}] Invalid operation parameters.
|
|
1178
1395
|
|
|
@@ -1187,7 +1404,7 @@ Example valid parameters:
|
|
|
1187
1404
|
);
|
|
1188
1405
|
}
|
|
1189
1406
|
if (typeof params !== "object") {
|
|
1190
|
-
|
|
1407
|
+
logger42.error(`Invalid params type for ${operation}`, { params, type: typeof params });
|
|
1191
1408
|
throw new Error(
|
|
1192
1409
|
`[${operation}] Invalid operation parameters.
|
|
1193
1410
|
|
|
@@ -1201,7 +1418,7 @@ Example valid parameters:
|
|
|
1201
1418
|
);
|
|
1202
1419
|
}
|
|
1203
1420
|
if (Array.isArray(params)) {
|
|
1204
|
-
|
|
1421
|
+
logger42.error(`Params cannot be an array for ${operation}`, { params });
|
|
1205
1422
|
throw new Error(
|
|
1206
1423
|
`[${operation}] Invalid operation parameters.
|
|
1207
1424
|
|
|
@@ -1215,7 +1432,7 @@ Received: ${JSON.stringify(params)}`
|
|
|
1215
1432
|
(v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean" || v instanceof Date
|
|
1216
1433
|
);
|
|
1217
1434
|
if (!isValidType) {
|
|
1218
|
-
|
|
1435
|
+
logger42.error(`Invalid param value type for ${operation}`, { key, value, valueType });
|
|
1219
1436
|
throw new Error(
|
|
1220
1437
|
`[${operation}] Invalid value type for parameter "${key}".
|
|
1221
1438
|
|
|
@@ -1225,11 +1442,11 @@ Value: ${JSON.stringify(value)}`
|
|
|
1225
1442
|
);
|
|
1226
1443
|
}
|
|
1227
1444
|
}
|
|
1228
|
-
|
|
1445
|
+
logger42.debug(`Operation params validation passed for ${operation}`, { params });
|
|
1229
1446
|
};
|
|
1230
1447
|
var validateFinderName = (finder, operation) => {
|
|
1231
1448
|
if (!finder || typeof finder !== "string") {
|
|
1232
|
-
|
|
1449
|
+
logger42.error(`Invalid finder name for ${operation}`, { finder, type: typeof finder });
|
|
1233
1450
|
throw new Error(
|
|
1234
1451
|
`[${operation}] Finder name must be a non-empty string.
|
|
1235
1452
|
|
|
@@ -1237,18 +1454,18 @@ Received: ${JSON.stringify(finder)}`
|
|
|
1237
1454
|
);
|
|
1238
1455
|
}
|
|
1239
1456
|
if (finder.trim().length === 0) {
|
|
1240
|
-
|
|
1457
|
+
logger42.error(`Empty finder name for ${operation}`, { finder });
|
|
1241
1458
|
throw new Error(
|
|
1242
1459
|
`[${operation}] Finder name cannot be empty or whitespace only.
|
|
1243
1460
|
|
|
1244
1461
|
Received: "${finder}"`
|
|
1245
1462
|
);
|
|
1246
1463
|
}
|
|
1247
|
-
|
|
1464
|
+
logger42.debug(`Finder name validation passed for ${operation}`, { finder });
|
|
1248
1465
|
};
|
|
1249
1466
|
var validateActionName = (action, operation) => {
|
|
1250
1467
|
if (!action || typeof action !== "string") {
|
|
1251
|
-
|
|
1468
|
+
logger42.error(`Invalid action name for ${operation}`, { action, type: typeof action });
|
|
1252
1469
|
throw new Error(
|
|
1253
1470
|
`[${operation}] Action name must be a non-empty string.
|
|
1254
1471
|
|
|
@@ -1256,580 +1473,42 @@ Received: ${JSON.stringify(action)}`
|
|
|
1256
1473
|
);
|
|
1257
1474
|
}
|
|
1258
1475
|
if (action.trim().length === 0) {
|
|
1259
|
-
|
|
1476
|
+
logger42.error(`Empty action name for ${operation}`, { action });
|
|
1260
1477
|
throw new Error(
|
|
1261
1478
|
`[${operation}] Action name cannot be empty or whitespace only.
|
|
1262
1479
|
|
|
1263
1480
|
Received: "${action}"`
|
|
1264
1481
|
);
|
|
1265
1482
|
}
|
|
1266
|
-
|
|
1483
|
+
logger42.debug(`Action name validation passed for ${operation}`, { action });
|
|
1267
1484
|
};
|
|
1268
1485
|
var validateFacetName = (facet, operation) => {
|
|
1269
1486
|
if (!facet || typeof facet !== "string") {
|
|
1270
|
-
|
|
1487
|
+
logger42.error(`Invalid facet name for ${operation}`, { facet, type: typeof facet });
|
|
1271
1488
|
throw new Error(
|
|
1272
1489
|
`[${operation}] Facet name must be a non-empty string.
|
|
1273
1490
|
|
|
1274
|
-
Received: ${JSON.stringify(facet)}`
|
|
1275
|
-
);
|
|
1276
|
-
}
|
|
1277
|
-
if (facet.trim().length === 0) {
|
|
1278
|
-
|
|
1279
|
-
throw new Error(
|
|
1280
|
-
`[${operation}] Facet name cannot be empty or whitespace only.
|
|
1281
|
-
|
|
1282
|
-
Received: "${facet}"`
|
|
1283
|
-
);
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
|
-
// src/errors/ActionError.ts
|
|
1289
|
-
var ActionError = class extends Error {
|
|
1290
|
-
constructor(errorInfo, cause) {
|
|
1291
|
-
super(errorInfo.message);
|
|
1292
|
-
this.errorInfo = errorInfo;
|
|
1293
|
-
this.name = "ActionError";
|
|
1294
|
-
this.cause = cause;
|
|
1295
|
-
if (!this.errorInfo.technical) {
|
|
1296
|
-
this.errorInfo.technical = { timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1297
|
-
}
|
|
1298
|
-
if (!this.errorInfo.technical.timestamp) {
|
|
1299
|
-
this.errorInfo.technical.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
toJSON() {
|
|
1303
|
-
return this.errorInfo;
|
|
1304
|
-
}
|
|
1305
|
-
};
|
|
1306
|
-
|
|
1307
|
-
// src/errors/ValidationError.ts
|
|
1308
|
-
var ValidationError = class extends ActionError {
|
|
1309
|
-
fieldErrors;
|
|
1310
|
-
constructor(message, validOptions, suggestedAction, conflictingValue, fieldErrors) {
|
|
1311
|
-
super({
|
|
1312
|
-
code: "VALIDATION_ERROR",
|
|
1313
|
-
message,
|
|
1314
|
-
operation: { type: "create", name: "", params: {} },
|
|
1315
|
-
// Will be filled by wrapper
|
|
1316
|
-
context: { itemType: "" },
|
|
1317
|
-
// Will be filled by wrapper
|
|
1318
|
-
details: {
|
|
1319
|
-
validOptions,
|
|
1320
|
-
suggestedAction,
|
|
1321
|
-
retryable: true,
|
|
1322
|
-
conflictingValue,
|
|
1323
|
-
fieldErrors
|
|
1324
|
-
},
|
|
1325
|
-
technical: {
|
|
1326
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1327
|
-
}
|
|
1328
|
-
});
|
|
1329
|
-
this.fieldErrors = fieldErrors;
|
|
1330
|
-
if (fieldErrors) {
|
|
1331
|
-
if (!this.errorInfo.details) this.errorInfo.details = {};
|
|
1332
|
-
this.errorInfo.details.fieldErrors = fieldErrors;
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
};
|
|
1336
|
-
|
|
1337
|
-
// src/errors/NotFoundError.ts
|
|
1338
|
-
var NotFoundError = class extends ActionError {
|
|
1339
|
-
constructor(message, itemType, key) {
|
|
1340
|
-
super({
|
|
1341
|
-
code: "NOT_FOUND",
|
|
1342
|
-
message,
|
|
1343
|
-
operation: { type: "get", name: "", params: {} },
|
|
1344
|
-
context: {
|
|
1345
|
-
itemType,
|
|
1346
|
-
key: typeof key === "object" ? key : { primary: key }
|
|
1347
|
-
},
|
|
1348
|
-
details: { retryable: false },
|
|
1349
|
-
technical: {
|
|
1350
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1351
|
-
}
|
|
1352
|
-
});
|
|
1353
|
-
this.name = "NotFoundError";
|
|
1354
|
-
}
|
|
1355
|
-
};
|
|
1356
|
-
|
|
1357
|
-
// src/errors/BusinessLogicError.ts
|
|
1358
|
-
var BusinessLogicError = class extends ActionError {
|
|
1359
|
-
constructor(message, suggestedAction, retryable = false) {
|
|
1360
|
-
super({
|
|
1361
|
-
code: "BUSINESS_LOGIC_ERROR",
|
|
1362
|
-
message,
|
|
1363
|
-
operation: { type: "action", name: "", params: {} },
|
|
1364
|
-
context: { itemType: "" },
|
|
1365
|
-
details: {
|
|
1366
|
-
suggestedAction,
|
|
1367
|
-
retryable
|
|
1368
|
-
},
|
|
1369
|
-
technical: {
|
|
1370
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1371
|
-
}
|
|
1372
|
-
});
|
|
1373
|
-
}
|
|
1374
|
-
};
|
|
1375
|
-
|
|
1376
|
-
// src/errors/PermissionError.ts
|
|
1377
|
-
var PermissionError = class extends ActionError {
|
|
1378
|
-
constructor(message, requiredPermission, currentPermissions) {
|
|
1379
|
-
super({
|
|
1380
|
-
code: "PERMISSION_DENIED",
|
|
1381
|
-
message,
|
|
1382
|
-
operation: { type: "action", name: "", params: {} },
|
|
1383
|
-
context: {
|
|
1384
|
-
itemType: "",
|
|
1385
|
-
...requiredPermission && { requiredPermission }
|
|
1386
|
-
},
|
|
1387
|
-
details: {
|
|
1388
|
-
...requiredPermission && {
|
|
1389
|
-
suggestedAction: `Required permission: ${requiredPermission}`,
|
|
1390
|
-
expectedValue: requiredPermission
|
|
1391
|
-
},
|
|
1392
|
-
...currentPermissions && { conflictingValue: currentPermissions },
|
|
1393
|
-
retryable: false
|
|
1394
|
-
},
|
|
1395
|
-
technical: {
|
|
1396
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1397
|
-
}
|
|
1398
|
-
});
|
|
1399
|
-
}
|
|
1400
|
-
};
|
|
1401
|
-
|
|
1402
|
-
// src/errors/DuplicateError.ts
|
|
1403
|
-
var DuplicateError = class extends ActionError {
|
|
1404
|
-
constructor(message, existingItemIdOrKey, duplicateField) {
|
|
1405
|
-
let existingItemId = null;
|
|
1406
|
-
let keyInfo = null;
|
|
1407
|
-
if (typeof existingItemIdOrKey === "object" && existingItemIdOrKey !== null) {
|
|
1408
|
-
existingItemId = existingItemIdOrKey.pk || existingItemIdOrKey.id || existingItemIdOrKey.primary || null;
|
|
1409
|
-
if (existingItemId !== null) {
|
|
1410
|
-
keyInfo = {
|
|
1411
|
-
primary: existingItemId,
|
|
1412
|
-
...existingItemIdOrKey
|
|
1413
|
-
};
|
|
1414
|
-
} else {
|
|
1415
|
-
keyInfo = existingItemIdOrKey;
|
|
1416
|
-
}
|
|
1417
|
-
} else if (typeof existingItemIdOrKey !== "undefined") {
|
|
1418
|
-
existingItemId = existingItemIdOrKey;
|
|
1419
|
-
keyInfo = { primary: existingItemId };
|
|
1420
|
-
}
|
|
1421
|
-
super({
|
|
1422
|
-
code: "DUPLICATE_ERROR",
|
|
1423
|
-
message,
|
|
1424
|
-
operation: { type: "create", name: "", params: {} },
|
|
1425
|
-
context: {
|
|
1426
|
-
itemType: "",
|
|
1427
|
-
...keyInfo && { key: keyInfo },
|
|
1428
|
-
...existingItemId && {
|
|
1429
|
-
affectedItems: [{
|
|
1430
|
-
id: existingItemId,
|
|
1431
|
-
type: "",
|
|
1432
|
-
displayName: `Existing item with ${duplicateField || "key"}`
|
|
1433
|
-
}]
|
|
1434
|
-
}
|
|
1435
|
-
},
|
|
1436
|
-
details: {
|
|
1437
|
-
retryable: false,
|
|
1438
|
-
conflictingValue: duplicateField
|
|
1439
|
-
},
|
|
1440
|
-
technical: {
|
|
1441
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1442
|
-
}
|
|
1443
|
-
});
|
|
1444
|
-
}
|
|
1445
|
-
};
|
|
1446
|
-
|
|
1447
|
-
// src/validation/schema.ts
|
|
1448
|
-
async function validateSchema(data, schema) {
|
|
1449
|
-
if (!schema) {
|
|
1450
|
-
return data;
|
|
1451
|
-
}
|
|
1452
|
-
try {
|
|
1453
|
-
if (schema.parseAsync) {
|
|
1454
|
-
return await schema.parseAsync(data);
|
|
1455
|
-
}
|
|
1456
|
-
const result = schema.safeParse(data);
|
|
1457
|
-
if (result.success) {
|
|
1458
|
-
return result.data;
|
|
1459
|
-
} else {
|
|
1460
|
-
throw result.error;
|
|
1461
|
-
}
|
|
1462
|
-
} catch (error) {
|
|
1463
|
-
if (error && Array.isArray(error.issues)) {
|
|
1464
|
-
const fieldErrors = error.issues.map((issue) => ({
|
|
1465
|
-
path: issue.path,
|
|
1466
|
-
message: issue.message,
|
|
1467
|
-
code: issue.code
|
|
1468
|
-
}));
|
|
1469
|
-
const validationError = new ValidationError(
|
|
1470
|
-
"Schema validation failed",
|
|
1471
|
-
// eslint-disable-next-line no-undefined
|
|
1472
|
-
void 0,
|
|
1473
|
-
// eslint-disable-next-line no-undefined
|
|
1474
|
-
void 0,
|
|
1475
|
-
// eslint-disable-next-line no-undefined
|
|
1476
|
-
void 0,
|
|
1477
|
-
fieldErrors
|
|
1478
|
-
);
|
|
1479
|
-
throw validationError;
|
|
1480
|
-
}
|
|
1481
|
-
if (error instanceof ValidationError) {
|
|
1482
|
-
throw error;
|
|
1483
|
-
}
|
|
1484
|
-
throw new ValidationError(`Validation failed: ${error.message || "Unknown error"}`);
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
// src/operations/errorEnhancer.ts
|
|
1489
|
-
async function executeWithContext(operation, context) {
|
|
1490
|
-
try {
|
|
1491
|
-
return await operation();
|
|
1492
|
-
} catch (error) {
|
|
1493
|
-
throw enhanceError(error, context);
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
function executeWithContextSync(operation, context) {
|
|
1497
|
-
try {
|
|
1498
|
-
return operation();
|
|
1499
|
-
} catch (error) {
|
|
1500
|
-
throw enhanceError(error, context);
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
function enhanceError(error, context) {
|
|
1504
|
-
if (!(error instanceof ActionError)) {
|
|
1505
|
-
return error;
|
|
1506
|
-
}
|
|
1507
|
-
error.errorInfo.operation = {
|
|
1508
|
-
type: context.operationType,
|
|
1509
|
-
name: context.operationName,
|
|
1510
|
-
params: context.params
|
|
1511
|
-
};
|
|
1512
|
-
if (!error.errorInfo.context.itemType) {
|
|
1513
|
-
error.errorInfo.context.itemType = context.itemType;
|
|
1514
|
-
}
|
|
1515
|
-
if (context.key) {
|
|
1516
|
-
const existingKey = error.errorInfo.context.key;
|
|
1517
|
-
const hasNoPrimaryKey = !existingKey || typeof existingKey.primary === "undefined";
|
|
1518
|
-
const hasNoCompositeKey = !existingKey || !existingKey.composite;
|
|
1519
|
-
const shouldOverride = hasNoPrimaryKey && hasNoCompositeKey;
|
|
1520
|
-
if (shouldOverride) {
|
|
1521
|
-
error.errorInfo.context.key = extractKeyInfo(context.key);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
if (context.locations && context.locations.length > 0 && !error.errorInfo.context.parentLocation) {
|
|
1525
|
-
error.errorInfo.context.parentLocation = {
|
|
1526
|
-
id: context.locations[0].lk,
|
|
1527
|
-
type: context.locations[0].kt
|
|
1528
|
-
};
|
|
1529
|
-
}
|
|
1530
|
-
return error;
|
|
1531
|
-
}
|
|
1532
|
-
function extractKeyInfo(key) {
|
|
1533
|
-
if ("loc" in key) {
|
|
1534
|
-
const ktaArray = Array.isArray(key.kt) ? key.kt : [key.kt];
|
|
1535
|
-
const locations = Array.isArray(key.loc) ? key.loc : [];
|
|
1536
|
-
return {
|
|
1537
|
-
composite: {
|
|
1538
|
-
sk: key.pk,
|
|
1539
|
-
kta: ktaArray,
|
|
1540
|
-
locations: locations.map((loc) => ({
|
|
1541
|
-
lk: loc.lk,
|
|
1542
|
-
kt: loc.kt
|
|
1543
|
-
}))
|
|
1544
|
-
}
|
|
1545
|
-
};
|
|
1546
|
-
} else if ("pk" in key) {
|
|
1547
|
-
return { primary: key.pk };
|
|
1548
|
-
}
|
|
1549
|
-
return { primary: JSON.stringify(key) };
|
|
1550
|
-
}
|
|
1551
|
-
function isActionError(error) {
|
|
1552
|
-
return error instanceof ActionError;
|
|
1553
|
-
}
|
|
1554
|
-
function getErrorInfo(error) {
|
|
1555
|
-
if (isActionError(error)) {
|
|
1556
|
-
return error.toJSON();
|
|
1557
|
-
}
|
|
1558
|
-
if (error instanceof Error) {
|
|
1559
|
-
return {
|
|
1560
|
-
code: "UNKNOWN_ERROR",
|
|
1561
|
-
message: error.message,
|
|
1562
|
-
technical: {
|
|
1563
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1564
|
-
stackTrace: error.stack
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1568
|
-
return {
|
|
1569
|
-
code: "UNKNOWN_ERROR",
|
|
1570
|
-
message: String(error),
|
|
1571
|
-
technical: {
|
|
1572
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1573
|
-
}
|
|
1574
|
-
};
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
// src/event/events.ts
|
|
1578
|
-
function isCreateEvent(event) {
|
|
1579
|
-
return event.eventType === "create";
|
|
1580
|
-
}
|
|
1581
|
-
function isUpdateEvent(event) {
|
|
1582
|
-
return event.eventType === "update";
|
|
1583
|
-
}
|
|
1584
|
-
function isDeleteEvent(event) {
|
|
1585
|
-
return event.eventType === "delete";
|
|
1586
|
-
}
|
|
1587
|
-
function isActionEvent(event) {
|
|
1588
|
-
return event.eventType === "action";
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
// src/event/subscription.ts
|
|
1592
|
-
function isItemSubscription(subscription) {
|
|
1593
|
-
return "key" in subscription;
|
|
1594
|
-
}
|
|
1595
|
-
function isLocationSubscription(subscription) {
|
|
1596
|
-
return "kta" in subscription && "location" in subscription;
|
|
1597
|
-
}
|
|
1598
|
-
function generateSubscriptionId() {
|
|
1599
|
-
return `sub-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1600
|
-
}
|
|
1601
|
-
function createItemSubscription(key, options) {
|
|
1602
|
-
return {
|
|
1603
|
-
id: generateSubscriptionId(),
|
|
1604
|
-
key,
|
|
1605
|
-
eventTypes: options?.eventTypes,
|
|
1606
|
-
scopes: options?.scopes,
|
|
1607
|
-
query: options?.query
|
|
1608
|
-
};
|
|
1609
|
-
}
|
|
1610
|
-
function createLocationSubscription(kta, location, options) {
|
|
1611
|
-
return {
|
|
1612
|
-
id: generateSubscriptionId(),
|
|
1613
|
-
kta,
|
|
1614
|
-
location,
|
|
1615
|
-
eventTypes: options?.eventTypes,
|
|
1616
|
-
scopes: options?.scopes,
|
|
1617
|
-
query: options?.query
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
// src/operations/Operations.ts
|
|
1622
|
-
function isPriKey2(key) {
|
|
1623
|
-
return !("loc" in key) || !key.loc;
|
|
1624
|
-
}
|
|
1625
|
-
function isComKey2(key) {
|
|
1626
|
-
return "loc" in key && key.loc && Array.isArray(key.loc) && key.loc.length > 0;
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
// src/event/matching.ts
|
|
1630
|
-
function doesEventMatchSubscription(event, subscription) {
|
|
1631
|
-
if (!doesScopeMatch(event.scopes, subscription.scopes)) {
|
|
1632
|
-
return false;
|
|
1633
|
-
}
|
|
1634
|
-
if (!doesEventTypeMatch(event.eventType, subscription.eventTypes)) {
|
|
1635
|
-
return false;
|
|
1636
|
-
}
|
|
1637
|
-
if (isItemSubscription(subscription)) {
|
|
1638
|
-
return doesKeyMatch(event.key, subscription.key);
|
|
1639
|
-
} else if (isLocationSubscription(subscription)) {
|
|
1640
|
-
return doesKeyMatchLocation(event.key, subscription.kta, subscription.location);
|
|
1641
|
-
}
|
|
1642
|
-
return false;
|
|
1643
|
-
}
|
|
1644
|
-
function doesScopeMatch(eventScopes, subscriptionScopes) {
|
|
1645
|
-
if (!subscriptionScopes || subscriptionScopes.length === 0) {
|
|
1646
|
-
return true;
|
|
1647
|
-
}
|
|
1648
|
-
return subscriptionScopes.some(
|
|
1649
|
-
(requiredScope) => eventScopes.includes(requiredScope)
|
|
1650
|
-
);
|
|
1651
|
-
}
|
|
1652
|
-
function doesEventTypeMatch(eventType, subscriptionEventTypes) {
|
|
1653
|
-
if (!subscriptionEventTypes || subscriptionEventTypes.length === 0) {
|
|
1654
|
-
return true;
|
|
1655
|
-
}
|
|
1656
|
-
return subscriptionEventTypes.includes(eventType);
|
|
1657
|
-
}
|
|
1658
|
-
function doesKeyMatch(eventKey, subscriptionKey) {
|
|
1659
|
-
if (isPriKey2(eventKey) && isPriKey2(subscriptionKey)) {
|
|
1660
|
-
return eventKey.pk === subscriptionKey.pk && eventKey.kt === subscriptionKey.kt;
|
|
1661
|
-
}
|
|
1662
|
-
if (isComKey2(eventKey) && isComKey2(subscriptionKey)) {
|
|
1663
|
-
const eventComKey = eventKey;
|
|
1664
|
-
const subscriptionComKey = subscriptionKey;
|
|
1665
|
-
if (eventComKey.pk !== subscriptionComKey.pk || eventComKey.kt !== subscriptionComKey.kt) {
|
|
1666
|
-
return false;
|
|
1667
|
-
}
|
|
1668
|
-
if (eventComKey.loc.length !== subscriptionComKey.loc.length) {
|
|
1669
|
-
return false;
|
|
1670
|
-
}
|
|
1671
|
-
return eventComKey.loc.every((eventLocKey, index) => {
|
|
1672
|
-
const subLocKey = subscriptionComKey.loc[index];
|
|
1673
|
-
return eventLocKey.lk === subLocKey.lk && eventLocKey.kt === subLocKey.kt;
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
return false;
|
|
1677
|
-
}
|
|
1678
|
-
function doesKeyMatchLocation(eventKey, subscriptionKta, subscriptionLocation) {
|
|
1679
|
-
const targetItemType = subscriptionKta[subscriptionKta.length - 1];
|
|
1680
|
-
if (eventKey.kt !== targetItemType) {
|
|
1681
|
-
return false;
|
|
1682
|
-
}
|
|
1683
|
-
if (isPriKey2(eventKey)) {
|
|
1684
|
-
return subscriptionLocation.length === 0;
|
|
1685
|
-
}
|
|
1686
|
-
if (isComKey2(eventKey)) {
|
|
1687
|
-
const comKey = eventKey;
|
|
1688
|
-
return doesLocationMatch(comKey.loc, subscriptionLocation, subscriptionKta);
|
|
1689
|
-
}
|
|
1690
|
-
return false;
|
|
1691
|
-
}
|
|
1692
|
-
function doesLocationMatch(eventLocation, subscriptionLocation, _subscriptionKta) {
|
|
1693
|
-
if (subscriptionLocation.length === 0) {
|
|
1694
|
-
return true;
|
|
1695
|
-
}
|
|
1696
|
-
if (eventLocation.length < subscriptionLocation.length) {
|
|
1697
|
-
return false;
|
|
1698
|
-
}
|
|
1699
|
-
for (let i = 0; i < subscriptionLocation.length; i++) {
|
|
1700
|
-
const eventLocKey = eventLocation[i];
|
|
1701
|
-
const subLocKey = subscriptionLocation[i];
|
|
1702
|
-
if (!eventLocKey || !subLocKey) {
|
|
1703
|
-
return false;
|
|
1704
|
-
}
|
|
1705
|
-
if (eventLocKey.lk !== subLocKey.lk || eventLocKey.kt !== subLocKey.kt) {
|
|
1706
|
-
return false;
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
return true;
|
|
1710
|
-
}
|
|
1711
|
-
function findMatchingSubscriptions(event, subscriptions) {
|
|
1712
|
-
return subscriptions.filter(
|
|
1713
|
-
(subscription) => doesEventMatchSubscription(event, subscription)
|
|
1714
|
-
);
|
|
1715
|
-
}
|
|
1716
|
-
function extractLocationValues(location) {
|
|
1717
|
-
return location.map((locKey) => String(locKey.lk));
|
|
1718
|
-
}
|
|
1719
|
-
function compareLocationValues(location1, location2) {
|
|
1720
|
-
if (location1.length !== location2.length) {
|
|
1721
|
-
return false;
|
|
1722
|
-
}
|
|
1723
|
-
return location1.every((locKey1, index) => {
|
|
1724
|
-
const locKey2 = location2[index];
|
|
1725
|
-
return locKey1.lk === locKey2.lk && locKey1.kt === locKey2.kt;
|
|
1726
|
-
});
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
// src/event/types.ts
|
|
1730
|
-
var STANDARD_EVENT_TYPES = {
|
|
1731
|
-
CREATE: "create",
|
|
1732
|
-
UPDATE: "update",
|
|
1733
|
-
DELETE: "delete",
|
|
1734
|
-
ACTION: "action"
|
|
1735
|
-
};
|
|
1736
|
-
var STANDARD_SCOPES = {
|
|
1737
|
-
FIRESTORE: "firestore",
|
|
1738
|
-
SEQUELIZE: "sequelize",
|
|
1739
|
-
POSTGRESQL: "postgresql",
|
|
1740
|
-
MYSQL: "mysql",
|
|
1741
|
-
MONGODB: "mongodb",
|
|
1742
|
-
REDIS: "redis"
|
|
1743
|
-
};
|
|
1744
|
-
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
1745
|
-
SubscriptionStatus2["PENDING"] = "pending";
|
|
1746
|
-
SubscriptionStatus2["ACTIVE"] = "active";
|
|
1747
|
-
SubscriptionStatus2["PAUSED"] = "paused";
|
|
1748
|
-
SubscriptionStatus2["ERROR"] = "error";
|
|
1749
|
-
SubscriptionStatus2["CANCELLED"] = "cancelled";
|
|
1750
|
-
return SubscriptionStatus2;
|
|
1751
|
-
})(SubscriptionStatus || {});
|
|
1752
|
-
var DEFAULT_EVENT_CONFIG = {
|
|
1753
|
-
maxBatchSize: 100,
|
|
1754
|
-
maxBatchWaitTime: 50,
|
|
1755
|
-
// 50ms
|
|
1756
|
-
maxRetryAttempts: 3,
|
|
1757
|
-
retryDelay: 1e3,
|
|
1758
|
-
// 1 second
|
|
1759
|
-
enableStats: true,
|
|
1760
|
-
maxSubscriptions: 1e3,
|
|
1761
|
-
subscriptionCleanupInterval: 3e5
|
|
1762
|
-
// 5 minutes
|
|
1763
|
-
};
|
|
1764
|
-
var EventSystemError = class extends Error {
|
|
1765
|
-
constructor(message, code, details) {
|
|
1766
|
-
super(message);
|
|
1767
|
-
this.code = code;
|
|
1768
|
-
this.details = details;
|
|
1769
|
-
this.name = "EventSystemError";
|
|
1770
|
-
}
|
|
1771
|
-
};
|
|
1772
|
-
var SubscriptionError = class extends EventSystemError {
|
|
1773
|
-
constructor(message, subscriptionId, details) {
|
|
1774
|
-
super(message, "SUBSCRIPTION_ERROR", { subscriptionId, ...details });
|
|
1775
|
-
this.subscriptionId = subscriptionId;
|
|
1776
|
-
this.name = "SubscriptionError";
|
|
1777
|
-
}
|
|
1778
|
-
};
|
|
1779
|
-
var EventEmissionError = class extends EventSystemError {
|
|
1780
|
-
constructor(message, eventType, details) {
|
|
1781
|
-
super(message, "EVENT_EMISSION_ERROR", { eventType, ...details });
|
|
1782
|
-
this.eventType = eventType;
|
|
1783
|
-
this.name = "EventEmissionError";
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
1786
|
-
var EventMatchingError = class extends EventSystemError {
|
|
1787
|
-
constructor(message, details) {
|
|
1788
|
-
super(message, "EVENT_MATCHING_ERROR", details);
|
|
1789
|
-
this.name = "EventMatchingError";
|
|
1790
|
-
}
|
|
1791
|
-
};
|
|
1792
|
-
function createEventSystemError(type, message, details) {
|
|
1793
|
-
switch (type) {
|
|
1794
|
-
case "subscription":
|
|
1795
|
-
return new SubscriptionError(message, details?.subscriptionId || "unknown", details);
|
|
1796
|
-
case "emission":
|
|
1797
|
-
return new EventEmissionError(message, details?.eventType || "unknown", details);
|
|
1798
|
-
case "matching":
|
|
1799
|
-
return new EventMatchingError(message, details);
|
|
1800
|
-
case "general":
|
|
1801
|
-
default:
|
|
1802
|
-
return new EventSystemError(message, "GENERAL_ERROR", details);
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
function isEventSystemError(error) {
|
|
1806
|
-
return error instanceof EventSystemError;
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
// src/event/index.ts
|
|
1810
|
-
var EVENT_SYSTEM_VERSION = "1.0.0";
|
|
1811
|
-
var SUPPORTED_EVENT_TYPES = [
|
|
1812
|
-
"create",
|
|
1813
|
-
"update",
|
|
1814
|
-
"delete",
|
|
1815
|
-
"action"
|
|
1816
|
-
];
|
|
1817
|
-
var SUPPORTED_SCOPES = [
|
|
1818
|
-
"firestore",
|
|
1819
|
-
"sequelize",
|
|
1820
|
-
"postgresql",
|
|
1821
|
-
"mysql",
|
|
1822
|
-
"mongodb",
|
|
1823
|
-
"redis"
|
|
1824
|
-
];
|
|
1825
|
-
|
|
1491
|
+
Received: ${JSON.stringify(facet)}`
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
if (facet.trim().length === 0) {
|
|
1495
|
+
logger42.error(`Empty facet name for ${operation}`, { facet });
|
|
1496
|
+
throw new Error(
|
|
1497
|
+
`[${operation}] Facet name cannot be empty or whitespace only.
|
|
1498
|
+
|
|
1499
|
+
Received: "${facet}"`
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
logger42.debug(`Facet name validation passed for ${operation}`, { facet });
|
|
1503
|
+
};
|
|
1504
|
+
|
|
1826
1505
|
// src/operations/wrappers/createOneWrapper.ts
|
|
1827
|
-
var
|
|
1506
|
+
var logger6 = logger_default.get("operations", "wrappers", "one");
|
|
1828
1507
|
function createOneWrapper(coordinate, implementation, options = {}) {
|
|
1829
1508
|
const operationName = options.operationName || "one";
|
|
1830
1509
|
return async (query, locations) => {
|
|
1831
1510
|
if (options.debug) {
|
|
1832
|
-
|
|
1511
|
+
logger6.debug(`[${operationName}] Called with:`, { query, locations });
|
|
1833
1512
|
}
|
|
1834
1513
|
if (!options.skipValidation) {
|
|
1835
1514
|
try {
|
|
@@ -1844,7 +1523,7 @@ function createOneWrapper(coordinate, implementation, options = {}) {
|
|
|
1844
1523
|
try {
|
|
1845
1524
|
const result = await implementation(normalizedQuery, normalizedLocations);
|
|
1846
1525
|
if (options.debug) {
|
|
1847
|
-
|
|
1526
|
+
logger6.debug(`[${operationName}] Result:`, result ? "found" : "not found");
|
|
1848
1527
|
}
|
|
1849
1528
|
if (result && !options.skipValidation) {
|
|
1850
1529
|
return validatePK(result, coordinate.kta[0]);
|
|
@@ -1872,19 +1551,29 @@ function createOneWrapper(coordinate, implementation, options = {}) {
|
|
|
1872
1551
|
}
|
|
1873
1552
|
|
|
1874
1553
|
// src/operations/wrappers/createAllWrapper.ts
|
|
1875
|
-
var
|
|
1554
|
+
var logger7 = logger_default.get("operations", "wrappers", "all");
|
|
1876
1555
|
function createAllWrapper(coordinate, implementation, wrapperOptions = {}) {
|
|
1877
1556
|
const operationName = wrapperOptions.operationName || "all";
|
|
1878
1557
|
return async (query, locations, allOptions) => {
|
|
1879
1558
|
if (wrapperOptions.debug) {
|
|
1880
|
-
|
|
1559
|
+
logger7.debug(`[${operationName}] Called with:`, { query, locations, allOptions });
|
|
1881
1560
|
}
|
|
1882
1561
|
if (!wrapperOptions.skipValidation) {
|
|
1883
1562
|
validateQuery(query, operationName);
|
|
1884
1563
|
validateLocations(locations, coordinate, operationName);
|
|
1885
1564
|
if (allOptions && "limit" in allOptions && allOptions.limit != null) {
|
|
1886
1565
|
if (!Number.isInteger(allOptions.limit) || allOptions.limit < 1) {
|
|
1887
|
-
|
|
1566
|
+
logger7.error(`Invalid limit parameter in ${operationName}`, {
|
|
1567
|
+
component: "core",
|
|
1568
|
+
wrapper: "createAllWrapper",
|
|
1569
|
+
operation: operationName,
|
|
1570
|
+
limit: allOptions.limit,
|
|
1571
|
+
limitType: typeof allOptions.limit,
|
|
1572
|
+
suggestion: "Use a positive integer (1, 2, 3, ...) for limit parameter"
|
|
1573
|
+
});
|
|
1574
|
+
throw new Error(
|
|
1575
|
+
`[${operationName}] limit must be a positive integer, got: ${allOptions.limit} (${typeof allOptions.limit}). Suggestion: Use limit: 10 or similar positive integer value.`
|
|
1576
|
+
);
|
|
1888
1577
|
}
|
|
1889
1578
|
}
|
|
1890
1579
|
if (allOptions && "offset" in allOptions && allOptions.offset != null) {
|
|
@@ -1898,7 +1587,7 @@ function createAllWrapper(coordinate, implementation, wrapperOptions = {}) {
|
|
|
1898
1587
|
try {
|
|
1899
1588
|
const result = await implementation(normalizedQuery, normalizedLocations, allOptions);
|
|
1900
1589
|
if (wrapperOptions.debug) {
|
|
1901
|
-
|
|
1590
|
+
logger7.debug(`[${operationName}] Result: ${result.items.length} items, total: ${result.metadata.total}`);
|
|
1902
1591
|
}
|
|
1903
1592
|
if (!wrapperOptions.skipValidation) {
|
|
1904
1593
|
const validatedItems = validatePK(result.items, coordinate.kta[0]);
|
|
@@ -1926,12 +1615,12 @@ function createAllWrapper(coordinate, implementation, wrapperOptions = {}) {
|
|
|
1926
1615
|
}
|
|
1927
1616
|
|
|
1928
1617
|
// src/operations/wrappers/createGetWrapper.ts
|
|
1929
|
-
var
|
|
1618
|
+
var logger8 = logger_default.get("operations", "wrappers", "get");
|
|
1930
1619
|
function createGetWrapper(coordinate, implementation, options = {}) {
|
|
1931
1620
|
const operationName = options.operationName || "get";
|
|
1932
1621
|
return async (key) => {
|
|
1933
1622
|
if (options.debug) {
|
|
1934
|
-
|
|
1623
|
+
logger8.debug(`[${operationName}] Called with key:`, key);
|
|
1935
1624
|
}
|
|
1936
1625
|
if (!options.skipValidation) {
|
|
1937
1626
|
validateKey(key, coordinate, operationName);
|
|
@@ -1939,7 +1628,7 @@ function createGetWrapper(coordinate, implementation, options = {}) {
|
|
|
1939
1628
|
try {
|
|
1940
1629
|
const result = await implementation(key);
|
|
1941
1630
|
if (options.debug) {
|
|
1942
|
-
|
|
1631
|
+
logger8.debug(`[${operationName}] Result:`, result ? "found" : "not found");
|
|
1943
1632
|
}
|
|
1944
1633
|
if (result && !options.skipValidation) {
|
|
1945
1634
|
return validatePK(result, coordinate.kta[0]);
|
|
@@ -1955,8 +1644,27 @@ function createGetWrapper(coordinate, implementation, options = {}) {
|
|
|
1955
1644
|
throw options.onError(error, context);
|
|
1956
1645
|
}
|
|
1957
1646
|
if (error instanceof NotFoundError) {
|
|
1647
|
+
logger8.debug(`[${operationName}] Item not found`, {
|
|
1648
|
+
component: "core",
|
|
1649
|
+
wrapper: "createGetWrapper",
|
|
1650
|
+
operation: operationName,
|
|
1651
|
+
key: JSON.stringify(key),
|
|
1652
|
+
itemType: coordinate.kta[0],
|
|
1653
|
+
note: "This is expected behavior when item does not exist"
|
|
1654
|
+
});
|
|
1958
1655
|
throw error;
|
|
1959
1656
|
}
|
|
1657
|
+
logger8.error(`[${operationName}] Operation failed in wrapper`, {
|
|
1658
|
+
component: "core",
|
|
1659
|
+
wrapper: "createGetWrapper",
|
|
1660
|
+
operation: operationName,
|
|
1661
|
+
key: JSON.stringify(key),
|
|
1662
|
+
itemType: coordinate.kta[0],
|
|
1663
|
+
errorType: error.constructor?.name,
|
|
1664
|
+
errorMessage: error.message,
|
|
1665
|
+
suggestion: "Check key validity, database connectivity, and implementation error handling",
|
|
1666
|
+
coordinate: JSON.stringify(coordinate)
|
|
1667
|
+
});
|
|
1960
1668
|
throw new Error(
|
|
1961
1669
|
`[${operationName}] Operation failed: ${error.message}`,
|
|
1962
1670
|
{ cause: error }
|
|
@@ -1966,12 +1674,12 @@ function createGetWrapper(coordinate, implementation, options = {}) {
|
|
|
1966
1674
|
}
|
|
1967
1675
|
|
|
1968
1676
|
// src/operations/wrappers/createCreateWrapper.ts
|
|
1969
|
-
var
|
|
1677
|
+
var logger9 = logger_default.get("operations", "wrappers", "create");
|
|
1970
1678
|
function createCreateWrapper(coordinate, implementation, wrapperOptions = {}) {
|
|
1971
1679
|
const operationName = wrapperOptions.operationName || "create";
|
|
1972
1680
|
return async (item, createOptions) => {
|
|
1973
1681
|
if (wrapperOptions.debug) {
|
|
1974
|
-
|
|
1682
|
+
logger9.debug(`[${operationName}] Called with:`, { item, options: createOptions });
|
|
1975
1683
|
}
|
|
1976
1684
|
if (!wrapperOptions.skipValidation) {
|
|
1977
1685
|
if (!item || typeof item !== "object" || Array.isArray(item)) {
|
|
@@ -1994,7 +1702,7 @@ Received: ${Array.isArray(item) ? "array" : typeof item}`
|
|
|
1994
1702
|
try {
|
|
1995
1703
|
const result = await implementation(item, createOptions);
|
|
1996
1704
|
if (wrapperOptions.debug) {
|
|
1997
|
-
|
|
1705
|
+
logger9.debug(`[${operationName}] Created item:`, result.key);
|
|
1998
1706
|
}
|
|
1999
1707
|
if (!wrapperOptions.skipValidation) {
|
|
2000
1708
|
return validatePK(result, coordinate.kta[0]);
|
|
@@ -2009,6 +1717,18 @@ Received: ${Array.isArray(item) ? "array" : typeof item}`
|
|
|
2009
1717
|
};
|
|
2010
1718
|
throw wrapperOptions.onError(error, context);
|
|
2011
1719
|
}
|
|
1720
|
+
logger9.error(`[${operationName}] Operation failed in wrapper`, {
|
|
1721
|
+
component: "core",
|
|
1722
|
+
wrapper: "createCreateWrapper",
|
|
1723
|
+
operation: operationName,
|
|
1724
|
+
itemType: coordinate.kta[0],
|
|
1725
|
+
hasKey: createOptions && "key" in createOptions,
|
|
1726
|
+
hasLocations: createOptions && "locations" in createOptions,
|
|
1727
|
+
errorType: error.constructor?.name,
|
|
1728
|
+
errorMessage: error.message,
|
|
1729
|
+
suggestion: "Check validation rules, required fields, unique constraints, and database connectivity",
|
|
1730
|
+
coordinate: JSON.stringify(coordinate)
|
|
1731
|
+
});
|
|
2012
1732
|
throw new Error(
|
|
2013
1733
|
`[${operationName}] Operation failed: ${error.message}`,
|
|
2014
1734
|
{ cause: error }
|
|
@@ -2018,12 +1738,12 @@ Received: ${Array.isArray(item) ? "array" : typeof item}`
|
|
|
2018
1738
|
}
|
|
2019
1739
|
|
|
2020
1740
|
// src/operations/wrappers/createUpdateWrapper.ts
|
|
2021
|
-
var
|
|
1741
|
+
var logger10 = logger_default.get("operations", "wrappers", "update");
|
|
2022
1742
|
function createUpdateWrapper(coordinate, implementation, options = {}) {
|
|
2023
1743
|
const operationName = options.operationName || "update";
|
|
2024
1744
|
return async (key, item, updateOptions) => {
|
|
2025
1745
|
if (options.debug) {
|
|
2026
|
-
|
|
1746
|
+
logger10.debug(`[${operationName}] Called with:`, { key, item, updateOptions });
|
|
2027
1747
|
}
|
|
2028
1748
|
if (!options.skipValidation) {
|
|
2029
1749
|
validateKey(key, coordinate, operationName);
|
|
@@ -2039,7 +1759,7 @@ Received: ${Array.isArray(item) ? "array" : typeof item}`
|
|
|
2039
1759
|
try {
|
|
2040
1760
|
const result = await implementation(key, item, updateOptions);
|
|
2041
1761
|
if (options.debug) {
|
|
2042
|
-
|
|
1762
|
+
logger10.debug(`[${operationName}] Updated item:`, result.key);
|
|
2043
1763
|
}
|
|
2044
1764
|
if (!options.skipValidation) {
|
|
2045
1765
|
return validatePK(result, coordinate.kta[0]);
|
|
@@ -2063,15 +1783,18 @@ Received: ${Array.isArray(item) ? "array" : typeof item}`
|
|
|
2063
1783
|
}
|
|
2064
1784
|
|
|
2065
1785
|
// src/operations/wrappers/createUpsertWrapper.ts
|
|
2066
|
-
var
|
|
1786
|
+
var logger11 = logger_default.get("operations", "wrappers", "upsert");
|
|
2067
1787
|
function createUpsertWrapper(coordinate, implementation, options = {}) {
|
|
2068
1788
|
const operationName = options.operationName || "upsert";
|
|
2069
1789
|
return async (key, item, locations, updateOptions) => {
|
|
2070
1790
|
if (options.debug) {
|
|
2071
|
-
|
|
1791
|
+
logger11.debug(`[${operationName}] Called with:`, { key, item, locations, updateOptions });
|
|
2072
1792
|
}
|
|
2073
1793
|
if (!options.skipValidation) {
|
|
2074
1794
|
validateKey(key, coordinate, operationName);
|
|
1795
|
+
if (locations) {
|
|
1796
|
+
validateLocations(locations, coordinate, operationName);
|
|
1797
|
+
}
|
|
2075
1798
|
if (!item || typeof item !== "object" || Array.isArray(item)) {
|
|
2076
1799
|
throw new Error(
|
|
2077
1800
|
`[${operationName}] Invalid item parameter.
|
|
@@ -2084,7 +1807,7 @@ Received: ${Array.isArray(item) ? "array" : typeof item}`
|
|
|
2084
1807
|
try {
|
|
2085
1808
|
const result = await implementation(key, item, locations, updateOptions);
|
|
2086
1809
|
if (options.debug) {
|
|
2087
|
-
|
|
1810
|
+
logger11.debug(`[${operationName}] Upserted item:`, result.key);
|
|
2088
1811
|
}
|
|
2089
1812
|
if (!options.skipValidation) {
|
|
2090
1813
|
return validatePK(result, coordinate.kta[0]);
|
|
@@ -2108,12 +1831,12 @@ Received: ${Array.isArray(item) ? "array" : typeof item}`
|
|
|
2108
1831
|
}
|
|
2109
1832
|
|
|
2110
1833
|
// src/operations/wrappers/createRemoveWrapper.ts
|
|
2111
|
-
var
|
|
1834
|
+
var logger12 = logger_default.get("operations", "wrappers", "remove");
|
|
2112
1835
|
function createRemoveWrapper(coordinate, implementation, options = {}) {
|
|
2113
1836
|
const operationName = options.operationName || "remove";
|
|
2114
1837
|
return async (key) => {
|
|
2115
1838
|
if (options.debug) {
|
|
2116
|
-
|
|
1839
|
+
logger12.debug(`[${operationName}] Called with key:`, key);
|
|
2117
1840
|
}
|
|
2118
1841
|
if (!options.skipValidation) {
|
|
2119
1842
|
validateKey(key, coordinate, operationName);
|
|
@@ -2121,7 +1844,7 @@ function createRemoveWrapper(coordinate, implementation, options = {}) {
|
|
|
2121
1844
|
try {
|
|
2122
1845
|
const result = await implementation(key);
|
|
2123
1846
|
if (options.debug) {
|
|
2124
|
-
|
|
1847
|
+
logger12.debug(`[${operationName}] Removed item:`, key);
|
|
2125
1848
|
}
|
|
2126
1849
|
return result;
|
|
2127
1850
|
} catch (error) {
|
|
@@ -2133,6 +1856,17 @@ function createRemoveWrapper(coordinate, implementation, options = {}) {
|
|
|
2133
1856
|
};
|
|
2134
1857
|
throw options.onError(error, context);
|
|
2135
1858
|
}
|
|
1859
|
+
logger12.error(`[${operationName}] Operation failed in wrapper`, {
|
|
1860
|
+
component: "core",
|
|
1861
|
+
wrapper: "createRemoveWrapper",
|
|
1862
|
+
operation: operationName,
|
|
1863
|
+
key: JSON.stringify(key),
|
|
1864
|
+
itemType: coordinate.kta[0],
|
|
1865
|
+
errorType: error.constructor?.name,
|
|
1866
|
+
errorMessage: error.message,
|
|
1867
|
+
suggestion: "Check item exists, delete permissions, referential integrity, and database connectivity",
|
|
1868
|
+
coordinate: JSON.stringify(coordinate)
|
|
1869
|
+
});
|
|
2136
1870
|
throw new Error(
|
|
2137
1871
|
`[${operationName}] Operation failed: ${error.message}`,
|
|
2138
1872
|
{ cause: error }
|
|
@@ -2142,7 +1876,7 @@ function createRemoveWrapper(coordinate, implementation, options = {}) {
|
|
|
2142
1876
|
}
|
|
2143
1877
|
|
|
2144
1878
|
// src/operations/wrappers/createFindWrapper.ts
|
|
2145
|
-
var
|
|
1879
|
+
var logger13 = logger_default.get("operations", "wrappers", "find");
|
|
2146
1880
|
function isFindOperationResult(value) {
|
|
2147
1881
|
return value && typeof value === "object" && "items" in value && "metadata" in value && Array.isArray(value.items) && value.metadata && typeof value.metadata === "object" && "total" in value.metadata;
|
|
2148
1882
|
}
|
|
@@ -2174,7 +1908,7 @@ function createFindWrapper(coordinate, implementation, options = {}) {
|
|
|
2174
1908
|
const operationName = options.operationName || "find";
|
|
2175
1909
|
return async (finder, params, locations, findOptions) => {
|
|
2176
1910
|
if (options.debug) {
|
|
2177
|
-
|
|
1911
|
+
logger13.debug(`[${operationName}] Called:`, { finder, params, locations, findOptions });
|
|
2178
1912
|
}
|
|
2179
1913
|
if (!options.skipValidation) {
|
|
2180
1914
|
validateFinderName(finder, operationName);
|
|
@@ -2187,7 +1921,7 @@ function createFindWrapper(coordinate, implementation, options = {}) {
|
|
|
2187
1921
|
const result = await implementation(finder, normalizedParams, normalizedLocations, findOptions);
|
|
2188
1922
|
if (isFindOperationResult(result)) {
|
|
2189
1923
|
if (options.debug) {
|
|
2190
|
-
|
|
1924
|
+
logger13.debug(`[${operationName}] Finder "${finder}" opted-in to pagination, found ${result.items.length} items (total: ${result.metadata.total})`);
|
|
2191
1925
|
}
|
|
2192
1926
|
if (!options.skipValidation) {
|
|
2193
1927
|
const validatedItems = validatePK(result.items, coordinate.kta[0]);
|
|
@@ -2199,7 +1933,7 @@ function createFindWrapper(coordinate, implementation, options = {}) {
|
|
|
2199
1933
|
return result;
|
|
2200
1934
|
} else {
|
|
2201
1935
|
if (options.debug) {
|
|
2202
|
-
|
|
1936
|
+
logger13.debug(`[${operationName}] Finder "${finder}" using legacy signature, applying post-processing pagination`);
|
|
2203
1937
|
}
|
|
2204
1938
|
let validatedItems;
|
|
2205
1939
|
if (!options.skipValidation) {
|
|
@@ -2221,7 +1955,7 @@ function createFindWrapper(coordinate, implementation, options = {}) {
|
|
|
2221
1955
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2222
1956
|
const errorStack = error instanceof Error ? error.stack : null;
|
|
2223
1957
|
const errorCause = error instanceof Error && "cause" in error ? error.cause : null;
|
|
2224
|
-
|
|
1958
|
+
logger13.error(`[${operationName}] Operation failed for finder "${finder}"`, {
|
|
2225
1959
|
finder,
|
|
2226
1960
|
params,
|
|
2227
1961
|
locations,
|
|
@@ -2239,12 +1973,12 @@ function createFindWrapper(coordinate, implementation, options = {}) {
|
|
|
2239
1973
|
}
|
|
2240
1974
|
|
|
2241
1975
|
// src/operations/wrappers/createFindOneWrapper.ts
|
|
2242
|
-
var
|
|
1976
|
+
var logger14 = logger_default.get("operations", "wrappers", "findOne");
|
|
2243
1977
|
function createFindOneWrapper(coordinate, implementation, options = {}) {
|
|
2244
1978
|
const operationName = options.operationName || "findOne";
|
|
2245
1979
|
return async (finder, params, locations) => {
|
|
2246
1980
|
if (options.debug) {
|
|
2247
|
-
|
|
1981
|
+
logger14.debug(`[${operationName}] Called:`, { finder, params, locations });
|
|
2248
1982
|
}
|
|
2249
1983
|
if (!options.skipValidation) {
|
|
2250
1984
|
validateFinderName(finder, operationName);
|
|
@@ -2256,7 +1990,7 @@ function createFindOneWrapper(coordinate, implementation, options = {}) {
|
|
|
2256
1990
|
try {
|
|
2257
1991
|
const result = await implementation(finder, normalizedParams, normalizedLocations);
|
|
2258
1992
|
if (options.debug) {
|
|
2259
|
-
|
|
1993
|
+
logger14.debug(`[${operationName}] Result for finder "${finder}":`, result ? "found" : "not found");
|
|
2260
1994
|
}
|
|
2261
1995
|
if (result && !options.skipValidation) {
|
|
2262
1996
|
return validatePK(result, coordinate.kta[0]);
|
|
@@ -2280,12 +2014,12 @@ function createFindOneWrapper(coordinate, implementation, options = {}) {
|
|
|
2280
2014
|
}
|
|
2281
2015
|
|
|
2282
2016
|
// src/operations/wrappers/createActionWrapper.ts
|
|
2283
|
-
var
|
|
2017
|
+
var logger15 = logger_default.get("operations", "wrappers", "action");
|
|
2284
2018
|
function createActionWrapper(coordinate, implementation, options = {}) {
|
|
2285
2019
|
const operationName = options.operationName || "action";
|
|
2286
2020
|
return async (key, action, params) => {
|
|
2287
2021
|
if (options.debug) {
|
|
2288
|
-
|
|
2022
|
+
logger15.debug(`[${operationName}] Called:`, { key, action, params });
|
|
2289
2023
|
}
|
|
2290
2024
|
if (!options.skipValidation) {
|
|
2291
2025
|
validateKey(key, coordinate, operationName);
|
|
@@ -2296,7 +2030,7 @@ function createActionWrapper(coordinate, implementation, options = {}) {
|
|
|
2296
2030
|
try {
|
|
2297
2031
|
const result = await implementation(key, action, normalizedParams);
|
|
2298
2032
|
if (options.debug) {
|
|
2299
|
-
|
|
2033
|
+
logger15.debug(`[${operationName}] Action "${action}" completed:`, {
|
|
2300
2034
|
itemKey: result[0].key,
|
|
2301
2035
|
affectedKeys: result[1].length
|
|
2302
2036
|
});
|
|
@@ -2315,6 +2049,19 @@ function createActionWrapper(coordinate, implementation, options = {}) {
|
|
|
2315
2049
|
};
|
|
2316
2050
|
throw options.onError(error, context);
|
|
2317
2051
|
}
|
|
2052
|
+
logger15.error(`[${operationName}] Action failed in wrapper`, {
|
|
2053
|
+
component: "core",
|
|
2054
|
+
wrapper: "createActionWrapper",
|
|
2055
|
+
operation: operationName,
|
|
2056
|
+
action,
|
|
2057
|
+
key: JSON.stringify(key),
|
|
2058
|
+
params: JSON.stringify(params),
|
|
2059
|
+
itemType: coordinate.kta[0],
|
|
2060
|
+
errorType: error.constructor?.name,
|
|
2061
|
+
errorMessage: error.message,
|
|
2062
|
+
suggestion: "Check action name is valid, item exists, and action implementation",
|
|
2063
|
+
coordinate: JSON.stringify(coordinate)
|
|
2064
|
+
});
|
|
2318
2065
|
throw new Error(
|
|
2319
2066
|
`[${operationName}] Action "${action}" failed: ${error.message}`,
|
|
2320
2067
|
{ cause: error }
|
|
@@ -2324,12 +2071,12 @@ function createActionWrapper(coordinate, implementation, options = {}) {
|
|
|
2324
2071
|
}
|
|
2325
2072
|
|
|
2326
2073
|
// src/operations/wrappers/createAllActionWrapper.ts
|
|
2327
|
-
var
|
|
2074
|
+
var logger16 = logger_default.get("operations", "wrappers", "allAction");
|
|
2328
2075
|
function createAllActionWrapper(coordinate, implementation, options = {}) {
|
|
2329
2076
|
const operationName = options.operationName || "allAction";
|
|
2330
2077
|
return async (action, params, locations) => {
|
|
2331
2078
|
if (options.debug) {
|
|
2332
|
-
|
|
2079
|
+
logger16.debug(`[${operationName}] Called:`, { action, params, locations });
|
|
2333
2080
|
}
|
|
2334
2081
|
if (!options.skipValidation) {
|
|
2335
2082
|
validateActionName(action, operationName);
|
|
@@ -2341,7 +2088,7 @@ function createAllActionWrapper(coordinate, implementation, options = {}) {
|
|
|
2341
2088
|
try {
|
|
2342
2089
|
const result = await implementation(action, normalizedParams, normalizedLocations);
|
|
2343
2090
|
if (options.debug) {
|
|
2344
|
-
|
|
2091
|
+
logger16.debug(`[${operationName}] Action "${action}" completed:`, {
|
|
2345
2092
|
itemsAffected: result[0].length,
|
|
2346
2093
|
affectedKeys: result[1].length
|
|
2347
2094
|
});
|
|
@@ -2369,12 +2116,12 @@ function createAllActionWrapper(coordinate, implementation, options = {}) {
|
|
|
2369
2116
|
}
|
|
2370
2117
|
|
|
2371
2118
|
// src/operations/wrappers/createFacetWrapper.ts
|
|
2372
|
-
var
|
|
2119
|
+
var logger17 = logger_default.get("operations", "wrappers", "facet");
|
|
2373
2120
|
function createFacetWrapper(coordinate, implementation, options = {}) {
|
|
2374
2121
|
const operationName = options.operationName || "facet";
|
|
2375
2122
|
return async (key, facet, params) => {
|
|
2376
2123
|
if (options.debug) {
|
|
2377
|
-
|
|
2124
|
+
logger17.debug(`[${operationName}] Called:`, { key, facet, params });
|
|
2378
2125
|
}
|
|
2379
2126
|
if (!options.skipValidation) {
|
|
2380
2127
|
validateKey(key, coordinate, operationName);
|
|
@@ -2385,7 +2132,7 @@ function createFacetWrapper(coordinate, implementation, options = {}) {
|
|
|
2385
2132
|
try {
|
|
2386
2133
|
const result = await implementation(key, facet, normalizedParams);
|
|
2387
2134
|
if (options.debug) {
|
|
2388
|
-
|
|
2135
|
+
logger17.debug(`[${operationName}] Facet "${facet}" completed`);
|
|
2389
2136
|
}
|
|
2390
2137
|
return result;
|
|
2391
2138
|
} catch (error) {
|
|
@@ -2406,12 +2153,12 @@ function createFacetWrapper(coordinate, implementation, options = {}) {
|
|
|
2406
2153
|
}
|
|
2407
2154
|
|
|
2408
2155
|
// src/operations/wrappers/createAllFacetWrapper.ts
|
|
2409
|
-
var
|
|
2156
|
+
var logger18 = logger_default.get("operations", "wrappers", "allFacet");
|
|
2410
2157
|
function createAllFacetWrapper(coordinate, implementation, options = {}) {
|
|
2411
2158
|
const operationName = options.operationName || "allFacet";
|
|
2412
2159
|
return async (facet, params, locations) => {
|
|
2413
2160
|
if (options.debug) {
|
|
2414
|
-
|
|
2161
|
+
logger18.debug(`[${operationName}] Called:`, { facet, params, locations });
|
|
2415
2162
|
}
|
|
2416
2163
|
if (!options.skipValidation) {
|
|
2417
2164
|
validateFacetName(facet, operationName);
|
|
@@ -2423,7 +2170,7 @@ function createAllFacetWrapper(coordinate, implementation, options = {}) {
|
|
|
2423
2170
|
try {
|
|
2424
2171
|
const result = await implementation(facet, normalizedParams, normalizedLocations);
|
|
2425
2172
|
if (options.debug) {
|
|
2426
|
-
|
|
2173
|
+
logger18.debug(`[${operationName}] Facet "${facet}" completed`);
|
|
2427
2174
|
}
|
|
2428
2175
|
return result;
|
|
2429
2176
|
} catch (error) {
|
|
@@ -2442,6 +2189,247 @@ function createAllFacetWrapper(coordinate, implementation, options = {}) {
|
|
|
2442
2189
|
}
|
|
2443
2190
|
};
|
|
2444
2191
|
}
|
|
2192
|
+
|
|
2193
|
+
// src/event/events.ts
|
|
2194
|
+
function isCreateEvent(event) {
|
|
2195
|
+
return event.eventType === "create";
|
|
2196
|
+
}
|
|
2197
|
+
function isUpdateEvent(event) {
|
|
2198
|
+
return event.eventType === "update";
|
|
2199
|
+
}
|
|
2200
|
+
function isDeleteEvent(event) {
|
|
2201
|
+
return event.eventType === "delete";
|
|
2202
|
+
}
|
|
2203
|
+
function isActionEvent(event) {
|
|
2204
|
+
return event.eventType === "action";
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
// src/event/subscription.ts
|
|
2208
|
+
function isItemSubscription(subscription) {
|
|
2209
|
+
return "key" in subscription;
|
|
2210
|
+
}
|
|
2211
|
+
function isLocationSubscription(subscription) {
|
|
2212
|
+
return "kta" in subscription && "location" in subscription;
|
|
2213
|
+
}
|
|
2214
|
+
function generateSubscriptionId() {
|
|
2215
|
+
return `sub-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
2216
|
+
}
|
|
2217
|
+
function createItemSubscription(key, options) {
|
|
2218
|
+
return {
|
|
2219
|
+
id: generateSubscriptionId(),
|
|
2220
|
+
key,
|
|
2221
|
+
eventTypes: options?.eventTypes,
|
|
2222
|
+
scopes: options?.scopes,
|
|
2223
|
+
query: options?.query
|
|
2224
|
+
};
|
|
2225
|
+
}
|
|
2226
|
+
function createLocationSubscription(kta, location, options) {
|
|
2227
|
+
return {
|
|
2228
|
+
id: generateSubscriptionId(),
|
|
2229
|
+
kta,
|
|
2230
|
+
location,
|
|
2231
|
+
eventTypes: options?.eventTypes,
|
|
2232
|
+
scopes: options?.scopes,
|
|
2233
|
+
query: options?.query
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
// src/event/matching.ts
|
|
2238
|
+
function doesEventMatchSubscription(event, subscription) {
|
|
2239
|
+
if (!doesScopeMatch(event.scopes, subscription.scopes)) {
|
|
2240
|
+
return false;
|
|
2241
|
+
}
|
|
2242
|
+
if (!doesEventTypeMatch(event.eventType, subscription.eventTypes)) {
|
|
2243
|
+
return false;
|
|
2244
|
+
}
|
|
2245
|
+
if (isItemSubscription(subscription)) {
|
|
2246
|
+
return doesKeyMatch(event.key, subscription.key);
|
|
2247
|
+
} else if (isLocationSubscription(subscription)) {
|
|
2248
|
+
return doesKeyMatchLocation(event.key, subscription.kta, subscription.location);
|
|
2249
|
+
}
|
|
2250
|
+
return false;
|
|
2251
|
+
}
|
|
2252
|
+
function doesScopeMatch(eventScopes, subscriptionScopes) {
|
|
2253
|
+
if (!subscriptionScopes || subscriptionScopes.length === 0) {
|
|
2254
|
+
return true;
|
|
2255
|
+
}
|
|
2256
|
+
return subscriptionScopes.some(
|
|
2257
|
+
(requiredScope) => eventScopes.includes(requiredScope)
|
|
2258
|
+
);
|
|
2259
|
+
}
|
|
2260
|
+
function doesEventTypeMatch(eventType, subscriptionEventTypes) {
|
|
2261
|
+
if (!subscriptionEventTypes || subscriptionEventTypes.length === 0) {
|
|
2262
|
+
return true;
|
|
2263
|
+
}
|
|
2264
|
+
return subscriptionEventTypes.includes(eventType);
|
|
2265
|
+
}
|
|
2266
|
+
function doesKeyMatch(eventKey, subscriptionKey) {
|
|
2267
|
+
if (isPriKey(eventKey) && isPriKey(subscriptionKey)) {
|
|
2268
|
+
return eventKey.pk === subscriptionKey.pk && eventKey.kt === subscriptionKey.kt;
|
|
2269
|
+
}
|
|
2270
|
+
if (isComKey(eventKey) && isComKey(subscriptionKey)) {
|
|
2271
|
+
const eventComKey = eventKey;
|
|
2272
|
+
const subscriptionComKey = subscriptionKey;
|
|
2273
|
+
if (eventComKey.pk !== subscriptionComKey.pk || eventComKey.kt !== subscriptionComKey.kt) {
|
|
2274
|
+
return false;
|
|
2275
|
+
}
|
|
2276
|
+
if (eventComKey.loc.length !== subscriptionComKey.loc.length) {
|
|
2277
|
+
return false;
|
|
2278
|
+
}
|
|
2279
|
+
return eventComKey.loc.every((eventLocKey, index) => {
|
|
2280
|
+
const subLocKey = subscriptionComKey.loc[index];
|
|
2281
|
+
return eventLocKey.lk === subLocKey.lk && eventLocKey.kt === subLocKey.kt;
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
return false;
|
|
2285
|
+
}
|
|
2286
|
+
function doesKeyMatchLocation(eventKey, subscriptionKta, subscriptionLocation) {
|
|
2287
|
+
const targetItemType = subscriptionKta[subscriptionKta.length - 1];
|
|
2288
|
+
if (eventKey.kt !== targetItemType) {
|
|
2289
|
+
return false;
|
|
2290
|
+
}
|
|
2291
|
+
if (isPriKey(eventKey)) {
|
|
2292
|
+
return subscriptionLocation.length === 0;
|
|
2293
|
+
}
|
|
2294
|
+
if (isComKey(eventKey)) {
|
|
2295
|
+
const comKey = eventKey;
|
|
2296
|
+
return doesLocationMatch(comKey.loc, subscriptionLocation, subscriptionKta);
|
|
2297
|
+
}
|
|
2298
|
+
return false;
|
|
2299
|
+
}
|
|
2300
|
+
function doesLocationMatch(eventLocation, subscriptionLocation, _subscriptionKta) {
|
|
2301
|
+
if (subscriptionLocation.length === 0) {
|
|
2302
|
+
return true;
|
|
2303
|
+
}
|
|
2304
|
+
if (eventLocation.length < subscriptionLocation.length) {
|
|
2305
|
+
return false;
|
|
2306
|
+
}
|
|
2307
|
+
for (let i = 0; i < subscriptionLocation.length; i++) {
|
|
2308
|
+
const eventLocKey = eventLocation[i];
|
|
2309
|
+
const subLocKey = subscriptionLocation[i];
|
|
2310
|
+
if (!eventLocKey || !subLocKey) {
|
|
2311
|
+
return false;
|
|
2312
|
+
}
|
|
2313
|
+
if (eventLocKey.lk !== subLocKey.lk || eventLocKey.kt !== subLocKey.kt) {
|
|
2314
|
+
return false;
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
return true;
|
|
2318
|
+
}
|
|
2319
|
+
function findMatchingSubscriptions(event, subscriptions) {
|
|
2320
|
+
return subscriptions.filter(
|
|
2321
|
+
(subscription) => doesEventMatchSubscription(event, subscription)
|
|
2322
|
+
);
|
|
2323
|
+
}
|
|
2324
|
+
function extractLocationValues(location) {
|
|
2325
|
+
return location.map((locKey) => String(locKey.lk));
|
|
2326
|
+
}
|
|
2327
|
+
function compareLocationValues(location1, location2) {
|
|
2328
|
+
if (location1.length !== location2.length) {
|
|
2329
|
+
return false;
|
|
2330
|
+
}
|
|
2331
|
+
return location1.every((locKey1, index) => {
|
|
2332
|
+
const locKey2 = location2[index];
|
|
2333
|
+
return locKey1.lk === locKey2.lk && locKey1.kt === locKey2.kt;
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
// src/event/types.ts
|
|
2338
|
+
var STANDARD_EVENT_TYPES = {
|
|
2339
|
+
CREATE: "create",
|
|
2340
|
+
UPDATE: "update",
|
|
2341
|
+
DELETE: "delete",
|
|
2342
|
+
ACTION: "action"
|
|
2343
|
+
};
|
|
2344
|
+
var STANDARD_SCOPES = {
|
|
2345
|
+
FIRESTORE: "firestore",
|
|
2346
|
+
SEQUELIZE: "sequelize",
|
|
2347
|
+
POSTGRESQL: "postgresql",
|
|
2348
|
+
MYSQL: "mysql",
|
|
2349
|
+
MONGODB: "mongodb",
|
|
2350
|
+
REDIS: "redis"
|
|
2351
|
+
};
|
|
2352
|
+
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
2353
|
+
SubscriptionStatus2["PENDING"] = "pending";
|
|
2354
|
+
SubscriptionStatus2["ACTIVE"] = "active";
|
|
2355
|
+
SubscriptionStatus2["PAUSED"] = "paused";
|
|
2356
|
+
SubscriptionStatus2["ERROR"] = "error";
|
|
2357
|
+
SubscriptionStatus2["CANCELLED"] = "cancelled";
|
|
2358
|
+
return SubscriptionStatus2;
|
|
2359
|
+
})(SubscriptionStatus || {});
|
|
2360
|
+
var DEFAULT_EVENT_CONFIG = {
|
|
2361
|
+
maxBatchSize: 100,
|
|
2362
|
+
maxBatchWaitTime: 50,
|
|
2363
|
+
// 50ms
|
|
2364
|
+
maxRetryAttempts: 3,
|
|
2365
|
+
retryDelay: 1e3,
|
|
2366
|
+
// 1 second
|
|
2367
|
+
enableStats: true,
|
|
2368
|
+
maxSubscriptions: 1e3,
|
|
2369
|
+
subscriptionCleanupInterval: 3e5
|
|
2370
|
+
// 5 minutes
|
|
2371
|
+
};
|
|
2372
|
+
var EventSystemError = class extends Error {
|
|
2373
|
+
constructor(message, code, details) {
|
|
2374
|
+
super(message);
|
|
2375
|
+
this.code = code;
|
|
2376
|
+
this.details = details;
|
|
2377
|
+
this.name = "EventSystemError";
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
var SubscriptionError = class extends EventSystemError {
|
|
2381
|
+
constructor(message, subscriptionId, details) {
|
|
2382
|
+
super(message, "SUBSCRIPTION_ERROR", { subscriptionId, ...details });
|
|
2383
|
+
this.subscriptionId = subscriptionId;
|
|
2384
|
+
this.name = "SubscriptionError";
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
var EventEmissionError = class extends EventSystemError {
|
|
2388
|
+
constructor(message, eventType, details) {
|
|
2389
|
+
super(message, "EVENT_EMISSION_ERROR", { eventType, ...details });
|
|
2390
|
+
this.eventType = eventType;
|
|
2391
|
+
this.name = "EventEmissionError";
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
var EventMatchingError = class extends EventSystemError {
|
|
2395
|
+
constructor(message, details) {
|
|
2396
|
+
super(message, "EVENT_MATCHING_ERROR", details);
|
|
2397
|
+
this.name = "EventMatchingError";
|
|
2398
|
+
}
|
|
2399
|
+
};
|
|
2400
|
+
function createEventSystemError(type, message, details) {
|
|
2401
|
+
switch (type) {
|
|
2402
|
+
case "subscription":
|
|
2403
|
+
return new SubscriptionError(message, details?.subscriptionId || "unknown", details);
|
|
2404
|
+
case "emission":
|
|
2405
|
+
return new EventEmissionError(message, details?.eventType || "unknown", details);
|
|
2406
|
+
case "matching":
|
|
2407
|
+
return new EventMatchingError(message, details);
|
|
2408
|
+
case "general":
|
|
2409
|
+
default:
|
|
2410
|
+
return new EventSystemError(message, "GENERAL_ERROR", details);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
function isEventSystemError(error) {
|
|
2414
|
+
return error instanceof EventSystemError;
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
// src/event/index.ts
|
|
2418
|
+
var EVENT_SYSTEM_VERSION = "1.0.0";
|
|
2419
|
+
var SUPPORTED_EVENT_TYPES = [
|
|
2420
|
+
"create",
|
|
2421
|
+
"update",
|
|
2422
|
+
"delete",
|
|
2423
|
+
"action"
|
|
2424
|
+
];
|
|
2425
|
+
var SUPPORTED_SCOPES = [
|
|
2426
|
+
"firestore",
|
|
2427
|
+
"sequelize",
|
|
2428
|
+
"postgresql",
|
|
2429
|
+
"mysql",
|
|
2430
|
+
"mongodb",
|
|
2431
|
+
"redis"
|
|
2432
|
+
];
|
|
2445
2433
|
export {
|
|
2446
2434
|
AItemService,
|
|
2447
2435
|
ActionError,
|
|
@@ -2514,7 +2502,6 @@ export {
|
|
|
2514
2502
|
isComKey,
|
|
2515
2503
|
isComKeyEqual,
|
|
2516
2504
|
isComKeyEqualNormalized,
|
|
2517
|
-
isCondition,
|
|
2518
2505
|
isCreateEvent,
|
|
2519
2506
|
isDeleteEvent,
|
|
2520
2507
|
isEventSystemError,
|
|
@@ -2526,8 +2513,6 @@ export {
|
|
|
2526
2513
|
isLocKeyEqual,
|
|
2527
2514
|
isLocKeyEqualNormalized,
|
|
2528
2515
|
isLocationSubscription,
|
|
2529
|
-
isComKey2 as isOperationComKey,
|
|
2530
|
-
isPriKey2 as isOperationPriKey,
|
|
2531
2516
|
isPriItem,
|
|
2532
2517
|
isPriKey,
|
|
2533
2518
|
isPriKeyEqual,
|
|
@@ -2538,7 +2523,6 @@ export {
|
|
|
2538
2523
|
isValidItemKey,
|
|
2539
2524
|
isValidLocKey,
|
|
2540
2525
|
isValidLocKeyArray,
|
|
2541
|
-
isValidLocations,
|
|
2542
2526
|
isValidPriKey,
|
|
2543
2527
|
itemKeyToLocKeyArray,
|
|
2544
2528
|
lkaToIK,
|
|
@@ -2546,17 +2530,5 @@ export {
|
|
|
2546
2530
|
paramsToQuery,
|
|
2547
2531
|
primaryType,
|
|
2548
2532
|
queryToParams,
|
|
2549
|
-
toKeyTypeArray
|
|
2550
|
-
validateActionName,
|
|
2551
|
-
validateComKey,
|
|
2552
|
-
validateFacetName,
|
|
2553
|
-
validateFinderName,
|
|
2554
|
-
validateKey,
|
|
2555
|
-
validateKeys,
|
|
2556
|
-
validateLocations,
|
|
2557
|
-
validateOperationParams,
|
|
2558
|
-
validatePK,
|
|
2559
|
-
validatePriKey,
|
|
2560
|
-
validateQuery,
|
|
2561
|
-
validateSchema
|
|
2533
|
+
toKeyTypeArray
|
|
2562
2534
|
};
|