nuxt-google-sheets-import 0.1.7 → 0.1.8
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 +35 -158
- package/dist/module.d.mts +0 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +13 -14
- package/dist/runtime/{components → app/components}/GoogleSheetsImportExport.vue +24 -8
- package/dist/runtime/app/examples/googleSheetsImportSchemasExample.d.ts +1 -0
- package/dist/runtime/app/examples/googleSheetsImportSchemasExample.js +0 -0
- package/dist/runtime/server/api/sheets.get.js +2 -2
- package/dist/runtime/server/api/values.post.js +2 -2
- package/dist/runtime/server/utils/transform.js +1 -1
- package/package.json +5 -2
- /package/dist/runtime/{assets → app/assets}/css/main.css +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportExecute.d.vue.ts +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportExecute.vue +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportExecute.vue.d.ts +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportExport.d.vue.ts +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportExport.vue.d.ts +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportSchemaGuide.d.vue.ts +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportSchemaGuide.vue +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportSchemaGuide.vue.d.ts +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportSource.d.vue.ts +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportSource.vue +0 -0
- /package/dist/runtime/{components → app/components}/GoogleSheetsImportSource.vue.d.ts +0 -0
- /package/dist/runtime/{composables → app/composables}/useGoogleSheetsImport.d.ts +0 -0
- /package/dist/runtime/{composables → app/composables}/useGoogleSheetsImport.js +0 -0
- /package/dist/runtime/{composables → app/composables}/useGoogleSheetsImportWorkflow.d.ts +0 -0
- /package/dist/runtime/{composables → app/composables}/useGoogleSheetsImportWorkflow.js +0 -0
- /package/dist/runtime/{pages → app/pages}/google-sheets-import.d.vue.ts +0 -0
- /package/dist/runtime/{pages → app/pages}/google-sheets-import.vue +0 -0
- /package/dist/runtime/{pages → app/pages}/google-sheets-import.vue.d.ts +0 -0
- /package/dist/runtime/{utils → app/utils}/clipboard.d.ts +0 -0
- /package/dist/runtime/{utils → app/utils}/clipboard.js +0 -0
- /package/dist/runtime/{utils → app/utils}/delimited.d.ts +0 -0
- /package/dist/runtime/{utils → app/utils}/delimited.js +0 -0
- /package/dist/runtime/{utils → app/utils}/pathMapping.d.ts +0 -0
- /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
|
|
3
|
+
Schema-driven Google Sheets import and export workflows for Nuxt Content.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Documentation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Project documentation now lives in the Docus site under [docs/content](docs/content).
|
|
8
8
|
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
110
|
-
The module auto-imports
|
|
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
|
-
##
|
|
65
|
+
## Repository Development
|
|
122
66
|
|
|
123
|
-
|
|
124
|
-
- `Download .csv` provides quoted CSV output for file-based workflows.
|
|
67
|
+
Module development:
|
|
125
68
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
75
|
+
Playground app:
|
|
200
76
|
|
|
201
77
|
```bash
|
|
202
|
-
npm run
|
|
78
|
+
npm run dev
|
|
203
79
|
```
|
|
204
80
|
|
|
205
|
-
|
|
81
|
+
Docs site:
|
|
206
82
|
|
|
207
83
|
```bash
|
|
208
|
-
|
|
209
|
-
npm
|
|
84
|
+
cd docs
|
|
85
|
+
npm install
|
|
86
|
+
npm run dev
|
|
210
87
|
```
|
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, 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,15 +15,19 @@ const module$1 = defineNuxtModule({
|
|
|
15
15
|
},
|
|
16
16
|
defaults: {
|
|
17
17
|
apiBase: "/api/google-sheets-import",
|
|
18
|
-
googleApiKeyRuntimeKey: "googleApiKey",
|
|
19
18
|
defaultContentDir: "content/data"
|
|
20
19
|
},
|
|
21
20
|
setup(options, nuxt) {
|
|
22
21
|
const resolver = createResolver(import.meta.url);
|
|
22
|
+
addTemplate({
|
|
23
|
+
filename: "googleSheetsImportSchemaExample.ts",
|
|
24
|
+
src: resolver.resolve("./runtime/app/examples/googleSheetsImportSchemasExample.ts"),
|
|
25
|
+
dst: "utils/googleSheetsImportSchemasExample.ts",
|
|
26
|
+
write: true
|
|
27
|
+
});
|
|
23
28
|
nuxt.options.runtimeConfig.googleSheetsImport = {
|
|
24
29
|
...nuxt.options.runtimeConfig.googleSheetsImport,
|
|
25
30
|
apiBase: options.apiBase,
|
|
26
|
-
googleApiKeyRuntimeKey: options.googleApiKeyRuntimeKey,
|
|
27
31
|
defaultContentDir: options.defaultContentDir
|
|
28
32
|
};
|
|
29
33
|
nuxt.options.runtimeConfig.public.googleSheetsImport = {
|
|
@@ -31,12 +35,12 @@ const module$1 = defineNuxtModule({
|
|
|
31
35
|
apiBase: options.apiBase,
|
|
32
36
|
defaultContentDir: options.defaultContentDir
|
|
33
37
|
};
|
|
34
|
-
nuxt.options.css.push(resolver.resolve("./runtime/assets/css/main.css"));
|
|
38
|
+
nuxt.options.css.push(resolver.resolve("./runtime/app/assets/css/main.css"));
|
|
35
39
|
extendPages((pages) => {
|
|
36
40
|
pages.push({
|
|
37
41
|
name: "google-sheets-import",
|
|
38
42
|
path: "/google-sheets-import",
|
|
39
|
-
file: resolver.resolve("./runtime/pages/google-sheets-import.vue")
|
|
43
|
+
file: resolver.resolve("./runtime/app/pages/google-sheets-import.vue")
|
|
40
44
|
});
|
|
41
45
|
});
|
|
42
46
|
addServerHandler({
|
|
@@ -64,16 +68,11 @@ const module$1 = defineNuxtModule({
|
|
|
64
68
|
method: "post",
|
|
65
69
|
handler: resolver.resolve("./runtime/server/api/write.post")
|
|
66
70
|
});
|
|
67
|
-
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
71
|
+
addImportsDir(resolver.resolve("./runtime/app/composables"));
|
|
68
72
|
addComponentsDir({
|
|
69
|
-
path: resolver.resolve("./runtime/components")
|
|
73
|
+
path: resolver.resolve("./runtime/app/components")
|
|
70
74
|
});
|
|
71
75
|
addImports([
|
|
72
|
-
{
|
|
73
|
-
from: "~/utils/googleSheetImportSchemas",
|
|
74
|
-
name: "schemas",
|
|
75
|
-
as: "googleSheetsImportSchemas"
|
|
76
|
-
},
|
|
77
76
|
{
|
|
78
77
|
from: resolver.resolve("./runtime/types/googleSheetsApi"),
|
|
79
78
|
name: "GoogleSheetsApiValues",
|
|
@@ -107,8 +106,8 @@ const module$1 = defineNuxtModule({
|
|
|
107
106
|
]);
|
|
108
107
|
addServerImports([
|
|
109
108
|
{
|
|
110
|
-
from: "~/utils/
|
|
111
|
-
name: "
|
|
109
|
+
from: "~/utils/googleSheetsImportSchemas",
|
|
110
|
+
name: "googleSheetsImportSchemas",
|
|
112
111
|
as: "googleSheetsImportSchemas"
|
|
113
112
|
}
|
|
114
113
|
]);
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref, watch } from "vue";
|
|
3
|
-
import {
|
|
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
|
|
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
|
-
|
|
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
|
|
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 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -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
|
|
10
|
-
const apiKey =
|
|
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
|
|
14
|
-
const apiKey =
|
|
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 "
|
|
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.
|
|
3
|
+
"version": "0.1.8",
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|