@kokimoki/kit 1.4.0 → 1.5.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 CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "./kokimoki-kit-plugin";
2
2
  export * from "./preprocess-style";
3
- export * from "./schema-builder";
package/dist/index.js CHANGED
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./kokimoki-kit-plugin"), exports);
18
18
  __exportStar(require("./preprocess-style"), exports);
19
- __exportStar(require("./schema-builder"), exports);
@@ -1,14 +1,14 @@
1
1
  import type { Plugin } from "vite";
2
- import type { Form } from "./schema-builder";
2
+ import { ZodTypeAny } from "zod";
3
3
  export interface KokimokiKitConfig {
4
4
  conceptId: string;
5
- form: Form<any, any>;
5
+ schema: ZodTypeAny;
6
6
  deployCodes: {
7
7
  name: string;
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;
@@ -32,6 +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 zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
35
36
  function kokimokiKitPlugin(config) {
36
37
  return {
37
38
  name: "kokimoki-kit",
@@ -105,11 +106,11 @@ function kokimokiKitPlugin(config) {
105
106
  await promises_1.default.writeFile(".kokimoki/app-id", appId);
106
107
  }
107
108
  // Get default config
108
- let defaultProjectConfig = config.form.value;
109
- if (config.defaultProjectConfigPath) {
110
- const defaultProjectConfigFile = await promises_1.default.readFile(config.defaultProjectConfigPath, "utf8");
111
- defaultProjectConfig = yaml.parse(defaultProjectConfigFile);
112
- }
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 = yaml.parse(defaultProjectConfigFile);
113
+ // }
113
114
  // Inject the app id into the index.html
114
115
  html = html.replace("<head>", `<head>
115
116
  <script id="kokimoki-env" type="application/json">
@@ -142,11 +143,18 @@ function kokimokiKitPlugin(config) {
142
143
  defaultProjectStylePath: config.defaultProjectStylePath,
143
144
  }, null, 2));
144
145
  // write schema
145
- await promises_1.default.writeFile(".kokimoki/schema.json", JSON.stringify(config.form.schema, null, 2));
146
- // write schema defaults as json
147
- await promises_1.default.writeFile(".kokimoki/schema-defaults.json", JSON.stringify(config.form.value, null, 2));
148
- // write schema defaults as yaml
149
- await promises_1.default.writeFile(".kokimoki/schema-defaults.yaml", yaml.stringify(config.form.value));
146
+ const jsonSchema = (0, zod_to_json_schema_1.default)(config.schema);
147
+ await promises_1.default.writeFile(".kokimoki/schema.json", JSON.stringify(jsonSchema, null, 2));
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
+ // );
150
158
  },
151
159
  configureServer(server) {
152
160
  // reload when defaultProjectConfigPath or defaultProjectStylePath changes
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const KOKIMOKI_KIT_VERSION = "1.4.0";
1
+ export declare const KOKIMOKI_KIT_VERSION = "1.5.1";
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.4.0";
4
+ exports.KOKIMOKI_KIT_VERSION = "1.5.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokimoki/kit",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,7 +25,9 @@
25
25
  "bson-objectid": "^2.0.4",
26
26
  "colorjs.io": "^0.5.2",
27
27
  "colornames": "^1.1.1",
28
- "yaml": "^2.7.0"
28
+ "yaml": "^2.7.0",
29
+ "zod": "^3.24.2",
30
+ "zod-to-json-schema": "^3.24.5"
29
31
  },
30
32
  "peerDependencies": {
31
33
  "vite": ">=5"