@strapi/data-transfer 4.6.0-beta.1 → 4.6.0-beta.2

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 (92) hide show
  1. package/{dist → lib}/engine/index.d.ts +7 -1
  2. package/{dist → lib}/engine/index.js +74 -18
  3. package/lib/engine/validation/index.d.ts +1 -0
  4. package/{dist/providers/shared → lib/engine/validation}/index.js +2 -2
  5. package/{dist/strategies → lib/engine/validation/schemas}/index.d.ts +2 -2
  6. package/{dist/strategies → lib/engine/validation/schemas}/index.js +3 -2
  7. package/lib/file/index.d.ts +1 -0
  8. package/lib/file/index.js +28 -0
  9. package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/index.d.ts +6 -6
  10. package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/index.js +7 -7
  11. package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/utils.d.ts +0 -0
  12. package/{dist/providers/local-file-destination-provider → lib/file/providers/destination}/utils.js +0 -0
  13. package/lib/file/providers/index.d.ts +2 -0
  14. package/{dist → lib/file}/providers/index.js +2 -6
  15. package/{dist/providers/local-file-source-provider → lib/file/providers/source}/index.d.ts +9 -8
  16. package/{dist/providers/local-file-source-provider → lib/file/providers/source}/index.js +33 -45
  17. package/lib/index.d.ts +4 -0
  18. package/lib/index.js +31 -0
  19. package/lib/strapi/index.d.ts +4 -0
  20. package/lib/strapi/index.js +35 -0
  21. package/lib/strapi/providers/index.d.ts +3 -0
  22. package/lib/strapi/providers/index.js +22 -0
  23. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/index.d.ts +8 -7
  24. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/index.js +14 -6
  25. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/index.d.ts +0 -0
  26. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/index.js +0 -0
  27. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/configuration.d.ts +1 -1
  28. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/configuration.js +0 -0
  29. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/entities.d.ts +0 -0
  30. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/entities.js +25 -13
  31. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/index.d.ts +0 -0
  32. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/index.js +2 -2
  33. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/links.d.ts +0 -0
  34. package/{dist/providers/local-strapi-destination-provider → lib/strapi/providers/local-destination}/strategies/restore/links.js +1 -1
  35. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/assets.d.ts +0 -0
  36. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/assets.js +0 -0
  37. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/configuration.d.ts +0 -0
  38. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/configuration.js +12 -13
  39. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/entities.d.ts +0 -0
  40. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/entities.js +11 -4
  41. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/index.d.ts +6 -6
  42. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/index.js +6 -6
  43. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/links.d.ts +0 -0
  44. package/{dist/providers/local-strapi-source-provider → lib/strapi/providers/local-source}/links.js +1 -1
  45. package/lib/strapi/providers/remote-destination/index.d.ts +40 -0
  46. package/lib/strapi/providers/remote-destination/index.js +171 -0
  47. package/lib/strapi/providers/remote-destination/utils.d.ts +31 -0
  48. package/lib/strapi/providers/remote-destination/utils.js +72 -0
  49. package/{dist/providers/shared/strapi → lib/strapi/queries}/entity.d.ts +0 -0
  50. package/{dist/providers/shared/strapi → lib/strapi/queries}/entity.js +0 -0
  51. package/{dist/providers/shared/strapi → lib/strapi/queries}/index.d.ts +0 -0
  52. package/{dist/providers/shared/strapi → lib/strapi/queries}/index.js +0 -0
  53. package/{dist/providers/shared/strapi → lib/strapi/queries}/link.d.ts +1 -1
  54. package/{dist/providers/shared/strapi → lib/strapi/queries}/link.js +0 -0
  55. package/lib/strapi/register.d.ts +7 -0
  56. package/lib/strapi/register.js +13 -0
  57. package/lib/strapi/remote/constants.d.ts +1 -0
  58. package/lib/strapi/remote/constants.js +5 -0
  59. package/lib/strapi/remote/controllers/index.d.ts +1 -0
  60. package/{dist → lib/strapi/remote/controllers}/index.js +1 -2
  61. package/lib/strapi/remote/controllers/push.d.ts +25 -0
  62. package/lib/strapi/remote/controllers/push.js +95 -0
  63. package/lib/strapi/remote/handlers.d.ts +3 -0
  64. package/lib/strapi/remote/handlers.js +177 -0
  65. package/lib/strapi/remote/index.d.ts +3 -0
  66. package/lib/strapi/remote/index.js +30 -0
  67. package/lib/strapi/remote/routes.d.ts +21 -0
  68. package/lib/strapi/remote/routes.js +22 -0
  69. package/lib/utils/encryption/decrypt.d.ts +11 -0
  70. package/{dist → lib/utils}/encryption/decrypt.js +8 -0
  71. package/lib/utils/encryption/encrypt.d.ts +11 -0
  72. package/{dist → lib/utils}/encryption/encrypt.js +8 -0
  73. package/{dist → lib/utils}/encryption/index.d.ts +0 -0
  74. package/{dist → lib/utils}/encryption/index.js +0 -0
  75. package/{dist → lib}/utils/index.d.ts +1 -0
  76. package/{dist → lib}/utils/index.js +2 -1
  77. package/{dist → lib}/utils/json.d.ts +7 -0
  78. package/{dist → lib}/utils/json.js +8 -1
  79. package/{dist → lib}/utils/schema.d.ts +4 -0
  80. package/{dist → lib}/utils/schema.js +9 -2
  81. package/lib/utils/stream.d.ts +27 -0
  82. package/lib/utils/stream.js +59 -0
  83. package/package.json +19 -12
  84. package/dist/encryption/decrypt.d.ts +0 -3
  85. package/dist/encryption/encrypt.d.ts +0 -3
  86. package/dist/index.d.ts +0 -2
  87. package/dist/providers/index.d.ts +0 -4
  88. package/dist/providers/shared/index.d.ts +0 -1
  89. package/dist/providers/test-utils/index.d.ts +0 -111
  90. package/dist/providers/test-utils/index.js +0 -64
  91. package/dist/utils/stream.d.ts +0 -10
  92. package/dist/utils/stream.js +0 -39
