@fjell/core 4.4.50 → 4.4.51

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,250 +0,0 @@
1
- /**
2
- * Query and parameter validation
3
- *
4
- * Validates ItemQuery and OperationParams structures.
5
- */
6
-
7
- import type { ItemQuery } from "../item/ItemQuery";
8
- import type { OperationParams } from "../operations/Operations";
9
- import LibLogger from "../logger";
10
-
11
- const logger = LibLogger.get('validation', 'QueryValidator');
12
-
13
- /**
14
- * Validates that a query parameter is a valid ItemQuery object.
15
- *
16
- * @param query - The query to validate
17
- * @param operation - The operation name (for error messages)
18
- * @throws Error if query is invalid
19
- *
20
- * @example
21
- * ```typescript
22
- * validateQuery({ filter: { status: 'active' } }, 'one');
23
- * ```
24
- */
25
- export const validateQuery = (
26
- query: ItemQuery | undefined,
27
- operation: string
28
- ): void => {
29
- // undefined and null are allowed - they default to empty query
30
- if (typeof query === 'undefined' || query === null) {
31
- return;
32
- }
33
-
34
- if (typeof query !== 'object') {
35
- logger.error(`Invalid query type for ${operation}`, { query, type: typeof query });
36
- throw new Error(
37
- `[${operation}] Invalid query parameter.\n` +
38
- `\n` +
39
- `Expected: object or undefined\n` +
40
- `Received: ${typeof query}\n` +
41
- `\n` +
42
- `Example valid queries:\n` +
43
- ` {}\n` +
44
- ` { filter: { status: 'active' } }\n` +
45
- ` { limit: 10, sort: { field: 'name', order: 'asc' } }`
46
- );
47
- }
48
-
49
- if (Array.isArray(query)) {
50
- logger.error(`Query cannot be an array for ${operation}`, { query });
51
- throw new Error(
52
- `[${operation}] Invalid query parameter.\n` +
53
- `\n` +
54
- `Query cannot be an array.\n` +
55
- `Received: ${JSON.stringify(query)}`
56
- );
57
- }
58
-
59
- logger.debug(`Query validation passed for ${operation}`, { query });
60
- };
61
-
62
- /**
63
- * Validates that operation parameters are valid.
64
- *
65
- * @param params - The parameters to validate
66
- * @param operation - The operation name (for error messages)
67
- * @throws Error if parameters are invalid
68
- *
69
- * @example
70
- * ```typescript
71
- * validateOperationParams({ email: 'test@example.com' }, 'find');
72
- * ```
73
- */
74
- export const validateOperationParams = (
75
- params: OperationParams | undefined,
76
- operation: string
77
- ): void => {
78
- // undefined is allowed - defaults to empty params
79
- if (typeof params === 'undefined') {
80
- return;
81
- }
82
-
83
- // null is not valid - must be object or undefined
84
- if (params === null) {
85
- logger.error(`Params cannot be null for ${operation}`, { params });
86
- throw new Error(
87
- `[${operation}] Invalid operation parameters.\n` +
88
- `\n` +
89
- `Parameters cannot be null.\n` +
90
- `Expected: object or undefined\n` +
91
- `Received: null\n` +
92
- `\n` +
93
- `Example valid parameters:\n` +
94
- ` {}\n` +
95
- ` { email: 'user@example.com' }\n` +
96
- ` { status: 'active', limit: 10 }`
97
- );
98
- }
99
-
100
- if (typeof params !== 'object') {
101
- logger.error(`Invalid params type for ${operation}`, { params, type: typeof params });
102
- throw new Error(
103
- `[${operation}] Invalid operation parameters.\n` +
104
- `\n` +
105
- `Expected: object or undefined\n` +
106
- `Received: ${typeof params}\n` +
107
- `\n` +
108
- `Example valid parameters:\n` +
109
- ` {}\n` +
110
- ` { email: 'user@example.com' }\n` +
111
- ` { status: 'active', limit: 10 }`
112
- );
113
- }
114
-
115
- if (Array.isArray(params)) {
116
- logger.error(`Params cannot be an array for ${operation}`, { params });
117
- throw new Error(
118
- `[${operation}] Invalid operation parameters.\n` +
119
- `\n` +
120
- `Parameters cannot be an array.\n` +
121
- `Received: ${JSON.stringify(params)}`
122
- );
123
- }
124
-
125
- // Validate parameter values are of allowed types
126
- for (const [key, value] of Object.entries(params)) {
127
- const valueType = typeof value;
128
- const isValidType =
129
- valueType === 'string' ||
130
- valueType === 'number' ||
131
- valueType === 'boolean' ||
132
- value instanceof Date ||
133
- (Array.isArray(value) && value.every(v =>
134
- typeof v === 'string' ||
135
- typeof v === 'number' ||
136
- typeof v === 'boolean' ||
137
- v instanceof Date
138
- ));
139
-
140
- if (!isValidType) {
141
- logger.error(`Invalid param value type for ${operation}`, { key, value, valueType });
142
- throw new Error(
143
- `[${operation}] Invalid value type for parameter "${key}".\n` +
144
- `\n` +
145
- `Allowed types: string, number, boolean, Date, or arrays of these types\n` +
146
- `Received: ${valueType}\n` +
147
- `Value: ${JSON.stringify(value)}`
148
- );
149
- }
150
- }
151
-
152
- logger.debug(`Operation params validation passed for ${operation}`, { params });
153
- };
154
-
155
- /**
156
- * Validates that a finder name is valid.
157
- *
158
- * @param finder - The finder name to validate
159
- * @param operation - The operation name (for error messages)
160
- * @throws Error if finder name is invalid
161
- */
162
- export const validateFinderName = (
163
- finder: string | undefined,
164
- operation: string
165
- ): void => {
166
- if (!finder || typeof finder !== 'string') {
167
- logger.error(`Invalid finder name for ${operation}`, { finder, type: typeof finder });
168
- throw new Error(
169
- `[${operation}] Finder name must be a non-empty string.\n` +
170
- `\n` +
171
- `Received: ${JSON.stringify(finder)}`
172
- );
173
- }
174
-
175
- if (finder.trim().length === 0) {
176
- logger.error(`Empty finder name for ${operation}`, { finder });
177
- throw new Error(
178
- `[${operation}] Finder name cannot be empty or whitespace only.\n` +
179
- `\n` +
180
- `Received: "${finder}"`
181
- );
182
- }
183
-
184
- logger.debug(`Finder name validation passed for ${operation}`, { finder });
185
- };
186
-
187
- /**
188
- * Validates that an action name is valid.
189
- *
190
- * @param action - The action name to validate
191
- * @param operation - The operation name (for error messages)
192
- * @throws Error if action name is invalid
193
- */
194
- export const validateActionName = (
195
- action: string | undefined,
196
- operation: string
197
- ): void => {
198
- if (!action || typeof action !== 'string') {
199
- logger.error(`Invalid action name for ${operation}`, { action, type: typeof action });
200
- throw new Error(
201
- `[${operation}] Action name must be a non-empty string.\n` +
202
- `\n` +
203
- `Received: ${JSON.stringify(action)}`
204
- );
205
- }
206
-
207
- if (action.trim().length === 0) {
208
- logger.error(`Empty action name for ${operation}`, { action });
209
- throw new Error(
210
- `[${operation}] Action name cannot be empty or whitespace only.\n` +
211
- `\n` +
212
- `Received: "${action}"`
213
- );
214
- }
215
-
216
- logger.debug(`Action name validation passed for ${operation}`, { action });
217
- };
218
-
219
- /**
220
- * Validates that a facet name is valid.
221
- *
222
- * @param facet - The facet name to validate
223
- * @param operation - The operation name (for error messages)
224
- * @throws Error if facet name is invalid
225
- */
226
- export const validateFacetName = (
227
- facet: string | undefined,
228
- operation: string
229
- ): void => {
230
- if (!facet || typeof facet !== 'string') {
231
- logger.error(`Invalid facet name for ${operation}`, { facet, type: typeof facet });
232
- throw new Error(
233
- `[${operation}] Facet name must be a non-empty string.\n` +
234
- `\n` +
235
- `Received: ${JSON.stringify(facet)}`
236
- );
237
- }
238
-
239
- if (facet.trim().length === 0) {
240
- logger.error(`Empty facet name for ${operation}`, { facet });
241
- throw new Error(
242
- `[${operation}] Facet name cannot be empty or whitespace only.\n` +
243
- `\n` +
244
- `Received: "${facet}"`
245
- );
246
- }
247
-
248
- logger.debug(`Facet name validation passed for ${operation}`, { facet });
249
- };
250
-
@@ -1,32 +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
- */
11
-
12
- // Types
13
- export type { ValidationOptions, ValidationResult } from './types';
14
-
15
- // Location validation
16
- export { validateLocations, isValidLocations } from './LocationValidator';
17
-
18
- // Key validation
19
- export { validateKey, validatePriKey, validateComKey } from './KeyValidator';
20
-
21
- // Item validation
22
- export { validatePK, validateKeys } from './ItemValidator';
23
-
24
- // Query and parameter validation
25
- export {
26
- validateQuery,
27
- validateOperationParams,
28
- validateFinderName,
29
- validateActionName,
30
- validateFacetName
31
- } from './QueryValidator';
32
-
@@ -1,45 +0,0 @@
1
- /**
2
- * Shared validation types and options
3
- */
4
-
5
- /**
6
- * Options for validation functions
7
- */
8
- export interface ValidationOptions {
9
- /**
10
- * Custom error message prefix
11
- */
12
- errorPrefix?: string;
13
-
14
- /**
15
- * Whether to allow undefined (treated as empty array for location validation)
16
- */
17
- allowUndefined?: boolean;
18
-
19
- /**
20
- * Whether to throw errors or return validation results
21
- * @default true
22
- */
23
- throwOnError?: boolean;
24
- }
25
-
26
- /**
27
- * Result of a validation operation (for non-throwing mode)
28
- */
29
- export interface ValidationResult {
30
- /**
31
- * Whether validation passed
32
- */
33
- valid: boolean;
34
-
35
- /**
36
- * Error message if validation failed
37
- */
38
- error?: string;
39
-
40
- /**
41
- * Detailed validation context
42
- */
43
- context?: Record<string, unknown>;
44
- }
45
-