@particle-academy/google-sheets-js 0.1.0
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/CHANGELOG.md +74 -0
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/chunk-7AZ3XUFX.js +93 -0
- package/dist/chunk-7AZ3XUFX.js.map +1 -0
- package/dist/flow.cjs +117 -0
- package/dist/flow.cjs.map +1 -0
- package/dist/flow.d.cts +26 -0
- package/dist/flow.d.ts +26 -0
- package/dist/flow.js +25 -0
- package/dist/flow.js.map +1 -0
- package/dist/index.cjs +102 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +118 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +85 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@particle-academy/google-sheets-ui`,
|
|
4
|
+
`@particle-academy/google-sheets-js`, `particle-academy/google-sheets-php` and
|
|
5
|
+
`fancy-google-sheets`.
|
|
6
|
+
|
|
7
|
+
The four packages share one version, because they are generated from one
|
|
8
|
+
`provider/` definition and a version that meant something different in each
|
|
9
|
+
would be a version nobody could reason about.
|
|
10
|
+
|
|
11
|
+
## [0.1.0] — 2026-08-23
|
|
12
|
+
|
|
13
|
+
First release. Provider eight, and the first Google connector.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `row_append` — append a row to a sheet.
|
|
18
|
+
`POST /v4/spreadsheets/{spreadsheetId}/values/{range}:append`.
|
|
19
|
+
- A faker for it, so the node runs on a canvas with no Google account.
|
|
20
|
+
|
|
21
|
+
### Config can go in the URL now
|
|
22
|
+
|
|
23
|
+
Every provider before this one sent a fixed path. Google Sheets needs **two
|
|
24
|
+
config values in the URL** and one **in the query of a POST**, so where a value
|
|
25
|
+
lands is declarable — `send.in: "path" | "query" | "body"` — and stays derived
|
|
26
|
+
when unstated.
|
|
27
|
+
|
|
28
|
+
**A path value is URL-encoded, in all three runtimes.** A range is
|
|
29
|
+
`Sheet1!A:B`; it contains `!`, and a sheet named `Q1/Q2` contains a slash.
|
|
30
|
+
Interpolated raw it changes *which URL is called*, and Google answers 404 about
|
|
31
|
+
a spreadsheet rather than about encoding — pointing at the sheet name instead of
|
|
32
|
+
at the interpolation.
|
|
33
|
+
|
|
34
|
+
The path template and the config are checked against each other, the same way a
|
|
35
|
+
GraphQL document and its variables are: a placeholder nothing fills, a field
|
|
36
|
+
naming no placeholder, and an optional path field are all refused at definition
|
|
37
|
+
time. A URL cannot have a hole in it.
|
|
38
|
+
|
|
39
|
+
### `valueInputOption` is in the QUERY, and that is not cosmetic
|
|
40
|
+
|
|
41
|
+
Sent in the body, Google **ignores it silently** and falls back to `RAW`. An
|
|
42
|
+
author who asked for `USER_ENTERED` then gets `=SUM(A1:A2)` stored as text that
|
|
43
|
+
looks like a formula and never calculates. Nothing errors.
|
|
44
|
+
|
|
45
|
+
### `values` is an array of ARRAYS
|
|
46
|
+
|
|
47
|
+
`ValueRange.values` is rows-of-cells, so a single row has to be wrapped:
|
|
48
|
+
`[["a", "b", "c"]]`. A flat array is rejected as the wrong type. That is
|
|
49
|
+
`encoding: "rows"`, and it is a different keyword from `array` by one word.
|
|
50
|
+
|
|
51
|
+
### The scope is the full `spreadsheets` one, deliberately
|
|
52
|
+
|
|
53
|
+
Not `drive.file`. `append` writes to a spreadsheet the user names by id, and
|
|
54
|
+
`drive.file` only reaches files **the app itself created** — so it would work
|
|
55
|
+
throughout testing, where the app made the sheet, and fail against the document
|
|
56
|
+
somebody actually wants to append to. Read from the discovery document's scopes
|
|
57
|
+
for this exact method.
|
|
58
|
+
|
|
59
|
+
### No sandbox, and no idempotency
|
|
60
|
+
|
|
61
|
+
`sandbox` is `none` — **checked**. Google has no test estate for Sheets: a test
|
|
62
|
+
spreadsheet is a real one in a real Drive, so every append is real.
|
|
63
|
+
|
|
64
|
+
`values.append` takes no idempotency key; the discovery document offers neither
|
|
65
|
+
a header nor a parameter for one. So it is `unsafe-to-replay` with no way to
|
|
66
|
+
make it safe, and a retried durable run appends a **second row**.
|
|
67
|
+
|
|
68
|
+
### Access tokens last one hour
|
|
69
|
+
|
|
70
|
+
Google's do. A connection that is never refreshed stops working within the day,
|
|
71
|
+
which is why `refreshToken` is required rather than optional — and Google only
|
|
72
|
+
issues one when the consent request asked for offline access.
|
|
73
|
+
|
|
74
|
+
[0.1.0]: https://github.com/Fancy-Friends/google-sheets/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Particle Academy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Google Sheets
|
|
2
|
+
|
|
3
|
+
Google Sheets for [fancy-flow][flow] — as **four imported, versioned packages**, one
|
|
4
|
+
per runtime. Not vendored source: a copy cannot be upgraded, and third-party APIs
|
|
5
|
+
change.
|
|
6
|
+
|
|
7
|
+
[flow]: https://github.com/Particle-Academy/fancy-flow
|
|
8
|
+
|
|
9
|
+
| Runtime | Package | Install |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Authoring surface (every host) | `@particle-academy/google-sheets-ui` | `npm install @particle-academy/google-sheets-ui` |
|
|
12
|
+
| Node | `@particle-academy/google-sheets-js` | `npm install @particle-academy/google-sheets-js` |
|
|
13
|
+
| PHP 8.4+ | `particle-academy/google-sheets-php` | `composer require particle-academy/google-sheets-php` |
|
|
14
|
+
| Python 3.11+ | `fancy-google-sheets` | `pip install fancy-google-sheets` |
|
|
15
|
+
|
|
16
|
+
The `ui` package is the editor surface and is React on every host — a PHP or
|
|
17
|
+
Python project installs it *and* its own runtime package, and never the `js` one.
|
|
18
|
+
|
|
19
|
+
## What it costs you
|
|
20
|
+
|
|
21
|
+
One dependency: `@particle-academy/fancy-connector-core` (or
|
|
22
|
+
`particle-academy/fancy-connector-core` on Composer), which the `js` and `php`
|
|
23
|
+
packages pull in themselves. The Python package has **zero** runtime
|
|
24
|
+
dependencies.
|
|
25
|
+
|
|
26
|
+
**No Google Sheets SDK.** Plain HTTP, deliberately: a vendor SDK is third-party code
|
|
27
|
+
subject to the kit's full approval bar, and one per provider is hundreds of
|
|
28
|
+
dependencies nobody is tracking.
|
|
29
|
+
|
|
30
|
+
## Run it before you have credentials
|
|
31
|
+
|
|
32
|
+
Every operation ships a **faker**, whether or not Google Sheets has a sandbox. Set a
|
|
33
|
+
node's mode to `fake` and it returns the shape Google Sheets actually publishes — the
|
|
34
|
+
same field names, deterministically — so you can wire the downstream nodes before
|
|
35
|
+
touching an account, a key, or a network.
|
|
36
|
+
|
|
37
|
+
## This repository is generated
|
|
38
|
+
|
|
39
|
+
`provider/` is the source. Everything under `packages/` is emitted from it and
|
|
40
|
+
**must not be hand-edited** — CI regenerates and diffs on every push, and the
|
|
41
|
+
next protocol sync destroys anything it finds. See [`AGENTS.md`](AGENTS.md).
|
|
42
|
+
|
|
43
|
+
## Two namespaces, which do not match on purpose
|
|
44
|
+
|
|
45
|
+
The repo is `github.com/Fancy-Friends/google-sheets`; the packages publish under
|
|
46
|
+
`particle-academy`. Nothing derives one from the other — the names come from
|
|
47
|
+
weaver's `friends.json` and nowhere else.
|
|
48
|
+
|
|
49
|
+
## Licence
|
|
50
|
+
|
|
51
|
+
MIT.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { callConnector } from '@particle-academy/fancy-connector-core';
|
|
2
|
+
|
|
3
|
+
// src/faker.ts
|
|
4
|
+
function fakeRowAppend({ config, fake }) {
|
|
5
|
+
const boundSpreadsheetid = config.spreadsheetId !== void 0 && config.spreadsheetId !== null && config.spreadsheetId !== "" ? String(config.spreadsheetId) : fake.id("1Sheet");
|
|
6
|
+
return {
|
|
7
|
+
"spreadsheetId": boundSpreadsheetid,
|
|
8
|
+
"tableRange": "Sheet1!A1:D4",
|
|
9
|
+
"updates": {
|
|
10
|
+
"spreadsheetId": boundSpreadsheetid,
|
|
11
|
+
"updatedRange": "Sheet1!A5:D5",
|
|
12
|
+
"updatedRows": 1,
|
|
13
|
+
"updatedColumns": 4,
|
|
14
|
+
"updatedCells": 4
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var googleSheetsFaker = (operation, request) => {
|
|
19
|
+
switch (operation) {
|
|
20
|
+
case "row_append":
|
|
21
|
+
return fakeRowAppend(request);
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(
|
|
24
|
+
`google_sheets: no fake response is defined for "${operation}". Add a fixture under provider/fixtures/ and regenerate \u2014 a connector without a faker cannot be developed against, tested, or demonstrated.`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// src/service.ts
|
|
30
|
+
var CONNECTOR_API_VERSION = 1;
|
|
31
|
+
var GOOGLE_SHEETS_BASE_URLS = {
|
|
32
|
+
"live": "https://sheets.googleapis.com"
|
|
33
|
+
};
|
|
34
|
+
var GOOGLE_SHEETS_REQUIRES = [
|
|
35
|
+
"accessToken",
|
|
36
|
+
"refreshToken",
|
|
37
|
+
"clientId",
|
|
38
|
+
"clientSecret"
|
|
39
|
+
];
|
|
40
|
+
function googleSheetsAuthorize(credentials, request, _mode) {
|
|
41
|
+
request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
|
|
42
|
+
}
|
|
43
|
+
var GOOGLE_SHEETS = {
|
|
44
|
+
service: "google_sheets",
|
|
45
|
+
title: "Google Sheets",
|
|
46
|
+
sandbox: "none",
|
|
47
|
+
baseUrls: { ...GOOGLE_SHEETS_BASE_URLS },
|
|
48
|
+
requires: [...GOOGLE_SHEETS_REQUIRES],
|
|
49
|
+
authorize: googleSheetsAuthorize,
|
|
50
|
+
faker: googleSheetsFaker
|
|
51
|
+
};
|
|
52
|
+
var ROW_APPEND_OPERATION = "row_append";
|
|
53
|
+
async function googleSheetsRowAppend(options) {
|
|
54
|
+
const config = options.config ?? {};
|
|
55
|
+
if (config.spreadsheetId === void 0 || config.spreadsheetId === null || config.spreadsheetId === "") {
|
|
56
|
+
throw new Error(`row_append: "spreadsheetId" is required (Spreadsheet ID).`);
|
|
57
|
+
}
|
|
58
|
+
if (config.range === void 0 || config.range === null || config.range === "") {
|
|
59
|
+
throw new Error(`row_append: "range" is required (Range).`);
|
|
60
|
+
}
|
|
61
|
+
if (config.values === void 0 || config.values === null || config.values === "") {
|
|
62
|
+
throw new Error(`row_append: "values" is required (Row values).`);
|
|
63
|
+
}
|
|
64
|
+
return callConnector(GOOGLE_SHEETS, {
|
|
65
|
+
operation: ROW_APPEND_OPERATION,
|
|
66
|
+
config,
|
|
67
|
+
input: options.input,
|
|
68
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
69
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
70
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
71
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
72
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
73
|
+
request: {
|
|
74
|
+
method: "POST",
|
|
75
|
+
path: `/v4/spreadsheets/${encodeURIComponent(String(config.spreadsheetId))}/values/${encodeURIComponent(String(config.range))}:append`,
|
|
76
|
+
json: {
|
|
77
|
+
"values": [valuesList(config.values)]
|
|
78
|
+
},
|
|
79
|
+
query: {
|
|
80
|
+
...config.valueInputOption !== void 0 && config.valueInputOption !== null && config.valueInputOption !== "" ? { "valueInputOption": String(config.valueInputOption) } : {},
|
|
81
|
+
...config.insertDataOption !== void 0 && config.insertDataOption !== null && config.insertDataOption !== "" ? { "insertDataOption": String(config.insertDataOption) } : {}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function valuesList(value) {
|
|
87
|
+
const items = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(",") : [];
|
|
88
|
+
return items.map((item) => item.trim()).filter(Boolean);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { CONNECTOR_API_VERSION, GOOGLE_SHEETS, GOOGLE_SHEETS_BASE_URLS, GOOGLE_SHEETS_REQUIRES, ROW_APPEND_OPERATION, googleSheetsAuthorize, googleSheetsFaker, googleSheetsRowAppend };
|
|
92
|
+
//# sourceMappingURL=chunk-7AZ3XUFX.js.map
|
|
93
|
+
//# sourceMappingURL=chunk-7AZ3XUFX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/row-append.ts"],"names":[],"mappings":";;;AA0BA,SAAS,a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AC;AAEP,EAAA,OAAO,KAAA,CAAM,IAAI,CAAC,IAAA,KAAS,KAAK,IAAA,EAAM,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA;AACxD","file":"chunk-7AZ3XUFX.js","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/fixtures/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * The Google Sheets faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Google Sheets actually publishes, so an author can wire {{\n * $json.data.id }} against a fake and have it keep working against the real\n * thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeRowAppend({ config, fake }: FakeRequest): unknown {\n const boundSpreadsheetid = (config.spreadsheetId !== undefined && config.spreadsheetId !== null && config.spreadsheetId !== \"\" ? String(config.spreadsheetId) : fake.id(\"1Sheet\"));\n\n return {\n \"spreadsheetId\": boundSpreadsheetid,\n \"tableRange\": \"Sheet1!A1:D4\",\n \"updates\": {\n \"spreadsheetId\": boundSpreadsheetid,\n \"updatedRange\": \"Sheet1!A5:D5\",\n \"updatedRows\": 1,\n \"updatedColumns\": 4,\n \"updatedCells\": 4,\n },\n };\n}\n\nexport const googleSheetsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"row_append\":\n return fakeRowAppend(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `google_sheets: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * Google Sheets, as one service descriptor shared by every Google Sheets\n * operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Google Sheets: its base URL, its\n * auth scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Google has no sandbox for Sheets. A test spreadsheet is a real one in a real\n * Drive, so every append is real -- point this at a scratch sheet, not a\n * production one. The faker is the only way to develop against it without\n * touching a document.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { googleSheetsFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const GOOGLE_SHEETS_BASE_URLS = {\n \"live\": \"https://sheets.googleapis.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const GOOGLE_SHEETS_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Google Sheets's auth scheme to an outgoing request.\n *\n *\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function googleSheetsAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers.Authorization = `Bearer ${credentials.accessToken ?? \"\"}`;\n}\n\n/** The Google Sheets service, for the TypeScript runtime. */\nexport const GOOGLE_SHEETS: ServiceDescriptor = {\n service: \"google_sheets\",\n title: \"Google Sheets\",\n sandbox: \"none\",\n baseUrls: { ...GOOGLE_SHEETS_BASE_URLS },\n requires: [...GOOGLE_SHEETS_REQUIRES],\n authorize: googleSheetsAuthorize,\n faker: googleSheetsFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/row-append.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/row-append.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * Append a row to a Google Sheet.\n *\n * POST /v4/spreadsheets/{spreadsheetId}/values/{range}:append —\n * https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Google Sheets or calls the\n * faker.\n *\n * sideEffects: unsafe-to-replay.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { GOOGLE_SHEETS } from \"../service.js\";\n\nexport const ROW_APPEND_OPERATION = \"row_append\";\n\nexport type RowAppendOptions = {\n /** The node's resolved config. Keys: spreadsheetId, range, values, valueInputOption, insertDataOption. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function googleSheetsRowAppend(options: RowAppendOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.spreadsheetId === undefined || config.spreadsheetId === null || config.spreadsheetId === \"\") {\n throw new Error(`row_append: \"spreadsheetId\" is required (Spreadsheet ID).`);\n }\n\n if (config.range === undefined || config.range === null || config.range === \"\") {\n throw new Error(`row_append: \"range\" is required (Range).`);\n }\n\n if (config.values === undefined || config.values === null || config.values === \"\") {\n throw new Error(`row_append: \"values\" is required (Row values).`);\n }\n\n return callConnector(GOOGLE_SHEETS, {\n operation: ROW_APPEND_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: `/v4/spreadsheets/${encodeURIComponent(String(config.spreadsheetId))}/values/${encodeURIComponent(String(config.range))}:append`,\n json: {\n \"values\": [valuesList(config.values)],\n },\n query: {\n ...(config.valueInputOption !== undefined && config.valueInputOption !== null && config.valueInputOption !== \"\" ? { \"valueInputOption\": String(config.valueInputOption) } : {}),\n ...(config.insertDataOption !== undefined && config.insertDataOption !== null && config.insertDataOption !== \"\" ? { \"insertDataOption\": String(config.insertDataOption) } : {}),\n },\n },\n });\n}\n\n/** One value, a \",\"-separated string, or an array — all end up a list. */\nfunction valuesList(value: unknown): string[] {\n const items = Array.isArray(value)\n ? value.map(String)\n : typeof value === \"string\"\n ? value.split(\",\")\n : [];\n\n return items.map((item) => item.trim()).filter(Boolean);\n}\n"]}
|
package/dist/flow.cjs
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
|
|
4
|
+
var googleSheetsUi = require('@particle-academy/google-sheets-ui');
|
|
5
|
+
|
|
6
|
+
// src/flow.ts
|
|
7
|
+
|
|
8
|
+
// src/faker.ts
|
|
9
|
+
function fakeRowAppend({ config, fake }) {
|
|
10
|
+
const boundSpreadsheetid = config.spreadsheetId !== void 0 && config.spreadsheetId !== null && config.spreadsheetId !== "" ? String(config.spreadsheetId) : fake.id("1Sheet");
|
|
11
|
+
return {
|
|
12
|
+
"spreadsheetId": boundSpreadsheetid,
|
|
13
|
+
"tableRange": "Sheet1!A1:D4",
|
|
14
|
+
"updates": {
|
|
15
|
+
"spreadsheetId": boundSpreadsheetid,
|
|
16
|
+
"updatedRange": "Sheet1!A5:D5",
|
|
17
|
+
"updatedRows": 1,
|
|
18
|
+
"updatedColumns": 4,
|
|
19
|
+
"updatedCells": 4
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
var googleSheetsFaker = (operation, request) => {
|
|
24
|
+
switch (operation) {
|
|
25
|
+
case "row_append":
|
|
26
|
+
return fakeRowAppend(request);
|
|
27
|
+
default:
|
|
28
|
+
throw new Error(
|
|
29
|
+
`google_sheets: no fake response is defined for "${operation}". Add a fixture under provider/fixtures/ and regenerate \u2014 a connector without a faker cannot be developed against, tested, or demonstrated.`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/service.ts
|
|
35
|
+
var GOOGLE_SHEETS_BASE_URLS = {
|
|
36
|
+
"live": "https://sheets.googleapis.com"
|
|
37
|
+
};
|
|
38
|
+
var GOOGLE_SHEETS_REQUIRES = [
|
|
39
|
+
"accessToken",
|
|
40
|
+
"refreshToken",
|
|
41
|
+
"clientId",
|
|
42
|
+
"clientSecret"
|
|
43
|
+
];
|
|
44
|
+
function googleSheetsAuthorize(credentials, request, _mode) {
|
|
45
|
+
request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
|
|
46
|
+
}
|
|
47
|
+
var GOOGLE_SHEETS = {
|
|
48
|
+
service: "google_sheets",
|
|
49
|
+
title: "Google Sheets",
|
|
50
|
+
sandbox: "none",
|
|
51
|
+
baseUrls: { ...GOOGLE_SHEETS_BASE_URLS },
|
|
52
|
+
requires: [...GOOGLE_SHEETS_REQUIRES],
|
|
53
|
+
authorize: googleSheetsAuthorize,
|
|
54
|
+
faker: googleSheetsFaker
|
|
55
|
+
};
|
|
56
|
+
var ROW_APPEND_OPERATION = "row_append";
|
|
57
|
+
async function googleSheetsRowAppend(options) {
|
|
58
|
+
const config = options.config ?? {};
|
|
59
|
+
if (config.spreadsheetId === void 0 || config.spreadsheetId === null || config.spreadsheetId === "") {
|
|
60
|
+
throw new Error(`row_append: "spreadsheetId" is required (Spreadsheet ID).`);
|
|
61
|
+
}
|
|
62
|
+
if (config.range === void 0 || config.range === null || config.range === "") {
|
|
63
|
+
throw new Error(`row_append: "range" is required (Range).`);
|
|
64
|
+
}
|
|
65
|
+
if (config.values === void 0 || config.values === null || config.values === "") {
|
|
66
|
+
throw new Error(`row_append: "values" is required (Row values).`);
|
|
67
|
+
}
|
|
68
|
+
return fancyConnectorCore.callConnector(GOOGLE_SHEETS, {
|
|
69
|
+
operation: ROW_APPEND_OPERATION,
|
|
70
|
+
config,
|
|
71
|
+
input: options.input,
|
|
72
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
73
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
74
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
75
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
76
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
77
|
+
request: {
|
|
78
|
+
method: "POST",
|
|
79
|
+
path: `/v4/spreadsheets/${encodeURIComponent(String(config.spreadsheetId))}/values/${encodeURIComponent(String(config.range))}:append`,
|
|
80
|
+
json: {
|
|
81
|
+
"values": [valuesList(config.values)]
|
|
82
|
+
},
|
|
83
|
+
query: {
|
|
84
|
+
...config.valueInputOption !== void 0 && config.valueInputOption !== null && config.valueInputOption !== "" ? { "valueInputOption": String(config.valueInputOption) } : {},
|
|
85
|
+
...config.insertDataOption !== void 0 && config.insertDataOption !== null && config.insertDataOption !== "" ? { "insertDataOption": String(config.insertDataOption) } : {}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function valuesList(value) {
|
|
91
|
+
const items = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(",") : [];
|
|
92
|
+
return items.map((item) => item.trim()).filter(Boolean);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/flow.ts
|
|
96
|
+
var googleSheetsRowExecutor = async (ctx) => {
|
|
97
|
+
const config = ctx.node.data?.config ?? {};
|
|
98
|
+
const result = await googleSheetsRowAppend({
|
|
99
|
+
config,
|
|
100
|
+
input: ctx.inputs?.in
|
|
101
|
+
});
|
|
102
|
+
ctx.emit({
|
|
103
|
+
type: "log",
|
|
104
|
+
level: "info",
|
|
105
|
+
nodeId: ctx.node.id,
|
|
106
|
+
message: `google_sheets row_append ${result.data?.id} (${result.mode})`
|
|
107
|
+
});
|
|
108
|
+
return { __port: "out", value: result };
|
|
109
|
+
};
|
|
110
|
+
var GOOGLE_SHEETS_RUNNABLE_KINDS = [
|
|
111
|
+
{ ...googleSheetsUi.googleSheetsRowKind, executor: googleSheetsRowExecutor }
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
exports.GOOGLE_SHEETS_RUNNABLE_KINDS = GOOGLE_SHEETS_RUNNABLE_KINDS;
|
|
115
|
+
exports.googleSheetsRowExecutor = googleSheetsRowExecutor;
|
|
116
|
+
//# sourceMappingURL=flow.cjs.map
|
|
117
|
+
//# sourceMappingURL=flow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/row-append.ts","../src/flow.ts"],"names":["callConnector","googleSheetsRowKind"],"mappings":";;;;;;;;AA0BA,SAAS,aAAA,CAAc,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC7D,EAAA,MAAM,qBAAsB,MAAA,CAAO,aAAA,KAAkB,MAAA,IAAa,MAAA,CAAO,kBAAkB,IAAA,IAAQ,MAAA,CAAO,aAAA,KAAkB,EAAA,GAAK,OAAO,MAAA,CAAO,aAAa,CAAA,GAAI,IAAA,CAAK,GAAG,QAAQ,CAAA;AAEhL,EAAA,OAAO;AAAA,IACL,eAAA,EAAiB,kBAAA;AAAA,IACjB,YAAA,E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AAA,IACA,KAAA,EAAO,IAAI,MAAA,EAAQ;AAAA,GACpB,CAAA;AAED,EAAA,GAAA,CAAI,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,yBAAA,EAA6B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GAC1F,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,4BAAA,GAAqD;AAAA,EAChE,EAAE,GAAGC,kCAAA,EAAqB,QAAA,EAAU,uBAAA;AACtC","file":"flow.cjs","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/fixtures/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * The Google Sheets faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Google Sheets actually publishes, so an author can wire {{\n * $json.data.id }} against a fake and have it keep working against the real\n * thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeRowAppend({ config, fake }: FakeRequest): unknown {\n const boundSpreadsheetid = (config.spreadsheetId !== undefined && config.spreadsheetId !== null && config.spreadsheetId !== \"\" ? String(config.spreadsheetId) : fake.id(\"1Sheet\"));\n\n return {\n \"spreadsheetId\": boundSpreadsheetid,\n \"tableRange\": \"Sheet1!A1:D4\",\n \"updates\": {\n \"spreadsheetId\": boundSpreadsheetid,\n \"updatedRange\": \"Sheet1!A5:D5\",\n \"updatedRows\": 1,\n \"updatedColumns\": 4,\n \"updatedCells\": 4,\n },\n };\n}\n\nexport const googleSheetsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"row_append\":\n return fakeRowAppend(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `google_sheets: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * Google Sheets, as one service descriptor shared by every Google Sheets\n * operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Google Sheets: its base URL, its\n * auth scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Google has no sandbox for Sheets. A test spreadsheet is a real one in a real\n * Drive, so every append is real -- point this at a scratch sheet, not a\n * production one. The faker is the only way to develop against it without\n * touching a document.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { googleSheetsFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const GOOGLE_SHEETS_BASE_URLS = {\n \"live\": \"https://sheets.googleapis.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const GOOGLE_SHEETS_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Google Sheets's auth scheme to an outgoing request.\n *\n *\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function googleSheetsAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers.Authorization = `Bearer ${credentials.accessToken ?? \"\"}`;\n}\n\n/** The Google Sheets service, for the TypeScript runtime. */\nexport const GOOGLE_SHEETS: ServiceDescriptor = {\n service: \"google_sheets\",\n title: \"Google Sheets\",\n sandbox: \"none\",\n baseUrls: { ...GOOGLE_SHEETS_BASE_URLS },\n requires: [...GOOGLE_SHEETS_REQUIRES],\n authorize: googleSheetsAuthorize,\n faker: googleSheetsFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/row-append.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/row-append.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * Append a row to a Google Sheet.\n *\n * POST /v4/spreadsheets/{spreadsheetId}/values/{range}:append —\n * https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Google Sheets or calls the\n * faker.\n *\n * sideEffects: unsafe-to-replay.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { GOOGLE_SHEETS } from \"../service.js\";\n\nexport const ROW_APPEND_OPERATION = \"row_append\";\n\nexport type RowAppendOptions = {\n /** The node's resolved config. Keys: spreadsheetId, range, values, valueInputOption, insertDataOption. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function googleSheetsRowAppend(options: RowAppendOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.spreadsheetId === undefined || config.spreadsheetId === null || config.spreadsheetId === \"\") {\n throw new Error(`row_append: \"spreadsheetId\" is required (Spreadsheet ID).`);\n }\n\n if (config.range === undefined || config.range === null || config.range === \"\") {\n throw new Error(`row_append: \"range\" is required (Range).`);\n }\n\n if (config.values === undefined || config.values === null || config.values === \"\") {\n throw new Error(`row_append: \"values\" is required (Row values).`);\n }\n\n return callConnector(GOOGLE_SHEETS, {\n operation: ROW_APPEND_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: `/v4/spreadsheets/${encodeURIComponent(String(config.spreadsheetId))}/values/${encodeURIComponent(String(config.range))}:append`,\n json: {\n \"values\": [valuesList(config.values)],\n },\n query: {\n ...(config.valueInputOption !== undefined && config.valueInputOption !== null && config.valueInputOption !== \"\" ? { \"valueInputOption\": String(config.valueInputOption) } : {}),\n ...(config.insertDataOption !== undefined && config.insertDataOption !== null && config.insertDataOption !== \"\" ? { \"insertDataOption\": String(config.insertDataOption) } : {}),\n },\n },\n });\n}\n\n/** One value, a \",\"-separated string, or an array — all end up a list. */\nfunction valuesList(value: unknown): string[] {\n const items = Array.isArray(value)\n ? value.map(String)\n : typeof value === \"string\"\n ? value.split(\",\")\n : [];\n\n return items.map((item) => item.trim()).filter(Boolean);\n}\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/ + triggers/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/ + triggers/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * Google Sheets's node kinds with their TypeScript executors attached — for\n * hosts that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/google-sheets-ui carries no\n * executor: the editor is React on every host, so a PHP or Python project\n * installs the ui package and never this one.\n */\n\nimport type { NodeExecutor, NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport {\n idempotencyKeyFor,\n NO_IDEMPOTENCY_KEY_WARNING,\n resolveConnection,\n triggerEvent,\n type RequestedMode,\n} from \"@particle-academy/fancy-connector-core\";\nimport { GOOGLE_SHEETS } from \"./service.js\";\n\nimport {\n googleSheetsRowKind,\n} from \"@particle-academy/google-sheets-ui\";\n\nimport { googleSheetsRowAppend } from \"./actions/row-append.js\";\n\nexport const googleSheetsRowExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleSheetsRowAppend({\n config,\n input: ctx.inputs?.in,\n });\n\n ctx.emit({\n type: \"log\",\n level: \"info\",\n nodeId: ctx.node.id,\n message: `google_sheets row_append ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\n\n/** The kinds a TypeScript host registers. */\nexport const GOOGLE_SHEETS_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...googleSheetsRowKind, executor: googleSheetsRowExecutor },\n];\n"]}
|
package/dist/flow.d.cts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NodeKindDefinition, NodeExecutor } from '@particle-academy/fancy-flow/engine';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GENERATED FILE — do not edit.
|
|
5
|
+
*
|
|
6
|
+
* Emitted from provider/actions/ + triggers/ by weaver's generator.
|
|
7
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
8
|
+
* being rejected, because it works until it silently does not. Fix
|
|
9
|
+
* provider/actions/ + triggers/ (or weaver's template/) and regenerate:
|
|
10
|
+
*
|
|
11
|
+
* npm run provider -- google_sheets
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Google Sheets's node kinds with their TypeScript executors attached — for
|
|
15
|
+
* hosts that EXECUTE on TS.
|
|
16
|
+
*
|
|
17
|
+
* The authoring surface in @particle-academy/google-sheets-ui carries no
|
|
18
|
+
* executor: the editor is React on every host, so a PHP or Python project
|
|
19
|
+
* installs the ui package and never this one.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare const googleSheetsRowExecutor: NodeExecutor;
|
|
23
|
+
/** The kinds a TypeScript host registers. */
|
|
24
|
+
declare const GOOGLE_SHEETS_RUNNABLE_KINDS: NodeKindDefinition[];
|
|
25
|
+
|
|
26
|
+
export { GOOGLE_SHEETS_RUNNABLE_KINDS, googleSheetsRowExecutor };
|
package/dist/flow.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NodeKindDefinition, NodeExecutor } from '@particle-academy/fancy-flow/engine';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GENERATED FILE — do not edit.
|
|
5
|
+
*
|
|
6
|
+
* Emitted from provider/actions/ + triggers/ by weaver's generator.
|
|
7
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
8
|
+
* being rejected, because it works until it silently does not. Fix
|
|
9
|
+
* provider/actions/ + triggers/ (or weaver's template/) and regenerate:
|
|
10
|
+
*
|
|
11
|
+
* npm run provider -- google_sheets
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Google Sheets's node kinds with their TypeScript executors attached — for
|
|
15
|
+
* hosts that EXECUTE on TS.
|
|
16
|
+
*
|
|
17
|
+
* The authoring surface in @particle-academy/google-sheets-ui carries no
|
|
18
|
+
* executor: the editor is React on every host, so a PHP or Python project
|
|
19
|
+
* installs the ui package and never this one.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare const googleSheetsRowExecutor: NodeExecutor;
|
|
23
|
+
/** The kinds a TypeScript host registers. */
|
|
24
|
+
declare const GOOGLE_SHEETS_RUNNABLE_KINDS: NodeKindDefinition[];
|
|
25
|
+
|
|
26
|
+
export { GOOGLE_SHEETS_RUNNABLE_KINDS, googleSheetsRowExecutor };
|
package/dist/flow.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { googleSheetsRowAppend } from './chunk-7AZ3XUFX.js';
|
|
2
|
+
import '@particle-academy/fancy-connector-core';
|
|
3
|
+
import { googleSheetsRowKind } from '@particle-academy/google-sheets-ui';
|
|
4
|
+
|
|
5
|
+
var googleSheetsRowExecutor = async (ctx) => {
|
|
6
|
+
const config = ctx.node.data?.config ?? {};
|
|
7
|
+
const result = await googleSheetsRowAppend({
|
|
8
|
+
config,
|
|
9
|
+
input: ctx.inputs?.in
|
|
10
|
+
});
|
|
11
|
+
ctx.emit({
|
|
12
|
+
type: "log",
|
|
13
|
+
level: "info",
|
|
14
|
+
nodeId: ctx.node.id,
|
|
15
|
+
message: `google_sheets row_append ${result.data?.id} (${result.mode})`
|
|
16
|
+
});
|
|
17
|
+
return { __port: "out", value: result };
|
|
18
|
+
};
|
|
19
|
+
var GOOGLE_SHEETS_RUNNABLE_KINDS = [
|
|
20
|
+
{ ...googleSheetsRowKind, executor: googleSheetsRowExecutor }
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export { GOOGLE_SHEETS_RUNNABLE_KINDS, googleSheetsRowExecutor };
|
|
24
|
+
//# sourceMappingURL=flow.js.map
|
|
25
|
+
//# sourceMappingURL=flow.js.map
|
package/dist/flow.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;;AAoCO,IAAM,uBAAA,GAAwC,OAAO,GAAA,KAAQ;AAClE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,qBAAA,CAAsB;AAAA,IACzC,MAAA;AAAA,IACA,KAAA,EAAO,IAAI,MAAA,EAAQ;AAAA,GACpB,CAAA;AAED,EAAA,GAAA,CAAI,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,yBAAA,EAA6B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GAC1F,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,4BAAA,GAAqD;AAAA,EAChE,EAAE,GAAG,mBAAA,EAAqB,QAAA,EAAU,uBAAA;AACtC","file":"flow.js","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/ + triggers/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/ + triggers/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * Google Sheets's node kinds with their TypeScript executors attached — for\n * hosts that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/google-sheets-ui carries no\n * executor: the editor is React on every host, so a PHP or Python project\n * installs the ui package and never this one.\n */\n\nimport type { NodeExecutor, NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport {\n idempotencyKeyFor,\n NO_IDEMPOTENCY_KEY_WARNING,\n resolveConnection,\n triggerEvent,\n type RequestedMode,\n} from \"@particle-academy/fancy-connector-core\";\nimport { GOOGLE_SHEETS } from \"./service.js\";\n\nimport {\n googleSheetsRowKind,\n} from \"@particle-academy/google-sheets-ui\";\n\nimport { googleSheetsRowAppend } from \"./actions/row-append.js\";\n\nexport const googleSheetsRowExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleSheetsRowAppend({\n config,\n input: ctx.inputs?.in,\n });\n\n ctx.emit({\n type: \"log\",\n level: \"info\",\n nodeId: ctx.node.id,\n message: `google_sheets row_append ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\n\n/** The kinds a TypeScript host registers. */\nexport const GOOGLE_SHEETS_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...googleSheetsRowKind, executor: googleSheetsRowExecutor },\n];\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
|
|
4
|
+
|
|
5
|
+
// src/faker.ts
|
|
6
|
+
function fakeRowAppend({ config, fake }) {
|
|
7
|
+
const boundSpreadsheetid = config.spreadsheetId !== void 0 && config.spreadsheetId !== null && config.spreadsheetId !== "" ? String(config.spreadsheetId) : fake.id("1Sheet");
|
|
8
|
+
return {
|
|
9
|
+
"spreadsheetId": boundSpreadsheetid,
|
|
10
|
+
"tableRange": "Sheet1!A1:D4",
|
|
11
|
+
"updates": {
|
|
12
|
+
"spreadsheetId": boundSpreadsheetid,
|
|
13
|
+
"updatedRange": "Sheet1!A5:D5",
|
|
14
|
+
"updatedRows": 1,
|
|
15
|
+
"updatedColumns": 4,
|
|
16
|
+
"updatedCells": 4
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var googleSheetsFaker = (operation, request) => {
|
|
21
|
+
switch (operation) {
|
|
22
|
+
case "row_append":
|
|
23
|
+
return fakeRowAppend(request);
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(
|
|
26
|
+
`google_sheets: no fake response is defined for "${operation}". Add a fixture under provider/fixtures/ and regenerate \u2014 a connector without a faker cannot be developed against, tested, or demonstrated.`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/service.ts
|
|
32
|
+
var CONNECTOR_API_VERSION = 1;
|
|
33
|
+
var GOOGLE_SHEETS_BASE_URLS = {
|
|
34
|
+
"live": "https://sheets.googleapis.com"
|
|
35
|
+
};
|
|
36
|
+
var GOOGLE_SHEETS_REQUIRES = [
|
|
37
|
+
"accessToken",
|
|
38
|
+
"refreshToken",
|
|
39
|
+
"clientId",
|
|
40
|
+
"clientSecret"
|
|
41
|
+
];
|
|
42
|
+
function googleSheetsAuthorize(credentials, request, _mode) {
|
|
43
|
+
request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
|
|
44
|
+
}
|
|
45
|
+
var GOOGLE_SHEETS = {
|
|
46
|
+
service: "google_sheets",
|
|
47
|
+
title: "Google Sheets",
|
|
48
|
+
sandbox: "none",
|
|
49
|
+
baseUrls: { ...GOOGLE_SHEETS_BASE_URLS },
|
|
50
|
+
requires: [...GOOGLE_SHEETS_REQUIRES],
|
|
51
|
+
authorize: googleSheetsAuthorize,
|
|
52
|
+
faker: googleSheetsFaker
|
|
53
|
+
};
|
|
54
|
+
var ROW_APPEND_OPERATION = "row_append";
|
|
55
|
+
async function googleSheetsRowAppend(options) {
|
|
56
|
+
const config = options.config ?? {};
|
|
57
|
+
if (config.spreadsheetId === void 0 || config.spreadsheetId === null || config.spreadsheetId === "") {
|
|
58
|
+
throw new Error(`row_append: "spreadsheetId" is required (Spreadsheet ID).`);
|
|
59
|
+
}
|
|
60
|
+
if (config.range === void 0 || config.range === null || config.range === "") {
|
|
61
|
+
throw new Error(`row_append: "range" is required (Range).`);
|
|
62
|
+
}
|
|
63
|
+
if (config.values === void 0 || config.values === null || config.values === "") {
|
|
64
|
+
throw new Error(`row_append: "values" is required (Row values).`);
|
|
65
|
+
}
|
|
66
|
+
return fancyConnectorCore.callConnector(GOOGLE_SHEETS, {
|
|
67
|
+
operation: ROW_APPEND_OPERATION,
|
|
68
|
+
config,
|
|
69
|
+
input: options.input,
|
|
70
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
71
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
72
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
73
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
74
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
75
|
+
request: {
|
|
76
|
+
method: "POST",
|
|
77
|
+
path: `/v4/spreadsheets/${encodeURIComponent(String(config.spreadsheetId))}/values/${encodeURIComponent(String(config.range))}:append`,
|
|
78
|
+
json: {
|
|
79
|
+
"values": [valuesList(config.values)]
|
|
80
|
+
},
|
|
81
|
+
query: {
|
|
82
|
+
...config.valueInputOption !== void 0 && config.valueInputOption !== null && config.valueInputOption !== "" ? { "valueInputOption": String(config.valueInputOption) } : {},
|
|
83
|
+
...config.insertDataOption !== void 0 && config.insertDataOption !== null && config.insertDataOption !== "" ? { "insertDataOption": String(config.insertDataOption) } : {}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function valuesList(value) {
|
|
89
|
+
const items = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(",") : [];
|
|
90
|
+
return items.map((item) => item.trim()).filter(Boolean);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
exports.CONNECTOR_API_VERSION = CONNECTOR_API_VERSION;
|
|
94
|
+
exports.GOOGLE_SHEETS = GOOGLE_SHEETS;
|
|
95
|
+
exports.GOOGLE_SHEETS_BASE_URLS = GOOGLE_SHEETS_BASE_URLS;
|
|
96
|
+
exports.GOOGLE_SHEETS_REQUIRES = GOOGLE_SHEETS_REQUIRES;
|
|
97
|
+
exports.ROW_APPEND_OPERATION = ROW_APPEND_OPERATION;
|
|
98
|
+
exports.googleSheetsAuthorize = googleSheetsAuthorize;
|
|
99
|
+
exports.googleSheetsFaker = googleSheetsFaker;
|
|
100
|
+
exports.googleSheetsRowAppend = googleSheetsRowAppend;
|
|
101
|
+
//# sourceMappingURL=index.cjs.map
|
|
102
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/row-append.ts"],"names":["callConnector"],"mappings":";;;;;AA0BA,SAAS,aAAA,CAAc,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC7D,EAAA,MAAM,qBAAsB,MAAA,CAAO,aAAA,KAAkB,MAAA,IAAa,MAAA,CAAO,kBAAkB,IAAA,IAAQ,MAAA,CAAO,aAAA,KAAkB,EAAA,GAAK,OAAO,MAAA,CAAO,aAAa,CAAA,GAAI,IAAA,CAAK,GAAG,QAAQ,CAAA;AAEhL,EAAA,OAAO;AAAA,IACL,eAAA,EAAiB,kBAAA;AAAA,IACjB,YAAA,EAAc,cAAA;AAAA,IACd,SAAA,EAAW;AAAA,MACT,eAAA,EAAiB,kBAAA;AAAA,MACjB,cAAA,EAAgB,cAAA;AAAA,MAChB,aAAA,EAAe,CAAA;AAAA,MACf,gBAAA,EAAkB,CAAA;AAAA,MAClB,cAAA,EAAgB;AAAA;AAClB,GACF;AACF;AAEO,IAAM,iBAAA,GAAoC,CAAC,SAAA,EAAW,OAAA,KAAY;AACvE,EAAA,QAAQ,SAAA;AAAW,IACjB,KAAK,YAAA;AACH,MAAA,OAAO,cAAc,OAAO,CAAA;AAAA,IAE9B;AAIE,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,mDAAmD,SAAS,CAAA,iJAAA;AAAA,OAG9D;AAAA;AAEN;;;ACnBO,IAAM,qBAAA,GAAwB;AAE9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,MAAA,EAAQ;AACV;AAGO,IAAM,sBAAA,GAAyB;AAAA,EACpC,aAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;AAWO,SAAS,qBAAA,CACd,WAAA,EACA,OAAA,EACA,KAAA,EACM;AACN,EAAA,O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CAAA;AACH;AAGA,SAAS,WAAW,KAAA,EAA0B;AAC5C,EAAA,MAAM,QAAQ,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAC7B,MAAM,GAAA,CAAI,MAAM,CAAA,GAChB,OAAO,UAAU,QAAA,GACf,KAAA,CAAM,KAAA,CAAM,GAAG,IACf,EAAC;AAEP,EAAA,OAAO,KAAA,CAAM,IAAI,CAAC,IAAA,KAAS,KAAK,IAAA,EAAM,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA;AACxD","file":"index.cjs","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/fixtures/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * The Google Sheets faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Google Sheets actually publishes, so an author can wire {{\n * $json.data.id }} against a fake and have it keep working against the real\n * thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeRowAppend({ config, fake }: FakeRequest): unknown {\n const boundSpreadsheetid = (config.spreadsheetId !== undefined && config.spreadsheetId !== null && config.spreadsheetId !== \"\" ? String(config.spreadsheetId) : fake.id(\"1Sheet\"));\n\n return {\n \"spreadsheetId\": boundSpreadsheetid,\n \"tableRange\": \"Sheet1!A1:D4\",\n \"updates\": {\n \"spreadsheetId\": boundSpreadsheetid,\n \"updatedRange\": \"Sheet1!A5:D5\",\n \"updatedRows\": 1,\n \"updatedColumns\": 4,\n \"updatedCells\": 4,\n },\n };\n}\n\nexport const googleSheetsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"row_append\":\n return fakeRowAppend(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `google_sheets: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * Google Sheets, as one service descriptor shared by every Google Sheets\n * operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Google Sheets: its base URL, its\n * auth scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Google has no sandbox for Sheets. A test spreadsheet is a real one in a real\n * Drive, so every append is real -- point this at a scratch sheet, not a\n * production one. The faker is the only way to develop against it without\n * touching a document.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { googleSheetsFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const GOOGLE_SHEETS_BASE_URLS = {\n \"live\": \"https://sheets.googleapis.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const GOOGLE_SHEETS_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Google Sheets's auth scheme to an outgoing request.\n *\n *\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function googleSheetsAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers.Authorization = `Bearer ${credentials.accessToken ?? \"\"}`;\n}\n\n/** The Google Sheets service, for the TypeScript runtime. */\nexport const GOOGLE_SHEETS: ServiceDescriptor = {\n service: \"google_sheets\",\n title: \"Google Sheets\",\n sandbox: \"none\",\n baseUrls: { ...GOOGLE_SHEETS_BASE_URLS },\n requires: [...GOOGLE_SHEETS_REQUIRES],\n authorize: googleSheetsAuthorize,\n faker: googleSheetsFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/row-append.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/row-append.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_sheets\n */\n\n/**\n * Append a row to a Google Sheet.\n *\n * POST /v4/spreadsheets/{spreadsheetId}/values/{range}:append —\n * https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Google Sheets or calls the\n * faker.\n *\n * sideEffects: unsafe-to-replay.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { GOOGLE_SHEETS } from \"../service.js\";\n\nexport const ROW_APPEND_OPERATION = \"row_append\";\n\nexport type RowAppendOptions = {\n /** The node's resolved config. Keys: spreadsheetId, range, values, valueInputOption, insertDataOption. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function googleSheetsRowAppend(options: RowAppendOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.spreadsheetId === undefined || config.spreadsheetId === null || config.spreadsheetId === \"\") {\n throw new Error(`row_append: \"spreadsheetId\" is required (Spreadsheet ID).`);\n }\n\n if (config.range === undefined || config.range === null || config.range === \"\") {\n throw new Error(`row_append: \"range\" is required (Range).`);\n }\n\n if (config.values === undefined || config.values === null || config.values === \"\") {\n throw new Error(`row_append: \"values\" is required (Row values).`);\n }\n\n return callConnector(GOOGLE_SHEETS, {\n operation: ROW_APPEND_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: `/v4/spreadsheets/${encodeURIComponent(String(config.spreadsheetId))}/values/${encodeURIComponent(String(config.range))}:append`,\n json: {\n \"values\": [valuesList(config.values)],\n },\n query: {\n ...(config.valueInputOption !== undefined && config.valueInputOption !== null && config.valueInputOption !== \"\" ? { \"valueInputOption\": String(config.valueInputOption) } : {}),\n ...(config.insertDataOption !== undefined && config.insertDataOption !== null && config.insertDataOption !== \"\" ? { \"insertDataOption\": String(config.insertDataOption) } : {}),\n },\n },\n });\n}\n\n/** One value, a \",\"-separated string, or an array — all end up a list. */\nfunction valuesList(value: unknown): string[] {\n const items = Array.isArray(value)\n ? value.map(String)\n : typeof value === \"string\"\n ? value.split(\",\")\n : [];\n\n return items.map((item) => item.trim()).filter(Boolean);\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ServiceDescriptor, PreparedRequest, ConnectorMode, ConnectorFaker, RequestedMode, Transport, ConnectorResult } from '@particle-academy/fancy-connector-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GENERATED FILE — do not edit.
|
|
5
|
+
*
|
|
6
|
+
* Emitted from provider/manifest.json by weaver's generator.
|
|
7
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
8
|
+
* being rejected, because it works until it silently does not. Fix
|
|
9
|
+
* provider/manifest.json (or weaver's template/) and regenerate:
|
|
10
|
+
*
|
|
11
|
+
* npm run provider -- google_sheets
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Google Sheets, as one service descriptor shared by every Google Sheets
|
|
15
|
+
* operation.
|
|
16
|
+
*
|
|
17
|
+
* @particle-academy/fancy-connector-core carries what is true of ALL
|
|
18
|
+
* connectors. This carries what is true of Google Sheets: its base URL, its
|
|
19
|
+
* auth scheme, its idempotency header, and its faker.
|
|
20
|
+
*
|
|
21
|
+
* ## The sandbox trap, written down where it is used
|
|
22
|
+
*
|
|
23
|
+
* Google has no sandbox for Sheets. A test spreadsheet is a real one in a real
|
|
24
|
+
* Drive, so every append is real -- point this at a scratch sheet, not a
|
|
25
|
+
* production one. The faker is the only way to develop against it without
|
|
26
|
+
* touching a document.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The connector API version this package was GENERATED against.
|
|
31
|
+
*
|
|
32
|
+
* A literal, never imported. An imported constant lets an upgrade rewrite the
|
|
33
|
+
* very claim it exists to detect, after which the copy agrees with itself
|
|
34
|
+
* forever.
|
|
35
|
+
*/
|
|
36
|
+
declare const CONNECTOR_API_VERSION = 1;
|
|
37
|
+
declare const GOOGLE_SHEETS_BASE_URLS: {
|
|
38
|
+
readonly live: "https://sheets.googleapis.com";
|
|
39
|
+
};
|
|
40
|
+
/** Credential keys a remote call cannot proceed without. */
|
|
41
|
+
declare const GOOGLE_SHEETS_REQUIRES: readonly ["accessToken", "refreshToken", "clientId", "clientSecret"];
|
|
42
|
+
/**
|
|
43
|
+
* Apply Google Sheets's auth scheme to an outgoing request.
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
* The mode is passed in because for some providers auth and estate are the
|
|
48
|
+
* same decision expressed in the URL; here it is unused, and saying so is
|
|
49
|
+
* cheaper than wondering later whether it was forgotten.
|
|
50
|
+
*/
|
|
51
|
+
declare function googleSheetsAuthorize(credentials: Record<string, string | undefined>, request: PreparedRequest, _mode: ConnectorMode): void;
|
|
52
|
+
/** The Google Sheets service, for the TypeScript runtime. */
|
|
53
|
+
declare const GOOGLE_SHEETS: ServiceDescriptor;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* GENERATED FILE — do not edit.
|
|
57
|
+
*
|
|
58
|
+
* Emitted from provider/fixtures/ by weaver's generator.
|
|
59
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
60
|
+
* being rejected, because it works until it silently does not. Fix
|
|
61
|
+
* provider/fixtures/ (or weaver's template/) and regenerate:
|
|
62
|
+
*
|
|
63
|
+
* npm run provider -- google_sheets
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* The Google Sheets faker.
|
|
67
|
+
*
|
|
68
|
+
* Shapes, not behaviour: the goal is that a downstream node sees the field
|
|
69
|
+
* NAMES Google Sheets actually publishes, so an author can wire {{
|
|
70
|
+
* $json.data.id }} against a fake and have it keep working against the real
|
|
71
|
+
* thing.
|
|
72
|
+
*
|
|
73
|
+
* Deterministic — same inputs, same output. A faker returning a fresh uuid
|
|
74
|
+
* every call cannot be asserted on, so its fixtures degrade to "it did not
|
|
75
|
+
* throw", which is the assertion that catches nothing.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
declare const googleSheetsFaker: ConnectorFaker;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* GENERATED FILE — do not edit.
|
|
82
|
+
*
|
|
83
|
+
* Emitted from provider/actions/row-append.json by weaver's generator.
|
|
84
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
85
|
+
* being rejected, because it works until it silently does not. Fix
|
|
86
|
+
* provider/actions/row-append.json (or weaver's template/) and regenerate:
|
|
87
|
+
*
|
|
88
|
+
* npm run provider -- google_sheets
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Append a row to a Google Sheet.
|
|
92
|
+
*
|
|
93
|
+
* POST /v4/spreadsheets/{spreadsheetId}/values/{range}:append —
|
|
94
|
+
* https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
|
|
95
|
+
*
|
|
96
|
+
* Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
|
|
97
|
+
* no fake/real branch. This describes the request; callConnector resolves the
|
|
98
|
+
* connection, picks the estate, and either calls Google Sheets or calls the
|
|
99
|
+
* faker.
|
|
100
|
+
*
|
|
101
|
+
* sideEffects: unsafe-to-replay.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
declare const ROW_APPEND_OPERATION = "row_append";
|
|
105
|
+
type RowAppendOptions = {
|
|
106
|
+
/** The node's resolved config. Keys: spreadsheetId, range, values, valueInputOption, insertDataOption. */
|
|
107
|
+
config: Record<string, unknown>;
|
|
108
|
+
credentials?: Record<string, string | undefined>;
|
|
109
|
+
mode?: RequestedMode;
|
|
110
|
+
connectionId?: string | null;
|
|
111
|
+
input?: unknown;
|
|
112
|
+
attempts?: number;
|
|
113
|
+
/** Override the transport. The only way to exercise this without a network. */
|
|
114
|
+
transport?: Transport;
|
|
115
|
+
};
|
|
116
|
+
declare function googleSheetsRowAppend(options: RowAppendOptions): Promise<ConnectorResult>;
|
|
117
|
+
|
|
118
|
+
export { CONNECTOR_API_VERSION, GOOGLE_SHEETS, GOOGLE_SHEETS_BASE_URLS, GOOGLE_SHEETS_REQUIRES, ROW_APPEND_OPERATION, type RowAppendOptions, googleSheetsAuthorize, googleSheetsFaker, googleSheetsRowAppend };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ServiceDescriptor, PreparedRequest, ConnectorMode, ConnectorFaker, RequestedMode, Transport, ConnectorResult } from '@particle-academy/fancy-connector-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GENERATED FILE — do not edit.
|
|
5
|
+
*
|
|
6
|
+
* Emitted from provider/manifest.json by weaver's generator.
|
|
7
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
8
|
+
* being rejected, because it works until it silently does not. Fix
|
|
9
|
+
* provider/manifest.json (or weaver's template/) and regenerate:
|
|
10
|
+
*
|
|
11
|
+
* npm run provider -- google_sheets
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Google Sheets, as one service descriptor shared by every Google Sheets
|
|
15
|
+
* operation.
|
|
16
|
+
*
|
|
17
|
+
* @particle-academy/fancy-connector-core carries what is true of ALL
|
|
18
|
+
* connectors. This carries what is true of Google Sheets: its base URL, its
|
|
19
|
+
* auth scheme, its idempotency header, and its faker.
|
|
20
|
+
*
|
|
21
|
+
* ## The sandbox trap, written down where it is used
|
|
22
|
+
*
|
|
23
|
+
* Google has no sandbox for Sheets. A test spreadsheet is a real one in a real
|
|
24
|
+
* Drive, so every append is real -- point this at a scratch sheet, not a
|
|
25
|
+
* production one. The faker is the only way to develop against it without
|
|
26
|
+
* touching a document.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The connector API version this package was GENERATED against.
|
|
31
|
+
*
|
|
32
|
+
* A literal, never imported. An imported constant lets an upgrade rewrite the
|
|
33
|
+
* very claim it exists to detect, after which the copy agrees with itself
|
|
34
|
+
* forever.
|
|
35
|
+
*/
|
|
36
|
+
declare const CONNECTOR_API_VERSION = 1;
|
|
37
|
+
declare const GOOGLE_SHEETS_BASE_URLS: {
|
|
38
|
+
readonly live: "https://sheets.googleapis.com";
|
|
39
|
+
};
|
|
40
|
+
/** Credential keys a remote call cannot proceed without. */
|
|
41
|
+
declare const GOOGLE_SHEETS_REQUIRES: readonly ["accessToken", "refreshToken", "clientId", "clientSecret"];
|
|
42
|
+
/**
|
|
43
|
+
* Apply Google Sheets's auth scheme to an outgoing request.
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
* The mode is passed in because for some providers auth and estate are the
|
|
48
|
+
* same decision expressed in the URL; here it is unused, and saying so is
|
|
49
|
+
* cheaper than wondering later whether it was forgotten.
|
|
50
|
+
*/
|
|
51
|
+
declare function googleSheetsAuthorize(credentials: Record<string, string | undefined>, request: PreparedRequest, _mode: ConnectorMode): void;
|
|
52
|
+
/** The Google Sheets service, for the TypeScript runtime. */
|
|
53
|
+
declare const GOOGLE_SHEETS: ServiceDescriptor;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* GENERATED FILE — do not edit.
|
|
57
|
+
*
|
|
58
|
+
* Emitted from provider/fixtures/ by weaver's generator.
|
|
59
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
60
|
+
* being rejected, because it works until it silently does not. Fix
|
|
61
|
+
* provider/fixtures/ (or weaver's template/) and regenerate:
|
|
62
|
+
*
|
|
63
|
+
* npm run provider -- google_sheets
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* The Google Sheets faker.
|
|
67
|
+
*
|
|
68
|
+
* Shapes, not behaviour: the goal is that a downstream node sees the field
|
|
69
|
+
* NAMES Google Sheets actually publishes, so an author can wire {{
|
|
70
|
+
* $json.data.id }} against a fake and have it keep working against the real
|
|
71
|
+
* thing.
|
|
72
|
+
*
|
|
73
|
+
* Deterministic — same inputs, same output. A faker returning a fresh uuid
|
|
74
|
+
* every call cannot be asserted on, so its fixtures degrade to "it did not
|
|
75
|
+
* throw", which is the assertion that catches nothing.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
declare const googleSheetsFaker: ConnectorFaker;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* GENERATED FILE — do not edit.
|
|
82
|
+
*
|
|
83
|
+
* Emitted from provider/actions/row-append.json by weaver's generator.
|
|
84
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
85
|
+
* being rejected, because it works until it silently does not. Fix
|
|
86
|
+
* provider/actions/row-append.json (or weaver's template/) and regenerate:
|
|
87
|
+
*
|
|
88
|
+
* npm run provider -- google_sheets
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Append a row to a Google Sheet.
|
|
92
|
+
*
|
|
93
|
+
* POST /v4/spreadsheets/{spreadsheetId}/values/{range}:append —
|
|
94
|
+
* https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
|
|
95
|
+
*
|
|
96
|
+
* Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
|
|
97
|
+
* no fake/real branch. This describes the request; callConnector resolves the
|
|
98
|
+
* connection, picks the estate, and either calls Google Sheets or calls the
|
|
99
|
+
* faker.
|
|
100
|
+
*
|
|
101
|
+
* sideEffects: unsafe-to-replay.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
declare const ROW_APPEND_OPERATION = "row_append";
|
|
105
|
+
type RowAppendOptions = {
|
|
106
|
+
/** The node's resolved config. Keys: spreadsheetId, range, values, valueInputOption, insertDataOption. */
|
|
107
|
+
config: Record<string, unknown>;
|
|
108
|
+
credentials?: Record<string, string | undefined>;
|
|
109
|
+
mode?: RequestedMode;
|
|
110
|
+
connectionId?: string | null;
|
|
111
|
+
input?: unknown;
|
|
112
|
+
attempts?: number;
|
|
113
|
+
/** Override the transport. The only way to exercise this without a network. */
|
|
114
|
+
transport?: Transport;
|
|
115
|
+
};
|
|
116
|
+
declare function googleSheetsRowAppend(options: RowAppendOptions): Promise<ConnectorResult>;
|
|
117
|
+
|
|
118
|
+
export { CONNECTOR_API_VERSION, GOOGLE_SHEETS, GOOGLE_SHEETS_BASE_URLS, GOOGLE_SHEETS_REQUIRES, ROW_APPEND_OPERATION, type RowAppendOptions, googleSheetsAuthorize, googleSheetsFaker, googleSheetsRowAppend };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CONNECTOR_API_VERSION, GOOGLE_SHEETS, GOOGLE_SHEETS_BASE_URLS, GOOGLE_SHEETS_REQUIRES, ROW_APPEND_OPERATION, googleSheetsAuthorize, googleSheetsFaker, googleSheetsRowAppend } from './chunk-7AZ3XUFX.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@particle-academy/google-sheets-js",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Google Sheets for Node — the service descriptor, its faker, its webhook verification, and one function per operation. Plain HTTP on @particle-academy/fancy-connector-core; no vendor SDK.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Fancy-Friends/google-sheets.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/Fancy-Friends/google-sheets#readme",
|
|
10
|
+
"bugs": "https://github.com/Fancy-Friends/google-sheets/issues",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./dist/index.d.cts",
|
|
23
|
+
"default": "./dist/index.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"./flow": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/flow.d.ts",
|
|
29
|
+
"default": "./dist/flow.js"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/flow.d.cts",
|
|
33
|
+
"default": "./dist/flow.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"CHANGELOG.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"lint": "tsc --noEmit",
|
|
47
|
+
"test": "node --import tsx --test tests/*.test.ts",
|
|
48
|
+
"prepublishOnly": "tsup"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@particle-academy/fancy-connector-core": ">=0.3.1 <2.0",
|
|
52
|
+
"@particle-academy/google-sheets-ui": "0.1.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@particle-academy/fancy-flow": ">=0.47.1 <2.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependenciesMeta": {
|
|
58
|
+
"@particle-academy/fancy-flow": {
|
|
59
|
+
"optional": true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@particle-academy/fancy-flow": ">=0.47.1 <2.0",
|
|
64
|
+
"@types/node": "^26.2.0",
|
|
65
|
+
"tsup": "^8.5.0",
|
|
66
|
+
"tsx": "^4.19.0",
|
|
67
|
+
"typescript": "^5.8.0"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
},
|
|
72
|
+
"keywords": [
|
|
73
|
+
"google_sheets",
|
|
74
|
+
"productivity",
|
|
75
|
+
"connector",
|
|
76
|
+
"api",
|
|
77
|
+
"fancy-ui",
|
|
78
|
+
"particle-academy"
|
|
79
|
+
],
|
|
80
|
+
"license": "MIT",
|
|
81
|
+
"sideEffects": false,
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=22"
|
|
84
|
+
}
|
|
85
|
+
}
|