@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,35 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.register = exports.remote = exports.queries = exports.providers = void 0;
30
+ exports.providers = __importStar(require("./providers"));
31
+ exports.queries = __importStar(require("./queries"));
32
+ exports.remote = __importStar(require("./remote"));
33
+ var register_1 = require("./register");
34
+ Object.defineProperty(exports, "register", { enumerable: true, get: function () { return __importDefault(register_1).default; } });
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ export * from './local-destination';
2
+ export * from './local-source';
3
+ export * from './remote-destination';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Local
18
+ __exportStar(require("./local-destination"), exports);
19
+ __exportStar(require("./local-source"), exports);
20
+ // Remote
21
+ __exportStar(require("./remote-destination"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -1,12 +1,13 @@
1
1
  /// <reference types="lodash" />
2
2
  /// <reference types="node" />
3
3
  import { Writable } from 'stream';
4
- import type { IDestinationProvider, IMetadata, ProviderType } from '../../../types';
4
+ import type { IDestinationProvider, IMetadata, ProviderType } from '../../../../types';
5
5
  import { restore } from './strategies';
6
6
  export declare const VALID_CONFLICT_STRATEGIES: string[];
7
7
  export declare const DEFAULT_CONFLICT_STRATEGY = "restore";
8
- interface ILocalStrapiDestinationProviderOptions {
8
+ export interface ILocalStrapiDestinationProviderOptions {
9
9
  getStrapi(): Strapi.Strapi | Promise<Strapi.Strapi>;
10
+ autoDestroy?: boolean;
10
11
  restore?: restore.IRestoreOptions;
11
12
  strategy: 'restore' | 'merge';
12
13
  }
@@ -20,12 +21,12 @@ declare class LocalStrapiDestinationProvider implements IDestinationProvider {
20
21
  bootstrap(): Promise<void>;
21
22
  close(): Promise<void>;
22
23
  beforeTransfer(): Promise<void>;
23
- getMetadata(): IMetadata | Promise<IMetadata>;
24
+ getMetadata(): IMetadata;
24
25
  getSchemas(): import("lodash").Dictionary<Partial<import("@strapi/strapi").Schema>>;
25
- getEntitiesStream(): Writable;
26
- getAssetsStream(): Promise<Writable>;
27
- getConfigurationStream(): Promise<Writable>;
28
- getLinksStream(): Promise<Writable>;
26
+ createEntitiesWriteStream(): Writable;
27
+ createAssetsWriteStream(): Promise<Writable>;
28
+ createConfigurationWriteStream(): Promise<Writable>;
29
+ createLinksWriteStream(): Promise<Writable>;
29
30
  }
30
31
  export declare const createLocalStrapiDestinationProvider: (options: ILocalStrapiDestinationProviderOptions) => LocalStrapiDestinationProvider;
31
32
  export {};
@@ -43,7 +43,7 @@ const stream_1 = require("stream");
43
43
  const path_1 = __importDefault(require("path"));
44
44
  const fse = __importStar(require("fs-extra"));
45
45
  const strategies_1 = require("./strategies");
46
- const utils = __importStar(require("../../utils"));
46
+ const utils = __importStar(require("../../../utils"));
47
47
  exports.VALID_CONFLICT_STRATEGIES = ['restore', 'merge'];
48
48
  exports.DEFAULT_CONFLICT_STRATEGY = 'restore';
49
49
  class LocalStrapiDestinationProvider {
@@ -51,6 +51,9 @@ class LocalStrapiDestinationProvider {
51
51
  _LocalStrapiDestinationProvider_instances.add(this);
52
52
  this.name = 'destination::local-strapi';
53
53
  this.type = 'destination';
54
+ /**
55
+ * The entities mapper is used to map old entities to their new IDs
56
+ */
54
57
  _LocalStrapiDestinationProvider_entitiesMapper.set(this, void 0);
55
58
  this.options = options;
56
59
  __classPrivateFieldSet(this, _LocalStrapiDestinationProvider_entitiesMapper, {}, "f");
@@ -60,7 +63,11 @@ class LocalStrapiDestinationProvider {
60
63
  this.strapi = await this.options.getStrapi();
61
64
  }
62
65
  async close() {
63
- await this.strapi?.destroy?.();
66
+ const { autoDestroy } = this.options;
67
+ // Basically `!== false` but more deterministic
68
+ if (autoDestroy === undefined || autoDestroy === true) {
69
+ await this.strapi?.destroy();
70
+ }
64
71
  }
65
72
  async beforeTransfer() {
66
73
  if (this.options.strategy === 'restore') {
@@ -93,7 +100,7 @@ class LocalStrapiDestinationProvider {
93
100
  };
94
101
  return utils.schema.mapSchemasValues(schemas);
95
102
  }
96
- getEntitiesStream() {
103
+ createEntitiesWriteStream() {
97
104
  if (!this.strapi) {
98
105
  throw new Error('Not able to import entities. Strapi instance not found');
99
106
  }
@@ -112,7 +119,8 @@ class LocalStrapiDestinationProvider {
112
119
  }
113
120
  throw new Error(`Invalid strategy supplied: "${strategy}"`);
114
121
  }
115
- async getAssetsStream() {
122
+ // TODO: Move this logic to the restore strategy
123
+ async createAssetsWriteStream() {
116
124
  if (!this.strapi) {
117
125
  throw new Error('Not able to stream Assets. Strapi instance not found');
118
126
  }
@@ -148,7 +156,7 @@ class LocalStrapiDestinationProvider {
148
156
  },
149
157
  });
150
158
  }
151
- async getConfigurationStream() {
159
+ async createConfigurationWriteStream() {
152
160
  if (!this.strapi) {
153
161
  throw new Error('Not able to stream Configurations. Strapi instance not found');
154
162
  }
@@ -158,7 +166,7 @@ class LocalStrapiDestinationProvider {
158
166
  }
159
167
  throw new Error(`Invalid strategy supplied: "${strategy}"`);
160
168
  }
161
- async getLinksStream() {
169
+ async createLinksWriteStream() {
162
170
  if (!this.strapi) {
163
171
  throw new Error('Not able to stream links. Strapi instance not found');
164
172
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  import { Writable } from 'stream';
3
- import { IConfiguration } from '../../../../../types';
3
+ import { IConfiguration } from '../../../../../../types';
4
4
  export declare const restoreConfigs: (strapi: Strapi.Strapi, config: IConfiguration) => Promise<any>;
5
5
  export declare const createConfigurationWriteStream: (strapi: Strapi.Strapi) => Promise<Writable>;
@@ -26,49 +26,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.createEntitiesWriteStream = void 0;
27
27
  const fp_1 = require("lodash/fp");
28
28
  const stream_1 = require("stream");
29
- const utils_1 = require("../../../../utils");
30
- const shared = __importStar(require("../../../shared"));
29
+ const utils_1 = require("../../../../../utils");
30
+ const queries = __importStar(require("../../../../queries"));
31
31
  const createEntitiesWriteStream = (options) => {
32
32
  const { strapi, updateMappingTable } = options;
33
- const query = shared.strapi.entity.createEntityQuery(strapi);
33
+ const query = queries.entity.createEntityQuery(strapi);
34
34
  return new stream_1.Writable({
35
35
  objectMode: true,
36
36
  async write(entity, _encoding, callback) {
37
37
  const { type, id, data } = entity;
38
38
  const { create, getDeepPopulateComponentLikeQuery } = query(type);
39
39
  const contentType = strapi.getModel(type);
40
+ /**
41
+ * Resolve the component UID of an entity's attribute based
42
+ * on a given path (components & dynamic zones only)
43
+ */
40
44
  const resolveType = (paths) => {
41
- let type = contentType;
45
+ let cType = contentType;
42
46
  let value = data;
43
47
  for (const path of paths) {
44
48
  value = (0, fp_1.get)(path, value);
45
- if (typeof type === 'function') {
46
- type = type(value);
49
+ // Needed when the value of cType should be computed
50
+ // based on the next value (eg: dynamic zones)
51
+ if (typeof cType === 'function') {
52
+ cType = cType(value);
47
53
  }
48
- if (path in type.attributes) {
49
- const attribute = type.attributes[path];
54
+ if (path in cType.attributes) {
55
+ const attribute = cType.attributes[path];
50
56
  if (attribute.type === 'component') {
51
- type = strapi.getModel(attribute.component);
57
+ cType = strapi.getModel(attribute.component);
52
58
  }
53
59
  if (attribute.type === 'dynamiczone') {
54
- type = ({ __component }) => strapi.getModel(__component);
60
+ cType = ({ __component }) => strapi.getModel(__component);
55
61
  }
56
62
  }
57
63
  }
58
- return type.uid;
64
+ return cType?.uid;
59
65
  };
60
66
  try {
61
- // Create the entity
62
67
  const created = await create({
63
68
  data,
64
69
  populate: getDeepPopulateComponentLikeQuery(contentType, { select: 'id' }),
65
70
  select: 'id',
66
71
  });
72
+ // Compute differences between original & new entities
67
73
  const diffs = utils_1.json.diff(data, created);
68
74
  updateMappingTable(type, id, created.id);
75
+ // For each difference found on an ID attribute,
76
+ // update the mapping the table accordingly
69
77
  diffs.forEach((diff) => {
70
- if (diff.kind === 'modified' && diff.path.at(-1) === 'id') {
78
+ if (diff.kind === 'modified' && (0, fp_1.last)(diff.path) === 'id') {
71
79
  const target = resolveType(diff.path);
80
+ // If no type is found for the given path, then ignore the diff
81
+ if (!target) {
82
+ return;
83
+ }
72
84
  const [oldID, newID] = diff.values;
73
85
  updateMappingTable(target, oldID, newID);
74
86
  }
@@ -27,7 +27,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.deleteRecords = void 0;
30
- const shared = __importStar(require("../../../shared"));
30
+ const queries = __importStar(require("../../../../queries"));
31
31
  const deleteRecords = async (strapi, options) => {
32
32
  const entities = await deleteEntitiesRecord(strapi, options);
33
33
  const configuration = await deleteConfigurationRecords(strapi, options);
@@ -40,7 +40,7 @@ const deleteRecords = async (strapi, options) => {
40
40
  exports.deleteRecords = deleteRecords;
41
41
  const deleteEntitiesRecord = async (strapi, options = {}) => {
42
42
  const { entities } = options;
43
- const query = shared.strapi.entity.createEntityQuery(strapi);
43
+ const query = queries.entity.createEntityQuery(strapi);
44
44
  const contentTypes = Object.values(strapi.contentTypes);
45
45
  const contentTypesToClear = contentTypes.filter((contentType) => {
46
46
  let keep = true;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLinksWriteStream = void 0;
4
4
  const stream_1 = require("stream");
5
- const link_1 = require("../../../shared/strapi/link");
5
+ const link_1 = require("../../../../queries/link");
6
6
  const createLinksWriteStream = (mapID, strapi) => {
7
7
  return new stream_1.Writable({
8
8
  objectMode: true,
@@ -8,20 +8,19 @@ const fp_1 = require("lodash/fp");
8
8
  * Create a readable stream that export the Strapi app configuration
9
9
  */
10
10
  const createConfigurationStream = (strapi) => {
11
- // Core Store
12
- const coreStoreStream = (0, stream_chain_1.chain)([
13
- strapi.db.queryBuilder('strapi::core-store').stream(),
14
- (data) => (0, fp_1.set)('value', JSON.parse(data.value), data),
15
- wrapConfigurationItem('core-store'),
16
- ]);
17
- // Webhook
18
- const webhooksStream = (0, stream_chain_1.chain)([
19
- strapi.db.queryBuilder('webhook').stream(),
20
- wrapConfigurationItem('webhook'),
21
- ]);
22
- const streams = [coreStoreStream, webhooksStream];
23
- // Readable configuration stream
24
11
  return stream_1.Readable.from((async function* configurationGenerator() {
12
+ // Core Store
13
+ const coreStoreStream = (0, stream_chain_1.chain)([
14
+ strapi.db.queryBuilder('strapi::core-store').stream(),
15
+ (data) => (0, fp_1.set)('value', JSON.parse(data.value), data),
16
+ wrapConfigurationItem('core-store'),
17
+ ]);
18
+ // Webhook
19
+ const webhooksStream = (0, stream_chain_1.chain)([
20
+ strapi.db.queryBuilder('webhook').stream(),
21
+ wrapConfigurationItem('webhook'),
22
+ ]);
23
+ const streams = [coreStoreStream, webhooksStream];
25
24
  for (const stream of streams) {
26
25
  for await (const item of stream) {
27
26
  yield item;
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.createEntitiesTransformStream = exports.createEntitiesStream = void 0;
27
27
  const stream_1 = require("stream");
28
- const shared = __importStar(require("../shared/strapi"));
28
+ const shared = __importStar(require("../../queries"));
29
29
  /**
30
30
  * Generate and consume content-types streams in order to stream each entity individually
31
31
  */
@@ -48,10 +48,17 @@ const createEntitiesStream = (strapi) => {
48
48
  }
49
49
  return stream_1.Readable.from((async function* entitiesGenerator() {
50
50
  for await (const { stream, contentType } of contentTypeStreamGenerator()) {
51
- for await (const entity of stream) {
52
- yield { entity, contentType };
51
+ try {
52
+ for await (const entity of stream) {
53
+ yield { entity, contentType };
54
+ }
55
+ }
56
+ catch {
57
+ // ignore
58
+ }
59
+ finally {
60
+ stream.destroy();
53
61
  }
54
- stream.destroy();
55
62
  }
56
63
  })());
57
64
  };
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="lodash" />
3
3
  import { Readable } from 'stream';
4
- import type { IMetadata, ISourceProvider, ProviderType } from '../../../types';
4
+ import type { IMetadata, ISourceProvider, ProviderType } from '../../../../types';
5
5
  export interface ILocalStrapiSourceProviderOptions {
6
6
  getStrapi(): Strapi.Strapi | Promise<Strapi.Strapi>;
7
7
  autoDestroy?: boolean;
@@ -16,12 +16,12 @@ declare class LocalStrapiSourceProvider implements ISourceProvider {
16
16
  bootstrap(): Promise<void>;
17
17
  close(): Promise<void>;
18
18
  getMetadata(): IMetadata;
19
- streamEntities(): Promise<Readable>;
20
- streamLinks(): Readable;
21
- streamConfiguration(): Readable;
19
+ createEntitiesReadStream(): Promise<Readable>;
20
+ createLinksReadStream(): Readable;
21
+ createConfigurationReadStream(): Readable;
22
22
  getSchemas(): import("lodash").Dictionary<Partial<import("@strapi/strapi").Schema>>;
23
- streamSchemas(): Readable;
24
- streamAssets(): Readable;
23
+ createSchemasReadStream(): Readable;
24
+ createAssetsReadStream(): Readable;
25
25
  }
26
26
  export declare type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;
27
27
  export {};
@@ -30,7 +30,7 @@ const entities_1 = require("./entities");
30
30
  const links_1 = require("./links");
31
31
  const configuration_1 = require("./configuration");
32
32
  const assets_1 = require("./assets");
33
- const utils = __importStar(require("../../utils"));
33
+ const utils = __importStar(require("../../../utils"));
34
34
  const createLocalStrapiSourceProvider = (options) => {
35
35
  return new LocalStrapiSourceProvider(options);
36
36
  };
@@ -67,7 +67,7 @@ class LocalStrapiSourceProvider {
67
67
  },
68
68
  };
69
69
  }
70
- async streamEntities() {
70
+ async createEntitiesReadStream() {
71
71
  if (!this.strapi) {
72
72
  throw new Error('Not able to stream entities. Strapi instance not found');
73
73
  }
@@ -78,13 +78,13 @@ class LocalStrapiSourceProvider {
78
78
  (0, entities_1.createEntitiesTransformStream)(),
79
79
  ]);
80
80
  }
81
- streamLinks() {
81
+ createLinksReadStream() {
82
82
  if (!this.strapi) {
83
83
  throw new Error('Not able to stream links. Strapi instance not found');
84
84
  }
85
85
  return (0, links_1.createLinksStream)(this.strapi);
86
86
  }
87
- streamConfiguration() {
87
+ createConfigurationReadStream() {
88
88
  if (!this.strapi) {
89
89
  throw new Error('Not able to stream configuration. Strapi instance not found');
90
90
  }
@@ -100,10 +100,10 @@ class LocalStrapiSourceProvider {
100
100
  };
101
101
  return utils.schema.mapSchemasValues(schemas);
102
102
  }
103
- streamSchemas() {
103
+ createSchemasReadStream() {
104
104
  return stream_1.Readable.from(Object.values(this.getSchemas()));
105
105
  }
106
- streamAssets() {
106
+ createAssetsReadStream() {
107
107
  if (!this.strapi) {
108
108
  throw new Error('Not able to stream assets. Strapi instance not found');
109
109
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLinksStream = void 0;
4
4
  const stream_1 = require("stream");
5
- const link_1 = require("../shared/strapi/link");
5
+ const link_1 = require("../../queries/link");
6
6
  /**
7
7
  * Create a Readable which will stream all the links from a Strapi instance
8
8
  */
@@ -0,0 +1,40 @@
1
+ /// <reference types="node" />
2
+ import { WebSocket } from 'ws';
3
+ import { Writable } from 'stream';
4
+ import { createDispatcher } from './utils';
5
+ import type { IDestinationProvider, IMetadata, ProviderType } from '../../../../types';
6
+ import type { ILocalStrapiDestinationProviderOptions } from '../local-destination';
7
+ interface ITokenAuth {
8
+ type: 'token';
9
+ token: string;
10
+ }
11
+ interface ICredentialsAuth {
12
+ type: 'credentials';
13
+ email: string;
14
+ password: string;
15
+ }
16
+ export interface IRemoteStrapiDestinationProviderOptions extends Pick<ILocalStrapiDestinationProviderOptions, 'restore' | 'strategy'> {
17
+ url: URL;
18
+ auth?: ITokenAuth | ICredentialsAuth;
19
+ }
20
+ declare class RemoteStrapiDestinationProvider implements IDestinationProvider {
21
+ #private;
22
+ name: string;
23
+ type: ProviderType;
24
+ options: IRemoteStrapiDestinationProviderOptions;
25
+ ws: WebSocket | null;
26
+ dispatcher: ReturnType<typeof createDispatcher> | null;
27
+ constructor(options: IRemoteStrapiDestinationProviderOptions);
28
+ initTransfer(): Promise<string>;
29
+ bootstrap(): Promise<void>;
30
+ close(): Promise<void>;
31
+ getMetadata(): Promise<IMetadata | null> | null;
32
+ beforeTransfer(): Promise<void>;
33
+ getSchemas(): Promise<Strapi.Schemas | null>;
34
+ createEntitiesWriteStream(): Writable;
35
+ createLinksWriteStream(): Writable;
36
+ createConfigurationWriteStream(): Writable;
37
+ createAssetsWriteStream(): Writable | Promise<Writable>;
38
+ }
39
+ export declare const createRemoteStrapiDestinationProvider: (options: IRemoteStrapiDestinationProviderOptions) => RemoteStrapiDestinationProvider;
40
+ export {};