@@ -0,0 +1,30 @@
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.constants = exports.routes = exports.controllers = void 0;
27
+ exports.controllers = __importStar(require("./controllers"));
28
+ exports.routes = __importStar(require("./routes"));
29
+ exports.constants = __importStar(require("./constants"));
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,21 @@
1
+ import type { Context } from 'koa';
2
+ declare module '@strapi/strapi' {
3
+ interface Strapi {
4
+ admin: {
5
+ routes: {
6
+ method: string;
7
+ path: string;
8
+ handler: (ctx: Context) => Promise<void>;
9
+ config: unknown;
10
+ }[];
11
+ };
12
+ }
13
+ }
14
+ /**
15
+ * Register a transfer route in the Strapi admin router.
16
+ *
17
+ * It exposes a WS server that can be used to run and manage transfer processes.
18
+ *
19
+ * @param strapi - A Strapi instance
20
+ */
21
+ export declare const registerAdminTransferRoute: (strapi: Strapi.Strapi) => void;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerAdminTransferRoute = void 0;
4
+ const constants_1 = require("./constants");
5
+ const handlers_1 = require("./handlers");
6
+ /**
7
+ * Register a transfer route in the Strapi admin router.
8
+ *
9
+ * It exposes a WS server that can be used to run and manage transfer processes.
10
+ *
11
+ * @param strapi - A Strapi instance
12
+ */
13
+ const registerAdminTransferRoute = (strapi) => {
14
+ strapi.admin.routes.push({
15
+ method: 'GET',
16
+ path: constants_1.TRANSFER_PATH,
17
+ handler: (0, handlers_1.createTransferHandler)(),
18
+ config: { auth: false },
19
+ });
20
+ };
21
+ exports.registerAdminTransferRoute = registerAdminTransferRoute;
22
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1,11 @@
1
+ import { Cipher } from 'crypto';
2
+ import { Algorithm } from '../../../types';
3
+ /**
4
+ * It creates a cipher instance used for decryption
5
+ *
6
+ * @param key - The decryption 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 createDecryptionCipher: (key: string, algorithm?: Algorithm) => Cipher;
@@ -32,6 +32,14 @@ const getDecryptionStrategy = (algorithm) => {
32
32
  };
33
33
  return strategies[algorithm];
34
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
+ */
35
43
  const createDecryptionCipher = (key, algorithm = 'aes-128-ecb') => {
36
44
  return getDecryptionStrategy(algorithm)(key);
37
45
  };
