@strapi/data-transfer 5.47.1 → 5.48.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/directory/providers/destination/index.d.ts +1 -1
- package/dist/directory/providers/destination/index.d.ts.map +1 -1
- package/dist/directory/providers/destination/index.js.map +1 -1
- package/dist/directory/providers/destination/index.mjs.map +1 -1
- package/dist/directory/providers/source/index.d.ts +1 -1
- package/dist/directory/providers/source/index.d.ts.map +1 -1
- package/dist/directory/providers/source/index.js.map +1 -1
- package/dist/directory/providers/source/index.mjs.map +1 -1
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/index.mjs.map +1 -1
- package/dist/engine/validation/provider.d.ts +1 -1
- package/dist/engine/validation/provider.d.ts.map +1 -1
- package/dist/engine/validation/provider.js.map +1 -1
- package/dist/engine/validation/provider.mjs.map +1 -1
- package/dist/errors/providers.d.ts +1 -1
- package/dist/errors/providers.d.ts.map +1 -1
- package/dist/errors/providers.js.map +1 -1
- package/dist/errors/providers.mjs.map +1 -1
- package/dist/file/providers/destination/index.d.ts +1 -1
- package/dist/file/providers/destination/index.d.ts.map +1 -1
- package/dist/file/providers/destination/index.js.map +1 -1
- package/dist/file/providers/destination/index.mjs.map +1 -1
- package/dist/file/providers/source/index.d.ts +1 -1
- package/dist/file/providers/source/index.d.ts.map +1 -1
- package/dist/file/providers/source/index.js.map +1 -1
- package/dist/file/providers/source/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/assets-destination-writable.d.ts +9 -4
- package/dist/strapi/providers/local-destination/assets-destination-writable.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/assets-destination-writable.js +67 -49
- package/dist/strapi/providers/local-destination/assets-destination-writable.js.map +1 -1
- package/dist/strapi/providers/local-destination/assets-destination-writable.mjs +67 -49
- package/dist/strapi/providers/local-destination/assets-destination-writable.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/index.js.map +1 -1
- package/dist/strapi/providers/local-destination/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js +13 -25
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs +14 -26
- package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.js +0 -4
- package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.mjs +0 -4
- package/dist/strapi/providers/local-destination/strategies/restore/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.js +22 -3
- package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.mjs +22 -3
- package/dist/strapi/providers/local-destination/strategies/restore/links.mjs.map +1 -1
- package/dist/strapi/providers/local-source/assets.d.ts +1 -1
- package/dist/strapi/providers/local-source/assets.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/assets.js.map +1 -1
- package/dist/strapi/providers/local-source/assets.mjs.map +1 -1
- package/dist/strapi/providers/local-source/configuration.js.map +1 -1
- package/dist/strapi/providers/local-source/configuration.mjs.map +1 -1
- package/dist/strapi/providers/local-source/entities.d.ts +3 -1
- package/dist/strapi/providers/local-source/entities.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/entities.js +7 -3
- package/dist/strapi/providers/local-source/entities.js.map +1 -1
- package/dist/strapi/providers/local-source/entities.mjs +7 -3
- package/dist/strapi/providers/local-source/entities.mjs.map +1 -1
- package/dist/strapi/providers/local-source/estimate-asset-totals.d.ts +1 -1
- package/dist/strapi/providers/local-source/estimate-asset-totals.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/estimate-asset-totals.js.map +1 -1
- package/dist/strapi/providers/local-source/estimate-asset-totals.mjs.map +1 -1
- package/dist/strapi/providers/local-source/index.d.ts +2 -2
- package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/index.js +6 -1
- package/dist/strapi/providers/local-source/index.js.map +1 -1
- package/dist/strapi/providers/local-source/index.mjs +6 -1
- package/dist/strapi/providers/local-source/index.mjs.map +1 -1
- package/dist/strapi/providers/local-source/links.js.map +1 -1
- package/dist/strapi/providers/local-source/links.mjs.map +1 -1
- package/dist/strapi/providers/remote-destination/index.d.ts +2 -2
- package/dist/strapi/providers/remote-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-destination/index.js +24 -3
- package/dist/strapi/providers/remote-destination/index.js.map +1 -1
- package/dist/strapi/providers/remote-destination/index.mjs +25 -4
- package/dist/strapi/providers/remote-destination/index.mjs.map +1 -1
- package/dist/strapi/providers/remote-source/index.d.ts +2 -2
- package/dist/strapi/providers/remote-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-source/index.js.map +1 -1
- package/dist/strapi/providers/remote-source/index.mjs.map +1 -1
- package/dist/strapi/providers/utils.d.ts +2 -2
- package/dist/strapi/providers/utils.d.ts.map +1 -1
- package/dist/strapi/providers/utils.js.map +1 -1
- package/dist/strapi/providers/utils.mjs.map +1 -1
- package/dist/strapi/queries/link.d.ts +1 -1
- package/dist/strapi/queries/link.d.ts.map +1 -1
- package/dist/strapi/queries/link.js.map +1 -1
- package/dist/strapi/queries/link.mjs.map +1 -1
- package/dist/strapi/remote/flows/index.d.ts +1 -1
- package/dist/strapi/remote/flows/index.d.ts.map +1 -1
- package/dist/strapi/remote/flows/index.js.map +1 -1
- package/dist/strapi/remote/flows/index.mjs.map +1 -1
- package/dist/strapi/remote/handlers/pull.d.ts +1 -1
- package/dist/strapi/remote/handlers/pull.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/pull.js +3 -3
- package/dist/strapi/remote/handlers/pull.js.map +1 -1
- package/dist/strapi/remote/handlers/pull.mjs +3 -3
- package/dist/strapi/remote/handlers/pull.mjs.map +1 -1
- package/dist/strapi/remote/handlers/push.d.ts +1 -1
- package/dist/strapi/remote/handlers/push.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/push.js +7 -1
- package/dist/strapi/remote/handlers/push.js.map +1 -1
- package/dist/strapi/remote/handlers/push.mjs +7 -1
- package/dist/strapi/remote/handlers/push.mjs.map +1 -1
- package/dist/strapi/remote/handlers/utils.d.ts +1 -1
- package/dist/strapi/remote/handlers/utils.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/utils.js.map +1 -1
- package/dist/strapi/remote/handlers/utils.mjs.map +1 -1
- package/dist/types/common-entities.d.ts +152 -0
- package/dist/types/common-entities.d.ts.map +1 -0
- package/dist/types/encryption.d.ts +11 -0
- package/dist/types/encryption.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/providers.d.ts +50 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/remote/index.d.ts +2 -0
- package/dist/types/remote/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/auth.d.ts +5 -0
- package/dist/types/remote/protocol/auth.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/commands.d.ts +37 -0
- package/dist/types/remote/protocol/client/commands.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/index.d.ts +9 -0
- package/dist/types/remote/protocol/client/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/action.d.ts +5 -0
- package/dist/types/remote/protocol/client/transfer/action.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/index.d.ts +12 -0
- package/dist/types/remote/protocol/client/transfer/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/pull.d.ts +25 -0
- package/dist/types/remote/protocol/client/transfer/pull.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/push.d.ts +29 -0
- package/dist/types/remote/protocol/client/transfer/push.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/utils.d.ts +49 -0
- package/dist/types/remote/protocol/client/transfer/utils.d.ts.map +1 -0
- package/dist/types/remote/protocol/index.d.ts +4 -0
- package/dist/types/remote/protocol/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/error.d.ts +18 -0
- package/dist/types/remote/protocol/server/error.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/index.d.ts +3 -0
- package/dist/types/remote/protocol/server/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/messaging.d.ts +37 -0
- package/dist/types/remote/protocol/server/messaging.d.ts.map +1 -0
- package/dist/types/transfer-engine.d.ts +149 -0
- package/dist/types/transfer-engine.d.ts.map +1 -0
- package/dist/types/utils.d.ts +83 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/utils/components.d.ts +21 -1
- package/dist/utils/components.d.ts.map +1 -1
- package/dist/utils/components.js +69 -21
- package/dist/utils/components.js.map +1 -1
- package/dist/utils/components.mjs +70 -22
- package/dist/utils/components.mjs.map +1 -1
- package/dist/utils/encryption/decrypt.d.ts +1 -1
- package/dist/utils/encryption/decrypt.d.ts.map +1 -1
- package/dist/utils/encryption/decrypt.js.map +1 -1
- package/dist/utils/encryption/decrypt.mjs.map +1 -1
- package/dist/utils/encryption/encrypt.d.ts +1 -1
- package/dist/utils/encryption/encrypt.d.ts.map +1 -1
- package/dist/utils/encryption/encrypt.js.map +1 -1
- package/dist/utils/encryption/encrypt.mjs.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/middleware.d.ts +1 -1
- package/dist/utils/middleware.d.ts.map +1 -1
- package/dist/utils/middleware.js.map +1 -1
- package/dist/utils/middleware.mjs.map +1 -1
- package/dist/utils/transaction.d.ts +1 -1
- package/dist/utils/transaction.d.ts.map +1 -1
- package/dist/utils/transaction.js.map +1 -1
- package/dist/utils/transaction.mjs.map +1 -1
- package/dist/utils/transfer-asset-chunk.d.ts +22 -0
- package/dist/utils/transfer-asset-chunk.d.ts.map +1 -1
- package/dist/utils/transfer-asset-chunk.js +25 -0
- package/dist/utils/transfer-asset-chunk.js.map +1 -1
- package/dist/utils/transfer-asset-chunk.mjs +25 -1
- package/dist/utils/transfer-asset-chunk.mjs.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../../../../src/types/remote/protocol/client/transfer/pull.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEnE,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CACrD,MAAM,EACJ,oBAAoB,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,GAC3C,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,GACtC,oBAAoB,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC,GACvD,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CACtD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAE3D,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,gBAAgB,IAAI;KACjE,GAAG,IAAI,gBAAgB,GAAG;QACzB,MAAM,EAAE,QAAQ,CAAC;QACjB,IAAI,EAAE,GAAG,CAAC;KACX,GAAG,mBAAmB;CACxB,CAAC,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC,CAAA;CAAE,GAC1B,CAAC,GACD,KAAK,CAAC;AAEV,KAAK,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEnF,KAAK,gBAAgB,CAAC,CAAC,IAAI;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CreateTransferMessage, TransferAssetFlow } from './utils';
|
|
2
|
+
import type { IEntity, ILink, IConfiguration } from '../../../../common-entities';
|
|
3
|
+
export type TransferPushMessage = CreateTransferMessage<'step', TransferStepCommands<'entities', IEntity[]> | TransferStepCommands<'links', ILink[]> | TransferStepCommands<'configuration', IConfiguration[]> | TransferStepCommands<'assets', TransferAssetFlow[]>>;
|
|
4
|
+
export type GetTransferPushStreamData<T extends TransferPushStep> = {
|
|
5
|
+
[key in TransferPushStep]: {
|
|
6
|
+
action: 'stream';
|
|
7
|
+
step: key;
|
|
8
|
+
} & TransferPushMessage;
|
|
9
|
+
}[T] extends {
|
|
10
|
+
data: infer U;
|
|
11
|
+
} ? U extends any[] ? U : U[] : never;
|
|
12
|
+
export type TransferPushStep = TransferPushMessage['step'];
|
|
13
|
+
type TransferStepCommands<T extends string, U> = {
|
|
14
|
+
step: T;
|
|
15
|
+
} & TransferStepFlow<U>;
|
|
16
|
+
type TransferStepFlow<U> = {
|
|
17
|
+
action: 'start';
|
|
18
|
+
} | {
|
|
19
|
+
action: 'stream';
|
|
20
|
+
data: U;
|
|
21
|
+
} | {
|
|
22
|
+
action: 'end';
|
|
23
|
+
};
|
|
24
|
+
export type Stats = {
|
|
25
|
+
started: number;
|
|
26
|
+
finished: number;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=push.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../../../../src/types/remote/protocol/client/transfer/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElF,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CACrD,MAAM,EACJ,oBAAoB,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,GAC3C,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,GACtC,oBAAoB,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC,GACvD,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CACtD,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,gBAAgB,IAAI;KACjE,GAAG,IAAI,gBAAgB,GAAG;QACzB,MAAM,EAAE,QAAQ,CAAC;QACjB,IAAI,EAAE,GAAG,CAAC;KACX,GAAG,mBAAmB;CACxB,CAAC,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC,CAAA;CAAE,GAC1B,CAAC,SAAS,GAAG,EAAE,GACb,CAAC,GACD,CAAC,EAAE,GACL,KAAK,CAAC;AAEV,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAE3D,KAAK,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEnF,KAAK,gBAAgB,CAAC,CAAC,IAAI;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,CAAC;AAEnG,MAAM,MAAM,KAAK,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { IAsset } from '../../../../common-entities';
|
|
4
|
+
export type CreateTransferMessage<T extends string, U = unknown> = {
|
|
5
|
+
type: 'transfer';
|
|
6
|
+
kind: T;
|
|
7
|
+
transferID: string;
|
|
8
|
+
} & U;
|
|
9
|
+
export type TransferAssetChecksum = {
|
|
10
|
+
algorithm: 'sha256';
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
export type TransferAssetFlow = {
|
|
14
|
+
assetID: string;
|
|
15
|
+
} & ({
|
|
16
|
+
action: 'start';
|
|
17
|
+
data: Omit<IAsset, 'stream'>;
|
|
18
|
+
}
|
|
19
|
+
/** Legacy in-process / default JSON: Buffer serializes to `{ type: 'Buffer'; data: number[] }` on the wire. */
|
|
20
|
+
| {
|
|
21
|
+
action: 'stream';
|
|
22
|
+
data: Buffer;
|
|
23
|
+
encoding?: undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Legacy Buffer JSON shape sent by {@link createTransferAssetStreamChunkLegacy} for remotes that
|
|
27
|
+
* predate #23479 and do `Buffer.from(item.data.data)` directly in their push handler.
|
|
28
|
+
*/
|
|
29
|
+
| {
|
|
30
|
+
action: 'stream';
|
|
31
|
+
data: {
|
|
32
|
+
type: 'Buffer';
|
|
33
|
+
data: number[];
|
|
34
|
+
};
|
|
35
|
+
encoding?: undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Canonical wire form for asset bytes (push + pull). Built with `createTransferAssetStreamChunk`.
|
|
39
|
+
* Decoders also accept legacy Buffer JSON and plain base64 strings without `encoding`.
|
|
40
|
+
*/
|
|
41
|
+
| {
|
|
42
|
+
action: 'stream';
|
|
43
|
+
data: string;
|
|
44
|
+
encoding?: 'base64';
|
|
45
|
+
} | {
|
|
46
|
+
action: 'end';
|
|
47
|
+
checksum?: TransferAssetChecksum;
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/types/remote/protocol/client/transfer/utils.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,OAAO,IAAI;IACjE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,CAAC,CAAC;AAEN,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,QAAQ,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,CAClD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAAE;AACnD,+GAA+G;GAC7G;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE;AAC1D;;;GAGG;GACD;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE;AACtF;;;GAGG;GACD;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,GACvD;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAA;CAAE,CACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/remote/protocol/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum ErrorKind {
|
|
2
|
+
Unknown = 0,
|
|
3
|
+
DiscardChunk = 1,
|
|
4
|
+
InvalidChunkFormat = 2
|
|
5
|
+
}
|
|
6
|
+
export declare class ServerError extends Error {
|
|
7
|
+
code: ErrorKind;
|
|
8
|
+
message: string;
|
|
9
|
+
details?: Record<string, unknown> | null | undefined;
|
|
10
|
+
constructor(code: ErrorKind, message: string, details?: Record<string, unknown> | null | undefined);
|
|
11
|
+
}
|
|
12
|
+
export declare class UnknownError extends ServerError {
|
|
13
|
+
constructor(message: string, details?: Record<string, unknown> | null);
|
|
14
|
+
}
|
|
15
|
+
export declare class DiscardChunkError extends ServerError {
|
|
16
|
+
constructor(message: string, details?: Record<string, unknown> | null);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../src/types/remote/protocol/server/error.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IAEnB,OAAO,IAAI;IAEX,YAAY,IAAI;IAChB,kBAAkB,IAAI;CACvB;AAED,qBAAa,WAAY,SAAQ,KAAK;IAE3B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,MAAM;IACf,OAAO,CAAC;gBAFR,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,4CAAgC;CAIlD;AAED,qBAAa,YAAa,SAAQ,WAAW;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAGtE;AAED,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAGtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/remote/protocol/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TransferKind } from '../client';
|
|
2
|
+
import type { ServerError } from './error';
|
|
3
|
+
import type { Diagnostic } from '../../../../utils/diagnostic';
|
|
4
|
+
export type Message<T = unknown> = {
|
|
5
|
+
uuid?: string;
|
|
6
|
+
data?: T | null;
|
|
7
|
+
error?: ServerError | null;
|
|
8
|
+
diagnostic?: Diagnostic;
|
|
9
|
+
};
|
|
10
|
+
export type OKMessage = Message<{
|
|
11
|
+
ok: true;
|
|
12
|
+
}>;
|
|
13
|
+
export type InitMessage = Message<{
|
|
14
|
+
transferID: string;
|
|
15
|
+
checksums?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Echoed back by the push handler when the client requests `assetEncoding: 'base64'` and the
|
|
18
|
+
* remote understands the compact base64 wire format. When absent, the client falls back to the
|
|
19
|
+
* legacy `{ type: 'Buffer', data: number[] }` asset-chunk shape so pre-#23479 remotes that do
|
|
20
|
+
* `Buffer.from(item.data.data)` directly can still receive pushes.
|
|
21
|
+
*/
|
|
22
|
+
assetEncoding?: 'base64';
|
|
23
|
+
}>;
|
|
24
|
+
export type EndMessage = OKMessage;
|
|
25
|
+
export type StatusMessage = Message<{
|
|
26
|
+
active: true;
|
|
27
|
+
kind: TransferKind;
|
|
28
|
+
startedAt: number;
|
|
29
|
+
elapsed: number;
|
|
30
|
+
} | {
|
|
31
|
+
active: false;
|
|
32
|
+
kind: null;
|
|
33
|
+
startedAt: null;
|
|
34
|
+
elapsed: null;
|
|
35
|
+
}>;
|
|
36
|
+
export type Payload<T extends Message> = T['data'];
|
|
37
|
+
//# sourceMappingURL=messaging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../../../../src/types/remote/protocol/server/messaging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,OAAO,IAAI;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAGF,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;CAC1B,CAAC,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC;AACnC,MAAM,MAAM,aAAa,GAAG,OAAO,CAC/B;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,CAChE,CAAC;AAEF,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { PassThrough } from 'stream';
|
|
3
|
+
import type { ITransferResults, TransferTransforms, TransferProgress } from './utils';
|
|
4
|
+
import type { ISourceProvider, IDestinationProvider } from './providers';
|
|
5
|
+
import type { IDiagnosticReporter } from '../utils/diagnostic';
|
|
6
|
+
import type { Diff } from '../utils/json';
|
|
7
|
+
export type TransferFilterPreset = 'content' | 'files' | 'config';
|
|
8
|
+
export type NextMiddleware<T> = (context: T) => void | Promise<void>;
|
|
9
|
+
export type Middleware<T> = (context: T, next: NextMiddleware<T>) => Promise<void> | void;
|
|
10
|
+
export type SchemaDiffHandlerContext = {
|
|
11
|
+
ignoredDiffs: Record<string, Diff[]>;
|
|
12
|
+
diffs: Record<string, Diff[]>;
|
|
13
|
+
source: ISourceProvider;
|
|
14
|
+
destination: IDestinationProvider;
|
|
15
|
+
};
|
|
16
|
+
export type SchemaDiffHandler = Middleware<SchemaDiffHandlerContext>;
|
|
17
|
+
export type ErrorHandlerContext = {
|
|
18
|
+
ignore?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type ErrorHandler<T extends ErrorHandlerContext = ErrorHandlerContext> = Middleware<T>;
|
|
21
|
+
export type ErrorCode = 'ASSETS_DIRECTORY_ERR';
|
|
22
|
+
export type ErrorHandlers = {
|
|
23
|
+
[k in ErrorCode]: ErrorHandler[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Defines the capabilities and properties of the transfer engine
|
|
27
|
+
*/
|
|
28
|
+
export interface ITransferEngine<S extends ISourceProvider = ISourceProvider, D extends IDestinationProvider = IDestinationProvider> {
|
|
29
|
+
/**
|
|
30
|
+
* Provider used as a source which that will stream its data to the transfer engine
|
|
31
|
+
*/
|
|
32
|
+
sourceProvider: ISourceProvider;
|
|
33
|
+
/**
|
|
34
|
+
* Provider used as a destination that will receive its data from the transfer engine
|
|
35
|
+
*/
|
|
36
|
+
destinationProvider: IDestinationProvider;
|
|
37
|
+
/**
|
|
38
|
+
* The options used to customize the behavio of the transfer engine
|
|
39
|
+
*/
|
|
40
|
+
options: ITransferEngineOptions;
|
|
41
|
+
/**
|
|
42
|
+
* A diagnostic reporter instance used to gather information about
|
|
43
|
+
* errors, warnings and information emitted by the engine
|
|
44
|
+
*/
|
|
45
|
+
diagnostics: IDiagnosticReporter;
|
|
46
|
+
/**
|
|
47
|
+
* Utilities used to retrieve transfer progress data
|
|
48
|
+
*/
|
|
49
|
+
progress: {
|
|
50
|
+
data: TransferProgress;
|
|
51
|
+
stream: PassThrough;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Runs the integrity check which will make sure it's possible
|
|
55
|
+
* to transfer data from the source to the provider.
|
|
56
|
+
*
|
|
57
|
+
* Note: It requires to read the content of the source & destination metadata files
|
|
58
|
+
*/
|
|
59
|
+
integrityCheck(): Promise<void | never>;
|
|
60
|
+
/**
|
|
61
|
+
* Start streaming selected data from the source to the destination
|
|
62
|
+
*/
|
|
63
|
+
transfer(): Promise<ITransferResults<S, D>>;
|
|
64
|
+
/**
|
|
65
|
+
* Run the bootstrap lifecycle method of each provider
|
|
66
|
+
*
|
|
67
|
+
* Note: The bootstrap method can be used to initialize database
|
|
68
|
+
* connections, open files, etc...
|
|
69
|
+
*/
|
|
70
|
+
bootstrap(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Abort the transfer process
|
|
73
|
+
*/
|
|
74
|
+
abortTransfer(): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Run the integrity check which will make sure it's possible
|
|
77
|
+
*/
|
|
78
|
+
reportWarning(message: string, origin?: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* Engine init step. Must be called after the providers bootstrap.
|
|
81
|
+
*/
|
|
82
|
+
init(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Run the close lifecycle method of each provider
|
|
85
|
+
*
|
|
86
|
+
* Note: The close method can be used to gracefully close connections, cleanup the filesystem, etc..
|
|
87
|
+
*/
|
|
88
|
+
close(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Run the preparations before starting a transfer for each provider
|
|
91
|
+
*
|
|
92
|
+
* related source and destination providers
|
|
93
|
+
*/
|
|
94
|
+
beforeTransfer(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Start the schemas transfer by connecting the
|
|
97
|
+
* related source and destination providers streams
|
|
98
|
+
*/
|
|
99
|
+
transferSchemas(): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Start the entities transfer by connecting the
|
|
102
|
+
* related source and destination providers streams
|
|
103
|
+
*/
|
|
104
|
+
transferEntities(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Start the links transfer by connecting the
|
|
107
|
+
* related source and destination providers streams
|
|
108
|
+
*/
|
|
109
|
+
transferLinks(): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Start the asset transfer by connecting the
|
|
112
|
+
* related source and destination providers streams
|
|
113
|
+
*/
|
|
114
|
+
transferAssets(): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Start the configuration transfer by connecting the
|
|
117
|
+
* related source and destination providers streams
|
|
118
|
+
*/
|
|
119
|
+
transferConfiguration(): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Options used to customize the TransferEngine behavior
|
|
123
|
+
*
|
|
124
|
+
* Note: Please add your suggestions. Also, we'll need to consider matching what is
|
|
125
|
+
* written for the CLI with those options at one point
|
|
126
|
+
*
|
|
127
|
+
* Note: here, we're listing the TransferEngine options, not the individual providers' options
|
|
128
|
+
*/
|
|
129
|
+
export interface ITransferEngineOptions {
|
|
130
|
+
/**
|
|
131
|
+
* What kind of version matching should be done between the source and the destination metadata?
|
|
132
|
+
* @example
|
|
133
|
+
* "exact" // must be a strict equality, whatever the format used
|
|
134
|
+
* "ignore" // do not check if versions match
|
|
135
|
+
* "major" // only the major version should match. 4.3.9 and 4.4.1 will work, while 3.3.2 and 4.3.2 won't
|
|
136
|
+
* "minor" // both the major and minor version should match. 4.3.9 and 4.3.11 will work, while 4.3.9 and 4.4.1 won't
|
|
137
|
+
* "patch" // every part of the version should match. Similar to "exact" but only work on semver.
|
|
138
|
+
*/
|
|
139
|
+
versionStrategy: 'exact' | 'ignore' | 'major' | 'minor' | 'patch';
|
|
140
|
+
/**
|
|
141
|
+
* Strategy used to do the schema matching in the integrity checks
|
|
142
|
+
*/
|
|
143
|
+
schemaStrategy: 'exact' | 'strict' | 'ignore';
|
|
144
|
+
transforms?: TransferTransforms;
|
|
145
|
+
exclude?: TransferFilterPreset[];
|
|
146
|
+
only?: TransferFilterPreset[];
|
|
147
|
+
throttle?: number;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=transfer-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer-engine.d.ts","sourceRoot":"","sources":["../../src/types/transfer-engine.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,KAAK,EAAE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BAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;OAQG;IACH,eAAe,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAElE;;OAEG;IACH,cAAc,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAG9C,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAGhC,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAG9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Duplex, Readable, Transform, Writable } from 'stream';
|
|
3
|
+
import type { Knex } from 'knex';
|
|
4
|
+
import type { Struct } from '@strapi/types';
|
|
5
|
+
import type { IAsset, IEntity, ILink } from './common-entities';
|
|
6
|
+
import type { IDestinationProvider, ISourceProvider } from './providers';
|
|
7
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
8
|
+
export type TransferStageTypeMap = {
|
|
9
|
+
schemas: Struct.Schema;
|
|
10
|
+
entities: IEntity;
|
|
11
|
+
links: ILink;
|
|
12
|
+
assets: IAsset;
|
|
13
|
+
configuration: unknown;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Define a transfer transform which will be used to intercept
|
|
17
|
+
* and potentially discard or modify the transferred data
|
|
18
|
+
*/
|
|
19
|
+
export type TransferTransform<T> = TransferFilter<T> | TransferMap<T>;
|
|
20
|
+
export type TransferFilter<T> = {
|
|
21
|
+
filter: (data: T) => boolean;
|
|
22
|
+
};
|
|
23
|
+
export type TransferMap<T> = {
|
|
24
|
+
map: (data: T) => T;
|
|
25
|
+
};
|
|
26
|
+
export type Stream = Readable | Writable | Duplex | Transform;
|
|
27
|
+
export type TransformFunction = (chunk: unknown, encoding?: string) => unknown;
|
|
28
|
+
export type StreamItem = Stream | TransformFunction;
|
|
29
|
+
export type TransferTransformsTypeMap = TransferStageTypeMap & {
|
|
30
|
+
global: unknown;
|
|
31
|
+
};
|
|
32
|
+
export type TransferStage = keyof TransferStageTypeMap;
|
|
33
|
+
export type TransferTransformArray<T extends TransferTransformOption> = TransferTransform<TransferTransformsTypeMap[T]>[];
|
|
34
|
+
export type TransferTransformOption = keyof TransferTransformsTypeMap;
|
|
35
|
+
export type TransferTransforms = {
|
|
36
|
+
[key in TransferTransformOption]?: TransferTransformArray<key>;
|
|
37
|
+
};
|
|
38
|
+
export type TransferFilterArray<T extends TransferTransformOption> = TransferFilter<TransferTransforms[T]>[];
|
|
39
|
+
export type TransferFilters = {
|
|
40
|
+
[key in TransferTransformOption]?: boolean | TransferFilterArray<key>;
|
|
41
|
+
};
|
|
42
|
+
export type StageTotalsEstimate = {
|
|
43
|
+
totalBytes?: number;
|
|
44
|
+
totalCount?: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Per-stage running progress. For `assets`, optional totals describe the full transfer when known
|
|
48
|
+
* (same basis as streamed data: one count per IAsset including formats; bytes = sum of binary file sizes).
|
|
49
|
+
*/
|
|
50
|
+
export type StageProgress = {
|
|
51
|
+
count: number;
|
|
52
|
+
bytes: number;
|
|
53
|
+
startTime: number;
|
|
54
|
+
endTime?: number;
|
|
55
|
+
/** Present when the source can estimate full stage size before/during streaming (e.g. asset library). */
|
|
56
|
+
totalBytes?: number;
|
|
57
|
+
/** Present when the source can estimate how many items the stage will emit. */
|
|
58
|
+
totalCount?: number;
|
|
59
|
+
aggregates?: {
|
|
60
|
+
[key: string]: {
|
|
61
|
+
count: number;
|
|
62
|
+
bytes: number;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export type TransferProgress = {
|
|
67
|
+
[key in TransferStage]?: StageProgress;
|
|
68
|
+
};
|
|
69
|
+
export interface ITransferResults<S extends ISourceProvider, D extends IDestinationProvider> {
|
|
70
|
+
source?: S['results'];
|
|
71
|
+
destination?: D['results'];
|
|
72
|
+
engine?: TransferProgress;
|
|
73
|
+
}
|
|
74
|
+
export type IProviderTransferResults = {};
|
|
75
|
+
export type ISourceProviderTransferResults = {};
|
|
76
|
+
export type IDestinationProviderTransferResults = {};
|
|
77
|
+
export type TransactionCallback = (trx?: Knex.Transaction) => Promise<void>;
|
|
78
|
+
export type Transaction = {
|
|
79
|
+
attach<T = undefined>(callback: TransactionCallback): Promise<T | undefined>;
|
|
80
|
+
end(): boolean;
|
|
81
|
+
rollback(): Promise<boolean>;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEzE,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAG7C,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,C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AG,SAAS,CAAC,CAAC;IAC7E,GAAG,IAAI,OAAO,CAAC;IACf,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -16,6 +16,26 @@ declare const deleteComponents: <TUID extends UID.Schema, TEntity extends Data.E
|
|
|
16
16
|
loadComponents?: boolean | undefined;
|
|
17
17
|
}) => Promise<void>;
|
|
18
18
|
declare const deleteComponent: <TUID extends `${string}.${string}`>(uid: TUID, componentToDelete: Data.Component<TUID>) => Promise<void>;
|
|
19
|
+
interface IComponentIdMapping {
|
|
20
|
+
uid: UID.Component;
|
|
21
|
+
oldID: number;
|
|
22
|
+
newID: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Walk the source data and the newly created entity in parallel and collect
|
|
26
|
+
* the [old ID, new ID] couple of every component instance found in both trees
|
|
27
|
+
* (components & dynamic zones, including nested ones).
|
|
28
|
+
*
|
|
29
|
+
* Unlike a JSON diff, couples are also collected when the ID did not change,
|
|
30
|
+
* so the result is an exhaustive map of every component instance that was
|
|
31
|
+
* re-created with the entity.
|
|
32
|
+
*/
|
|
33
|
+
declare const collectComponentIdMappings: ({ data, created, schema, strapi, }: {
|
|
34
|
+
data: any;
|
|
35
|
+
created: any;
|
|
36
|
+
schema: Schema.Schema;
|
|
37
|
+
strapi: Core.Strapi;
|
|
38
|
+
}) => IComponentIdMapping[];
|
|
19
39
|
/**
|
|
20
40
|
* Resolve the component UID of an entity's attribute based
|
|
21
41
|
* on a given path (components & dynamic zones only)
|
|
@@ -26,5 +46,5 @@ declare const resolveComponentUID: ({ paths, strapi, data, contentType, }: {
|
|
|
26
46
|
data: any;
|
|
27
47
|
contentType: Schema.ContentType;
|
|
28
48
|
}) => UID.Schema | undefined;
|
|
29
|
-
export { omitComponentData, getComponents, createComponents, updateComponents, deleteComponents, deleteComponent, resolveComponentUID, };
|
|
49
|
+
export { omitComponentData, getComponents, createComponents, updateComponents, deleteComponents, deleteComponent, collectComponentIdMappings, resolveComponentUID, };
|
|
30
50
|
//# sourceMappingURL=components.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/utils/components.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAS,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE7E,KAAK,gBAAgB,CAAC,IAAI,SAAS,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAC1D,IAAI,EACJ,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAAC,CAC/D,CAAC;AAMF,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CACjC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,GAChD,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAC/C,MAAM,CAAC,SAAS,CAAC,WAAW,CAC/B,CAAC;CACH,CAAC;AAIF,iBAAS,iBAAiB,CACxB,WAAW,EAAE,MAAM,CAAC,WAAW,EAC/B,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GACvE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/E,iBAAS,iBAAiB,CACxB,WAAW,EAAE,MAAM,CAAC,SAAS,EAC7B,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,G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AM,CAAC,SAAS,CAAC,EAAE,CAAA;CAAE,KACxD,QAAQ,iBAAiB,IAAI,CAAC,CAQhC,CAAC;AAMF,QAAA,MAAM,gBAAgB,uGAIf,IAAI,kBACO;IAAE,EAAE,EAAE,QAAQ,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAA;CAAE,QAC3D,KAAK,2BA0FZ,CAAC;AAkGF,QAAA,MAAM,gBAAgB,oHACf,IAAI,kBACO,OAAO;;mBA6CxB,CAAC;AA8DF,QAAA,MAAM,eAAe,4CACd,IAAI,qBACU,KAAK,SAAS,CAAC,IAAI,CAAC,kBAIxC,CAAC;AAEF,UAAU,mBAAmB;IAC3B,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,0BAA0B,uCAK7B;IACD,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,OAAO,MAAM,CAAC;IACtB,MAAM,EAAE,KAAK,MAAM,CAAC;CACrB,KAAG,mBAAmB,EAkFtB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,mBAAmB,0CAKtB;IACD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,KAAK,MAAM,CAAC;IACpB,IAAI,EAAE,GAAG,CAAC;IACV,WAAW,EAAE,OAAO,WAAW,CAAC;CACjC,KAAG,IAAI,MAAM,GAAG,SAiChB,CAAC;AAEF,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,GACpB,CAAC"}
|
package/dist/utils/components.js
CHANGED
|
@@ -141,38 +141,86 @@ const deleteComponent = async (uid, componentToDelete)=>{
|
|
|
141
141
|
});
|
|
142
142
|
};
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
* Walk the source data and the newly created entity in parallel and collect
|
|
145
|
+
* the [old ID, new ID] couple of every component instance found in both trees
|
|
146
|
+
* (components & dynamic zones, including nested ones).
|
|
147
|
+
*
|
|
148
|
+
* Unlike a JSON diff, couples are also collected when the ID did not change,
|
|
149
|
+
* so the result is an exhaustive map of every component instance that was
|
|
150
|
+
* re-created with the entity.
|
|
151
|
+
*/ const collectComponentIdMappings = ({ data, created, schema, strapi: strapi1 })=>{
|
|
152
|
+
const mappings = [];
|
|
153
|
+
const visitComponent = (uid, oldValue, newValue)=>{
|
|
154
|
+
if (!_.isObjectLike(oldValue) || !_.isObjectLike(newValue)) {
|
|
155
|
+
return;
|
|
155
156
|
}
|
|
156
|
-
if (
|
|
157
|
-
|
|
157
|
+
if (typeof oldValue.id === 'number' && typeof newValue.id === 'number') {
|
|
158
|
+
mappings.push({
|
|
159
|
+
uid,
|
|
160
|
+
oldID: oldValue.id,
|
|
161
|
+
newID: newValue.id
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const componentSchema = strapi1.getModel(uid);
|
|
165
|
+
// Collect nested components & dynamic zones
|
|
166
|
+
if (componentSchema) {
|
|
167
|
+
visitSchema(componentSchema, oldValue, newValue);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const visitSchema = (currentSchema, oldData, newData)=>{
|
|
171
|
+
if (!_.isObjectLike(oldData) || !_.isObjectLike(newData)) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const { attributes = {} } = currentSchema;
|
|
175
|
+
for (const [attributeName, attribute] of Object.entries(attributes)){
|
|
176
|
+
const oldValue = oldData[attributeName];
|
|
177
|
+
const newValue = newData[attributeName];
|
|
178
|
+
if (_.isNil(oldValue) || _.isNil(newValue)) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
158
181
|
if (attribute.type === 'component') {
|
|
159
|
-
|
|
182
|
+
const { component: componentUID, repeatable = false } = attribute;
|
|
183
|
+
if (repeatable === true) {
|
|
184
|
+
if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
// Components are created (and thus populated back) in the same
|
|
188
|
+
// order as the source data, pair them by index
|
|
189
|
+
const length = Math.min(oldValue.length, newValue.length);
|
|
190
|
+
for(let i = 0; i < length; i += 1){
|
|
191
|
+
visitComponent(componentUID, oldValue[i], newValue[i]);
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
visitComponent(componentUID, oldValue, newValue);
|
|
195
|
+
}
|
|
160
196
|
}
|
|
161
197
|
if (attribute.type === 'dynamiczone') {
|
|
162
|
-
|
|
198
|
+
if (!Array.isArray(oldValue) || !Array.isArray(newValue)) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const length = Math.min(oldValue.length, newValue.length);
|
|
202
|
+
for(let i = 0; i < length; i += 1){
|
|
203
|
+
const oldItem = oldValue[i];
|
|
204
|
+
const newItem = newValue[i];
|
|
205
|
+
const componentUID = oldItem?.__component;
|
|
206
|
+
// Both items must reference the same dynamic zone component for the
|
|
207
|
+
// ID couple to be meaningful
|
|
208
|
+
if (!componentUID || newItem?.__component && newItem.__component !== componentUID) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
visitComponent(componentUID, oldItem, newItem);
|
|
212
|
+
}
|
|
163
213
|
}
|
|
164
214
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
return undefined;
|
|
215
|
+
};
|
|
216
|
+
visitSchema(schema, data, created);
|
|
217
|
+
return mappings;
|
|
170
218
|
};
|
|
171
219
|
|
|
220
|
+
exports.collectComponentIdMappings = collectComponentIdMappings;
|
|
172
221
|
exports.createComponents = createComponents;
|
|
173
222
|
exports.deleteComponent = deleteComponent;
|
|
174
223
|
exports.deleteComponents = deleteComponents;
|
|
175
224
|
exports.getComponents = getComponents;
|
|
176
225
|
exports.omitComponentData = omitComponentData;
|
|
177
|
-
exports.resolveComponentUID = resolveComponentUID;
|
|
178
226
|
//# sourceMappingURL=components.js.map
|