@strapi/data-transfer 4.13.0-beta.0 → 4.13.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.
Files changed (169) hide show
  1. package/package.json +5 -5
  2. package/dist/engine/diagnostic.d.ts +0 -40
  3. package/dist/engine/diagnostic.js +0 -50
  4. package/dist/engine/diagnostic.js.map +0 -1
  5. package/dist/engine/errors.d.ts +0 -28
  6. package/dist/engine/errors.js +0 -29
  7. package/dist/engine/errors.js.map +0 -1
  8. package/dist/engine/index.d.ts +0 -64
  9. package/dist/engine/index.js +0 -664
  10. package/dist/engine/index.js.map +0 -1
  11. package/dist/engine/validation/index.d.ts +0 -2
  12. package/dist/engine/validation/index.js +0 -19
  13. package/dist/engine/validation/index.js.map +0 -1
  14. package/dist/engine/validation/provider.d.ts +0 -3
  15. package/dist/engine/validation/provider.js +0 -18
  16. package/dist/engine/validation/provider.js.map +0 -1
  17. package/dist/engine/validation/schemas/index.d.ts +0 -7
  18. package/dist/engine/validation/schemas/index.js +0 -70
  19. package/dist/engine/validation/schemas/index.js.map +0 -1
  20. package/dist/errors/base.d.ts +0 -8
  21. package/dist/errors/base.js +0 -13
  22. package/dist/errors/base.js.map +0 -1
  23. package/dist/errors/constants.d.ts +0 -3
  24. package/dist/errors/constants.js +0 -9
  25. package/dist/errors/constants.js.map +0 -1
  26. package/dist/errors/index.d.ts +0 -2
  27. package/dist/errors/index.js +0 -19
  28. package/dist/errors/index.js.map +0 -1
  29. package/dist/errors/providers.d.ts +0 -23
  30. package/dist/errors/providers.js +0 -32
  31. package/dist/errors/providers.js.map +0 -1
  32. package/dist/file/index.d.ts +0 -1
  33. package/dist/file/index.js +0 -28
  34. package/dist/file/index.js.map +0 -1
  35. package/dist/file/providers/destination/index.d.ts +0 -46
  36. package/dist/file/providers/destination/index.js +0 -181
  37. package/dist/file/providers/destination/index.js.map +0 -1
  38. package/dist/file/providers/destination/utils.d.ts +0 -9
  39. package/dist/file/providers/destination/utils.js +0 -62
  40. package/dist/file/providers/destination/utils.js.map +0 -1
  41. package/dist/file/providers/index.d.ts +0 -2
  42. package/dist/file/providers/index.js +0 -19
  43. package/dist/file/providers/index.js.map +0 -1
  44. package/dist/file/providers/source/index.d.ts +0 -40
  45. package/dist/file/providers/source/index.js +0 -242
  46. package/dist/file/providers/source/index.js.map +0 -1
  47. package/dist/file/providers/source/utils.d.ts +0 -37
  48. package/dist/file/providers/source/utils.js +0 -62
  49. package/dist/file/providers/source/utils.js.map +0 -1
  50. package/dist/index.d.ts +0 -4
  51. package/dist/index.js +0 -31
  52. package/dist/index.js.map +0 -1
  53. package/dist/strapi/index.d.ts +0 -3
  54. package/dist/strapi/index.js +0 -30
  55. package/dist/strapi/index.js.map +0 -1
  56. package/dist/strapi/providers/index.d.ts +0 -4
  57. package/dist/strapi/providers/index.js +0 -23
  58. package/dist/strapi/providers/index.js.map +0 -1
  59. package/dist/strapi/providers/local-destination/index.d.ts +0 -34
  60. package/dist/strapi/providers/local-destination/index.js +0 -321
  61. package/dist/strapi/providers/local-destination/index.js.map +0 -1
  62. package/dist/strapi/providers/local-destination/strategies/index.d.ts +0 -1
  63. package/dist/strapi/providers/local-destination/strategies/index.js +0 -28
  64. package/dist/strapi/providers/local-destination/strategies/index.js.map +0 -1
  65. package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +0 -5
  66. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +0 -51
  67. package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +0 -1
  68. package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +0 -11
  69. package/dist/strapi/providers/local-destination/strategies/restore/entities.js +0 -103
  70. package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +0 -1
  71. package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +0 -32
  72. package/dist/strapi/providers/local-destination/strategies/restore/index.js +0 -107
  73. package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +0 -1
  74. package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +0 -4
  75. package/dist/strapi/providers/local-destination/strategies/restore/links.js +0 -32
  76. package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +0 -1
  77. package/dist/strapi/providers/local-source/assets.d.ts +0 -5
  78. package/dist/strapi/providers/local-source/assets.js +0 -98
  79. package/dist/strapi/providers/local-source/assets.js.map +0 -1
  80. package/dist/strapi/providers/local-source/configuration.d.ts +0 -5
  81. package/dist/strapi/providers/local-source/configuration.js +0 -36
  82. package/dist/strapi/providers/local-source/configuration.js.map +0 -1
  83. package/dist/strapi/providers/local-source/entities.d.ts +0 -10
  84. package/dist/strapi/providers/local-source/entities.js +0 -85
  85. package/dist/strapi/providers/local-source/entities.js.map +0 -1
  86. package/dist/strapi/providers/local-source/index.d.ts +0 -26
  87. package/dist/strapi/providers/local-source/index.js +0 -98
  88. package/dist/strapi/providers/local-source/index.js.map +0 -1
  89. package/dist/strapi/providers/local-source/links.d.ts +0 -5
  90. package/dist/strapi/providers/local-source/links.js +0 -23
  91. package/dist/strapi/providers/local-source/links.js.map +0 -1
  92. package/dist/strapi/providers/remote-destination/index.d.ts +0 -39
  93. package/dist/strapi/providers/remote-destination/index.js +0 -269
  94. package/dist/strapi/providers/remote-destination/index.js.map +0 -1
  95. package/dist/strapi/providers/remote-source/index.d.ts +0 -39
  96. package/dist/strapi/providers/remote-source/index.js +0 -239
  97. package/dist/strapi/providers/remote-source/index.js.map +0 -1
  98. package/dist/strapi/providers/utils.d.ts +0 -39
  99. package/dist/strapi/providers/utils.js +0 -138
  100. package/dist/strapi/providers/utils.js.map +0 -1
  101. package/dist/strapi/queries/entity.d.ts +0 -2
  102. package/dist/strapi/queries/entity.js +0 -130
  103. package/dist/strapi/queries/entity.js.map +0 -1
  104. package/dist/strapi/queries/index.d.ts +0 -2
  105. package/dist/strapi/queries/index.js +0 -29
  106. package/dist/strapi/queries/index.js.map +0 -1
  107. package/dist/strapi/queries/link.d.ts +0 -7
  108. package/dist/strapi/queries/link.js +0 -215
  109. package/dist/strapi/queries/link.js.map +0 -1
  110. package/dist/strapi/remote/constants.d.ts +0 -4
  111. package/dist/strapi/remote/constants.js +0 -6
  112. package/dist/strapi/remote/constants.js.map +0 -1
  113. package/dist/strapi/remote/flows/default.d.ts +0 -3
  114. package/dist/strapi/remote/flows/default.js +0 -41
  115. package/dist/strapi/remote/flows/default.js.map +0 -1
  116. package/dist/strapi/remote/flows/index.d.ts +0 -18
  117. package/dist/strapi/remote/flows/index.js +0 -59
  118. package/dist/strapi/remote/flows/index.js.map +0 -1
  119. package/dist/strapi/remote/handlers/abstract.d.ts +0 -71
  120. package/dist/strapi/remote/handlers/abstract.js +0 -3
  121. package/dist/strapi/remote/handlers/abstract.js.map +0 -1
  122. package/dist/strapi/remote/handlers/constants.d.ts +0 -2
  123. package/dist/strapi/remote/handlers/constants.js +0 -5
  124. package/dist/strapi/remote/handlers/constants.js.map +0 -1
  125. package/dist/strapi/remote/handlers/index.d.ts +0 -3
  126. package/dist/strapi/remote/handlers/index.js +0 -10
  127. package/dist/strapi/remote/handlers/index.js.map +0 -1
  128. package/dist/strapi/remote/handlers/pull.d.ts +0 -22
  129. package/dist/strapi/remote/handlers/pull.js +0 -243
  130. package/dist/strapi/remote/handlers/pull.js.map +0 -1
  131. package/dist/strapi/remote/handlers/push.d.ts +0 -75
  132. package/dist/strapi/remote/handlers/push.js +0 -311
  133. package/dist/strapi/remote/handlers/push.js.map +0 -1
  134. package/dist/strapi/remote/handlers/utils.d.ts +0 -25
  135. package/dist/strapi/remote/handlers/utils.js +0 -217
  136. package/dist/strapi/remote/handlers/utils.js.map +0 -1
  137. package/dist/strapi/remote/index.d.ts +0 -2
  138. package/dist/strapi/remote/index.js +0 -29
  139. package/dist/strapi/remote/index.js.map +0 -1
  140. package/dist/utils/encryption/decrypt.d.ts +0 -11
  141. package/dist/utils/encryption/decrypt.js +0 -47
  142. package/dist/utils/encryption/decrypt.js.map +0 -1
  143. package/dist/utils/encryption/encrypt.d.ts +0 -11
  144. package/dist/utils/encryption/encrypt.js +0 -47
  145. package/dist/utils/encryption/encrypt.js.map +0 -1
  146. package/dist/utils/encryption/index.d.ts +0 -2
  147. package/dist/utils/encryption/index.js +0 -19
  148. package/dist/utils/encryption/index.js.map +0 -1
  149. package/dist/utils/index.d.ts +0 -6
  150. package/dist/utils/index.js +0 -33
  151. package/dist/utils/index.js.map +0 -1
  152. package/dist/utils/json.d.ts +0 -30
  153. package/dist/utils/json.js +0 -68
  154. package/dist/utils/json.js.map +0 -1
  155. package/dist/utils/middleware.d.ts +0 -2
  156. package/dist/utils/middleware.js +0 -14
  157. package/dist/utils/middleware.js.map +0 -1
  158. package/dist/utils/providers.d.ts +0 -2
  159. package/dist/utils/providers.js +0 -11
  160. package/dist/utils/providers.js.map +0 -1
  161. package/dist/utils/schema.d.ts +0 -6
  162. package/dist/utils/schema.js +0 -29
  163. package/dist/utils/schema.js.map +0 -1
  164. package/dist/utils/stream.d.ts +0 -27
  165. package/dist/utils/stream.js +0 -59
  166. package/dist/utils/stream.js.map +0 -1
  167. package/dist/utils/transaction.d.ts +0 -3
  168. package/dist/utils/transaction.js +0 -88
  169. package/dist/utils/transaction.js.map +0 -1
