@fjell/core 4.4.73 → 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.
Files changed (47) hide show
  1. package/README.md +6 -6
  2. package/dist/AItemService.d.ts +1 -1
  3. package/dist/Coordinate.d.ts +1 -6
  4. package/dist/event/emitter.d.ts +1 -2
  5. package/dist/event/events.d.ts +1 -2
  6. package/dist/event/matching.d.ts +1 -1
  7. package/dist/event/subscription.d.ts +1 -2
  8. package/dist/index.d.ts +7 -20
  9. package/dist/index.js +1113 -1276
  10. package/dist/item/IFactory.d.ts +1 -2
  11. package/dist/item/IQFactory.d.ts +1 -1
  12. package/dist/item/IQUtils.d.ts +1 -2
  13. package/dist/item/IUtils.d.ts +1 -7
  14. package/dist/key/KUtils.d.ts +3 -3
  15. package/dist/operations/OperationContext.d.ts +1 -1
  16. package/dist/operations/index.d.ts +1 -0
  17. package/dist/operations/wrappers/createActionWrapper.d.ts +1 -3
  18. package/dist/operations/wrappers/createAllActionWrapper.d.ts +1 -3
  19. package/dist/operations/wrappers/createAllFacetWrapper.d.ts +1 -2
  20. package/dist/operations/wrappers/createAllWrapper.d.ts +1 -3
  21. package/dist/operations/wrappers/createCreateWrapper.d.ts +1 -3
  22. package/dist/operations/wrappers/createFacetWrapper.d.ts +1 -2
  23. package/dist/operations/wrappers/createFindOneWrapper.d.ts +1 -3
  24. package/dist/operations/wrappers/createFindWrapper.d.ts +1 -3
  25. package/dist/operations/wrappers/createGetWrapper.d.ts +1 -3
  26. package/dist/operations/wrappers/createOneWrapper.d.ts +1 -3
  27. package/dist/operations/wrappers/createRemoveWrapper.d.ts +1 -3
  28. package/dist/operations/wrappers/createUpdateWrapper.d.ts +1 -3
  29. package/dist/operations/wrappers/createUpsertWrapper.d.ts +1 -3
  30. package/dist/operations/wrappers/types.d.ts +1 -1
  31. package/package.json +4 -7
  32. package/dist/item/ItemQuery.d.ts +0 -62
  33. package/dist/items.d.ts +0 -74
  34. package/dist/keys.d.ts +0 -66
  35. package/dist/operations/Operations.d.ts +0 -530
  36. package/dist/operations/contained.d.ts +0 -65
  37. package/dist/operations/methods.d.ts +0 -204
  38. package/dist/operations/primary.d.ts +0 -57
  39. package/dist/operations/specialized.d.ts +0 -41
  40. package/dist/validation/ItemValidator.d.ts +0 -43
  41. package/dist/validation/KeyValidator.d.ts +0 -56
  42. package/dist/validation/LocationValidator.d.ts +0 -39
  43. package/dist/validation/QueryValidator.d.ts +0 -57
  44. package/dist/validation/index.d.ts +0 -17
  45. package/dist/validation/index.js +0 -656
  46. package/dist/validation/schema.d.ts +0 -23
  47. package/dist/validation/types.d.ts +0 -69
