@fjell/core 4.4.50 → 4.4.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/package.json +3 -3
  2. package/src/AItemService.ts +0 -38
  3. package/src/Coordinate.ts +0 -35
  4. package/src/dictionary.ts +0 -84
  5. package/src/errors/ActionError.ts +0 -69
  6. package/src/errors/BusinessLogicError.ts +0 -24
  7. package/src/errors/DuplicateError.ts +0 -57
  8. package/src/errors/NotFoundError.ts +0 -24
  9. package/src/errors/PermissionError.ts +0 -31
  10. package/src/errors/ValidationError.ts +0 -27
  11. package/src/errors/index.ts +0 -7
  12. package/src/event/emitter.ts +0 -247
  13. package/src/event/events.ts +0 -178
  14. package/src/event/index.ts +0 -130
  15. package/src/event/matching.ts +0 -264
  16. package/src/event/subscription.ts +0 -181
  17. package/src/event/types.ts +0 -282
  18. package/src/index.ts +0 -70
  19. package/src/item/IFactory.ts +0 -122
  20. package/src/item/IQFactory.ts +0 -163
  21. package/src/item/IQUtils.ts +0 -392
  22. package/src/item/IUtils.ts +0 -40
  23. package/src/item/ItemQuery.ts +0 -88
  24. package/src/items.ts +0 -120
  25. package/src/key/KUtils.ts +0 -484
  26. package/src/keys.ts +0 -95
  27. package/src/logger.ts +0 -5
  28. package/src/operations/OperationContext.ts +0 -12
  29. package/src/operations/Operations.ts +0 -357
  30. package/src/operations/contained.ts +0 -134
  31. package/src/operations/errorEnhancer.ts +0 -204
  32. package/src/operations/index.ts +0 -2
  33. package/src/operations/methods.ts +0 -363
  34. package/src/operations/primary.ts +0 -101
  35. package/src/operations/specialized.ts +0 -71
  36. package/src/operations/wrappers/createActionWrapper.ts +0 -108
  37. package/src/operations/wrappers/createAllActionWrapper.ts +0 -109
  38. package/src/operations/wrappers/createAllFacetWrapper.ts +0 -98
  39. package/src/operations/wrappers/createAllWrapper.ts +0 -103
  40. package/src/operations/wrappers/createCreateWrapper.ts +0 -117
  41. package/src/operations/wrappers/createFacetWrapper.ts +0 -97
  42. package/src/operations/wrappers/createFindOneWrapper.ts +0 -105
  43. package/src/operations/wrappers/createFindWrapper.ts +0 -105
  44. package/src/operations/wrappers/createGetWrapper.ts +0 -96
  45. package/src/operations/wrappers/createOneWrapper.ts +0 -128
  46. package/src/operations/wrappers/createRemoveWrapper.ts +0 -91
  47. package/src/operations/wrappers/createUpdateWrapper.ts +0 -106
  48. package/src/operations/wrappers/createUpsertWrapper.ts +0 -108
  49. package/src/operations/wrappers/index.ts +0 -39
  50. package/src/operations/wrappers/types.ts +0 -63
  51. package/src/validation/ItemValidator.ts +0 -131
  52. package/src/validation/KeyValidator.ts +0 -365
  53. package/src/validation/LocationValidator.ts +0 -136
  54. package/src/validation/QueryValidator.ts +0 -250
  55. package/src/validation/index.ts +0 -32
  56. package/src/validation/types.ts +0 -45
