nuxt-google-sheets-import 0.1.7 → 0.1.9

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.
Files changed (36) hide show
  1. package/README.md +35 -158
  2. package/dist/module.d.mts +4 -1
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +19 -17
  5. package/dist/runtime/{components → app/components}/GoogleSheetsImportExecute.vue +3 -3
  6. package/dist/runtime/{components → app/components}/GoogleSheetsImportExport.vue +24 -8
  7. package/dist/runtime/app/examples/googleSheetsImportSchemas.d.ts +29 -0
  8. package/dist/runtime/app/examples/googleSheetsImportSchemas.js +28 -0
  9. package/dist/runtime/{pages → app/pages}/google-sheets-import.vue +3 -4
  10. package/dist/runtime/server/api/sheets.get.js +2 -2
  11. package/dist/runtime/server/api/values.post.js +2 -2
  12. package/dist/runtime/server/utils/transform.js +1 -1
  13. package/package.json +5 -2
  14. /package/dist/runtime/{assets → app/assets}/css/main.css +0 -0
  15. /package/dist/runtime/{components → app/components}/GoogleSheetsImportExecute.d.vue.ts +0 -0
  16. /package/dist/runtime/{components → app/components}/GoogleSheetsImportExecute.vue.d.ts +0 -0
  17. /package/dist/runtime/{components → app/components}/GoogleSheetsImportExport.d.vue.ts +0 -0
  18. /package/dist/runtime/{components → app/components}/GoogleSheetsImportExport.vue.d.ts +0 -0
  19. /package/dist/runtime/{components → app/components}/GoogleSheetsImportSchemaGuide.d.vue.ts +0 -0
  20. /package/dist/runtime/{components → app/components}/GoogleSheetsImportSchemaGuide.vue +0 -0
  21. /package/dist/runtime/{components → app/components}/GoogleSheetsImportSchemaGuide.vue.d.ts +0 -0
  22. /package/dist/runtime/{components → app/components}/GoogleSheetsImportSource.d.vue.ts +0 -0
  23. /package/dist/runtime/{components → app/components}/GoogleSheetsImportSource.vue +0 -0
  24. /package/dist/runtime/{components → app/components}/GoogleSheetsImportSource.vue.d.ts +0 -0
  25. /package/dist/runtime/{composables → app/composables}/useGoogleSheetsImport.d.ts +0 -0
  26. /package/dist/runtime/{composables → app/composables}/useGoogleSheetsImport.js +0 -0
  27. /package/dist/runtime/{composables → app/composables}/useGoogleSheetsImportWorkflow.d.ts +0 -0
  28. /package/dist/runtime/{composables → app/composables}/useGoogleSheetsImportWorkflow.js +0 -0
  29. /package/dist/runtime/{pages → app/pages}/google-sheets-import.d.vue.ts +0 -0
  30. /package/dist/runtime/{pages → app/pages}/google-sheets-import.vue.d.ts +0 -0
  31. /package/dist/runtime/{utils → app/utils}/clipboard.d.ts +0 -0
  32. /package/dist/runtime/{utils → app/utils}/clipboard.js +0 -0
  33. /package/dist/runtime/{utils → app/utils}/delimited.d.ts +0 -0
  34. /package/dist/runtime/{utils → app/utils}/delimited.js +0 -0
  35. /package/dist/runtime/{utils → app/utils}/pathMapping.d.ts +0 -0
  36. /package/dist/runtime/{utils → app/utils}/pathMapping.js +0 -0
package/README.md CHANGED
@@ -1,28 +1,25 @@
1
1
  # nuxt-google-sheets-import
2
2
 
3
- Schema-driven Google Sheets importer for Nuxt Content.
3
+ Schema-driven Google Sheets import and export workflows for Nuxt Content.
4
4
 
5
- ## Status
5
+ ## Documentation
6
6
 
7
- Nuxt module for schema-driven Google Sheets import/export workflows with Nuxt Content.
7
+ Project documentation now lives in the Docus site under [docs/content](docs/content).
8
8
 
