@c-time/frelio-data-json 1.1.0 → 1.2.1
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/index.d.ts +40 -21
- package/dist/index.js +14 -27
- package/dist/index.js.map +1 -1
- package/package.json +13 -3
- package/README.md +0 -62
- package/dist/guards.d.ts +0 -13
- package/dist/guards.d.ts.map +0 -1
- package/dist/guards.js +0 -24
- package/dist/guards.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -33
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @c-time/frelio-data-json
|
|
3
|
-
*
|
|
4
2
|
* Type definitions for Frelio data JSON output.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* frelio-data-json 操作タイプ
|
|
6
|
+
*/
|
|
7
|
+
type FrelioDataJsonType = 'create' | 'update' | 'delete';
|
|
8
|
+
/**
|
|
9
|
+
* frelio-data-json 単一エントリ
|
|
5
10
|
*
|
|
6
|
-
*
|
|
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
|
-
* }
|
|
11
|
+
* データ JSON ジェネレーターが出力し、gentl が消費する中間形式。
|
|
17
12
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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": "..." }
|
|
21
20
|
* }
|
|
22
21
|
* ```
|
|
23
|
-
*
|
|
24
|
-
* @packageDocumentation
|
|
25
22
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
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
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Type guard functions for Frelio data JSON.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 型ガード: FrelioDataJson
|
|
40
|
+
*/
|
|
41
|
+
declare function isFrelioDataJson(value: unknown): value is FrelioDataJson;
|
|
42
|
+
/**
|
|
43
|
+
* 型ガード: FrelioDataJson[]
|
|
44
|
+
*/
|
|
45
|
+
declare function isFrelioDataJsonArray(value: unknown): value is FrelioDataJson[];
|
|
46
|
+
|
|
47
|
+
export { type FrelioDataJson, type FrelioDataJsonType, isFrelioDataJson, isFrelioDataJsonArray };
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
25
|
-
*/
|
|
26
|
-
// Type guards
|
|
27
|
-
export { isFrelioDataJson, isFrelioDataJsonArray } from './guards.js';
|
|
1
|
+
// src/guards.ts
|
|
2
|
+
function isFrelioDataJson(value) {
|
|
3
|
+
if (typeof value !== "object" || value === null) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const obj = value;
|
|
7
|
+
return (obj.type === "create" || obj.type === "update" || obj.type === "delete") && typeof obj.template === "string" && typeof obj.outputFile === "string" && typeof obj.data === "object" && obj.data !== null;
|
|
8
|
+
}
|
|
9
|
+
function isFrelioDataJsonArray(value) {
|
|
10
|
+
return Array.isArray(value) && value.every(isFrelioDataJson);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { isFrelioDataJson, isFrelioDataJsonArray };
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
28
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/guards.ts"],"names":[],"mappings":";AASO,SAAS,iBAAiB,KAAA,EAAyC;AACxE,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA,EAAM;AAC/C,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,GAAA,GAAM,KAAA;AACZ,EAAA,OAAA,CACG,GAAA,CAAI,SAAS,QAAA,IAAY,GAAA,CAAI,SAAS,QAAA,IAAY,GAAA,CAAI,IAAA,KAAS,QAAA,KAChE,OAAO,GAAA,CAAI,aAAa,QAAA,IACxB,OAAO,IAAI,UAAA,KAAe,QAAA,IAC1B,OAAO,GAAA,CAAI,IAAA,KAAS,QAAA,IACpB,GAAA,CAAI,IAAA,KAAS,IAAA;AAEjB;AAKO,SAAS,sBAAsB,KAAA,EAA2C;AAC/E,EAAA,OAAO,MAAM,OAAA,CAAQ,KAAK,CAAA,IAAK,KAAA,CAAM,MAAM,gBAAgB,CAAA;AAC7D","file":"index.js","sourcesContent":["/**\n * Type guard functions for Frelio data JSON.\n */\n\nimport type { FrelioDataJson } from './types.js'\n\n/**\n * 型ガード: FrelioDataJson\n */\nexport function isFrelioDataJson(value: unknown): value is FrelioDataJson {\n if (typeof value !== 'object' || value === null) {\n return false\n }\n const obj = value as Record<string, unknown>\n return (\n (obj.type === 'create' || obj.type === 'update' || obj.type === 'delete') &&\n typeof obj.template === 'string' &&\n typeof obj.outputFile === 'string' &&\n typeof obj.data === 'object' &&\n obj.data !== null\n )\n}\n\n/**\n * 型ガード: FrelioDataJson[]\n */\nexport function isFrelioDataJsonArray(value: unknown): value is FrelioDataJson[] {\n return Array.isArray(value) && value.every(isFrelioDataJson)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c-time/frelio-data-json",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Type definitions for frelio data JSON output",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,15 +11,24 @@
|
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"sideEffects": false,
|
|
14
15
|
"files": [
|
|
15
16
|
"dist",
|
|
16
17
|
"README.md"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
|
-
"build": "
|
|
20
|
-
"dev": "
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"dev": "tsup --watch",
|
|
21
22
|
"prepublishOnly": "npm run build"
|
|
22
23
|
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/c-time/frelio.git",
|
|
30
|
+
"directory": "packages/data-json"
|
|
31
|
+
},
|
|
23
32
|
"keywords": [
|
|
24
33
|
"frelio",
|
|
25
34
|
"data-json",
|
|
@@ -29,6 +38,7 @@
|
|
|
29
38
|
],
|
|
30
39
|
"license": "MIT",
|
|
31
40
|
"devDependencies": {
|
|
41
|
+
"tsup": "^8.5.0",
|
|
32
42
|
"typescript": "^5.7.0"
|
|
33
43
|
},
|
|
34
44
|
"engines": {
|
package/README.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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
|
package/dist/guards.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
package/dist/guards.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
package/dist/guards.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/types.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|