@twin.org/entity-storage-models 0.0.3-next.9 → 0.9.0
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 +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 +337 -49
- 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 +101 -3
- package/docs/reference/interfaces/IEntityStorageConnector.md +84 -0
- 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 +6 -0
- package/docs/reference/interfaces/IEntityStorageMigrationConnector.md +402 -0
- package/docs/reference/interfaces/IEntityStorageRemoveBatchRequest.md +11 -0
- package/docs/reference/interfaces/IEntityStorageRemoveRequest.md +14 -0
- package/docs/reference/interfaces/IEntityStorageSetBatchRequest.md +11 -0
- package/docs/reference/interfaces/IEntityStorageSetRequest.md +14 -0
- package/docs/reference/interfaces/IMigrationOptions.md +49 -0
- package/docs/reference/interfaces/IResolvedMigrationStep.md +84 -0
- package/docs/reference/interfaces/ISchemaMigration.md +68 -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 +8 -6
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Interface: IEntityStorageCountResponse
|
|
2
|
+
|
|
3
|
+
The response for counting entries in entity storage.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### body {#body}
|
|
8
|
+
|
|
9
|
+
> **body**: `object`
|
|
10
|
+
|
|
11
|
+
The body of the response.
|
|
12
|
+
|
|
13
|
+
#### count
|
|
14
|
+
|
|
15
|
+
> **count**: `number`
|
|
16
|
+
|
|
17
|
+
The total count of entities.
|
|
@@ -29,3 +29,9 @@ The query parameters.
|
|
|
29
29
|
> `optional` **secondaryIndex?**: `string`
|
|
30
30
|
|
|
31
31
|
The secondary index to query with the id.
|
|
32
|
+
|
|
33
|
+
#### conditions?
|
|
34
|
+
|
|
35
|
+
> `optional` **conditions?**: `string`
|
|
36
|
+
|
|
37
|
+
The optional conditions to match for the entity, JSON encoded array of property/value pairs.
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
# Interface: IEntityStorageMigrationConnector\<T\>
|
|
2
|
+
|
|
3
|
+
Interface describing an entity storage migration connector.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- [`IEntityStorageConnector`](IEntityStorageConnector.md)\<`T`\>
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
### T
|
|
12
|
+
|
|
13
|
+
`T` = `unknown`
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### getSchema() {#getschema}
|
|
18
|
+
|
|
19
|
+
> **getSchema**(): `IEntitySchema`
|
|
20
|
+
|
|
21
|
+
Get the schema for the entities.
|
|
22
|
+
|
|
23
|
+
#### Returns
|
|
24
|
+
|
|
25
|
+
`IEntitySchema`
|
|
26
|
+
|
|
27
|
+
The schema for the entities.
|
|
28
|
+
|
|
29
|
+
#### Inherited from
|
|
30
|
+
|
|
31
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`getSchema`](IEntityStorageConnector.md#getschema)
|
|
32
|
+
|
|
33
|
+
***
|
|
34
|
+
|
|
35
|
+
### set() {#set}
|
|
36
|
+
|
|
37
|
+
> **set**(`entity`, `conditions?`): `Promise`\<`void`\>
|
|
38
|
+
|
|
39
|
+
Set an entity.
|
|
40
|
+
|
|
41
|
+
#### Parameters
|
|
42
|
+
|
|
43
|
+
##### entity
|
|
44
|
+
|
|
45
|
+
`T`
|
|
46
|
+
|
|
47
|
+
The entity to set.
|
|
48
|
+
|
|
49
|
+
##### conditions?
|
|
50
|
+
|
|
51
|
+
`object`[]
|
|
52
|
+
|
|
53
|
+
The optional conditions to match for the entities.
|
|
54
|
+
|
|
55
|
+
#### Returns
|
|
56
|
+
|
|
57
|
+
`Promise`\<`void`\>
|
|
58
|
+
|
|
59
|
+
The id of the entity.
|
|
60
|
+
|
|
61
|
+
#### Inherited from
|
|
62
|
+
|
|
63
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`set`](IEntityStorageConnector.md#set)
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### setBatch() {#setbatch}
|
|
68
|
+
|
|
69
|
+
> **setBatch**(`entities`): `Promise`\<`void`\>
|
|
70
|
+
|
|
71
|
+
Set multiple entities in a batch.
|
|
72
|
+
|
|
73
|
+
#### Parameters
|
|
74
|
+
|
|
75
|
+
##### entities
|
|
76
|
+
|
|
77
|
+
`T`[]
|
|
78
|
+
|
|
79
|
+
The entities to set.
|
|
80
|
+
|
|
81
|
+
#### Returns
|
|
82
|
+
|
|
83
|
+
`Promise`\<`void`\>
|
|
84
|
+
|
|
85
|
+
Nothing.
|
|
86
|
+
|
|
87
|
+
#### Inherited from
|
|
88
|
+
|
|
89
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`setBatch`](IEntityStorageConnector.md#setbatch)
|
|
90
|
+
|
|
91
|
+
***
|
|
92
|
+
|
|
93
|
+
### get() {#get}
|
|
94
|
+
|
|
95
|
+
> **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`T` \| `undefined`\>
|
|
96
|
+
|
|
97
|
+
Get an entity.
|
|
98
|
+
|
|
99
|
+
#### Parameters
|
|
100
|
+
|
|
101
|
+
##### id
|
|
102
|
+
|
|
103
|
+
`string`
|
|
104
|
+
|
|
105
|
+
The id of the entity to get, or the index value if secondaryIndex is set.
|
|
106
|
+
|
|
107
|
+
##### secondaryIndex?
|
|
108
|
+
|
|
109
|
+
keyof `T`
|
|
110
|
+
|
|
111
|
+
Get the item using a secondary index.
|
|
112
|
+
|
|
113
|
+
##### conditions?
|
|
114
|
+
|
|
115
|
+
`object`[]
|
|
116
|
+
|
|
117
|
+
The optional conditions to match for the entities.
|
|
118
|
+
|
|
119
|
+
#### Returns
|
|
120
|
+
|
|
121
|
+
`Promise`\<`T` \| `undefined`\>
|
|
122
|
+
|
|
123
|
+
The object if it can be found or undefined.
|
|
124
|
+
|
|
125
|
+
#### Inherited from
|
|
126
|
+
|
|
127
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`get`](IEntityStorageConnector.md#get)
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
### remove() {#remove}
|
|
132
|
+
|
|
133
|
+
> **remove**(`id`, `conditions?`): `Promise`\<`void`\>
|
|
134
|
+
|
|
135
|
+
Remove the entity.
|
|
136
|
+
|
|
137
|
+
#### Parameters
|
|
138
|
+
|
|
139
|
+
##### id
|
|
140
|
+
|
|
141
|
+
`string`
|
|
142
|
+
|
|
143
|
+
The id of the entity to remove.
|
|
144
|
+
|
|
145
|
+
##### conditions?
|
|
146
|
+
|
|
147
|
+
`object`[]
|
|
148
|
+
|
|
149
|
+
The optional conditions to match for the entities.
|
|
150
|
+
|
|
151
|
+
#### Returns
|
|
152
|
+
|
|
153
|
+
`Promise`\<`void`\>
|
|
154
|
+
|
|
155
|
+
Nothing.
|
|
156
|
+
|
|
157
|
+
#### Inherited from
|
|
158
|
+
|
|
159
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`remove`](IEntityStorageConnector.md#remove)
|
|
160
|
+
|
|
161
|
+
***
|
|
162
|
+
|
|
163
|
+
### removeBatch() {#removebatch}
|
|
164
|
+
|
|
165
|
+
> **removeBatch**(`ids`): `Promise`\<`void`\>
|
|
166
|
+
|
|
167
|
+
Remove multiple entities by id.
|
|
168
|
+
|
|
169
|
+
#### Parameters
|
|
170
|
+
|
|
171
|
+
##### ids
|
|
172
|
+
|
|
173
|
+
`string`[]
|
|
174
|
+
|
|
175
|
+
The ids of the entities to remove.
|
|
176
|
+
|
|
177
|
+
#### Returns
|
|
178
|
+
|
|
179
|
+
`Promise`\<`void`\>
|
|
180
|
+
|
|
181
|
+
Nothing.
|
|
182
|
+
|
|
183
|
+
#### Inherited from
|
|
184
|
+
|
|
185
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`removeBatch`](IEntityStorageConnector.md#removebatch)
|
|
186
|
+
|
|
187
|
+
***
|
|
188
|
+
|
|
189
|
+
### query() {#query}
|
|
190
|
+
|
|
191
|
+
> **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
|
192
|
+
|
|
193
|
+
Query all the entities which match the conditions.
|
|
194
|
+
|
|
195
|
+
#### Parameters
|
|
196
|
+
|
|
197
|
+
##### conditions?
|
|
198
|
+
|
|
199
|
+
`EntityCondition`\<`T`\>
|
|
200
|
+
|
|
201
|
+
The conditions to match for the entities.
|
|
202
|
+
|
|
203
|
+
##### sortProperties?
|
|
204
|
+
|
|
205
|
+
`object`[]
|
|
206
|
+
|
|
207
|
+
The optional sort order.
|
|
208
|
+
|
|
209
|
+
##### properties?
|
|
210
|
+
|
|
211
|
+
keyof `T`[]
|
|
212
|
+
|
|
213
|
+
The optional properties to return, defaults to all.
|
|
214
|
+
|
|
215
|
+
##### cursor?
|
|
216
|
+
|
|
217
|
+
`string`
|
|
218
|
+
|
|
219
|
+
The cursor to request the next chunk of entities.
|
|
220
|
+
|
|
221
|
+
##### limit?
|
|
222
|
+
|
|
223
|
+
`number`
|
|
224
|
+
|
|
225
|
+
The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
|
|
226
|
+
|
|
227
|
+
#### Returns
|
|
228
|
+
|
|
229
|
+
`Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
|
230
|
+
|
|
231
|
+
All the entities for the storage matching the conditions,
|
|
232
|
+
and a cursor which can be used to request more entities.
|
|
233
|
+
|
|
234
|
+
#### Inherited from
|
|
235
|
+
|
|
236
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`query`](IEntityStorageConnector.md#query)
|
|
237
|
+
|
|
238
|
+
***
|
|
239
|
+
|
|
240
|
+
### empty() {#empty}
|
|
241
|
+
|
|
242
|
+
> **empty**(): `Promise`\<`void`\>
|
|
243
|
+
|
|
244
|
+
Remove all entities from the storage.
|
|
245
|
+
|
|
246
|
+
#### Returns
|
|
247
|
+
|
|
248
|
+
`Promise`\<`void`\>
|
|
249
|
+
|
|
250
|
+
Nothing.
|
|
251
|
+
|
|
252
|
+
#### Inherited from
|
|
253
|
+
|
|
254
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`empty`](IEntityStorageConnector.md#empty)
|
|
255
|
+
|
|
256
|
+
***
|
|
257
|
+
|
|
258
|
+
### count() {#count}
|
|
259
|
+
|
|
260
|
+
> **count**(`conditions?`): `Promise`\<`number`\>
|
|
261
|
+
|
|
262
|
+
Count all the entities which match the conditions.
|
|
263
|
+
|
|
264
|
+
#### Parameters
|
|
265
|
+
|
|
266
|
+
##### conditions?
|
|
267
|
+
|
|
268
|
+
`EntityCondition`\<`T`\>
|
|
269
|
+
|
|
270
|
+
The optional conditions to match for the entities.
|
|
271
|
+
|
|
272
|
+
#### Returns
|
|
273
|
+
|
|
274
|
+
`Promise`\<`number`\>
|
|
275
|
+
|
|
276
|
+
The total count of entities in the storage.
|
|
277
|
+
|
|
278
|
+
#### Inherited from
|
|
279
|
+
|
|
280
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md).[`count`](IEntityStorageConnector.md#count)
|
|
281
|
+
|
|
282
|
+
***
|
|
283
|
+
|
|
284
|
+
### getPartitionContextIds() {#getpartitioncontextids}
|
|
285
|
+
|
|
286
|
+
> **getPartitionContextIds**(): `Promise`\<`IContextIds`[]\>
|
|
287
|
+
|
|
288
|
+
Get a unique list of all the context ids from the storage.
|
|
289
|
+
|
|
290
|
+
#### Returns
|
|
291
|
+
|
|
292
|
+
`Promise`\<`IContextIds`[]\>
|
|
293
|
+
|
|
294
|
+
The list of unique context ids.
|
|
295
|
+
|
|
296
|
+
***
|
|
297
|
+
|
|
298
|
+
### createTargetConnector() {#createtargetconnector}
|
|
299
|
+
|
|
300
|
+
> **createTargetConnector**\<`U`\>(`newEntitySchema`): `Promise`\<[`IEntityStorageConnector`](IEntityStorageConnector.md)\<`U`\>\>
|
|
301
|
+
|
|
302
|
+
Create the target connector for performing the migration it will use a temporary storage location.
|
|
303
|
+
|
|
304
|
+
#### Type Parameters
|
|
305
|
+
|
|
306
|
+
##### U
|
|
307
|
+
|
|
308
|
+
`U`
|
|
309
|
+
|
|
310
|
+
#### Parameters
|
|
311
|
+
|
|
312
|
+
##### newEntitySchema
|
|
313
|
+
|
|
314
|
+
`string`
|
|
315
|
+
|
|
316
|
+
The name of the new entity schema to create the connector for.
|
|
317
|
+
|
|
318
|
+
#### Returns
|
|
319
|
+
|
|
320
|
+
`Promise`\<[`IEntityStorageConnector`](IEntityStorageConnector.md)\<`U`\>\>
|
|
321
|
+
|
|
322
|
+
Connector for performing the migration.
|
|
323
|
+
|
|
324
|
+
***
|
|
325
|
+
|
|
326
|
+
### finalizeMigration() {#finalizemigration}
|
|
327
|
+
|
|
328
|
+
> **finalizeMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<[`IEntityStorageConnector`](IEntityStorageConnector.md)\<`U`\>\>
|
|
329
|
+
|
|
330
|
+
Finalize the migration by tearing down the old connector and replacing it with the target connector.
|
|
331
|
+
|
|
332
|
+
#### Type Parameters
|
|
333
|
+
|
|
334
|
+
##### U
|
|
335
|
+
|
|
336
|
+
`U`
|
|
337
|
+
|
|
338
|
+
#### Parameters
|
|
339
|
+
|
|
340
|
+
##### targetConnector
|
|
341
|
+
|
|
342
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md)\<`U`\>
|
|
343
|
+
|
|
344
|
+
The target connector to finalize the migration with.
|
|
345
|
+
|
|
346
|
+
##### options?
|
|
347
|
+
|
|
348
|
+
[`IMigrationOptions`](IMigrationOptions.md)
|
|
349
|
+
|
|
350
|
+
The options to control how the migration is finalized.
|
|
351
|
+
|
|
352
|
+
##### loggingComponentType?
|
|
353
|
+
|
|
354
|
+
`string`
|
|
355
|
+
|
|
356
|
+
The optional component type to use for logging the migration progress.
|
|
357
|
+
|
|
358
|
+
#### Returns
|
|
359
|
+
|
|
360
|
+
`Promise`\<[`IEntityStorageConnector`](IEntityStorageConnector.md)\<`U`\>\>
|
|
361
|
+
|
|
362
|
+
A promise that resolves when the migration is finalized and returns the final connector.
|
|
363
|
+
|
|
364
|
+
***
|
|
365
|
+
|
|
366
|
+
### cleanupMigration() {#cleanupmigration}
|
|
367
|
+
|
|
368
|
+
> **cleanupMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
369
|
+
|
|
370
|
+
Cleanup the migration if a migration fails or needs to be aborted.
|
|
371
|
+
|
|
372
|
+
#### Type Parameters
|
|
373
|
+
|
|
374
|
+
##### U
|
|
375
|
+
|
|
376
|
+
`U`
|
|
377
|
+
|
|
378
|
+
#### Parameters
|
|
379
|
+
|
|
380
|
+
##### targetConnector
|
|
381
|
+
|
|
382
|
+
[`IEntityStorageConnector`](IEntityStorageConnector.md)\<`U`\> \| `undefined`
|
|
383
|
+
|
|
384
|
+
The target connector to cleanup the migration with.
|
|
385
|
+
|
|
386
|
+
##### options?
|
|
387
|
+
|
|
388
|
+
[`IMigrationOptions`](IMigrationOptions.md)
|
|
389
|
+
|
|
390
|
+
The options to control how the migration is cleaned up.
|
|
391
|
+
|
|
392
|
+
##### loggingComponentType?
|
|
393
|
+
|
|
394
|
+
`string`
|
|
395
|
+
|
|
396
|
+
The optional component type to use for logging the migration progress.
|
|
397
|
+
|
|
398
|
+
#### Returns
|
|
399
|
+
|
|
400
|
+
`Promise`\<`void`\>
|
|
401
|
+
|
|
402
|
+
A promise that resolves when the migration is cleaned up.
|
|
@@ -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.
|
|
@@ -9,3 +9,17 @@ Set an entry in entity storage.
|
|
|
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,84 @@
|
|
|
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
|
+
**schema1Property**
|
|
67
|
+
|
|
68
|
+
The property schema in the old schema.
|
|
69
|
+
|
|
70
|
+
#### Param
|
|
71
|
+
|
|
72
|
+
**schemaProperty2**
|
|
73
|
+
|
|
74
|
+
The property schema in the new schema.
|
|
75
|
+
|
|
76
|
+
#### Param
|
|
77
|
+
|
|
78
|
+
**value**
|
|
79
|
+
|
|
80
|
+
The value of the property in the old schema.
|
|
81
|
+
|
|
82
|
+
#### Returns
|
|
83
|
+
|
|
84
|
+
The transformed value to match the new schema.
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
**schema1Property**
|
|
51
|
+
|
|
52
|
+
The property schema in the old schema.
|
|
53
|
+
|
|
54
|
+
#### Param
|
|
55
|
+
|
|
56
|
+
**schemaProperty2**
|
|
57
|
+
|
|
58
|
+
The property schema in the new schema.
|
|
59
|
+
|
|
60
|
+
#### Param
|
|
61
|
+
|
|
62
|
+
**value**
|
|
63
|
+
|
|
64
|
+
The value of the property in the old schema.
|
|
65
|
+
|
|
66
|
+
#### Returns
|
|
67
|
+
|
|
68
|
+
The transformed value to match the new schema.
|