@fjell/core 4.4.48 → 4.4.50
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 +92 -0
- package/dist/Coordinate.d.ts +7 -0
- package/dist/errors/ActionError.d.ts +51 -0
- package/dist/errors/BusinessLogicError.d.ts +4 -0
- package/dist/errors/DuplicateError.d.ts +4 -0
- package/dist/errors/NotFoundError.d.ts +4 -0
- package/dist/errors/PermissionError.d.ts +4 -0
- package/dist/errors/ValidationError.d.ts +4 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/event/emitter.d.ts +140 -0
- package/dist/event/events.d.ts +81 -0
- package/dist/event/index.d.ts +38 -0
- package/dist/event/matching.d.ts +54 -0
- package/dist/event/subscription.d.ts +74 -0
- package/dist/event/types.d.ts +186 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1584 -47
- package/dist/item/IUtils.d.ts +6 -3
- package/dist/operations/OperationContext.d.ts +10 -0
- package/dist/operations/Operations.d.ts +259 -0
- package/dist/operations/contained.d.ts +65 -0
- package/dist/operations/errorEnhancer.d.ts +79 -0
- package/dist/operations/index.d.ts +2 -0
- package/dist/operations/methods.d.ts +134 -0
- package/dist/operations/primary.d.ts +57 -0
- package/dist/operations/specialized.d.ts +41 -0
- package/dist/operations/wrappers/createActionWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createAllActionWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createAllFacetWrapper.d.ts +27 -0
- package/dist/operations/wrappers/createAllWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createCreateWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createFacetWrapper.d.ts +27 -0
- package/dist/operations/wrappers/createFindOneWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createFindWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createGetWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createOneWrapper.d.ts +38 -0
- package/dist/operations/wrappers/createRemoveWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createUpdateWrapper.d.ts +28 -0
- package/dist/operations/wrappers/createUpsertWrapper.d.ts +28 -0
- package/dist/operations/wrappers/index.d.ts +34 -0
- package/dist/operations/wrappers/types.d.ts +48 -0
- package/dist/validation/ItemValidator.d.ts +43 -0
- package/dist/validation/KeyValidator.d.ts +56 -0
- package/dist/validation/LocationValidator.d.ts +39 -0
- package/dist/validation/QueryValidator.d.ts +57 -0
- package/dist/validation/index.d.ts +15 -0
- package/dist/validation/index.js +501 -0
- package/dist/validation/types.d.ts +38 -0
- package/package.json +7 -2
- package/src/Coordinate.ts +35 -0
- package/src/errors/ActionError.ts +69 -0
- package/src/errors/BusinessLogicError.ts +24 -0
- package/src/errors/DuplicateError.ts +57 -0
- package/src/errors/NotFoundError.ts +24 -0
- package/src/errors/PermissionError.ts +31 -0
- package/src/errors/ValidationError.ts +27 -0
- package/src/errors/index.ts +7 -0
- package/src/event/emitter.ts +247 -0
- package/src/event/events.ts +178 -0
- package/src/event/index.ts +130 -0
- package/src/event/matching.ts +264 -0
- package/src/event/subscription.ts +181 -0
- package/src/event/types.ts +282 -0
- package/src/index.ts +57 -0
- package/src/item/IUtils.ts +9 -80
- package/src/operations/OperationContext.ts +12 -0
- package/src/operations/Operations.ts +357 -0
- package/src/operations/contained.ts +134 -0
- package/src/operations/errorEnhancer.ts +204 -0
- package/src/operations/index.ts +2 -0
- package/src/operations/methods.ts +363 -0
- package/src/operations/primary.ts +101 -0
- package/src/operations/specialized.ts +71 -0
- package/src/operations/wrappers/createActionWrapper.ts +108 -0
- package/src/operations/wrappers/createAllActionWrapper.ts +109 -0
- package/src/operations/wrappers/createAllFacetWrapper.ts +98 -0
- package/src/operations/wrappers/createAllWrapper.ts +103 -0
- package/src/operations/wrappers/createCreateWrapper.ts +117 -0
- package/src/operations/wrappers/createFacetWrapper.ts +97 -0
- package/src/operations/wrappers/createFindOneWrapper.ts +105 -0
- package/src/operations/wrappers/createFindWrapper.ts +105 -0
- package/src/operations/wrappers/createGetWrapper.ts +96 -0
- package/src/operations/wrappers/createOneWrapper.ts +128 -0
- package/src/operations/wrappers/createRemoveWrapper.ts +91 -0
- package/src/operations/wrappers/createUpdateWrapper.ts +106 -0
- package/src/operations/wrappers/createUpsertWrapper.ts +108 -0
- package/src/operations/wrappers/index.ts +39 -0
- package/src/operations/wrappers/types.ts +63 -0
- package/src/validation/ItemValidator.ts +131 -0
- package/src/validation/KeyValidator.ts +365 -0
- package/src/validation/LocationValidator.ts +136 -0
- package/src/validation/QueryValidator.ts +250 -0
- package/src/validation/index.ts +32 -0
- package/src/validation/types.ts +45 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { BaseEvent } from './events';
|
|
2
|
+
import { Subscription } from './subscription';
|
|
3
|
+
/**
|
|
4
|
+
* Common event types used throughout the event system.
|
|
5
|
+
* Libraries can extend these with custom event types as needed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const STANDARD_EVENT_TYPES: {
|
|
8
|
+
readonly CREATE: "create";
|
|
9
|
+
readonly UPDATE: "update";
|
|
10
|
+
readonly DELETE: "delete";
|
|
11
|
+
readonly ACTION: "action";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Type for standard event type values.
|
|
15
|
+
*/
|
|
16
|
+
export type StandardEventType = typeof STANDARD_EVENT_TYPES[keyof typeof STANDARD_EVENT_TYPES];
|
|
17
|
+
/**
|
|
18
|
+
* Common scope identifiers used by storage libraries.
|
|
19
|
+
* Libraries should use these standard scopes for consistency.
|
|
20
|
+
*/
|
|
21
|
+
export declare const STANDARD_SCOPES: {
|
|
22
|
+
readonly FIRESTORE: "firestore";
|
|
23
|
+
readonly SEQUELIZE: "sequelize";
|
|
24
|
+
readonly POSTGRESQL: "postgresql";
|
|
25
|
+
readonly MYSQL: "mysql";
|
|
26
|
+
readonly MONGODB: "mongodb";
|
|
27
|
+
readonly REDIS: "redis";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Type for standard scope values.
|
|
31
|
+
*/
|
|
32
|
+
export type StandardScope = typeof STANDARD_SCOPES[keyof typeof STANDARD_SCOPES];
|
|
33
|
+
/**
|
|
34
|
+
* Status of a subscription.
|
|
35
|
+
* Used to track subscription lifecycle and health.
|
|
36
|
+
*/
|
|
37
|
+
export declare enum SubscriptionStatus {
|
|
38
|
+
PENDING = "pending",// Subscription created but not yet active
|
|
39
|
+
ACTIVE = "active",// Subscription is active and receiving events
|
|
40
|
+
PAUSED = "paused",// Subscription is paused (not receiving events)
|
|
41
|
+
ERROR = "error",// Subscription has encountered an error
|
|
42
|
+
CANCELLED = "cancelled"
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Metadata about a subscription's current state.
|
|
46
|
+
* Used for monitoring and debugging subscription health.
|
|
47
|
+
*/
|
|
48
|
+
export interface SubscriptionMetadata {
|
|
49
|
+
/** Current status of the subscription */
|
|
50
|
+
status: SubscriptionStatus;
|
|
51
|
+
/** When the subscription was created */
|
|
52
|
+
createdAt: Date;
|
|
53
|
+
/** When the subscription was last updated */
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
/** When the subscription last received an event */
|
|
56
|
+
lastEventAt?: Date;
|
|
57
|
+
/** Total number of events received by this subscription */
|
|
58
|
+
eventCount: number;
|
|
59
|
+
/** Any error that occurred with this subscription */
|
|
60
|
+
lastError?: Error;
|
|
61
|
+
/** Additional metadata specific to the storage implementation */
|
|
62
|
+
implementationMetadata?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Enhanced subscription interface that includes metadata.
|
|
66
|
+
* Used internally by libraries for subscription management.
|
|
67
|
+
*/
|
|
68
|
+
export type ManagedSubscription<S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> = Subscription<S, L1, L2, L3, L4, L5> & {
|
|
69
|
+
/** Metadata about this subscription's state */
|
|
70
|
+
metadata: SubscriptionMetadata;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Event handler function type.
|
|
74
|
+
* Used for type-safe event callbacks.
|
|
75
|
+
*/
|
|
76
|
+
export type EventHandler<S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> = (event: BaseEvent<S, L1, L2, L3, L4, L5>) => void | Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Event handler with error handling.
|
|
79
|
+
* Allows handlers to indicate success/failure for better error tracking.
|
|
80
|
+
*/
|
|
81
|
+
export type SafeEventHandler<S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> = (event: BaseEvent<S, L1, L2, L3, L4, L5>) => Promise<{
|
|
82
|
+
success: boolean;
|
|
83
|
+
error?: Error;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Batch of events for efficient processing.
|
|
87
|
+
* Used when multiple events need to be processed together.
|
|
88
|
+
*/
|
|
89
|
+
export interface EventBatch<S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
|
|
90
|
+
/** Events in this batch */
|
|
91
|
+
events: BaseEvent<S, L1, L2, L3, L4, L5>[];
|
|
92
|
+
/** When this batch was created */
|
|
93
|
+
createdAt: Date;
|
|
94
|
+
/** Optional: transaction ID if these events are part of a transaction */
|
|
95
|
+
transactionId?: string;
|
|
96
|
+
/** Optional: batch metadata */
|
|
97
|
+
metadata?: Record<string, unknown>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Statistics about event processing.
|
|
101
|
+
* Used for monitoring and performance analysis.
|
|
102
|
+
*/
|
|
103
|
+
export interface EventStats {
|
|
104
|
+
/** Total events processed */
|
|
105
|
+
totalEvents: number;
|
|
106
|
+
/** Events processed by type */
|
|
107
|
+
eventsByType: Record<string, number>;
|
|
108
|
+
/** Events processed by scope */
|
|
109
|
+
eventsByScope: Record<string, number>;
|
|
110
|
+
/** Average event processing time in milliseconds */
|
|
111
|
+
averageProcessingTime: number;
|
|
112
|
+
/** Number of active subscriptions */
|
|
113
|
+
activeSubscriptions: number;
|
|
114
|
+
/** Number of failed event deliveries */
|
|
115
|
+
failedDeliveries: number;
|
|
116
|
+
/** When these stats were last updated */
|
|
117
|
+
lastUpdated: Date;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Configuration for event system behavior.
|
|
121
|
+
* Used by libraries to customize event processing.
|
|
122
|
+
*/
|
|
123
|
+
export interface EventSystemConfig {
|
|
124
|
+
/** Maximum number of events to batch together */
|
|
125
|
+
maxBatchSize?: number;
|
|
126
|
+
/** Maximum time to wait before processing a batch (milliseconds) */
|
|
127
|
+
maxBatchWaitTime?: number;
|
|
128
|
+
/** Maximum number of retry attempts for failed event deliveries */
|
|
129
|
+
maxRetryAttempts?: number;
|
|
130
|
+
/** Delay between retry attempts (milliseconds) */
|
|
131
|
+
retryDelay?: number;
|
|
132
|
+
/** Whether to enable event statistics collection */
|
|
133
|
+
enableStats?: boolean;
|
|
134
|
+
/** Maximum number of subscriptions to allow */
|
|
135
|
+
maxSubscriptions?: number;
|
|
136
|
+
/** Cleanup interval for inactive subscriptions (milliseconds) */
|
|
137
|
+
subscriptionCleanupInterval?: number;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Default configuration values.
|
|
141
|
+
* Libraries can use these as defaults and override as needed.
|
|
142
|
+
*/
|
|
143
|
+
export declare const DEFAULT_EVENT_CONFIG: Required<EventSystemConfig>;
|
|
144
|
+
/**
|
|
145
|
+
* Error types specific to the event system.
|
|
146
|
+
* Used for better error handling and debugging.
|
|
147
|
+
*/
|
|
148
|
+
export declare class EventSystemError extends Error {
|
|
149
|
+
readonly code: string;
|
|
150
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
151
|
+
constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
|
|
152
|
+
}
|
|
153
|
+
export declare class SubscriptionError extends EventSystemError {
|
|
154
|
+
readonly subscriptionId: string;
|
|
155
|
+
constructor(message: string, subscriptionId: string, details?: Record<string, unknown>);
|
|
156
|
+
}
|
|
157
|
+
export declare class EventEmissionError extends EventSystemError {
|
|
158
|
+
readonly eventType: string;
|
|
159
|
+
constructor(message: string, eventType: string, details?: Record<string, unknown>);
|
|
160
|
+
}
|
|
161
|
+
export declare class EventMatchingError extends EventSystemError {
|
|
162
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Utility function to create standardized error messages.
|
|
166
|
+
*/
|
|
167
|
+
export declare function createEventSystemError(type: 'subscription' | 'emission' | 'matching' | 'general', message: string, details?: Record<string, unknown>): EventSystemError;
|
|
168
|
+
/**
|
|
169
|
+
* Utility function to check if an error is an EventSystemError.
|
|
170
|
+
*/
|
|
171
|
+
export declare function isEventSystemError(error: unknown): error is EventSystemError;
|
|
172
|
+
/**
|
|
173
|
+
* Utility type for extracting the item type from an event.
|
|
174
|
+
*/
|
|
175
|
+
export type ExtractItemType<T> = T extends BaseEvent<infer S, any, any, any, any, any> ? S : never;
|
|
176
|
+
/**
|
|
177
|
+
* Utility type for extracting all type parameters from an event.
|
|
178
|
+
*/
|
|
179
|
+
export type ExtractEventTypes<T> = T extends BaseEvent<infer S, infer L1, infer L2, infer L3, infer L4, infer L5> ? {
|
|
180
|
+
S: S;
|
|
181
|
+
L1: L1;
|
|
182
|
+
L2: L2;
|
|
183
|
+
L3: L3;
|
|
184
|
+
L4: L4;
|
|
185
|
+
L5: L5;
|
|
186
|
+
} : never;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./dictionary";
|
|
2
2
|
export * from "./keys";
|
|
3
3
|
export * from "./items";
|
|
4
|
+
export * from "./Coordinate";
|
|
5
|
+
export * from "./Coordinate";
|
|
4
6
|
export { IFactory } from "./item/IFactory";
|
|
5
7
|
export { AItemService } from "./AItemService";
|
|
6
8
|
export * from './key/KUtils';
|
|
@@ -9,3 +11,14 @@ export * from './item/IQFactory';
|
|
|
9
11
|
export * from './item/IQUtils';
|
|
10
12
|
export * from './item/IUtils';
|
|
11
13
|
export * from './item/ItemQuery';
|
|
14
|
+
export * from './validation';
|
|
15
|
+
export * from './errors';
|
|
16
|
+
export * from './operations';
|
|
17
|
+
export * from './event';
|
|
18
|
+
export type { Operations, OperationParams, AffectedKeys, CreateOptions } from './operations/Operations';
|
|
19
|
+
export { isPriKey as isOperationPriKey, isComKey as isOperationComKey } from './operations/Operations';
|
|
20
|
+
export type { GetMethod, CreateMethod, UpdateMethod, RemoveMethod, UpsertMethod, AllMethod, OneMethod, FindMethod, FindOneMethod, FinderMethod, ActionMethod, ActionOperationMethod, AllActionMethod, AllActionOperationMethod, FacetMethod, FacetOperationMethod, AllFacetMethod, AllFacetOperationMethod, OperationsExtensions } from './operations/methods';
|
|
21
|
+
export * from './operations/wrappers';
|
|
22
|
+
export type { PrimaryOperations } from './operations/primary';
|
|
23
|
+
export type { ContainedOperations } from './operations/contained';
|
|
24
|
+
export type { CollectionOperations, InstanceOperations } from './operations/specialized';
|