content-serialization 0.0.0 → 1.0.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/server/index.js +26 -2
- package/dist/server/index.mjs +26 -2
- package/package.json +71 -71
package/dist/server/index.js
CHANGED
|
@@ -212,6 +212,29 @@ function getComponentSchemas() {
|
|
|
212
212
|
});
|
|
213
213
|
return schemas;
|
|
214
214
|
}
|
|
215
|
+
function getDeepPopulate(uid, depth = 5) {
|
|
216
|
+
if (depth <= 0) return true;
|
|
217
|
+
const model = strapi.contentTypes[uid] || strapi.components[uid];
|
|
218
|
+
const populate = {};
|
|
219
|
+
Object.keys(model.attributes).forEach((key) => {
|
|
220
|
+
const attr = model.attributes[key];
|
|
221
|
+
if (attr.type === "component") {
|
|
222
|
+
populate[key] = { populate: getDeepPopulate(attr.component, depth - 1) };
|
|
223
|
+
} else if (attr.type === "dynamiczone") {
|
|
224
|
+
const dzPopulate = { on: {} };
|
|
225
|
+
attr.components.forEach((compUid) => {
|
|
226
|
+
dzPopulate.on[compUid] = { populate: getDeepPopulate(compUid, depth - 1) };
|
|
227
|
+
});
|
|
228
|
+
populate[key] = dzPopulate;
|
|
229
|
+
} else if (attr.type === "media") {
|
|
230
|
+
populate[key] = true;
|
|
231
|
+
} else if (attr.type === "relation") {
|
|
232
|
+
populate[key] = { count: true };
|
|
233
|
+
populate[key] = true;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
return populate;
|
|
237
|
+
}
|
|
215
238
|
const serialization = ({ strapi: strapi2 }) => ({
|
|
216
239
|
async pull() {
|
|
217
240
|
ensureDir(SERIALIZATION_DIR);
|
|
@@ -250,14 +273,15 @@ const serialization = ({ strapi: strapi2 }) => ({
|
|
|
250
273
|
}
|
|
251
274
|
processedFiles.add(filename);
|
|
252
275
|
};
|
|
276
|
+
const populate = getDeepPopulate(uid);
|
|
253
277
|
const items = await strapi2.documents(uid).findMany({
|
|
254
|
-
populate
|
|
278
|
+
populate,
|
|
255
279
|
publicationState: "preview",
|
|
256
280
|
limit: 1e4
|
|
257
281
|
});
|
|
258
282
|
const itemArray = Array.isArray(items) ? items : [items];
|
|
259
283
|
if (contentType.kind === "singleType") {
|
|
260
|
-
const item = await strapi2.documents(uid).findFirst({ populate:
|
|
284
|
+
const item = await strapi2.documents(uid).findFirst({ populate: getDeepPopulate(uid) });
|
|
261
285
|
if (item) {
|
|
262
286
|
processItem(item, `${singularName}.yml`);
|
|
263
287
|
}
|
package/dist/server/index.mjs
CHANGED
|
@@ -206,6 +206,29 @@ function getComponentSchemas() {
|
|
|
206
206
|
});
|
|
207
207
|
return schemas;
|
|
208
208
|
}
|
|
209
|
+
function getDeepPopulate(uid, depth = 5) {
|
|
210
|
+
if (depth <= 0) return true;
|
|
211
|
+
const model = strapi.contentTypes[uid] || strapi.components[uid];
|
|
212
|
+
const populate = {};
|
|
213
|
+
Object.keys(model.attributes).forEach((key) => {
|
|
214
|
+
const attr = model.attributes[key];
|
|
215
|
+
if (attr.type === "component") {
|
|
216
|
+
populate[key] = { populate: getDeepPopulate(attr.component, depth - 1) };
|
|
217
|
+
} else if (attr.type === "dynamiczone") {
|
|
218
|
+
const dzPopulate = { on: {} };
|
|
219
|
+
attr.components.forEach((compUid) => {
|
|
220
|
+
dzPopulate.on[compUid] = { populate: getDeepPopulate(compUid, depth - 1) };
|
|
221
|
+
});
|
|
222
|
+
populate[key] = dzPopulate;
|
|
223
|
+
} else if (attr.type === "media") {
|
|
224
|
+
populate[key] = true;
|
|
225
|
+
} else if (attr.type === "relation") {
|
|
226
|
+
populate[key] = { count: true };
|
|
227
|
+
populate[key] = true;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
return populate;
|
|
231
|
+
}
|
|
209
232
|
const serialization = ({ strapi: strapi2 }) => ({
|
|
210
233
|
async pull() {
|
|
211
234
|
ensureDir(SERIALIZATION_DIR);
|
|
@@ -244,14 +267,15 @@ const serialization = ({ strapi: strapi2 }) => ({
|
|
|
244
267
|
}
|
|
245
268
|
processedFiles.add(filename);
|
|
246
269
|
};
|
|
270
|
+
const populate = getDeepPopulate(uid);
|
|
247
271
|
const items = await strapi2.documents(uid).findMany({
|
|
248
|
-
populate
|
|
272
|
+
populate,
|
|
249
273
|
publicationState: "preview",
|
|
250
274
|
limit: 1e4
|
|
251
275
|
});
|
|
252
276
|
const itemArray = Array.isArray(items) ? items : [items];
|
|
253
277
|
if (contentType.kind === "singleType") {
|
|
254
|
-
const item = await strapi2.documents(uid).findFirst({ populate:
|
|
278
|
+
const item = await strapi2.documents(uid).findFirst({ populate: getDeepPopulate(uid) });
|
|
255
279
|
if (item) {
|
|
256
280
|
processItem(item, `${singularName}.yml`);
|
|
257
281
|
}
|
package/package.json
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "
|
|
3
|
-
"keywords": [],
|
|
4
|
-
"type": "commonjs",
|
|
5
|
-
"exports": {
|
|
6
|
-
"./package.json": "./package.json",
|
|
7
|
-
"./strapi-admin": {
|
|
8
|
-
"types": "./dist/admin/src/index.d.ts",
|
|
9
|
-
"source": "./admin/src/index.ts",
|
|
10
|
-
"import": "./dist/admin/index.mjs",
|
|
11
|
-
"require": "./dist/admin/index.js",
|
|
12
|
-
"default": "./dist/admin/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./strapi-server": {
|
|
15
|
-
"types": "./dist/server/src/index.d.ts",
|
|
16
|
-
"source": "./server/src/index.ts",
|
|
17
|
-
"import": "./dist/server/index.mjs",
|
|
18
|
-
"require": "./dist/server/index.js",
|
|
19
|
-
"default": "./dist/server/index.js"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "strapi-plugin build",
|
|
27
|
-
"watch": "strapi-plugin watch",
|
|
28
|
-
"watch:link": "strapi-plugin watch:link",
|
|
29
|
-
"verify": "strapi-plugin verify",
|
|
30
|
-
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
|
|
31
|
-
"test:ts:back": "run -T tsc -p server/tsconfig.json"
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@strapi/design-system": "^2.0.0-rc.30",
|
|
35
|
-
"@strapi/icons": "^2.0.0-rc.30",
|
|
36
|
-
"@types/js-yaml": "^4.0.9",
|
|
37
|
-
"js-yaml": "^4.1.1",
|
|
38
|
-
"react-intl": "^8.0.10"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@strapi/sdk-plugin": "^5.4.0",
|
|
42
|
-
"@strapi/strapi": "^5.33.1",
|
|
43
|
-
"@strapi/typescript-utils": "^5.33.1",
|
|
44
|
-
"@types/react": "^19.2.7",
|
|
45
|
-
"@types/react-dom": "^19.2.3",
|
|
46
|
-
"prettier": "^3.7.4",
|
|
47
|
-
"react": "^18.3.1",
|
|
48
|
-
"react-dom": "^18.3.1",
|
|
49
|
-
"react-router-dom": "^6.30.2",
|
|
50
|
-
"styled-components": "^6.1.19",
|
|
51
|
-
"typescript": "^5.9.3"
|
|
52
|
-
},
|
|
53
|
-
"peerDependencies": {
|
|
54
|
-
"@strapi/sdk-plugin": "^5.4.0",
|
|
55
|
-
"@strapi/strapi": "^5.33.1",
|
|
56
|
-
"react": "^18.3.1",
|
|
57
|
-
"react-dom": "^18.3.1",
|
|
58
|
-
"react-router-dom": "^6.30.2",
|
|
59
|
-
"styled-components": "^6.1.19"
|
|
60
|
-
},
|
|
61
|
-
"strapi": {
|
|
62
|
-
"kind": "plugin",
|
|
63
|
-
"name": "content-serialization",
|
|
64
|
-
"displayName": "Content CLI",
|
|
65
|
-
"description": ""
|
|
66
|
-
},
|
|
67
|
-
"name": "content-serialization",
|
|
68
|
-
"description": "",
|
|
69
|
-
"license": "MIT",
|
|
70
|
-
"author": "Jaydeep <jaydeepkotak10@gmail.com>"
|
|
71
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"keywords": [],
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"exports": {
|
|
6
|
+
"./package.json": "./package.json",
|
|
7
|
+
"./strapi-admin": {
|
|
8
|
+
"types": "./dist/admin/src/index.d.ts",
|
|
9
|
+
"source": "./admin/src/index.ts",
|
|
10
|
+
"import": "./dist/admin/index.mjs",
|
|
11
|
+
"require": "./dist/admin/index.js",
|
|
12
|
+
"default": "./dist/admin/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./strapi-server": {
|
|
15
|
+
"types": "./dist/server/src/index.d.ts",
|
|
16
|
+
"source": "./server/src/index.ts",
|
|
17
|
+
"import": "./dist/server/index.mjs",
|
|
18
|
+
"require": "./dist/server/index.js",
|
|
19
|
+
"default": "./dist/server/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "strapi-plugin build",
|
|
27
|
+
"watch": "strapi-plugin watch",
|
|
28
|
+
"watch:link": "strapi-plugin watch:link",
|
|
29
|
+
"verify": "strapi-plugin verify",
|
|
30
|
+
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
|
|
31
|
+
"test:ts:back": "run -T tsc -p server/tsconfig.json"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@strapi/design-system": "^2.0.0-rc.30",
|
|
35
|
+
"@strapi/icons": "^2.0.0-rc.30",
|
|
36
|
+
"@types/js-yaml": "^4.0.9",
|
|
37
|
+
"js-yaml": "^4.1.1",
|
|
38
|
+
"react-intl": "^8.0.10"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@strapi/sdk-plugin": "^5.4.0",
|
|
42
|
+
"@strapi/strapi": "^5.33.1",
|
|
43
|
+
"@strapi/typescript-utils": "^5.33.1",
|
|
44
|
+
"@types/react": "^19.2.7",
|
|
45
|
+
"@types/react-dom": "^19.2.3",
|
|
46
|
+
"prettier": "^3.7.4",
|
|
47
|
+
"react": "^18.3.1",
|
|
48
|
+
"react-dom": "^18.3.1",
|
|
49
|
+
"react-router-dom": "^6.30.2",
|
|
50
|
+
"styled-components": "^6.1.19",
|
|
51
|
+
"typescript": "^5.9.3"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@strapi/sdk-plugin": "^5.4.0",
|
|
55
|
+
"@strapi/strapi": "^5.33.1",
|
|
56
|
+
"react": "^18.3.1",
|
|
57
|
+
"react-dom": "^18.3.1",
|
|
58
|
+
"react-router-dom": "^6.30.2",
|
|
59
|
+
"styled-components": "^6.1.19"
|
|
60
|
+
},
|
|
61
|
+
"strapi": {
|
|
62
|
+
"kind": "plugin",
|
|
63
|
+
"name": "content-serialization",
|
|
64
|
+
"displayName": "Content CLI",
|
|
65
|
+
"description": ""
|
|
66
|
+
},
|
|
67
|
+
"name": "content-serialization",
|
|
68
|
+
"description": "",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"author": "Jaydeep <jaydeepkotak10@gmail.com>"
|
|
71
|
+
}
|