@@ -0,0 +1,11 @@
1
+ import { Cipher } from 'crypto';
2
+ import { Algorithm } from '../../../types';
3
+ /**
4
+ * It creates a cipher instance used for encryption
5
+ *
6
+ * @param key - The encryption key
7
+ * @param algorithm - The algorithm to use to create the Cipher
8
+ *
9
+ * @returns A {@link Cipher} instance created with the given key & algorithm
10
+ */
11
+ export declare const createEncryptionCipher: (key: string, algorithm?: Algorithm) => Cipher;
@@ -32,6 +32,14 @@ const getEncryptionStrategy = (algorithm) => {
32
32
  };
33
33
  return strategies[algorithm];
34
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
+ */
35
43
  const createEncryptionCipher = (key, algorithm = 'aes-128-ecb') => {
36
44
  return getEncryptionStrategy(algorithm)(key);
37
45
  };
File without changes
File without changes
@@ -1,3 +1,4 @@
1
+ export * as encryption from './encryption';
1
2
  export * as stream from './stream';
2
3
  export * as json from './json';
3
4
  export * as schema from './schema';
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.schema = exports.json = exports.stream = void 0;
26
+ exports.schema = exports.json = exports.stream = exports.encryption = void 0;
27
+ exports.encryption = __importStar(require("./encryption"));
27
28
  exports.stream = __importStar(require("./stream"));
28
29
  exports.json = __importStar(require("./json"));
29
30
  exports.schema = __importStar(require("./schema"));
@@ -1,3 +1,10 @@
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
+ */
1
8
  export declare const diff: (a: unknown, b: unknown, ctx?: Context) => Diff[];
