@c-time/frelio-data-json-generator 2.3.0 → 2.4.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/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -282
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/preview/index.d.ts +39 -0
- package/dist/preview/index.js +506 -0
- package/dist/preview/index.js.map +1 -0
- package/dist/types-CKkhMZAh.d.ts +285 -0
- package/package.json +9 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,286 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as GenerateDataJsonInput, a as GenerateDataJsonResult, F as FileSystemPort, b as GitDiffInfo, L as Logger, C as ClassifiedChanges, R as RegenerationTarget } from './types-CKkhMZAh.js';
|
|
2
|
+
export { c as GenerateDataJsonOptions, d as GenerationError, e as GenerationErrorCode, f as GenerationOutputEntry, g as GenerationReport, h as GenerationStats, i as GenerationWarning, j as GenerationWarningCode, O as OutputFile, P as ParsedContent, k as RecipeExecutionContext } from './types-CKkhMZAh.js';
|
|
2
3
|
import { FrelioBuildDataRecipe, TemplateIncludes } from '@c-time/frelio-data-json-recipe';
|
|
3
4
|
import { FrelioDependencyMap } from '@c-time/frelio-dependency-map';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Type definitions for @c-time/frelio-data-json-generator
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* ファイルシステム抽象化インターフェース
|
|
11
|
-
* テスト可能にするため、実際のファイルシステムアクセスを抽象化
|
|
12
|
-
*/
|
|
13
|
-
type FileSystemPort = {
|
|
14
|
-
/**
|
|
15
|
-
* ファイルを読み込む
|
|
16
|
-
* @param path ファイルパス
|
|
17
|
-
* @returns ファイル内容
|
|
18
|
-
* @throws ファイルが存在しない場合
|
|
19
|
-
*/
|
|
20
|
-
readFile(path: string): Promise<string>;
|
|
21
|
-
/**
|
|
22
|
-
* ファイルの存在確認
|
|
23
|
-
* @param path ファイルパス
|
|
24
|
-
* @returns 存在すれば true
|
|
25
|
-
*/
|
|
26
|
-
exists(path: string): Promise<boolean>;
|
|
27
|
-
/**
|
|
28
|
-
* glob パターンにマッチするファイル一覧を取得
|
|
29
|
-
* @param pattern glob パターン
|
|
30
|
-
* @returns マッチしたファイルパスの配列
|
|
31
|
-
*/
|
|
32
|
-
listFiles(pattern: string): Promise<string[]>;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Git diff 情報
|
|
36
|
-
* git diff --name-status の出力をパースした結果
|
|
37
|
-
*/
|
|
38
|
-
type GitDiffInfo = {
|
|
39
|
-
/** 追加されたファイル (A) */
|
|
40
|
-
added: string[];
|
|
41
|
-
/** 変更されたファイル (M) */
|
|
42
|
-
modified: string[];
|
|
43
|
-
/** 削除されたファイル (D) */
|
|
44
|
-
deleted: string[];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* 生成オプション
|
|
48
|
-
*/
|
|
49
|
-
type GenerateDataJsonOptions = {
|
|
50
|
-
/**
|
|
51
|
-
* フルリビルド(差分無視で全件再生成)
|
|
52
|
-
* @default false
|
|
53
|
-
*/
|
|
54
|
-
fullRebuild?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* ドライラン(ファイル出力せず、レポートのみ生成)
|
|
57
|
-
* @default false
|
|
58
|
-
*/
|
|
59
|
-
dryRun?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* ログレベル
|
|
62
|
-
* - debug: 詳細ログ
|
|
63
|
-
* - info: 通常ログ(デフォルト)
|
|
64
|
-
* - quiet: エラーのみ
|
|
65
|
-
* @default 'info'
|
|
66
|
-
*/
|
|
67
|
-
logLevel?: 'debug' | 'info' | 'quiet';
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* generateDataJson 関数の入力パラメータ
|
|
71
|
-
*/
|
|
72
|
-
type GenerateDataJsonInput = {
|
|
73
|
-
/** ビルドデータレシピ */
|
|
74
|
-
recipe: FrelioBuildDataRecipe;
|
|
75
|
-
/** 依存マップ(スコープ選定用) */
|
|
76
|
-
dependencyMap: FrelioDependencyMap;
|
|
77
|
-
/** Git diff 情報 */
|
|
78
|
-
gitDiff: GitDiffInfo;
|
|
79
|
-
/** ファイルシステムアクセス */
|
|
80
|
-
fileSystem: FileSystemPort;
|
|
81
|
-
/** コンテンツ読み込み元パス (例: "frelio-data/site") */
|
|
82
|
-
contentRootPath: string;
|
|
83
|
-
/** 出力先ルートパス (例: "frelio-data/generated/data-json") */
|
|
84
|
-
outputRootPath: string;
|
|
85
|
-
/** 生成オプション */
|
|
86
|
-
options?: GenerateDataJsonOptions;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* 出力ファイル
|
|
90
|
-
*/
|
|
91
|
-
type OutputFile = {
|
|
92
|
-
/** 相対パス (例: "articles/my-article.json") */
|
|
93
|
-
path: string;
|
|
94
|
-
/** FrelioDataJson 形式のコンテンツ */
|
|
95
|
-
content: FrelioDataJson;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* generateDataJson 関数の出力結果
|
|
99
|
-
*/
|
|
100
|
-
type GenerateDataJsonResult = {
|
|
101
|
-
/** 生成されたファイル一覧 */
|
|
102
|
-
outputs: OutputFile[];
|
|
103
|
-
/** ビルドレポート */
|
|
104
|
-
report: GenerationReport;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* ビルド統計
|
|
108
|
-
*/
|
|
109
|
-
type GenerationStats = {
|
|
110
|
-
/** 更新されたファイル数(create/update は区別しない) */
|
|
111
|
-
updated: number;
|
|
112
|
-
/** 削除されたファイル数 */
|
|
113
|
-
deleted: number;
|
|
114
|
-
/** スキップされたファイル数 */
|
|
115
|
-
skipped: number;
|
|
116
|
-
/** エラー数 */
|
|
117
|
-
errors: number;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* ビルドレポート
|
|
121
|
-
* CMS-admin で表示するためのレポート形式
|
|
122
|
-
*/
|
|
123
|
-
type GenerationReport = {
|
|
124
|
-
/** 生成日時 (ISO 8601) */
|
|
125
|
-
generatedAt: string;
|
|
126
|
-
/** ビルドモード */
|
|
127
|
-
mode: 'incremental' | 'full-rebuild';
|
|
128
|
-
/** 差分範囲(incremental の場合) */
|
|
129
|
-
diffRange?: string;
|
|
130
|
-
/** ドライランかどうか */
|
|
131
|
-
dryRun: boolean;
|
|
132
|
-
/** 統計情報 */
|
|
133
|
-
stats: GenerationStats;
|
|
134
|
-
/** 出力ファイル一覧 */
|
|
135
|
-
outputs: GenerationOutputEntry[];
|
|
136
|
-
/** エラー一覧 */
|
|
137
|
-
errors: GenerationError[];
|
|
138
|
-
/** 警告一覧 */
|
|
139
|
-
warnings: GenerationWarning[];
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* 出力ファイルエントリ
|
|
143
|
-
*/
|
|
144
|
-
type GenerationOutputEntry = {
|
|
145
|
-
/** ファイルパス */
|
|
146
|
-
path: string;
|
|
147
|
-
/** ステータス */
|
|
148
|
-
status: 'updated' | 'deleted';
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* エラーコード
|
|
152
|
-
*/
|
|
153
|
-
type GenerationErrorCode = 'RELATION_NOT_FOUND' | 'CONTENT_NOT_FOUND' | 'INVALID_TEMPLATE_VAR' | 'INVALID_JSON' | 'FILTER_ERROR' | 'CIRCULAR_REFERENCE' | 'INVALID_OUTPUT_PATH' | 'DUPLICATE_OUTPUT_PATH' | 'MISSING_DETAIL_REPLACER';
|
|
154
|
-
/**
|
|
155
|
-
* 生成エラー
|
|
156
|
-
*/
|
|
157
|
-
type GenerationError = {
|
|
158
|
-
/** エラーコード */
|
|
159
|
-
code: GenerationErrorCode;
|
|
160
|
-
/** 対象の出力パス */
|
|
161
|
-
outputPath?: string;
|
|
162
|
-
/** 対象のコンテンツID */
|
|
163
|
-
contentId?: string;
|
|
164
|
-
/** 対象のフィールド名 */
|
|
165
|
-
field?: string;
|
|
166
|
-
/** エラーメッセージ */
|
|
167
|
-
message: string;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* 警告コード
|
|
171
|
-
*/
|
|
172
|
-
type GenerationWarningCode = 'EMPTY_LIST' | 'TRUNCATED_RELATION' | 'DEFAULT_VALUE_USED';
|
|
173
|
-
/**
|
|
174
|
-
* 生成警告
|
|
175
|
-
*/
|
|
176
|
-
type GenerationWarning = {
|
|
177
|
-
/** 警告コード */
|
|
178
|
-
code: GenerationWarningCode;
|
|
179
|
-
/** 対象の出力パス */
|
|
180
|
-
outputPath?: string;
|
|
181
|
-
/** 警告メッセージ */
|
|
182
|
-
message: string;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* 分類された変更ファイル
|
|
186
|
-
*/
|
|
187
|
-
type ClassifiedChanges = {
|
|
188
|
-
/** コンテンツファイルの変更 */
|
|
189
|
-
contents: {
|
|
190
|
-
added: string[];
|
|
191
|
-
modified: string[];
|
|
192
|
-
deleted: string[];
|
|
193
|
-
};
|
|
194
|
-
/** テンプレートの変更 */
|
|
195
|
-
templates: {
|
|
196
|
-
added: string[];
|
|
197
|
-
modified: string[];
|
|
198
|
-
deleted: string[];
|
|
199
|
-
};
|
|
200
|
-
/** コンテンツタイプ定義の変更 */
|
|
201
|
-
contentTypes: {
|
|
202
|
-
added: string[];
|
|
203
|
-
modified: string[];
|
|
204
|
-
deleted: string[];
|
|
205
|
-
};
|
|
206
|
-
/** パーツファイルの変更 */
|
|
207
|
-
parts: {
|
|
208
|
-
added: string[];
|
|
209
|
-
modified: string[];
|
|
210
|
-
deleted: string[];
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* 再生成が必要な出力パスとその理由
|
|
215
|
-
*/
|
|
216
|
-
type RegenerationTarget = {
|
|
217
|
-
/** 出力パス(パターン or 具体的パス) */
|
|
218
|
-
outputPath: string;
|
|
219
|
-
/** 再生成の理由 */
|
|
220
|
-
reason: 'content_changed' | 'template_changed' | 'schema_changed' | 'parts_changed' | 'deleted' | 'full_rebuild';
|
|
221
|
-
/** 関連するコンテンツID(detail の場合) */
|
|
222
|
-
contentId?: string;
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* パース済みコンテンツ
|
|
226
|
-
*/
|
|
227
|
-
type ParsedContent = {
|
|
228
|
-
/** コンテンツID (UUID) */
|
|
229
|
-
contentId: string;
|
|
230
|
-
/** コンテンツタイプID */
|
|
231
|
-
contentTypeId: string;
|
|
232
|
-
/** slug */
|
|
233
|
-
slug: string;
|
|
234
|
-
/** タイトル */
|
|
235
|
-
title: string;
|
|
236
|
-
/** ステータス */
|
|
237
|
-
status: string;
|
|
238
|
-
/** コンテンツデータ */
|
|
239
|
-
data: Record<string, unknown>;
|
|
240
|
-
/** 作成日時 */
|
|
241
|
-
createdAt: string;
|
|
242
|
-
/** 更新日時 */
|
|
243
|
-
updatedAt: string;
|
|
244
|
-
/** 公開日時 */
|
|
245
|
-
publishedAt: string | null;
|
|
246
|
-
/** 作成者 */
|
|
247
|
-
createdBy: string;
|
|
248
|
-
/** ファイルパス */
|
|
249
|
-
filePath: string;
|
|
250
|
-
};
|
|
251
|
-
/**
|
|
252
|
-
* レシピ実行コンテキスト
|
|
253
|
-
*/
|
|
254
|
-
type RecipeExecutionContext = {
|
|
255
|
-
/** コンテンツタイプ別のコンテンツ */
|
|
256
|
-
contentsByType: Map<string, ParsedContent[]>;
|
|
257
|
-
/** ファイルシステム */
|
|
258
|
-
fileSystem: FileSystemPort;
|
|
259
|
-
/** コンテンツルートパス */
|
|
260
|
-
contentRootPath: string;
|
|
261
|
-
/** 出力ルートパス */
|
|
262
|
-
outputRootPath: string;
|
|
263
|
-
/** エラー記録用 */
|
|
264
|
-
errors: GenerationError[];
|
|
265
|
-
/** 警告記録用 */
|
|
266
|
-
warnings: GenerationWarning[];
|
|
267
|
-
/** ログレベル */
|
|
268
|
-
logLevel: 'debug' | 'info' | 'quiet';
|
|
269
|
-
/**
|
|
270
|
-
* レシピ既定の出力タイムゾーン(issue #92)。
|
|
271
|
-
* date 整形時、フィールド単位の timezone が無い場合のフォールバック。
|
|
272
|
-
* オフセット表記(例 "+09:00")。未設定は UTC。
|
|
273
|
-
*/
|
|
274
|
-
defaultTimezone?: string;
|
|
275
|
-
};
|
|
276
|
-
/**
|
|
277
|
-
* ロガーインターフェース
|
|
278
|
-
*/
|
|
279
|
-
type Logger = {
|
|
280
|
-
debug(message: string, ...args: unknown[]): void;
|
|
281
|
-
info(message: string, ...args: unknown[]): void;
|
|
282
|
-
error(message: string, ...args: unknown[]): void;
|
|
283
|
-
};
|
|
5
|
+
import '@c-time/frelio-data-json';
|
|
284
6
|
|
|
285
7
|
/**
|
|
286
8
|
* Main generator function
|
|
@@ -460,4 +182,4 @@ declare function getAllOutputPaths(dependencyMap: FrelioDependencyMap): Regenera
|
|
|
460
182
|
*/
|
|
461
183
|
declare function expandPartsAffectedScope(changedParts: string[], templateIncludes: TemplateIncludes | undefined, dependencyMap: FrelioDependencyMap): RegenerationTarget[];
|
|
462
184
|
|
|
463
|
-
export {
|
|
185
|
+
export { ClassifiedChanges, FileSystemPort, GenerateDataJsonInput, GenerateDataJsonResult, GitDiffInfo, Logger, NodeFileSystem, RegenerationTarget, calculateRegenerationScope, classifyChangedFiles, createLogger, expandPartsAffectedScope, generateDataJson, getAllOutputPaths, getGitDiff, parseGitDiff };
|
package/dist/index.js
CHANGED
|
@@ -956,7 +956,7 @@ async function processListRecipes(contentTypeId, recipes, targets, context) {
|
|
|
956
956
|
}
|
|
957
957
|
return outputs;
|
|
958
958
|
}
|
|
959
|
-
async function
|
|
959
|
+
async function buildListPageData(contentTypeId, recipe, context) {
|
|
960
960
|
let contents = context.contentsByType.get(contentTypeId) ?? [];
|
|
961
961
|
contents = applyFilters(contents, recipe.filters);
|
|
962
962
|
contents = applySort(contents, recipe.sort);
|
|
@@ -967,6 +967,10 @@ async function processListWithoutPagination(contentTypeId, recipe, context) {
|
|
|
967
967
|
contents = contents.slice(0, recipe.limit);
|
|
968
968
|
}
|
|
969
969
|
const items = await processListItems(contents, recipe, context);
|
|
970
|
+
return { items, totalCount: items.length };
|
|
971
|
+
}
|
|
972
|
+
async function processListWithoutPagination(contentTypeId, recipe, context) {
|
|
973
|
+
const { items, totalCount } = await buildListPageData(contentTypeId, recipe, context);
|
|
970
974
|
const outputPath = sanitizePath(recipe.outputPath);
|
|
971
975
|
const pathError = validateOutputPath(outputPath);
|
|
972
976
|
if (pathError) {
|
|
@@ -986,7 +990,7 @@ async function processListWithoutPagination(contentTypeId, recipe, context) {
|
|
|
986
990
|
outputFile: toHtmlOutputPath(outputPath),
|
|
987
991
|
data: {
|
|
988
992
|
items,
|
|
989
|
-
totalCount
|
|
993
|
+
totalCount
|
|
990
994
|
}
|
|
991
995
|
};
|
|
992
996
|
return {
|