@c-time/frelio-data-json-recipe 1.3.14 → 1.3.17

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/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @c-time/frelio-data-json-recipe
2
+
3
+ Frelio SSG のビルドレシピ(build-data-recipe)の型定義。
4
+
5
+ ---
6
+
7
+ ## 概要
8
+
9
+ ビルドレシピは、コンテンツをどのように変換して data-json を生成するかを定義する設定ファイルのスキーマ。コンテンツタイプごとの詳細ページ・一覧ページの生成ルール、静的ページの定義、カスタムフィールド変換などを記述する。
10
+
11
+ ランタイム依存なし。型定義と型ガードのみを提供する。
12
+
13
+ ---
14
+
15
+ ## インストール
16
+
17
+ ```bash
18
+ npm install @c-time/frelio-data-json-recipe
19
+ ```
20
+
21
+ ---
22
+
23
+ ## 使用例
24
+
25
+ ```typescript
26
+ import type {
27
+ FrelioBuildDataRecipe,
28
+ ContentTypeRecipe,
29
+ DetailPageRecipe,
30
+ ListPageRecipe,
31
+ } from '@c-time/frelio-data-json-recipe'
32
+
33
+ import {
34
+ isListPageRecipeWithPagination,
35
+ isCustomFieldTransform,
36
+ } from '@c-time/frelio-data-json-recipe'
37
+
38
+ // レシピの型チェック
39
+ const recipe: FrelioBuildDataRecipe = {
40
+ contentTypes: { /* ... */ },
41
+ staticPages: [],
42
+ templateIncludes: {},
43
+ }
44
+
45
+ // ページネーションの有無を判定
46
+ if (isListPageRecipeWithPagination(listRecipe)) {
47
+ console.log(listRecipe.pagination.perPage)
48
+ }
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 主な型
54
+
55
+ | 型 | 説明 |
56
+ |----|------|
57
+ | `FrelioBuildDataRecipe` | ビルドレシピ全体の定義 |
58
+ | `ContentTypeRecipe` | コンテンツタイプごとの生成ルール |
59
+ | `DetailPageRecipe` | 詳細ページの生成設定 |
60
+ | `ListPageRecipe` | 一覧ページの生成設定(ページネーション有無で分岐) |
61
+ | `StaticPageRecipe` | 静的ページの生成設定 |
62
+ | `CustomFieldTransform` | フィールド値の変換定義 |
63
+ | `CustomFieldRelationList` | 関連コンテンツの参照定義 |
64
+ | `CustomFieldConstant` | 固定値の定義 |
65
+ | `RelationExpand` | 関連コンテンツの展開設定 |
66
+ | `RecipeSort` / `RecipeFilter` | ソート・フィルタ設定 |
67
+ | `TemplateIncludes` | テンプレート依存関係 |
68
+
69
+ ### カスタムフィールドのフォーマットタイプ
70
+
71
+ `string`, `date`, `number`, `escape`, `toc`, `truncate`, `stripHtml`, `slug`, `lowercase`, `uppercase`, `default`, `count`, `first`, `last`, `join`, `url`, `picture`, `img`, `srcset`, `fileLink`, `relationList`, `constant` など 25 種類以上。
72
+
73
+ ---
74
+
75
+ ## 型ガード
76
+
77
+ | 関数 | 説明 |
78
+ |------|------|
79
+ | `isListPageRecipeWithPagination(recipe)` | ページネーション付き一覧レシピか判定 |
80
+ | `isListPageRecipeWithoutPagination(recipe)` | ページネーションなし一覧レシピか判定 |
81
+ | `isCustomFieldTransform(field)` | Transform 型カスタムフィールドか判定 |
82
+ | `isCustomFieldRelationList(field)` | RelationList 型カスタムフィールドか判定 |
83
+ | `isCustomFieldConstant(field)` | Constant 型カスタムフィールドか判定 |
84
+
85
+ ---
86
+
87
+ ## ライセンス
88
+
89
+ MIT
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ function isCustomFieldRelationList(field) {
12
12
  return field.type === "relationList";
13
13
  }
14
14
  function isCustomFieldTransform(field) {
15
- return field.type !== "relationList" && field.type !== "constant";
15
+ return field.type !== void 0 && field.type !== "relationList" && field.type !== "constant";
16
16
  }
17
17
 
18
18
  export { isCustomFieldConstant, isCustomFieldRelationList, isCustomFieldTransform, isListPageRecipeWithPagination, isListPageRecipeWithoutPagination };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/guards.ts"],"names":[],"mappings":";AAiBO,SAAS,+BACd,MAAA,EACwC;AACxC,EAAA,OAAO,OAAO,UAAA,KAAe,MAAA;AAC/B;AAKO,SAAS,kCACd,MAAA,EAC2C;AAC3C,EAAA,OAAO,OAAO,UAAA,KAAe,MAAA;AAC/B;AAKO,SAAS,sBACd,KAAA,EAC8B;AAC9B,EAAA,OAAO,MAAM,IAAA,KAAS,UAAA;AACxB;AAKO,SAAS,0BACd,KAAA,EACkC;AAClC,EAAA,OAAO,MAAM,IAAA,KAAS,cAAA;AACxB;AAKO,SAAS,uBACd,KAAA,EAC+B;AAC/B,EAAA,OAAO,KAAA,CAAM,IAAA,KAAS,cAAA,IAAkB,KAAA,CAAM,IAAA,KAAS,UAAA;AACzD","file":"index.js","sourcesContent":["/**\n * Type guard functions for Frelio build data recipe.\n */\n\nimport type {\n ListPageRecipe,\n ListPageRecipeWithPagination,\n ListPageRecipeWithoutPagination,\n CustomField,\n CustomFieldConstant,\n CustomFieldRelationList,\n CustomFieldTransform,\n} from './types.js'\n\n/**\n * ListPageRecipe がページネーション有効かどうかを判定\n */\nexport function isListPageRecipeWithPagination(\n recipe: ListPageRecipe\n): recipe is ListPageRecipeWithPagination {\n return recipe.pagination !== undefined\n}\n\n/**\n * ListPageRecipe がページネーション無効かどうかを判定\n */\nexport function isListPageRecipeWithoutPagination(\n recipe: ListPageRecipe\n): recipe is ListPageRecipeWithoutPagination {\n return recipe.pagination === undefined\n}\n\n/**\n * CustomField が定数(Constant)かどうかを判定\n */\nexport function isCustomFieldConstant(\n field: CustomField\n): field is CustomFieldConstant {\n return field.type === 'constant'\n}\n\n/**\n * CustomField が RelationList かどうかを判定\n */\nexport function isCustomFieldRelationList(\n field: CustomField\n): field is CustomFieldRelationList {\n return field.type === 'relationList'\n}\n\n/**\n * CustomField が変換系(Transform)かどうかを判定\n */\nexport function isCustomFieldTransform(\n field: CustomField\n): field is CustomFieldTransform {\n return field.type !== 'relationList' && field.type !== 'constant'\n}\n"]}
1
+ {"version":3,"sources":["../src/guards.ts"],"names":[],"mappings":";AAiBO,SAAS,+BACd,MAAA,EACwC;AACxC,EAAA,OAAO,OAAO,UAAA,KAAe,MAAA;AAC/B;AAKO,SAAS,kCACd,MAAA,EAC2C;AAC3C,EAAA,OAAO,OAAO,UAAA,KAAe,MAAA;AAC/B;AAKO,SAAS,sBACd,KAAA,EAC8B;AAC9B,EAAA,OAAO,MAAM,IAAA,KAAS,UAAA;AACxB;AAKO,SAAS,0BACd,KAAA,EACkC;AAClC,EAAA,OAAO,MAAM,IAAA,KAAS,cAAA;AACxB;AAKO,SAAS,uBACd,KAAA,EAC+B;AAC/B,EAAA,OAAO,MAAM,IAAA,KAAS,MAAA,IAAa,MAAM,IAAA,KAAS,cAAA,IAAkB,MAAM,IAAA,KAAS,UAAA;AACrF","file":"index.js","sourcesContent":["/**\n * Type guard functions for Frelio build data recipe.\n */\n\nimport type {\n ListPageRecipe,\n ListPageRecipeWithPagination,\n ListPageRecipeWithoutPagination,\n CustomField,\n CustomFieldConstant,\n CustomFieldRelationList,\n CustomFieldTransform,\n} from './types.js'\n\n/**\n * ListPageRecipe がページネーション有効かどうかを判定\n */\nexport function isListPageRecipeWithPagination(\n recipe: ListPageRecipe\n): recipe is ListPageRecipeWithPagination {\n return recipe.pagination !== undefined\n}\n\n/**\n * ListPageRecipe がページネーション無効かどうかを判定\n */\nexport function isListPageRecipeWithoutPagination(\n recipe: ListPageRecipe\n): recipe is ListPageRecipeWithoutPagination {\n return recipe.pagination === undefined\n}\n\n/**\n * CustomField が定数(Constant)かどうかを判定\n */\nexport function isCustomFieldConstant(\n field: CustomField\n): field is CustomFieldConstant {\n return field.type === 'constant'\n}\n\n/**\n * CustomField が RelationList かどうかを判定\n */\nexport function isCustomFieldRelationList(\n field: CustomField\n): field is CustomFieldRelationList {\n return field.type === 'relationList'\n}\n\n/**\n * CustomField が変換系(Transform)かどうかを判定\n */\nexport function isCustomFieldTransform(\n field: CustomField\n): field is CustomFieldTransform {\n return field.type !== undefined && field.type !== 'relationList' && field.type !== 'constant'\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-time/frelio-data-json-recipe",
3
- "version": "1.3.14",
3
+ "version": "1.3.17",
4
4
  "description": "Type definitions for frelio data JSON recipe",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,6 +19,8 @@
19
19
  "scripts": {
20
20
  "build": "tsup",
21
21
  "dev": "tsup --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest",
22
24
  "prepublishOnly": "npm run build"
23
25
  },
24
26
  "publishConfig": {
@@ -39,7 +41,8 @@
39
41
  "license": "MIT",
40
42
  "devDependencies": {
41
43
  "tsup": "^8.5.0",
42
- "typescript": "^5.7.0"
44
+ "typescript": "^5.7.0",
45
+ "vitest": "^4.0.18"
43
46
  },
44
47
  "engines": {
45
48
  "node": ">=18"