2
9
  export interface AddedDiff<T = unknown> {
3
10
  kind: 'added';
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.diff = void 0;
4
4
  const fp_1 = require("lodash/fp");
5
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
+ */
6
13
  const diff = (a, b, ctx = createContext()) => {
7
14
  const diffs = [];
8
15
  const { path } = ctx;
@@ -53,7 +60,7 @@ const diff = (a, b, ctx = createContext()) => {
53
60
  return diffs;
54
61
  }
55
62
  if (!(0, fp_1.isEqual)(a, b)) {
56
- modified();
63
+ return modified();
57
64
  }
58
65
  return diffs;
59
66
  };
@@ -1,3 +1,7 @@
1
1
  /// <reference types="lodash" />
2
2
  import type { Schema } from '@strapi/strapi';
3
+ /**
4
+ * Sanitize a schemas dictionnary by omiting unwanted properties
5
+ * The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES}
6
+ */
3
7
  export declare const mapSchemasValues: (schemas: Record<string, Schema>) => import("lodash").Dictionary<Partial<Schema>>;
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapSchemasValues = void 0;
4
4
  const fp_1 = require("lodash/fp");
5
- const schemaSelectedKeys = [
5
+ /**
6
+ * List of schema properties that should be kept when sanitizing schemas
7
+ */
8
+ const VALID_SCHEMA_PROPERTIES = [
6
9
  'collectionName',
7
10
  'info',
8
11
  'options',
@@ -15,8 +18,12 @@ const schemaSelectedKeys = [
15
18
  'plugin',
16
19
  'globalId',
17
20
  ];
21
+ /**
22
+ * Sanitize a schemas dictionnary by omiting unwanted properties
23
+ * The list of allowed properties can be found here: {@link VALID_SCHEMA_PROPERTIES}
24
+ */
18
25
  const mapSchemasValues = (schemas) => {
19
- return (0, fp_1.mapValues)((0, fp_1.pick)(schemaSelectedKeys), schemas);
26
+ return (0, fp_1.mapValues)((0, fp_1.pick)(VALID_SCHEMA_PROPERTIES), schemas);
20
27
  };
21
28
  exports.mapSchemasValues = mapSchemasValues;
22
29
  //# sourceMappingURL=schema.js.map
@@ -0,0 +1,27 @@
1
+ /// <reference types="node" />
2
+ import { Transform, Readable } from 'stream';
3
+ declare type TransformOptions = ConstructorParameters<typeof Transform>[0];
4
+ /**
5
+ * Create a filter stream that discard chunks which doesn't satisfies the given predicate
6
+ *
7
+ * @param predicate - A filter predicate, takes a stream data chunk as parameter and returns a boolean value
8
+ * @param options - Transform stream options
9
+ */
10
+ export declare const filter: <T>(predicate: (value: T) => boolean | Promise<boolean>, options?: TransformOptions) => Transform;
11
+ /**
12
+ * Create a map stream that transform chunks using the given predicate
13
+ *
14
+ * @param predicate - A map predicate, takes a stream data chunk as parameter and returns a mapped value
15
+ * @param options - Transform stream options
16
+ */
17
+ export declare const map: <T, U = T>(predicate: (value: T) => U | Promise<U>, options?: TransformOptions) => Transform;
18
+ /**
19
+ * Collect every chunks from a Readable stream.
20
+ *
21
+ * @param stream - The redable stream to collect data from
22
+ * @param options.destroy - If set to true, it automatically calls `destroy()` on the given stream upon receiving the 'end' event
23
+ */
24
+ export declare const collect: <T = unknown>(stream: Readable, options?: {
25
+ destroy: boolean;
26
+ }) => Promise<T[]>;
27
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collect = exports.map = exports.filter = void 0;
4
+ const stream_1 = require("stream");
5
+ /**
6
+ * Create a filter stream that discard chunks which doesn't satisfies the given predicate
7
+ *
8
+ * @param predicate - A filter predicate, takes a stream data chunk as parameter and returns a boolean value
9
+ * @param options - Transform stream options
10
+ */
11
+ const filter = (predicate, options = { objectMode: true }) => {
12
+ return new stream_1.Transform({
13
+ ...options,
14
+ async transform(chunk, _encoding, callback) {
15
+ const keep = await predicate(chunk);
16
+ callback(null, keep ? chunk : undefined);
17
+ },
18
+ });
19
+ };
20
+ exports.filter = filter;
21
+ /**
22
+ * Create a map stream that transform chunks using the given predicate
23
+ *
24
+ * @param predicate - A map predicate, takes a stream data chunk as parameter and returns a mapped value
25
+ * @param options - Transform stream options
26
+ */
27
+ const map = (predicate, options = { objectMode: true }) => {
28
+ return new stream_1.Transform({
29
+ ...options,
30
+ async transform(chunk, _encoding, callback) {
31
+ const mappedValue = await predicate(chunk);
32
+ callback(null, mappedValue);
33
+ },
34
+ });
35
+ };
36
+ exports.map = map;
37
+ /**
38
+ * Collect every chunks from a Readable stream.
39
+ *
40
+ * @param stream - The redable stream to collect data from
41
+ * @param options.destroy - If set to true, it automatically calls `destroy()` on the given stream upon receiving the 'end' event
42
+ */
43
+ const collect = (stream, options = { destroy: true }) => {
44
+ const chunks = [];
45
+ return new Promise((resolve, reject) => {
46
+ stream
47
+ .on('close', () => resolve(chunks))
48
+ .on('error', reject)
49
+ .on('data', (chunk) => chunks.push(chunk))
50
+ .on('end', () => {
51
+ if (options.destroy) {
52
+ stream.destroy();
53
+ }
54
+ resolve(chunks);
55
+ });
56
+ });
57
+ };
58
+ exports.collect = collect;
59
+ //# sourceMappingURL=stream.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/data-transfer",
3
- "version": "4.6.0-beta.1",
3
+ "version": "4.6.0-beta.2",
4
4
  "description": "Data transfer capabilities for Strapi",
5
5
  "keywords": [
6
6
  "strapi",
@@ -24,21 +24,23 @@
24
24
  "url": "https://strapi.io"
25
25
  }
26
26
  ],
27
- "main": "./dist/index.js",
28
- "types": "./dist/index.d.ts",
27
+ "main": "./lib/index.js",
28
+ "types": "./lib/index.d.ts",
29
29
  "scripts": {
30
- "build": "tsc -p tsconfig.json",
31
- "clean": "rimraf ./dist",
30
+ "build": "yarn build:ts",
31
+ "build:ts": "tsc -p tsconfig.json",
32
32
  "build:clean": "yarn clean && yarn build",
33
- "watch": "yarn build -w",
34
- "test:unit": "jest --verbose"
33
+ "clean": "rimraf ./dist",
34
+ "prepublishOnly": "yarn build:clean",
35
+ "test:unit": "jest --verbose",
36
+ "watch": "yarn build:ts -w --preserveWatchOutput"
35
37
  },
36
38
  "directories": {
37
- "lib": "./dist"
39
+ "lib": "./lib"
38
40
  },
39
41
  "dependencies": {
40
- "@strapi/logger": "4.6.0-beta.1",
41
- "@strapi/strapi": "4.6.0-beta.1",
42
+ "@strapi/logger": "4.6.0-beta.2",
43
+ "@strapi/strapi": "4.6.0-beta.2",
42
44
  "chalk": "4.1.2",
43
45
  "fs-extra": "10.0.0",
44
46
  "lodash": "4.17.21",
@@ -47,17 +49,22 @@
47
49
  "stream-chain": "2.2.5",
48
50
  "stream-json": "1.7.4",
49
51
  "tar": "6.1.12",
50
- "tar-stream": "2.2.0"
52
+ "tar-stream": "2.2.0",
53
+ "uuid": "9.0.0",
54
+ "ws": "8.11.0"
51
55
  },
52
56
  "devDependencies": {
53
57
  "@tsconfig/node16": "1.0.3",
54
58
  "@types/fs-extra": "9.0.13",
55
59
  "@types/jest": "29.2.0",
60
+ "@types/koa": "2.13.4",
56
61
  "@types/semver": "7.3.13",
57
62
  "@types/stream-chain": "2.0.1",
58
63
  "@types/stream-json": "1.7.2",
59
64
  "@types/tar": "6.1.3",
60
65
  "@types/tar-stream": "2.2.2",
66
+ "@types/uuid": "9.0.0",
67
+ "koa": "2.13.4",
61
68
  "rimraf": "3.0.2",
62
69
  "typescript": "4.6.2"
63
70
  },
@@ -65,5 +72,5 @@
65
72
  "node": ">=14.19.1 <=18.x.x",
66
73
  "npm": ">=6.0.0"
67
74
  },
68
- "gitHead": "2c0bcabdf0bf2a269fed50c6f23ba777845968a0"
75
+ "gitHead": "b852090f931cd21868c4016f24db2f9fdfc7a7ab"
69
76
  }