@@ -1,47 +0,0 @@
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
@@ -1 +0,0 @@
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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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;
@@ -1,47 +0,0 @@
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=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U,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"}
@@ -1,2 +0,0 @@
1
- export * from './encrypt';
2
- export * from './decrypt';
@@ -1,19 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/encryption/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B"}
@@ -1,6 +0,0 @@
1
- export * as encryption from './encryption';
2
- export * as stream from './stream';
3
- export * as json from './json';
4
- export * as schema from './schema';
5
- export * as transaction from './transaction';
6
- export * as middleware from './middleware';
@@ -1,33 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,30 +0,0 @@
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
- }
@@ -1,68 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAE,CAAU,EAAE,MAAe,aAAa,EAAE,EAAU,EAAE;IACrF,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;IAErB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC;IACvB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC;IAEvB,iBAAiB;IAEjB,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;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CAAC;QAEzD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,MAAM,MAAM,GAAI,CAA6B,CAAC,GAAG,CAAC,CAAC;YACnD,MAAM,MAAM,GAAI,CAA6B,CAAC,GAAG,CAAC,CAAC;YAEnD,MAAM,WAAW,GAAG,IAAA,YAAI,EAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAEnE,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;SAC5B;QAED,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,IAAA,YAAO,EAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QAClB,IAAI,KAAK,KAAK,WAAW,EAAE;YACzB,OAAO,KAAK,EAAE,CAAC;SAChB;QAED,IAAI,KAAK,KAAK,WAAW,EAAE;YACzB,OAAO,OAAO,EAAE,CAAC;SAClB;QAED,OAAO,QAAQ,EAAE,CAAC;KACnB;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAxEW,QAAA,IAAI,QAwEf"}
@@ -1,2 +0,0 @@
1
- import { Middleware } from '../../types';
2
- export declare const runMiddleware: <T>(context: T, middlewares: Middleware<T>[]) => Promise<void>;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- export type ValidStrapiAssertion = (strapi: unknown, msg?: string) => asserts strapi is Strapi.Strapi;
2
- export declare const assertValidStrapi: ValidStrapiAssertion;
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
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>;
@@ -1,29 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,27 +0,0 @@
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 {};
@@ -1,59 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,3 +0,0 @@
1
- import { Strapi } from '@strapi/strapi';
2
- import { Transaction } from '../../types/utils';
3
- export declare const createTransaction: (strapi: Strapi) => Transaction;
@@ -1,88 +0,0 @@
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
@@ -1 +0,0 @@
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;I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