@kokimoki/kit 1.5.0 → 1.5.2

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.
@@ -8,7 +8,7 @@ export interface KokimokiKitConfig {
8
8
  description: string;
9
9
  clientContext: any;
10
10
  }[];
11
- defaultProjectConfigPath?: string;
11
+ defaultProjectConfigPath: string;
12
12
  defaultProjectStylePath?: string;
13
13
  }
14
14
  export declare function kokimokiKitPlugin(config: KokimokiKitConfig): Plugin;
@@ -106,11 +106,11 @@ function kokimokiKitPlugin(config) {
106
106
  await promises_1.default.writeFile(".kokimoki/app-id", appId);
107
107
  }
108
108
  // Get default config
109
- let defaultProjectConfig = config.schema.parse(undefined);
110
- if (config.defaultProjectConfigPath) {
111
- const defaultProjectConfigFile = await promises_1.default.readFile(config.defaultProjectConfigPath, "utf8");
112
- defaultProjectConfig = yaml.parse(defaultProjectConfigFile);
113
- }
109
+ // let defaultProjectConfig = config.schema.parse(undefined);
110
+ // if (config.defaultProjectConfigPath) {
111
+ const defaultProjectConfigFile = await promises_1.default.readFile(config.defaultProjectConfigPath, "utf8");
112
+ const defaultProjectConfig = config.schema.parse(yaml.parse(defaultProjectConfigFile));
113
+ // }
114
114
  // Inject the app id into the index.html
115
115
  html = html.replace("<head>", `<head>
116
116
  <script id="kokimoki-env" type="application/json">
@@ -144,12 +144,17 @@ function kokimokiKitPlugin(config) {
144
144
  }, null, 2));
145
145
  // write schema
146
146
  const jsonSchema = (0, zod_to_json_schema_1.default)(config.schema);
147
- const defaultJsonSchemaValue = config.schema.parse(undefined);
148
147
  await promises_1.default.writeFile(".kokimoki/schema.json", JSON.stringify(jsonSchema, null, 2));
149
- // write schema defaults as json
150
- await promises_1.default.writeFile(".kokimoki/schema-defaults.json", JSON.stringify(defaultJsonSchemaValue, null, 2));
151
- // write schema defaults as yaml
152
- await promises_1.default.writeFile(".kokimoki/schema-defaults.yaml", yaml.stringify(defaultJsonSchemaValue));
148
+ // // write schema defaults as json
149
+ // await fs.writeFile(
150
+ // ".kokimoki/schema-defaults.json",
151
+ // JSON.stringify(defaultJsonSchemaValue, null, 2)
152
+ // );
153
+ // // write schema defaults as yaml
154
+ // await fs.writeFile(
155
+ // ".kokimoki/schema-defaults.yaml",
156
+ // yaml.stringify(defaultJsonSchemaValue)
157
+ // );
153
158
  },
154
159
  configureServer(server) {
155
160
  // reload when defaultProjectConfigPath or defaultProjectStylePath changes
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const KOKIMOKI_KIT_VERSION = "1.5.0";
1
+ export declare const KOKIMOKI_KIT_VERSION = "1.5.2";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KOKIMOKI_KIT_VERSION = void 0;
4
- exports.KOKIMOKI_KIT_VERSION = "1.5.0";
4
+ exports.KOKIMOKI_KIT_VERSION = "1.5.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokimoki/kit",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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
- }
@@ -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;