@@ -1,3 +0,0 @@
1
- import { Cipher } from 'crypto';
2
- import { Algorithm } from '../../types';
3
- export declare const createDecryptionCipher: (key: string, algorithm?: Algorithm) => Cipher;
@@ -1,3 +0,0 @@
1
- import { Cipher } from 'crypto';
2
- import { Algorithm } from '../../types';
3
- export declare const createEncryptionCipher: (key: string, algorithm?: Algorithm) => Cipher;
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './engine';
2
- export * from './providers';
@@ -1,4 +0,0 @@
1
- export * from './local-file-source-provider';
2
- export * from './local-strapi-source-provider';
3
- export * from './local-file-destination-provider';
4
- export * from './local-strapi-destination-provider';
@@ -1 +0,0 @@
1
- export * as strapi from './strapi';
@@ -1,111 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="jest" />
3
- import { Readable } from 'stream';
4
- /**
5
- * Collect every entity in a Readable stream
6
- */
7
- export declare const collect: <T = unknown>(stream: Readable) => Promise<T[]>;
8
- /**
9
- * Create a "Strapi" like object factory based on the
10
- * given params and cast it to the correct type
11
- */
12
- export declare const getStrapiFactory: <T extends {
13
- readonly EE?: unknown;
14
- readonly config?: unknown;
15
- readonly auth?: unknown;
16
- readonly contentAPI?: unknown;
17
- readonly sanitizers?: unknown;
18
- readonly services?: unknown;
19
- service?: unknown;
20
- readonly controllers?: unknown;
21
- controller?: unknown;
22
- readonly contentTypes?: unknown;
23
- contentType?: unknown;
24
- readonly components?: unknown;
25
- readonly customFields?: unknown;
26
- readonly policies?: unknown;
27
- policy?: unknown;
28
- readonly middlewares?: unknown;
29
- middleware?: unknown;
30
- readonly plugins?: unknown;
31
- plugin?: unknown;
32
- readonly hooks?: unknown;
33
- hook?: unknown;
34
- readonly api?: unknown;
35
- register?: unknown;
36
- bootstrap?: unknown;
37
- destroy?: unknown;
38
- runLifecyclesFunctions?: unknown;
39
- start?: unknown;
40
- stopWithError?: unknown;
41
- stop?: unknown;
42
- load?: unknown;
43
- reload?: unknown;
44
- startWebhooks?: unknown;
45
- postListen?: unknown;
46
- listen?: unknown;
47
- openAdmin?: unknown;
48
- loadAdmin?: unknown;
49
- loadPlugins?: unknown;
50
- loadPolicies?: unknown;
51
- loadAPIs?: unknown;
52
- loadComponents?: unknown;
53
- loadMiddlewares?: unknown;
54
- loadApp?: unknown;
55
- registerInternalHooks?: unknown;
56
- getModel?: unknown;
57
- query?: unknown;
58
- container?: unknown;
59
- dirs?: unknown;
60
- isLoaded?: unknown;
61
- server?: unknown;
62
- fs?: unknown;
63
- eventHub?: unknown;
64
- startupLogger?: unknown;
65
- log?: unknown;
66
- cron?: unknown;
67
- telemetry?: unknown;
68
- db?: unknown;
69
- store?: unknown;
70
- entityValidator?: unknown;
71
- entityService?: unknown;
72
- }>(properties?: T | undefined) => () => import("@strapi/strapi").Strapi;
73
- /**
74
- * Union type used to represent the default content types available
75
- */
76
- export declare type ContentType = 'foo' | 'bar';
77
- /**
78
- * Factory to get default content types test values
79
- */
80
- export declare const getContentTypes: () => {
81
- foo: {
82
- uid: "foo";
83
- attributes: {
84
- [attribute: string]: unknown;
85
- };
86
- };
87
- bar: {
88
- uid: "bar";
89
- attributes: {
90
- [attribute: string]: unknown;
91
- };
92
- };
93
- };
94
- /**
95
- * Create a factory of readable streams (wrapped with a jest mock function)
96
- */
97
- export declare const createMockedReadableFactory: <T extends string = ContentType>(source: { [ct in T]: {
98
- [key: string]: unknown;
99
- id: number;
100
- }[]; }) => jest.Mock<Readable, [uid: T]>;
101
- /**
102
- * Create a factory of mocked query builders
103
- */
104
- export declare const createMockedQueryBuilder: <T extends string = ContentType>(data: { [key in T]: unknown[]; }) => jest.Mock<{
105
- populate(populate: unknown): any;
106
- stream(): Readable;
107
- }, [uid: T]>;
108
- /**
109
- * Update the global store with the given strapi value
110
- */
111
- export declare const setGlobalStrapi: (strapi: Strapi.Strapi) => void;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setGlobalStrapi = exports.createMockedQueryBuilder = exports.createMockedReadableFactory = exports.getContentTypes = exports.getStrapiFactory = exports.collect = void 0;
4
- const stream_1 = require("stream");
5
- /**
6
- * Collect every entity in a Readable stream
7
- */
8
- const collect = (stream) => {
9
- const chunks = [];
10
- return new Promise((resolve, reject) => {
11
- stream
12
- .on('data', (chunk) => chunks.push(chunk))
13
- .on('close', () => resolve(chunks))
14
- .on('error', reject);
15
- });
16
- };
17
- exports.collect = collect;
18
- /**
19
- * Create a "Strapi" like object factory based on the
20
- * given params and cast it to the correct type
21
- */
22
- const getStrapiFactory = (properties) => () => {
23
- return { ...properties };
24
- };
25
- exports.getStrapiFactory = getStrapiFactory;
26
- /**
27
- * Factory to get default content types test values
28
- */
29
- const getContentTypes = () => ({
30
- foo: { uid: 'foo', attributes: { title: { type: 'string' } } },
31
- bar: { uid: 'bar', attributes: { age: { type: 'number' } } },
32
- });
33
- exports.getContentTypes = getContentTypes;
34
- /**
35
- * Create a factory of readable streams (wrapped with a jest mock function)
36
- */
37
- const createMockedReadableFactory = (source) => jest.fn((uid) => {
38
- return stream_1.Readable.from(source[uid] || []);
39
- });
40
- exports.createMockedReadableFactory = createMockedReadableFactory;
41
- /**
42
- * Create a factory of mocked query builders
43
- */
44
- const createMockedQueryBuilder = (data) => jest.fn((uid) => {
45
- const state = { populate: undefined };
46
- return {
47
- populate(populate) {
48
- state.populate = populate;
49
- return this;
50
- },
51
- stream() {
52
- return stream_1.Readable.from(data[uid]);
53
- },
54
- };
55
- });
56
- exports.createMockedQueryBuilder = createMockedQueryBuilder;
57
- /**
58
- * Update the global store with the given strapi value
59
- */
60
- const setGlobalStrapi = (strapi) => {
61
- global.strapi = strapi;
62
- };
63
- exports.setGlobalStrapi = setGlobalStrapi;
64
- //# sourceMappingURL=index.js.map
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- import { Transform, Readable } from 'stream';
3
- declare type TransformOptions = ConstructorParameters<typeof Transform>[0];
4
- export declare const filter: <T>(predicate: (value: T) => boolean | Promise<boolean>, options?: TransformOptions) => Transform;
5
- export declare const map: <T>(predicate: (value: T) => T | Promise<T>, options?: TransformOptions) => Transform;
6
- /**
7
- * Collect every entity in a Readable stream
8
- */
9
- export declare const collect: <T = unknown>(stream: Readable) => Promise<T[]>;
10
- export {};
@@ -1,39 +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
- const filter = (predicate, options = { objectMode: true }) => {
6
- return new stream_1.Transform({
7
- ...options,
8
- async transform(chunk, _encoding, callback) {
9
- const keep = await predicate(chunk);
10
- callback(null, keep ? chunk : undefined);
11
- },
12
- });
13
- };
14
- exports.filter = filter;
15
- const map = (predicate, options = { objectMode: true }) => {
16
- return new stream_1.Transform({
17
- ...options,
18
- async transform(chunk, _encoding, callback) {
19
- const mappedValue = await predicate(chunk);
20
- callback(null, mappedValue);
21
- },
22
- });
23
- };
24
- exports.map = map;
25
- /**
26
- * Collect every entity in a Readable stream
27
- */
28
- const collect = (stream) => {
29
- const chunks = [];
30
- return new Promise((resolve) => {
31
- stream.on('data', (chunk) => chunks.push(chunk));
32
- stream.on('end', () => {
33
- stream.destroy();
34
- resolve(chunks);
35
- });
36
- });
37
- };
38
- exports.collect = collect;
39
- //# sourceMappingURL=stream.js.map