nuxt-google-sheets-import 0.1.4 → 0.1.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.
- package/README.md +19 -25
- package/dist/module.d.mts +0 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +18 -18
- package/dist/runtime/components/GoogleSheetsImportExecute.vue +3 -0
- package/dist/runtime/components/GoogleSheetsImportSchemaGuide.vue +1 -0
- package/dist/runtime/components/GoogleSheetsImportSource.vue +3 -0
- package/dist/runtime/server/api/collection-type.get.js +1 -2
- package/dist/runtime/server/api/schema-columns.get.js +5 -6
- package/dist/runtime/server/api/values.post.js +2 -3
- package/dist/runtime/server/api/write.post.js +2 -3
- package/dist/runtime/server/utils/collectionType.d.ts +1 -1
- package/dist/runtime/server/utils/collectionType.js +39 -30
- package/dist/runtime/server/utils/schemaColumns.js +5 -2
- package/package.json +1 -1
- package/dist/runtime/import/schemas.d.ts +0 -67
- package/dist/runtime/import/schemas.js +0 -35
package/README.md
CHANGED
|
@@ -29,17 +29,13 @@ export default defineNuxtConfig({
|
|
|
29
29
|
googleSheetsImport: {
|
|
30
30
|
apiBase: '/api/google-sheets-import',
|
|
31
31
|
googleApiKeyRuntimeKey: 'googleApiKey',
|
|
32
|
-
|
|
33
|
-
schemaRegistryExport: 'schemas',
|
|
34
|
-
defaultContentDir: 'content',
|
|
35
|
-
collectionTypeBySchema: {
|
|
36
|
-
machines: 'page',
|
|
37
|
-
materials: 'data'
|
|
38
|
-
}
|
|
32
|
+
defaultContentDir: 'content'
|
|
39
33
|
}
|
|
40
34
|
})
|
|
41
35
|
```
|
|
42
36
|
|
|
37
|
+
Collection type (`page` vs `data`) is derived from your Nuxt Content `content.config.ts` collection definitions.
|
|
38
|
+
|
|
43
39
|
## Environment
|
|
44
40
|
|
|
45
41
|
```bash
|
|
@@ -126,6 +122,7 @@ Benefits:
|
|
|
126
122
|
|
|
127
123
|
- Reduces import failures by giving editors exact header names before filling a sheet
|
|
128
124
|
- Supports nested/array header patterns used by schema mapping (for example `items[0].name`)
|
|
125
|
+
- Uses a single column for arrays of scalar values (for example `tags` with `foo, bar, baz`)
|
|
129
126
|
- For `page` collections, shows Nuxt Content built-in page override fields and allows copying them separately
|
|
130
127
|
- Supports two copy modes:
|
|
131
128
|
- line-by-line copy
|
|
@@ -135,14 +132,23 @@ Optional prop:
|
|
|
135
132
|
|
|
136
133
|
- `initialSchema?: string`
|
|
137
134
|
|
|
138
|
-
|
|
135
|
+
### Suggested Cell Examples
|
|
136
|
+
|
|
137
|
+
Use these value patterns when filling sheets:
|
|
138
|
+
|
|
139
|
+
- `string`: `example text`
|
|
140
|
+
- `number`: `123`
|
|
141
|
+
- `boolean`: `true` or `false`
|
|
142
|
+
- `enum` / `literal`: use one of the schema's allowed values
|
|
143
|
+
- `date-like string`: `2026-01-01`
|
|
144
|
+
- `string[]` (scalar array): `foo, bar, baz` in a single cell
|
|
145
|
+
- `object[]` (array of objects): use indexed headers like `items[0].name`, `items[0].price`
|
|
139
146
|
|
|
140
|
-
|
|
147
|
+
## Schema source
|
|
141
148
|
|
|
142
|
-
-
|
|
143
|
-
- `schemaRegistryExport` (default: `schemas`)
|
|
149
|
+
The module resolves Zod schemas from Nuxt auto-imports using `#imports.schemas`.
|
|
144
150
|
|
|
145
|
-
|
|
151
|
+
Define a `schemas` export in `~/utils/googleSheetImportSchemas.ts`:
|
|
146
152
|
|
|
147
153
|
```ts
|
|
148
154
|
export const schemas = {
|
|
@@ -151,23 +157,11 @@ export const schemas = {
|
|
|
151
157
|
}
|
|
152
158
|
```
|
|
153
159
|
|
|
154
|
-
If your schemas are exported from a custom file, point the module to it:
|
|
155
|
-
|
|
156
|
-
```ts
|
|
157
|
-
export default defineNuxtConfig({
|
|
158
|
-
modules: ['@tribeweb/nuxt-google-sheets-import'],
|
|
159
|
-
googleSheetsImport: {
|
|
160
|
-
schemaRegistryImport: '~/server/google-sheets/schemas',
|
|
161
|
-
schemaRegistryExport: 'schemas'
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
```
|
|
165
|
-
|
|
166
160
|
## Playground smoke test (`values` + `write`)
|
|
167
161
|
|
|
168
162
|
The playground includes:
|
|
169
163
|
|
|
170
|
-
- `playground/
|
|
164
|
+
- `playground/utils/googleSheetImportSchemas.ts` (tiny local schema registry)
|
|
171
165
|
- `POST /api/google-sheets-import/values-smoke` (local transform/validation payload)
|
|
172
166
|
- `playground/scripts/smoke.mjs` (calls `values-smoke`, then module `write` for `frontmatter`, `json`, `yaml`)
|
|
173
167
|
|
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, extendPages, addServerHandler, addImportsDir, addComponentsDir, addImports } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, extendPages, addServerHandler, addImportsDir, addComponentsDir, addImports, addServerImports } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
@@ -13,32 +13,20 @@ const module$1 = defineNuxtModule({
|
|
|
13
13
|
defaults: {
|
|
14
14
|
apiBase: "/api/google-sheets-import",
|
|
15
15
|
googleApiKeyRuntimeKey: "googleApiKey",
|
|
16
|
-
defaultContentDir: "content/data"
|
|
17
|
-
collectionTypeBySchema: {}
|
|
18
|
-
// schemaRegistryImport: '#imports',
|
|
19
|
-
// schemaRegistryExport: 'schemas',
|
|
16
|
+
defaultContentDir: "content/data"
|
|
20
17
|
},
|
|
21
18
|
setup(options, nuxt) {
|
|
22
19
|
const resolver = createResolver(import.meta.url);
|
|
23
|
-
const normalizedCollectionTypeBySchema = Object.entries(options.collectionTypeBySchema).reduce((acc, [key, value]) => {
|
|
24
|
-
const trimmed = key.trim();
|
|
25
|
-
acc[trimmed] = value;
|
|
26
|
-
acc[trimmed.toLowerCase()] = value;
|
|
27
|
-
acc[trimmed.replace(/[-\s]+/g, "_").toLowerCase()] = value;
|
|
28
|
-
return acc;
|
|
29
|
-
}, {});
|
|
30
20
|
nuxt.options.runtimeConfig.googleSheetsImport = {
|
|
21
|
+
...nuxt.options.runtimeConfig.googleSheetsImport,
|
|
31
22
|
apiBase: options.apiBase,
|
|
32
23
|
googleApiKeyRuntimeKey: options.googleApiKeyRuntimeKey,
|
|
33
|
-
defaultContentDir: options.defaultContentDir
|
|
34
|
-
collectionTypeBySchema: normalizedCollectionTypeBySchema
|
|
35
|
-
// schemaRegistryImport: options.schemaRegistryImport,
|
|
36
|
-
// schemaRegistryExport: options.schemaRegistryExport,
|
|
24
|
+
defaultContentDir: options.defaultContentDir
|
|
37
25
|
};
|
|
38
26
|
nuxt.options.runtimeConfig.public.googleSheetsImport = {
|
|
27
|
+
...nuxt.options.runtimeConfig.public.googleSheetsImport,
|
|
39
28
|
apiBase: options.apiBase,
|
|
40
|
-
defaultContentDir: options.defaultContentDir
|
|
41
|
-
collectionTypeBySchema: normalizedCollectionTypeBySchema
|
|
29
|
+
defaultContentDir: options.defaultContentDir
|
|
42
30
|
};
|
|
43
31
|
nuxt.options.css.push(resolver.resolve("./runtime/assets/css/main.css"));
|
|
44
32
|
extendPages((pages) => {
|
|
@@ -78,6 +66,11 @@ const module$1 = defineNuxtModule({
|
|
|
78
66
|
path: resolver.resolve("./runtime/components")
|
|
79
67
|
});
|
|
80
68
|
addImports([
|
|
69
|
+
{
|
|
70
|
+
from: "~/utils/googleSheetImportSchemas",
|
|
71
|
+
name: "schemas",
|
|
72
|
+
as: "googleSheetsImportSchemas"
|
|
73
|
+
},
|
|
81
74
|
{
|
|
82
75
|
from: resolver.resolve("./runtime/types/googleSheetsApi"),
|
|
83
76
|
name: "GoogleSheetsApiValues",
|
|
@@ -109,6 +102,13 @@ const module$1 = defineNuxtModule({
|
|
|
109
102
|
type: true
|
|
110
103
|
}
|
|
111
104
|
]);
|
|
105
|
+
addServerImports([
|
|
106
|
+
{
|
|
107
|
+
from: "~/utils/googleSheetImportSchemas",
|
|
108
|
+
name: "schemas",
|
|
109
|
+
as: "googleSheetsImportSchemas"
|
|
110
|
+
}
|
|
111
|
+
]);
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, onMounted, ref, watch } from "vue";
|
|
3
|
+
import { useToast } from "#imports";
|
|
3
4
|
import { useGoogleSheetsImport } from "../composables/useGoogleSheetsImport";
|
|
4
5
|
const props = defineProps({
|
|
5
6
|
initialSchema: { type: String, required: false, default: "" }
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { useGoogleSheetsImportWorkflow } from "../composables/useGoogleSheetsImportWorkflow";
|
|
4
|
+
import { useToast } from "#imports";
|
|
5
|
+
import { watch } from "vue";
|
|
3
6
|
const { googleSheets } = defineProps({
|
|
4
7
|
googleSheets: { type: Array, required: true }
|
|
5
8
|
});
|
|
@@ -9,8 +9,7 @@ export default defineEventHandler(async (event) => {
|
|
|
9
9
|
const { schema } = await getValidatedQuery(event, (query) => querySchema.parse(query));
|
|
10
10
|
const config = useRuntimeConfig(event);
|
|
11
11
|
const moduleConfig = config.googleSheetsImport;
|
|
12
|
-
const
|
|
13
|
-
const collectionType = await resolveCollectionTypeBySchema(schema, fromConfig);
|
|
12
|
+
const collectionType = await resolveCollectionTypeBySchema(schema);
|
|
14
13
|
const baseContentDir = collectionType === "page" ? "content" : collectionType === "data" ? "content/data" : moduleConfig.defaultContentDir;
|
|
15
14
|
return {
|
|
16
15
|
schema: schema ?? null,
|
|
@@ -2,15 +2,13 @@ import { z } from "zod";
|
|
|
2
2
|
import { resolveCollectionTypeBySchema } from "../utils/collectionType.js";
|
|
3
3
|
import { getSchemaColumns, PAGE_SCHEMA_OVERRIDE_COLUMNS } from "../utils/schemaColumns.js";
|
|
4
4
|
import { getValidatedQuery, defineEventHandler, createError } from "h3";
|
|
5
|
-
import {
|
|
5
|
+
import { googleSheetsImportSchemas } from "#imports";
|
|
6
6
|
const querySchema = z.object({
|
|
7
7
|
schema: z.string().optional()
|
|
8
8
|
});
|
|
9
9
|
export default defineEventHandler(async (event) => {
|
|
10
10
|
const { schema } = await getValidatedQuery(event, (query) => querySchema.parse(query));
|
|
11
|
-
const
|
|
12
|
-
const moduleConfig = config.googleSheetsImport;
|
|
13
|
-
const schemaMap = {};
|
|
11
|
+
const schemaMap = googleSheetsImportSchemas ?? {};
|
|
14
12
|
const availableSchemas = Object.keys(schemaMap).sort((left, right) => left.localeCompare(right));
|
|
15
13
|
if (!schema) {
|
|
16
14
|
return {
|
|
@@ -21,7 +19,7 @@ export default defineEventHandler(async (event) => {
|
|
|
21
19
|
pageOverrideColumns: []
|
|
22
20
|
};
|
|
23
21
|
}
|
|
24
|
-
const collectionType = await resolveCollectionTypeBySchema(schema
|
|
22
|
+
const collectionType = await resolveCollectionTypeBySchema(schema);
|
|
25
23
|
const selectedSchema = schemaMap[schema];
|
|
26
24
|
if (!selectedSchema) {
|
|
27
25
|
throw createError({
|
|
@@ -29,10 +27,11 @@ export default defineEventHandler(async (event) => {
|
|
|
29
27
|
statusMessage: `Unknown schema: ${schema}`
|
|
30
28
|
});
|
|
31
29
|
}
|
|
30
|
+
const columns = getSchemaColumns(selectedSchema);
|
|
32
31
|
return {
|
|
33
32
|
schema,
|
|
34
33
|
schemas: availableSchemas,
|
|
35
|
-
columns
|
|
34
|
+
columns,
|
|
36
35
|
collectionType,
|
|
37
36
|
pageOverrideColumns: collectionType === "page" ? PAGE_SCHEMA_OVERRIDE_COLUMNS : []
|
|
38
37
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { transformAndValidateRows } from "../utils/transform.js";
|
|
3
3
|
import { readBody, defineEventHandler, createError } from "h3";
|
|
4
|
-
import { useRuntimeConfig } from "#imports";
|
|
5
|
-
import { schemas } from "../../import/schemas.js";
|
|
4
|
+
import { useRuntimeConfig, googleSheetsImportSchemas } from "#imports";
|
|
6
5
|
const bodySchema = z.object({
|
|
7
6
|
spreadsheetId: z.string().length(44),
|
|
8
7
|
sheetTitle: z.string().min(1),
|
|
@@ -19,7 +18,7 @@ export default defineEventHandler(async (event) => {
|
|
|
19
18
|
const encodedRange = encodeURIComponent(`${body.sheetTitle}!${body.range}`);
|
|
20
19
|
const googleResponse = await $fetch(`https://sheets.googleapis.com/v4/spreadsheets/${body.spreadsheetId}/values/${encodedRange}?key=${apiKey}`);
|
|
21
20
|
const values = googleResponse.values ?? [];
|
|
22
|
-
const schemaMap =
|
|
21
|
+
const schemaMap = googleSheetsImportSchemas ?? {};
|
|
23
22
|
const schema = schemaMap[body.schema];
|
|
24
23
|
if (!schema) {
|
|
25
24
|
throw createError({ statusCode: 400, statusMessage: `Unknown schema: ${body.schema}` });
|
|
@@ -25,7 +25,7 @@ function resolveContentDirByCollectionType(collectionType, schemaKey, fallback)
|
|
|
25
25
|
}
|
|
26
26
|
const normalizedSchemaKey = schemaKey.trim();
|
|
27
27
|
console.warn(
|
|
28
|
-
`[google-sheets-import] No collection type mapping found for schema "${normalizedSchemaKey}". Using fallback content directory "${fallback}".
|
|
28
|
+
`[google-sheets-import] No collection type mapping found for schema "${normalizedSchemaKey}". Using fallback content directory "${fallback}". Ensure the matching Nuxt Content collection is defined with type "page" or "data" in content.config.ts.`
|
|
29
29
|
);
|
|
30
30
|
return fallback;
|
|
31
31
|
}
|
|
@@ -33,8 +33,7 @@ export default defineEventHandler(async (event) => {
|
|
|
33
33
|
const body = bodySchema.parse(await readBody(event));
|
|
34
34
|
const config = useRuntimeConfig(event);
|
|
35
35
|
const moduleConfig = config.googleSheetsImport;
|
|
36
|
-
const
|
|
37
|
-
const resolvedCollectionType = await resolveCollectionTypeBySchema(body.schema, mappedInConfig);
|
|
36
|
+
const resolvedCollectionType = await resolveCollectionTypeBySchema(body.schema);
|
|
38
37
|
const resolvedContentDir = body.contentDir ?? resolveContentDirByCollectionType(resolvedCollectionType, body.schema, moduleConfig.defaultContentDir);
|
|
39
38
|
const logs = [];
|
|
40
39
|
const summary = {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
type CollectionType = 'page' | 'data';
|
|
2
|
-
export declare function resolveCollectionTypeBySchema(schemaKey: string | undefined
|
|
2
|
+
export declare function resolveCollectionTypeBySchema(schemaKey: string | undefined): Promise<CollectionType | 'unknown'>;
|
|
3
3
|
export {};
|
|
@@ -12,46 +12,55 @@ function setCollectionType(map, key, type) {
|
|
|
12
12
|
map[normalized] = type;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
if (cachedCollectionTypeBySchema) {
|
|
17
|
-
return cachedCollectionTypeBySchema;
|
|
18
|
-
}
|
|
15
|
+
function parseManifestSource(source) {
|
|
19
16
|
const result = {};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
const schemas = /* @__PURE__ */ new Set();
|
|
18
|
+
const defaultExportIndex = source.indexOf("export default");
|
|
19
|
+
const manifestCollectionsSource = defaultExportIndex === -1 ? source : source.slice(defaultExportIndex);
|
|
20
|
+
const collectionTypeMatches = manifestCollectionsSource.matchAll(/"([^"\n]+)"\s*:\s*\{[\s\S]{0,500}?"type"\s*:\s*"(page|data)"/g);
|
|
21
|
+
for (const match of collectionTypeMatches) {
|
|
22
|
+
const collectionName = match[1];
|
|
23
|
+
const collectionType = match[2];
|
|
24
|
+
if (collectionName) {
|
|
25
|
+
schemas.add(collectionName);
|
|
26
|
+
setCollectionType(result, collectionName, collectionType);
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
collectionTypeBySchema: result,
|
|
31
|
+
schemas: Array.from(schemas).sort((left, right) => left.localeCompare(right))
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function readManifestData() {
|
|
35
|
+
const candidates = [
|
|
36
|
+
path.resolve(process.cwd(), ".nuxt/content/manifest.ts"),
|
|
37
|
+
path.resolve(process.cwd(), ".nuxt/content/manifest.mjs")
|
|
38
|
+
];
|
|
39
|
+
for (const manifestPath of candidates) {
|
|
40
|
+
try {
|
|
41
|
+
const source = await readFile(manifestPath, "utf-8");
|
|
42
|
+
return parseManifestSource(source);
|
|
43
|
+
} catch {
|
|
38
44
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
collectionTypeBySchema: {},
|
|
48
|
+
schemas: []
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async function readCollectionTypeBySchema() {
|
|
52
|
+
if (cachedCollectionTypeBySchema) {
|
|
41
53
|
return cachedCollectionTypeBySchema;
|
|
42
54
|
}
|
|
43
|
-
|
|
55
|
+
const fromManifest = await readManifestData();
|
|
56
|
+
cachedCollectionTypeBySchema = fromManifest.collectionTypeBySchema;
|
|
44
57
|
return cachedCollectionTypeBySchema;
|
|
45
58
|
}
|
|
46
|
-
export async function resolveCollectionTypeBySchema(schemaKey
|
|
59
|
+
export async function resolveCollectionTypeBySchema(schemaKey) {
|
|
47
60
|
if (!schemaKey) {
|
|
48
61
|
return "unknown";
|
|
49
62
|
}
|
|
50
|
-
const
|
|
51
|
-
const map = {
|
|
52
|
-
...mappedInContentConfig,
|
|
53
|
-
...collectionTypeBySchemaFromConfig
|
|
54
|
-
};
|
|
63
|
+
const map = await readCollectionTypeBySchema();
|
|
55
64
|
const normalizedSchemaKey = schemaKey.trim();
|
|
56
65
|
const collectionType = normalizeSchemaKey(normalizedSchemaKey).map((key) => map[key]).find((value) => value === "page" || value === "data");
|
|
57
66
|
return collectionType ?? "unknown";
|
|
@@ -66,8 +66,11 @@ function collectSchemaColumns(schema, prefix = "") {
|
|
|
66
66
|
const arrayPrefix = `${prefix}[0]`;
|
|
67
67
|
const elementCandidate = getDefValue(unwrapped, "element");
|
|
68
68
|
const arrayElement = isZodType(elementCandidate) ? elementCandidate : null;
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
if (arrayElement && getObjectShape(arrayElement)) {
|
|
70
|
+
const nested = collectSchemaColumns(arrayElement, arrayPrefix);
|
|
71
|
+
return nested.length ? nested : [arrayPrefix];
|
|
72
|
+
}
|
|
73
|
+
return prefix ? [prefix] : [arrayPrefix];
|
|
71
74
|
}
|
|
72
75
|
const objectShape = getObjectShape(unwrapped);
|
|
73
76
|
if (objectShape) {
|
package/package.json
CHANGED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const machinesSmoke: z.ZodObject<{
|
|
3
|
-
pageOrder: z.ZodNumber;
|
|
4
|
-
modelId: z.ZodString;
|
|
5
|
-
machineName: z.ZodString;
|
|
6
|
-
cutRate: z.ZodNumber;
|
|
7
|
-
featurePrimary: z.ZodOptional<z.ZodString>;
|
|
8
|
-
}, z.core.$strip>;
|
|
9
|
-
export declare const example: z.ZodObject<{
|
|
10
|
-
slug: z.ZodString;
|
|
11
|
-
pageOrder: z.ZodCoercedNumber<unknown>;
|
|
12
|
-
number: z.ZodCoercedNumber<unknown>;
|
|
13
|
-
string: z.ZodString;
|
|
14
|
-
enumString: z.ZodEnum<{
|
|
15
|
-
foo: "foo";
|
|
16
|
-
bar: "bar";
|
|
17
|
-
baz: "baz";
|
|
18
|
-
}>;
|
|
19
|
-
literalString: z.ZodLiteral<"foo">;
|
|
20
|
-
unionString: z.ZodUnion<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>;
|
|
21
|
-
unionStringArray: z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>>;
|
|
22
|
-
exclusiveUnionString: z.ZodXor<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>;
|
|
23
|
-
stringArray: z.ZodArray<z.ZodString>;
|
|
24
|
-
boolean: z.ZodCoercedBoolean<unknown>;
|
|
25
|
-
object: z.ZodObject<{
|
|
26
|
-
key1: z.ZodString;
|
|
27
|
-
key2: z.ZodString;
|
|
28
|
-
}, z.core.$strip>;
|
|
29
|
-
objectArray: z.ZodArray<z.ZodObject<{
|
|
30
|
-
keyA: z.ZodString;
|
|
31
|
-
keyB: z.ZodString;
|
|
32
|
-
}, z.core.$strip>>;
|
|
33
|
-
}, z.core.$strip>;
|
|
34
|
-
export declare const schemas: {
|
|
35
|
-
machinesSmoke: z.ZodObject<{
|
|
36
|
-
pageOrder: z.ZodNumber;
|
|
37
|
-
modelId: z.ZodString;
|
|
38
|
-
machineName: z.ZodString;
|
|
39
|
-
cutRate: z.ZodNumber;
|
|
40
|
-
featurePrimary: z.ZodOptional<z.ZodString>;
|
|
41
|
-
}, z.core.$strip>;
|
|
42
|
-
example: z.ZodObject<{
|
|
43
|
-
slug: z.ZodString;
|
|
44
|
-
pageOrder: z.ZodCoercedNumber<unknown>;
|
|
45
|
-
number: z.ZodCoercedNumber<unknown>;
|
|
46
|
-
string: z.ZodString;
|
|
47
|
-
enumString: z.ZodEnum<{
|
|
48
|
-
foo: "foo";
|
|
49
|
-
bar: "bar";
|
|
50
|
-
baz: "baz";
|
|
51
|
-
}>;
|
|
52
|
-
literalString: z.ZodLiteral<"foo">;
|
|
53
|
-
unionString: z.ZodUnion<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>;
|
|
54
|
-
unionStringArray: z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>>;
|
|
55
|
-
exclusiveUnionString: z.ZodXor<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>;
|
|
56
|
-
stringArray: z.ZodArray<z.ZodString>;
|
|
57
|
-
boolean: z.ZodCoercedBoolean<unknown>;
|
|
58
|
-
object: z.ZodObject<{
|
|
59
|
-
key1: z.ZodString;
|
|
60
|
-
key2: z.ZodString;
|
|
61
|
-
}, z.core.$strip>;
|
|
62
|
-
objectArray: z.ZodArray<z.ZodObject<{
|
|
63
|
-
keyA: z.ZodString;
|
|
64
|
-
keyB: z.ZodString;
|
|
65
|
-
}, z.core.$strip>>;
|
|
66
|
-
}, z.core.$strip>;
|
|
67
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const machinesSmoke = z.object({
|
|
3
|
-
pageOrder: z.number(),
|
|
4
|
-
modelId: z.string().min(1),
|
|
5
|
-
machineName: z.string().min(1),
|
|
6
|
-
cutRate: z.number(),
|
|
7
|
-
featurePrimary: z.string().optional()
|
|
8
|
-
});
|
|
9
|
-
export const example = z.object({
|
|
10
|
-
slug: z.string().min(1).max(100),
|
|
11
|
-
pageOrder: z.coerce.number().int(),
|
|
12
|
-
number: z.coerce.number(),
|
|
13
|
-
string: z.string().min(1).max(100),
|
|
14
|
-
enumString: z.enum(["foo", "bar", "baz"]),
|
|
15
|
-
literalString: z.literal("foo"),
|
|
16
|
-
unionString: z.union([z.literal("foo"), z.literal("bar")]),
|
|
17
|
-
unionStringArray: z.union([z.literal("foo"), z.literal("bar")]).array(),
|
|
18
|
-
exclusiveUnionString: z.xor([z.literal("foo"), z.literal("bar")]),
|
|
19
|
-
stringArray: z.string().array(),
|
|
20
|
-
boolean: z.coerce.boolean(),
|
|
21
|
-
object: z.object({
|
|
22
|
-
key1: z.string().min(1),
|
|
23
|
-
key2: z.string().min(1)
|
|
24
|
-
}),
|
|
25
|
-
objectArray: z.array(
|
|
26
|
-
z.object({
|
|
27
|
-
keyA: z.string().min(1),
|
|
28
|
-
keyB: z.string().min(1)
|
|
29
|
-
})
|
|
30
|
-
)
|
|
31
|
-
});
|
|
32
|
-
export const schemas = {
|
|
33
|
-
machinesSmoke,
|
|
34
|
-
example
|
|
35
|
-
};
|