@twin.org/entity-storage-service 0.0.3-next.9 → 0.9.0-next.1
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/dist/es/entities/schemaVersion.js +39 -0
- package/dist/es/entities/schemaVersion.js.map +1 -0
- package/dist/es/entityStorageRoutes.js +176 -4
- package/dist/es/entityStorageRoutes.js.map +1 -1
- package/dist/es/entityStorageService.js +44 -49
- package/dist/es/entityStorageService.js.map +1 -1
- package/dist/es/index.js +6 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IEntityStorageRoutesExamples.js.map +1 -1
- package/dist/es/models/ISchemaVersionServiceConfig.js +4 -0
- package/dist/es/models/ISchemaVersionServiceConfig.js.map +1 -0
- package/dist/es/models/ISchemaVersionServiceConstructorOptions.js +2 -0
- package/dist/es/models/ISchemaVersionServiceConstructorOptions.js.map +1 -0
- package/dist/es/schema.js +11 -0
- package/dist/es/schema.js.map +1 -0
- package/dist/es/schemaVersionService.js +356 -0
- package/dist/es/schemaVersionService.js.map +1 -0
- package/dist/types/entities/schemaVersion.d.ts +19 -0
- package/dist/types/entityStorageRoutes.d.ts +33 -1
- package/dist/types/entityStorageService.d.ts +38 -3
- package/dist/types/index.d.ts +6 -1
- package/dist/types/models/IEntityStorageRoutesExamples.d.ts +8 -1
- package/dist/types/models/ISchemaVersionServiceConfig.d.ts +9 -0
- package/dist/types/models/ISchemaVersionServiceConstructorOptions.d.ts +15 -0
- package/dist/types/schema.d.ts +4 -0
- package/dist/types/schemaVersionService.d.ts +52 -0
- package/docs/changelog.md +546 -52
- package/docs/open-api/spec.json +439 -1
- package/docs/reference/classes/EntityStorageService.md +117 -3
- package/docs/reference/classes/SchemaVersion.md +39 -0
- package/docs/reference/classes/SchemaVersionService.md +103 -0
- package/docs/reference/functions/entityStorageCount.md +31 -0
- package/docs/reference/functions/entityStorageEmpty.md +31 -0
- package/docs/reference/functions/entityStorageRemoveBatch.md +31 -0
- package/docs/reference/functions/entityStorageSetBatch.md +31 -0
- package/docs/reference/functions/initSchema.md +9 -0
- package/docs/reference/index.md +9 -0
- package/docs/reference/interfaces/IEntityStorageRoutesExamples.md +16 -0
- package/docs/reference/interfaces/ISchemaVersionServiceConfig.md +11 -0
- package/docs/reference/interfaces/ISchemaVersionServiceConstructorOptions.md +25 -0
- package/locales/en.json +17 -2
- package/package.json +10 -9
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type IComponent } from "@twin.org/core";
|
|
2
|
+
import type { ISchemaVersionServiceConstructorOptions } from "./models/ISchemaVersionServiceConstructorOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Service that checks and applies entity schema migrations at every node start-up.
|
|
5
|
+
*
|
|
6
|
+
* This service must be the first entry in coreTypeInitialisers.json. The engine iterates that
|
|
7
|
+
* array in order to determine start sequence — there is no engine-level priority mechanism, so
|
|
8
|
+
* registration position is the only guarantee that start() runs before any other service.
|
|
9
|
+
* By the time start() is called, all component bootstraps have completed (every table already
|
|
10
|
+
* exists) and EntitySchemaFactory / EntityStorageConnectorFactory are fully populated with every
|
|
11
|
+
* registered schema and connector.
|
|
12
|
+
*
|
|
13
|
+
* Migration mechanics: old schema versions are registered in EntitySchemaFactory by naming
|
|
14
|
+
* convention — current schema = "MyEntity", first history = "MyEntityV0", second = "MyEntityV1".
|
|
15
|
+
* The service groups schemas by base name (strips the trailing V number suffix) and resolves the
|
|
16
|
+
* migration chain automatically by diffing consecutive versioned schemas. For steps that require
|
|
17
|
+
* property renames or a custom transform hook, register an optional ISchemaMigration entry in
|
|
18
|
+
* SchemaMigrationFactory under the key "Base_from_to" (e.g. "MyEntity_0_1").
|
|
19
|
+
*
|
|
20
|
+
* Crash-window note: finalizeMigration and the subsequent version-record write are two
|
|
21
|
+
* separate operations. If the process dies between them the next boot re-runs the chain
|
|
22
|
+
* over already-migrated data. applyEntityTransform is NOT idempotent for structural changes
|
|
23
|
+
* (newly-added optional fields would be dropped on re-run). A transaction spanning both
|
|
24
|
+
* writes is a precondition for production; track this in the concurrency follow-up.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SchemaVersionService implements IComponent {
|
|
27
|
+
/**
|
|
28
|
+
* Runtime name for the class.
|
|
29
|
+
*/
|
|
30
|
+
static readonly CLASS_NAME: string;
|
|
31
|
+
/**
|
|
32
|
+
* Create a new SchemaVersionService.
|
|
33
|
+
* @param options Optional constructor options.
|
|
34
|
+
*/
|
|
35
|
+
constructor(options?: ISchemaVersionServiceConstructorOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Returns the class name.
|
|
38
|
+
* @returns The class name.
|
|
39
|
+
*/
|
|
40
|
+
className(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Reads all registered entity schemas, groups versioned schemas by base name, reads the
|
|
43
|
+
* full schemaVersion table in one pass, then orchestrates chain migrations for any schema
|
|
44
|
+
* whose stored version is behind the current version declared in EntitySchemaFactory.
|
|
45
|
+
* SchemaVersion itself is processed first so the version store is migrated before any
|
|
46
|
+
* version records are written for other schemas.
|
|
47
|
+
*
|
|
48
|
+
* Runs after all component bootstraps, so every managed table already exists.
|
|
49
|
+
* @param nodeLoggingComponentType An optional logging component type.
|
|
50
|
+
*/
|
|
51
|
+
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
52
|
+
}
|