@objectstack/runtime 3.2.1 → 3.2.3
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +19 -0
- package/dist/index.cjs +568 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +557 -12
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/app-plugin.ts +52 -14
- package/src/http-dispatcher.test.ts +3 -3
- package/src/http-dispatcher.ts +4 -4
- package/src/index.ts +1 -0
- package/src/seed-loader.test.ts +1123 -0
- package/src/seed-loader.ts +713 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ObjectKernel, IHttpServer, ObjectKernelConfig, Plugin, PluginContext, RouteHandler, Middleware } from '@objectstack/core';
|
|
2
2
|
export * from '@objectstack/core';
|
|
3
3
|
export { ObjectKernel } from '@objectstack/core';
|
|
4
|
+
import { ISeedLoaderService, IDataEngine, IMetadataService } from '@objectstack/spec/contracts';
|
|
5
|
+
import { SeedLoaderRequest, SeedLoaderResult, ObjectDependencyGraph, Dataset, SeedLoaderConfigInput } from '@objectstack/spec/data';
|
|
4
6
|
import { MiddlewareConfig, MiddlewareType } from '@objectstack/spec/system';
|
|
5
7
|
export { RestApiPluginConfig, RestServer, RouteEntry, RouteGroupBuilder, RouteManager, createRestApiPlugin } from '@objectstack/rest';
|
|
6
8
|
|
|
@@ -92,6 +94,50 @@ declare class AppPlugin implements Plugin {
|
|
|
92
94
|
start: (ctx: PluginContext) => Promise<void>;
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
interface Logger {
|
|
98
|
+
info(message: string, meta?: Record<string, any>): void;
|
|
99
|
+
warn(message: string, meta?: Record<string, any>): void;
|
|
100
|
+
error(message: string, error?: Error, meta?: Record<string, any>): void;
|
|
101
|
+
debug(message: string, meta?: Record<string, any>): void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* SeedLoaderService — Runtime implementation of ISeedLoaderService
|
|
105
|
+
*
|
|
106
|
+
* Provides metadata-driven seed data loading with:
|
|
107
|
+
* - Automatic lookup/master_detail reference resolution via externalId
|
|
108
|
+
* - Topological dependency ordering (parents before children)
|
|
109
|
+
* - Multi-pass loading for circular references
|
|
110
|
+
* - Dry-run validation mode
|
|
111
|
+
* - Upsert support honoring DatasetSchema mode
|
|
112
|
+
* - Actionable error reporting
|
|
113
|
+
*/
|
|
114
|
+
declare class SeedLoaderService implements ISeedLoaderService {
|
|
115
|
+
private engine;
|
|
116
|
+
private metadata;
|
|
117
|
+
private logger;
|
|
118
|
+
constructor(engine: IDataEngine, metadata: IMetadataService, logger: Logger);
|
|
119
|
+
load(request: SeedLoaderRequest): Promise<SeedLoaderResult>;
|
|
120
|
+
buildDependencyGraph(objectNames: string[]): Promise<ObjectDependencyGraph>;
|
|
121
|
+
validate(datasets: Dataset[], config?: SeedLoaderConfigInput): Promise<SeedLoaderResult>;
|
|
122
|
+
private loadDataset;
|
|
123
|
+
private resolveFromDatabase;
|
|
124
|
+
private resolveDeferredUpdates;
|
|
125
|
+
private writeRecord;
|
|
126
|
+
/**
|
|
127
|
+
* Kahn's algorithm for topological sort with cycle detection.
|
|
128
|
+
*/
|
|
129
|
+
private topologicalSort;
|
|
130
|
+
private findCycles;
|
|
131
|
+
private filterByEnv;
|
|
132
|
+
private orderDatasets;
|
|
133
|
+
private buildReferenceMap;
|
|
134
|
+
private loadExistingRecords;
|
|
135
|
+
private looksLikeInternalId;
|
|
136
|
+
private extractId;
|
|
137
|
+
private buildEmptyResult;
|
|
138
|
+
private buildResult;
|
|
139
|
+
}
|
|
140
|
+
|
|
95
141
|
interface DispatcherPluginConfig {
|
|
96
142
|
/**
|
|
97
143
|
* API path prefix for all endpoints.
|
|
@@ -486,7 +532,7 @@ declare class HttpDispatcher {
|
|
|
486
532
|
* Handles Analytics requests
|
|
487
533
|
* path: sub-path after /analytics/
|
|
488
534
|
*/
|
|
489
|
-
handleAnalytics(path: string, method: string, body: any,
|
|
535
|
+
handleAnalytics(path: string, method: string, body: any, _context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
490
536
|
/**
|
|
491
537
|
* Handles i18n requests
|
|
492
538
|
* path: sub-path after /i18n/
|
|
@@ -680,4 +726,4 @@ declare class MiddlewareManager {
|
|
|
680
726
|
createCompositeMiddleware(): Middleware;
|
|
681
727
|
}
|
|
682
728
|
|
|
683
|
-
export { AppPlugin, type DispatcherPluginConfig, DriverPlugin, HttpDispatcher, type HttpDispatcherResult, type HttpProtocolContext, HttpServer, MiddlewareManager, Runtime, type RuntimeConfig, createDispatcherPlugin };
|
|
729
|
+
export { AppPlugin, type DispatcherPluginConfig, DriverPlugin, HttpDispatcher, type HttpDispatcherResult, type HttpProtocolContext, HttpServer, MiddlewareManager, Runtime, type RuntimeConfig, SeedLoaderService, createDispatcherPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ObjectKernel, IHttpServer, ObjectKernelConfig, Plugin, PluginContext, RouteHandler, Middleware } from '@objectstack/core';
|
|
2
2
|
export * from '@objectstack/core';
|
|
3
3
|
export { ObjectKernel } from '@objectstack/core';
|
|
4
|
+
import { ISeedLoaderService, IDataEngine, IMetadataService } from '@objectstack/spec/contracts';
|
|
5
|
+
import { SeedLoaderRequest, SeedLoaderResult, ObjectDependencyGraph, Dataset, SeedLoaderConfigInput } from '@objectstack/spec/data';
|
|
4
6
|
import { MiddlewareConfig, MiddlewareType } from '@objectstack/spec/system';
|
|
5
7
|
export { RestApiPluginConfig, RestServer, RouteEntry, RouteGroupBuilder, RouteManager, createRestApiPlugin } from '@objectstack/rest';
|
|
6
8
|
|
|
@@ -92,6 +94,50 @@ declare class AppPlugin implements Plugin {
|
|
|
92
94
|
start: (ctx: PluginContext) => Promise<void>;
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
interface Logger {
|
|
98
|
+
info(message: string, meta?: Record<string, any>): void;
|
|
99
|
+
warn(message: string, meta?: Record<string, any>): void;
|
|
100
|
+
error(message: string, error?: Error, meta?: Record<string, any>): void;
|
|
101
|
+
debug(message: string, meta?: Record<string, any>): void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* SeedLoaderService — Runtime implementation of ISeedLoaderService
|
|
105
|
+
*
|
|
106
|
+
* Provides metadata-driven seed data loading with:
|
|
107
|
+
* - Automatic lookup/master_detail reference resolution via externalId
|
|
108
|
+
* - Topological dependency ordering (parents before children)
|
|
109
|
+
* - Multi-pass loading for circular references
|
|
110
|
+
* - Dry-run validation mode
|
|
111
|
+
* - Upsert support honoring DatasetSchema mode
|
|
112
|
+
* - Actionable error reporting
|
|
113
|
+
*/
|
|
114
|
+
declare class SeedLoaderService implements ISeedLoaderService {
|
|
115
|
+
private engine;
|
|
116
|
+
private metadata;
|
|
117
|
+
private logger;
|
|
118
|
+
constructor(engine: IDataEngine, metadata: IMetadataService, logger: Logger);
|
|
119
|
+
load(request: SeedLoaderRequest): Promise<SeedLoaderResult>;
|
|
120
|
+
buildDependencyGraph(objectNames: string[]): Promise<ObjectDependencyGraph>;
|
|
121
|
+
validate(datasets: Dataset[], config?: SeedLoaderConfigInput): Promise<SeedLoaderResult>;
|
|
122
|
+
private loadDataset;
|
|
123
|
+
private resolveFromDatabase;
|
|
124
|
+
private resolveDeferredUpdates;
|
|
125
|
+
private writeRecord;
|
|
126
|
+
/**
|
|
127
|
+
* Kahn's algorithm for topological sort with cycle detection.
|
|
128
|
+
*/
|
|
129
|
+
private topologicalSort;
|
|
130
|
+
private findCycles;
|
|
131
|
+
private filterByEnv;
|
|
132
|
+
private orderDatasets;
|
|
133
|
+
private buildReferenceMap;
|
|
134
|
+
private loadExistingRecords;
|
|
135
|
+
private looksLikeInternalId;
|
|
136
|
+
private extractId;
|
|
137
|
+
private buildEmptyResult;
|
|
138
|
+
private buildResult;
|
|
139
|
+
}
|
|
140
|
+
|
|
95
141
|
interface DispatcherPluginConfig {
|
|
96
142
|
/**
|
|
97
143
|
* API path prefix for all endpoints.
|
|
@@ -486,7 +532,7 @@ declare class HttpDispatcher {
|
|
|
486
532
|
* Handles Analytics requests
|
|
487
533
|
* path: sub-path after /analytics/
|
|
488
534
|
*/
|
|
489
|
-
handleAnalytics(path: string, method: string, body: any,
|
|
535
|
+
handleAnalytics(path: string, method: string, body: any, _context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
490
536
|
/**
|
|
491
537
|
* Handles i18n requests
|
|
492
538
|
* path: sub-path after /i18n/
|
|
@@ -680,4 +726,4 @@ declare class MiddlewareManager {
|
|
|
680
726
|
createCompositeMiddleware(): Middleware;
|
|
681
727
|
}
|
|
682
728
|
|
|
683
|
-
export { AppPlugin, type DispatcherPluginConfig, DriverPlugin, HttpDispatcher, type HttpDispatcherResult, type HttpProtocolContext, HttpServer, MiddlewareManager, Runtime, type RuntimeConfig, createDispatcherPlugin };
|
|
729
|
+
export { AppPlugin, type DispatcherPluginConfig, DriverPlugin, HttpDispatcher, type HttpDispatcherResult, type HttpProtocolContext, HttpServer, MiddlewareManager, Runtime, type RuntimeConfig, SeedLoaderService, createDispatcherPlugin };
|