@@ -1,204 +0,0 @@
1
- import { Item } from "../items";
2
- import { ComKey, LocKeyArray, PriKey } from "../keys";
3
- import { ItemQuery } from "../item/ItemQuery";
4
- import { AffectedKeys, AllOperationResult, AllOptions, CreateOptions, FindOperationResult, FindOptions, OperationParams, UpdateOptions } from "./Operations";
5
- /**
6
- * Get method signature - retrieves single item by key
7
- */
8
- export interface GetMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
9
- (key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>): Promise<V | null>;
10
- }
11
- /**
12
- * Create method signature - creates new item
13
- */
14
- export interface CreateMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
15
- (item: Partial<Item<S, L1, L2, L3, L4, L5>>, options?: CreateOptions<S, L1, L2, L3, L4, L5>): Promise<V>;
16
- }
17
- /**
18
- * Update method signature - updates existing item
19
- */
20
- export interface UpdateMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
21
- (key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, item: Partial<Item<S, L1, L2, L3, L4, L5>>, options?: UpdateOptions): Promise<V>;
22
- }
23
- /**
24
- * Remove method signature - removes item
25
- */
26
- export interface RemoveMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
27
- (key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>): Promise<V | void>;
28
- }
29
- /**
30
- * Upsert method signature - updates or creates item
31
- */
32
- export interface UpsertMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
33
- (key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, item: Partial<Item<S, L1, L2, L3, L4, L5>>, locations?: LocKeyArray<L1, L2, L3, L4, L5>, options?: UpdateOptions): Promise<V>;
34
- }
35
- /**
36
- * All method signature - retrieves all items matching query with optional pagination.
37
- *
38
- * @param query - Optional query to filter items (may include limit/offset for backwards compatibility)
39
- * @param locations - Optional location hierarchy to scope the query
40
- * @param options - Optional pagination options (takes precedence over query limit/offset)
41
- * @returns Result containing items and pagination metadata
42
- *
43
- * @example Without options (backwards compatible)
44
- * ```typescript
45
- * const result = await operations.all({ compoundCondition: {...} });
46
- * // result.items = [...all matching items...]
47
- * // result.metadata.total = result.items.length
48
- * ```
49
- *
50
- * @example With options (new pattern)
51
- * ```typescript
52
- * const result = await operations.all(
53
- * { compoundCondition: {...} },
54
- * [],
55
- * { limit: 50, offset: 0 }
56
- * );
57
- * // result.items = [...first 50 items...]
58
- * // result.metadata.total = total matching count
59
- * // result.metadata.hasMore = true if more items exist
60
- * ```
61
- */
62
- export interface AllMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
63
- (query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | [], options?: AllOptions): Promise<AllOperationResult<V>>;
64
- }
65
- /**
66
- * One method signature - retrieves first item matching query
67
- */
68
- export interface OneMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
69
- (query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V | null>;
70
- }
71
- /**
72
- * Find method signature - finds multiple items using finder with optional pagination.
73
- *
74
- * Supports hybrid approach:
75
- * - If finder returns FindOperationResult<V>, uses it directly (opt-in)
76
- * - If finder returns V[], framework applies post-processing pagination
77
- *
78
- * @param finder - Name of the finder method
79
- * @param params - Parameters for the finder
80
- * @param locations - Optional location hierarchy to scope the query
81
- * @param options - Optional pagination options (limit, offset)
82
- * @returns Result containing items and pagination metadata
83
- *
84
- * @example
85
- * ```typescript
86
- * // Without pagination (returns all results)
87
- * const result = await operations.find('byEmail', { email: 'test@example.com' });
88
- *
89
- * // With pagination
90
- * const result = await operations.find('byEmail', { email: 'test@example.com' }, [], { limit: 10, offset: 0 });
91
- * ```
92
- */
93
- export interface FindMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
94
- (finder: string, params: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | [], options?: FindOptions): Promise<FindOperationResult<V>>;
95
- }
96
- /**
97
- * FindOne method signature - finds single item using finder
98
- */
99
- export interface FindOneMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
100
- (finder: string, params: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V | null>;
101
- }
102
- /**
103
- * Finder method signature - finds multiple items.
104
- *
105
- * Supports hybrid approach for pagination:
106
- * - **Legacy signature**: Return `Promise<V[]>` - framework applies post-processing pagination
107
- * - **Opt-in signature**: Return `Promise<FindOperationResult<V>>` - finder handles pagination at source
108
- *
109
- * @example Legacy finder (framework handles pagination)
110
- * ```typescript
111
- * const byEmailFinder: FinderMethod<User, 'user'> = async (params) => {
112
- * return await database.findUsers({ email: params.email });
113
- * };
114
- * ```
115
- *
116
- * @example Opt-in finder (finder handles pagination)
117
- * ```typescript
118
- * const byEmailFinder: FinderMethod<User, 'user'> = async (params, locations, options) => {
119
- * const query = buildQuery({ email: params.email });
120
- * const total = await database.count(query);
121
- *
122
- * if (options?.offset) query.offset(options.offset);
123
- * if (options?.limit) query.limit(options.limit);
124
- *
125
- * const items = await database.find(query);
126
- * return {
127
- * items,
128
- * metadata: {
129
- * total,
130
- * returned: items.length,
131
- * offset: options?.offset ?? 0,
132
- * limit: options?.limit,
133
- * hasMore: (options?.offset ?? 0) + items.length < total
134
- * }
135
- * };
136
- * };
137
- * ```
138
- */
139
- export interface FinderMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
140
- (params: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | [], options?: FindOptions): Promise<V[] | FindOperationResult<V>>;
141
- }
142
- /**
143
- * Action operation method signature - executes action on specific item by key
144
- */
145
- export interface ActionOperationMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
146
- (key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, action: string, params?: OperationParams): Promise<[V, AffectedKeys]>;
147
- }
148
- /**
149
- * Action method signature - user-defined action implementation
150
- */
151
- export interface ActionMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
152
- (item: V, params: OperationParams): Promise<[V, AffectedKeys]>;
153
- }
154
- /**
155
- * AllAction operation method signature - executes action on all items
156
- */
157
- export interface AllActionOperationMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
158
- (action: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<[V[], AffectedKeys]>;
159
- }
160
- /**
161
- * All-action method signature - user-defined all-action implementation
162
- */
163
- export interface AllActionMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
164
- (params: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<[V[], AffectedKeys]>;
165
- }
166
- /**
167
- * Facet operation method signature - executes facet on specific item by key
168
- */
169
- export interface FacetOperationMethod<S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
170
- (key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, facet: string, params?: OperationParams): Promise<any>;
171
- }
172
- /**
173
- * Facet method signature - user-defined facet implementation
174
- */
175
- export interface FacetMethod<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
176
- (item: V, params: OperationParams): Promise<any>;
177
- }
178
- /**
179
- * AllFacet operation method signature - executes facet on all items
180
- */
181
- export interface AllFacetOperationMethod<L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
182
- (facet: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<any>;
183
- }
184
- /**
185
- * All-facet method signature - user-defined all-facet implementation
186
- */
187
- export interface AllFacetMethod<L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
188
- (params: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<any>;
189
- }
190
- /**
191
- * Extension maps for operations
192
- */
193
- export interface OperationsExtensions<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
194
- /** Registered finder methods */
195
- finders?: Record<string, FinderMethod<V, S, L1, L2, L3, L4, L5>>;
196
- /** Registered action methods */
197
- actions?: Record<string, ActionMethod<V, S, L1, L2, L3, L4, L5>>;
198
- /** Registered facet methods */
199
- facets?: Record<string, FacetMethod<V, S, L1, L2, L3, L4, L5>>;
200
- /** Registered all-action methods */
201
- allActions?: Record<string, AllActionMethod<V, S, L1, L2, L3, L4, L5>>;
202
- /** Registered all-facet methods */
203
- allFacets?: Record<string, AllFacetMethod<L1, L2, L3, L4, L5>>;
204
- }
@@ -1,57 +0,0 @@
1
- import { Item } from "../items";
2
- import { PriKey } from "../keys";
3
- import { ItemQuery } from "../item/ItemQuery";
4
- import { AffectedKeys, AllOperationResult, AllOptions, FindOperationResult, FindOptions, OperationParams, Operations } from "./Operations";
5
- /**
6
- * Primary Operations interface - specialized for primary (top-level) items only.
7
- *
8
- * This interface narrows the generic Operations interface to work exclusively
9
- * with PriKey. All operations accept only PriKey, never ComKey or locations.
10
- *
11
- * Primary items are top-level entities that don't belong to a location hierarchy.
12
- * Examples: Users, Organizations, Products, Documents
13
- *
14
- * Use this for:
15
- * - Libraries that store primary items
16
- * - Caches for primary items
17
- * - API clients for primary endpoints
18
- * - Any operations that work with non-hierarchical data
19
- *
20
- * @example
21
- * ```typescript
22
- * // Define a primary item type
23
- * interface User extends Item<'user'> {
24
- * name: string;
25
- * email: string;
26
- * }
27
- *
28
- * // Create operations for primary items
29
- * const userOps: PrimaryOperations<User, 'user'> = createUserOperations();
30
- *
31
- * // Only PriKey allowed - no locations
32
- * await userOps.get({ kt: 'user', pk: '123' });
33
- * await userOps.update({ kt: 'user', pk: '123' }, { name: 'Updated' });
34
- *
35
- * // No locations parameter on collection methods
36
- * await userOps.all({});
37
- * await userOps.find('byEmail', { email: 'test@example.com' });
38
- * await userOps.allAction('deactivate', { reason: 'inactive' });
39
- * ```
40
- */
41
- export interface PrimaryOperations<V extends Item<S>, S extends string> extends Omit<Operations<V, S>, 'all' | 'one' | 'create' | 'get' | 'update' | 'upsert' | 'remove' | 'find' | 'findOne' | 'action' | 'allAction' | 'facet' | 'allFacet'> {
42
- all(query?: ItemQuery, locations?: [], allOptions?: AllOptions): Promise<AllOperationResult<V>>;
43
- one(query?: ItemQuery): Promise<V | null>;
44
- find(finder: string, params?: OperationParams, locations?: [], options?: FindOptions): Promise<FindOperationResult<V>>;
45
- findOne(finder: string, params?: OperationParams): Promise<V | null>;
46
- create(item: Partial<Item<S>>, options?: {
47
- key?: PriKey<S>;
48
- }): Promise<V>;
49
- get(key: PriKey<S>): Promise<V | null>;
50
- update(key: PriKey<S>, item: Partial<Item<S>>): Promise<V>;
51
- upsert(key: PriKey<S>, item: Partial<Item<S>>): Promise<V>;
52
- remove(key: PriKey<S>): Promise<V | void>;
53
- action(key: PriKey<S>, action: string, params?: OperationParams): Promise<[V, AffectedKeys]>;
54
- allAction(action: string, params?: OperationParams): Promise<[V[], AffectedKeys]>;
55
- facet(key: PriKey<S>, facet: string, params?: OperationParams): Promise<any>;
56
- allFacet(facet: string, params?: OperationParams): Promise<any>;
57
- }
@@ -1,41 +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
- * Specialized Operations Interfaces
7
- *
8
- * This file contains operation interfaces for specific usage patterns.
9
- * These are primarily used in UI layers (like React providers) to group
10
- * operations by their usage pattern rather than data structure.
11
- *
12
- * For core architectural patterns (Primary vs. Contained), see:
13
- * - primary.ts - Operations for top-level items
14
- * - contained.ts - Operations for hierarchical items
15
- */
16
- /**
17
- * Collection-focused operations interface.
18
- * Optimized for working with groups of items.
19
- * Used by React providers for array/list contexts.
20
- */
21
- export interface CollectionOperations<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
22
- all(query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V[]>;
23
- one(query?: ItemQuery, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V | null>;
24
- find(finder: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V[]>;
25
- findOne(finder: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V | null>;
26
- create(item: Partial<Item<S, L1, L2, L3, L4, L5>>, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<V>;
27
- allAction(action: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<[V[], AffectedKeys]>;
28
- allFacet(facet: string, params?: OperationParams, locations?: LocKeyArray<L1, L2, L3, L4, L5> | []): Promise<any>;
29
- }
30
- /**
31
- * Instance-focused operations interface.
32
- * Optimized for working with a single specific item.
33
- * Used by React providers for single-item contexts.
34
- */
35
- export interface InstanceOperations<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
36
- get(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>): Promise<V | null>;
37
- update(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, item: Partial<Item<S, L1, L2, L3, L4, L5>>): Promise<V>;
38
- remove(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>): Promise<V | void>;
39
- action(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, action: string, params?: OperationParams): Promise<[V, AffectedKeys]>;
40
- facet(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, facet: string, params?: OperationParams): Promise<any>;
41
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * Item validation
3
- *
4
- * Validates that Item objects have correct key types and structures.
5
- */
6
- import type { Item } from "../items";
7
- import type { AllItemTypeArrays } from "../keys";
8
- /**
9
- * Validates that an item or array of items have the correct primary key type
10
- *
11
- * @param input - The item or array of items to validate
12
- * @param pkType - The expected primary key type
13
- * @returns The validated item(s)
14
- * @throws Error if any item is invalid or has wrong key type
15
- *
16
- * @example
17
- * ```typescript
18
- * // Validate single item
19
- * const item = validatePK(fetchedItem, 'product');
20
- *
21
- * // Validate array of items
22
- * const items = validatePK(fetchedItems, 'product');
23
- * ```
24
- */
25
- export declare const validatePK: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(input: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[], pkType: S) => Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[];
26
- /**
27
- * Validates that an item's key matches the expected key type array
28
- *
29
- * This is used to validate composite items where the key structure must match
30
- * the complete hierarchy (e.g., [product, store, region])
31
- *
32
- * @param item - The item to validate
33
- * @param keyTypes - The expected key type array
34
- * @returns The validated item
35
- * @throws Error if item is invalid or key types don't match
36
- *
37
- * @example
38
- * ```typescript
39
- * // Validate item has correct key structure
40
- * const item = validateKeys(fetchedItem, ['product', 'store']);
41
- * ```
42
- */
43
- export declare const validateKeys: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(item: Item<S, L1, L2, L3, L4, L5>, keyTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5>) => Item<S, L1, L2, L3, L4, L5>;
@@ -1,56 +0,0 @@
1
- /**
2
- * Key validation (PriKey, ComKey)
3
- *
4
- * Validates key structures and ensures keys match the expected library type.
5
- */
6
- import type { ComKey, PriKey } from "../keys";
7
- import type { Coordinate } from "../Coordinate";
8
- /**
9
- * Validates that a key is valid and matches the expected library type.
10
- *
11
- * This function performs comprehensive validation:
12
- * 1. Validates key type (PriKey vs ComKey) matches library type (primary vs composite)
13
- * 2. For composite keys, validates location key array order matches hierarchy
14
- * 3. Validates key structure is correct
15
- *
16
- * @param key - The key to validate
17
- * @param coordinate - The coordinate defining the library's key type hierarchy
18
- * @param operation - The operation name (for error messages)
19
- * @throws Error if key type doesn't match library type or location key array order is incorrect
20
- *
21
- * @example
22
- * ```typescript
23
- * // Validate a PriKey for a primary library
24
- * validateKey(
25
- * { kt: 'product', pk: '123' },
26
- * coordinate,
27
- * 'get'
28
- * );
29
- *
30
- * // Validate a ComKey for a composite library
31
- * validateKey(
32
- * { kt: 'product', pk: '123', loc: [{ kt: 'store', lk: '456' }] },
33
- * coordinate,
34
- * 'get'
35
- * );
36
- * ```
37
- */
38
- export declare const validateKey: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, operation: string) => void;
39
- /**
40
- * Validates a PriKey structure
41
- *
42
- * @param key - The primary key to validate
43
- * @param expectedType - The expected key type
44
- * @param operation - The operation name (for error messages)
45
- * @throws Error if key is invalid
46
- */
47
- export declare const validatePriKey: <S extends string>(key: PriKey<S>, expectedType: S, operation: string) => void;
48
- /**
49
- * Validates a ComKey structure
50
- *
51
- * @param key - The composite key to validate
52
- * @param coordinate - The coordinate defining the expected hierarchy
53
- * @param operation - The operation name (for error messages)
54
- * @throws Error if key is invalid
55
- */
56
- export declare const validateComKey: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(key: ComKey<S, L1, L2, L3, L4, L5>, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, operation: string) => void;
@@ -1,39 +0,0 @@
1
- /**
2
- * Location array validation
3
- *
4
- * Validates that LocKeyArray parameters match the expected Coordinate hierarchy.
5
- */
6
- import type { LocKeyArray } from "../keys";
7
- import type { Coordinate } from "../Coordinate";
8
- import type { ValidationResult } from "./types";
9
- /**
10
- * Validates that a standalone LocKeyArray parameter matches the expected hierarchy
11
- * defined by the coordinate's key type array (kta).
12
- *
13
- * This is used to validate the `locations` parameter passed to operations like
14
- * all(), find(), create(), etc.
15
- *
16
- * @param locations - The location key array to validate
17
- * @param coordinate - The coordinate defining the library's key type hierarchy
18
- * @param operation - The operation name (for error messages)
19
- * @throws Error if location key array order is incorrect
20
- *
21
- * @example
22
- * ```typescript
23
- * validateLocations(
24
- * [{kt: 'store', lk: '123'}],
25
- * coordinate,
26
- * 'find'
27
- * );
28
- * ```
29
- */
30
- export declare const validateLocations: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | undefined, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, operation: string) => void;
31
- /**
32
- * Non-throwing version of validateLocations that returns a ValidationResult
33
- *
34
- * @param locations - The location key array to validate
35
- * @param coordinate - The coordinate defining the library's key type hierarchy
36
- * @param operation - The operation name (for error messages)
37
- * @returns ValidationResult with valid flag and optional error message
38
- */
39
- export declare const isValidLocations: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | undefined, coordinate: Coordinate<S, L1, L2, L3, L4, L5>, operation: string) => ValidationResult;
@@ -1,57 +0,0 @@
1
- /**
2
- * Query and parameter validation
3
- *
4
- * Validates ItemQuery and OperationParams structures.
5
- */
6
- import type { ItemQuery } from "../item/ItemQuery";
7
- import type { OperationParams } from "../operations/Operations";
8
- /**
9
- * Validates that a query parameter is a valid ItemQuery object.
10
- *
11
- * @param query - The query to validate
12
- * @param operation - The operation name (for error messages)
13
- * @throws Error if query is invalid
14
- *
15
- * @example
16
- * ```typescript
17
- * validateQuery({ filter: { status: 'active' } }, 'one');
18
- * ```
19
- */
20
- export declare const validateQuery: (query: ItemQuery | undefined, operation: string) => void;
21
- /**
22
- * Validates that operation parameters are valid.
23
- *
24
- * @param params - The parameters to validate
25
- * @param operation - The operation name (for error messages)
26
- * @throws Error if parameters are invalid
27
- *
28
- * @example
29
- * ```typescript
30
- * validateOperationParams({ email: 'test@example.com' }, 'find');
31
- * ```
32
- */
33
- export declare const validateOperationParams: (params: OperationParams | undefined, operation: string) => void;
34
- /**
35
- * Validates that a finder name is valid.
36
- *
37
- * @param finder - The finder name to validate
38
- * @param operation - The operation name (for error messages)
39
- * @throws Error if finder name is invalid
40
- */
41
- export declare const validateFinderName: (finder: string | undefined, operation: string) => void;
42
- /**
43
- * Validates that an action name is valid.
44
- *
45
- * @param action - The action name to validate
46
- * @param operation - The operation name (for error messages)
47
- * @throws Error if action name is invalid
48
- */
49
- export declare const validateActionName: (action: string | undefined, operation: string) => void;
50
- /**
51
- * Validates that a facet name is valid.
52
- *
53
- * @param facet - The facet name to validate
54
- * @param operation - The operation name (for error messages)
55
- * @throws Error if facet name is invalid
56
- */
57
- export declare const validateFacetName: (facet: string | undefined, operation: string) => void;
@@ -1,17 +0,0 @@
1
- /**
2
- * Validation module
3
- *
4
- * Provides centralized validation functions for:
5
- * - Location arrays (LocKeyArray validation against Coordinate hierarchy)
6
- * - Keys (PriKey, ComKey validation)
7
- * - Items (Item key type validation)
8
- * - Queries (ItemQuery validation)
9
- * - Operation parameters (OperationParams validation)
10
- * - Schema validation (Zod, Yup, etc.)
11
- */
12
- export type { ValidationOptions, ValidationResult, SchemaValidator } from './types';
13
- export { validateLocations, isValidLocations } from './LocationValidator';
14
- export { validateKey, validatePriKey, validateComKey } from './KeyValidator';
15
- export { validatePK, validateKeys } from './ItemValidator';
16
- export { validateQuery, validateOperationParams, validateFinderName, validateActionName, validateFacetName } from './QueryValidator';
17
- export { validateSchema } from './schema';