9
- ## Features
9
+ - Intro: [docs/content/1.getting-started/2.introduction.md](docs/content/1.getting-started/2.introduction.md)
10
+ - Installation: [docs/content/1.getting-started/3.installation.md](docs/content/1.getting-started/3.installation.md)
10
11
 
11
- - Fetches sheet list and values from Google Sheets
12
- - Validates/transforms rows with Zod schemas
13
- - Writes frontmatter markdown, JSON, or YAML output
14
- - Supports overwrite strategies (`overwrite`, `skip`, `overwrite-frontmatter`)
15
- - Exposes UI components and composables for import workflow
16
- - Includes a built-in `/google-sheets-import` page with tabbed setup/import/export flow
17
- - Supports TSV clipboard copy for Google Sheets-friendly paste
12
+ Use this root README as a repo quick-start and contributor guide. Keep long-form user documentation in the docs site.
18
13
 
19
- ## Install
14
+ ## Module Quick Start
15
+
16
+ Install:
20
17
 
21
18
  ```bash
22
19
  pnpm add nuxt-google-sheets-import
23
20
  ```
24
21
 
25
- ## Configuration
22
+ Enable the module:
26
23
 
27
24
  ```ts
28
25
  // nuxt.config.ts
@@ -30,86 +27,33 @@ export default defineNuxtConfig({
30
27
  modules: ['nuxt-google-sheets-import'],
31
28
  googleSheetsImport: {
32
29
  apiBase: '/api/google-sheets-import',
33
- googleApiKeyRuntimeKey: 'googleApiKey',
34
30
  defaultContentDir: 'content/data'
35
31
  }
36
32
  })
37
33
  ```
38
34
 
39
- Collection type (`page` vs `data`) is derived from your Nuxt Content `content.config.ts` collections.
40
-
41
- ## Environment
35
+ Environment:
42
36
 
43
37
  ```bash
44
38
  NUXT_GOOGLE_API_KEY=your_google_sheets_api_key
45
39
  ```
46
40
 
47
- ## Quick Start
48
-
49
- 1. Add the module and runtime env var.
50
- 2. Define your Zod `schemas` export in `~/utils/googleSheetImportSchemas.ts`.
51
- 3. Ensure matching Nuxt Content collections exist in `content.config.ts`.
52
- 4. Start dev server and open `/google-sheets-import`.
53
- 5. Use tabs in order:
54
- - `Setup Google Sheet`: confirm schema headers and copy as needed.
55
- - `Import data`: load sheet rows and write content files.
56
- - `Export data`: query existing records, copy TSV for Sheets, or download CSV.
57
-
58
- Quick endpoint check:
59
-
60
- `GET /api/google-sheets-import/sheets?spreadsheetId=<SPREADSHEET_ID>`
41
+ ## What The Module Provides
61
42
 
62
- ## Exported runtime
43
+ - A built-in route at `/google-sheets-import`
44
+ - Tabbed workflow with schema setup, import, and export steps
45
+ - Zod schema-driven row validation/transforms
46
+ - Writes to markdown frontmatter, JSON, and YAML
47
+ - Export helpers:
48
+ - copy TSV to clipboard for Google Sheets paste
49
+ - download CSV
63
50
 
