@c-time/frelio-data-json-recipe-to-dependency-map 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/converter.d.ts +7 -0
- package/dist/converter.d.ts.map +1 -0
- package/dist/converter.js +145 -0
- package/dist/converter.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FrelioBuildDataRecipe } from '@c-time/frelio-data-json-recipe';
|
|
2
|
+
import type { FrelioDependencyMap } from '@c-time/frelio-dependency-map';
|
|
3
|
+
/**
|
|
4
|
+
* FrelioBuildDataRecipe を FrelioDependencyMap に変換
|
|
5
|
+
*/
|
|
6
|
+
export declare function convertRecipeToDependencyMap(recipe: FrelioBuildDataRecipe): FrelioDependencyMap;
|
|
7
|
+
//# sourceMappingURL=converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EAQtB,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAwKxE;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,qBAAqB,GAC5B,mBAAmB,CAmBrB"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RelationExpand と CustomField から関連する contentTypeId を再帰的に収集
|
|
3
|
+
*/
|
|
4
|
+
function collectRelatedContentTypes(expand, customFields) {
|
|
5
|
+
const contentTypeIds = new Set();
|
|
6
|
+
// expand から収集(ネスト対応)
|
|
7
|
+
if (expand) {
|
|
8
|
+
for (const rel of expand) {
|
|
9
|
+
// expand 内のネストした expand と customFields を再帰処理
|
|
10
|
+
const nested = collectRelatedContentTypes(rel.expand, rel.customFields);
|
|
11
|
+
nested.forEach((id) => contentTypeIds.add(id));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// customFields から relationList を収集
|
|
15
|
+
if (customFields) {
|
|
16
|
+
for (const field of customFields) {
|
|
17
|
+
if (field.type === 'relationList') {
|
|
18
|
+
contentTypeIds.add(field.contentTypeId);
|
|
19
|
+
// relationList 内のネストした expand と customFields を再帰処理
|
|
20
|
+
const nested = collectRelatedContentTypes(field.expand, field.customFields);
|
|
21
|
+
nested.forEach((id) => contentTypeIds.add(id));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return contentTypeIds;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* contentTypeId から基本的な依存パスを生成
|
|
29
|
+
*/
|
|
30
|
+
function createContentTypeDependencies(contentTypeId) {
|
|
31
|
+
return [
|
|
32
|
+
`content_types/${contentTypeId}`,
|
|
33
|
+
`contents/*/${contentTypeId}/*`,
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* DetailPageRecipe を処理して依存マップに追加
|
|
38
|
+
*/
|
|
39
|
+
function processDetailRecipe(result, contentTypeId, recipe) {
|
|
40
|
+
const deps = [
|
|
41
|
+
...createContentTypeDependencies(contentTypeId),
|
|
42
|
+
`templates/${recipe.templatePath}`,
|
|
43
|
+
];
|
|
44
|
+
// expand と customFields から関連 contentTypeId を収集
|
|
45
|
+
const relatedTypes = collectRelatedContentTypes(recipe.expand, recipe.customFields);
|
|
46
|
+
for (const relatedId of relatedTypes) {
|
|
47
|
+
deps.push(...createContentTypeDependencies(relatedId));
|
|
48
|
+
}
|
|
49
|
+
result[recipe.outputPath] = [...new Set(deps)];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* ListPageRecipe を処理して依存マップに追加
|
|
53
|
+
*/
|
|
54
|
+
function processListRecipe(result, contentTypeId, recipe) {
|
|
55
|
+
const deps = [
|
|
56
|
+
...createContentTypeDependencies(contentTypeId),
|
|
57
|
+
`templates/${recipe.templatePath}`,
|
|
58
|
+
];
|
|
59
|
+
// expand の取得(pagination 有無で場所が異なる)
|
|
60
|
+
const expand = recipe.pagination ? recipe.items?.expand : recipe.expand;
|
|
61
|
+
// expand と customFields から関連 contentTypeId を収集
|
|
62
|
+
const relatedTypes = collectRelatedContentTypes(expand, recipe.customFields);
|
|
63
|
+
for (const relatedId of relatedTypes) {
|
|
64
|
+
deps.push(...createContentTypeDependencies(relatedId));
|
|
65
|
+
}
|
|
66
|
+
result[recipe.outputPath] = [...new Set(deps)];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* ContentTypeRecipe を処理
|
|
70
|
+
*/
|
|
71
|
+
function processContentType(result, contentTypeId, recipe) {
|
|
72
|
+
// details を処理
|
|
73
|
+
if (recipe.details) {
|
|
74
|
+
for (const detail of recipe.details) {
|
|
75
|
+
processDetailRecipe(result, contentTypeId, detail);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// lists を処理
|
|
79
|
+
if (recipe.lists) {
|
|
80
|
+
for (const list of recipe.lists) {
|
|
81
|
+
processListRecipe(result, contentTypeId, list);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* StaticPageRecipe を処理
|
|
87
|
+
*/
|
|
88
|
+
function processStaticPages(result, staticPages) {
|
|
89
|
+
for (const page of staticPages) {
|
|
90
|
+
const deps = [`templates/${page.templatePath}`];
|
|
91
|
+
// customFields から関連 contentTypeId を収集
|
|
92
|
+
const relatedTypes = collectRelatedContentTypes(undefined, page.customFields);
|
|
93
|
+
for (const relatedId of relatedTypes) {
|
|
94
|
+
deps.push(...createContentTypeDependencies(relatedId));
|
|
95
|
+
}
|
|
96
|
+
result[page.outputPath] = [...new Set(deps)];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* templateIncludes を適用
|
|
101
|
+
* パーツパターンが影響するテンプレートを使う全 outputPath に依存を追加
|
|
102
|
+
*/
|
|
103
|
+
function applyTemplateIncludes(result, templateIncludes) {
|
|
104
|
+
for (const [partsPattern, affectedTemplates] of Object.entries(templateIncludes)) {
|
|
105
|
+
const partsPath = `templates/${partsPattern}`;
|
|
106
|
+
// "*" は全テンプレートに影響
|
|
107
|
+
if (affectedTemplates.includes('*')) {
|
|
108
|
+
for (const outputPath of Object.keys(result)) {
|
|
109
|
+
if (!result[outputPath].includes(partsPath)) {
|
|
110
|
+
result[outputPath].push(partsPath);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// 特定のテンプレートに影響
|
|
116
|
+
for (const outputPath of Object.keys(result)) {
|
|
117
|
+
const deps = result[outputPath];
|
|
118
|
+
const hasAffectedTemplate = affectedTemplates.some((tmpl) => deps.includes(`templates/${tmpl}`));
|
|
119
|
+
if (hasAffectedTemplate && !deps.includes(partsPath)) {
|
|
120
|
+
deps.push(partsPath);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* FrelioBuildDataRecipe を FrelioDependencyMap に変換
|
|
128
|
+
*/
|
|
129
|
+
export function convertRecipeToDependencyMap(recipe) {
|
|
130
|
+
const result = {};
|
|
131
|
+
// contentTypes を処理
|
|
132
|
+
for (const [contentTypeId, contentTypeRecipe] of Object.entries(recipe.contentTypes)) {
|
|
133
|
+
processContentType(result, contentTypeId, contentTypeRecipe);
|
|
134
|
+
}
|
|
135
|
+
// staticPages を処理
|
|
136
|
+
if (recipe.staticPages) {
|
|
137
|
+
processStaticPages(result, recipe.staticPages);
|
|
138
|
+
}
|
|
139
|
+
// templateIncludes を適用
|
|
140
|
+
if (recipe.templateIncludes) {
|
|
141
|
+
applyTemplateIncludes(result, recipe.templateIncludes);
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,SAAS,0BAA0B,CACjC,MAAyB,EACzB,YAA4B;IAE5B,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAA;IAExC,qBAAqB;IACrB,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,6CAA6C;YAC7C,MAAM,MAAM,GAAG,0BAA0B,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAAA;YACvE,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IAED,mCAAmC;IACnC,IAAI,YAAY,EAAE,CAAC;QACjB,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;YACjC,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;gBAClC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;gBACvC,mDAAmD;gBACnD,MAAM,MAAM,GAAG,0BAA0B,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;gBAC3E,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,cAAc,CAAA;AACvB,CAAC;AAED;;GAEG;AACH,SAAS,6BAA6B,CAAC,aAAqB;IAC1D,OAAO;QACL,iBAAiB,aAAa,EAAE;QAChC,cAAc,aAAa,IAAI;KAChC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAS,mBA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AAC;IAED,uBAAuB;IACvB,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC5B,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxD,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @c-time/frelio-data-json-recipe-to-dependency-map
|
|
3
|
+
*
|
|
4
|
+
* Convert FrelioBuildDataRecipe to FrelioDependencyMap.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { convertRecipeToDependencyMap } from './converter.js';
|
|
9
|
+
export type { FrelioBuildDataRecipe } from '@c-time/frelio-data-json-recipe';
|
|
10
|
+
export type { FrelioDependencyMap } from '@c-time/frelio-dependency-map';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAG7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAC5E,YAAY,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@c-time/frelio-data-json-recipe-to-dependency-map",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Convert FrelioBuildDataRecipe to FrelioDependencyMap",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.build.json",
|
|
20
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"frelio",
|
|
25
|
+
"dependency-map",
|
|
26
|
+
"recipe",
|
|
27
|
+
"typescript",
|
|
28
|
+
"cms"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@c-time/frelio-data-json-recipe": "^1.2.0",
|
|
33
|
+
"@c-time/frelio-dependency-map": "^1.2.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.7.0"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
}
|
|
41
|
+
}
|