@strapi/data-transfer 5.48.0 → 5.49.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/directory/providers/destination/index.d.ts +1 -1
- package/dist/directory/providers/destination/index.d.ts.map +1 -1
- package/dist/directory/providers/destination/index.js +16 -11
- package/dist/directory/providers/destination/index.js.map +1 -1
- package/dist/directory/providers/destination/index.mjs.map +1 -1
- package/dist/directory/providers/destination/utils.js +6 -2
- package/dist/directory/providers/destination/utils.js.map +1 -1
- package/dist/directory/providers/source/index.d.ts +1 -1
- package/dist/directory/providers/source/index.d.ts.map +1 -1
- package/dist/directory/providers/source/index.js +25 -20
- package/dist/directory/providers/source/index.js.map +1 -1
- package/dist/directory/providers/source/index.mjs.map +1 -1
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/index.mjs.map +1 -1
- package/dist/engine/validation/provider.d.ts +1 -1
- package/dist/engine/validation/provider.d.ts.map +1 -1
- package/dist/engine/validation/provider.js.map +1 -1
- package/dist/engine/validation/provider.mjs.map +1 -1
- package/dist/errors/providers.d.ts +1 -1
- package/dist/errors/providers.d.ts.map +1 -1
- package/dist/errors/providers.js.map +1 -1
- package/dist/errors/providers.mjs.map +1 -1
- package/dist/file/providers/destination/index.d.ts +1 -1
- package/dist/file/providers/destination/index.d.ts.map +1 -1
- package/dist/file/providers/destination/index.js +10 -4
- package/dist/file/providers/destination/index.js.map +1 -1
- package/dist/file/providers/destination/index.mjs.map +1 -1
- package/dist/file/providers/source/index.d.ts +1 -1
- package/dist/file/providers/source/index.d.ts.map +1 -1
- package/dist/file/providers/source/index.js +9 -3
- package/dist/file/providers/source/index.js.map +1 -1
- package/dist/file/providers/source/index.mjs.map +1 -1
- package/dist/file/providers/source/utils.js +10 -6
- package/dist/file/providers/source/utils.js.map +1 -1
- package/dist/strapi/providers/local-destination/assets-destination-writable.d.ts +9 -4
- package/dist/strapi/providers/local-destination/assets-destination-writable.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/assets-destination-writable.js +67 -49
- package/dist/strapi/providers/local-destination/assets-destination-writable.js.map +1 -1
- package/dist/strapi/providers/local-destination/assets-destination-writable.mjs +67 -49
- package/dist/strapi/providers/local-destination/assets-destination-writable.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/index.js +11 -7
- package/dist/strapi/providers/local-destination/index.js.map +1 -1
- package/dist/strapi/providers/local-destination/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +9 -3
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs +4 -2
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js +13 -25
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs +14 -26
- package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.js +0 -4
- package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.mjs +0 -4
- package/dist/strapi/providers/local-destination/strategies/restore/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.js +22 -3
- package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.mjs +22 -3
- package/dist/strapi/providers/local-destination/strategies/restore/links.mjs.map +1 -1
- package/dist/strapi/providers/local-source/assets.d.ts +1 -1
- package/dist/strapi/providers/local-source/assets.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/assets.js.map +1 -1
- package/dist/strapi/providers/local-source/assets.mjs.map +1 -1
- package/dist/strapi/providers/local-source/configuration.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/configuration.js +8 -0
- package/dist/strapi/providers/local-source/configuration.js.map +1 -1
- package/dist/strapi/providers/local-source/configuration.mjs +8 -0
- package/dist/strapi/providers/local-source/configuration.mjs.map +1 -1
- package/dist/strapi/providers/local-source/entities.d.ts +3 -1
- package/dist/strapi/providers/local-source/entities.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/entities.js +7 -3
- package/dist/strapi/providers/local-source/entities.js.map +1 -1
- package/dist/strapi/providers/local-source/entities.mjs +7 -3
- package/dist/strapi/providers/local-source/entities.mjs.map +1 -1
- package/dist/strapi/providers/local-source/estimate-asset-totals.d.ts +1 -1
- package/dist/strapi/providers/local-source/estimate-asset-totals.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/estimate-asset-totals.js.map +1 -1
- package/dist/strapi/providers/local-source/estimate-asset-totals.mjs.map +1 -1
- package/dist/strapi/providers/local-source/index.d.ts +2 -2
- package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/index.js +6 -1
- package/dist/strapi/providers/local-source/index.js.map +1 -1
- package/dist/strapi/providers/local-source/index.mjs +6 -1
- package/dist/strapi/providers/local-source/index.mjs.map +1 -1
- package/dist/strapi/providers/local-source/links.js.map +1 -1
- package/dist/strapi/providers/local-source/links.mjs.map +1 -1
- package/dist/strapi/providers/remote-destination/index.d.ts +2 -2
- package/dist/strapi/providers/remote-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-destination/index.js +24 -3
- package/dist/strapi/providers/remote-destination/index.js.map +1 -1
- package/dist/strapi/providers/remote-destination/index.mjs +25 -4
- package/dist/strapi/providers/remote-destination/index.mjs.map +1 -1
- package/dist/strapi/providers/remote-source/index.d.ts +2 -2
- package/dist/strapi/providers/remote-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-source/index.js.map +1 -1
- package/dist/strapi/providers/remote-source/index.mjs.map +1 -1
- package/dist/strapi/providers/utils.d.ts +2 -2
- package/dist/strapi/providers/utils.d.ts.map +1 -1
- package/dist/strapi/providers/utils.js.map +1 -1
- package/dist/strapi/providers/utils.mjs.map +1 -1
- package/dist/strapi/queries/link.d.ts +1 -1
- package/dist/strapi/queries/link.d.ts.map +1 -1
- package/dist/strapi/queries/link.js.map +1 -1
- package/dist/strapi/queries/link.mjs.map +1 -1
- package/dist/strapi/remote/flows/index.d.ts +1 -1
- package/dist/strapi/remote/flows/index.d.ts.map +1 -1
- package/dist/strapi/remote/flows/index.js.map +1 -1
- package/dist/strapi/remote/flows/index.mjs.map +1 -1
- package/dist/strapi/remote/handlers/pull.d.ts +1 -1
- package/dist/strapi/remote/handlers/pull.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/pull.js +3 -3
- package/dist/strapi/remote/handlers/pull.js.map +1 -1
- package/dist/strapi/remote/handlers/pull.mjs +3 -3
- package/dist/strapi/remote/handlers/pull.mjs.map +1 -1
- package/dist/strapi/remote/handlers/push.d.ts +1 -1
- package/dist/strapi/remote/handlers/push.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/push.js +8 -1
- package/dist/strapi/remote/handlers/push.js.map +1 -1
- package/dist/strapi/remote/handlers/push.mjs +8 -1
- package/dist/strapi/remote/handlers/push.mjs.map +1 -1
- package/dist/strapi/remote/handlers/utils.d.ts +1 -1
- package/dist/strapi/remote/handlers/utils.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/utils.js.map +1 -1
- package/dist/strapi/remote/handlers/utils.mjs.map +1 -1
- package/dist/strapi/utils/project-settings-logos.d.ts +29 -0
- package/dist/strapi/utils/project-settings-logos.d.ts.map +1 -0
- package/dist/strapi/utils/project-settings-logos.js +174 -0
- package/dist/strapi/utils/project-settings-logos.js.map +1 -0
- package/dist/strapi/utils/project-settings-logos.mjs +169 -0
- package/dist/strapi/utils/project-settings-logos.mjs.map +1 -0
- package/dist/types/common-entities.d.ts +152 -0
- package/dist/types/common-entities.d.ts.map +1 -0
- package/dist/types/encryption.d.ts +11 -0
- package/dist/types/encryption.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/providers.d.ts +50 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/remote/index.d.ts +2 -0
- package/dist/types/remote/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/auth.d.ts +5 -0
- package/dist/types/remote/protocol/auth.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/commands.d.ts +37 -0
- package/dist/types/remote/protocol/client/commands.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/index.d.ts +9 -0
- package/dist/types/remote/protocol/client/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/action.d.ts +5 -0
- package/dist/types/remote/protocol/client/transfer/action.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/index.d.ts +12 -0
- package/dist/types/remote/protocol/client/transfer/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/pull.d.ts +25 -0
- package/dist/types/remote/protocol/client/transfer/pull.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/push.d.ts +29 -0
- package/dist/types/remote/protocol/client/transfer/push.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/utils.d.ts +49 -0
- package/dist/types/remote/protocol/client/transfer/utils.d.ts.map +1 -0
- package/dist/types/remote/protocol/index.d.ts +4 -0
- package/dist/types/remote/protocol/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/error.d.ts +18 -0
- package/dist/types/remote/protocol/server/error.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/index.d.ts +3 -0
- package/dist/types/remote/protocol/server/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/messaging.d.ts +37 -0
- package/dist/types/remote/protocol/server/messaging.d.ts.map +1 -0
- package/dist/types/transfer-engine.d.ts +149 -0
- package/dist/types/transfer-engine.d.ts.map +1 -0
- package/dist/types/utils.d.ts +83 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/utils/components.d.ts +21 -1
- package/dist/utils/components.d.ts.map +1 -1
- package/dist/utils/components.js +76 -24
- package/dist/utils/components.js.map +1 -1
- package/dist/utils/components.mjs +70 -22
- package/dist/utils/components.mjs.map +1 -1
- package/dist/utils/encryption/decrypt.d.ts +1 -1
- package/dist/utils/encryption/decrypt.d.ts.map +1 -1
- package/dist/utils/encryption/decrypt.js.map +1 -1
- package/dist/utils/encryption/decrypt.mjs.map +1 -1
- package/dist/utils/encryption/encrypt.d.ts +1 -1
- package/dist/utils/encryption/encrypt.d.ts.map +1 -1
- package/dist/utils/encryption/encrypt.js.map +1 -1
- package/dist/utils/encryption/encrypt.mjs.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/middleware.d.ts +1 -1
- package/dist/utils/middleware.d.ts.map +1 -1
- package/dist/utils/middleware.js.map +1 -1
- package/dist/utils/middleware.mjs.map +1 -1
- package/dist/utils/transaction.d.ts +1 -1
- package/dist/utils/transaction.d.ts.map +1 -1
- package/dist/utils/transaction.js.map +1 -1
- package/dist/utils/transaction.mjs.map +1 -1
- package/dist/utils/transfer-asset-chunk.d.ts +22 -0
- package/dist/utils/transfer-asset-chunk.d.ts.map +1 -1
- package/dist/utils/transfer-asset-chunk.js +25 -0
- package/dist/utils/transfer-asset-chunk.js.map +1 -1
- package/dist/utils/transfer-asset-chunk.mjs +25 -1
- package/dist/utils/transfer-asset-chunk.mjs.map +1 -1
- package/package.json +11 -9
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import { pick } from 'lodash/fp';
|
|
4
|
+
import { readFile } from 'fs-extra';
|
|
5
|
+
import { lookup } from 'mime-types';
|
|
6
|
+
|
|
7
|
+
const PROJECT_SETTINGS_CORE_STORE_KEY = 'core_admin_project-settings';
|
|
8
|
+
// The shape persisted back to core-store, matching what the admin project-settings
|
|
9
|
+
// service stores (so the admin UI keeps behaving identically after a transfer).
|
|
10
|
+
const LOGO_PERSISTED_FIELDS = [
|
|
11
|
+
'name',
|
|
12
|
+
'hash',
|
|
13
|
+
'url',
|
|
14
|
+
'width',
|
|
15
|
+
'height',
|
|
16
|
+
'ext',
|
|
17
|
+
'size',
|
|
18
|
+
'provider'
|
|
19
|
+
];
|
|
20
|
+
const isProjectSettingsRow = (row)=>row.key === PROJECT_SETTINGS_CORE_STORE_KEY;
|
|
21
|
+
const getConfiguredUploadProvider = (strapi)=>strapi.config.get('plugin::upload')?.provider;
|
|
22
|
+
// Admin logos with no provider were uploaded with the local provider (the default).
|
|
23
|
+
const isLocalProviderLogo = (logo)=>!logo.provider || logo.provider === 'local';
|
|
24
|
+
// Best-effort mime type for a logo so that remote providers (S3, Cloudinary, …)
|
|
25
|
+
// store the correct Content-Type and the image renders instead of downloading.
|
|
26
|
+
// The admin does not persist the mime type, so it is reconstructed from the
|
|
27
|
+
// file extension (falling back to the file name).
|
|
28
|
+
const getLogoMimeType = (logo)=>{
|
|
29
|
+
const fromExt = logo.ext ? lookup(logo.ext) : false;
|
|
30
|
+
if (fromExt) {
|
|
31
|
+
return fromExt;
|
|
32
|
+
}
|
|
33
|
+
const fromName = logo.name ? lookup(logo.name) : false;
|
|
34
|
+
if (fromName) {
|
|
35
|
+
return fromName;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Resolve the URL to read a non-local logo from during export.
|
|
41
|
+
*
|
|
42
|
+
* Mirrors the media-library asset export: when the file lives on the
|
|
43
|
+
* currently-configured provider and that provider serves private files,
|
|
44
|
+
* a signed URL is generated so the bytes can be fetched.
|
|
45
|
+
*/ const getRemoteLogoUrl = async (strapi, logo)=>{
|
|
46
|
+
const { provider } = strapi.plugins.upload;
|
|
47
|
+
const providerName = getConfiguredUploadProvider(strapi);
|
|
48
|
+
if (logo.provider === providerName && typeof provider?.isPrivate === 'function' && typeof provider?.getSignedUrl === 'function' && await provider.isPrivate()) {
|
|
49
|
+
const { url } = await provider.getSignedUrl(logo);
|
|
50
|
+
return url;
|
|
51
|
+
}
|
|
52
|
+
return logo.url;
|
|
53
|
+
};
|
|
54
|
+
const logoLabel = (logo)=>logo.name ?? logo.hash ?? 'unknown';
|
|
55
|
+
const readLocalLogoBuffer = async (strapi, logo)=>{
|
|
56
|
+
const filepath = join(strapi.dirs.static.public, logo.url);
|
|
57
|
+
try {
|
|
58
|
+
const buffer = await readFile(filepath);
|
|
59
|
+
return buffer.toString('base64');
|
|
60
|
+
} catch (error) {
|
|
61
|
+
const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
|
|
62
|
+
if (code === 'ENOENT') {
|
|
63
|
+
strapi.log.warn(`[Data transfer] Admin logo "${logoLabel(logo)}" exists in project settings but no corresponding file was found to transfer. Path: ${filepath}`);
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const readRemoteLogoBuffer = async (strapi, logo)=>{
|
|
70
|
+
const url = await getRemoteLogoUrl(strapi, logo);
|
|
71
|
+
const response = await strapi.fetch(url);
|
|
72
|
+
if (response.status !== 200 || !response.body) {
|
|
73
|
+
strapi.log.warn(`[Data transfer] Admin logo "${logoLabel(logo)}" exists in project settings but could not be fetched for transfer. URL: ${url} (status: ${response.status})`);
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const chunks = [];
|
|
77
|
+
for await (const chunk of Readable.fromWeb(response.body)){
|
|
78
|
+
chunks.push(chunk);
|
|
79
|
+
}
|
|
80
|
+
return Buffer.concat(chunks).toString('base64');
|
|
81
|
+
};
|
|
82
|
+
const readLogoTransferBuffer = async (strapi, logo)=>{
|
|
83
|
+
if (!logo.url) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
if (isLocalProviderLogo(logo)) {
|
|
87
|
+
return readLocalLogoBuffer(strapi, logo);
|
|
88
|
+
}
|
|
89
|
+
return readRemoteLogoBuffer(strapi, logo);
|
|
90
|
+
};
|
|
91
|
+
const enrichLogoForExport = async (strapi, logo)=>{
|
|
92
|
+
if (!logo?.url) {
|
|
93
|
+
return logo;
|
|
94
|
+
}
|
|
95
|
+
const transferBuffer = await readLogoTransferBuffer(strapi, logo);
|
|
96
|
+
if (!transferBuffer) {
|
|
97
|
+
return logo;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
...logo,
|
|
101
|
+
__transferBuffer: transferBuffer
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
const enrichProjectSettingsForExport = async (strapi, row)=>{
|
|
105
|
+
if (!isProjectSettingsRow(row)) {
|
|
106
|
+
return row;
|
|
107
|
+
}
|
|
108
|
+
const settings = row.value;
|
|
109
|
+
const [menuLogo, authLogo] = await Promise.all([
|
|
110
|
+
enrichLogoForExport(strapi, settings.menuLogo),
|
|
111
|
+
enrichLogoForExport(strapi, settings.authLogo)
|
|
112
|
+
]);
|
|
113
|
+
return {
|
|
114
|
+
...row,
|
|
115
|
+
value: {
|
|
116
|
+
...settings,
|
|
117
|
+
menuLogo,
|
|
118
|
+
authLogo
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Re-upload a transferred logo to the destination's configured upload provider.
|
|
124
|
+
*
|
|
125
|
+
* The file is always re-uploaded through the destination provider, so the
|
|
126
|
+
* persisted `url` and `provider` reflect the destination (matching how the
|
|
127
|
+
* media-library asset restore behaves). A best-effort mime type is supplied so
|
|
128
|
+
* remote providers serve the logo with the correct Content-Type.
|
|
129
|
+
*/ const uploadLogoFromTransferBuffer = async (strapi, logo)=>{
|
|
130
|
+
if (!logo.__transferBuffer) {
|
|
131
|
+
return logo;
|
|
132
|
+
}
|
|
133
|
+
const { __transferBuffer, ...logoWithoutBuffer } = logo;
|
|
134
|
+
const provider = getConfiguredUploadProvider(strapi);
|
|
135
|
+
const mime = getLogoMimeType(logoWithoutBuffer);
|
|
136
|
+
const file = {
|
|
137
|
+
...logoWithoutBuffer,
|
|
138
|
+
...mime ? {
|
|
139
|
+
mime
|
|
140
|
+
} : {},
|
|
141
|
+
stream: Readable.from(Buffer.from(__transferBuffer, 'base64')),
|
|
142
|
+
provider
|
|
143
|
+
};
|
|
144
|
+
await strapi.plugin('upload').provider.uploadStream(file);
|
|
145
|
+
return pick(LOGO_PERSISTED_FIELDS, file);
|
|
146
|
+
};
|
|
147
|
+
const restoreProjectSettingsLogos = async (strapi, settings)=>{
|
|
148
|
+
const [menuLogo, authLogo] = await Promise.all([
|
|
149
|
+
settings.menuLogo ? uploadLogoFromTransferBuffer(strapi, settings.menuLogo) : settings.menuLogo,
|
|
150
|
+
settings.authLogo ? uploadLogoFromTransferBuffer(strapi, settings.authLogo) : settings.authLogo
|
|
151
|
+
]);
|
|
152
|
+
return {
|
|
153
|
+
...settings,
|
|
154
|
+
menuLogo,
|
|
155
|
+
authLogo
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
const restoreProjectSettingsRow = async (strapi, row)=>{
|
|
159
|
+
if (!isProjectSettingsRow(row)) {
|
|
160
|
+
return row;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
...row,
|
|
164
|
+
value: await restoreProjectSettingsLogos(strapi, row.value)
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export { PROJECT_SETTINGS_CORE_STORE_KEY, enrichProjectSettingsForExport, restoreProjectSettingsLogos, restoreProjectSettingsRow };
|
|
169
|
+
//# sourceMappingURL=project-settings-logos.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-settings-logos.mjs","sources":["../../../src/strapi/utils/project-settings-logos.ts"],"sourcesContent":["import { join } from 'path';\nimport { Readable } from 'stream';\nimport { pick } from 'lodash/fp';\nimport { readFile } from 'fs-extra';\nimport { lookup as lookupMimeType } from 'mime-types';\nimport * as webStream from 'stream/web';\nimport type { Core } from '@strapi/types';\n\nexport const PROJECT_SETTINGS_CORE_STORE_KEY = 'core_admin_project-settings';\n\nexport const PROJECT_SETTINGS_LOGO_FIELDS = ['menuLogo', 'authLogo'] as const;\n\nexport type ProjectSettingsLogoField = (typeof PROJECT_SETTINGS_LOGO_FIELDS)[number];\n\nexport type ProjectSettingsLogo = {\n name?: string;\n hash?: string;\n url?: string;\n width?: number;\n height?: number;\n ext?: string;\n size?: number;\n mime?: string;\n provider?: string;\n __transferBuffer?: string;\n};\n\nexport type ProjectSettingsStoreValue = {\n menuLogo?: ProjectSettingsLogo | null;\n authLogo?: ProjectSettingsLogo | null;\n};\n\nexport type CoreStoreRow = {\n key: string;\n value: unknown;\n [key: string]: unknown;\n};\n\n// The shape persisted back to core-store, matching what the admin project-settings\n// service stores (so the admin UI keeps behaving identically after a transfer).\nconst LOGO_PERSISTED_FIELDS = [\n 'name',\n 'hash',\n 'url',\n 'width',\n 'height',\n 'ext',\n 'size',\n 'provider',\n] as const;\n\nconst isProjectSettingsRow = (row: CoreStoreRow) => row.key === PROJECT_SETTINGS_CORE_STORE_KEY;\n\nconst getConfiguredUploadProvider = (strapi: Core.Strapi) =>\n (strapi.config.get('plugin::upload') as { provider?: string } | undefined)?.provider;\n\n// Admin logos with no provider were uploaded with the local provider (the default).\nconst isLocalProviderLogo = (logo: ProjectSettingsLogo) =>\n !logo.provider || logo.provider === 'local';\n\n// Best-effort mime type for a logo so that remote providers (S3, Cloudinary, …)\n// store the correct Content-Type and the image renders instead of downloading.\n// The admin does not persist the mime type, so it is reconstructed from the\n// file extension (falling back to the file name).\nconst getLogoMimeType = (logo: ProjectSettingsLogo): string | undefined => {\n const fromExt = logo.ext ? lookupMimeType(logo.ext) : false;\n if (fromExt) {\n return fromExt;\n }\n\n const fromName = logo.name ? lookupMimeType(logo.name) : false;\n if (fromName) {\n return fromName;\n }\n\n return undefined;\n};\n\n/**\n * Resolve the URL to read a non-local logo from during export.\n *\n * Mirrors the media-library asset export: when the file lives on the\n * currently-configured provider and that provider serves private files,\n * a signed URL is generated so the bytes can be fetched.\n */\nconst getRemoteLogoUrl = async (strapi: Core.Strapi, logo: ProjectSettingsLogo) => {\n const { provider } = strapi.plugins.upload;\n const providerName = getConfiguredUploadProvider(strapi);\n\n if (\n logo.provider === providerName &&\n typeof provider?.isPrivate === 'function' &&\n typeof provider?.getSignedUrl === 'function' &&\n (await provider.isPrivate())\n ) {\n const { url } = await provider.getSignedUrl(logo);\n return url;\n }\n\n return logo.url;\n};\n\nconst logoLabel = (logo: ProjectSettingsLogo) => logo.name ?? logo.hash ?? 'unknown';\n\nconst readLocalLogoBuffer = async (strapi: Core.Strapi, logo: ProjectSettingsLogo) => {\n const filepath = join(strapi.dirs.static.public, logo.url as string);\n\n try {\n const buffer = await readFile(filepath);\n return buffer.toString('base64');\n } catch (error) {\n const code =\n error && typeof error === 'object' && 'code' in error\n ? (error as NodeJS.ErrnoException).code\n : undefined;\n\n if (code === 'ENOENT') {\n strapi.log.warn(\n `[Data transfer] Admin logo \"${logoLabel(logo)}\" exists in project settings but no corresponding file was found to transfer. Path: ${filepath}`\n );\n return undefined;\n }\n\n throw error;\n }\n};\n\nconst readRemoteLogoBuffer = async (strapi: Core.Strapi, logo: ProjectSettingsLogo) => {\n const url = await getRemoteLogoUrl(strapi, logo);\n const response = await strapi.fetch(url);\n\n if (response.status !== 200 || !response.body) {\n strapi.log.warn(\n `[Data transfer] Admin logo \"${logoLabel(logo)}\" exists in project settings but could not be fetched for transfer. URL: ${url} (status: ${response.status})`\n );\n return undefined;\n }\n\n const chunks: Uint8Array[] = [];\n\n for await (const chunk of Readable.fromWeb(\n response.body as webStream.ReadableStream<Uint8Array>\n )) {\n chunks.push(chunk);\n }\n\n return Buffer.concat(chunks).toString('base64');\n};\n\nconst readLogoTransferBuffer = async (strapi: Core.Strapi, logo: ProjectSettingsLogo) => {\n if (!logo.url) {\n return undefined;\n }\n\n if (isLocalProviderLogo(logo)) {\n return readLocalLogoBuffer(strapi, logo);\n }\n\n return readRemoteLogoBuffer(strapi, logo);\n};\n\nconst enrichLogoForExport = async (\n strapi: Core.Strapi,\n logo: ProjectSettingsLogo | null | undefined\n) => {\n if (!logo?.url) {\n return logo;\n }\n\n const transferBuffer = await readLogoTransferBuffer(strapi, logo);\n\n if (!transferBuffer) {\n return logo;\n }\n\n return {\n ...logo,\n __transferBuffer: transferBuffer,\n };\n};\n\nexport const enrichProjectSettingsForExport = async (\n strapi: Core.Strapi,\n row: CoreStoreRow\n): Promise<CoreStoreRow> => {\n if (!isProjectSettingsRow(row)) {\n return row;\n }\n\n const settings = row.value as ProjectSettingsStoreValue;\n\n const [menuLogo, authLogo] = await Promise.all([\n enrichLogoForExport(strapi, settings.menuLogo),\n enrichLogoForExport(strapi, settings.authLogo),\n ]);\n\n return {\n ...row,\n value: {\n ...settings,\n menuLogo,\n authLogo,\n },\n };\n};\n\n/**\n * Re-upload a transferred logo to the destination's configured upload provider.\n *\n * The file is always re-uploaded through the destination provider, so the\n * persisted `url` and `provider` reflect the destination (matching how the\n * media-library asset restore behaves). A best-effort mime type is supplied so\n * remote providers serve the logo with the correct Content-Type.\n */\nconst uploadLogoFromTransferBuffer = async (strapi: Core.Strapi, logo: ProjectSettingsLogo) => {\n if (!logo.__transferBuffer) {\n return logo;\n }\n\n const { __transferBuffer, ...logoWithoutBuffer } = logo;\n const provider = getConfiguredUploadProvider(strapi);\n const mime = getLogoMimeType(logoWithoutBuffer);\n\n const file = {\n ...logoWithoutBuffer,\n ...(mime ? { mime } : {}),\n stream: Readable.from(Buffer.from(__transferBuffer, 'base64')),\n provider,\n };\n\n await strapi.plugin('upload').provider.uploadStream(file);\n\n return pick(LOGO_PERSISTED_FIELDS, file);\n};\n\nexport const restoreProjectSettingsLogos = async (\n strapi: Core.Strapi,\n settings: ProjectSettingsStoreValue\n): Promise<ProjectSettingsStoreValue> => {\n const [menuLogo, authLogo] = await Promise.all([\n settings.menuLogo ? uploadLogoFromTransferBuffer(strapi, settings.menuLogo) : settings.menuLogo,\n settings.authLogo ? uploadLogoFromTransferBuffer(strapi, settings.authLogo) : settings.authLogo,\n ]);\n\n return {\n ...settings,\n menuLogo,\n authLogo,\n };\n};\n\nexport const restoreProjectSettingsRow = async (strapi: Core.Strapi, row: CoreStoreRow) => {\n if (!isProjectSettingsRow(row)) {\n return row;\n }\n\n return {\n ...row,\n value: await restoreProjectSettingsLogos(strapi, row.value as ProjectSettingsStoreValue),\n };\n};\n"],"names":["PROJECT_SETTINGS_CORE_STORE_KEY","LOGO_PERSISTED_FIELDS","isProjectSettingsRow","row","key","getConfiguredUploadProvider","strapi","config","get","provider","isLocalProviderLogo","logo","getLogoMimeType","fromExt","ext","lookupMimeType","fromName","name","undefined","getRemoteLogoUrl","plugins","upload","providerName","isPrivate","getSignedUrl","url","logoLabel","hash","readLocalLogoBuffer","filepath","join","dirs","static","public","buffer","readFile","toString","error","code","log","warn","readRemoteLogoBuffer","response","fetch","status","body","chunks","chunk","Readable","fromWeb","push","Buffer","concat","readLogoTransferBuffer","enrichLogoForExport","transferBuffer","__transferBuffer","enrichProjectSettingsForExport","settings","value","menuLogo","authLogo","Promise","all","uploadLogoFromTransferBuffer","logoWithoutBuffer","mime","file","stream","from","plugin","uploadStream","pick","restoreProjectSettingsLogos","restoreProjectSettingsRow"],"mappings":";;;;;;AAQO,MAAMA,kCAAkC;AA8B/C;AACA;AACA,MAAMC,qBAAAA,GAAwB;AAC5B,IAAA,MAAA;AACA,IAA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qB,IAAI,CAAClB,MAAAA,CAAOkB,IAAI,CAACb,gBAAAA,EAAkB,QAAA,CAAA,CAAA;AACpD/C,QAAAA;AACF,KAAA;AAEA,IAAA,MAAMH,OAAOgE,MAAM,CAAC,UAAU7D,QAAQ,CAAC8D,YAAY,CAACJ,IAAAA,CAAAA;AAEpD,IAAA,OAAOK,KAAKvE,qBAAAA,EAAuBkE,IAAAA,CAAAA;AACrC,CAAA;AAEO,MAAMM,2BAAAA,GAA8B,OACzCnE,MAAAA,EACAoD,QAAAA,GAAAA;AAEA,IAAA,MAAM,CAACE,QAAAA,EAAUC,QAAAA,CAAS,GAAG,MAAMC,OAAAA,CAAQC,GAAG,CAAC;QAC7CL,QAAAA,CAASE,QAAQ,GAAGI,4BAAAA,CAA6B1D,MAAAA,EAAQoD,SAASE,QAAQ,CAAA,GAAIF,SAASE,QAAQ;QAC/FF,QAAAA,CAASG,QAAQ,GAAGG,4BAAAA,CAA6B1D,MAAAA,EAAQoD,SAASG,QAAQ,CAAA,GAAIH,SAASG;AACxF,KAAA,CAAA;IAED,OAAO;AACL,QAAA,GAAGH,QAAQ;AACXE,QAAAA,QAAAA;AACAC,QAAAA;AACF,KAAA;AACF;AAEO,MAAMa,yBAAAA,GAA4B,OAAOpE,MAAAA,EAAqBH,GAAAA,GAAAA;IACnE,IAAI,CAACD,qBAAqBC,GAAAA,CAAAA,EAAM;QAC9B,OAAOA,GAAAA;AACT,IAAA;IAEA,OAAO;AACL,QAAA,GAAGA,GAAG;AACNwD,QAAAA,KAAAA,EAAO,MAAMc,2BAAAA,CAA4BnE,MAAAA,EAAQH,GAAAA,CAAIwD,KAAK;AAC5D,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import type { Readable } from 'stream';
|
|
5
|
+
import type { Schema, Data, UID } from '@strapi/types';
|
|
6
|
+
export interface IMetadata {
|
|
7
|
+
strapi?: {
|
|
8
|
+
version?: string;
|
|
9
|
+
};
|
|
10
|
+
createdAt?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Common TransferEngine format to represent a Strapi entity
|
|
14
|
+
* @template T The schema UID this entity represents
|
|
15
|
+
*/
|
|
16
|
+
export interface IEntity<T extends UID.ContentType = UID.ContentType> {
|
|
17
|
+
/**
|
|
18
|
+
* UID of the parent type (content-type, component, etc...)
|
|
19
|
+
*/
|
|
20
|
+
type: T;
|
|
21
|
+
/**
|
|
22
|
+
* Reference of the entity.
|
|
23
|
+
* Might be deprecated and replaced by a "ref" or "reference" property in the future
|
|
24
|
+
*/
|
|
25
|
+
id: number;
|
|
26
|
+
/**
|
|
27
|
+
* The entity data (attributes value)
|
|
28
|
+
*/
|
|
29
|
+
data: Data.Entity<T>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Union type that regroups all the different kinds of link
|
|
33
|
+
*/
|
|
34
|
+
export type ILink = IBasicLink | IMorphLink | ICircularLink;
|
|
35
|
+
/**
|
|
36
|
+
* Default generic link structure
|
|
37
|
+
*/
|
|
38
|
+
interface IDefaultLink {
|
|
39
|
+
/**
|
|
40
|
+
* The link type
|
|
41
|
+
* (useful for providers (destination) to adapt the logic following what kind of link is processed)
|
|
42
|
+
*/
|
|
43
|
+
kind: string;
|
|
44
|
+
/**
|
|
45
|
+
* The relation type
|
|
46
|
+
*/
|
|
47
|
+
relation: Schema.Attribute.RelationKind.Any;
|
|
48
|
+
/**
|
|
49
|
+
* Left side of the link
|
|
50
|
+
* It should hold information about the entity that owns the dominant side of the link
|
|
51
|
+
*/
|
|
52
|
+
left: {
|
|
53
|
+
/**
|
|
54
|
+
* Entity UID
|
|
55
|
+
* (restricted to content type)
|
|
56
|
+
*/
|
|
57
|
+
type: string;
|
|
58
|
+
/**
|
|
59
|
+
* Reference ID of the entity
|
|
60
|
+
*/
|
|
61
|
+
ref: number;
|
|
62
|
+
/**
|
|
63
|
+
* Field used to hold the link in the entity
|
|
64
|
+
*/
|
|
65
|
+
field: string;
|
|
66
|
+
/**
|
|
67
|
+
* If the link is part of a collection, keep its position here
|
|
68
|
+
*/
|
|
69
|
+
pos?: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Right side of the link
|
|
73
|
+
* It should hold information about the entity attached to the left side of the link
|
|
74
|
+
*/
|
|
75
|
+
right: {
|
|
76
|
+
/**
|
|
77
|
+
* Entity UID
|
|
78
|
+
* (can be a content type or a component)
|
|
79
|
+
*/
|
|
80
|
+
type: string;
|
|
81
|
+
/**
|
|
82
|
+
* Reference ID of the entity
|
|
83
|
+
*/
|
|
84
|
+
ref: number;
|
|
85
|
+
/**
|
|
86
|
+
* Field used to hold the link in the entity
|
|
87
|
+
*/
|
|
88
|
+
field?: string;
|
|
89
|
+
/**
|
|
90
|
+
* If the link is part of a collection, keep its position here
|
|
91
|
+
*/
|
|
92
|
+
pos?: number;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Basic link between two content type entities
|
|
97
|
+
*/
|
|
98
|
+
interface IBasicLink extends IDefaultLink {
|
|
99
|
+
kind: 'relation.basic';
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Polymorphic link (one source content type to multiple different content types)
|
|
103
|
+
*/
|
|
104
|
+
interface IMorphLink extends IDefaultLink {
|
|
105
|
+
kind: 'relation.morph';
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Regular link with the left and right sides having the save content-type
|
|
109
|
+
*/
|
|
110
|
+
interface ICircularLink extends IDefaultLink {
|
|
111
|
+
kind: 'relation.circular';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Strapi configurations
|
|
115
|
+
*/
|
|
116
|
+
export interface IConfiguration<T = unknown> {
|
|
117
|
+
type: 'core-store' | 'webhook';
|
|
118
|
+
value: T;
|
|
119
|
+
}
|
|
120
|
+
export interface IFile {
|
|
121
|
+
id: number;
|
|
122
|
+
name: string;
|
|
123
|
+
alternativeText?: string;
|
|
124
|
+
caption?: string;
|
|
125
|
+
width?: number;
|
|
126
|
+
height?: number;
|
|
127
|
+
formats?: Record<string, IFile>;
|
|
128
|
+
hash: string;
|
|
129
|
+
ext?: string;
|
|
130
|
+
mime: string;
|
|
131
|
+
size: number;
|
|
132
|
+
url: string;
|
|
133
|
+
previewUrl?: string;
|
|
134
|
+
path?: string;
|
|
135
|
+
provider?: string;
|
|
136
|
+
provider_metadata?: Record<string, unknown>;
|
|
137
|
+
type?: string;
|
|
138
|
+
mainHash?: string;
|
|
139
|
+
}
|
|
140
|
+
export interface IAsset {
|
|
141
|
+
filename: string;
|
|
142
|
+
filepath: string;
|
|
143
|
+
stream: Readable;
|
|
144
|
+
stats: IAssetStats;
|
|
145
|
+
metadata: IFile;
|
|
146
|
+
buffer?: Buffer;
|
|
147
|
+
}
|
|
148
|
+
export interface IAssetStats {
|
|
149
|
+
size: number;
|
|
150
|
+
}
|
|
151
|
+
export {};
|
|
152
|
+
//# sourceMappingURL=common-entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-entities.d.ts","sourceRoot":"","sources":["../../src/types/common-entities.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IAEF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW;IAClE;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;;OAGG;IACH,EAAE,EAAE,M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Ae,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Cipheriv, Decipheriv } from 'crypto';
|
|
3
|
+
export type EncryptionStrategy = (key: string) => Cipheriv | Decipheriv;
|
|
4
|
+
export type Strategies = {
|
|
5
|
+
'aes-128-ecb': (key: string) => Cipheriv | Decipheriv;
|
|
6
|
+
aes128: (key: string) => Cipheriv | Decipheriv;
|
|
7
|
+
aes192: (key: string) => Cipheriv | Decipheriv;
|
|
8
|
+
aes256: (key: string) => Cipheriv | Decipheriv;
|
|
9
|
+
};
|
|
10
|
+
export type Algorithm = 'aes-128-ecb' | 'aes128' | 'aes192' | 'aes256';
|
|
11
|
+
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/types/encryption.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,QAAQ,GAAG,UAAU,CAAC;AAExE,MAAM,MAAM,UAAU,GAAG;IACvB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,QAAQ,GAAG,UAAU,CAAC;IACtD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,QAAQ,GAAG,UAAU,CAAC;IAC/C,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,QAAQ,GAAG,UAAU,CAAC;IAC/C,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,QAAQ,GAAG,UAAU,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Readable, Writable } from 'stream';
|
|
3
|
+
import type { Struct } from '@strapi/types';
|
|
4
|
+
import type { IDestinationProviderTransferResults, IProviderTransferResults, ISourceProviderTransferResults, MaybePromise, StageTotalsEstimate, TransferStage } from './utils';
|
|
5
|
+
import type { IMetadata } from './common-entities';
|
|
6
|
+
import type { IDiagnosticReporter } from '../utils/diagnostic';
|
|
7
|
+
export type ProviderType = 'source' | 'destination';
|
|
8
|
+
export interface IProvider {
|
|
9
|
+
type: ProviderType;
|
|
10
|
+
name: string;
|
|
11
|
+
results?: IProviderTransferResults;
|
|
12
|
+
/**
|
|
13
|
+
* bootstrap() is called during transfer engine bootstrap
|
|
14
|
+
* It is used for initialization operations such as making a database connection, opening a file, checking authorization, etc
|
|
15
|
+
*/
|
|
16
|
+
bootstrap?(diagnostics?: IDiagnosticReporter): MaybePromise<void>;
|
|
17
|
+
close?(): MaybePromise<void>;
|
|
18
|
+
getMetadata(): MaybePromise<IMetadata | null>;
|
|
19
|
+
getSchemas?(): MaybePromise<Record<string, Struct.Schema> | null>;
|
|
20
|
+
beforeTransfer?(): MaybePromise<void>;
|
|
21
|
+
}
|
|
22
|
+
export interface ISourceProvider extends IProvider {
|
|
23
|
+
results?: ISourceProviderTransferResults;
|
|
24
|
+
/**
|
|
25
|
+
* Optional totals for a stage. Called by the engine after the stage read stream is created and before `stage::start`.
|
|
26
|
+
* Used for CLI progress (e.g. bytes/count remaining, ETA). Omit or return null when unknown (older remotes, file providers).
|
|
27
|
+
*/
|
|
28
|
+
getStageTotals?(stage: TransferStage): MaybePromise<StageTotalsEstimate | null | undefined>;
|
|
29
|
+
createEntitiesReadStream?(): MaybePromise<Readable>;
|
|
30
|
+
createLinksReadStream?(): MaybePromise<Readable>;
|
|
31
|
+
createAssetsReadStream?(): MaybePromise<Readable>;
|
|
32
|
+
createConfigurationReadStream?(): MaybePromise<Readable>;
|
|
33
|
+
createSchemasReadStream?(): MaybePromise<Readable>;
|
|
34
|
+
}
|
|
35
|
+
export interface IDestinationProvider extends IProvider {
|
|
36
|
+
results?: IDestinationProviderTransferResults;
|
|
37
|
+
/**
|
|
38
|
+
* Optional rollback implementation
|
|
39
|
+
* Called when an error is thrown during a transfer to allow rollback operations to be performed
|
|
40
|
+
*/
|
|
41
|
+
rollback?<T extends Error = Error>(e: T): MaybePromise<void>;
|
|
42
|
+
setMetadata?(target: ProviderType, metadata: IMetadata): IDestinationProvider;
|
|
43
|
+
onWarning?: (message: string) => void;
|
|
44
|
+
createEntitiesWriteStream?(): MaybePromise<Writable>;
|
|
45
|
+
createLinksWriteStream?(): MaybePromise<Writable>;
|
|
46
|
+
createAssetsWriteStream?(): MaybePromise<Writable>;
|
|
47
|
+
createConfigurationWriteStream?(): MaybePromise<Writable>;
|
|
48
|
+
createSchemasWriteStream?(): MaybePromise<Writable>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/types/providers.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EACV,mCAAmC,EACnC,wBAAwB,EACxB,8BAA8B,EAC9B,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACd,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEpD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,wBAAwB,CAAC;IAEnC;;;OAGG;IACH,SAAS,CAAC,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClE,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI,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C,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;IACnD,8BAA8B,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC1D,wBAAwB,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/remote/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/types/remote/protocol/auth.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ILocalStrapiDestinationProviderOptions } from '../../../../strapi/providers';
|
|
2
|
+
import type { TransferMethod } from '../../../../strapi/remote/constants';
|
|
3
|
+
export type CommandMessage = {
|
|
4
|
+
type: 'command';
|
|
5
|
+
} & (InitCommand | EndCommand | StatusCommand);
|
|
6
|
+
export type Command = CommandMessage['command'];
|
|
7
|
+
export type GetCommandParams<T extends Command> = {
|
|
8
|
+
[key in Command]: {
|
|
9
|
+
command: key;
|
|
10
|
+
} & CommandMessage;
|
|
11
|
+
}[T] extends {
|
|
12
|
+
params: infer U;
|
|
13
|
+
} ? U : never;
|
|
14
|
+
export type InitCommand = CreateCommand<'init', {
|
|
15
|
+
options?: Pick<ILocalStrapiDestinationProviderOptions, 'strategy' | 'restore'>;
|
|
16
|
+
transfer: TransferMethod;
|
|
17
|
+
checksums?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Opt-in request for the compact base64 asset-chunk wire format. Remotes that understand it
|
|
20
|
+
* echo it back in {@link InitMessage}; older remotes ignore it and the client falls back to
|
|
21
|
+
* the legacy `{ type: 'Buffer', data: number[] }` shape they can still decode.
|
|
22
|
+
*/
|
|
23
|
+
assetEncoding?: 'base64';
|
|
24
|
+
}>;
|
|
25
|
+
export type TransferKind = InitCommand['params']['transfer'];
|
|
26
|
+
export type EndCommand = CreateCommand<'end', {
|
|
27
|
+
transferID: string;
|
|
28
|
+
}>;
|
|
29
|
+
export type StatusCommand = CreateCommand<'status'>;
|
|
30
|
+
type CreateCommand<T extends string, U extends Record<string, unknown> = never> = {
|
|
31
|
+
type: 'command';
|
|
32
|
+
command: T;
|
|
33
|
+
} & ([U] extends [never] ? unknown : {
|
|
34
|
+
params: U;
|
|
35
|
+
});
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../src/types/remote/protocol/client/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG,CAAC,WAAW,GAAG,UAAU,GAAG,aAAa,CAAC,CAAC;AAE9F,MAAM,MAAM,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAEhD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,IAAI;KAC/C,GAAG,IAAI,OAAO,GAAG;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,GAAG,cAAc;CACpD,CAAC,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC5B,CAAC,GACD,KAAK,CAAC;AAEV,MAAM,MAAM,WAAW,GAAG,aAAa,CACrC,MAAM,EACN;IACE,OAAO,CAAC,EAAE,IAAI,CAAC,sCAAsC,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;IAC/E,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;CAC1B,CACF,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC;AAE7D,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEtE,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;AAEpD,KAAK,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,IAAI;IAChF,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,CAAC,CAAC;CACZ,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG;IAAE,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandMessage } from './commands';
|
|
2
|
+
import type { TransferMessage } from './transfer';
|
|
3
|
+
export * from './commands';
|
|
4
|
+
export * from './transfer';
|
|
5
|
+
export type Message = {
|
|
6
|
+
uuid: string;
|
|
7
|
+
} & (CommandMessage | TransferMessage);
|
|
8
|
+
export type MessageType = Message['type'];
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/remote/protocol/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAE3B,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,CAAC,cAAc,GAAG,eAAe,CAAC,CAAC;AAC5E,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../../../src/types/remote/protocol/client/transfer/action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,MAAM,GAAG,qBAAqB,CAAC,QAAQ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Action } from './action';
|
|
2
|
+
import type { TransferPullMessage } from './pull';
|
|
3
|
+
import type { TransferPushMessage } from './push';
|
|
4
|
+
export * from './action';
|
|
5
|
+
export * from './pull';
|
|
6
|
+
export * from './push';
|
|
7
|
+
export * from './utils';
|
|
8
|
+
export type TransferMessage = {
|
|
9
|
+
type: 'transfer';
|
|
10
|
+
transferID: string;
|
|
11
|
+
} & (Action | TransferPushMessage | TransferPullMessage);
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/types/remote/protocol/client/transfer/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAElD,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAExB,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,CACrE,MAAM,GACN,mBAAmB,GACnB,mBAAmB,CACtB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IEntity, ILink, IConfiguration } from '../../../../common-entities';
|
|
2
|
+
import { CreateTransferMessage, TransferAssetFlow } from './utils';
|
|
3
|
+
export type TransferPullMessage = CreateTransferMessage<'step', TransferStepCommands<'entities', IEntity[]> | TransferStepCommands<'links', ILink[]> | TransferStepCommands<'configuration', IConfiguration[]> | TransferStepCommands<'assets', TransferAssetFlow[]>>;
|
|
4
|
+
export type TransferPullStep = TransferPullMessage['step'];
|
|
5
|
+
export type GetTransferPullStreamData<T extends TransferPullStep> = {
|
|
6
|
+
[key in TransferPullStep]: {
|
|
7
|
+
action: 'stream';
|
|
8
|
+
step: key;
|
|
9
|
+
} & TransferPullMessage;
|
|
10
|
+
}[T] extends {
|
|
11
|
+
data: infer U;
|
|
12
|
+
} ? U : never;
|
|
13
|
+
type TransferStepCommands<T extends string, U> = {
|
|
14
|
+
step: T;
|
|
15
|
+
} & TransferStepFlow<U>;
|
|
16
|
+
type TransferStepFlow<U> = {
|
|
17
|
+
action: 'start';
|
|
18
|
+
} | {
|
|
19
|
+
action: 'stream';
|
|
20
|
+
data: U;
|
|
21
|
+
} | {
|
|
22
|
+
action: 'end';
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=pull.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../../../../src/types/remote/protocol/client/transfer/pull.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEnE,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CACrD,MAAM,EACJ,oBAAoB,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,GAC3C,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,GACtC,oBAAoB,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC,GACvD,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CACtD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAE3D,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,gBAAgB,IAAI;KACjE,GAAG,IAAI,gBAAgB,GAAG;QACzB,MAAM,EAAE,QAAQ,CAAC;QACjB,IAAI,EAAE,GAAG,CAAC;KACX,GAAG,mBAAmB;CACxB,CAAC,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC,CAAA;CAAE,GAC1B,CAAC,GACD,KAAK,CAAC;AAEV,KAAK,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEnF,KAAK,gBAAgB,CAAC,CAAC,IAAI;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CreateTransferMessage, TransferAssetFlow } from './utils';
|
|
2
|
+
import type { IEntity, ILink, IConfiguration } from '../../../../common-entities';
|
|
3
|
+
export type TransferPushMessage = CreateTransferMessage<'step', TransferStepCommands<'entities', IEntity[]> | TransferStepCommands<'links', ILink[]> | TransferStepCommands<'configuration', IConfiguration[]> | TransferStepCommands<'assets', TransferAssetFlow[]>>;
|
|
4
|
+
export type GetTransferPushStreamData<T extends TransferPushStep> = {
|
|
5
|
+
[key in TransferPushStep]: {
|
|
6
|
+
action: 'stream';
|
|
7
|
+
step: key;
|
|
8
|
+
} & TransferPushMessage;
|
|
9
|
+
}[T] extends {
|
|
10
|
+
data: infer U;
|
|
11
|
+
} ? U extends any[] ? U : U[] : never;
|
|
12
|
+
export type TransferPushStep = TransferPushMessage['step'];
|
|
13
|
+
type TransferStepCommands<T extends string, U> = {
|
|
14
|
+
step: T;
|
|
15
|
+
} & TransferStepFlow<U>;
|
|
16
|
+
type TransferStepFlow<U> = {
|
|
17
|
+
action: 'start';
|
|
18
|
+
} | {
|
|
19
|
+
action: 'stream';
|
|
20
|
+
data: U;
|
|
21
|
+
} | {
|
|
22
|
+
action: 'end';
|
|
23
|
+
};
|
|
24
|
+
export type Stats = {
|
|
25
|
+
started: number;
|
|
26
|
+
finished: number;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=push.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../../../../src/types/remote/protocol/client/transfer/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElF,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CACrD,MAAM,EACJ,oBAAoB,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,GAC3C,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,GACtC,oBAAoB,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC,GACvD,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CACtD,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,gBAAgB,IAAI;KACjE,GAAG,IAAI,gBAAgB,GAAG;QACzB,MAAM,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