@c-time/frelio-data-json 1.0.0 → 1.1.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/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @c-time/frelio-data-json
2
+
3
+ Type definitions for Frelio data JSON output.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @c-time/frelio-data-json
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import type { FrelioDataJson } from '@c-time/frelio-data-json'
15
+
16
+ const data: FrelioDataJson = {
17
+ type: 'create',
18
+ template: 'article/detail.html',
19
+ outputFile: 'articles/my-article.html',
20
+ data: { title: 'My Article', body: '...' }
21
+ }
22
+ ```
23
+
24
+ ## Type Guards
25
+
26
+ ```typescript
27
+ import { isFrelioDataJson, isFrelioDataJsonArray } from '@c-time/frelio-data-json'
28
+
29
+ // Validate single entry
30
+ if (isFrelioDataJson(unknownData)) {
31
+ console.log(unknownData.outputFile)
32
+ }
33
+
34
+ // Validate array
35
+ if (isFrelioDataJsonArray(unknownArray)) {
36
+ unknownArray.forEach(entry => console.log(entry.type))
37
+ }
38
+ ```
39
+
40
+ ## Types
41
+
42
+ ### FrelioDataJson
43
+
44
+ ```typescript
45
+ type FrelioDataJson = {
46
+ type: 'create' | 'update' | 'delete'
47
+ template: string
48
+ outputFile: string
49
+ data: Record<string, unknown>
50
+ }
51
+ ```
52
+
53
+ | Field | Description |
54
+ |-------|-------------|
55
+ | `type` | Operation type: `create`, `update`, or `delete` |
56
+ | `template` | Template file path |
57
+ | `outputFile` | Output file path |
58
+ | `data` | Data to pass to the template |
59
+
60
+ ## License
61
+
62
+ MIT
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Type guard functions for Frelio data JSON.
3
+ */
4
+ import type { FrelioDataJson } from './types.js';
5
+ /**
6
+ * 型ガード: FrelioDataJson
7
+ */
8
+ export declare function isFrelioDataJson(value: unknown): value is FrelioDataJson;
9
+ /**
10
+ * 型ガード: FrelioDataJson[]
11
+ */
12
+ export declare function isFrelioDataJsonArray(value: unknown): value is FrelioDataJson[];
13
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAYxE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,EAAE,CAE/E"}
package/dist/guards.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Type guard functions for Frelio data JSON.
3
+ */
4
+ /**
5
+ * 型ガード: FrelioDataJson
6
+ */
7
+ export function isFrelioDataJson(value) {
8
+ if (typeof value !== 'object' || value === null) {
9
+ return false;
10
+ }
11
+ const obj = value;
12
+ return ((obj.type === 'create' || obj.type === 'update' || obj.type === 'delete') &&
13
+ typeof obj.template === 'string' &&
14
+ typeof obj.outputFile === 'string' &&
15
+ typeof obj.data === 'object' &&
16
+ obj.data !== null);
17
+ }
18
+ /**
19
+ * 型ガード: FrelioDataJson[]
20
+ */
21
+ export function isFrelioDataJsonArray(value) {
22
+ return Array.isArray(value) && value.every(isFrelioDataJson);
23
+ }
24
+ //# sourceMappingURL=guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,GAAG,GAAG,KAAgC,CAAA;IAC5C,OAAO,CACL,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;QACzE,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAChC,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ;QAClC,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAC5B,GAAG,CAAC,IAAI,KAAK,IAAI,CAClB,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;AAC9D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,22 +1,28 @@
1
1
  /**
2
- * frelio-data-json 操作タイプ
2
+ * @c-time/frelio-data-json
3
+ *
4
+ * Type definitions for Frelio data JSON output.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import type { FrelioDataJson } from '@c-time/frelio-data-json'
9
+ * import { isFrelioDataJson } from '@c-time/frelio-data-json'
10
+ *
11
+ * const data: FrelioDataJson = {
12
+ * type: 'create',
13
+ * template: 'article/detail.html',
14
+ * outputFile: 'articles/my-article.html',
15
+ * data: { title: 'My Article', body: '...' }
16
+ * }
17
+ *
18
+ * // Validate unknown data
19
+ * if (isFrelioDataJson(unknownData)) {
20
+ * console.log(unknownData.outputFile)
21
+ * }
22
+ * ```
23
+ *
24
+ * @packageDocumentation
3
25
  */
