@twin.org/entity-storage-models 0.0.3-next.3 → 0.0.3-next.30
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 +2 -2
- package/dist/es/factories/schemaMigrationFactory.js +17 -0
- package/dist/es/factories/schemaMigrationFactory.js.map +1 -0
- package/dist/es/helpers/entityStorageHelper.js +126 -0
- package/dist/es/helpers/entityStorageHelper.js.map +1 -0
- package/dist/es/helpers/migrationHelper.js +232 -0
- package/dist/es/helpers/migrationHelper.js.map +1 -0
- package/dist/es/index.js +14 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IEntityStorageComponent.js.map +1 -1
- package/dist/es/models/IEntityStorageConnector.js.map +1 -1
- package/dist/es/models/IEntityStorageMigrationConnector.js +2 -0
- package/dist/es/models/IEntityStorageMigrationConnector.js.map +1 -0
- package/dist/es/models/IMigrationOptions.js +4 -0
- package/dist/es/models/IMigrationOptions.js.map +1 -0
- 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/es/models/api/IEntityStorageCountRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageCountRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageCountResponse.js +4 -0
- package/dist/es/models/api/IEntityStorageCountResponse.js.map +1 -0
- package/dist/es/models/api/IEntityStorageEmptyRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageEmptyRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageGetRequest.js.map +1 -1
- package/dist/es/models/api/IEntityStorageRemoveBatchRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageRemoveBatchRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageRemoveRequest.js.map +1 -1
- package/dist/es/models/api/IEntityStorageSetBatchRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageSetBatchRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageSetRequest.js.map +1 -1
- package/dist/es/models/entityPropertyTransformer.js +2 -0
- package/dist/es/models/entityPropertyTransformer.js.map +1 -0
- package/dist/types/factories/schemaMigrationFactory.d.ts +14 -0
- package/dist/types/helpers/entityStorageHelper.d.ts +59 -0
- package/dist/types/helpers/migrationHelper.d.ts +65 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/models/IEntityStorageComponent.d.ts +38 -3
- package/dist/types/models/IEntityStorageConnector.d.ts +23 -0
- package/dist/types/models/IEntityStorageMigrationConnector.d.ts +35 -0
- package/dist/types/models/IMigrationOptions.d.ts +17 -0
- package/dist/types/models/IResolvedMigrationStep.d.ts +38 -0
- package/dist/types/models/ISchemaMigration.d.ts +30 -0
- package/dist/types/models/api/IEntityStorageCountRequest.d.ts +14 -0
- package/dist/types/models/api/IEntityStorageCountResponse.d.ts +14 -0
- package/dist/types/models/api/IEntityStorageEmptyRequest.d.ts +5 -0
- package/dist/types/models/api/IEntityStorageGetRequest.d.ts +4 -0
- package/dist/types/models/api/IEntityStorageRemoveBatchRequest.d.ts +9 -0
- package/dist/types/models/api/IEntityStorageRemoveRequest.d.ts +9 -0
- package/dist/types/models/api/IEntityStorageSetBatchRequest.d.ts +9 -0
- package/dist/types/models/api/IEntityStorageSetRequest.d.ts +9 -0
- package/dist/types/models/entityPropertyTransformer.d.ts +6 -0
- package/docs/changelog.md +308 -44
- package/docs/examples.md +87 -1
- package/docs/reference/classes/EntityStorageHelper.md +209 -0
- package/docs/reference/classes/MigrationHelper.md +198 -0
- package/docs/reference/index.md +19 -0
- package/docs/reference/interfaces/IEntityStorageComponent.md +105 -7
- package/docs/reference/interfaces/IEntityStorageConnector.md +89 -5
- package/docs/reference/interfaces/IEntityStorageCountRequest.md +17 -0
- package/docs/reference/interfaces/IEntityStorageCountResponse.md +17 -0
- package/docs/reference/interfaces/IEntityStorageEmptyRequest.md +3 -0
- package/docs/reference/interfaces/IEntityStorageGetRequest.md +10 -4
- package/docs/reference/interfaces/IEntityStorageGetResponse.md +1 -1
- package/docs/reference/interfaces/IEntityStorageListRequest.md +8 -8
- package/docs/reference/interfaces/IEntityStorageListResponse.md +2 -2
- package/docs/reference/interfaces/IEntityStorageMigrationConnector.md +402 -0
- package/docs/reference/interfaces/IEntityStorageRemoveBatchRequest.md +11 -0
- package/docs/reference/interfaces/IEntityStorageRemoveRequest.md +15 -1
- package/docs/reference/interfaces/IEntityStorageSetBatchRequest.md +11 -0
- package/docs/reference/interfaces/IEntityStorageSetRequest.md +15 -1
- package/docs/reference/interfaces/IMigrationOptions.md +49 -0
- package/docs/reference/interfaces/IResolvedMigrationStep.md +78 -0
- package/docs/reference/interfaces/ISchemaMigration.md +62 -0
- package/docs/reference/type-aliases/EntityPropertyTransformer.md +34 -0
- package/docs/reference/variables/SchemaMigrationFactory.md +13 -0
- package/locales/en.json +18 -1
- package/package.json +6 -4
|
@@ -4,7 +4,7 @@ Remove an entry from entity storage.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### pathParams
|
|
7
|
+
### pathParams {#pathparams}
|
|
8
8
|
|
|
9
9
|
> **pathParams**: `object`
|
|
10
10
|
|
|
@@ -15,3 +15,17 @@ The parameters from the path.
|
|
|
15
15
|
> **id**: `string`
|
|
16
16
|
|
|
17
17
|
The id of the entity to remove.
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### query? {#query}
|
|
22
|
+
|
|
23
|
+
> `optional` **query?**: `object`
|
|
24
|
+
|
|
25
|
+
The query parameters.
|
|
26
|
+
|
|
27
|
+
#### conditions?
|
|
28
|
+
|
|
29
|
+
> `optional` **conditions?**: `string`
|
|
30
|
+
|
|
31
|
+
The optional conditions to match for the entity, JSON encoded array of property/value pairs.
|
|
@@ -4,8 +4,22 @@ Set an entry in entity storage.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### body
|
|
7
|
+
### body {#body}
|
|
8
8
|
|
|
9
9
|
> **body**: `unknown`
|
|
10
10
|
|
|
11
11
|
The data to be used in the entity.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### query? {#query}
|
|
16
|
+
|
|
17
|
+
> `optional` **query?**: `object`
|
|
18
|
+
|
|
19
|
+
The query parameters.
|
|
20
|
+
|
|
21
|
+
#### conditions?
|
|
22
|
+
|
|
23
|
+
> `optional` **conditions?**: `string`
|
|
24
|
+
|
|
25
|
+
The optional conditions to match for the entity, JSON encoded array of property/value pairs.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Interface: IMigrationOptions
|
|
2
|
+
|
|
3
|
+
Options controlling how a schema migration is executed.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### batchSize? {#batchsize}
|
|
8
|
+
|
|
9
|
+
> `optional` **batchSize?**: `number`
|
|
10
|
+
|
|
11
|
+
Number of entities to read and write per batch.
|
|
12
|
+
|
|
13
|
+
#### Default
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
100
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### onProgress? {#onprogress}
|
|
22
|
+
|
|
23
|
+
> `optional` **onProgress?**: (`progressItem`, `itemTotal`, `itemIndex`) => `Promise`\<`void`\>
|
|
24
|
+
|
|
25
|
+
Called for progress tracking.
|
|
26
|
+
|
|
27
|
+
#### Parameters
|
|
28
|
+
|
|
29
|
+
##### progressItem
|
|
30
|
+
|
|
31
|
+
`"partitionStart"` \| `"partitionProgress"` \| `"partitionEnd"` \| `"partitionItemsStart"` \| `"partitionItemsProgress"` \| `"partitionItemsEnd"`
|
|
32
|
+
|
|
33
|
+
The item progress being updated.
|
|
34
|
+
|
|
35
|
+
##### itemTotal
|
|
36
|
+
|
|
37
|
+
`number`
|
|
38
|
+
|
|
39
|
+
The total number of rows to migrate.
|
|
40
|
+
|
|
41
|
+
##### itemIndex
|
|
42
|
+
|
|
43
|
+
`number`
|
|
44
|
+
|
|
45
|
+
The number of rows migrated so far.
|
|
46
|
+
|
|
47
|
+
#### Returns
|
|
48
|
+
|
|
49
|
+
`Promise`\<`void`\>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Interface: IResolvedMigrationStep\<T, U\>
|
|
2
|
+
|
|
3
|
+
A fully-resolved single migration step used by MigrationHelper.
|
|
4
|
+
The SchemaVersionService builds these by looking up versioned schema classes
|
|
5
|
+
from EntitySchemaFactory (e.g. MyEntityV0, MyEntityV1) before invoking the helper,
|
|
6
|
+
keeping factory knowledge out of the helper itself.
|
|
7
|
+
|
|
8
|
+
## Type Parameters
|
|
9
|
+
|
|
10
|
+
### T
|
|
11
|
+
|
|
12
|
+
`T` = `unknown`
|
|
13
|
+
|
|
14
|
+
The entity type. Defaults to `unknown`. Use a concrete entity type
|
|
15
|
+
when the step's source and target schemas are known at the call site.
|
|
16
|
+
|
|
17
|
+
### U
|
|
18
|
+
|
|
19
|
+
`U` = `unknown`
|
|
20
|
+
|
|
21
|
+
## Properties
|
|
22
|
+
|
|
23
|
+
### fromProperties {#fromproperties}
|
|
24
|
+
|
|
25
|
+
> **fromProperties**: `IEntitySchemaProperty`\<`T`\>[]
|
|
26
|
+
|
|
27
|
+
The property list of the entity at the start of this step (the "old" shape).
|
|
28
|
+
Sourced from the versioned schema class registered in EntitySchemaFactory,
|
|
29
|
+
e.g. EntitySchemaFactory.get("MyEntityV0").properties.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### toProperties {#toproperties}
|
|
34
|
+
|
|
35
|
+
> **toProperties**: `IEntitySchemaProperty`\<`U`\>[]
|
|
36
|
+
|
|
37
|
+
The property list of the entity at the end of this step (the "new" shape).
|
|
38
|
+
For the final step this is the live current schema's properties.
|
|
39
|
+
|
|
40
|
+
***
|
|
41
|
+
|
|
42
|
+
### renames? {#renames}
|
|
43
|
+
|
|
44
|
+
> `optional` **renames?**: `object`[]
|
|
45
|
+
|
|
46
|
+
Optional property renames for this step, forwarded to EntitySchemaDiffHelper.diff.
|
|
47
|
+
|
|
48
|
+
#### from
|
|
49
|
+
|
|
50
|
+
> **from**: `string`
|
|
51
|
+
|
|
52
|
+
#### to
|
|
53
|
+
|
|
54
|
+
> **to**: `string`
|
|
55
|
+
|
|
56
|
+
***
|
|
57
|
+
|
|
58
|
+
### transformEntityProperty? {#transformentityproperty}
|
|
59
|
+
|
|
60
|
+
> `optional` **transformEntityProperty?**: [`EntityPropertyTransformer`](../type-aliases/EntityPropertyTransformer.md)\<`T`, `U`\>
|
|
61
|
+
|
|
62
|
+
Optional transformation for properties, usually only called for object and array types.
|
|
63
|
+
|
|
64
|
+
#### Param
|
|
65
|
+
|
|
66
|
+
The property schema in the old schema.
|
|
67
|
+
|
|
68
|
+
#### Param
|
|
69
|
+
|
|
70
|
+
The property schema in the new schema.
|
|
71
|
+
|
|
72
|
+
#### Param
|
|
73
|
+
|
|
74
|
+
The value of the property in the old schema.
|
|
75
|
+
|
|
76
|
+
#### Returns
|
|
77
|
+
|
|
78
|
+
The transformed value to match the new schema.
|
|
@@ -0,0 +1,62 @@
|
|
|
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?**: [`EntityPropertyTransformer`](../type-aliases/EntityPropertyTransformer.md)\<`T`, `U`\>
|
|
45
|
+
|
|
46
|
+
Optional transformation for properties, usually only called for object and array types.
|
|
47
|
+
|
|
48
|
+
#### Param
|
|
49
|
+
|
|
50
|
+
The property schema in the old schema.
|
|
51
|
+
|
|
52
|
+
#### Param
|
|
53
|
+
|
|
54
|
+
The property schema in the new schema.
|
|
55
|
+
|
|
56
|
+
#### Param
|
|
57
|
+
|
|
58
|
+
The value of the property in the old schema.
|
|
59
|
+
|
|
60
|
+
#### Returns
|
|
61
|
+
|
|
62
|
+
The transformed value to match the new schema.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Type Alias: EntityPropertyTransformer\<T, U\>
|
|
2
|
+
|
|
3
|
+
> **EntityPropertyTransformer**\<`T`, `U`\> = (`schema1Property`, `schemaProperty2`, `value`) => `unknown`
|
|
4
|
+
|
|
5
|
+
Type for the optional transformEntityProperty function.
|
|
6
|
+
Used in migration steps for custom property transformations.
|
|
7
|
+
|
|
8
|
+
## Type Parameters
|
|
9
|
+
|
|
10
|
+
### T
|
|
11
|
+
|
|
12
|
+
`T` = `unknown`
|
|
13
|
+
|
|
14
|
+
### U
|
|
15
|
+
|
|
16
|
+
`U` = `unknown`
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
### schema1Property
|
|
21
|
+
|
|
22
|
+
`IEntitySchemaProperty`\<`T`\>
|
|
23
|
+
|
|
24
|
+
### schemaProperty2
|
|
25
|
+
|
|
26
|
+
`IEntitySchemaProperty`\<`U`\>
|
|
27
|
+
|
|
28
|
+
### value
|
|
29
|
+
|
|
30
|
+
`unknown`
|
|
31
|
+
|
|
32
|
+
## Returns
|
|
33
|
+
|
|
34
|
+
`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,3 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"error": {
|
|
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
|
+
},
|
|
7
|
+
"migrationHelper": {
|
|
8
|
+
"migrateSchemaFailed": "Migration failed for schema \"{schemaName}\".",
|
|
9
|
+
"transformRequiredForProperty": "A transformation function is required to migrate property \"{from}\" to \"{to}\" of type \"{type}\"",
|
|
10
|
+
"coercionProducedUndefined": "Coercion of property \"{property}\" to type \"{type}\" produced undefined but the property is not optional"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"info": {
|
|
14
|
+
"migrationHelper": {
|
|
15
|
+
"migrateSchemaStarting": "Migrating schema \"{schemaName}\"",
|
|
16
|
+
"migrateSchemaFinalizing": "Finalizing migration of schema \"{schemaName}\"",
|
|
17
|
+
"migrateSchemaComplete": "Migration of schema \"{schemaName}\" complete"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
3
20
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity-storage-models",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.30",
|
|
4
|
+
"description": "Shared models for storage contracts, requests, responses and connector capabilities.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/iotaledger/twin-entity-storage.git",
|
|
8
8
|
"directory": "packages/entity-storage-models"
|
|
9
9
|
},
|
|
10
10
|
"author": "martyn.janes@iota.org",
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@twin.org/context": "next",
|
|
17
18
|
"@twin.org/core": "next",
|
|
18
19
|
"@twin.org/entity": "next",
|
|
20
|
+
"@twin.org/logging-models": "next",
|
|
19
21
|
"@twin.org/nameof": "next"
|
|
20
22
|
},
|
|
21
23
|
"main": "./dist/es/index.js",
|
|
@@ -50,7 +52,7 @@
|
|
|
50
52
|
"schemas"
|
|
51
53
|
],
|
|
52
54
|
"bugs": {
|
|
53
|
-
"url": "git+https://github.com/
|
|
55
|
+
"url": "git+https://github.com/iotaledger/twin-entity-storage/issues"
|
|
54
56
|
},
|
|
55
57
|
"homepage": "https://twindev.org"
|
|
56
58
|
}
|