@objectstack/core 1.0.4 → 1.0.6

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 (127) hide show
  1. package/.turbo/turbo-build.log +22 -0
  2. package/CHANGELOG.md +19 -0
  3. package/dist/index.cjs +4304 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +1777 -0
  6. package/dist/index.d.ts +1776 -21
  7. package/dist/index.js +4246 -23
  8. package/dist/index.js.map +1 -0
  9. package/package.json +5 -5
  10. package/src/logger.ts +2 -2
  11. package/src/security/plugin-signature-verifier.ts +12 -11
  12. package/tsconfig.json +1 -3
  13. package/dist/api-registry-plugin.d.ts +0 -54
  14. package/dist/api-registry-plugin.d.ts.map +0 -1
  15. package/dist/api-registry-plugin.js +0 -53
  16. package/dist/api-registry-plugin.test.d.ts +0 -2
  17. package/dist/api-registry-plugin.test.d.ts.map +0 -1
  18. package/dist/api-registry-plugin.test.js +0 -334
  19. package/dist/api-registry.d.ts +0 -259
  20. package/dist/api-registry.d.ts.map +0 -1
  21. package/dist/api-registry.js +0 -600
  22. package/dist/api-registry.test.d.ts +0 -2
  23. package/dist/api-registry.test.d.ts.map +0 -1
  24. package/dist/api-registry.test.js +0 -957
  25. package/dist/contracts/data-engine.d.ts +0 -62
  26. package/dist/contracts/data-engine.d.ts.map +0 -1
  27. package/dist/contracts/data-engine.js +0 -1
  28. package/dist/contracts/http-server.d.ts +0 -119
  29. package/dist/contracts/http-server.d.ts.map +0 -1
  30. package/dist/contracts/http-server.js +0 -11
  31. package/dist/contracts/logger.d.ts +0 -63
  32. package/dist/contracts/logger.d.ts.map +0 -1
  33. package/dist/contracts/logger.js +0 -1
  34. package/dist/dependency-resolver.d.ts +0 -62
  35. package/dist/dependency-resolver.d.ts.map +0 -1
  36. package/dist/dependency-resolver.js +0 -317
  37. package/dist/dependency-resolver.test.d.ts +0 -2
  38. package/dist/dependency-resolver.test.d.ts.map +0 -1
  39. package/dist/dependency-resolver.test.js +0 -241
  40. package/dist/health-monitor.d.ts +0 -65
  41. package/dist/health-monitor.d.ts.map +0 -1
  42. package/dist/health-monitor.js +0 -269
  43. package/dist/health-monitor.test.d.ts +0 -2
  44. package/dist/health-monitor.test.d.ts.map +0 -1
  45. package/dist/health-monitor.test.js +0 -68
  46. package/dist/hot-reload.d.ts +0 -79
  47. package/dist/hot-reload.d.ts.map +0 -1
  48. package/dist/hot-reload.js +0 -313
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/kernel-base.d.ts +0 -84
  51. package/dist/kernel-base.d.ts.map +0 -1
  52. package/dist/kernel-base.js +0 -219
  53. package/dist/kernel.d.ts +0 -113
  54. package/dist/kernel.d.ts.map +0 -1
  55. package/dist/kernel.js +0 -472
  56. package/dist/kernel.test.d.ts +0 -2
  57. package/dist/kernel.test.d.ts.map +0 -1
  58. package/dist/kernel.test.js +0 -414
  59. package/dist/lite-kernel.d.ts +0 -55
  60. package/dist/lite-kernel.d.ts.map +0 -1
  61. package/dist/lite-kernel.js +0 -112
  62. package/dist/lite-kernel.test.d.ts +0 -2
  63. package/dist/lite-kernel.test.d.ts.map +0 -1
  64. package/dist/lite-kernel.test.js +0 -161
  65. package/dist/logger.d.ts +0 -71
  66. package/dist/logger.d.ts.map +0 -1
  67. package/dist/logger.js +0 -312
  68. package/dist/logger.test.d.ts +0 -2
  69. package/dist/logger.test.d.ts.map +0 -1
  70. package/dist/logger.test.js +0 -92
  71. package/dist/plugin-loader.d.ts +0 -164
  72. package/dist/plugin-loader.d.ts.map +0 -1
  73. package/dist/plugin-loader.js +0 -319
  74. package/dist/plugin-loader.test.d.ts +0 -2
  75. package/dist/plugin-loader.test.d.ts.map +0 -1
  76. package/dist/plugin-loader.test.js +0 -348
  77. package/dist/qa/adapter.d.ts +0 -14
  78. package/dist/qa/adapter.d.ts.map +0 -1
  79. package/dist/qa/adapter.js +0 -1
  80. package/dist/qa/http-adapter.d.ts +0 -16
  81. package/dist/qa/http-adapter.d.ts.map +0 -1
  82. package/dist/qa/http-adapter.js +0 -107
  83. package/dist/qa/index.d.ts +0 -4
  84. package/dist/qa/index.d.ts.map +0 -1
  85. package/dist/qa/index.js +0 -3
  86. package/dist/qa/runner.d.ts +0 -27
  87. package/dist/qa/runner.d.ts.map +0 -1
  88. package/dist/qa/runner.js +0 -157
  89. package/dist/security/index.d.ts +0 -17
  90. package/dist/security/index.d.ts.map +0 -1
  91. package/dist/security/index.js +0 -17
  92. package/dist/security/permission-manager.d.ts +0 -96
  93. package/dist/security/permission-manager.d.ts.map +0 -1
  94. package/dist/security/permission-manager.js +0 -235
  95. package/dist/security/permission-manager.test.d.ts +0 -2
  96. package/dist/security/permission-manager.test.d.ts.map +0 -1
  97. package/dist/security/permission-manager.test.js +0 -220
  98. package/dist/security/plugin-config-validator.d.ts +0 -79
  99. package/dist/security/plugin-config-validator.d.ts.map +0 -1
  100. package/dist/security/plugin-config-validator.js +0 -166
  101. package/dist/security/plugin-config-validator.test.d.ts +0 -2
  102. package/dist/security/plugin-config-validator.test.d.ts.map +0 -1
  103. package/dist/security/plugin-config-validator.test.js +0 -223
  104. package/dist/security/plugin-permission-enforcer.d.ts +0 -154
  105. package/dist/security/plugin-permission-enforcer.d.ts.map +0 -1
  106. package/dist/security/plugin-permission-enforcer.js +0 -323
  107. package/dist/security/plugin-permission-enforcer.test.d.ts +0 -2
  108. package/dist/security/plugin-permission-enforcer.test.d.ts.map +0 -1
  109. package/dist/security/plugin-permission-enforcer.test.js +0 -205
  110. package/dist/security/plugin-signature-verifier.d.ts +0 -96
  111. package/dist/security/plugin-signature-verifier.d.ts.map +0 -1
  112. package/dist/security/plugin-signature-verifier.js +0 -250
  113. package/dist/security/sandbox-runtime.d.ts +0 -115
  114. package/dist/security/sandbox-runtime.d.ts.map +0 -1
  115. package/dist/security/sandbox-runtime.js +0 -311
  116. package/dist/security/security-scanner.d.ts +0 -92
  117. package/dist/security/security-scanner.d.ts.map +0 -1
  118. package/dist/security/security-scanner.js +0 -273
  119. package/dist/types.d.ts +0 -89
  120. package/dist/types.d.ts.map +0 -1
  121. package/dist/types.js +0 -1
  122. package/dist/utils/env.d.ts +0 -20
  123. package/dist/utils/env.d.ts.map +0 -1
  124. package/dist/utils/env.js +0 -46
  125. package/dist/utils/env.test.d.ts +0 -2
  126. package/dist/utils/env.test.d.ts.map +0 -1
  127. package/dist/utils/env.test.js +0 -52