@@ -1,363 +0,0 @@
1
- import { Item } from "../items";
2
- import { ComKey, LocKeyArray, PriKey } from "../keys";
3
- import { ItemQuery } from "../item/ItemQuery";
4
- import { AffectedKeys, CreateOptions, OperationParams } from "./Operations";
5
-
6
- /**
7
- * Get method signature - retrieves single item by key
8
- */
9
- export interface GetMethod<
10
- V extends Item<S, L1, L2, L3, L4, L5>,
11
- S extends string,
12
- L1 extends string = never,
13
- L2 extends string = never,
14
- L3 extends string = never,
15
- L4 extends string = never,
16
- L5 extends string = never
17
- > {
18
- (
19
- key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>
20
- ): Promise<V | null>;
21
- }
22
-
23
- /**
24
- * Create method signature - creates new item
25
- */
26
- export interface CreateMethod<
27
- V extends Item<S, L1, L2, L3, L4, L5>,
28
- S extends string,
29
- L1 extends string = never,
30
- L2 extends string = never,
31
- L3 extends string = never,
32
- L4 extends string = never,
33
- L5 extends string = never
34
- > {
35
- (
36
- item: Partial<Item<S, L1, L2, L3, L4, L5>>,
37
- options?: CreateOptions<S, L1, L2, L3, L4, L5>
38
- ): Promise<V>;
39
- }
40
-
41
- /**
42
- * Update method signature - updates existing item
43
- */
44
- export interface UpdateMethod<
45
- V extends Item<S, L1, L2, L3, L4, L5>,
46
- S extends string,
47
- L1 extends string = never,
48
- L2 extends string = never,
49
- L3 extends string = never,
50
- L4 extends string = never,
51
- L5 extends string = never
52
- > {
53
- (
54
- key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,
55
- item: Partial<Item<S, L1, L2, L3, L4, L5>>
56
- ): Promise<V>;
57
- }
58
-
59
- /**
60
- * Remove method signature - removes item
61
- */
62
- export interface RemoveMethod<
63
- V extends Item<S, L1, L2, L3, L4, L5>,
64
- S extends string,
65
- L1 extends string = never,
66
- L2 extends string = never,
67
- L3 extends string = never,
68
- L4 extends string = never,
69
- L5 extends string = never
70
- > {
71
- (
72
- key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>
73
- ): Promise<V | void>;
74
- }
75
-
76
- /**
77
- * Upsert method signature - updates or creates item
78
- */
79
- export interface UpsertMethod<
80
- V extends Item<S, L1, L2, L3, L4, L5>,
81
- S extends string,
82
- L1 extends string = never,
83
- L2 extends string = never,
84
- L3 extends string = never,
85
- L4 extends string = never,
86
- L5 extends string = never
87
- > {
88
- (
89
- key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,
90
- item: Partial<Item<S, L1, L2, L3, L4, L5>>
91
- ): Promise<V>;
92
- }
93
-
94
- /**
95
- * All method signature - retrieves all items matching query
96
- */
97
- export interface AllMethod<
98
- V extends Item<S, L1, L2, L3, L4, L5>,
99
- S extends string,
100
- L1 extends string = never,
101
- L2 extends string = never,
102
- L3 extends string = never,
103
- L4 extends string = never,
104
- L5 extends string = never
105
- > {
106
- (
107
- query?: ItemQuery,
108
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
109
- ): Promise<V[]>;
110
- }
111
-
112
- /**
113
- * One method signature - retrieves first item matching query
114
- */
115
- export interface OneMethod<
116
- V extends Item<S, L1, L2, L3, L4, L5>,
117
- S extends string,
118
- L1 extends string = never,
119
- L2 extends string = never,
120
- L3 extends string = never,
121
- L4 extends string = never,
122
- L5 extends string = never
123
- > {
124
- (
125
- query?: ItemQuery,
126
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
127
- ): Promise<V | null>;
128
- }
129
-
130
- /**
131
- * Find method signature - finds multiple items using finder
132
- */
133
- export interface FindMethod<
134
- V extends Item<S, L1, L2, L3, L4, L5>,
135
- S extends string,
136
- L1 extends string = never,
137
- L2 extends string = never,
138
- L3 extends string = never,
139
- L4 extends string = never,
140
- L5 extends string = never
141
- > {
142
- (
143
- finder: string,
144
- params: OperationParams,
145
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
146
- ): Promise<V[]>;
147
- }
148
-
149
- /**
150
- * FindOne method signature - finds single item using finder
151
- */
152
- export interface FindOneMethod<
153
- V extends Item<S, L1, L2, L3, L4, L5>,
154
- S extends string,
155
- L1 extends string = never,
156
- L2 extends string = never,
157
- L3 extends string = never,
158
- L4 extends string = never,
159
- L5 extends string = never
160
- > {
161
- (
162
- finder: string,
163
- params: OperationParams,
164
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
165
- ): Promise<V | null>;
166
- }
167
-
168
- /**
169
- * Finder method signature - finds multiple items
170
- *
171
- * @example
172
- * ```typescript
173
- * const byEmailFinder: FinderMethod<User, 'user'> = async (params) => {
174
- * return await database.findUsers({ email: params.email });
175
- * };
176
- * ```
177
- */
178
- export interface FinderMethod<
179
- V extends Item<S, L1, L2, L3, L4, L5>,
180
- S extends string,
181
- L1 extends string = never,
182
- L2 extends string = never,
183
- L3 extends string = never,
184
- L4 extends string = never,
185
- L5 extends string = never
186
- > {
187
- (
188
- params: OperationParams,
189
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
190
- ): Promise<V[]>;
191
- }
192
-
193
- /**
194
- * Action operation method signature - executes action on specific item by key
195
- */
196
- export interface ActionOperationMethod<
197
- V extends Item<S, L1, L2, L3, L4, L5>,
198
- S extends string,
199
- L1 extends string = never,
200
- L2 extends string = never,
201
- L3 extends string = never,
202
- L4 extends string = never,
203
- L5 extends string = never
204
- > {
205
- (
206
- key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,
207
- action: string,
208
- params?: OperationParams
209
- ): Promise<[V, AffectedKeys]>;
210
- }
211
-
212
- /**
213
- * Action method signature - user-defined action implementation
214
- */
215
- export interface ActionMethod<
216
- V extends Item<S, L1, L2, L3, L4, L5>,
217
- S extends string,
218
- L1 extends string = never,
219
- L2 extends string = never,
220
- L3 extends string = never,
221
- L4 extends string = never,
222
- L5 extends string = never
223
- > {
224
- (
225
- item: V,
226
- params: OperationParams
227
- ): Promise<[V, AffectedKeys]>;
228
- }
229
-
230
- /**
231
- * AllAction operation method signature - executes action on all items
232
- */
233
- export interface AllActionOperationMethod<
234
- V extends Item<S, L1, L2, L3, L4, L5>,
235
- S extends string,
236
- L1 extends string = never,
237
- L2 extends string = never,
238
- L3 extends string = never,
239
- L4 extends string = never,
240
- L5 extends string = never
241
- > {
242
- (
243
- action: string,
244
- params?: OperationParams,
245
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
246
- ): Promise<[V[], AffectedKeys]>;
247
- }
248
-
249
- /**
250
- * All-action method signature - user-defined all-action implementation
251
- */
252
- export interface AllActionMethod<
253
- V extends Item<S, L1, L2, L3, L4, L5>,
254
- S extends string,
255
- L1 extends string = never,
256
- L2 extends string = never,
257
- L3 extends string = never,
258
- L4 extends string = never,
259
- L5 extends string = never
260
- > {
261
- (
262
- params: OperationParams,
263
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
264
- ): Promise<[V[], AffectedKeys]>;
265
- }
266
-
267
- /**
268
- * Facet operation method signature - executes facet on specific item by key
269
- */
270
- export interface FacetOperationMethod<
271
- S extends string,
272
- L1 extends string = never,
273
- L2 extends string = never,
274
- L3 extends string = never,
275
- L4 extends string = never,
276
- L5 extends string = never
277
- > {
278
- (
279
- key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,
280
- facet: string,
281
- params?: OperationParams
282
- ): Promise<any>;
283
- }
284
-
285
- /**
286
- * Facet method signature - user-defined facet implementation
287
- */
288
- export interface FacetMethod<
289
- V extends Item<S, L1, L2, L3, L4, L5>,
290
- S extends string,
291
- L1 extends string = never,
292
- L2 extends string = never,
293
- L3 extends string = never,
294
- L4 extends string = never,
295
- L5 extends string = never
296
- > {
297
- (
298
- item: V,
299
- params: OperationParams
300
- ): Promise<any>;
301
- }
302
-
303
- /**
304
- * AllFacet operation method signature - executes facet on all items
305
- */
306
- export interface AllFacetOperationMethod<
307
- L1 extends string = never,
308
- L2 extends string = never,
309
- L3 extends string = never,
310
- L4 extends string = never,
311
- L5 extends string = never
312
- > {
313
- (
314
- facet: string,
315
- params?: OperationParams,
316
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
317
- ): Promise<any>;
318
- }
319
-
320
- /**
321
- * All-facet method signature - user-defined all-facet implementation
322
- */
323
- export interface AllFacetMethod<
324
- L1 extends string = never,
325
- L2 extends string = never,
326
- L3 extends string = never,
327
- L4 extends string = never,
328
- L5 extends string = never
329
- > {
330
- (
331
- params: OperationParams,
332
- locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
333
- ): Promise<any>;
334
- }
335
-
336
- /**
337
- * Extension maps for operations
338
- */
339
- export interface OperationsExtensions<
340
- V extends Item<S, L1, L2, L3, L4, L5>,
341
- S extends string,
342
- L1 extends string = never,
343
- L2 extends string = never,
344
- L3 extends string = never,
345
- L4 extends string = never,
346
- L5 extends string = never,
347
- > {
348
- /** Registered finder methods */
349
- finders?: Record<string, FinderMethod<V, S, L1, L2, L3, L4, L5>>;
350
-
351
- /** Registered action methods */
352
- actions?: Record<string, ActionMethod<V, S, L1, L2, L3, L4, L5>>;
353
-
354
- /** Registered facet methods */
355
- facets?: Record<string, FacetMethod<V, S, L1, L2, L3, L4, L5>>;
356
-
357
- /** Registered all-action methods */
358
- allActions?: Record<string, AllActionMethod<V, S, L1, L2, L3, L4, L5>>;
359
-
360
- /** Registered all-facet methods */
361
- allFacets?: Record<string, AllFacetMethod<L1, L2, L3, L4, L5>>;
362
- }
363
-
@@ -1,101 +0,0 @@
1
- import { Item } from "../items";
2
- import { PriKey } from "../keys";
3
- import { ItemQuery } from "../item/ItemQuery";
4
- import { AffectedKeys, OperationParams, Operations } from "./Operations";
5
-
6
- /**
7
- * Primary Operations interface - specialized for primary (top-level) items only.
8
- *
9
- * This interface narrows the generic Operations interface to work exclusively
10
- * with PriKey. All operations accept only PriKey, never ComKey or locations.
11
- *
12
- * Primary items are top-level entities that don't belong to a location hierarchy.
13
- * Examples: Users, Organizations, Products, Documents
14
- *
15
- * Use this for:
16
- * - Libraries that store primary items
17
- * - Caches for primary items
18
- * - API clients for primary endpoints
19
- * - Any operations that work with non-hierarchical data
20
- *
21
- * @example
22
- * ```typescript
23
- * // Define a primary item type
24
- * interface User extends Item<'user'> {
25
- * name: string;
26
- * email: string;
27
- * }
28
- *
29
- * // Create operations for primary items
30
- * const userOps: PrimaryOperations<User, 'user'> = createUserOperations();
31
- *
32
- * // Only PriKey allowed - no locations
33
- * await userOps.get({ kt: 'user', pk: '123' });
34
- * await userOps.update({ kt: 'user', pk: '123' }, { name: 'Updated' });
35
- *
36
- * // No locations parameter on collection methods
37
- * await userOps.all({});
38
- * await userOps.find('byEmail', { email: 'test@example.com' });
39
- * await userOps.allAction('deactivate', { reason: 'inactive' });
40
- * ```
41
- */
42
- export interface PrimaryOperations<
43
- V extends Item<S>,
44
- S extends string
45
- > extends Omit<Operations<V, S>,
46
- 'all' | 'one' | 'create' | 'get' | 'update' | 'upsert' | 'remove' |
47
- 'find' | 'findOne' | 'action' | 'allAction' | 'facet' | 'allFacet'> {
48
-
49
- // Collection query operations - no locations needed
50
- all(query?: ItemQuery): Promise<V[]>;
51
- one(query?: ItemQuery): Promise<V | null>;
52
-
53
- // Finder operations - no locations
54
- find(finder: string, params?: OperationParams): Promise<V[]>;
55
- findOne(finder: string, params?: OperationParams): Promise<V | null>;
56
-
57
- // CRUD operations - PriKey only
58
- create(
59
- item: Partial<Item<S>>,
60
- options?: { key?: PriKey<S> }
61
- ): Promise<V>;
62
-
63
- get(key: PriKey<S>): Promise<V | null>;
64
-
65
- update(
66
- key: PriKey<S>,
67
- item: Partial<Item<S>>
68
- ): Promise<V>;
69
-
70
- upsert(
71
- key: PriKey<S>,
72
- item: Partial<Item<S>>
73
- ): Promise<V>;
74
-
75
- remove(key: PriKey<S>): Promise<V | void>;
76
-
77
- // Action operations - PriKey only, no locations
78
- action(
79
- key: PriKey<S>,
80
- action: string,
81
- params?: OperationParams
82
- ): Promise<[V, AffectedKeys]>;
83
-
84
- allAction(
85
- action: string,
86
- params?: OperationParams
87
- ): Promise<[V[], AffectedKeys]>;
88
-
89
- // Facet operations - PriKey only, no locations
90
- facet(
91
- key: PriKey<S>,
92
- facet: string,
93
- params?: OperationParams
94
- ): Promise<any>;
95
-
96
- allFacet(
97
- facet: string,
98
- params?: OperationParams
99
- ): Promise<any>;
100
- }
101
-
@@ -1,71 +0,0 @@
1
- import { Item } from "../items";
2
- import { ComKey, LocKeyArray, PriKey } from "../keys";
3
- import { ItemQuery } from "../item/ItemQuery";
4
- import { AffectedKeys, OperationParams } from "./Operations";
5
-
6
- /**
7
- * Specialized Operations Interfaces
8
- *
9
- * This file contains operation interfaces for specific usage patterns.
10
- * These are primarily used in UI layers (like React providers) to group
11
- * operations by their usage pattern rather than data structure.
12
- *
13
- * For core architectural patterns (Primary vs. Contained), see:
14
- * - primary.ts - Operations for top-level items
15
- * - contained.ts - Operations for hierarchical items
16
- */
17
-
18
- /**
19
- * Collection-focused operations interface.
20
- * Optimized for working with groups of items.
21
- * Used by React providers for array/list contexts.
22
- */
23
- export interface CollectionOperations<
24
- V extends Item<S, L1, L2, L3, L4, L5>,
25
- S extends string,
26
- L1 extends string = never,
27
- L2 extends string = never,
28
- L3 extends string = never,
29
- L4 extends string = never,
30
- L5 extends string = never
31
- > {
32
- // Query operations
33
- all(query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V[]>;
34
- one(query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V | null>;
35
- find(finder: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V[]>;
36
- findOne(finder: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V | null>;
37
-
38
- // Create new items
39
- create(item: Partial<Item<S, L1, L2, L3, L4, L5>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V>;
40
-
41
- // Collection-level operations
42
- allAction(action: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<[V[], AffectedKeys]>;
43
- allFacet(facet: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<any>;
44
- }
45
-
46
- /**
47
- * Instance-focused operations interface.
48
- * Optimized for working with a single specific item.
49
- * Used by React providers for single-item contexts.
50
- */
51
- export interface InstanceOperations<
52
- V extends Item<S, L1, L2, L3, L4, L5>,
53
- S extends string,
54
- L1 extends string = never,
55
- L2 extends string = never,
56
- L3 extends string = never,
57
- L4 extends string = never,
58
- L5 extends string = never
59
- > {
60
- // Retrieve specific item
61
- get(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>): Promise<V | null>;
62
-
63
- // Modify specific item
64
- update(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, item: Partial<Item<S, L1, L2, L3, L4, L5>>): Promise<V>;
65
- remove(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>): Promise<V | void>;
66
-
67
- // Instance-level operations
68
- action(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, action: string, params?: OperationParams): Promise<[V, AffectedKeys]>;
69
- facet(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, facet: string, params?: OperationParams): Promise<any>;
70
- }
71
-
@@ -1,108 +0,0 @@
1
- /**
2
- * Wrapper for action() operation
3
- *
4
- * Provides automatic validation for action() operation parameters.
5
- */
6
-
7
- import type { Item } from "../../items";
8
- import type { ComKey, PriKey } from "../../keys";
9
- import type { Coordinate } from "../../Coordinate";
10
- import type { AffectedKeys, OperationParams } from "../Operations";
11
- import { validateActionName, validateKey, validateOperationParams, validatePK } from "../../validation";
12
- import type { ActionOperationMethod } from "../methods";
13
- import type { ErrorContext, WrapperOptions } from "./types";
14
- import LibLogger from "../../logger";
15
-
16
- const logger = LibLogger.get('operations', 'wrappers', 'action');
17
-
18
- /**
19
- * Creates a wrapped action() method with automatic parameter validation.
20
- *
21
- * @param coordinate - The coordinate defining the item hierarchy
22
- * @param implementation - The core logic for the operation
23
- * @param options - Optional configuration
24
- * @returns A fully validated action() method
25
- *
26
- * @example
27
- * ```typescript
28
- * const action = createActionWrapper(
29
- * coordinate,
30
- * async (key, action, params) => {
31
- * return await database.executeAction(key, action, params);
32
- * }
33
- * );
34
- * ```
35
- */
36
- export function createActionWrapper<
37
- V extends Item<S, L1, L2, L3, L4, L5>,
38
- S extends string,
39
- L1 extends string = never,
40
- L2 extends string = never,
41
- L3 extends string = never,
42
- L4 extends string = never,
43
- L5 extends string = never
44
- >(
45
- coordinate: Coordinate<S, L1, L2, L3, L4, L5>,
46
- implementation: ActionOperationMethod<V, S, L1, L2, L3, L4, L5>,
47
- options: WrapperOptions = {}
48
- ): ActionOperationMethod<V, S, L1, L2, L3, L4, L5> {
49
-
50
- const operationName = options.operationName || 'action';
51
-
52
- return async (
53
- key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,
54
- action: string,
55
- params?: OperationParams
56
- ): Promise<[V, AffectedKeys]> => {
57
-
58
- if (options.debug) {
59
- logger.debug(`[${operationName}] Called:`, { key, action, params });
60
- }
61
-
62
- // Validate
63
- if (!options.skipValidation) {
64
- validateKey(key, coordinate, operationName);
65
- validateActionName(action, operationName);
66
- validateOperationParams(params, operationName);
67
- }
68
-
69
- // Normalize
70
- const normalizedParams = params ?? {};
71
-
72
- // Execute
73
- try {
74
- const result = await implementation(key, action, normalizedParams);
75
-
76
- if (options.debug) {
77
- logger.debug(`[${operationName}] Action "${action}" completed:`, {
78
- itemKey: result[0].key,
79
- affectedKeys: result[1].length
80
- });
81
- }
82
-
83
- // Validate primary key type of the returned item
84
- if (!options.skipValidation) {
85
- const validatedItem = validatePK(result[0], coordinate.kta[0]) as V;
86
- return [validatedItem, result[1]];
87
- }
88
-
89
- return result;
90
-
91
- } catch (error) {
92
- if (options.onError) {
93
- const context: ErrorContext = {
94
- operationName,
95
- params: [key, action, params],
96
- coordinate
97
- };
98
- throw options.onError(error as Error, context);
99
- }
100
-
101
- throw new Error(
102
- `[${operationName}] Action "${action}" failed: ${(error as Error).message}`,
103
- { cause: error }
104
- );
105
- }
106
- };
107
- }
108
-