@twin.org/entity-storage-models 0.0.3-next.21 → 0.0.3-next.23
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/factories/schemaMigrationFactory.js +17 -0
- package/dist/es/factories/schemaMigrationFactory.js.map +1 -0
- package/dist/es/helpers/entityStorageHelper.js +42 -1
- package/dist/es/helpers/entityStorageHelper.js.map +1 -1
- package/dist/es/helpers/migrationHelper.js +102 -129
- package/dist/es/helpers/migrationHelper.js.map +1 -1
- package/dist/es/index.js +4 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IResolvedMigrationStep.js +2 -0
- package/dist/es/models/IResolvedMigrationStep.js.map +1 -0
- package/dist/es/models/ISchemaMigration.js +2 -0
- package/dist/es/models/ISchemaMigration.js.map +1 -0
- package/dist/types/factories/schemaMigrationFactory.d.ts +14 -0
- package/dist/types/helpers/entityStorageHelper.d.ts +20 -1
- package/dist/types/helpers/migrationHelper.d.ts +36 -43
- package/dist/types/index.d.ts +3 -0
- package/dist/types/models/IResolvedMigrationStep.d.ts +36 -0
- package/dist/types/models/ISchemaMigration.d.ts +27 -0
- package/docs/changelog.md +14 -0
- package/docs/reference/classes/EntityStorageHelper.md +74 -0
- package/docs/reference/classes/MigrationHelper.md +62 -152
- package/docs/reference/index.md +3 -0
- package/docs/reference/interfaces/IResolvedMigrationStep.md +82 -0
- package/docs/reference/interfaces/ISchemaMigration.md +65 -0
- package/docs/reference/variables/SchemaMigrationFactory.md +13 -0
- package/locales/en.json +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Interface: ISchemaMigration\<T, U\>
|
|
2
|
+
|
|
3
|
+
Optional per-step override for a single version-to-version migration.
|
|
4
|
+
Only register an entry in SchemaMigrationFactory when a step requires property
|
|
5
|
+
renames or a custom object/array transform. For purely structural changes
|
|
6
|
+
(add/remove/type-change fields) no entry is needed — the runner diffs the two
|
|
7
|
+
versioned schema classes (e.g. MyEntityV0 vs MyEntityV1) from EntitySchemaFactory
|
|
8
|
+
automatically.
|
|
9
|
+
|
|
10
|
+
Register under the key "<BaseSchemaName>_<fromVersion>_<toVersion>"
|
|
11
|
+
e.g. "MyEntity_0_1" for the step that migrates from version 0 to version 1.
|
|
12
|
+
The key itself encodes the version pair; no version field is needed on the object.
|
|
13
|
+
|
|
14
|
+
## Type Parameters
|
|
15
|
+
|
|
16
|
+
### T
|
|
17
|
+
|
|
18
|
+
`T` = `unknown`
|
|
19
|
+
|
|
20
|
+
### U
|
|
21
|
+
|
|
22
|
+
`U` = `unknown`
|
|
23
|
+
|
|
24
|
+
## Properties
|
|
25
|
+
|
|
26
|
+
### renames? {#renames}
|
|
27
|
+
|
|
28
|
+
> `optional` **renames?**: `object`[]
|
|
29
|
+
|
|
30
|
+
Optional property renames to apply during this step.
|
|
31
|
+
|
|
32
|
+
#### from
|
|
33
|
+
|
|
34
|
+
> **from**: `string`
|
|
35
|
+
|
|
36
|
+
#### to
|
|
37
|
+
|
|
38
|
+
> **to**: `string`
|
|
39
|
+
|
|
40
|
+
***
|
|
41
|
+
|
|
42
|
+
### transformEntityProperty? {#transformentityproperty}
|
|
43
|
+
|
|
44
|
+
> `optional` **transformEntityProperty?**: (`schema1Property`, `schemaProperty2`, `value`) => `unknown`
|
|
45
|
+
|
|
46
|
+
Optional per-property transformer for object/array properties that cannot be
|
|
47
|
+
automatically coerced. T is the source entity type, U is the target entity type.
|
|
48
|
+
|
|
49
|
+
#### Parameters
|
|
50
|
+
|
|
51
|
+
##### schema1Property
|
|
52
|
+
|
|
53
|
+
`IEntitySchemaProperty`\<`T`\>
|
|
54
|
+
|
|
55
|
+
##### schemaProperty2
|
|
56
|
+
|
|
57
|
+
`IEntitySchemaProperty`\<`U`\>
|
|
58
|
+
|
|
59
|
+
##### value
|
|
60
|
+
|
|
61
|
+
`unknown`
|
|
62
|
+
|
|
63
|
+
#### Returns
|
|
64
|
+
|
|
65
|
+
`unknown`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Variable: SchemaMigrationFactory
|
|
2
|
+
|
|
3
|
+
> `const` **SchemaMigrationFactory**: `Factory`\<[`ISchemaMigration`](../interfaces/ISchemaMigration.md)\<`unknown`, `unknown`\>\>
|
|
4
|
+
|
|
5
|
+
Factory for optional per-step migration overrides.
|
|
6
|
+
|
|
7
|
+
Only register an entry when a version step requires property renames or a custom
|
|
8
|
+
transform hook. For purely structural changes (add/remove/type-change) the
|
|
9
|
+
SchemaVersionService diffs the two versioned schema classes automatically
|
|
10
|
+
without needing any factory entry.
|
|
11
|
+
|
|
12
|
+
Keys follow the convention "<BaseSchemaName>_<fromVersion>_<toVersion>",
|
|
13
|
+
for example "MyEntity_0_1" for the step that migrates MyEntity from version 0 to 1.
|
package/locales/en.json
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"error": {
|
|
3
|
+
"entityStorageHelper": {
|
|
4
|
+
"sortNotIndexed": "The property \"{property}\" is not indexed and cannot be used for sorting",
|
|
5
|
+
"propertyNotInSchema": "The property \"{property}\" does not exist in the schema and cannot be used for projection"
|
|
6
|
+
},
|
|
3
7
|
"migrationHelper": {
|
|
4
8
|
"migrationFailed": "Migration failed.",
|
|
5
9
|
"transformRequiredForProperty": "A transformation function is required to migrate property \"{from}\" to \"{to}\" of type \"{type}\"",
|
package/package.json
CHANGED