@strapi/data-transfer 5.37.0 → 5.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine/errors.js.map +1 -1
- package/dist/engine/errors.mjs.map +1 -1
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/index.mjs.map +1 -1
- package/dist/engine/validation/provider.js.map +1 -1
- package/dist/engine/validation/provider.mjs.map +1 -1
- package/dist/engine/validation/schemas/index.js.map +1 -1
- package/dist/engine/validation/schemas/index.mjs.map +1 -1
- package/dist/errors/base.js.map +1 -1
- package/dist/errors/base.mjs.map +1 -1
- package/dist/errors/constants.js +0 -1
- package/dist/errors/constants.js.map +1 -1
- package/dist/errors/constants.mjs +0 -1
- package/dist/errors/constants.mjs.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.js.map +1 -1
- package/dist/file/providers/destination/index.mjs.map +1 -1
- package/dist/file/providers/destination/utils.js.map +1 -1
- package/dist/file/providers/destination/utils.mjs.map +1 -1
- package/dist/file/providers/index.js +4 -4
- package/dist/file/providers/source/index.js.map +1 -1
- package/dist/file/providers/source/index.mjs +1 -1
- package/dist/file/providers/source/index.mjs.map +1 -1
- package/dist/file/providers/source/utils.js.map +1 -1
- package/dist/file/providers/source/utils.mjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- 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.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.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.mjs.map +1 -1
- package/dist/strapi/providers/local-source/assets.js.map +1 -1
- package/dist/strapi/providers/local-source/assets.mjs +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.js.map +1 -1
- package/dist/strapi/providers/local-source/entities.mjs.map +1 -1
- package/dist/strapi/providers/local-source/index.js.map +1 -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.js +1 -1
- package/dist/strapi/providers/remote-destination/index.js.map +1 -1
- package/dist/strapi/providers/remote-destination/index.mjs +1 -1
- package/dist/strapi/providers/remote-destination/index.mjs.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.js.map +1 -1
- package/dist/strapi/providers/utils.mjs.map +1 -1
- package/dist/strapi/queries/entity.js.map +1 -1
- package/dist/strapi/queries/entity.mjs +2 -2
- package/dist/strapi/queries/entity.mjs.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/constants.js.map +1 -1
- package/dist/strapi/remote/constants.mjs.map +1 -1
- package/dist/strapi/remote/flows/default.js.map +1 -1
- package/dist/strapi/remote/flows/default.mjs.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/constants.js.map +1 -1
- package/dist/strapi/remote/handlers/constants.mjs.map +1 -1
- package/dist/strapi/remote/handlers/pull.js.map +1 -1
- package/dist/strapi/remote/handlers/pull.mjs.map +1 -1
- package/dist/strapi/remote/handlers/push.js.map +1 -1
- package/dist/strapi/remote/handlers/push.mjs +1 -1
- package/dist/strapi/remote/handlers/push.mjs.map +1 -1
- package/dist/strapi/remote/handlers/utils.js.map +1 -1
- package/dist/strapi/remote/handlers/utils.mjs +1 -1
- package/dist/strapi/remote/handlers/utils.mjs.map +1 -1
- package/dist/utils/components.js.map +1 -1
- package/dist/utils/components.mjs +1 -1
- package/dist/utils/components.mjs.map +1 -1
- package/dist/utils/diagnostic.js.map +1 -1
- package/dist/utils/diagnostic.mjs.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.js.map +1 -1
- package/dist/utils/encryption/encrypt.mjs.map +1 -1
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/json.mjs.map +1 -1
- package/dist/utils/middleware.js.map +1 -1
- package/dist/utils/middleware.mjs.map +1 -1
- package/dist/utils/providers.js.map +1 -1
- package/dist/utils/providers.mjs.map +1 -1
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/schema.mjs.map +1 -1
- package/dist/utils/stream.js.map +1 -1
- package/dist/utils/stream.mjs.map +1 -1
- package/dist/utils/transaction.js.map +1 -1
- package/dist/utils/transaction.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decrypt.mjs","sources":["../../../src/utils/encryption/decrypt.ts"],"sourcesContent":["import { Decipheriv, scryptSync, CipherKey, BinaryLike, createDecipheriv } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getDecryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Decipheriv {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Decipheriv {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.subarray(16);\n const securityKey: CipherKey = hashedKey.subarray(0, 16);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Decipheriv {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.subarray(24);\n const securityKey: CipherKey = hashedKey.subarray(0, 24);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Decipheriv {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.subarray(32);\n const securityKey: CipherKey = hashedKey.subarray(0, 32);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for decryption\n *\n * @param key - The decryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Decipheriv} instance created with the given key & algorithm\n */\nexport const createDecryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Decipheriv => {\n return getDecryptionStrategy(algorithm)(key);\n};\n"],"names":["getDecryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createDecipheriv","aes128","subarray","aes192","aes256","createDecryptionCipher"],"mappings":";;AAGA;AACA,MAAMA,wBAAwB,CAACC,SAAAA,GAAAA;AAC7B,IAAA,MAAMC,
|
|
1
|
+
{"version":3,"file":"decrypt.mjs","sources":["../../../src/utils/encryption/decrypt.ts"],"sourcesContent":["import { Decipheriv, scryptSync, CipherKey, BinaryLike, createDecipheriv } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getDecryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Decipheriv {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Decipheriv {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.subarray(16);\n const securityKey: CipherKey = hashedKey.subarray(0, 16);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Decipheriv {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.subarray(24);\n const securityKey: CipherKey = hashedKey.subarray(0, 24);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Decipheriv {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.subarray(32);\n const securityKey: CipherKey = hashedKey.subarray(0, 32);\n return createDecipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for decryption\n *\n * @param key - The decryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Decipheriv} instance created with the given key & algorithm\n */\nexport const createDecryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Decipheriv => {\n return getDecryptionStrategy(algorithm)(key);\n};\n"],"names":["getDecryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createDecipheriv","aes128","subarray","aes192","aes256","createDecryptionCipher"],"mappings":";;AAGA;AACA,MAAMA,wBAAwB,CAACC,SAAAA,GAAAA;AAC7B,IAAA,MAAMC,UAAAA,GAAyB;AAC7B,QAAA,aAAA,CAAA,CAAcC,GAAW,EAAA;YACvB,MAAMC,SAAAA,GAAYC,UAAAA,CAAWF,GAAAA,EAAK,EAAA,EAAI,EAAA,CAAA;AACtC,YAAA,MAAMG,UAAAA,GAAgC,IAAA;AACtC,YAAA,MAAMC,WAAAA,GAAyBH,SAAAA;YAC/B,OAAOI,gBAAAA,CAAiBP,WAAWM,WAAAA,EAAaD,UAAAA,CAAAA;AAClD,QAAA,CAAA;AACAG,QAAAA,MAAAA,C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OAAOD,sBAAsBC,SAAAA,CAAAA,CAAWE,GAAAA,CAAAA;AAC1C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt.js","sources":["../../../src/utils/encryption/encrypt.ts"],"sourcesContent":["import { createCipheriv, Cipheriv, scryptSync, CipherKey, BinaryLike } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getEncryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.subarray(16);\n const securityKey: CipherKey = hashedKey.subarray(0, 16);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.subarray(24);\n const securityKey: CipherKey = hashedKey.subarray(0, 24);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.subarray(32);\n const securityKey: CipherKey = hashedKey.subarray(0, 32);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for encryption\n *\n * @param key - The encryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Cipheriv} instance created with the given key & algorithm\n */\nexport const createEncryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Cipheriv => {\n return getEncryptionStrategy(algorithm)(key);\n};\n"],"names":["getEncryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createCipheriv","aes128","subarray","aes192","aes256","createEncryptionCipher"],"mappings":";;;;AAGA;AACA,MAAMA,wBAAwB,CAACC,SAAAA,GAAAA;AAC7B,IAAA,MAAMC,
|
|
1
|
+
{"version":3,"file":"encrypt.js","sources":["../../../src/utils/encryption/encrypt.ts"],"sourcesContent":["import { createCipheriv, Cipheriv, scryptSync, CipherKey, BinaryLike } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getEncryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.subarray(16);\n const securityKey: CipherKey = hashedKey.subarray(0, 16);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.subarray(24);\n const securityKey: CipherKey = hashedKey.subarray(0, 24);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.subarray(32);\n const securityKey: CipherKey = hashedKey.subarray(0, 32);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for encryption\n *\n * @param key - The encryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Cipheriv} instance created with the given key & algorithm\n */\nexport const createEncryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Cipheriv => {\n return getEncryptionStrategy(algorithm)(key);\n};\n"],"names":["getEncryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createC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AA,CAAWF,GAAAA,EAAK,EAAA,EAAI,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAAA,CAAUM,QAAQ,CAAC,EAAA,CAAA;AACzD,YAAA,MAAMH,WAAAA,GAAyBH,SAAAA,CAAUM,QAAQ,CAAC,CAAA,EAAG,EAAA,CAAA;YACrD,OAAOF,qBAAAA,CAAeP,WAAWM,WAAAA,EAAaD,UAAAA,CAAAA;AAChD,QAAA;AACF,KAAA;IAEA,OAAOJ,UAAU,CAACD,SAAAA,CAAU;AAC9B,CAAA;AAEA;;;;;;;AAOC,IACM,MAAMY,sBAAAA,GAAyB,CACpCV,GAAAA,EACAF,YAAuB,aAAa,GAAA;AAEpC,IAAA,OAAOD,sBAAsBC,SAAAA,CAAAA,CAAWE,GAAAA,CAAAA;AAC1C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt.mjs","sources":["../../../src/utils/encryption/encrypt.ts"],"sourcesContent":["import { createCipheriv, Cipheriv, scryptSync, CipherKey, BinaryLike } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getEncryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.subarray(16);\n const securityKey: CipherKey = hashedKey.subarray(0, 16);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.subarray(24);\n const securityKey: CipherKey = hashedKey.subarray(0, 24);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.subarray(32);\n const securityKey: CipherKey = hashedKey.subarray(0, 32);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for encryption\n *\n * @param key - The encryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Cipheriv} instance created with the given key & algorithm\n */\nexport const createEncryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Cipheriv => {\n return getEncryptionStrategy(algorithm)(key);\n};\n"],"names":["getEncryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createCipheriv","aes128","subarray","aes192","aes256","createEncryptionCipher"],"mappings":";;AAGA;AACA,MAAMA,wBAAwB,CAACC,SAAAA,GAAAA;AAC7B,IAAA,MAAMC,
|
|
1
|
+
{"version":3,"file":"encrypt.mjs","sources":["../../../src/utils/encryption/encrypt.ts"],"sourcesContent":["import { createCipheriv, Cipheriv, scryptSync, CipherKey, BinaryLike } from 'crypto';\nimport { EncryptionStrategy, Strategies, Algorithm } from '../../../types';\n\n// different key values depending on algorithm chosen\nconst getEncryptionStrategy = (algorithm: Algorithm): EncryptionStrategy => {\n const strategies: Strategies = {\n 'aes-128-ecb'(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 16);\n const initVector: BinaryLike | null = null;\n const securityKey: CipherKey = hashedKey;\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes128(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 32);\n const initVector: BinaryLike | null = hashedKey.subarray(16);\n const securityKey: CipherKey = hashedKey.subarray(0, 16);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes192(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 40);\n const initVector: BinaryLike | null = hashedKey.subarray(24);\n const securityKey: CipherKey = hashedKey.subarray(0, 24);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n aes256(key: string): Cipheriv {\n const hashedKey = scryptSync(key, '', 48);\n const initVector: BinaryLike | null = hashedKey.subarray(32);\n const securityKey: CipherKey = hashedKey.subarray(0, 32);\n return createCipheriv(algorithm, securityKey, initVector);\n },\n };\n\n return strategies[algorithm];\n};\n\n/**\n * It creates a cipher instance used for encryption\n *\n * @param key - The encryption key\n * @param algorithm - The algorithm to use to create the Cipher\n *\n * @returns A {@link Cipheriv} instance created with the given key & algorithm\n */\nexport const createEncryptionCipher = (\n key: string,\n algorithm: Algorithm = 'aes-128-ecb'\n): Cipheriv => {\n return getEncryptionStrategy(algorithm)(key);\n};\n"],"names":["getEncryptionStrategy","algorithm","strategies","key","hashedKey","scryptSync","initVector","securityKey","createCipheriv","aes128","subarray","aes192","aes256","createEncryptionCipher"],"mappings":";;AAGA;AACA,MAAMA,wBAAwB,CAACC,SAAAA,GAAAA;AAC7B,IAAA,MAAMC,UAAAA,GAAyB;AAC7B,QAAA,aAAA,CAAA,CAAcC,GAAW,EAAA;YACvB,MAAMC,SAAAA,GAAYC,UAAAA,CAAWF,GAAAA,EAAK,EAAA,EAAI,EAAA,CAAA;AACtC,YAAA,MAAMG,UAAAA,GAAgC,IAAA;AACtC,YAAA,MAAMC,WAAAA,GAAyBH,SAAAA;YAC/B,OAAOI,cAAAA,CAAeP,WAAWM,WAAAA,EAAaD,UAAAA,CAAAA;AAChD,QAAA,CAAA;AACAG,QAAAA,MAAAA,CAAAA,CAAON,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAAA,CAAWF,GAAAA,EAAK,EAAA,EAAI,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAAA,CAAUM,QAAQ,CAAC,EAAA,CAAA;AACzD,YAAA,MAAMH,WAAAA,GAAyBH,SAAAA,CAAUM,QAAQ,CAAC,CAAA,EAAG,EAAA,CAAA;YACrD,OAAOF,cAAAA,CAAeP,WAAWM,WAAAA,EAAaD,UAAAA,CAAAA;AAChD,QAAA,CAAA;AACAK,QAAAA,MAAAA,CAAAA,CAAOR,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAAA,CAAWF,GAAAA,EAAK,EAAA,EAAI,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAAA,CAAUM,QAAQ,CAAC,EAAA,CAAA;AACzD,YAAA,MAAMH,WAAAA,GAAyBH,SAAAA,CAAUM,QAAQ,CAAC,CAAA,EAAG,EAAA,CAAA;YACrD,OAAOF,cAAAA,CAAeP,WAAWM,WAAAA,EAAaD,UAAAA,CAAAA;AAChD,QAAA,CAAA;AACAM,QAAAA,MAAAA,CAAAA,CAAOT,GAAW,EAAA;YAChB,MAAMC,SAAAA,GAAYC,UAAAA,CAAWF,GAAAA,EAAK,EAAA,EAAI,EAAA,CAAA;YACtC,MAAMG,UAAAA,GAAgCF,SAAAA,CAAUM,QAAQ,CAAC,EAAA,CAAA;AACzD,YAAA,MAAMH,WAAAA,GAAyBH,SAAAA,CAAUM,QAAQ,CAAC,CAAA,EAAG,EAAA,CAAA;YACrD,OAAOF,cAAAA,CAAeP,WAAWM,WAAAA,EAAaD,UAAAA,CAAAA;AAChD,QAAA;AACF,KAAA;IAEA,OAAOJ,UAAU,CAACD,SAAAA,CAAU;AAC9B,CAAA;AAEA;;;;;;;AAOC,IACM,MAAMY,sBAAAA,GAAyB,CACpCV,GAAAA,EACAF,YAAuB,aAAa,GAAA;AAEpC,IAAA,OAAOD,sBAAsBC,SAAAA,CAAAA,CAAWE,GAAAA,CAAAA;AAC1C;;;;"}
|
package/dist/utils/json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sources":["../../src/utils/json.ts"],"sourcesContent":["import { isArray, isObject, zip, isEqual, uniq } from 'lodash/fp';\n\nconst createContext = (): Context => ({ path: [] });\n\n/**\n * Compute differences between two JSON objects and returns them\n *\n * @param a - First object\n * @param b - Second object\n * @param ctx - Context used to keep track of the current path during recursion\n */\nexport const diff = (a: unknown, b: unknown, ctx: Context = createContext()): Diff[] => {\n const diffs: Diff[] = [];\n const { path } = ctx;\n\n const aType = typeof a;\n const bType = typeof b;\n\n // Define helpers\n\n const added = () => {\n diffs.push({ kind: 'added', path, type: bType, value: b });\n return diffs;\n };\n\n const deleted = () => {\n diffs.push({ kind: 'deleted', path, type: aType, value: a });\n return diffs;\n };\n\n const modified = () => {\n diffs.push({\n kind: 'modified',\n path,\n types: [aType, bType],\n values: [a, b],\n });\n return diffs;\n };\n\n if (isArray(a) && isArray(b)) {\n let k = 0;\n\n for (const [aItem, bItem] of zip(a, b)) {\n const kCtx: Context = { path: [...path, k.toString()] };\n const kDiffs = diff(aItem, bItem, kCtx);\n\n diffs.push(...kDiffs);\n\n k += 1;\n }\n\n return diffs;\n }\n\n if (isObject(a) && isObject(b)) {\n const keys = uniq(Object.keys(a).concat(Object.keys(b)));\n\n for (const key of keys) {\n const aValue = (a as Record<string, unknown>)[key];\n const bValue = (b as Record<string, unknown>)[key];\n\n const nestedDiffs = diff(aValue, bValue, { path: [...path, key] });\n\n diffs.push(...nestedDiffs);\n }\n\n return diffs;\n }\n\n if (!isEqual(a, b)) {\n if (aType === 'undefined') {\n return added();\n }\n\n if (bType === 'undefined') {\n return deleted();\n }\n\n return modified();\n }\n\n return diffs;\n};\n\nexport interface AddedDiff<T = unknown> {\n kind: 'added';\n path: string[];\n type: string;\n value: T;\n}\n\nexport interface ModifiedDiff<T = unknown, P = unknown> {\n kind: 'modified';\n path: string[];\n types: [string, string];\n values: [T, P];\n}\n\nexport interface DeletedDiff<T = unknown> {\n kind: 'deleted';\n path: string[];\n type: string;\n value: T;\n}\n\nexport type Diff<T = unknown> = AddedDiff<T> | ModifiedDiff<T> | DeletedDiff<T>;\n\nexport interface Context {\n path: string[];\n}\n"],"names":["createContext","path","diff","a","b","ctx","diffs","aType","bType","added","push","kind","type","value","deleted","modified","types","values","isArray","k","aItem","bItem","zip","kCtx","toString","kDiffs","isObject","keys","uniq","Object","concat","key","aValue","bValue","nestedDiffs","isEqual"],"mappings":";;;;AAEA,MAAMA,aAAAA,GAAgB,KAAgB;AAAEC,QAAAA,IAAAA,EAAM;KAAG,CAAA;AAEjD;;;;;;AAMC,
|
|
1
|
+
{"version":3,"file":"json.js","sources":["../../src/utils/json.ts"],"sourcesContent":["import { isArray, isObject, zip, isEqual, uniq } from 'lodash/fp';\n\nconst createContext = (): Context => ({ path: [] });\n\n/**\n * Compute differences between two JSON objects and returns them\n *\n * @param a - First object\n * @param b - Second object\n * @param ctx - Context used to keep track of the current path during recursion\n */\nexport const diff = (a: unknown, b: unknown, ctx: Context = createContext()): Diff[] => {\n const diffs: Diff[] = [];\n const { path } = ctx;\n\n const aType = typeof a;\n const bType = typeof b;\n\n // Define helpers\n\n const added = () => {\n diffs.push({ kind: 'added', path, type: bType, value: b });\n return diffs;\n };\n\n const deleted = () => {\n diffs.push({ kind: 'deleted', path, type: aType, value: a });\n return diffs;\n };\n\n const modified = () => {\n diffs.push({\n kind: 'modified',\n path,\n types: [aType, bType],\n values: [a, b],\n });\n return diffs;\n };\n\n if (isArray(a) && isArray(b)) {\n let k = 0;\n\n for (const [aItem, bItem] of zip(a, b)) {\n const kCtx: Context = { path: [...path, k.toString()] };\n const kDiffs = diff(aItem, bItem, kCtx);\n\n diffs.push(...kDiffs);\n\n k += 1;\n }\n\n return diffs;\n }\n\n if (isObject(a) && isObject(b)) {\n const keys = uniq(Object.keys(a).concat(Object.keys(b)));\n\n for (const key of keys) {\n const aValue = (a as Record<string, unknown>)[key];\n const bValue = (b as Record<string, unknown>)[key];\n\n const nestedDiffs = diff(aValue, bValue, { path: [...path, key] });\n\n diffs.push(...nestedDiffs);\n }\n\n return diffs;\n }\n\n if (!isEqual(a, b)) {\n if (aType === 'undefined') {\n return added();\n }\n\n if (bType === 'undefined') {\n return deleted();\n }\n\n return modified();\n }\n\n return diffs;\n};\n\nexport interface AddedDiff<T = unknown> {\n kind: 'added';\n path: string[];\n type: string;\n value: T;\n}\n\nexport interface ModifiedDiff<T = unknown, P = unknown> {\n kind: 'modified';\n path: string[];\n types: [string, string];\n values: [T, P];\n}\n\nexport interface DeletedDiff<T = unknown> {\n kind: 'deleted';\n path: string[];\n type: string;\n value: T;\n}\n\nexport type Diff<T = unknown> = AddedDiff<T> | ModifiedDiff<T> | DeletedDiff<T>;\n\nexport interface Context {\n path: string[];\n}\n"],"names":["createContext","path","diff","a","b","ctx","diffs","aType","bType","added","push","kind","type","value","deleted","modified","types","values","isArray","k","aItem","bItem","zip","kCtx","toString","kDiffs","isObject","keys","uniq","Object","concat","key","aValue","bValue","nestedDiffs","isEqual"],"mappings":";;;;AAEA,MAAMA,aAAAA,GAAgB,KAAgB;AAAEC,QAAAA,IAAAA,EAAM;KAAG,CAAA;AAEjD;;;;;;AAMC,IACM,MAAMC,IAAAA,GAAO,CAACC,CAAAA,EAAYC,CAAAA,EAAYC,MAAeL,aAAAA,EAAe,GAAA;AACzE,IAAA,MAAMM,QAAgB,EAAE;IACxB,MAAM,EAAEL,IAAI,EAAE,GAAGI,GAAAA;AAEjB,IAAA,MAAME,QAAQ,OAAOJ,CAAAA;AACrB,IAAA,MAAMK,QAAQ,OAAOJ,CAAAA;;AAIrB,IAAA,MAAMK,KAAAA,GAAQ,IAAA;AACZH,QAAAA,KAAAA,CAAMI,IAAI,CAAC;YAAEC,IAAAA,EAAM,OAAA;AAASV,YAAAA,IAAAA;YAAMW,IAAAA,EAAMJ,KAAAA;YAAOK,KAAAA,EAAOT;AAAE,SAAA,CAAA;QACxD,OAAOE,KAAAA;AACT,IAAA,CAAA;AAEA,IAAA,MAAMQ,OAAAA,GAAU,IAAA;AACdR,QAAAA,KAAAA,CAAMI,IAAI,CAAC;YAAEC,IAAAA,EAAM,SAAA;AAAWV,YAAAA,IAAAA;YAAMW,IAAAA,EAAML,KAAAA;YAAOM,KAAAA,EAAOV;AAAE,SAAA,CAAA;QAC1D,OAAOG,KAAAA;AACT,IAAA,CAAA;AAEA,IAAA,MAAMS,QAAAA,GAAW,IAAA;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7B,CAA6B,CAAC2B,GAAAA,CAAI;YAElD,MAAMG,WAAAA,GAAchC,IAAAA,CAAK8B,MAAAA,EAAQC,MAAAA,EAAQ;gBAAEhC,IAAAA,EAAM;AAAIA,oBAAAA,GAAAA,IAAAA;AAAM8B,oBAAAA;AAAI;AAAC,aAAA,CAAA;AAEhEzB,YAAAA,KAAAA,CAAMI,IAAI,CAAA,GAAIwB,WAAAA,CAAAA;AAChB,QAAA;QAEA,OAAO5B,KAAAA;AACT,IAAA;IAEA,IAAI,CAAC6B,UAAAA,CAAQhC,CAAAA,EAAGC,CAAAA,CAAAA,EAAI;AAClB,QAAA,IAAIG,UAAU,WAAA,EAAa;YACzB,OAAOE,KAAAA,EAAAA;AACT,QAAA;AAEA,QAAA,IAAID,UAAU,WAAA,EAAa;YACzB,OAAOM,OAAAA,EAAAA;AACT,QAAA;QAEA,OAAOC,QAAAA,EAAAA;AACT,IAAA;IAEA,OAAOT,KAAAA;AACT;;;;"}
|
package/dist/utils/json.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.mjs","sources":["../../src/utils/json.ts"],"sourcesContent":["import { isArray, isObject, zip, isEqual, uniq } from 'lodash/fp';\n\nconst createContext = (): Context => ({ path: [] });\n\n/**\n * Compute differences between two JSON objects and returns them\n *\n * @param a - First object\n * @param b - Second object\n * @param ctx - Context used to keep track of the current path during recursion\n */\nexport const diff = (a: unknown, b: unknown, ctx: Context = createContext()): Diff[] => {\n const diffs: Diff[] = [];\n const { path } = ctx;\n\n const aType = typeof a;\n const bType = typeof b;\n\n // Define helpers\n\n const added = () => {\n diffs.push({ kind: 'added', path, type: bType, value: b });\n return diffs;\n };\n\n const deleted = () => {\n diffs.push({ kind: 'deleted', path, type: aType, value: a });\n return diffs;\n };\n\n const modified = () => {\n diffs.push({\n kind: 'modified',\n path,\n types: [aType, bType],\n values: [a, b],\n });\n return diffs;\n };\n\n if (isArray(a) && isArray(b)) {\n let k = 0;\n\n for (const [aItem, bItem] of zip(a, b)) {\n const kCtx: Context = { path: [...path, k.toString()] };\n const kDiffs = diff(aItem, bItem, kCtx);\n\n diffs.push(...kDiffs);\n\n k += 1;\n }\n\n return diffs;\n }\n\n if (isObject(a) && isObject(b)) {\n const keys = uniq(Object.keys(a).concat(Object.keys(b)));\n\n for (const key of keys) {\n const aValue = (a as Record<string, unknown>)[key];\n const bValue = (b as Record<string, unknown>)[key];\n\n const nestedDiffs = diff(aValue, bValue, { path: [...path, key] });\n\n diffs.push(...nestedDiffs);\n }\n\n return diffs;\n }\n\n if (!isEqual(a, b)) {\n if (aType === 'undefined') {\n return added();\n }\n\n if (bType === 'undefined') {\n return deleted();\n }\n\n return modified();\n }\n\n return diffs;\n};\n\nexport interface AddedDiff<T = unknown> {\n kind: 'added';\n path: string[];\n type: string;\n value: T;\n}\n\nexport interface ModifiedDiff<T = unknown, P = unknown> {\n kind: 'modified';\n path: string[];\n types: [string, string];\n values: [T, P];\n}\n\nexport interface DeletedDiff<T = unknown> {\n kind: 'deleted';\n path: string[];\n type: string;\n value: T;\n}\n\nexport type Diff<T = unknown> = AddedDiff<T> | ModifiedDiff<T> | DeletedDiff<T>;\n\nexport interface Context {\n path: string[];\n}\n"],"names":["createContext","path","diff","a","b","ctx","diffs","aType","bType","added","push","kind","type","value","deleted","modified","types","values","isArray","k","aItem","bItem","zip","kCtx","toString","kDiffs","isObject","keys","uniq","Object","concat","key","aValue","bValue","nestedDiffs","isEqual"],"mappings":";;AAEA,MAAMA,aAAAA,GAAgB,KAAgB;AAAEC,QAAAA,IAAAA,EAAM;KAAG,CAAA;AAEjD;;;;;;AAMC,
|
|
1
|
+
{"version":3,"file":"json.mjs","sources":["../../src/utils/json.ts"],"sourcesContent":["import { isArray, isObject, zip, isEqual, uniq } from 'lodash/fp';\n\nconst createContext = (): Context => ({ path: [] });\n\n/**\n * Compute differences between two JSON objects and returns them\n *\n * @param a - First object\n * @param b - Second object\n * @param ctx - Context used to keep track of the current path during recursion\n */\nexport const diff = (a: unknown, b: unknown, ctx: Context = createContext()): Diff[] => {\n const diffs: Diff[] = [];\n const { path } = ctx;\n\n const aType = typeof a;\n const bType = typeof b;\n\n // Define helpers\n\n const added = () => {\n diffs.push({ kind: 'added', path, type: bType, value: b });\n return diffs;\n };\n\n const deleted = () => {\n diffs.push({ kind: 'deleted', path, type: aType, value: a });\n return diffs;\n };\n\n const modified = () => {\n diffs.push({\n kind: 'modified',\n path,\n types: [aType, bType],\n values: [a, b],\n });\n return diffs;\n };\n\n if (isArray(a) && isArray(b)) {\n let k = 0;\n\n for (const [aItem, bItem] of zip(a, b)) {\n const kCtx: Context = { path: [...path, k.toString()] };\n const kDiffs = diff(aItem, bItem, kCtx);\n\n diffs.push(...kDiffs);\n\n k += 1;\n }\n\n return diffs;\n }\n\n if (isObject(a) && isObject(b)) {\n const keys = uniq(Object.keys(a).concat(Object.keys(b)));\n\n for (const key of keys) {\n const aValue = (a as Record<string, unknown>)[key];\n const bValue = (b as Record<string, unknown>)[key];\n\n const nestedDiffs = diff(aValue, bValue, { path: [...path, key] });\n\n diffs.push(...nestedDiffs);\n }\n\n return diffs;\n }\n\n if (!isEqual(a, b)) {\n if (aType === 'undefined') {\n return added();\n }\n\n if (bType === 'undefined') {\n return deleted();\n }\n\n return modified();\n }\n\n return diffs;\n};\n\nexport interface AddedDiff<T = unknown> {\n kind: 'added';\n path: string[];\n type: string;\n value: T;\n}\n\nexport interface ModifiedDiff<T = unknown, P = unknown> {\n kind: 'modified';\n path: string[];\n types: [string, string];\n values: [T, P];\n}\n\nexport interface DeletedDiff<T = unknown> {\n kind: 'deleted';\n path: string[];\n type: string;\n value: T;\n}\n\nexport type Diff<T = unknown> = AddedDiff<T> | ModifiedDiff<T> | DeletedDiff<T>;\n\nexport interface Context {\n path: string[];\n}\n"],"names":["createContext","path","diff","a","b","ctx","diffs","aType","bType","added","push","kind","type","value","deleted","modified","types","values","isArray","k","aItem","bItem","zip","kCtx","toString","kDiffs","isObject","keys","uniq","Object","conc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hC,CAAAA,EAAGC,CAAAA,CAAAA,EAAI;AAClB,QAAA,IAAIG,UAAU,WAAA,EAAa;YACzB,OAAOE,KAAAA,EAAAA;AACT,QAAA;AAEA,QAAA,IAAID,UAAU,WAAA,EAAa;YACzB,OAAOM,OAAAA,EAAAA;AACT,QAAA;QAEA,OAAOC,QAAAA,EAAAA;AACT,IAAA;IAEA,OAAOT,KAAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sources":["../../src/utils/middleware.ts"],"sourcesContent":["import { Middleware } from '../../types';\n\nexport const runMiddleware = async <T>(context: T, middlewares: Middleware<T>[]): Promise<void> => {\n if (!middlewares.length) {\n return;\n }\n const cb = middlewares[0];\n await cb(context, async (newContext: T) => {\n await runMiddleware(newContext, middlewares.slice(1));\n });\n};\n"],"names":["runMiddleware","context","middlewares","length","cb","newContext","slice"],"mappings":";;AAEO,MAAMA,
|
|
1
|
+
{"version":3,"file":"middleware.js","sources":["../../src/utils/middleware.ts"],"sourcesContent":["import { Middleware } from '../../types';\n\nexport const runMiddleware = async <T>(context: T, middlewares: Middleware<T>[]): Promise<void> => {\n if (!middlewares.length) {\n return;\n }\n const cb = middlewares[0];\n await cb(context, async (newContext: T) => {\n await runMiddleware(newContext, middlewares.slice(1));\n });\n};\n"],"names":["runMiddleware","context","middlewares","length","cb","newContext","slice"],"mappings":";;AAEO,MAAMA,aAAAA,GAAgB,OAAUC,OAAAA,EAAYC,WAAAA,GAAAA;IACjD,IAAI,CAACA,WAAAA,CAAYC,MAAM,EAAE;AACvB,QAAA;AACF,IAAA;IACA,MAAMC,EAAAA,GAAKF,WAAW,CAAC,CAAA,CAAE;IACzB,MAAME,EAAAA,CAAGH,SAAS,OAAOI,UAAAA,GAAAA;AACvB,QAAA,MAAML,aAAAA,CAAcK,UAAAA,EAAYH,WAAAA,CAAYI,KAAK,CAAC,CAAA,CAAA,CAAA;AACpD,IAAA,CAAA,CAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.mjs","sources":["../../src/utils/middleware.ts"],"sourcesContent":["import { Middleware } from '../../types';\n\nexport const runMiddleware = async <T>(context: T, middlewares: Middleware<T>[]): Promise<void> => {\n if (!middlewares.length) {\n return;\n }\n const cb = middlewares[0];\n await cb(context, async (newContext: T) => {\n await runMiddleware(newContext, middlewares.slice(1));\n });\n};\n"],"names":["runMiddleware","context","middlewares","length","cb","newContext","slice"],"mappings":"AAEO,MAAMA,
|
|
1
|
+
{"version":3,"file":"middleware.mjs","sources":["../../src/utils/middleware.ts"],"sourcesContent":["import { Middleware } from '../../types';\n\nexport const runMiddleware = async <T>(context: T, middlewares: Middleware<T>[]): Promise<void> => {\n if (!middlewares.length) {\n return;\n }\n const cb = middlewares[0];\n await cb(context, async (newContext: T) => {\n await runMiddleware(newContext, middlewares.slice(1));\n });\n};\n"],"names":["runMiddleware","context","middlewares","length","cb","newContext","slice"],"mappings":"AAEO,MAAMA,aAAAA,GAAgB,OAAUC,OAAAA,EAAYC,WAAAA,GAAAA;IACjD,IAAI,CAACA,WAAAA,CAAYC,MAAM,EAAE;AACvB,QAAA;AACF,IAAA;IACA,MAAMC,EAAAA,GAAKF,WAAW,CAAC,CAAA,CAAE;IACzB,MAAME,EAAAA,CAAGH,SAAS,OAAOI,UAAAA,GAAAA;AACvB,QAAA,MAAML,aAAAA,CAAcK,UAAAA,EAAYH,WAAAA,CAAYI,KAAK,CAAC,CAAA,CAAA,CAAA;AACpD,IAAA,CAAA,CAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sources":["../../src/utils/providers.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { ProviderInitializationError } from '../errors/providers';\n\nexport type ValidStrapiAssertion = (strapi: unknown, msg?: string) => asserts strapi is Core.Strapi;\n\nexport const assertValidStrapi: ValidStrapiAssertion = (strapi?: unknown, msg = '') => {\n if (!strapi) {\n throw new ProviderInitializationError(`${msg}. Strapi instance not found.`);\n }\n};\n"],"names":["assertValidStrapi","strapi","msg","ProviderInitializationError"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"providers.js","sources":["../../src/utils/providers.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { ProviderInitializationError } from '../errors/providers';\n\nexport type ValidStrapiAssertion = (strapi: unknown, msg?: string) => asserts strapi is Core.Strapi;\n\nexport const assertValidStrapi: ValidStrapiAssertion = (strapi?: unknown, msg = '') => {\n if (!strapi) {\n throw new ProviderInitializationError(`${msg}. Strapi instance not found.`);\n }\n};\n"],"names":["assertValidStrapi","strapi","msg","ProviderInitializationError"],"mappings":";;;;AAMO,MAAMA,iBAAAA,GAA0C,CAACC,MAAAA,EAAkBC,MAAM,EAAE,GAAA;AAChF,IAAA,IAAI,CAACD,MAAAA,EAAQ;AACX,QAAA,MAAM,IAAIE,qCAAAA,CAA4B,CAAA,EAAGD,GAAAA,CAAI,4BAA4B,CAAC,CAAA;AAC5E,IAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.mjs","sources":["../../src/utils/providers.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { ProviderInitializationError } from '../errors/providers';\n\nexport type ValidStrapiAssertion = (strapi: unknown, msg?: string) => asserts strapi is Core.Strapi;\n\nexport const assertValidStrapi: ValidStrapiAssertion = (strapi?: unknown, msg = '') => {\n if (!strapi) {\n throw new ProviderInitializationError(`${msg}. Strapi instance not found.`);\n }\n};\n"],"names":["assertValidStrapi","strapi","msg","ProviderInitializationError"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"providers.mjs","sources":["../../src/utils/providers.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport { ProviderInitializationError } from '../errors/providers';\n\nexport type ValidStrapiAssertion = (strapi: unknown, msg?: string) => asserts strapi is Core.Strapi;\n\nexport const assertValidStrapi: ValidStrapiAssertion = (strapi?: unknown, msg = '') => {\n if (!strapi) {\n throw new ProviderInitializationError(`${msg}. Strapi instance not found.`);\n }\n};\n"],"names":["assertValidStrapi","strapi","msg","ProviderInitializationError"],"mappings":";;AAMO,MAAMA,iBAAAA,GAA0C,CAACC,MAAAA,EAAkBC,MAAM,EAAE,GAAA;AAChF,IAAA,IAAI,CAACD,MAAAA,EAAQ;AACX,QAAA,MAAM,IAAIE,2BAAAA,CAA4B,CAAA,EAAGD,GAAAA,CAAI,4BAA4B,CAAC,CAAA;AAC5E,IAAA;AACF;;;;"}
|
package/dist/utils/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sources":["../../src/utils/schema.ts"],"sourcesContent":["import type { Struct, Utils } from '@strapi/types';\nimport { mapValues, pick } from 'lodash/fp';\n\n/**\n * List of schema properties that should be kept when sanitizing schemas\n */\nconst VALID_SCHEMA_PROPERTIES = [\n 'collectionName',\n 'info',\n 'options',\n 'pluginOptions',\n 'attributes',\n 'kind',\n 'modelType',\n 'modelName',\n 'uid',\n 'plugin',\n 'globalId',\n];\n\n/**\n * Sanitize a schemas dictionary by omitting unwanted properties\n * The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES}\n */\nexport const mapSchemasValues = (schemas: Utils.String.Dict<Struct.Schema>) => {\n return mapValues(pick(VALID_SCHEMA_PROPERTIES), schemas) as Utils.String.Dict<Struct.Schema>;\n};\n\nexport const schemasToValidJSON = (schemas: Utils.String.Dict<Struct.Schema>) => {\n return JSON.parse(JSON.stringify(schemas));\n};\n"],"names":["VALID_SCHEMA_PROPERTIES","mapSchemasValues","schemas","mapValues","pick","schemasToValidJSON","JSON","parse","stringify"],"mappings":";;;;AAGA;;AAEC,IACD,MAAMA,
|
|
1
|
+
{"version":3,"file":"schema.js","sources":["../../src/utils/schema.ts"],"sourcesContent":["import type { Struct, Utils } from '@strapi/types';\nimport { mapValues, pick } from 'lodash/fp';\n\n/**\n * List of schema properties that should be kept when sanitizing schemas\n */\nconst VALID_SCHEMA_PROPERTIES = [\n 'collectionName',\n 'info',\n 'options',\n 'pluginOptions',\n 'attributes',\n 'kind',\n 'modelType',\n 'modelName',\n 'uid',\n 'plugin',\n 'globalId',\n];\n\n/**\n * Sanitize a schemas dictionary by omitting unwanted properties\n * The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES}\n */\nexport const mapSchemasValues = (schemas: Utils.String.Dict<Struct.Schema>) => {\n return mapValues(pick(VALID_SCHEMA_PROPERTIES), schemas) as Utils.String.Dict<Struct.Schema>;\n};\n\nexport const schemasToValidJSON = (schemas: Utils.String.Dict<Struct.Schema>) => {\n return JSON.parse(JSON.stringify(schemas));\n};\n"],"names":["VALID_SCHEMA_PROPERTIES","mapSchemasValues","schemas","mapValues","pick","schemasToValidJSON","JSON","parse","stringify"],"mappings":";;;;AAGA;;AAEC,IACD,MAAMA,uBAAAA,GAA0B;AAC9B,IAAA,gBAAA;AACA,IAAA,MAAA;AACA,IAAA,SAAA;AACA,IAAA,eAAA;AACA,IAAA,YAAA;AACA,IAAA,MAAA;AACA,IAAA,WAAA;AACA,IAAA,WAAA;AACA,IAAA,KAAA;AACA,IAAA,QAAA;AACA,IAAA;AACD,CAAA;AAED;;;IAIO,MAAMC,gBAAAA,GAAmB,CAACC,OAAAA,GAAAA;IAC/B,OAAOC,YAAAA,CAAUC,QAAKJ,uBAAAA,CAAAA,EAA0BE,OAAAA,CAAAA;AAClD;AAEO,MAAMG,qBAAqB,CAACH,OAAAA,GAAAA;AACjC,IAAA,OAAOI,IAAAA,CAAKC,KAAK,CAACD,IAAAA,CAAKE,SAAS,CAACN,OAAAA,CAAAA,CAAAA;AACnC;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.mjs","sources":["../../src/utils/schema.ts"],"sourcesContent":["import type { Struct, Utils } from '@strapi/types';\nimport { mapValues, pick } from 'lodash/fp';\n\n/**\n * List of schema properties that should be kept when sanitizing schemas\n */\nconst VALID_SCHEMA_PROPERTIES = [\n 'collectionName',\n 'info',\n 'options',\n 'pluginOptions',\n 'attributes',\n 'kind',\n 'modelType',\n 'modelName',\n 'uid',\n 'plugin',\n 'globalId',\n];\n\n/**\n * Sanitize a schemas dictionary by omitting unwanted properties\n * The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES}\n */\nexport const mapSchemasValues = (schemas: Utils.String.Dict<Struct.Schema>) => {\n return mapValues(pick(VALID_SCHEMA_PROPERTIES), schemas) as Utils.String.Dict<Struct.Schema>;\n};\n\nexport const schemasToValidJSON = (schemas: Utils.String.Dict<Struct.Schema>) => {\n return JSON.parse(JSON.stringify(schemas));\n};\n"],"names":["VALID_SCHEMA_PROPERTIES","mapSchemasValues","schemas","mapValues","pick","schemasToValidJSON","JSON","parse","stringify"],"mappings":";;AAGA;;AAEC,IACD,MAAMA,
|
|
1
|
+
{"version":3,"file":"schema.mjs","sources":["../../src/utils/schema.ts"],"sourcesContent":["import type { Struct, Utils } from '@strapi/types';\nimport { mapValues, pick } from 'lodash/fp';\n\n/**\n * List of schema properties that should be kept when sanitizing schemas\n */\nconst VALID_SCHEMA_PROPERTIES = [\n 'collectionName',\n 'info',\n 'options',\n 'pluginOptions',\n 'attributes',\n 'kind',\n 'modelType',\n 'modelName',\n 'uid',\n 'plugin',\n 'globalId',\n];\n\n/**\n * Sanitize a schemas dictionary by omitting unwanted properties\n * The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES}\n */\nexport const mapSchemasValues = (schemas: Utils.String.Dict<Struct.Schema>) => {\n return mapValues(pick(VALID_SCHEMA_PROPERTIES), schemas) as Utils.String.Dict<Struct.Schema>;\n};\n\nexport const schemasToValidJSON = (schemas: Utils.String.Dict<Struct.Schema>) => {\n return JSON.parse(JSON.stringify(schemas));\n};\n"],"names":["VALID_SCHEMA_PROPERTIES","mapSchemasValues","schemas","mapValues","pick","schemasToValidJSON","JSON","parse","stringify"],"mappings":";;AAGA;;AAEC,IACD,MAAMA,uBAAAA,GAA0B;AAC9B,IAAA,gBAAA;AACA,IAAA,MAAA;AACA,IAAA,SAAA;AACA,IAAA,eAAA;AACA,IAAA,YAAA;AACA,IAAA,MAAA;AACA,IAAA,WAAA;AACA,IAAA,WAAA;AACA,IAAA,KAAA;AACA,IAAA,QAAA;AACA,IAAA;AACD,CAAA;AAED;;;IAIO,MAAMC,gBAAAA,GAAmB,CAACC,OAAAA,GAAAA;IAC/B,OAAOC,SAAAA,CAAUC,KAAKJ,uBAAAA,CAAAA,EAA0BE,OAAAA,CAAAA;AAClD;AAEO,MAAMG,qBAAqB,CAACH,OAAAA,GAAAA;AACjC,IAAA,OAAOI,IAAAA,CAAKC,KAAK,CAACD,IAAAA,CAAKE,SAAS,CAACN,OAAAA,CAAAA,CAAAA;AACnC;;;;"}
|
package/dist/utils/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sources":["../../src/utils/stream.ts"],"sourcesContent":["import { Transform, Readable } from 'stream';\n\ntype TransformOptions = ConstructorParameters<typeof Transform>[0];\n\n/**\n * Create a filter stream that discard chunks which doesn't satisfies the given predicate\n *\n * @param predicate - A filter predicate, takes a stream data chunk as parameter and returns a boolean value\n * @param options - Transform stream options\n */\nexport const filter = <T>(\n predicate: (value: T) => boolean | Promise<boolean>,\n options: TransformOptions = { objectMode: true }\n): Transform => {\n return new Transform({\n ...options,\n\n async transform(chunk, _encoding, callback) {\n const keep = await predicate(chunk);\n\n callback(null, keep ? chunk : undefined);\n },\n });\n};\n\n/**\n * Create a map stream that transform chunks using the given predicate\n *\n * @param predicate - A map predicate, takes a stream data chunk as parameter and returns a mapped value\n * @param options - Transform stream options\n */\nexport const map = <T, U = T>(\n predicate: (value: T) => U | Promise<U>,\n options: TransformOptions = { objectMode: true }\n): Transform => {\n return new Transform({\n ...options,\n\n async transform(chunk, _encoding, callback) {\n const mappedValue = await predicate(chunk);\n\n callback(null, mappedValue);\n },\n });\n};\n\n/**\n * Collect every chunks from a Readable stream.\n *\n * @param stream - The redable stream to collect data from\n * @param options.destroy - If set to true, it automatically calls `destroy()` on the given stream upon receiving the 'end' event\n */\nexport const collect = <T = unknown>(\n stream: Readable,\n options: { destroy: boolean } = { destroy: true }\n): Promise<T[]> => {\n const chunks: T[] = [];\n\n return new Promise((resolve, reject) => {\n stream\n .on('close', () => resolve(chunks))\n .on('error', reject)\n .on('data', (chunk) => chunks.push(chunk))\n .on('end', () => {\n if (options.destroy) {\n stream.destroy();\n }\n\n resolve(chunks);\n });\n });\n};\n"],"names":["filter","predicate","options","objectMode","Transform","transform","chunk","_encoding","callback","keep","undefined","map","mappedValue","collect","stream","destroy","chunks","Promise","resolve","reject","on","push"],"mappings":";;;;AAIA;;;;;AAKC,IACM,MAAMA,
|
|
1
|
+
{"version":3,"file":"stream.js","sources":["../../src/utils/stream.ts"],"sourcesContent":["import { Transform, Readable } from 'stream';\n\ntype TransformOptions = ConstructorParameters<typeof Transform>[0];\n\n/**\n * Create a filter stream that discard chunks which doesn't satisfies the given predicate\n *\n * @param predicate - A filter predicate, takes a stream data chunk as parameter and returns a boolean value\n * @param options - Transform stream options\n */\nexport const filter = <T>(\n predicate: (value: T) => boolean | Promise<boolean>,\n options: TransformOptions = { objectMode: true }\n): Transform => {\n return new Transform({\n ...options,\n\n async transform(chunk, _encoding, callback) {\n const keep = await predicate(chunk);\n\n callback(null, keep ? chunk : undefined);\n },\n });\n};\n\n/**\n * Create a map stream that transform chunks using the given predicate\n *\n * @param predicate - A map predicate, takes a stream data chunk as parameter and returns a mapped value\n * @param options - Transform stream options\n */\nexport const map = <T, U = T>(\n predicate: (value: T) => U | Promise<U>,\n options: TransformOptions = { objectMode: true }\n): Transform => {\n return new Transform({\n ...options,\n\n async transform(chunk, _encoding, callback) {\n const mappedValue = await predicate(chunk);\n\n callback(null, mappedValue);\n },\n });\n};\n\n/**\n * Collect every chunks from a Readable stream.\n *\n * @param stream - The redable stream to collect data from\n * @param options.destroy - If set to true, it automatically calls `destroy()` on the given stream upon receiving the 'end' event\n */\nexport const collect = <T = unknown>(\n stream: Readable,\n options: { destroy: boolean } = { destroy: true }\n): Promise<T[]> => {\n const chunks: T[] = [];\n\n return new Promise((resolve, reject) => {\n stream\n .on('close', () => resolve(chunks))\n .on('error', reject)\n .on('data', (chunk) => chunks.push(chunk))\n .on('end', () => {\n if (options.destroy) {\n stream.destroy();\n }\n\n resolve(chunks);\n });\n });\n};\n"],"names":["filter","predicate","options","objectMode","Transform","transform","chunk","_encoding","callback","keep","undefined","map","mappedValue","collect","stream","destroy","chunks","Promise","resolve","reject","on","push"],"mappings":";;;;AAIA;;;;;AAKC,IACM,MAAMA,MAAAA,GAAS,CACpBC,WACAC,OAAAA,GAA4B;IAAEC,UAAAA,EAAY;AAAK,CAAC,GAAA;AAEhD,IAAA,OAAO,IAAIC,gBAAAA,CAAU;AACnB,QAAA,GAAGF,OAAO;AAEV,QAAA,MAAMG,SAAAA,CAAAA,CAAUC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAA;YACxC,MAAMC,IAAAA,GAAO,MAAMR,SAAAA,CAAUK,KAAAA,CAAAA;YAE7BE,QAAAA,CAAS,IAAA,EAAMC,OAAOH,KAAAA,GAAQI,SAAAA,CAAAA;AAChC,QAAA;AACF,KAAA,CAAA;AACF;AAEA;;;;;AAKC,IACM,MAAMC,GAAAA,GAAM,CACjBV,WACAC,OAAAA,GAA4B;IAAEC,UAAAA,EAAY;AAAK,CAAC,GAAA;AAEhD,IAAA,OAAO,IAAIC,gBAAAA,CAAU;AACnB,QAAA,GAAGF,OAAO;AAEV,QAAA,MAAMG,SAAAA,CAAAA,CAAUC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAA;YACxC,MAAMI,WAAAA,GAAc,MAAMX,SAAAA,CAAUK,KAAAA,CAAAA;AAEpCE,YAAAA,QAAAA,CAAS,IAAA,EAAMI,WAAAA,CAAAA;AACjB,QAAA;AACF,KAAA,CAAA;AACF;AAEA;;;;;AAKC,IACM,MAAMC,OAAAA,GAAU,CACrBC,QACAZ,OAAAA,GAAgC;IAAEa,OAAAA,EAAS;AAAK,CAAC,GAAA;AAEjD,IAAA,MAAMC,SAAc,EAAE;IAEtB,OAAO,IAAIC,OAAAA,CAAQ,CAACC,OAAAA,EAASC,MAAAA,GAAAA;QAC3BL,MAAAA,CACGM,EAAE,CAAC,OAAA,EAAS,IAAMF,QAAQF,MAAAA,CAAAA,CAAAA,CAC1BI,EAAE,CAAC,OAAA,EAASD,MAAAA,CAAAA,CACZC,EAAE,CAAC,MAAA,EAAQ,CAACd,KAAAA,GAAUU,MAAAA,CAAOK,IAAI,CAACf,KAAAA,CAAAA,CAAAA,CAClCc,EAAE,CAAC,KAAA,EAAO,IAAA;YACT,IAAIlB,OAAAA,CAAQa,OAAO,EAAE;AACnBD,gBAAAA,MAAAA,CAAOC,OAAO,EAAA;AAChB,YAAA;YAEAG,OAAAA,CAAQF,MAAAA,CAAAA;AACV,QAAA,CAAA,CAAA;AACJ,IAAA,CAAA,CAAA;AACF;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.mjs","sources":["../../src/utils/stream.ts"],"sourcesContent":["import { Transform, Readable } from 'stream';\n\ntype TransformOptions = ConstructorParameters<typeof Transform>[0];\n\n/**\n * Create a filter stream that discard chunks which doesn't satisfies the given predicate\n *\n * @param predicate - A filter predicate, takes a stream data chunk as parameter and returns a boolean value\n * @param options - Transform stream options\n */\nexport const filter = <T>(\n predicate: (value: T) => boolean | Promise<boolean>,\n options: TransformOptions = { objectMode: true }\n): Transform => {\n return new Transform({\n ...options,\n\n async transform(chunk, _encoding, callback) {\n const keep = await predicate(chunk);\n\n callback(null, keep ? chunk : undefined);\n },\n });\n};\n\n/**\n * Create a map stream that transform chunks using the given predicate\n *\n * @param predicate - A map predicate, takes a stream data chunk as parameter and returns a mapped value\n * @param options - Transform stream options\n */\nexport const map = <T, U = T>(\n predicate: (value: T) => U | Promise<U>,\n options: TransformOptions = { objectMode: true }\n): Transform => {\n return new Transform({\n ...options,\n\n async transform(chunk, _encoding, callback) {\n const mappedValue = await predicate(chunk);\n\n callback(null, mappedValue);\n },\n });\n};\n\n/**\n * Collect every chunks from a Readable stream.\n *\n * @param stream - The redable stream to collect data from\n * @param options.destroy - If set to true, it automatically calls `destroy()` on the given stream upon receiving the 'end' event\n */\nexport const collect = <T = unknown>(\n stream: Readable,\n options: { destroy: boolean } = { destroy: true }\n): Promise<T[]> => {\n const chunks: T[] = [];\n\n return new Promise((resolve, reject) => {\n stream\n .on('close', () => resolve(chunks))\n .on('error', reject)\n .on('data', (chunk) => chunks.push(chunk))\n .on('end', () => {\n if (options.destroy) {\n stream.destroy();\n }\n\n resolve(chunks);\n });\n });\n};\n"],"names":["filter","predicate","options","objectMode","Transform","transform","chunk","_encoding","callback","keep","undefined","map","mappedValue","collect","stream","destroy","chunks","Promise","resolve","reject","on","push"],"mappings":";;AAIA;;;;;AAKC,IACM,MAAMA,
|
|
1
|
+
{"version":3,"file":"stream.mjs","sources":["../../src/utils/stream.ts"],"sourcesContent":["import { Transform, Readable } from 'stream';\n\ntype TransformOptions = ConstructorParameters<typeof Transform>[0];\n\n/**\n * Create a filter stream that discard chunks which doesn't satisfies the given predicate\n *\n * @param predicate - A filter predicate, takes a stream data chunk as parameter and returns a boolean value\n * @param options - Transform stream options\n */\nexport const filter = <T>(\n predicate: (value: T) => boolean | Promise<boolean>,\n options: TransformOptions = { objectMode: true }\n): Transform => {\n return new Transform({\n ...options,\n\n async transform(chunk, _encoding, callback) {\n const keep = await predicate(chunk);\n\n callback(null, keep ? chunk : undefined);\n },\n });\n};\n\n/**\n * Create a map stream that transform chunks using the given predicate\n *\n * @param predicate - A map predicate, takes a stream data chunk as parameter and returns a mapped value\n * @param options - Transform stream options\n */\nexport const map = <T, U = T>(\n predicate: (value: T) => U | Promise<U>,\n options: TransformOptions = { objectMode: true }\n): Transform => {\n return new Transform({\n ...options,\n\n async transform(chunk, _encoding, callback) {\n const mappedValue = await predicate(chunk);\n\n callback(null, mappedValue);\n },\n });\n};\n\n/**\n * Collect every chunks from a Readable stream.\n *\n * @param stream - The redable stream to collect data from\n * @param options.destroy - If set to true, it automatically calls `destroy()` on the given stream upon receiving the 'end' event\n */\nexport const collect = <T = unknown>(\n stream: Readable,\n options: { destroy: boolean } = { destroy: true }\n): Promise<T[]> => {\n const chunks: T[] = [];\n\n return new Promise((resolve, reject) => {\n stream\n .on('close', () => resolve(chunks))\n .on('error', reject)\n .on('data', (chunk) => chunks.push(chunk))\n .on('end', () => {\n if (options.destroy) {\n stream.destroy();\n }\n\n resolve(chunks);\n });\n });\n};\n"],"names":["filter","predicate","options","objectMode","Transform","transform","chunk","_encoding","callback","keep","undefined","map","mappedValue","collect","stream","destroy","chunks","Promise","resolve","reject","on","push"],"mappings":";;AAIA;;;;;AAKC,IACM,MAAMA,MAAAA,GAAS,CACpBC,WACAC,OAAAA,GAA4B;IAAEC,UAAAA,EAAY;AAAK,CAAC,GAAA;AAEhD,IAAA,OAAO,IAAIC,SAAAA,CAAU;AACnB,QAAA,GAAGF,OAAO;AAEV,QAAA,MAAMG,SAAAA,CAAAA,CAAUC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAA;YACxC,MAAMC,IAAAA,GAAO,MAAMR,SAAAA,CAAUK,KAAAA,CAAAA;YAE7BE,QAAAA,CAAS,IAAA,EAAMC,OAAOH,KAAAA,GAAQI,SAAAA,CAAAA;AAChC,QAAA;AACF,KAAA,CAAA;AACF;AAEA;;;;;AAKC,IACM,MAAMC,GAAAA,GAAM,CACjBV,WACAC,OAAAA,GAA4B;IAAEC,UAAAA,EAAY;AAAK,CAAC,GAAA;AAEhD,IAAA,OAAO,IAAIC,SAAAA,CAAU;AACnB,QAAA,GAAGF,OAAO;AAEV,QAAA,MAAMG,SAAAA,CAAAA,CAAUC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAA;YACxC,MAAMI,WAAAA,GAAc,MAAMX,SAAAA,CAAUK,KAAAA,CAAAA;AAEpCE,YAAAA,QAAAA,CAAS,IAAA,EAAMI,WAAAA,CAAAA;AACjB,QAAA;AACF,KAAA,CAAA;AACF;AAEA;;;;;AAKC,IACM,MAAMC,OAAAA,GAAU,CACrBC,QACAZ,OAAAA,GAAgC;IAAEa,OAAAA,EAAS;AAAK,CAAC,GAAA;AAEjD,IAAA,MAAMC,SAAc,EAAE;IAEtB,OAAO,IAAIC,OAAAA,CAAQ,CAACC,OAAAA,EAASC,MAAAA,GAAAA;QAC3BL,MAAAA,CACGM,EAAE,CAAC,OAAA,EAAS,IAAMF,QAAQF,MAAAA,CAAAA,CAAAA,CAC1BI,EAAE,CAAC,OAAA,EAASD,MAAAA,CAAAA,CACZC,EAAE,CAAC,MAAA,EAAQ,CAACd,KAAAA,GAAUU,MAAAA,CAAOK,IAAI,CAACf,KAAAA,CAAAA,CAAAA,CAClCc,EAAE,CAAC,KAAA,EAAO,IAAA;YACT,IAAIlB,OAAAA,CAAQa,OAAO,EAAE;AACnBD,gBAAAA,MAAAA,CAAOC,OAAO,EAAA;AAChB,YAAA;YAEAG,OAAAA,CAAQF,MAAAA,CAAAA;AACV,QAAA,CAAA,CAAA;AACJ,IAAA,CAAA,CAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sources":["../../src/utils/transaction.ts"],"sourcesContent":["import { EventEmitter } from 'events';\nimport { randomUUID } from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { Transaction, TransactionCallback } from '../../types/utils';\n\nexport const createTransaction = (strapi: Core.Strapi): Transaction => {\n const fns: { fn: TransactionCallback; uuid: string }[] = [];\n\n let done = false;\n let resume: null | (() => void) = null;\n\n const e = new EventEmitter();\n e.on('spawn', (uuid, cb) => {\n fns.push({ fn: cb, uuid });\n resume?.();\n });\n\n e.on('close', () => {\n e.removeAllListeners('rollback');\n e.removeAllListeners('spawn');\n\n done = true;\n resume?.();\n });\n\n strapi.db.transaction(async ({ trx, rollback }) => {\n e.once('rollback', async () => {\n e.removeAllListeners('close');\n e.removeAllListeners('spawn');\n\n try {\n await rollback();\n e.emit('rollback_completed');\n } catch {\n e.emit('rollback_failed');\n } finally {\n done = true;\n resume?.();\n }\n });\n\n while (!done) {\n while (fns.length) {\n const item = fns.shift();\n\n if (item) {\n const { fn, uuid } = item;\n\n try {\n const res = await fn(trx);\n e.emit(uuid, { data: res });\n } catch (error) {\n e.emit(uuid, { error });\n }\n }\n }\n if (!done && !fns.length) {\n // eslint-disable-next-line @typescript-eslint/no-loop-func\n await new Promise<void>((resolve) => {\n resume = resolve;\n });\n }\n }\n });\n\n return {\n async attach<T = undefined>(callback: TransactionCallback): Promise<T | undefined> {\n const uuid = randomUUID();\n e.emit('spawn', uuid, callback);\n return new Promise<T | undefined>((resolve, reject) => {\n e.on(uuid, ({ data, error }) => {\n if (data) {\n resolve(data);\n }\n\n if (error) {\n reject(error);\n }\n resolve(undefined);\n });\n });\n },\n\n end() {\n return e.emit('close');\n },\n\n rollback() {\n return new Promise<boolean>((resolve) => {\n e.emit('rollback');\n\n e.once('rollback_failed', () => resolve(false));\n e.once('rollback_completed', () => resolve(true));\n });\n },\n };\n};\n"],"names":["createTransaction","strapi","fns","done","resume","e","EventEmitter","on","uuid","cb","push","fn","removeAllListeners","db","transaction","trx","rollback","once","emit","length","item","shift","res","data","error","Promise","resolve","attach","callback","randomUUID","reject","undefined","end"],"mappings":";;;;;AAMO,MAAMA,oBAAoB,CAACC,MAAAA,GAAAA;AAChC,IAAA,MAAMC,MAAmD,EAAE;AAE3D,IAAA,IAAIC,
|
|
1
|
+
{"version":3,"file":"transaction.js","sources":["../../src/utils/transaction.ts"],"sourcesContent":["import { EventEmitter } from 'events';\nimport { randomUUID } from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { Transaction, TransactionCallback } from '../../types/utils';\n\nexport const createTransaction = (strapi: Core.Strapi): Transaction => {\n const fns: { fn: TransactionCallback; uuid: string }[] = [];\n\n let done = false;\n let resume: null | (() => void) = null;\n\n const e = new EventEmitter();\n e.on('spawn', (uuid, cb) => {\n fns.push({ fn: cb, uuid });\n resume?.();\n });\n\n e.on('close', () => {\n e.removeAllListeners('rollback');\n e.removeAllListeners('spawn');\n\n done = true;\n resume?.();\n });\n\n strapi.db.transaction(async ({ trx, rollback }) => {\n e.once('rollback', async () => {\n e.removeAllListeners('close');\n e.removeAllListeners('spawn');\n\n try {\n await rollback();\n e.emit('rollback_completed');\n } catch {\n e.emit('rollback_failed');\n } finally {\n done = true;\n resume?.();\n }\n });\n\n while (!done) {\n while (fns.length) {\n const item = fns.shift();\n\n if (item) {\n const { fn, uuid } = item;\n\n try {\n const res = await fn(trx);\n e.emit(uuid, { data: res });\n } catch (error) {\n e.emit(uuid, { error });\n }\n }\n }\n if (!done && !fns.length) {\n // eslint-disable-next-line @typescript-eslint/no-loop-func\n await new Promise<void>((resolve) => {\n resume = resolve;\n });\n }\n }\n });\n\n return {\n async attach<T = undefined>(callback: TransactionCallback): Promise<T | undefined> {\n const uuid = randomUUID();\n e.emit('spawn', uuid, callback);\n return new Promise<T | undefined>((resolve, reject) => {\n e.on(uuid, ({ data, error }) => {\n if (data) {\n resolve(data);\n }\n\n if (error) {\n reject(error);\n }\n resolve(undefined);\n });\n });\n },\n\n end() {\n return e.emit('close');\n },\n\n rollback() {\n return new Promise<boolean>((resolve) => {\n e.emit('rollback');\n\n e.once('rollback_failed', () => resolve(false));\n e.once('rollback_completed', () => resolve(true));\n });\n },\n };\n};\n"],"names":["createTransaction","strapi","fns","done","resume","e","EventEmitter","on","uuid","cb","push","fn","removeAllListeners","db","transaction","trx","rollback","once","emit","length","item","shift","res","data","error","Promise","resolve","attach","callback","randomUUID","reject","undefined","end"],"mappings":";;;;;AAMO,MAAMA,oBAAoB,CAACC,MAAAA,GAAAA;AAChC,IAAA,MAAMC,MAAmD,EAAE;AAE3D,IAAA,IAAIC,IAAAA,GAAO,KAAA;AACX,IAAA,IAAIC,MAAAA,GAA8B,IAAA;AAElC,IAAA,MA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AAA;YACE,OAAO3B,CAAAA,CAAEa,IAAI,CAAC,OAAA,CAAA;AAChB,QAAA,CAAA;AAEAF,QAAAA,QAAAA,CAAAA,GAAAA;YACE,OAAO,IAAIS,QAAiB,CAACC,OAAAA,GAAAA;AAC3BrB,gBAAAA,CAAAA,CAAEa,IAAI,CAAC,UAAA,CAAA;AAEPb,gBAAAA,CAAAA,CAAEY,IAAI,CAAC,iBAAA,EAAmB,IAAMS,OAAAA,CAAQ,KAAA,CAAA,CAAA;AACxCrB,gBAAAA,CAAAA,CAAEY,IAAI,CAAC,oBAAA,EAAsB,IAAMS,OAAAA,CAAQ,IAAA,CAAA,CAAA;AAC7C,YAAA,CAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.mjs","sources":["../../src/utils/transaction.ts"],"sourcesContent":["import { EventEmitter } from 'events';\nimport { randomUUID } from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { Transaction, TransactionCallback } from '../../types/utils';\n\nexport const createTransaction = (strapi: Core.Strapi): Transaction => {\n const fns: { fn: TransactionCallback; uuid: string }[] = [];\n\n let done = false;\n let resume: null | (() => void) = null;\n\n const e = new EventEmitter();\n e.on('spawn', (uuid, cb) => {\n fns.push({ fn: cb, uuid });\n resume?.();\n });\n\n e.on('close', () => {\n e.removeAllListeners('rollback');\n e.removeAllListeners('spawn');\n\n done = true;\n resume?.();\n });\n\n strapi.db.transaction(async ({ trx, rollback }) => {\n e.once('rollback', async () => {\n e.removeAllListeners('close');\n e.removeAllListeners('spawn');\n\n try {\n await rollback();\n e.emit('rollback_completed');\n } catch {\n e.emit('rollback_failed');\n } finally {\n done = true;\n resume?.();\n }\n });\n\n while (!done) {\n while (fns.length) {\n const item = fns.shift();\n\n if (item) {\n const { fn, uuid } = item;\n\n try {\n const res = await fn(trx);\n e.emit(uuid, { data: res });\n } catch (error) {\n e.emit(uuid, { error });\n }\n }\n }\n if (!done && !fns.length) {\n // eslint-disable-next-line @typescript-eslint/no-loop-func\n await new Promise<void>((resolve) => {\n resume = resolve;\n });\n }\n }\n });\n\n return {\n async attach<T = undefined>(callback: TransactionCallback): Promise<T | undefined> {\n const uuid = randomUUID();\n e.emit('spawn', uuid, callback);\n return new Promise<T | undefined>((resolve, reject) => {\n e.on(uuid, ({ data, error }) => {\n if (data) {\n resolve(data);\n }\n\n if (error) {\n reject(error);\n }\n resolve(undefined);\n });\n });\n },\n\n end() {\n return e.emit('close');\n },\n\n rollback() {\n return new Promise<boolean>((resolve) => {\n e.emit('rollback');\n\n e.once('rollback_failed', () => resolve(false));\n e.once('rollback_completed', () => resolve(true));\n });\n },\n };\n};\n"],"names":["createTransaction","strapi","fns","done","resume","e","EventEmitter","on","uuid","cb","push","fn","removeAllListeners","db","transaction","trx","rollback","once","emit","length","item","shift","res","data","error","Promise","resolve","attach","callback","randomUUID","reject","undefined","end"],"mappings":";;;AAMO,MAAMA,oBAAoB,CAACC,MAAAA,GAAAA;AAChC,IAAA,MAAMC,MAAmD,EAAE;AAE3D,IAAA,IAAIC,
|
|
1
|
+
{"version":3,"file":"transaction.mjs","sources":["../../src/utils/transaction.ts"],"sourcesContent":["import { EventEmitter } from 'events';\nimport { randomUUID } from 'crypto';\nimport type { Core } from '@strapi/types';\n\nimport { Transaction, TransactionCallback } from '../../types/utils';\n\nexport const createTransaction = (strapi: Core.Strapi): Transaction => {\n const fns: { fn: TransactionCallback; uuid: string }[] = [];\n\n let done = false;\n let resume: null | (() => void) = null;\n\n const e = new EventEmitter();\n e.on('spawn', (uuid, cb) => {\n fns.push({ fn: cb, uuid });\n resume?.();\n });\n\n e.on('close', () => {\n e.removeAllListeners('rollback');\n e.removeAllListeners('spawn');\n\n done = true;\n resume?.();\n });\n\n strapi.db.transaction(async ({ trx, rollback }) => {\n e.once('rollback', async () => {\n e.removeAllListeners('close');\n e.removeAllListeners('spawn');\n\n try {\n await rollback();\n e.emit('rollback_completed');\n } catch {\n e.emit('rollback_failed');\n } finally {\n done = true;\n resume?.();\n }\n });\n\n while (!done) {\n while (fns.length) {\n const item = fns.shift();\n\n if (item) {\n const { fn, uuid } = item;\n\n try {\n const res = await fn(trx);\n e.emit(uuid, { data: res });\n } catch (error) {\n e.emit(uuid, { error });\n }\n }\n }\n if (!done && !fns.length) {\n // eslint-disable-next-line @typescript-eslint/no-loop-func\n await new Promise<void>((resolve) => {\n resume = resolve;\n });\n }\n }\n });\n\n return {\n async attach<T = undefined>(callback: TransactionCallback): Promise<T | undefined> {\n const uuid = randomUUID();\n e.emit('spawn', uuid, callback);\n return new Promise<T | undefined>((resolve, reject) => {\n e.on(uuid, ({ data, error }) => {\n if (data) {\n resolve(data);\n }\n\n if (error) {\n reject(error);\n }\n resolve(undefined);\n });\n });\n },\n\n end() {\n return e.emit('close');\n },\n\n rollback() {\n return new Promise<boolean>((resolve) => {\n e.emit('rollback');\n\n e.once('rollback_failed', () => resolve(false));\n e.once('rollback_completed', () => resolve(true));\n });\n },\n };\n};\n"],"names":["createTransaction","strapi","fns","done","resume","e","EventEmitter","on","uuid","cb","push","fn","removeAllListeners","db","transaction","trx","rollback","once","emit","length","item","shift","res","data","error","Promise","resolve","attach","callback","randomUUID","reject","undefined","end"],"mappings":";;;AAMO,MAAMA,oBAAoB,CAACC,MAAAA,GAAAA;AAChC,IAAA,MAAMC,MAAmD,EAAE;AAE3D,IAAA,IAAIC,IAAAA,GAAO,KAAA;AACX,IAAA,IAAIC,MAAAA,GAA8B,IAAA;AAElC,IAAA,MAAMC,IAAI,IAAIC,YAAAA,EAAAA;AACdD,IAAAA,CAAAA,CAAEE,EAAE,CAAC,OAAA,EAAS,CAACC,IAAAA,EAAMC,EAAAA,GAAAA;AACnBP,QAAAA,GAAAA,CAAIQ,IAAI,CAAC;YAAEC,EAAAA,EAAIF,EAAAA;AAAID,YAAAA;AAAK,SAAA,CAAA;AACxBJ,QAAAA,MAAAA,IAAAA;AACF,IAAA,CAAA,CAAA;IAEAC,CAAAA,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KAAA,CAAA,CAAA;AACxCrB,gBAAAA,CAAAA,CAAEY,IAAI,CAAC,oBAAA,EAAsB,IAAMS,OAAAA,CAAQ,IAAA,CAAA,CAAA;AAC7C,YAAA,CAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/data-transfer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.38.0",
|
|
4
4
|
"description": "Data transfer capabilities for Strapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"watch": "run -T rollup -c -w"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@strapi/logger": "5.
|
|
46
|
-
"@strapi/types": "5.
|
|
47
|
-
"@strapi/utils": "5.
|
|
45
|
+
"@strapi/logger": "5.38.0",
|
|
46
|
+
"@strapi/types": "5.38.0",
|
|
47
|
+
"@strapi/utils": "5.38.0",
|
|
48
48
|
"chalk": "4.1.2",
|
|
49
49
|
"cli-table3": "0.6.5",
|
|
50
50
|
"commander": "8.3.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"ws": "8.17.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@strapi/database": "5.
|
|
64
|
+
"@strapi/database": "5.38.0",
|
|
65
65
|
"@types/fs-extra": "11.0.4",
|
|
66
66
|
"@types/jest": "29.5.2",
|
|
67
67
|
"@types/koa": "2.13.4",
|