@strapi/data-transfer 4.12.2 → 4.13.0-beta.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/diagnostic.d.ts +40 -0
- package/dist/engine/diagnostic.js +50 -0
- package/dist/engine/diagnostic.js.map +1 -0
- package/dist/engine/errors.d.ts +28 -0
- package/dist/engine/errors.js +29 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/index.d.ts +64 -0
- package/dist/engine/index.js +664 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/validation/index.d.ts +2 -0
- package/dist/engine/validation/index.js +19 -0
- package/dist/engine/validation/index.js.map +1 -0
- package/dist/engine/validation/provider.d.ts +3 -0
- package/dist/engine/validation/provider.js +18 -0
- package/dist/engine/validation/provider.js.map +1 -0
- package/dist/engine/validation/schemas/index.d.ts +7 -0
- package/dist/engine/validation/schemas/index.js +70 -0
- package/dist/engine/validation/schemas/index.js.map +1 -0
- package/dist/errors/base.d.ts +8 -0
- package/dist/errors/base.js +13 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/constants.d.ts +3 -0
- package/dist/errors/constants.js +9 -0
- package/dist/errors/constants.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +19 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/providers.d.ts +23 -0
- package/dist/errors/providers.js +32 -0
- package/dist/errors/providers.js.map +1 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +28 -0
- package/dist/file/index.js.map +1 -0
- package/dist/file/providers/destination/index.d.ts +46 -0
- package/dist/file/providers/destination/index.js +181 -0
- package/dist/file/providers/destination/index.js.map +1 -0
- package/dist/file/providers/destination/utils.d.ts +9 -0
- package/dist/file/providers/destination/utils.js +62 -0
- package/dist/file/providers/destination/utils.js.map +1 -0
- package/dist/file/providers/index.d.ts +2 -0
- package/dist/file/providers/index.js +19 -0
- package/dist/file/providers/index.js.map +1 -0
- package/dist/file/providers/source/index.d.ts +40 -0
- package/dist/file/providers/source/index.js +242 -0
- package/dist/file/providers/source/index.js.map +1 -0
- package/dist/file/providers/source/utils.d.ts +37 -0
- package/dist/file/providers/source/utils.js +62 -0
- package/dist/file/providers/source/utils.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/strapi/index.d.ts +3 -0
- package/dist/strapi/index.js +30 -0
- package/dist/strapi/index.js.map +1 -0
- package/dist/strapi/providers/index.d.ts +4 -0
- package/dist/strapi/providers/index.js +23 -0
- package/dist/strapi/providers/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/index.d.ts +34 -0
- package/dist/strapi/providers/local-destination/index.js +321 -0
- package/dist/strapi/providers/local-destination/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/index.d.ts +1 -0
- package/dist/strapi/providers/local-destination/strategies/index.js +28 -0
- package/dist/strapi/providers/local-destination/strategies/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +5 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +51 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +11 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js +103 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts +32 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.js +107 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +4 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.js +32 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -0
- package/dist/strapi/providers/local-source/assets.d.ts +5 -0
- package/dist/strapi/providers/local-source/assets.js +98 -0
- package/dist/strapi/providers/local-source/assets.js.map +1 -0
- package/dist/strapi/providers/local-source/configuration.d.ts +5 -0
- package/dist/strapi/providers/local-source/configuration.js +36 -0
- package/dist/strapi/providers/local-source/configuration.js.map +1 -0
- package/dist/strapi/providers/local-source/entities.d.ts +10 -0
- package/dist/strapi/providers/local-source/entities.js +85 -0
- package/dist/strapi/providers/local-source/entities.js.map +1 -0
- package/dist/strapi/providers/local-source/index.d.ts +26 -0
- package/dist/strapi/providers/local-source/index.js +98 -0
- package/dist/strapi/providers/local-source/index.js.map +1 -0
- package/dist/strapi/providers/local-source/links.d.ts +5 -0
- package/dist/strapi/providers/local-source/links.js +23 -0
- package/dist/strapi/providers/local-source/links.js.map +1 -0
- package/dist/strapi/providers/remote-destination/index.d.ts +39 -0
- package/dist/strapi/providers/remote-destination/index.js +269 -0
- package/dist/strapi/providers/remote-destination/index.js.map +1 -0
- package/dist/strapi/providers/remote-source/index.d.ts +39 -0
- package/dist/strapi/providers/remote-source/index.js +239 -0
- package/dist/strapi/providers/remote-source/index.js.map +1 -0
- package/dist/strapi/providers/utils.d.ts +39 -0
- package/dist/strapi/providers/utils.js +138 -0
- package/dist/strapi/providers/utils.js.map +1 -0
- package/dist/strapi/queries/entity.d.ts +2 -0
- package/dist/strapi/queries/entity.js +130 -0
- package/dist/strapi/queries/entity.js.map +1 -0
- package/dist/strapi/queries/index.d.ts +2 -0
- package/dist/strapi/queries/index.js +29 -0
- package/dist/strapi/queries/index.js.map +1 -0
- package/dist/strapi/queries/link.d.ts +7 -0
- package/dist/strapi/queries/link.js +215 -0
- package/dist/strapi/queries/link.js.map +1 -0
- package/dist/strapi/remote/constants.d.ts +4 -0
- package/dist/strapi/remote/constants.js +6 -0
- package/dist/strapi/remote/constants.js.map +1 -0
- package/dist/strapi/remote/flows/default.d.ts +3 -0
- package/dist/strapi/remote/flows/default.js +41 -0
- package/dist/strapi/remote/flows/default.js.map +1 -0
- package/dist/strapi/remote/flows/index.d.ts +18 -0
- package/dist/strapi/remote/flows/index.js +59 -0
- package/dist/strapi/remote/flows/index.js.map +1 -0
- package/dist/strapi/remote/handlers/abstract.d.ts +71 -0
- package/dist/strapi/remote/handlers/abstract.js +3 -0
- package/dist/strapi/remote/handlers/abstract.js.map +1 -0
- package/dist/strapi/remote/handlers/constants.d.ts +2 -0
- package/dist/strapi/remote/handlers/constants.js +5 -0
- package/dist/strapi/remote/handlers/constants.js.map +1 -0
- package/dist/strapi/remote/handlers/index.d.ts +3 -0
- package/dist/strapi/remote/handlers/index.js +10 -0
- package/dist/strapi/remote/handlers/index.js.map +1 -0
- package/dist/strapi/remote/handlers/pull.d.ts +22 -0
- package/dist/strapi/remote/handlers/pull.js +243 -0
- package/dist/strapi/remote/handlers/pull.js.map +1 -0
- package/dist/strapi/remote/handlers/push.d.ts +75 -0
- package/dist/strapi/remote/handlers/push.js +311 -0
- package/dist/strapi/remote/handlers/push.js.map +1 -0
- package/dist/strapi/remote/handlers/utils.d.ts +25 -0
- package/dist/strapi/remote/handlers/utils.js +217 -0
- package/dist/strapi/remote/handlers/utils.js.map +1 -0
- package/dist/strapi/remote/index.d.ts +2 -0
- package/dist/strapi/remote/index.js +29 -0
- package/dist/strapi/remote/index.js.map +1 -0
- package/dist/utils/encryption/decrypt.d.ts +11 -0
- package/dist/utils/encryption/decrypt.js +47 -0
- package/dist/utils/encryption/decrypt.js.map +1 -0
- package/dist/utils/encryption/encrypt.d.ts +11 -0
- package/dist/utils/encryption/encrypt.js +47 -0
- package/dist/utils/encryption/encrypt.js.map +1 -0
- package/dist/utils/encryption/index.d.ts +2 -0
- package/dist/utils/encryption/index.js +19 -0
- package/dist/utils/encryption/index.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +33 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json.d.ts +30 -0
- package/dist/utils/json.js +68 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/middleware.d.ts +2 -0
- package/dist/utils/middleware.js +14 -0
- package/dist/utils/middleware.js.map +1 -0
- package/dist/utils/providers.d.ts +2 -0
- package/dist/utils/providers.js +11 -0
- package/dist/utils/providers.js.map +1 -0
- package/dist/utils/schema.d.ts +6 -0
- package/dist/utils/schema.js +29 -0
- package/dist/utils/schema.js.map +1 -0
- package/dist/utils/stream.d.ts +27 -0
- package/dist/utils/stream.js +59 -0
- package/dist/utils/stream.js.map +1 -0
- package/dist/utils/transaction.d.ts +3 -0
- package/dist/utils/transaction.js +88 -0
- package/dist/utils/transaction.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,321 @@
|
|
|
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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
26
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
28
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
29
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
30
|
+
};
|
|
31
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
32
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
33
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
var _LocalStrapiDestinationProvider_instances, _LocalStrapiDestinationProvider_entitiesMapper, _LocalStrapiDestinationProvider_validateOptions, _LocalStrapiDestinationProvider_deleteAll, _LocalStrapiDestinationProvider_deleteAllAssets, _LocalStrapiDestinationProvider_handleAssetsBackup, _LocalStrapiDestinationProvider_removeAssetsBackup;
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.createLocalStrapiDestinationProvider = exports.DEFAULT_CONFLICT_STRATEGY = exports.VALID_CONFLICT_STRATEGIES = void 0;
|
|
42
|
+
const stream_1 = require("stream");
|
|
43
|
+
const path_1 = __importDefault(require("path"));
|
|
44
|
+
const fse = __importStar(require("fs-extra"));
|
|
45
|
+
const strategies_1 = require("./strategies");
|
|
46
|
+
const utils = __importStar(require("../../../utils"));
|
|
47
|
+
const providers_1 = require("../../../errors/providers");
|
|
48
|
+
const providers_2 = require("../../../utils/providers");
|
|
49
|
+
exports.VALID_CONFLICT_STRATEGIES = ['restore'];
|
|
50
|
+
exports.DEFAULT_CONFLICT_STRATEGY = 'restore';
|
|
51
|
+
class LocalStrapiDestinationProvider {
|
|
52
|
+
constructor(options) {
|
|
53
|
+
_LocalStrapiDestinationProvider_instances.add(this);
|
|
54
|
+
this.name = 'destination::local-strapi';
|
|
55
|
+
this.type = 'destination';
|
|
56
|
+
/**
|
|
57
|
+
* The entities mapper is used to map old entities to their new IDs
|
|
58
|
+
*/
|
|
59
|
+
_LocalStrapiDestinationProvider_entitiesMapper.set(this, void 0);
|
|
60
|
+
this.options = options;
|
|
61
|
+
__classPrivateFieldSet(this, _LocalStrapiDestinationProvider_entitiesMapper, {}, "f");
|
|
62
|
+
this.uploadsBackupDirectoryName = `uploads_backup_${Date.now()}`;
|
|
63
|
+
}
|
|
64
|
+
async bootstrap() {
|
|
65
|
+
__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_validateOptions).call(this);
|
|
66
|
+
this.strapi = await this.options.getStrapi();
|
|
67
|
+
this.transaction = utils.transaction.createTransaction(this.strapi);
|
|
68
|
+
}
|
|
69
|
+
async close() {
|
|
70
|
+
const { autoDestroy } = this.options;
|
|
71
|
+
this.transaction?.end();
|
|
72
|
+
// Basically `!== false` but more deterministic
|
|
73
|
+
if (autoDestroy === undefined || autoDestroy === true) {
|
|
74
|
+
await this.strapi?.destroy();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async rollback() {
|
|
78
|
+
await this.transaction?.rollback();
|
|
79
|
+
}
|
|
80
|
+
async beforeTransfer() {
|
|
81
|
+
if (!this.strapi) {
|
|
82
|
+
throw new Error('Strapi instance not found');
|
|
83
|
+
}
|
|
84
|
+
await this.transaction?.attach(async (trx) => {
|
|
85
|
+
await __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_handleAssetsBackup).call(this);
|
|
86
|
+
try {
|
|
87
|
+
if (this.options.strategy === 'restore') {
|
|
88
|
+
await __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_deleteAllAssets).call(this, trx);
|
|
89
|
+
await __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_deleteAll).call(this);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw new Error(`restore failed ${error}`);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
getMetadata() {
|
|
98
|
+
const strapiVersion = strapi.config.get('info.strapi');
|
|
99
|
+
const createdAt = new Date().toISOString();
|
|
100
|
+
return {
|
|
101
|
+
createdAt,
|
|
102
|
+
strapi: {
|
|
103
|
+
version: strapiVersion,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
getSchemas() {
|
|
108
|
+
(0, providers_2.assertValidStrapi)(this.strapi, 'Not able to get Schemas');
|
|
109
|
+
const schemas = {
|
|
110
|
+
...this.strapi.contentTypes,
|
|
111
|
+
...this.strapi.components,
|
|
112
|
+
};
|
|
113
|
+
return utils.schema.mapSchemasValues(schemas);
|
|
114
|
+
}
|
|
115
|
+
createEntitiesWriteStream() {
|
|
116
|
+
(0, providers_2.assertValidStrapi)(this.strapi, 'Not able to import entities');
|
|
117
|
+
const { strategy } = this.options;
|
|
118
|
+
const updateMappingTable = (type, oldID, newID) => {
|
|
119
|
+
if (!__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type]) {
|
|
120
|
+
__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type] = {};
|
|
121
|
+
}
|
|
122
|
+
Object.assign(__classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[type], { [oldID]: newID });
|
|
123
|
+
};
|
|
124
|
+
if (strategy === 'restore') {
|
|
125
|
+
return strategies_1.restore.createEntitiesWriteStream({
|
|
126
|
+
strapi: this.strapi,
|
|
127
|
+
updateMappingTable,
|
|
128
|
+
transaction: this.transaction,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
throw new providers_1.ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
|
|
132
|
+
check: 'strategy',
|
|
133
|
+
strategy: this.options.strategy,
|
|
134
|
+
validStrategies: exports.VALID_CONFLICT_STRATEGIES,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
// TODO: Move this logic to the restore strategy
|
|
138
|
+
async createAssetsWriteStream() {
|
|
139
|
+
(0, providers_2.assertValidStrapi)(this.strapi, 'Not able to stream Assets');
|
|
140
|
+
const removeAssetsBackup = __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_instances, "m", _LocalStrapiDestinationProvider_removeAssetsBackup).bind(this);
|
|
141
|
+
const strapi = this.strapi;
|
|
142
|
+
const transaction = this.transaction;
|
|
143
|
+
const backupDirectory = this.uploadsBackupDirectoryName;
|
|
144
|
+
return new stream_1.Writable({
|
|
145
|
+
objectMode: true,
|
|
146
|
+
async final(next) {
|
|
147
|
+
// Deletes the backup folder
|
|
148
|
+
removeAssetsBackup();
|
|
149
|
+
next();
|
|
150
|
+
},
|
|
151
|
+
async write(chunk, _encoding, callback) {
|
|
152
|
+
await transaction?.attach(async () => {
|
|
153
|
+
// TODO: Remove this logic in V5
|
|
154
|
+
if (!chunk.metadata) {
|
|
155
|
+
// If metadata does not exist is because it is an old backup file
|
|
156
|
+
const assetsDirectory = path_1.default.join(strapi.dirs.static.public, 'uploads');
|
|
157
|
+
const entryPath = path_1.default.join(assetsDirectory, chunk.filename);
|
|
158
|
+
const writableStream = fse.createWriteStream(entryPath);
|
|
159
|
+
chunk.stream
|
|
160
|
+
.pipe(writableStream)
|
|
161
|
+
.on('close', () => {
|
|
162
|
+
callback(null);
|
|
163
|
+
})
|
|
164
|
+
.on('error', async (error) => {
|
|
165
|
+
const errorMessage = error.code === 'ENOSPC'
|
|
166
|
+
? " Your server doesn't have space to proceed with the import. "
|
|
167
|
+
: ' ';
|
|
168
|
+
try {
|
|
169
|
+
await fse.rm(assetsDirectory, { recursive: true, force: true });
|
|
170
|
+
this.destroy(new providers_1.ProviderTransferError(`There was an error during the transfer process.${errorMessage}The original files have been restored to ${assetsDirectory}`));
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
throw new providers_1.ProviderTransferError(`There was an error doing the rollback process. The original files are in ${backupDirectory}, but we failed to restore them to ${assetsDirectory}`);
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
callback(error);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const uploadData = {
|
|
182
|
+
...chunk.metadata,
|
|
183
|
+
stream: stream_1.Readable.from(chunk.stream),
|
|
184
|
+
buffer: chunk?.buffer,
|
|
185
|
+
};
|
|
186
|
+
const provider = strapi.config.get('plugin.upload').provider;
|
|
187
|
+
try {
|
|
188
|
+
await strapi.plugin('upload').provider.uploadStream(uploadData);
|
|
189
|
+
// Files formats are stored within the parent file entity
|
|
190
|
+
if (uploadData?.type) {
|
|
191
|
+
const entry = await strapi.db.query('plugin::upload.file').findOne({
|
|
192
|
+
where: { hash: uploadData.mainHash },
|
|
193
|
+
});
|
|
194
|
+
const specificFormat = entry?.formats?.[uploadData.type];
|
|
195
|
+
if (specificFormat) {
|
|
196
|
+
specificFormat.url = uploadData.url;
|
|
197
|
+
}
|
|
198
|
+
await strapi.db.query('plugin::upload.file').update({
|
|
199
|
+
where: { hash: uploadData.mainHash },
|
|
200
|
+
data: {
|
|
201
|
+
formats: entry.formats,
|
|
202
|
+
provider,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
return callback();
|
|
206
|
+
}
|
|
207
|
+
const entry = await strapi.db.query('plugin::upload.file').findOne({
|
|
208
|
+
where: { hash: uploadData.hash },
|
|
209
|
+
});
|
|
210
|
+
entry.url = uploadData.url;
|
|
211
|
+
await strapi.db.query('plugin::upload.file').update({
|
|
212
|
+
where: { hash: uploadData.hash },
|
|
213
|
+
data: {
|
|
214
|
+
url: entry.url,
|
|
215
|
+
provider,
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
callback();
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
callback(new Error(`Error while uploading asset ${chunk.filename} ${error}`));
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
async createConfigurationWriteStream() {
|
|
228
|
+
(0, providers_2.assertValidStrapi)(this.strapi, 'Not able to stream Configurations');
|
|
229
|
+
const { strategy } = this.options;
|
|
230
|
+
if (strategy === 'restore') {
|
|
231
|
+
return strategies_1.restore.createConfigurationWriteStream(this.strapi, this.transaction);
|
|
232
|
+
}
|
|
233
|
+
throw new providers_1.ProviderValidationError(`Invalid strategy ${strategy}`, {
|
|
234
|
+
check: 'strategy',
|
|
235
|
+
strategy,
|
|
236
|
+
validStrategies: exports.VALID_CONFLICT_STRATEGIES,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
async createLinksWriteStream() {
|
|
240
|
+
if (!this.strapi) {
|
|
241
|
+
throw new Error('Not able to stream links. Strapi instance not found');
|
|
242
|
+
}
|
|
243
|
+
const { strategy } = this.options;
|
|
244
|
+
const mapID = (uid, id) => __classPrivateFieldGet(this, _LocalStrapiDestinationProvider_entitiesMapper, "f")[uid]?.[id];
|
|
245
|
+
if (strategy === 'restore') {
|
|
246
|
+
return strategies_1.restore.createLinksWriteStream(mapID, this.strapi, this.transaction);
|
|
247
|
+
}
|
|
248
|
+
throw new providers_1.ProviderValidationError(`Invalid strategy ${strategy}`, {
|
|
249
|
+
check: 'strategy',
|
|
250
|
+
strategy,
|
|
251
|
+
validStrategies: exports.VALID_CONFLICT_STRATEGIES,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
_LocalStrapiDestinationProvider_entitiesMapper = new WeakMap(), _LocalStrapiDestinationProvider_instances = new WeakSet(), _LocalStrapiDestinationProvider_validateOptions = function _LocalStrapiDestinationProvider_validateOptions() {
|
|
256
|
+
if (!exports.VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {
|
|
257
|
+
throw new providers_1.ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
|
|
258
|
+
check: 'strategy',
|
|
259
|
+
strategy: this.options.strategy,
|
|
260
|
+
validStrategies: exports.VALID_CONFLICT_STRATEGIES,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}, _LocalStrapiDestinationProvider_deleteAll = async function _LocalStrapiDestinationProvider_deleteAll() {
|
|
264
|
+
(0, providers_2.assertValidStrapi)(this.strapi);
|
|
265
|
+
return strategies_1.restore.deleteRecords(this.strapi, this.options.restore);
|
|
266
|
+
}, _LocalStrapiDestinationProvider_deleteAllAssets = async function _LocalStrapiDestinationProvider_deleteAllAssets(trx) {
|
|
267
|
+
(0, providers_2.assertValidStrapi)(this.strapi);
|
|
268
|
+
const stream = strapi.db
|
|
269
|
+
// Create a query builder instance (default type is 'select')
|
|
270
|
+
.queryBuilder('plugin::upload.file')
|
|
271
|
+
// Fetch all columns
|
|
272
|
+
.select('*')
|
|
273
|
+
// Attach the transaction
|
|
274
|
+
.transacting(trx)
|
|
275
|
+
// Get a readable stream
|
|
276
|
+
.stream();
|
|
277
|
+
// TODO use bulk delete when exists in providers
|
|
278
|
+
for await (const file of stream) {
|
|
279
|
+
await strapi.plugin('upload').provider.delete(file);
|
|
280
|
+
if (file.formats) {
|
|
281
|
+
for (const fileFormat of Object.values(file.formats)) {
|
|
282
|
+
await strapi.plugin('upload').provider.delete(fileFormat);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}, _LocalStrapiDestinationProvider_handleAssetsBackup = async function _LocalStrapiDestinationProvider_handleAssetsBackup() {
|
|
287
|
+
(0, providers_2.assertValidStrapi)(this.strapi, 'Not able to create the assets backup');
|
|
288
|
+
if (strapi.config.get('plugin.upload').provider === 'local') {
|
|
289
|
+
const assetsDirectory = path_1.default.join(this.strapi.dirs.static.public, 'uploads');
|
|
290
|
+
const backupDirectory = path_1.default.join(this.strapi.dirs.static.public, this.uploadsBackupDirectoryName);
|
|
291
|
+
try {
|
|
292
|
+
// Check access before attempting to do anything
|
|
293
|
+
await fse.access(assetsDirectory,
|
|
294
|
+
// eslint-disable-next-line no-bitwise
|
|
295
|
+
fse.constants.W_OK | fse.constants.R_OK | fse.constants.F_OK);
|
|
296
|
+
// eslint-disable-next-line no-bitwise
|
|
297
|
+
await fse.access(path_1.default.join(assetsDirectory, '..'), fse.constants.W_OK | fse.constants.R_OK);
|
|
298
|
+
await fse.move(assetsDirectory, backupDirectory);
|
|
299
|
+
await fse.mkdir(assetsDirectory);
|
|
300
|
+
// Create a .gitkeep file to ensure the directory is not empty
|
|
301
|
+
await fse.outputFile(path_1.default.join(assetsDirectory, '.gitkeep'), '');
|
|
302
|
+
}
|
|
303
|
+
catch (err) {
|
|
304
|
+
throw new providers_1.ProviderTransferError('The backup folder for the assets could not be created inside the public folder. Please ensure Strapi has write permissions on the public directory', {
|
|
305
|
+
code: 'ASSETS_DIRECTORY_ERR',
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
return backupDirectory;
|
|
309
|
+
}
|
|
310
|
+
}, _LocalStrapiDestinationProvider_removeAssetsBackup = async function _LocalStrapiDestinationProvider_removeAssetsBackup() {
|
|
311
|
+
if (strapi.config.get('plugin.upload').provider === 'local') {
|
|
312
|
+
(0, providers_2.assertValidStrapi)(this.strapi);
|
|
313
|
+
const backupDirectory = path_1.default.join(this.strapi.dirs.static.public, this.uploadsBackupDirectoryName);
|
|
314
|
+
await fse.rm(backupDirectory, { recursive: true, force: true });
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const createLocalStrapiDestinationProvider = (options) => {
|
|
318
|
+
return new LocalStrapiDestinationProvider(options);
|
|
319
|
+
};
|
|
320
|
+
exports.createLocalStrapiDestinationProvider = createLocalStrapiDestinationProvider;
|
|
321
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/strapi/providers/local-destination/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA4C;AAC5C,gDAAwB;AACxB,8CAAgC;AAWhC,6CAAuC;AACvC,sDAAwC;AACxC,yDAA2F;AAC3F,wDAA6D;AAEhD,QAAA,yBAAyB,GAAG,CAAC,SAAS,CAAC,CAAC;AACxC,QAAA,yBAAyB,GAAG,SAAS,CAAC;AAUnD,MAAM,8BAA8B;IAkBlC,YAAY,OAA+C;;QAjB3D,SAAI,GAAG,2BAA2B,CAAC;QAEnC,SAAI,GAAiB,aAAa,CAAC;QAUnC;;WAEG;QACH,iEAA8D;QAG5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,uBAAA,IAAI,kDAAmB,EAAE,MAAA,CAAC;QAC1B,IAAI,CAAC,0BAA0B,GAAG,kBAAkB,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,SAAS;QACb,uBAAA,IAAI,kGAAiB,MAArB,IAAI,CAAmB,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QAE7C,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC;QAExB,+CAA+C;QAC/C,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,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AAC,CAAC;AAJW,QAAA,oCAAoC,wCAI/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as restore from './restore';
|
|
@@ -0,0 +1,28 @@
|
|
|
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.restore = void 0;
|
|
27
|
+
exports.restore = __importStar(require("./restore"));
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/strapi/providers/local-destination/strategies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAqC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
import { IConfiguration, Transaction } from '../../../../../../types';
|
|
4
|
+
export declare const restoreConfigs: (strapi: Strapi.Strapi, config: IConfiguration) => Promise<any>;
|
|
5
|
+
export declare const createConfigurationWriteStream: (strapi: Strapi.Strapi, transaction?: Transaction) => Promise<Writable>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createConfigurationWriteStream = exports.restoreConfigs = void 0;
|
|
7
|
+
const stream_1 = require("stream");
|
|
8
|
+
const fp_1 = require("lodash/fp");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const providers_1 = require("../../../../../errors/providers");
|
|
11
|
+
const omitInvalidCreationAttributes = (0, fp_1.omit)(['id']);
|
|
12
|
+
const restoreCoreStore = async (strapi, values) => {
|
|
13
|
+
const data = omitInvalidCreationAttributes(values);
|
|
14
|
+
return strapi.db.query('strapi::core-store').create({
|
|
15
|
+
data: {
|
|
16
|
+
...data,
|
|
17
|
+
value: JSON.stringify(data.value),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const restoreWebhooks = async (strapi, values) => {
|
|
22
|
+
const data = omitInvalidCreationAttributes(values);
|
|
23
|
+
return strapi.db.query('webhook').create({ data });
|
|
24
|
+
};
|
|
25
|
+
const restoreConfigs = async (strapi, config) => {
|
|
26
|
+
if (config.type === 'core-store') {
|
|
27
|
+
return restoreCoreStore(strapi, config.value);
|
|
28
|
+
}
|
|
29
|
+
if (config.type === 'webhook') {
|
|
30
|
+
return restoreWebhooks(strapi, config.value);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.restoreConfigs = restoreConfigs;
|
|
34
|
+
const createConfigurationWriteStream = async (strapi, transaction) => {
|
|
35
|
+
return new stream_1.Writable({
|
|
36
|
+
objectMode: true,
|
|
37
|
+
async write(config, _encoding, callback) {
|
|
38
|
+
await transaction?.attach(async () => {
|
|
39
|
+
try {
|
|
40
|
+
await (0, exports.restoreConfigs)(strapi, config);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return callback(new providers_1.ProviderTransferError(`Failed to import ${chalk_1.default.yellowBright(config.type)} (${chalk_1.default.greenBright(config.value.id)}`));
|
|
44
|
+
}
|
|
45
|
+
callback();
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
exports.createConfigurationWriteStream = createConfigurationWriteStream;
|
|
51
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/configuration.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAkC;AAClC,kCAAiC;AACjC,kDAA0B;AAC1B,+DAAwE;AAGxE,MAAM,6BAA6B,GAAG,IAAA,SAAI,EAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAEnD,MAAM,gBAAgB,GAAG,KAAK,EAAgC,MAAqB,EAAE,MAAS,EAAE,EAAE;IAChG,MAAM,IAAI,GAAG,6BAA6B,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC;QAClD,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;SAClC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,KAAK,EAAgC,MAAqB,EAAE,MAAS,EAAE,EAAE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11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
import type { Common } from '@strapi/strapi';
|
|
4
|
+
import type { Transaction } from '../../../../../../types';
|
|
5
|
+
interface IEntitiesRestoreStreamOptions {
|
|
6
|
+
strapi: Strapi.Strapi;
|
|
7
|
+
updateMappingTable<TSchemaUID extends Common.UID.Schema>(type: TSchemaUID, oldID: number, newID: number): void;
|
|
8
|
+
transaction?: Transaction;
|
|
9
|
+
}
|
|
10
|
+
declare const createEntitiesWriteStream: (options: IEntitiesRestoreStreamOptions) => Writable;
|
|
11
|
+
export { createEntitiesWriteStream };
|
|
@@ -0,0 +1,103 @@
|
|
|
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.createEntitiesWriteStream = void 0;
|
|
27
|
+
const stream_1 = require("stream");
|
|
28
|
+
const fp_1 = require("lodash/fp");
|
|
29
|
+
const providers_1 = require("../../../../../errors/providers");
|
|
30
|
+
const utils_1 = require("../../../../../utils");
|
|
31
|
+
const queries = __importStar(require("../../../../queries"));
|
|
32
|
+
const createEntitiesWriteStream = (options) => {
|
|
33
|
+
const { strapi, updateMappingTable, transaction } = options;
|
|
34
|
+
const query = queries.entity.createEntityQuery(strapi);
|
|
35
|
+
return new stream_1.Writable({
|
|
36
|
+
objectMode: true,
|
|
37
|
+
async write(entity, _encoding, callback) {
|
|
38
|
+
await transaction?.attach(async () => {
|
|
39
|
+
const { type, id, data } = entity;
|
|
40
|
+
const { create, getDeepPopulateComponentLikeQuery } = query(type);
|
|
41
|
+
const contentType = strapi.getModel(type);
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the component UID of an entity's attribute based
|
|
44
|
+
* on a given path (components & dynamic zones only)
|
|
45
|
+
*/
|
|
46
|
+
const resolveType = (paths) => {
|
|
47
|
+
let cType = contentType;
|
|
48
|
+
let value = data;
|
|
49
|
+
for (const path of paths) {
|
|
50
|
+
value = (0, fp_1.get)(path, value);
|
|
51
|
+
// Needed when the value of cType should be computed
|
|
52
|
+
// based on the next value (eg: dynamic zones)
|
|
53
|
+
if (typeof cType === 'function') {
|
|
54
|
+
cType = cType(value);
|
|
55
|
+
}
|
|
56
|
+
if (path in cType.attributes) {
|
|
57
|
+
const attribute = cType.attributes[path];
|
|
58
|
+
if (attribute.type === 'component') {
|
|
59
|
+
cType = strapi.getModel(attribute.component);
|
|
60
|
+
}
|
|
61
|
+
if (attribute.type === 'dynamiczone') {
|
|
62
|
+
cType = ({ __component }) => strapi.getModel(__component);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return cType?.uid;
|
|
67
|
+
};
|
|
68
|
+
try {
|
|
69
|
+
const created = await create({
|
|
70
|
+
data,
|
|
71
|
+
populate: getDeepPopulateComponentLikeQuery(contentType, { select: 'id' }),
|
|
72
|
+
select: 'id',
|
|
73
|
+
});
|
|
74
|
+
// Compute differences between original & new entities
|
|
75
|
+
const diffs = utils_1.json.diff(data, created);
|
|
76
|
+
updateMappingTable(type, id, created.id);
|
|
77
|
+
// For each difference found on an ID attribute,
|
|
78
|
+
// update the mapping the table accordingly
|
|
79
|
+
diffs.forEach((diff) => {
|
|
80
|
+
if (diff.kind === 'modified' && (0, fp_1.last)(diff.path) === 'id') {
|
|
81
|
+
const target = resolveType(diff.path);
|
|
82
|
+
// If no type is found for the given path, then ignore the diff
|
|
83
|
+
if (!target) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const [oldID, newID] = diff.values;
|
|
87
|
+
updateMappingTable(target, oldID, newID);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
if (e instanceof Error) {
|
|
93
|
+
return callback(e);
|
|
94
|
+
}
|
|
95
|
+
return callback(new providers_1.ProviderTransferError(`Failed to create "${type}" (${id})`));
|
|
96
|
+
}
|
|
97
|
+
return callback(null);
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
exports.createEntitiesWriteStream = createEntitiesWriteStream;
|
|
103
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../../../../src/strapi/providers/local-destination/strategies/restore/entities.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAGlC,kCAAsC;AAEtC,+DAAwE;AAExE,gDAA4C;AAC5C,6DAA+C;AAY/C,MAAM,yBAAyB,GAAG,CAAC,OAAsC,EAAE,EAAE;IAC3E,MAAM,EAAE,MAAM,EAAE,kBAA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C,CAAC,CAAC;iBAClF;gBAED,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEO,8DAAyB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Schema } from '@strapi/strapi';
|
|
2
|
+
export interface IRestoreOptions {
|
|
3
|
+
assets?: boolean;
|
|
4
|
+
configuration?: {
|
|
5
|
+
webhook?: boolean;
|
|
6
|
+
coreStore?: boolean;
|
|
7
|
+
};
|
|
8
|
+
entities?: {
|
|
9
|
+
include?: string[];
|
|
10
|
+
exclude?: string[];
|
|
11
|
+
filters?: ((contentType: Schema.ContentType) => boolean)[];
|
|
12
|
+
params?: {
|
|
13
|
+
[uid: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface IDeleteResults {
|
|
18
|
+
count: number;
|
|
19
|
+
aggregate: {
|
|
20
|
+
[uid: string]: {
|
|
21
|
+
count: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare const deleteRecords: (strapi: Strapi.Strapi, options?: IRestoreOptions) => Promise<{
|
|
26
|
+
count: number;
|
|
27
|
+
entities: IDeleteResults;
|
|
28
|
+
configuration: IDeleteResults;
|
|
29
|
+
}>;
|
|
30
|
+
export * from './entities';
|
|
31
|
+
export * from './configuration';
|
|
32
|
+
export * from './links';
|