@@ -1,259 +0,0 @@
1
- import type { ApiRegistry as ApiRegistryType, ApiRegistryEntry, ApiRegistryEntryInput, ApiEndpointRegistration, ConflictResolutionStrategy, ApiDiscoveryQuery, ApiDiscoveryResponse } from '@objectstack/spec/api';
2
- import type { Logger } from '@objectstack/spec/contracts';
3
- /**
4
- * API Registry Service
5
- *
6
- * Central registry for managing API endpoints across different protocols.
7
- * Provides endpoint registration, discovery, and conflict resolution.
8
- *
9
- * **Features:**
10
- * - Multi-protocol support (REST, GraphQL, OData, WebSocket, etc.)
11
- * - Route conflict detection with configurable resolution strategies
12
- * - RBAC permission integration
13
- * - Dynamic schema linking with ObjectQL references
14
- * - Plugin API registration
15
- *
16
- * **Architecture Alignment:**
17
- * - Kubernetes: Service Discovery & API Server
18
- * - AWS API Gateway: Unified API Management
19
- * - Kong Gateway: Plugin-based API Management
20
- *
21
- * @example
22
- * ```typescript
23
- * const registry = new ApiRegistry(logger, 'priority');
24
- *
25
- * // Register an API
26
- * registry.registerApi({
27
- * id: 'customer_api',
28
- * name: 'Customer API',
29
- * type: 'rest',
30
- * version: 'v1',
31
- * basePath: '/api/v1/customers',
32
- * endpoints: [...]
33
- * });
34
- *
35
- * // Discover APIs
36
- * const apis = registry.findApis({ type: 'rest', status: 'active' });
37
- *
38
- * // Get registry snapshot
39
- * const snapshot = registry.getRegistry();
40
- * ```
41
- */
42
- export declare class ApiRegistry {
43
- private apis;
44
- private endpoints;
45
- private routes;
46
- private apisByType;
47
- private apisByTag;
48
- private apisByStatus;
49
- private conflictResolution;
50
- private logger;
51
- private version;
52
- private updatedAt;
53
- constructor(logger: Logger, conflictResolution?: ConflictResolutionStrategy, version?: string);
54
- /**
55
- * Register an API with its endpoints
56
- *
57
- * @param api - API registry entry
58
- * @throws Error if API already registered or route conflicts detected
59
- */
60
- registerApi(api: ApiRegistryEntryInput): void;
61
- /**
62
- * Unregister an API and all its endpoints
63
- *
64
- * @param apiId - API identifier
65
- */
66
- unregisterApi(apiId: string): void;
67
- /**
68
- * Register a single endpoint
69
- *
70
- * @param apiId - API identifier
71
- * @param endpoint - Endpoint registration
72
- * @throws Error if route conflict detected
73
- */
74
- private registerEndpoint;
75
- /**
76
- * Unregister a single endpoint
77
- *
78
- * @param apiId - API identifier
79
- * @param endpointId - Endpoint identifier
80
- */
81
- private unregisterEndpoint;
82
- /**
83
- * Register a route with conflict detection
84
- *
85
- * @param apiId - API identifier
86
- * @param endpoint - Endpoint registration
87
- * @throws Error if route conflict detected (based on strategy)
88
- */
89
- private registerRoute;
90
- /**
91
- * Handle route conflict based on resolution strategy
92
- *
93
- * @param routeKey - Route key
94
- * @param apiId - New API identifier
95
- * @param endpoint - New endpoint
96
- * @param existingRoute - Existing route registration
97
- * @param newPriority - New endpoint priority
98
- * @throws Error if strategy is 'error'
99
- */
100
- private handleRouteConflict;
101
- /**
102
- * Generate a unique route key for conflict detection
103
- *
104
- * NOTE: This implementation uses exact string matching for route conflict detection.
105
- * It works well for static paths but has limitations with parameterized routes.
106
- * For example, `/api/users/:id` and `/api/users/:userId` will NOT be detected as conflicts
107
- * even though they are semantically identical parameterized patterns. Similarly,
108
- * `/api/:resource/list` and `/api/:entity/list` would also not be detected as conflicting.
109
- *
110
- * For more advanced conflict detection (e.g., path-to-regexp pattern matching),
111
- * consider integrating with your routing library's conflict detection mechanism.
112
- *
113
- * @param endpoint - Endpoint registration
114
- * @returns Route key (e.g., "GET:/api/v1/customers/:id")
115
- */
116
- private getRouteKey;
117
- /**
118
- * Validate endpoint registration
119
- *
120
- * @param endpoint - Endpoint to validate
121
- * @param apiId - API identifier (for error messages)
122
- * @throws Error if endpoint is invalid
123
- */
124
- private validateEndpoint;
125
- /**
126
- * Get an API by ID
127
- *
128
- * @param apiId - API identifier
129
- * @returns API registry entry or undefined
130
- */
131
- getApi(apiId: string): ApiRegistryEntry | undefined;
132
- /**
133
- * Get all registered APIs
134
- *
135
- * @returns Array of all APIs
136
- */
137
- getAllApis(): ApiRegistryEntry[];
138
- /**
139
- * Find APIs matching query criteria
140
- *
141
- * Performance optimized with auxiliary indices for O(1) lookups on type, tags, and status.
142
- *
143
- * @param query - Discovery query parameters
144
- * @returns Matching APIs
145
- */
146
- findApis(query: ApiDiscoveryQuery): ApiDiscoveryResponse;
147
- /**
148
- * Get endpoint by API ID and endpoint ID
149
- *
150
- * @param apiId - API identifier
151
- * @param endpointId - Endpoint identifier
152
- * @returns Endpoint registration or undefined
153
- */
154
- getEndpoint(apiId: string, endpointId: string): ApiEndpointRegistration | undefined;
155
- /**
156
- * Find endpoint by route (method + path)
157
- *
158
- * @param method - HTTP method
159
- * @param path - URL path
160
- * @returns Endpoint registration or undefined
161
- */
162
- findEndpointByRoute(method: string, path: string): {
163
- api: ApiRegistryEntry;
164
- endpoint: ApiEndpointRegistration;
165
- } | undefined;
166
- /**
167
- * Get complete registry snapshot
168
- *
169
- * @returns Current registry state
170
- */
171
- getRegistry(): ApiRegistryType;
172
- /**
173
- * Clear all registered APIs
174
- *
175
- * **⚠️ SAFETY WARNING:**
176
- * This method clears all registered APIs and should be used with caution.
177
- *
178
- * **Usage Restrictions:**
179
- * - In production environments (NODE_ENV=production), a `force: true` parameter is required
180
- * - Primarily intended for testing and development hot-reload scenarios
181
- *
182
- * @param options - Clear options
183
- * @param options.force - Force clear in production environment (default: false)
184
- * @throws Error if called in production without force flag
185
- *
186
- * @example Safe usage in tests
187
- * ```typescript
188
- * beforeEach(() => {
189
- * registry.clear(); // OK in test environment
190
- * });
191
- * ```
192
- *
193
- * @example Usage in production (requires explicit force)
194
- * ```typescript
195
- * // In production, explicit force is required
196
- * registry.clear({ force: true });
197
- * ```
198
- */
199
- clear(options?: {
200
- force?: boolean;
201
- }): void;
202
- /**
203
- * Get registry statistics
204
- *
205
- * @returns Registry statistics
206
- */
207
- getStats(): {
208
- totalApis: number;
209
- totalEndpoints: number;
210
- totalRoutes: number;
211
- apisByType: Record<string, number>;
212
- endpointsByApi: Record<string, number>;
213
- };
214
- /**
215
- * Update auxiliary indices when an API is registered
216
- *
217
- * @param api - API entry to index
218
- * @private
219
- * @internal
220
- */
221
- private updateIndices;
222
- /**
223
- * Remove API from auxiliary indices when unregistered
224
- *
225
- * @param api - API entry to remove from indices
226
- * @private
227
- * @internal
228
- */
229
- private removeFromIndices;
230
- /**
231
- * Helper to ensure an index set exists and return it
232
- *
233
- * @param map - Index map
234
- * @param key - Index key
235
- * @returns The Set for this key (created if needed)
236
- * @private
237
- * @internal
238
- */
239
- private ensureIndexSet;
240
- /**
241
- * Helper to remove an ID from an index set and clean up empty sets
242
- *
243
- * @param map - Index map
244
- * @param key - Index key
245
- * @param id - API ID to remove
246
- * @private
247
- * @internal
248
- */
249
- private removeFromIndexSet;
250
- /**
251
- * Check if running in production environment
252
- *
253
- * @returns true if NODE_ENV is 'production'
254
- * @private
255
- * @internal
256
- */
257
- private isProductionEnvironment;
258
- }
259
- //# sourceMappingURL=api-registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-registry.d.ts","sourceRoot":"","sources":["../src/api-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,IAAI,eAAe,EAC9B,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,IAAI,CAA4C;IACxD,OAAO,CAAC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