64
- - Components: `GoogleSheetsImportSource`, `GoogleSheetsImportExecute`, `GoogleSheetsImportSchemaGuide`, `GoogleSheetsImportExport`
65
- - Composables: `useGoogleSheetsImport`, `useGoogleSheetsImportWorkflow`
66
-
67
- The module adds a route at `/google-sheets-import` with `UTabs` for:
68
-
69
- - `Setup Google Sheet` (schema guide)
70
- - `Import data` (sheet source/import flow)
71
- - `Export data` (export existing content records)
72
-
73
- ### Schema helper component
74
-
75
- Use `GoogleSheetsImportSchemaGuide` to let editors choose a schema and see the expected Google Sheet column headers.
76
-
77
- ```vue
78
- <GoogleSheetsImportSchemaGuide />
79
- ```
80
-
81
- Benefits:
82
-
83
- - Reduces import failures by giving editors exact header names before filling a sheet
84
- - Supports nested/array header patterns used by schema mapping (for example `items[0].name`)
85
- - Uses a single column for arrays of scalar values (for example `tags` with `foo, bar, baz`)
86
- - For `page` collections, shows Nuxt Content built-in page override fields and allows copying them separately
87
- - Supports two copy modes:
88
- - line-by-line copy
89
- - tab-separated row copy (pastes horizontally into Google Sheets)
90
-
91
- Optional prop:
92
-
93
- - `initialSchema?: string`
94
-
95
- ### Suggested Cell Examples
96
-
97
- Use these value patterns when filling sheets:
98
-
99
- - `string`: `example text`
100
- - `number`: `123`
101
- - `boolean`: `true` or `false`
102
- - `enum` / `literal`: use one of the schema's allowed values
103
- - `date-like string`: `2026-01-01`
104
- - `string[]` (scalar array): `foo, bar, baz` in a single cell
105
- - `object[]` (array of objects): use indexed headers like `items[0].name`, `items[0].price`
51
+ Collection type (`page` vs `data`) is resolved from your Nuxt Content collections.
106
52
 
107
53
  ## Schema Source
108
54
 
109
- Define a `schemas` export in `~/utils/googleSheetImportSchemas.ts`.
110
- The module auto-imports this as `googleSheetsImportSchemas` for app and server runtime use.
111
-
112
- Example:
55
+ Define and export `schemas` in `~/utils/googleSheetImportSchemas.ts`.
56
+ The module auto-imports it as `googleSheetsImportSchemas` in app and server runtime.
113
57
 
114
58
  ```ts
115
59
  export const schemas = {
@@ -118,93 +62,26 @@ export const schemas = {
118
62
  }
119
63
  ```
120
64
 
121
- ## Export Behavior
65
+ ## Repository Development
122
66
 
123
- - `Copy for Google Sheets` in `GoogleSheetsImportExport` copies **TSV** to the clipboard for reliable Sheets paste.
124
- - `Download .csv` provides quoted CSV output for file-based workflows.
67
+ Module development:
125
68
 
126
- ## Additional API Endpoint
127
-
128
- - `GET {apiBase}/schema-columns`
129
- - Query: `schema?`
130
- - Returns:
131
- - `schemas`: available schema keys
132
- - `columns`: expected import header names for selected schema
133
- - `collectionType`: `page | data | unknown`
134
- - `pageOverrideColumns`: Nuxt Content page override fields (when `collectionType === 'page'`)
135
-
136
- ## Google Setup (Permissions + API Key)
137
-
138
- This module reads Google Sheets using an API key, so the sheet must be publicly readable.
139
-
140
- > Security note:
141
- > API-key access is best suited to non-sensitive sheets that are intentionally shared as `Anyone with the link`.
142
- > For private or sensitive spreadsheets, prefer OAuth 2.0 or a service account flow instead of API-key access.
143
-
144
- ### 1) Set sheet permissions (Google Sheets)
145
-
146
- 1. Open your sheet in Google Sheets.
147
- 2. Click `Share`.
148
- 3. Under `General access`, set to `Anyone with the link`.
149
- 4. Set role to `Viewer`.
150
- 5. Copy the spreadsheet ID from the URL:
151
- - `https://docs.google.com/spreadsheets/d/<SPREADSHEET_ID>/edit`
152
-
153
- If your Google Workspace policy blocks public link sharing, API key access will fail. In that case you need OAuth/service-account based auth (not part of this module yet).
154
-
155
- ### 2) Create API key (Google Cloud Console)
156
-
157
- 1. Open Google Cloud Console: https://console.cloud.google.com/
158
- 2. Create/select a project.
159
- 3. Enable Google Sheets API:
160
- - https://console.cloud.google.com/apis/library/sheets.googleapis.com
161
- 4. Create credentials (API key):
162
- - https://console.cloud.google.com/apis/credentials
163
- - Click `Create credentials` -> `API key`
164
- 5. Restrict the key (recommended):
165
- - **API restrictions**: `Restrict key` -> select `Google Sheets API`
166
- - **Application restrictions**:
167
- - Server usage: `IP addresses` (recommended for backend)
168
- - Browser-only usage: `HTTP referrers` (if applicable)
169
- 6. Put the key into `NUXT_GOOGLE_API_KEY`.
170
-
171
- ### 3) Troubleshooting (common errors)
172
-
173
- - `403 PERMISSION_DENIED` / `The caller does not have permission`
174
- - The sheet is not publicly readable with link.
175
- - Fix: set `Share` -> `General access` -> `Anyone with the link` + `Viewer`.
176
-
177
- - `403 API key not valid` or `API has not been used in project`
178
- - The key is wrong, restricted to the wrong API, or Sheets API is not enabled.
179
- - Fix: enable `Google Sheets API` and ensure key restriction includes it.
180
-
181
- - `403 Requests from this referrer/IP are blocked`
182
- - Your key application restrictions do not match where requests come from.
183
- - Fix: update key restrictions (`IP addresses` for server use is preferred).
184
-
185
- - `404 Requested entity was not found`
186
- - Spreadsheet ID is incorrect or malformed.
187
- - Fix: copy ID from `https://docs.google.com/spreadsheets/d/<SPREADSHEET_ID>/edit`.
188
-
189
- - `400 Unable to parse range`
190
- - Invalid A1 range (for example typo in sheet tab or columns).
191
- - Fix: verify tab name and use ranges like `A:Z`.
192
-
193
- ## Publish checklist
194
-
195
- - Add playground integration tests for `/values` and `/write`
196
- - Add CI (`lint`, `typecheck`, `build`) and release workflow
197
- - Verify Nuxt 4 peer compatibility matrix
69
+ ```bash
70
+ npm install
71
+ npm run dev:prepare
72
+ npm run test
73
+ ```
198
74
 
