@kokimoki/kit 1.6.4 → 1.6.6

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.
@@ -1,4 +1,4 @@
1
- import type { Plugin } from "vite";
1
+ import type { PluginOption } from "vite";
2
2
  import { ZodType } from "zod/v4";
3
3
  export interface KokimokiKitConfig {
4
4
  conceptId: string;
@@ -11,4 +11,4 @@ export interface KokimokiKitConfig {
11
11
  defaultProjectConfigPath: string;
12
12
  defaultProjectStylePath?: string;
13
13
  }
14
- export declare function kokimokiKitPlugin(config: KokimokiKitConfig): Plugin;
14
+ export declare function kokimokiKitPlugin(config: KokimokiKitConfig): PluginOption;
@@ -133,6 +133,16 @@ function kokimokiKitPlugin(config) {
133
133
  },
134
134
  // write kokimoki metadata to .kokimoki directory
135
135
  async generateBundle(_, _bundle) {
136
+ // Ensure .kokimoki directory exists
137
+ try {
138
+ await promises_1.default.mkdir(".kokimoki");
139
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
+ }
141
+ catch (e) {
142
+ if (e?.code !== "EEXIST") {
143
+ throw e;
144
+ }
145
+ }
136
146
  // write config
137
147
  await promises_1.default.writeFile(".kokimoki/config.json", JSON.stringify({
138
148
  kokimokiKitVersion: version_1.KOKIMOKI_KIT_VERSION,
@@ -0,0 +1,95 @@
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
+ }
@@ -0,0 +1,166 @@
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;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const KOKIMOKI_KIT_VERSION = "1.6.4";
1
+ export declare const KOKIMOKI_KIT_VERSION = "1.6.6";
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.6.4";
4
+ exports.KOKIMOKI_KIT_VERSION = "1.6.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokimoki/kit",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,8 +18,7 @@
18
18
  "@types/colornames": "^1.1.4",
19
19
  "@types/expect": "^24.3.2",
20
20
  "mocha": "^11.1.0",
21
- "ts-mocha": "^10.0.0",
22
- "vite": "^5.4.8"
21
+ "ts-mocha": "^10.0.0"
23
22
  },
24
23
  "dependencies": {
25
24
  "bson-objectid": "^2.0.4",
@@ -29,6 +28,6 @@
29
28
  "zod": "^3.25.30"
30
29
  },
31
30
  "peerDependencies": {
32
- "vite": ">=5"
31
+ "vite": ">=4 <=6"
33
32
  }
34
33
  }