4
- export type FrelioDataJsonType = "create" | "update" | "delete";
5
- /**
6
- * frelio-data-json 単一エントリ
7
- */
8
- export type FrelioDataJson = {
9
- type: FrelioDataJsonType;
10
- template: string;
11
- outputFile: string;
12
- data: Record<string, unknown>;
13
- };
14
- /**
15
- * 型ガード: FrelioDataJson
16
- */
17
- export declare function isFrelioDataJson(value: unknown): value is FrelioDataJson;
18
- /**
19
- * 型ガード: FrelioDataJson[]
20
- */
21
- export declare function isFrelioDataJsonArray(value: unknown): value is FrelioDataJson[];
26
+ export type { FrelioDataJsonType, FrelioDataJson } from './types.js';
27
+ export { isFrelioDataJson, isFrelioDataJsonArray } from './guards.js';
22
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,kBAAkB,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAYxE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,EAAE,CAE/E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAGpE,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1,21 +1,28 @@
1
1
  /**
2
- * 型ガード: FrelioDataJson
2
+ * @c-time/frelio-data-json
3
+ *
4
+ * Type definitions for Frelio data JSON output.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import type { FrelioDataJson } from '@c-time/frelio-data-json'
9
+ * import { isFrelioDataJson } from '@c-time/frelio-data-json'
10
+ *
11
+ * const data: FrelioDataJson = {
12
+ * type: 'create',
13
+ * template: 'article/detail.html',
14
+ * outputFile: 'articles/my-article.html',
15
+ * data: { title: 'My Article', body: '...' }
16
+ * }
17
+ *
18
+ * // Validate unknown data
19
+ * if (isFrelioDataJson(unknownData)) {
20
+ * console.log(unknownData.outputFile)
21
+ * }
22
+ * ```
23
+ *
24
+ * @packageDocumentation
3
25
  */
4
- export function isFrelioDataJson(value) {
5
- if (typeof value !== 'object' || value === null) {
6
- return false;
7
- }
8
- const obj = value;
9
- return ((obj.type === 'create' || obj.type === 'update' || obj.type === 'delete') &&
10
- typeof obj.template === 'string' &&
11
- typeof obj.outputFile === 'string' &&
12
- typeof obj.data === 'object' &&
13
- obj.data !== null);
14
- }
15
- /**
16
- * 型ガード: FrelioDataJson[]
17
- */
18
- export function isFrelioDataJsonArray(value) {
19
- return Array.isArray(value) && value.every(isFrelioDataJson);
20
- }
26
+ // Type guards
27
+ export { isFrelioDataJson, isFrelioDataJsonArray } from './guards.js';
21
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,GAAG,GAAG,KAAgC,CAAA;IAC5C,OAAO,CACL,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;QACzE,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAChC,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ;QAClC,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAC5B,GAAG,CAAC,IAAI,KAAK,IAAI,CAClB,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;AAC9D,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,cAAc;AACd,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Type definitions for Frelio data JSON output.
3
+ */
4
+ /**
5
+ * frelio-data-json 操作タイプ
6
+ */
7
+ export type FrelioDataJsonType = 'create' | 'update' | 'delete';
8
+ /**
9
+ * frelio-data-json 単一エントリ
10
+ *
11
+ * データ JSON ジェネレーターが出力し、gentl が消費する中間形式。
12
+ *
13
+ * @example
14
+ * ```json
15
+ * {
16
+ * "type": "create",
17
+ * "template": "article/detail.html",
18
+ * "outputFile": "articles/my-article.html",
19
+ * "data": { "title": "My Article", "body": "..." }
20
+ * }
21
+ * ```
22
+ */
23
+ export type FrelioDataJson = {
24
+ /** 操作タイプ: create(新規), update(更新), delete(削除) */
25
+ type: FrelioDataJsonType;
26
+ /** テンプレートファイルのパス */
27
+ template: string;
28
+ /** 出力ファイルのパス */
29
+ outputFile: string;
30
+ /** テンプレートに渡すデータ */
31
+ data: Record<string, unknown>;
32
+ };
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,gDAAgD;IAChD,IAAI,EAAE,kBAAkB,CAAA;IACxB,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Type definitions for Frelio data JSON output.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-time/frelio-data-json",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Type definitions for frelio data JSON output",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",