@kokimoki/kit 1.5.1 → 1.6.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/kokimoki-kit-plugin.d.ts +2 -2
- package/dist/kokimoki-kit-plugin.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/dist/schema-builder.d.ts +0 -95
- package/dist/schema-builder.js +0 -166
@@ -1,8 +1,8 @@
|
|
1
1
|
import type { Plugin } from "vite";
|
2
|
-
import {
|
2
|
+
import { ZodAny } from "zod/v4";
|
3
3
|
export interface KokimokiKitConfig {
|
4
4
|
conceptId: string;
|
5
|
-
schema:
|
5
|
+
schema: ZodAny;
|
6
6
|
deployCodes: {
|
7
7
|
name: string;
|
8
8
|
description: string;
|
@@ -32,7 +32,7 @@ const promises_1 = __importDefault(require("fs/promises"));
|
|
32
32
|
const preprocess_style_1 = require("./preprocess-style");
|
33
33
|
const version_1 = require("./version");
|
34
34
|
const yaml = __importStar(require("yaml"));
|
35
|
-
const
|
35
|
+
const v4_1 = require("zod/v4");
|
36
36
|
function kokimokiKitPlugin(config) {
|
37
37
|
return {
|
38
38
|
name: "kokimoki-kit",
|
@@ -109,7 +109,7 @@ function kokimokiKitPlugin(config) {
|
|
109
109
|
// let defaultProjectConfig = config.schema.parse(undefined);
|
110
110
|
// if (config.defaultProjectConfigPath) {
|
111
111
|
const defaultProjectConfigFile = await promises_1.default.readFile(config.defaultProjectConfigPath, "utf8");
|
112
|
-
const defaultProjectConfig = yaml.parse(defaultProjectConfigFile);
|
112
|
+
const defaultProjectConfig = config.schema.parse(yaml.parse(defaultProjectConfigFile));
|
113
113
|
// }
|
114
114
|
// Inject the app id into the index.html
|
115
115
|
html = html.replace("<head>", `<head>
|
@@ -143,7 +143,7 @@ function kokimokiKitPlugin(config) {
|
|
143
143
|
defaultProjectStylePath: config.defaultProjectStylePath,
|
144
144
|
}, null, 2));
|
145
145
|
// write schema
|
146
|
-
const jsonSchema =
|
146
|
+
const jsonSchema = v4_1.z.toJSONSchema(config.schema);
|
147
147
|
await promises_1.default.writeFile(".kokimoki/schema.json", JSON.stringify(jsonSchema, null, 2));
|
148
148
|
// // write schema defaults as json
|
149
149
|
// await fs.writeFile(
|
package/dist/version.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const KOKIMOKI_KIT_VERSION = "1.
|
1
|
+
export declare const KOKIMOKI_KIT_VERSION = "1.6.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@kokimoki/kit",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.6.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -26,8 +26,7 @@
|
|
26
26
|
"colorjs.io": "^0.5.2",
|
27
27
|
"colornames": "^1.1.1",
|
28
28
|
"yaml": "^2.7.0",
|
29
|
-
"zod": "^3.
|
30
|
-
"zod-to-json-schema": "^3.24.5"
|
29
|
+
"zod": "^3.25.30"
|
31
30
|
},
|
32
31
|
"peerDependencies": {
|
33
32
|
"vite": ">=5"
|
package/dist/schema-builder.d.ts
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
export interface FieldOptions {
|
2
|
-
label?: string;
|
3
|
-
}
|
4
|
-
export declare abstract class Field<T> {
|
5
|
-
readonly options: FieldOptions;
|
6
|
-
constructor(options: FieldOptions);
|
7
|
-
abstract get value(): T;
|
8
|
-
abstract get schema(): any;
|
9
|
-
}
|
10
|
-
export declare class BooleanField extends Field<boolean> {
|
11
|
-
value: boolean;
|
12
|
-
constructor(value: boolean, options?: FieldOptions);
|
13
|
-
get schema(): {
|
14
|
-
type: string;
|
15
|
-
default: boolean;
|
16
|
-
};
|
17
|
-
}
|
18
|
-
export declare class ConstField<T extends string> extends Field<string extends T ? never : T> {
|
19
|
-
value: string extends T ? never : T;
|
20
|
-
constructor(value: string extends T ? never : T, options?: FieldOptions);
|
21
|
-
get schema(): {
|
22
|
-
const: string extends T ? never : T;
|
23
|
-
};
|
24
|
-
}
|
25
|
-
export declare class ImageField extends Field<string> {
|
26
|
-
value: string;
|
27
|
-
constructor(value: string, options?: FieldOptions);
|
28
|
-
get schema(): {
|
29
|
-
type: string;
|
30
|
-
default: string;
|
31
|
-
};
|
32
|
-
}
|
33
|
-
export declare class TextField extends Field<string> {
|
34
|
-
value: string;
|
35
|
-
constructor(value: string, options?: FieldOptions);
|
36
|
-
get schema(): {
|
37
|
-
type: string;
|
38
|
-
default: string;
|
39
|
-
};
|
40
|
-
}
|
41
|
-
export declare class EnumField<T extends Record<string, string>> extends Field<keyof T> {
|
42
|
-
enumValues: T;
|
43
|
-
value: keyof T;
|
44
|
-
constructor(enumValues: T, value: keyof T, options?: FieldOptions);
|
45
|
-
get schema(): {
|
46
|
-
enum: string[];
|
47
|
-
};
|
48
|
-
}
|
49
|
-
export declare class IntegerField extends Field<number> {
|
50
|
-
value: number;
|
51
|
-
constructor(value: number, options?: FieldOptions);
|
52
|
-
get schema(): {
|
53
|
-
type: string;
|
54
|
-
default: number;
|
55
|
-
};
|
56
|
-
}
|
57
|
-
export declare class FloatField extends Field<number> {
|
58
|
-
value: number;
|
59
|
-
constructor(value: number, options?: FieldOptions);
|
60
|
-
get schema(): {
|
61
|
-
type: string;
|
62
|
-
default: number;
|
63
|
-
};
|
64
|
-
}
|
65
|
-
export declare class FormGroup<T extends Record<string, Field<any>>, O extends Record<string, Field<any>>> extends Field<{
|
66
|
-
[key in keyof T]: T[key]["value"];
|
67
|
-
} & Partial<{
|
68
|
-
[key in keyof O]: O[key]["value"];
|
69
|
-
}>> {
|
70
|
-
requiredFields: T;
|
71
|
-
optionalFields: O;
|
72
|
-
constructor(requiredFields: T, optionalFields?: O, options?: FieldOptions);
|
73
|
-
get value(): {
|
74
|
-
[key in keyof T]: T[key]["value"];
|
75
|
-
} & Partial<{
|
76
|
-
[key in keyof O]: O[key]["value"];
|
77
|
-
}>;
|
78
|
-
get schema(): {
|
79
|
-
type: string;
|
80
|
-
properties: any;
|
81
|
-
required: string[];
|
82
|
-
};
|
83
|
-
}
|
84
|
-
export declare class FormArray<T> extends Field<T[]> {
|
85
|
-
private factory;
|
86
|
-
value: Field<T>["value"][];
|
87
|
-
constructor(factory: () => Field<T>, value: Field<T>["value"][], options?: FieldOptions);
|
88
|
-
get schema(): {
|
89
|
-
type: string;
|
90
|
-
items: any;
|
91
|
-
default: T[];
|
92
|
-
};
|
93
|
-
}
|
94
|
-
export declare class Form<R extends Record<string, Field<any>>, O extends Record<string, Field<any>>> extends FormGroup<R, O> {
|
95
|
-
}
|
package/dist/schema-builder.js
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Form = exports.FormArray = exports.FormGroup = exports.FloatField = exports.IntegerField = exports.EnumField = exports.TextField = exports.ImageField = exports.ConstField = exports.BooleanField = exports.Field = void 0;
|
4
|
-
const defaultFieldOptions = {};
|
5
|
-
class Field {
|
6
|
-
options;
|
7
|
-
constructor(options) {
|
8
|
-
this.options = options;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
exports.Field = Field;
|
12
|
-
class BooleanField extends Field {
|
13
|
-
value;
|
14
|
-
constructor(value, options = defaultFieldOptions) {
|
15
|
-
super(options);
|
16
|
-
this.value = value;
|
17
|
-
}
|
18
|
-
get schema() {
|
19
|
-
return {
|
20
|
-
type: "boolean",
|
21
|
-
default: this.value,
|
22
|
-
};
|
23
|
-
}
|
24
|
-
}
|
25
|
-
exports.BooleanField = BooleanField;
|
26
|
-
class ConstField extends Field {
|
27
|
-
value;
|
28
|
-
constructor(value, options = defaultFieldOptions) {
|
29
|
-
super(options);
|
30
|
-
this.value = value;
|
31
|
-
}
|
32
|
-
get schema() {
|
33
|
-
return {
|
34
|
-
const: this.value,
|
35
|
-
};
|
36
|
-
}
|
37
|
-
}
|
38
|
-
exports.ConstField = ConstField;
|
39
|
-
class ImageField extends Field {
|
40
|
-
value;
|
41
|
-
constructor(value, options = defaultFieldOptions) {
|
42
|
-
super(options);
|
43
|
-
this.value = value;
|
44
|
-
}
|
45
|
-
get schema() {
|
46
|
-
return {
|
47
|
-
type: "string",
|
48
|
-
default: this.value,
|
49
|
-
};
|
50
|
-
}
|
51
|
-
}
|
52
|
-
exports.ImageField = ImageField;
|
53
|
-
class TextField extends Field {
|
54
|
-
value;
|
55
|
-
constructor(value, options = defaultFieldOptions) {
|
56
|
-
super(options);
|
57
|
-
this.value = value;
|
58
|
-
}
|
59
|
-
get schema() {
|
60
|
-
return {
|
61
|
-
type: "string",
|
62
|
-
default: this.value,
|
63
|
-
};
|
64
|
-
}
|
65
|
-
}
|
66
|
-
exports.TextField = TextField;
|
67
|
-
class EnumField extends Field {
|
68
|
-
enumValues;
|
69
|
-
value;
|
70
|
-
constructor(enumValues, value, options = defaultFieldOptions) {
|
71
|
-
super(options);
|
72
|
-
this.enumValues = enumValues;
|
73
|
-
this.value = value;
|
74
|
-
}
|
75
|
-
get schema() {
|
76
|
-
return {
|
77
|
-
enum: Object.keys(this.enumValues),
|
78
|
-
};
|
79
|
-
}
|
80
|
-
}
|
81
|
-
exports.EnumField = EnumField;
|
82
|
-
class IntegerField extends Field {
|
83
|
-
value;
|
84
|
-
constructor(value, options = defaultFieldOptions) {
|
85
|
-
super(options);
|
86
|
-
this.value = value;
|
87
|
-
}
|
88
|
-
get schema() {
|
89
|
-
return {
|
90
|
-
type: "integer",
|
91
|
-
default: this.value,
|
92
|
-
};
|
93
|
-
}
|
94
|
-
}
|
95
|
-
exports.IntegerField = IntegerField;
|
96
|
-
class FloatField extends Field {
|
97
|
-
value;
|
98
|
-
constructor(value, options = defaultFieldOptions) {
|
99
|
-
super(options);
|
100
|
-
this.value = value;
|
101
|
-
}
|
102
|
-
get schema() {
|
103
|
-
return {
|
104
|
-
type: "number",
|
105
|
-
default: this.value,
|
106
|
-
};
|
107
|
-
}
|
108
|
-
}
|
109
|
-
exports.FloatField = FloatField;
|
110
|
-
class FormGroup extends Field {
|
111
|
-
requiredFields;
|
112
|
-
optionalFields;
|
113
|
-
constructor(requiredFields, optionalFields = {}, options = defaultFieldOptions) {
|
114
|
-
super(options);
|
115
|
-
this.requiredFields = requiredFields;
|
116
|
-
this.optionalFields = optionalFields;
|
117
|
-
}
|
118
|
-
get value() {
|
119
|
-
const value = Object.entries(this.requiredFields).reduce((acc, [key, field]) => {
|
120
|
-
acc[key] = field.value;
|
121
|
-
return acc;
|
122
|
-
}, {});
|
123
|
-
Object.entries(this.optionalFields).forEach(([key, field]) => {
|
124
|
-
if (field.value !== undefined) {
|
125
|
-
value[key] = field.value;
|
126
|
-
}
|
127
|
-
});
|
128
|
-
return value;
|
129
|
-
}
|
130
|
-
get schema() {
|
131
|
-
const properties = {};
|
132
|
-
Object.entries(this.requiredFields).forEach(([key, field]) => {
|
133
|
-
properties[key] = field.schema;
|
134
|
-
});
|
135
|
-
Object.entries(this.optionalFields).forEach(([key, field]) => {
|
136
|
-
properties[key] = field.schema;
|
137
|
-
});
|
138
|
-
return {
|
139
|
-
type: "object",
|
140
|
-
properties,
|
141
|
-
required: Object.keys(this.requiredFields),
|
142
|
-
};
|
143
|
-
}
|
144
|
-
}
|
145
|
-
exports.FormGroup = FormGroup;
|
146
|
-
class FormArray extends Field {
|
147
|
-
factory;
|
148
|
-
value;
|
149
|
-
constructor(factory, value, options = defaultFieldOptions) {
|
150
|
-
super(options);
|
151
|
-
this.factory = factory;
|
152
|
-
this.value = value;
|
153
|
-
}
|
154
|
-
get schema() {
|
155
|
-
const field = this.factory();
|
156
|
-
return {
|
157
|
-
type: "array",
|
158
|
-
items: field.schema,
|
159
|
-
default: this.value,
|
160
|
-
};
|
161
|
-
}
|
162
|
-
}
|
163
|
-
exports.FormArray = FormArray;
|
164
|
-
class Form extends FormGroup {
|
165
|
-
}
|
166
|
-
exports.Form = Form;
|