199
- ## Release
75
+ Playground app:
200
76
 
201
77
  ```bash
202
- npm run release
78
+ npm run dev
203
79
  ```
204
80
 
205
- If needed, authenticate and publish manually:
81
+ Docs site:
206
82
 
207
83
  ```bash
208
- npm login
209
- npm publish --access public
84
+ cd docs
85
+ npm install
86
+ npm run dev
210
87
  ```
package/dist/module.d.mts CHANGED
@@ -2,8 +2,11 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
4
  apiBase: string;
5
- googleApiKeyRuntimeKey: string;
6
5
  defaultContentDir: string;
6
+ googleSheets: Array<{
7
+ id: string;
8
+ label: string;
9
+ }>;
7
10
  }
8
11
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
9
12
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-google-sheets-import",
3
3
  "configKey": "googleSheetsImport",
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, extendPages, addServerHandler, addImportsDir, addComponentsDir, addImports, addServerImports } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addTemplate, extendPages, addServerHandler, addImportsDir, addComponentsDir, addImports, addServerImports } from '@nuxt/kit';
2
2
 
3
3
  const module$1 = defineNuxtModule({
4
4
  meta: {
@@ -15,28 +15,35 @@ const module$1 = defineNuxtModule({
15
15
  },
16
16
  defaults: {
17
17
  apiBase: "/api/google-sheets-import",
18
- googleApiKeyRuntimeKey: "googleApiKey",
19
- defaultContentDir: "content/data"
18
+ defaultContentDir: "content/data",
19
+ googleSheets: []
20
20
  },
21
21
  setup(options, nuxt) {
22
22
  const resolver = createResolver(import.meta.url);
23
+ addTemplate({
24
+ filename: "googleSheetsImportSchemas.ts",
25
+ src: resolver.resolve("./runtime/app/examples/googleSheetsImportSchemas.ts"),
26
+ dst: "utils/.googleSheetsImportSchemas.ts",
27
+ write: true
28
+ });
23
29
  nuxt.options.runtimeConfig.googleSheetsImport = {
24
30
  ...nuxt.options.runtimeConfig.googleSheetsImport,
25
31
  apiBase: options.apiBase,
26
- googleApiKeyRuntimeKey: options.googleApiKeyRuntimeKey,
27
- defaultContentDir: options.defaultContentDir
32
+ defaultContentDir: options.defaultContentDir,
33
+ googleSheets: options.googleSheets
28
34
  };
29
35
  nuxt.options.runtimeConfig.public.googleSheetsImport = {
30
36
  ...nuxt.options.runtimeConfig.public.googleSheetsImport,
31
37
  apiBase: options.apiBase,
32
- defaultContentDir: options.defaultContentDir
38
+ defaultContentDir: options.defaultContentDir,
39
+ googleSheets: options.googleSheets
33
40
  };
34
- nuxt.options.css.push(resolver.resolve("./runtime/assets/css/main.css"));
41
+ nuxt.options.css.push(resolver.resolve("./runtime/app/assets/css/main.css"));
35
42
  extendPages((pages) => {
36
43
  pages.push({
37
44
  name: "google-sheets-import",
38
45
  path: "/google-sheets-import",
39
- file: resolver.resolve("./runtime/pages/google-sheets-import.vue")
46
+ file: resolver.resolve("./runtime/app/pages/google-sheets-import.vue")
40
47
  });
41
48
  });
42
49
  addServerHandler({
@@ -64,16 +71,11 @@ const module$1 = defineNuxtModule({
64
71
  method: "post",
65
72
  handler: resolver.resolve("./runtime/server/api/write.post")
66
73
  });
67
- addImportsDir(resolver.resolve("./runtime/composables"));
74
+ addImportsDir(resolver.resolve("./runtime/app/composables"));
68
75
  addComponentsDir({
69
- path: resolver.resolve("./runtime/components")
76
+ path: resolver.resolve("./runtime/app/components")
70
77
  });
71
78
  addImports([
72
- {
73
- from: "~/utils/googleSheetImportSchemas",
74
- name: "schemas",
75
- as: "googleSheetsImportSchemas"
76
- },
77
79
  {
78
80
  from: resolver.resolve("./runtime/types/googleSheetsApi"),
79
81
  name: "GoogleSheetsApiValues",
@@ -107,8 +109,8 @@ const module$1 = defineNuxtModule({
107
109
  ]);
108
110
  addServerImports([
109
111
  {
110
- from: "~/utils/googleSheetImportSchemas",
111
- name: "schemas",
112
+ from: "~/utils/googleSheetsImportSchemas",
113
+ name: "googleSheetsImportSchemas",
112
114
  as: "googleSheetsImportSchemas"
113
115
  }
114
116
  ]);
@@ -12,9 +12,9 @@ const outputFormatOptions = [
12
12
  { label: "YAML (.yml)", value: "yaml" }
13
13
  ];
14
14
  const overwriteModeOptions = [
15
- { label: "Overwrite existing files", value: "overwrite" },
16
- { label: "Skip files that already exist", value: "skip" },
17
- { label: "Overwrite frontmatter only (.md only)", value: "overwrite-frontmatter" }
15
+ { label: "Skip existing files", value: "skip" },
16
+ { label: "Overwrite frontmatter only (.md files)", value: "overwrite-frontmatter" },
17
+ { label: "Overwrite all", value: "overwrite" }
18
18
  ];
19
19
  const {
20
20
  status,
@@ -1,11 +1,17 @@
1
1
  <script setup>
2
2
  import { computed, ref, watch } from "vue";
3
- import { googleSheetsImportSchemas, queryCollection, useAsyncData, useToast } from "#imports";
3
+ import { queryCollection, useAsyncData, useToast } from "#imports";
4
+ import { useGoogleSheetsImport } from "../composables/useGoogleSheetsImport";
4
5
  import { copyTextWithSuccessToast } from "../utils/clipboard";
5
6
  import { toCsvRow, toTsvRow } from "../utils/delimited";
6
7
  import { flattenRecordToStringMap } from "../utils/pathMapping";
7
8
  const toast = useToast();
8
- const queryCollectionLoose = queryCollection;
9
+ const { getSchemaColumns } = useGoogleSheetsImport();
10
+ const queryCollectionAny = queryCollection;
11
+ function queryCollectionRows(collection) {
12
+ const query = queryCollectionAny(collection);
13
+ return query.all();
14
+ }
9
15
  const selectedSchema = ref("");
10
16
  const {
11
17
  data: rowsData,
@@ -15,26 +21,36 @@ const {
15
21
  execute,
16
22
  clear
17
23
  } = useAsyncData(
18
- "google-sheets-import-export-records",
19
24
  async () => {
20
25
  if (!selectedSchema.value) {
21
26
  return [];
22
27
  }
23
- const result = await queryCollectionLoose(selectedSchema.value).all();
24
- return result;
28
+ return await queryCollectionRows(selectedSchema.value);
25
29
  },
26
30
  {
27
31
  immediate: false,
28
32
  default: () => []
29
33
  }
30
34
  );
35
+ const {
36
+ data: schemaNames,
37
+ error: schemaNamesError
38
+ } = useAsyncData(
39
+ "google-sheets-import-export-schemas",
40
+ async () => {
41
+ const response = await getSchemaColumns();
42
+ return response.schemas ?? [];
43
+ },
44
+ {
45
+ default: () => []
46
+ }
47
+ );
31
48
  const rows = computed(() => rowsData.value ?? []);
32
- const error = computed(() => loadError.value?.message ?? "");
49
+ const error = computed(() => loadError.value?.message ?? schemaNamesError.value?.message ?? "");
33
50
  watch(selectedSchema, () => {
34
51
  clear();
35
52
  });
36
- const schemaMap = computed(() => googleSheetsImportSchemas ?? {});
37
- const schemaOptions = computed(() => Object.keys(schemaMap.value).sort((left, right) => left.localeCompare(right)).map((schema) => ({ label: schema, value: schema })));
53
+ const schemaOptions = computed(() => (schemaNames.value ?? []).sort((left, right) => left.localeCompare(right)).map((schema) => ({ label: schema, value: schema })));
38
54
  const headers = computed(() => {
39
55
  const all = /* @__PURE__ */ new Set();
40
56
  for (const row of rows.value) {
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ export declare const googleSheetsImportSchemas: {
3
+ example: z.ZodObject<{
4
+ slug: z.ZodString;
5
+ pageOrder: z.ZodCoercedNumber<unknown>;
6
+ number: z.ZodCoercedNumber<unknown>;
7
+ string: z.ZodString;
8
+ enumString: z.ZodEnum<{
9
+ foo: "foo";
10
+ bar: "bar";
11
+ baz: "baz";
12
+ }>;
13
+ literalString: z.ZodLiteral<"foo">;
14
+ unionString: z.ZodUnion<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>;
15
+ unionStringArray: z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>>;
16
+ exclusiveUnionString: z.ZodXor<readonly [z.ZodLiteral<"foo">, z.ZodLiteral<"bar">]>;
17
+ stringArray: z.ZodArray<z.ZodString>;
18
+ numberArray: z.ZodArray<z.ZodCoercedNumber<unknown>>;
19
+ boolean: z.ZodCoercedBoolean<unknown>;
20
+ object: z.ZodObject<{
21
+ key1: z.ZodString;
22
+ key2: z.ZodString;
23
+ }, z.core.$strip>;
24
+ objectArray: z.ZodArray<z.ZodObject<{
25
+ keyA: z.ZodString;
26
+ keyB: z.ZodString;
27
+ }, z.core.$strip>>;
28
+ }, z.core.$strip>;
29
+ };
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ const example = z.object({
3
+ slug: z.string().min(1).max(100),
4
+ pageOrder: z.coerce.number().int(),
5
+ number: z.coerce.number(),
6
+ string: z.string().min(1).max(100),
7
+ enumString: z.enum(["foo", "bar", "baz"]),
8
+ literalString: z.literal("foo"),
9
+ unionString: z.union([z.literal("foo"), z.literal("bar")]),
10
+ unionStringArray: z.union([z.literal("foo"), z.literal("bar")]).array(),
11
+ exclusiveUnionString: z.xor([z.literal("foo"), z.literal("bar")]),
12
+ stringArray: z.string().array(),
13
+ numberArray: z.coerce.number().array(),
14
+ boolean: z.coerce.boolean(),
15
+ object: z.object({
16
+ key1: z.string().min(1),
17
+ key2: z.string().min(1)
18
+ }),
19
+ objectArray: z.array(
20
+ z.object({
21
+ keyA: z.string().min(1),
22
+ keyB: z.string().min(1)
23
+ })
24
+ )
25
+ });
26
+ export const googleSheetsImportSchemas = {
27
+ example
28
+ };
@@ -1,9 +1,8 @@
1
1
  <script setup>
2
2
  import { ref } from "vue";
3
- const sheetsList = ref([
4
- { id: "1NKS0cTX6u5urtgQ3Q4Z2motiR2-9JmyPxcd05yVc1bc", label: "Metzner" },
5
- { id: "1tGZCEoiikXfg3mOpfVWWTS1SSSsj18xv6Z3owrnnt4s", label: "Example Sheet" }
6
- ]);
3
+ import { useRuntimeConfig } from "#imports";
4
+ const config = useRuntimeConfig();
5
+ const sheetsList = config.public.googleSheetsImport?.googleSheets ?? [];
7
6
  const items = ref([
8
7
  {
9
8
  label: "Setup Google Sheet",
@@ -6,8 +6,8 @@ const querySchema = z.object({
6
6
  spreadsheetId: z.string().length(44)
7
7
  });
8
8
  export default defineEventHandler(async (event) => {
9
- const { googleSheetsImport } = useRuntimeConfig();
10
- const apiKey = googleSheetsImport?.googleApiKeyRuntimeKey;
9
+ const config = useRuntimeConfig(event);
10
+ const apiKey = config.googleApiKey;
11
11
  const { spreadsheetId } = await getValidatedQuery(event, (query) => querySchema.parse(query));
12
12
  if (!apiKey || typeof apiKey !== "string") {
13
13
  throw createError({ statusCode: 500, statusMessage: `Missing Google API key in nuxt.config googleSheetsImport: { googleApiKeyRuntimeKey: '${apiKey}' }` });
@@ -10,8 +10,8 @@ const bodySchema = z.object({
10
10
  });
11
11
  export default defineEventHandler(async (event) => {
12
12
  const body = bodySchema.parse(await readBody(event));
13
- const { googleSheetsImport } = useRuntimeConfig();
14
- const apiKey = googleSheetsImport?.googleApiKeyRuntimeKey;
13
+ const config = useRuntimeConfig(event);
14
+ const apiKey = config.googleApiKey;
15
15
  if (!apiKey || typeof apiKey !== "string") {
16
16
  throw createError({ statusCode: 500, statusMessage: `Missing Google API key in nuxt.config googleSheetsImport: { googleApiKeyRuntimeKey: '${apiKey}' }` });
17
17
  }
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { parseHeaderPath, setDeep } from "../../utils/pathMapping.js";
2
+ import { parseHeaderPath, setDeep } from "../../../runtime/app/utils/pathMapping";
3
3
  function isZodType(value) {
4
4
  return typeof value === "object" && value !== null && "_def" in value;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-google-sheets-import",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Schema-driven Google Sheets import module for Nuxt Content",
5
5
  "repository": "tribeweb/nuxt-google-sheets-import",
6
6
  "license": "MIT",
@@ -23,9 +23,12 @@
23
23
  "dist"
24
24
  ],
25
25
  "workspaces": [
26
- "playground"
26
+ "playground",
27
+ "docs"
27
28
  ],
28
29
  "scripts": {
30
+ "docs:dev": "cd docs && nuxt dev --extends docus",
31
+ "docs:build": "nuxt build docs --extends docus",
29
32
  "prepack": "nuxt-module-build build",
30
33
  "dev": "npm run dev:prepare && nuxt dev playground",
31
34
  "dev:build": "nuxt build playground",
File without changes
File without changes