@strapi/data-transfer 4.13.0 → 4.13.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/engine/diagnostic.d.ts +40 -0
- package/dist/engine/diagnostic.js +50 -0
- package/dist/engine/diagnostic.js.map +1 -0
- package/dist/engine/errors.d.ts +28 -0
- package/dist/engine/errors.js +29 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/index.d.ts +64 -0
- package/dist/engine/index.js +675 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/validation/index.d.ts +2 -0
- package/dist/engine/validation/index.js +19 -0
- package/dist/engine/validation/index.js.map +1 -0
- package/dist/engine/validation/provider.d.ts +3 -0
- package/dist/engine/validation/provider.js +18 -0
- package/dist/engine/validation/provider.js.map +1 -0
- package/dist/engine/validation/schemas/index.d.ts +7 -0
- package/dist/engine/validation/schemas/index.js +70 -0
- package/dist/engine/validation/schemas/index.js.map +1 -0
- package/dist/errors/base.d.ts +8 -0
- package/dist/errors/base.js +13 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/constants.d.ts +3 -0
- package/dist/errors/constants.js +9 -0
- package/dist/errors/constants.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +19 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/providers.d.ts +23 -0
- package/dist/errors/providers.js +32 -0
- package/dist/errors/providers.js.map +1 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +28 -0
- package/dist/file/index.js.map +1 -0
- package/dist/file/providers/destination/index.d.ts +46 -0
- package/dist/file/providers/destination/index.js +181 -0
- package/dist/file/providers/destination/index.js.map +1 -0
- package/dist/file/providers/destination/utils.d.ts +9 -0
- package/dist/file/providers/destination/utils.js +62 -0
- package/dist/file/providers/destination/utils.js.map +1 -0
- package/dist/file/providers/index.d.ts +2 -0
- package/dist/file/providers/index.js +19 -0
- package/dist/file/providers/index.js.map +1 -0
- package/dist/file/providers/source/index.d.ts +40 -0
- package/dist/file/providers/source/index.js +242 -0
- package/dist/file/providers/source/index.js.map +1 -0
- package/dist/file/providers/source/utils.d.ts +37 -0
- package/dist/file/providers/source/utils.js +62 -0
- package/dist/file/providers/source/utils.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/strapi/index.d.ts +3 -0
- package/dist/strapi/index.js +30 -0
- package/dist/strapi/index.js.map +1 -0
- package/dist/strapi/providers/index.d.ts +4 -0
- package/dist/strapi/providers/index.js +23 -0
- package/dist/strapi/providers/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/index.d.ts +34 -0
- package/dist/strapi/providers/local-destination/index.js +365 -0
- package/dist/strapi/providers/local-destination/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/index.d.ts +1 -0
- package/dist/strapi/providers/local-destination/strategies/index.js +28 -0
- package/dist/strapi/providers/local-destination/strategies/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +5 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +51 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +11 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js +103 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +32 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.js +109 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +4 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.js +32 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -0
- package/dist/strapi/providers/local-source/assets.d.ts +5 -0
- package/dist/strapi/providers/local-source/assets.js +98 -0
- package/dist/strapi/providers/local-source/assets.js.map +1 -0
- package/dist/strapi/providers/local-source/configuration.d.ts +5 -0
- package/dist/strapi/providers/local-source/configuration.js +36 -0
- package/dist/strapi/providers/local-source/configuration.js.map +1 -0
- package/dist/strapi/providers/local-source/entities.d.ts +10 -0
- package/dist/strapi/providers/local-source/entities.js +85 -0
- package/dist/strapi/providers/local-source/entities.js.map +1 -0
- package/dist/strapi/providers/local-source/index.d.ts +26 -0
- package/dist/strapi/providers/local-source/index.js +98 -0
- package/dist/strapi/providers/local-source/index.js.map +1 -0
- package/dist/strapi/providers/local-source/links.d.ts +5 -0
- package/dist/strapi/providers/local-source/links.js +23 -0
- package/dist/strapi/providers/local-source/links.js.map +1 -0
- package/dist/strapi/providers/remote-destination/index.d.ts +39 -0
- package/dist/strapi/providers/remote-destination/index.js +269 -0
- package/dist/strapi/providers/remote-destination/index.js.map +1 -0
- package/dist/strapi/providers/remote-source/index.d.ts +39 -0
- package/dist/strapi/providers/remote-source/index.js +239 -0
- package/dist/strapi/providers/remote-source/index.js.map +1 -0
- package/dist/strapi/providers/utils.d.ts +39 -0
- package/dist/strapi/providers/utils.js +138 -0
- package/dist/strapi/providers/utils.js.map +1 -0
- package/dist/strapi/queries/entity.d.ts +2 -0
- package/dist/strapi/queries/entity.js +130 -0
- package/dist/strapi/queries/entity.js.map +1 -0
- package/dist/strapi/queries/index.d.ts +2 -0
- package/dist/strapi/queries/index.js +29 -0
- package/dist/strapi/queries/index.js.map +1 -0
- package/dist/strapi/queries/link.d.ts +7 -0
- package/dist/strapi/queries/link.js +215 -0
- package/dist/strapi/queries/link.js.map +1 -0
- package/dist/strapi/remote/constants.d.ts +4 -0
- package/dist/strapi/remote/constants.js +6 -0
- package/dist/strapi/remote/constants.js.map +1 -0
- package/dist/strapi/remote/flows/default.d.ts +3 -0
- package/dist/strapi/remote/flows/default.js +41 -0
- package/dist/strapi/remote/flows/default.js.map +1 -0
- package/dist/strapi/remote/flows/index.d.ts +18 -0
- package/dist/strapi/remote/flows/index.js +59 -0
- package/dist/strapi/remote/flows/index.js.map +1 -0
- package/dist/strapi/remote/handlers/abstract.d.ts +71 -0
- package/dist/strapi/remote/handlers/abstract.js +3 -0
- package/dist/strapi/remote/handlers/abstract.js.map +1 -0
- package/dist/strapi/remote/handlers/constants.d.ts +2 -0
- package/dist/strapi/remote/handlers/constants.js +5 -0
- package/dist/strapi/remote/handlers/constants.js.map +1 -0
- package/dist/strapi/remote/handlers/index.d.ts +3 -0
- package/dist/strapi/remote/handlers/index.js +10 -0
- package/dist/strapi/remote/handlers/index.js.map +1 -0
- package/dist/strapi/remote/handlers/pull.d.ts +22 -0
- package/dist/strapi/remote/handlers/pull.js +243 -0
- package/dist/strapi/remote/handlers/pull.js.map +1 -0
- package/dist/strapi/remote/handlers/push.d.ts +75 -0
- package/dist/strapi/remote/handlers/push.js +311 -0
- package/dist/strapi/remote/handlers/push.js.map +1 -0
- package/dist/strapi/remote/handlers/utils.d.ts +25 -0
- package/dist/strapi/remote/handlers/utils.js +217 -0
- package/dist/strapi/remote/handlers/utils.js.map +1 -0
- package/dist/strapi/remote/index.d.ts +2 -0
- package/dist/strapi/remote/index.js +29 -0
- package/dist/strapi/remote/index.js.map +1 -0
- package/dist/utils/encryption/decrypt.d.ts +11 -0
- package/dist/utils/encryption/decrypt.js +47 -0
- package/dist/utils/encryption/decrypt.js.map +1 -0
- package/dist/utils/encryption/encrypt.d.ts +11 -0
- package/dist/utils/encryption/encrypt.js +47 -0
- package/dist/utils/encryption/encrypt.js.map +1 -0
- package/dist/utils/encryption/index.d.ts +2 -0
- package/dist/utils/encryption/index.js +19 -0
- package/dist/utils/encryption/index.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +33 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json.d.ts +30 -0
- package/dist/utils/json.js +68 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/middleware.d.ts +2 -0
- package/dist/utils/middleware.js +14 -0
- package/dist/utils/middleware.js.map +1 -0
- package/dist/utils/providers.d.ts +2 -0
- package/dist/utils/providers.js +11 -0
- package/dist/utils/providers.js.map +1 -0
- package/dist/utils/schema.d.ts +6 -0
- package/dist/utils/schema.js +29 -0
- package/dist/utils/schema.js.map +1 -0
- package/dist/utils/stream.d.ts +27 -0
- package/dist/utils/stream.js +59 -0
- package/dist/utils/stream.js.map +1 -0
- package/dist/utils/transaction.d.ts +3 -0
- package/dist/utils/transaction.js +88 -0
- package/dist/utils/transaction.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDecryptionCipher = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
// different key values depending on algorithm chosen
|
|
6
|
+
const getDecryptionStrategy = (algorithm) => {
|
|
7
|
+
const strategies = {
|
|
8
|
+
'aes-128-ecb'(key) {
|
|
9
|
+
const hashedKey = (0, crypto_1.scryptSync)(key, '', 16);
|
|
10
|
+
const initVector = null;
|
|
11
|
+
const securityKey = hashedKey;
|
|
12
|
+
return (0, crypto_1.createDecipheriv)(algorithm, securityKey, initVector);
|
|
13
|
+
},
|
|
14
|
+
aes128(key) {
|
|
15
|
+
const hashedKey = (0, crypto_1.scryptSync)(key, '', 32);
|
|
16
|
+
const initVector = hashedKey.slice(16);
|
|
17
|
+
const securityKey = hashedKey.slice(0, 16);
|
|
18
|
+
return (0, crypto_1.createDecipheriv)(algorithm, securityKey, initVector);
|
|
19
|
+
},
|
|
20
|
+
aes192(key) {
|
|
21
|
+
const hashedKey = (0, crypto_1.scryptSync)(key, '', 40);
|
|
22
|
+
const initVector = hashedKey.slice(24);
|
|
23
|
+
const securityKey = hashedKey.slice(0, 24);
|
|
24
|
+
return (0, crypto_1.createDecipheriv)(algorithm, securityKey, initVector);
|
|
25
|
+
},
|
|
26
|
+
aes256(key) {
|
|
27
|
+
const hashedKey = (0, crypto_1.scryptSync)(key, '', 48);
|
|
28
|
+
const initVector = hashedKey.slice(32);
|
|
29
|
+
const securityKey = hashedKey.slice(0, 32);
|
|
30
|
+
return (0, crypto_1.createDecipheriv)(algorithm, securityKey, initVector);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return strategies[algorithm];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* It creates a cipher instance used for decryption
|
|
37
|
+
*
|
|
38
|
+
* @param key - The decryption key
|
|
39
|
+
* @param algorithm - The algorithm to use to create the Cipher
|
|
40
|
+
*
|
|
41
|
+
* @returns A {@link Cipher} instance created with the given key & algorithm
|
|
42
|
+
*/
|
|
43
|
+
const createDecryptionCipher = (key, algorithm = 'aes-128-ecb') => {
|
|
44
|
+
return getDecryptionStrategy(algorithm)(key);
|
|
45
|
+
};
|
|
46
|
+
exports.createDecryptionCipher = createDecryptionCipher;
|
|
47
|
+
//# sourceMappingURL=decrypt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decrypt.js","sourceRoot":"","sources":["../../../src/utils/encryption/decrypt.ts"],"names":[],"mappings":";;;AAAA,mCAAqF;AAGrF,qDAAqD;AACrD,MAAM,qBAAqB,GAAG,CAAC,SAAoB,EAAsB,EAAE;IACzE,MAAM,UAAU,GAAe;QAC7B,aAAa,CAAC,GAAW;YACvB,MAAM,SAAS,GAAG,IAAA,mBAAU,EAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1C,MAAM,UAAU,GAAsB,IAAI,CAAC;YAC3C,MAAM,WAAW,GAAc,SAAS,CAAC;YACzC,OAAO,IAAA,yBAAgB,EAAC,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,CAAC,GAAW;YAChB,MAAM,SAAS,GAAG,IAAA,mBAAU,EAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1C,MAAM,UAAU,GAAsB,SAAS,CAAC,KAAK,CAAC,EAAE,CA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
+
/**
|
|
4
|
+
* It creates a cipher instance used for encryption
|
|
5
|
+
*
|
|
6
|
+
* @param key - The encryption key
|
|
7
|
+
* @param algorithm - The algorithm to use to create the Cipher
|
|
8
|
+
*
|
|
9
|
+
* @returns A {@link Cipher} instance created with the given key & algorithm
|
|
10
|
+
*/
|
|
11
|
+
export declare const createEncryptionCipher: (key: string, algorithm?: Algorithm) => Cipher;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEncryptionCipher = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
// different key values depending on algorithm chosen
|
|
6
|
+
const getEncryptionStrategy = (algorithm) => {
|
|
7
|
+
const strategies = {
|
|
8
|
+
'aes-128-ecb'(key) {
|
|
9
|
+
const hashedKey = (0, crypto_1.scryptSync)(key, '', 16);
|
|
10
|
+
const initVector = null;
|
|
11
|
+
const securityKey = hashedKey;
|
|
12
|
+
return (0, crypto_1.createCipheriv)(algorithm, securityKey, initVector);
|
|
13
|
+
},
|
|
14
|
+
aes128(key) {
|
|
15
|
+
const hashedKey = (0, crypto_1.scryptSync)(key, '', 32);
|
|
16
|
+
const initVector = hashedKey.slice(16);
|
|
17
|
+
const securityKey = hashedKey.slice(0, 16);
|
|
18
|
+
return (0, crypto_1.createCipheriv)(algorithm, securityKey, initVector);
|
|
19
|
+
},
|
|
20
|
+
aes192(key) {
|
|
21
|
+
const hashedKey = (0, crypto_1.scryptSync)(key, '', 40);
|
|
22
|
+
const initVector = hashedKey.slice(24);
|
|
23
|
+
const securityKey = hashedKey.slice(0, 24);
|
|
24
|
+
return (0, crypto_1.createCipheriv)(algorithm, securityKey, initVector);
|
|
25
|
+
},
|
|
26
|
+
aes256(key) {
|
|
27
|
+
const hashedKey = (0, crypto_1.scryptSync)(key, '', 48);
|
|
28
|
+
const initVector = hashedKey.slice(32);
|
|
29
|
+
const securityKey = hashedKey.slice(0, 32);
|
|
30
|
+
return (0, crypto_1.createCipheriv)(algorithm, securityKey, initVector);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return strategies[algorithm];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* It creates a cipher instance used for encryption
|
|
37
|
+
*
|
|
38
|
+
* @param key - The encryption key
|
|
39
|
+
* @param algorithm - The algorithm to use to create the Cipher
|
|
40
|
+
*
|
|
41
|
+
* @returns A {@link Cipher} instance created with the given key & algorithm
|
|
42
|
+
*/
|
|
43
|
+
const createEncryptionCipher = (key, algorithm = 'aes-128-ecb') => {
|
|
44
|
+
return getEncryptionStrategy(algorithm)(key);
|
|
45
|
+
};
|
|
46
|
+
exports.createEncryptionCipher = createEncryptionCipher;
|
|
47
|
+
//# sourceMappingURL=encrypt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encrypt.js","sourceRoot":"","sources":["../../../src/utils/encryption/encrypt.ts"],"names":[],"mappings":";;;AAAA,mCAAmF;AAGnF,qDAAqD;AACrD,MAAM,qBAAqB,GAAG,CAAC,SAAoB,EAAsB,EAAE;IACzE,MAAM,UAAU,GAAe;QAC7B,aAAa,CAAC,GAAW;YACvB,MAAM,SAAS,GAAG,IAAA,mBAAU,EAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1C,MAAM,UAAU,GAAsB,IAAI,CAAC;YAC3C,MAAM,WAAW,GAAc,SAAS,CAAC;YACzC,OAAO,IAAA,uBAAc,EAAC,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,CAAC,GAAW;YAChB,MAAM,SAAS,GAAG,IAAA,mBAAU,EAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1C,MAAM,UAAU,GAAsB,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC1D,MAAM,WAAW,GAAc,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACtD,OAAO,IAAA,uBAAc,EAAC,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,CAAC,GAAW;YAChB,MAAM,SAAS,GAAG,IAAA,mBAAU,EAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1C,MAAM,UAAU,GAAsB,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC1D,MAAM,WAAW,GAAc,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACtD,OAAO,IAAA,uBAAc,EAAC,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,CAAC,GAAW;YAChB,MAAM,SAAS,GAAG,IAAA,mBAAU,EAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1C,MAAM,UAAU,GAAsB,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC1D,MAAM,WAAW,GAAc,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACtD,OAAO,IAAA,uBAAc,EAAC,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC;IAEF,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CACpC,GAAW,EACX,YAAuB,aAAa,EAC5B,EAAE;IACV,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;AAC/C,CAAC,CAAC;AALW,QAAA,sBAAsB,0BAKjC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./encrypt"), exports);
|
|
18
|
+
__exportStar(require("./decrypt"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/encryption/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.middleware = exports.transaction = exports.schema = exports.json = exports.stream = exports.encryption = void 0;
|
|
27
|
+
exports.encryption = __importStar(require("./encryption"));
|
|
28
|
+
exports.stream = __importStar(require("./stream"));
|
|
29
|
+
exports.json = __importStar(require("./json"));
|
|
30
|
+
exports.schema = __importStar(require("./schema"));
|
|
31
|
+
exports.transaction = __importStar(require("./transaction"));
|
|
32
|
+
exports.middleware = __importStar(require("./middleware"));
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA2C;AAC3C,mDAAmC;AACnC,+CAA+B;AAC/B,mDAAmC;AACnC,6DAA6C;AAC7C,2DAA2C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute differences between two JSON objects and returns them
|
|
3
|
+
*
|
|
4
|
+
* @param a - First object
|
|
5
|
+
* @param b - Second object
|
|
6
|
+
* @param ctx - Context used to keep track of the current path during recursion
|
|
7
|
+
*/
|
|
8
|
+
export declare const diff: (a: unknown, b: unknown, ctx?: Context) => Diff[];
|
|
9
|
+
export interface AddedDiff<T = unknown> {
|
|
10
|
+
kind: 'added';
|
|
11
|
+
path: string[];
|
|
12
|
+
type: string;
|
|
13
|
+
value: T;
|
|
14
|
+
}
|
|
15
|
+
export interface ModifiedDiff<T = unknown, P = unknown> {
|
|
16
|
+
kind: 'modified';
|
|
17
|
+
path: string[];
|
|
18
|
+
types: [string, string];
|
|
19
|
+
values: [T, P];
|
|
20
|
+
}
|
|
21
|
+
export interface DeletedDiff<T = unknown> {
|
|
22
|
+
kind: 'deleted';
|
|
23
|
+
path: string[];
|
|
24
|
+
type: string;
|
|
25
|
+
value: T;
|
|
26
|
+
}
|
|
27
|
+
export type Diff<T = unknown> = AddedDiff<T> | ModifiedDiff<T> | DeletedDiff<T>;
|
|
28
|
+
export interface Context {
|
|
29
|
+
path: string[];
|
|
30
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.diff = void 0;
|
|
4
|
+
const fp_1 = require("lodash/fp");
|
|
5
|
+
const createContext = () => ({ path: [] });
|
|
6
|
+
/**
|
|
7
|
+
* Compute differences between two JSON objects and returns them
|
|
8
|
+
*
|
|
9
|
+
* @param a - First object
|
|
10
|
+
* @param b - Second object
|
|
11
|
+
* @param ctx - Context used to keep track of the current path during recursion
|
|
12
|
+
*/
|
|
13
|
+
const diff = (a, b, ctx = createContext()) => {
|
|
14
|
+
const diffs = [];
|
|
15
|
+
const { path } = ctx;
|
|
16
|
+
const aType = typeof a;
|
|
17
|
+
const bType = typeof b;
|
|
18
|
+
// Define helpers
|
|
19
|
+
const added = () => {
|
|
20
|
+
diffs.push({ kind: 'added', path, type: bType, value: b });
|
|
21
|
+
return diffs;
|
|
22
|
+
};
|
|
23
|
+
const deleted = () => {
|
|
24
|
+
diffs.push({ kind: 'deleted', path, type: aType, value: a });
|
|
25
|
+
return diffs;
|
|
26
|
+
};
|
|
27
|
+
const modified = () => {
|
|
28
|
+
diffs.push({
|
|
29
|
+
kind: 'modified',
|
|
30
|
+
path,
|
|
31
|
+
types: [aType, bType],
|
|
32
|
+
values: [a, b],
|
|
33
|
+
});
|
|
34
|
+
return diffs;
|
|
35
|
+
};
|
|
36
|
+
if ((0, fp_1.isArray)(a) && (0, fp_1.isArray)(b)) {
|
|
37
|
+
let k = 0;
|
|
38
|
+
for (const [aItem, bItem] of (0, fp_1.zip)(a, b)) {
|
|
39
|
+
const kCtx = { path: [...path, k.toString()] };
|
|
40
|
+
const kDiffs = (0, exports.diff)(aItem, bItem, kCtx);
|
|
41
|
+
diffs.push(...kDiffs);
|
|
42
|
+
k += 1;
|
|
43
|
+
}
|
|
44
|
+
return diffs;
|
|
45
|
+
}
|
|
46
|
+
if ((0, fp_1.isObject)(a) && (0, fp_1.isObject)(b)) {
|
|
47
|
+
const keys = (0, fp_1.uniq)(Object.keys(a).concat(Object.keys(b)));
|
|
48
|
+
for (const key of keys) {
|
|
49
|
+
const aValue = a[key];
|
|
50
|
+
const bValue = b[key];
|
|
51
|
+
const nestedDiffs = (0, exports.diff)(aValue, bValue, { path: [...path, key] });
|
|
52
|
+
diffs.push(...nestedDiffs);
|
|
53
|
+
}
|
|
54
|
+
return diffs;
|
|
55
|
+
}
|
|
56
|
+
if (!(0, fp_1.isEqual)(a, b)) {
|
|
57
|
+
if (aType === 'undefined') {
|
|
58
|
+
return added();
|
|
59
|
+
}
|
|
60
|
+
if (bType === 'undefined') {
|
|
61
|
+
return deleted();
|
|
62
|
+
}
|
|
63
|
+
return modified();
|
|
64
|
+
}
|
|
65
|
+
return diffs;
|
|
66
|
+
};
|
|
67
|
+
exports.diff = diff;
|
|
68
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/utils/json.ts"],"names":[],"mappings":";;;AAAA,kCAAkE;AAElE,MAAM,aAAa,GAAG,GAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAEpD;;;;;;GAMG;AACI,MAAM,IAAI,GAAG,CAAC,CAAU,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
|
|
3
|
+
exports.runMiddleware = void 0;
|
|
4
|
+
const runMiddleware = async (context, middlewares) => {
|
|
5
|
+
if (!middlewares.length) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const cb = middlewares[0];
|
|
9
|
+
await cb(context, async (newContext) => {
|
|
10
|
+
await (0, exports.runMiddleware)(newContext, middlewares.slice(1));
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
exports.runMiddleware = runMiddleware;
|
|
14
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/utils/middleware.ts"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,GAAG,KAAK,EAAK,OAAU,EAAE,WAA4B,EAAiB,EAAE;IAChG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;QACvB,OAAO;KACR;IACD,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,UAAa,EAAE,EAAE;QACxC,MAAM,IAAA,qBAAa,EAAC,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertValidStrapi = void 0;
|
|
4
|
+
const providers_1 = require("../errors/providers");
|
|
5
|
+
const assertValidStrapi = (strapi, msg = '') => {
|
|
6
|
+
if (!strapi) {
|
|
7
|
+
throw new providers_1.ProviderInitializationError(`${msg}. Strapi instance not found.`);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
exports.assertValidStrapi = assertValidStrapi;
|
|
11
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAO3D,MAAM,iBAAiB,GAAyB,CAAC,MAAgB,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE;IACpF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,uCAA2B,CAAC,GAAG,GAAG,8BAA8B,CAAC,CAAC;KAC7E;AACH,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Schema, Utils } from '@strapi/strapi';
|
|
2
|
+
/**
|
|
3
|
+
* Sanitize a schemas dictionary by omitting unwanted properties
|
|
4
|
+
* The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES}
|
|
5
|
+
*/
|
|
6
|
+
export declare const mapSchemasValues: (schemas: Utils.String.Dict<Schema.Schema>) => Utils.String.Dict<Schema.Schema>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapSchemasValues = void 0;
|
|
4
|
+
const fp_1 = require("lodash/fp");
|
|
5
|
+
/**
|
|
6
|
+
* List of schema properties that should be kept when sanitizing schemas
|
|
7
|
+
*/
|
|
8
|
+
const VALID_SCHEMA_PROPERTIES = [
|
|
9
|
+
'collectionName',
|
|
10
|
+
'info',
|
|
11
|
+
'options',
|
|
12
|
+
'pluginOptions',
|
|
13
|
+
'attributes',
|
|
14
|
+
'kind',
|
|
15
|
+
'modelType',
|
|
16
|
+
'modelName',
|
|
17
|
+
'uid',
|
|
18
|
+
'plugin',
|
|
19
|
+
'globalId',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Sanitize a schemas dictionary by omitting unwanted properties
|
|
23
|
+
* The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES}
|
|
24
|
+
*/
|
|
25
|
+
const mapSchemasValues = (schemas) => {
|
|
26
|
+
return (0, fp_1.mapValues)((0, fp_1.pick)(VALID_SCHEMA_PROPERTIES), schemas);
|
|
27
|
+
};
|
|
28
|
+
exports.mapSchemasValues = mapSchemasValues;
|
|
29
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":";;;AACA,kCAA4C;AAE5C;;GAEG;AACH,MAAM,uBAAuB,GAAG;IAC9B,gBAAgB;IAChB,MAAM;IACN,SAAS;IACT,eAAe;IACf,YAAY;IACZ,MAAM;IACN,WAAW;IACX,WAAW;IACX,KAAK;IACL,QAAQ;IACR,UAAU;CACX,CAAC;AAEF;;;GAGG;AACI,MAAM,gBAAgB,GAAG,CAAC,OAAyC,EAAE,EAAE;IAC5E,OAAO,IAAA,cAAS,EAAC,IAAA,SAAI,EAAC,uBAAuB,CAAC,EAAE,OAAO,CAAqC,CAAC;AAC/F,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Transform, Readable } from 'stream';
|
|
3
|
+
type TransformOptions = ConstructorParameters<typeof Transform>[0];
|
|
4
|
+
/**
|
|
5
|
+
* Create a filter stream that discard chunks which doesn't satisfies the given predicate
|
|
6
|
+
*
|
|
7
|
+
* @param predicate - A filter predicate, takes a stream data chunk as parameter and returns a boolean value
|
|
8
|
+
* @param options - Transform stream options
|
|
9
|
+
*/
|
|
10
|
+
export declare const filter: <T>(predicate: (value: T) => boolean | Promise<boolean>, options?: TransformOptions) => Transform;
|
|
11
|
+
/**
|
|
12
|
+
* Create a map stream that transform chunks using the given predicate
|
|
13
|
+
*
|
|
14
|
+
* @param predicate - A map predicate, takes a stream data chunk as parameter and returns a mapped value
|
|
15
|
+
* @param options - Transform stream options
|
|
16
|
+
*/
|
|
17
|
+
export declare const map: <T, U = T>(predicate: (value: T) => U | Promise<U>, options?: TransformOptions) => Transform;
|
|
18
|
+
/**
|
|
19
|
+
* Collect every chunks from a Readable stream.
|
|
20
|
+
*
|
|
21
|
+
* @param stream - The redable stream to collect data from
|
|
22
|
+
* @param options.destroy - If set to true, it automatically calls `destroy()` on the given stream upon receiving the 'end' event
|
|
23
|
+
*/
|
|
24
|
+
export declare const collect: <T = unknown>(stream: Readable, options?: {
|
|
25
|
+
destroy: boolean;
|
|
26
|
+
}) => Promise<T[]>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collect = exports.map = exports.filter = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
/**
|
|
6
|
+
* Create a filter stream that discard chunks which doesn't satisfies the given predicate
|
|
7
|
+
*
|
|
8
|
+
* @param predicate - A filter predicate, takes a stream data chunk as parameter and returns a boolean value
|
|
9
|
+
* @param options - Transform stream options
|
|
10
|
+
*/
|
|
11
|
+
const filter = (predicate, options = { objectMode: true }) => {
|
|
12
|
+
return new stream_1.Transform({
|
|
13
|
+
...options,
|
|
14
|
+
async transform(chunk, _encoding, callback) {
|
|
15
|
+
const keep = await predicate(chunk);
|
|
16
|
+
callback(null, keep ? chunk : undefined);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.filter = filter;
|
|
21
|
+
/**
|
|
22
|
+
* Create a map stream that transform chunks using the given predicate
|
|
23
|
+
*
|
|
24
|
+
* @param predicate - A map predicate, takes a stream data chunk as parameter and returns a mapped value
|
|
25
|
+
* @param options - Transform stream options
|
|
26
|
+
*/
|
|
27
|
+
const map = (predicate, options = { objectMode: true }) => {
|
|
28
|
+
return new stream_1.Transform({
|
|
29
|
+
...options,
|
|
30
|
+
async transform(chunk, _encoding, callback) {
|
|
31
|
+
const mappedValue = await predicate(chunk);
|
|
32
|
+
callback(null, mappedValue);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.map = map;
|
|
37
|
+
/**
|
|
38
|
+
* Collect every chunks from a Readable stream.
|
|
39
|
+
*
|
|
40
|
+
* @param stream - The redable stream to collect data from
|
|
41
|
+
* @param options.destroy - If set to true, it automatically calls `destroy()` on the given stream upon receiving the 'end' event
|
|
42
|
+
*/
|
|
43
|
+
const collect = (stream, options = { destroy: true }) => {
|
|
44
|
+
const chunks = [];
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
stream
|
|
47
|
+
.on('close', () => resolve(chunks))
|
|
48
|
+
.on('error', reject)
|
|
49
|
+
.on('data', (chunk) => chunks.push(chunk))
|
|
50
|
+
.on('end', () => {
|
|
51
|
+
if (options.destroy) {
|
|
52
|
+
stream.destroy();
|
|
53
|
+
}
|
|
54
|
+
resolve(chunks);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
exports.collect = collect;
|
|
59
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":";;;AAAA,mCAA6C;AAI7C;;;;;GAKG;AACI,MAAM,MAAM,GAAG,CACpB,SAAmD,EACnD,UAA4B,EAAE,UAAU,EAAE,IAAI,EAAE,EACrC,EAAE;IACb,OAAO,IAAI,kBAAS,CAAC;QACnB,GAAG,OAAO;QAEV,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ;YACxC,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;YAEpC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAbW,QAAA,MAAM,UAajB;AAEF;;;;;GAKG;AACI,MAAM,GAAG,GAAG,CACjB,SAAuC,EACvC,UAA4B,EAAE,UAAU,EAAE,IAAI,EAAE,EACrC,EAAE;IACb,OAAO,IAAI,kBAAS,CAAC;QACnB,GAAG,OAAO;QAEV,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ;YACxC,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;YAE3C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAbW,QAAA,GAAG,OAad;AAEF;;;;;GAKG;AACI,MAAM,OAAO,GAAG,CACrB,MAAgB,EAChB,UAAgC,EAAE,OAAO,EAAE,IAAI,EAAE,EACnC,EAAE;IAChB,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM;aACH,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aAClC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;aACnB,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACzC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACd,IAAI,OAAO,CAAC,OAAO,EAAE;gBACnB,MAAM,CAAC,OAAO,EAAE,CAAC;aAClB;YAED,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAnBW,QAAA,OAAO,WAmBlB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTransaction = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const createTransaction = (strapi) => {
|
|
7
|
+
const fns = [];
|
|
8
|
+
let done = false;
|
|
9
|
+
let resume = null;
|
|
10
|
+
const e = new events_1.EventEmitter();
|
|
11
|
+
e.on('spawn', (uuid, cb) => {
|
|
12
|
+
fns.push({ fn: cb, uuid });
|
|
13
|
+
resume?.();
|
|
14
|
+
});
|
|
15
|
+
e.on('close', () => {
|
|
16
|
+
e.removeAllListeners('rollback');
|
|
17
|
+
e.removeAllListeners('spawn');
|
|
18
|
+
done = true;
|
|
19
|
+
resume?.();
|
|
20
|
+
});
|
|
21
|
+
strapi.db.transaction(async ({ trx, rollback }) => {
|
|
22
|
+
e.once('rollback', async () => {
|
|
23
|
+
e.removeAllListeners('close');
|
|
24
|
+
e.removeAllListeners('spawn');
|
|
25
|
+
try {
|
|
26
|
+
await rollback();
|
|
27
|
+
e.emit('rollback_completed');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
e.emit('rollback_failed');
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
done = true;
|
|
34
|
+
resume?.();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
while (!done) {
|
|
38
|
+
while (fns.length) {
|
|
39
|
+
const item = fns.shift();
|
|
40
|
+
if (item) {
|
|
41
|
+
const { fn, uuid } = item;
|
|
42
|
+
try {
|
|
43
|
+
const res = await fn(trx);
|
|
44
|
+
e.emit(uuid, { data: res });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
e.emit(uuid, { error });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!done && !fns.length) {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
53
|
+
await new Promise((resolve) => {
|
|
54
|
+
resume = resolve;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
async attach(callback) {
|
|
61
|
+
const uuid = (0, crypto_1.randomUUID)();
|
|
62
|
+
e.emit('spawn', uuid, callback);
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
e.on(uuid, ({ data, error }) => {
|
|
65
|
+
if (data) {
|
|
66
|
+
resolve(data);
|
|
67
|
+
}
|
|
68
|
+
if (error) {
|
|
69
|
+
reject(error);
|
|
70
|
+
}
|
|
71
|
+
resolve(undefined);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
end() {
|
|
76
|
+
return e.emit('close');
|
|
77
|
+
},
|
|
78
|
+
rollback() {
|
|
79
|
+
return new Promise((resolve) => {
|
|
80
|
+
e.emit('rollback');
|
|
81
|
+
e.once('rollback_failed', () => resolve(false));
|
|
82
|
+
e.once('rollback_completed', () => resolve(true));
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
exports.createTransaction = createTransaction;
|
|
88
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,mCAAoC;AAK7B,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAe,EAAE;IAC/D,MAAM,GAAG,GAAgD,EAAE,CAAC;IAE5D,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,MAAM,GAAwB,IAAI,CAAC;IAEvC,MAAM,CAAC,GAAG,IAAI,qBAAY,EAAE,CAAC;IAC7B,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE;QACzB,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3B,MAAM,EAAE,EAAE,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,CAAC,CAAC,EAAE,CA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CAAC,CAAC;AA3FW,QAAA,iBAAiB,qBA2F5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/data-transfer",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.1",
|
|
4
4
|
"description": "Data transfer capabilities for Strapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"./dist"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@strapi/logger": "4.13.
|
|
44
|
-
"@strapi/strapi": "4.13.
|
|
43
|
+
"@strapi/logger": "4.13.1",
|
|
44
|
+
"@strapi/strapi": "4.13.1",
|
|
45
45
|
"chalk": "4.1.2",
|
|
46
46
|
"fs-extra": "10.0.0",
|
|
47
47
|
"lodash": "4.17.21",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"node": ">=16.0.0 <=20.x.x",
|
|
77
77
|
"npm": ">=6.0.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "a9afeb90c525d9b8ab033aa0c87e03a72134e0dd"
|
|
80
80
|
}
|