@particle-academy/google-docs-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 +34 -0
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/chunk-2X6MFNGK.js +71 -0
- package/dist/chunk-2X6MFNGK.js.map +1 -0
- package/dist/flow.cjs +95 -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 +80 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +116 -0
- package/dist/index.d.ts +116 -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,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@particle-academy/google-docs-ui`,
|
|
4
|
+
`@particle-academy/google-docs-js`, `particle-academy/google-docs-php` and
|
|
5
|
+
`fancy-google-docs`.
|
|
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.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `document_create` — create a blank Google Docs document from a title.
|
|
18
|
+
`POST /v1/documents`.
|
|
19
|
+
- A top-level `Document` faker, so the node runs on a canvas with no Google
|
|
20
|
+
account.
|
|
21
|
+
|
|
22
|
+
### Only the title is accepted
|
|
23
|
+
|
|
24
|
+
The request type is the full `Document`, but Google's discovery method says
|
|
25
|
+
every field other than `title` is ignored, including content. The action does
|
|
26
|
+
not offer fields the endpoint will silently discard.
|
|
27
|
+
|
|
28
|
+
### No sandbox, and no idempotency
|
|
29
|
+
|
|
30
|
+
Google has no Docs test estate. A test document is a real document in a real
|
|
31
|
+
Drive. `documents.create` also declares no idempotency key, so a retry can
|
|
32
|
+
create a second document and the action is honestly `unsafe-to-replay`.
|
|
33
|
+
|
|
34
|
+
[0.1.0]: https://github.com/Fancy-Friends/google-docs/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 Docs
|
|
2
|
+
|
|
3
|
+
Google Docs 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-docs-ui` | `npm install @particle-academy/google-docs-ui` |
|
|
12
|
+
| Node | `@particle-academy/google-docs-js` | `npm install @particle-academy/google-docs-js` |
|
|
13
|
+
| PHP 8.4+ | `particle-academy/google-docs-php` | `composer require particle-academy/google-docs-php` |
|
|
14
|
+
| Python 3.11+ | `fancy-google-docs` | `pip install fancy-google-docs` |
|
|
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 Docs 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 Docs has a sandbox. Set a
|
|
33
|
+
node's mode to `fake` and it returns the shape Google Docs 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-docs`; 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,71 @@
|
|
|
1
|
+
import { callConnector } from '@particle-academy/fancy-connector-core';
|
|
2
|
+
|
|
3
|
+
// src/faker.ts
|
|
4
|
+
function fakeDocumentCreate({ config, fake }) {
|
|
5
|
+
return {
|
|
6
|
+
"documentId": fake.id("1Doc"),
|
|
7
|
+
"title": config.title !== void 0 && config.title !== null && config.title !== "" ? String(config.title) : "Untitled document"
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
var googleDocsFaker = (operation, request) => {
|
|
11
|
+
switch (operation) {
|
|
12
|
+
case "document_create":
|
|
13
|
+
return fakeDocumentCreate(request);
|
|
14
|
+
default:
|
|
15
|
+
throw new Error(
|
|
16
|
+
`google_docs: 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.`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/service.ts
|
|
22
|
+
var CONNECTOR_API_VERSION = 1;
|
|
23
|
+
var GOOGLE_DOCS_BASE_URLS = {
|
|
24
|
+
"live": "https://docs.googleapis.com"
|
|
25
|
+
};
|
|
26
|
+
var GOOGLE_DOCS_REQUIRES = [
|
|
27
|
+
"accessToken",
|
|
28
|
+
"refreshToken",
|
|
29
|
+
"clientId",
|
|
30
|
+
"clientSecret"
|
|
31
|
+
];
|
|
32
|
+
function googleDocsAuthorize(credentials, request, _mode) {
|
|
33
|
+
request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
|
|
34
|
+
}
|
|
35
|
+
var GOOGLE_DOCS = {
|
|
36
|
+
service: "google_docs",
|
|
37
|
+
title: "Google Docs",
|
|
38
|
+
sandbox: "none",
|
|
39
|
+
baseUrls: { ...GOOGLE_DOCS_BASE_URLS },
|
|
40
|
+
requires: [...GOOGLE_DOCS_REQUIRES],
|
|
41
|
+
authorize: googleDocsAuthorize,
|
|
42
|
+
faker: googleDocsFaker
|
|
43
|
+
};
|
|
44
|
+
var DOCUMENT_CREATE_OPERATION = "document_create";
|
|
45
|
+
async function googleDocsDocumentCreate(options) {
|
|
46
|
+
const config = options.config ?? {};
|
|
47
|
+
if (config.title === void 0 || config.title === null || config.title === "") {
|
|
48
|
+
throw new Error(`document_create: "title" is required (Title).`);
|
|
49
|
+
}
|
|
50
|
+
return callConnector(GOOGLE_DOCS, {
|
|
51
|
+
operation: DOCUMENT_CREATE_OPERATION,
|
|
52
|
+
config,
|
|
53
|
+
input: options.input,
|
|
54
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
55
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
56
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
57
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
58
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
59
|
+
request: {
|
|
60
|
+
method: "POST",
|
|
61
|
+
path: "/v1/documents",
|
|
62
|
+
json: {
|
|
63
|
+
"title": String(config.title)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker };
|
|
70
|
+
//# sourceMappingURL=chunk-2X6MFNGK.js.map
|
|
71
|
+
//# sourceMappingURL=chunk-2X6MF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file":"chunk-2X6MFNGK.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_docs\n */\n\n/**\n * The Google Docs faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Google Docs actually publishes, so an author can wire {{ $json.data.id\n * }} against a fake and have it keep working against the real 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 fakeDocumentCreate({ config, fake }: FakeRequest): unknown {\n return {\n \"documentId\": fake.id(\"1Doc\"),\n \"title\": (config.title !== undefined && config.title !== null && config.title !== \"\" ? String(config.title) : \"Untitled document\"),\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"document_create\":\n return fakeDocumentCreate(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_docs: 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_docs\n */\n\n/**\n * Google Docs, as one service descriptor shared by every Google Docs\n * operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Google Docs: its base URL, its auth\n * 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 Docs. A test document is a real one in a real\n * Drive, so every create is real -- use the faker while developing and clean\n * up any live test documents.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { googleDocsFaker } 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_DOCS_BASE_URLS = {\n \"live\": \"https://docs.googleapis.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const GOOGLE_DOCS_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Google Docs'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 googleDocsAuthorize(\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 Docs service, for the TypeScript runtime. */\nexport const GOOGLE_DOCS: ServiceDescriptor = {\n service: \"google_docs\",\n title: \"Google Docs\",\n sandbox: \"none\",\n baseUrls: { ...GOOGLE_DOCS_BASE_URLS },\n requires: [...GOOGLE_DOCS_REQUIRES],\n authorize: googleDocsAuthorize,\n faker: googleDocsFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/document-create.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/document-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Create a blank Google Docs document.\n *\n * POST /v1/documents —\n * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/create\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 Docs 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_DOCS } from \"../service.js\";\n\nexport const DOCUMENT_CREATE_OPERATION = \"document_create\";\n\nexport type DocumentCreateOptions = {\n /** The node's resolved config. Keys: title. */\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 googleDocsDocumentCreate(options: DocumentCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.title === undefined || config.title === null || config.title === \"\") {\n throw new Error(`document_create: \"title\" is required (Title).`);\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: DOCUMENT_CREATE_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: \"/v1/documents\",\n json: {\n \"title\": String(config.title),\n },\n },\n });\n}\n"]}
|
package/dist/flow.cjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
|
|
4
|
+
var googleDocsUi = require('@particle-academy/google-docs-ui');
|
|
5
|
+
|
|
6
|
+
// src/flow.ts
|
|
7
|
+
|
|
8
|
+
// src/faker.ts
|
|
9
|
+
function fakeDocumentCreate({ config, fake }) {
|
|
10
|
+
return {
|
|
11
|
+
"documentId": fake.id("1Doc"),
|
|
12
|
+
"title": config.title !== void 0 && config.title !== null && config.title !== "" ? String(config.title) : "Untitled document"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
var googleDocsFaker = (operation, request) => {
|
|
16
|
+
switch (operation) {
|
|
17
|
+
case "document_create":
|
|
18
|
+
return fakeDocumentCreate(request);
|
|
19
|
+
default:
|
|
20
|
+
throw new Error(
|
|
21
|
+
`google_docs: 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.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/service.ts
|
|
27
|
+
var GOOGLE_DOCS_BASE_URLS = {
|
|
28
|
+
"live": "https://docs.googleapis.com"
|
|
29
|
+
};
|
|
30
|
+
var GOOGLE_DOCS_REQUIRES = [
|
|
31
|
+
"accessToken",
|
|
32
|
+
"refreshToken",
|
|
33
|
+
"clientId",
|
|
34
|
+
"clientSecret"
|
|
35
|
+
];
|
|
36
|
+
function googleDocsAuthorize(credentials, request, _mode) {
|
|
37
|
+
request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
|
|
38
|
+
}
|
|
39
|
+
var GOOGLE_DOCS = {
|
|
40
|
+
service: "google_docs",
|
|
41
|
+
title: "Google Docs",
|
|
42
|
+
sandbox: "none",
|
|
43
|
+
baseUrls: { ...GOOGLE_DOCS_BASE_URLS },
|
|
44
|
+
requires: [...GOOGLE_DOCS_REQUIRES],
|
|
45
|
+
authorize: googleDocsAuthorize,
|
|
46
|
+
faker: googleDocsFaker
|
|
47
|
+
};
|
|
48
|
+
var DOCUMENT_CREATE_OPERATION = "document_create";
|
|
49
|
+
async function googleDocsDocumentCreate(options) {
|
|
50
|
+
const config = options.config ?? {};
|
|
51
|
+
if (config.title === void 0 || config.title === null || config.title === "") {
|
|
52
|
+
throw new Error(`document_create: "title" is required (Title).`);
|
|
53
|
+
}
|
|
54
|
+
return fancyConnectorCore.callConnector(GOOGLE_DOCS, {
|
|
55
|
+
operation: DOCUMENT_CREATE_OPERATION,
|
|
56
|
+
config,
|
|
57
|
+
input: options.input,
|
|
58
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
59
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
60
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
61
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
62
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
63
|
+
request: {
|
|
64
|
+
method: "POST",
|
|
65
|
+
path: "/v1/documents",
|
|
66
|
+
json: {
|
|
67
|
+
"title": String(config.title)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/flow.ts
|
|
74
|
+
var googleDocsDocumentExecutor = async (ctx) => {
|
|
75
|
+
const config = ctx.node.data?.config ?? {};
|
|
76
|
+
const result = await googleDocsDocumentCreate({
|
|
77
|
+
config,
|
|
78
|
+
input: ctx.inputs?.in
|
|
79
|
+
});
|
|
80
|
+
ctx.emit({
|
|
81
|
+
type: "log",
|
|
82
|
+
level: "info",
|
|
83
|
+
nodeId: ctx.node.id,
|
|
84
|
+
message: `google_docs document_create ${result.data?.id} (${result.mode})`
|
|
85
|
+
});
|
|
86
|
+
return { __port: "out", value: result };
|
|
87
|
+
};
|
|
88
|
+
var GOOGLE_DOCS_RUNNABLE_KINDS = [
|
|
89
|
+
{ ...googleDocsUi.googleDocsDocumentKind, executor: googleDocsDocumentExecutor }
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
exports.GOOGLE_DOCS_RUNNABLE_KINDS = GOOGLE_DOCS_RUNNABLE_KINDS;
|
|
93
|
+
exports.googleDocsDocumentExecutor = googleDocsDocumentExecutor;
|
|
94
|
+
//# sourceMappingURL=flow.cjs.map
|
|
95
|
+
//# sourceMappingURL=flow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/document-create.ts","../src/flow.ts"],"names":["callConnector","googleDocsDocumentKind"],"mappings":";;;;;;;;AAyBA,SAAS,kBAAA,CAAmB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAClE,EAAA,OAAO;AAAA,IACL,YAAA,EAAc,IAAA,CAAK,EAAA,CAAG,MAAM,CAAA;AAAA,IAC5B,OAAA,EAAU,MAAA,CAAO,KAAA,KAAU,MAAA,IAAa,MAAA,CAAO,KAAA,KAAU,IAAA,IAAQ,MAAA,CAAO,KAAA,KAAU,EAAA,GAAK,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA,GAAI;AAAA,GAChH;AACF;AAEO,IAAM,eAAA,GAAkC,CAAC,SAAA,EAAW,OAAA,KAAY;AACrE,EAAA,QAAQ,SAAA;AAAW,IACjB,KAAK,iBAAA;AACH,MAAA,OAAO,mBAAmB,OAAO,CAAA;AAAA,IAEnC;AAIE,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,iDAAiD,SAAS,CAAA,iJAAA;AAAA,OAG5D;AAAA;AAEN,CAAA;;;ACRO,IAAM,qBAAA,GAAwB;AAAA,EACnC,MAAA,EAAQ;AACV,CAAA;AAGO,IAAM,oBAAA,GAAuB;AAAA,EAClC,aAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA;AAWO,SAAS,mBAAA,CACd,WAAA,EACA,OAAA,EACA,KAAA,EACM;AACN,EAAA,OAAA,CAAQ,OAAA,CAAQ,aAAA,GAAgB,CAAA,OAAA,EAAU,WAAA,CAAY,eAAe,EAAE,CAAA,CAAA;AACzE;AAGO,IAAM,WAAA,GAAiC;AAAA,EAC5C,OAAA,EAAS,aAAA;AAAA,EACT,KAAA,EAAO,aAAA;AAAA,EACP,OAAA,EAAS,MAAA;AAAA,EACT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,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK;AAAA;AAC9B;AACF,GACD,CAAA;AACH;;;ACnCO,IAAM,0BAAA,GAA2C,OAAO,GAAA,KAAQ;AACrE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,wBAAA,CAAyB;AAAA,IAC5C,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,4BAAA,EAAgC,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GAC7F,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,0BAAA,GAAmD;AAAA,EAC9D,EAAE,GAAGC,mCAAA,EAAwB,QAAA,EAAU,0BAAA;AACzC","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_docs\n */\n\n/**\n * The Google Docs faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Google Docs actually publishes, so an author can wire {{ $json.data.id\n * }} against a fake and have it keep working against the real 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 fakeDocumentCreate({ config, fake }: FakeRequest): unknown {\n return {\n \"documentId\": fake.id(\"1Doc\"),\n \"title\": (config.title !== undefined && config.title !== null && config.title !== \"\" ? String(config.title) : \"Untitled document\"),\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"document_create\":\n return fakeDocumentCreate(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_docs: 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_docs\n */\n\n/**\n * Google Docs, as one service descriptor shared by every Google Docs\n * operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Google Docs: its base URL, its auth\n * 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 Docs. A test document is a real one in a real\n * Drive, so every create is real -- use the faker while developing and clean\n * up any live test documents.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { googleDocsFaker } 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_DOCS_BASE_URLS = {\n \"live\": \"https://docs.googleapis.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const GOOGLE_DOCS_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Google Docs'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 googleDocsAuthorize(\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 Docs service, for the TypeScript runtime. */\nexport const GOOGLE_DOCS: ServiceDescriptor = {\n service: \"google_docs\",\n title: \"Google Docs\",\n sandbox: \"none\",\n baseUrls: { ...GOOGLE_DOCS_BASE_URLS },\n requires: [...GOOGLE_DOCS_REQUIRES],\n authorize: googleDocsAuthorize,\n faker: googleDocsFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/document-create.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/document-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Create a blank Google Docs document.\n *\n * POST /v1/documents —\n * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/create\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 Docs 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_DOCS } from \"../service.js\";\n\nexport const DOCUMENT_CREATE_OPERATION = \"document_create\";\n\nexport type DocumentCreateOptions = {\n /** The node's resolved config. Keys: title. */\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 googleDocsDocumentCreate(options: DocumentCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.title === undefined || config.title === null || config.title === \"\") {\n throw new Error(`document_create: \"title\" is required (Title).`);\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: DOCUMENT_CREATE_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: \"/v1/documents\",\n json: {\n \"title\": String(config.title),\n },\n },\n });\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_docs\n */\n\n/**\n * Google Docs's node kinds with their TypeScript executors attached — for\n * hosts that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/google-docs-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_DOCS } from \"./service.js\";\n\nimport {\n googleDocsDocumentKind,\n} from \"@particle-academy/google-docs-ui\";\n\nimport { googleDocsDocumentCreate } from \"./actions/document-create.js\";\n\nexport const googleDocsDocumentExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleDocsDocumentCreate({\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_docs document_create ${(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_DOCS_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...googleDocsDocumentKind, executor: googleDocsDocumentExecutor },\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_docs
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Google Docs's node kinds with their TypeScript executors attached — for
|
|
15
|
+
* hosts that EXECUTE on TS.
|
|
16
|
+
*
|
|
17
|
+
* The authoring surface in @particle-academy/google-docs-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 googleDocsDocumentExecutor: NodeExecutor;
|
|
23
|
+
/** The kinds a TypeScript host registers. */
|
|
24
|
+
declare const GOOGLE_DOCS_RUNNABLE_KINDS: NodeKindDefinition[];
|
|
25
|
+
|
|
26
|
+
export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor };
|
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_docs
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Google Docs's node kinds with their TypeScript executors attached — for
|
|
15
|
+
* hosts that EXECUTE on TS.
|
|
16
|
+
*
|
|
17
|
+
* The authoring surface in @particle-academy/google-docs-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 googleDocsDocumentExecutor: NodeExecutor;
|
|
23
|
+
/** The kinds a TypeScript host registers. */
|
|
24
|
+
declare const GOOGLE_DOCS_RUNNABLE_KINDS: NodeKindDefinition[];
|
|
25
|
+
|
|
26
|
+
export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor };
|
package/dist/flow.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { googleDocsDocumentCreate } from './chunk-2X6MFNGK.js';
|
|
2
|
+
import '@particle-academy/fancy-connector-core';
|
|
3
|
+
import { googleDocsDocumentKind } from '@particle-academy/google-docs-ui';
|
|
4
|
+
|
|
5
|
+
var googleDocsDocumentExecutor = async (ctx) => {
|
|
6
|
+
const config = ctx.node.data?.config ?? {};
|
|
7
|
+
const result = await googleDocsDocumentCreate({
|
|
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_docs document_create ${result.data?.id} (${result.mode})`
|
|
16
|
+
});
|
|
17
|
+
return { __port: "out", value: result };
|
|
18
|
+
};
|
|
19
|
+
var GOOGLE_DOCS_RUNNABLE_KINDS = [
|
|
20
|
+
{ ...googleDocsDocumentKind, executor: googleDocsDocumentExecutor }
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor };
|
|
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,0BAAA,GAA2C,OAAO,GAAA,KAAQ;AACrE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,wBAAA,CAAyB;AAAA,IAC5C,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,4BAAA,EAAgC,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GAC7F,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,0BAAA,GAAmD;AAAA,EAC9D,EAAE,GAAG,sBAAA,EAAwB,QAAA,EAAU,0BAAA;AACzC","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_docs\n */\n\n/**\n * Google Docs's node kinds with their TypeScript executors attached — for\n * hosts that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/google-docs-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_DOCS } from \"./service.js\";\n\nimport {\n googleDocsDocumentKind,\n} from \"@particle-academy/google-docs-ui\";\n\nimport { googleDocsDocumentCreate } from \"./actions/document-create.js\";\n\nexport const googleDocsDocumentExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleDocsDocumentCreate({\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_docs document_create ${(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_DOCS_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...googleDocsDocumentKind, executor: googleDocsDocumentExecutor },\n];\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
|
|
4
|
+
|
|
5
|
+
// src/faker.ts
|
|
6
|
+
function fakeDocumentCreate({ config, fake }) {
|
|
7
|
+
return {
|
|
8
|
+
"documentId": fake.id("1Doc"),
|
|
9
|
+
"title": config.title !== void 0 && config.title !== null && config.title !== "" ? String(config.title) : "Untitled document"
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
var googleDocsFaker = (operation, request) => {
|
|
13
|
+
switch (operation) {
|
|
14
|
+
case "document_create":
|
|
15
|
+
return fakeDocumentCreate(request);
|
|
16
|
+
default:
|
|
17
|
+
throw new Error(
|
|
18
|
+
`google_docs: 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.`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/service.ts
|
|
24
|
+
var CONNECTOR_API_VERSION = 1;
|
|
25
|
+
var GOOGLE_DOCS_BASE_URLS = {
|
|
26
|
+
"live": "https://docs.googleapis.com"
|
|
27
|
+
};
|
|
28
|
+
var GOOGLE_DOCS_REQUIRES = [
|
|
29
|
+
"accessToken",
|
|
30
|
+
"refreshToken",
|
|
31
|
+
"clientId",
|
|
32
|
+
"clientSecret"
|
|
33
|
+
];
|
|
34
|
+
function googleDocsAuthorize(credentials, request, _mode) {
|
|
35
|
+
request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
|
|
36
|
+
}
|
|
37
|
+
var GOOGLE_DOCS = {
|
|
38
|
+
service: "google_docs",
|
|
39
|
+
title: "Google Docs",
|
|
40
|
+
sandbox: "none",
|
|
41
|
+
baseUrls: { ...GOOGLE_DOCS_BASE_URLS },
|
|
42
|
+
requires: [...GOOGLE_DOCS_REQUIRES],
|
|
43
|
+
authorize: googleDocsAuthorize,
|
|
44
|
+
faker: googleDocsFaker
|
|
45
|
+
};
|
|
46
|
+
var DOCUMENT_CREATE_OPERATION = "document_create";
|
|
47
|
+
async function googleDocsDocumentCreate(options) {
|
|
48
|
+
const config = options.config ?? {};
|
|
49
|
+
if (config.title === void 0 || config.title === null || config.title === "") {
|
|
50
|
+
throw new Error(`document_create: "title" is required (Title).`);
|
|
51
|
+
}
|
|
52
|
+
return fancyConnectorCore.callConnector(GOOGLE_DOCS, {
|
|
53
|
+
operation: DOCUMENT_CREATE_OPERATION,
|
|
54
|
+
config,
|
|
55
|
+
input: options.input,
|
|
56
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
57
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
58
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
59
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
60
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
61
|
+
request: {
|
|
62
|
+
method: "POST",
|
|
63
|
+
path: "/v1/documents",
|
|
64
|
+
json: {
|
|
65
|
+
"title": String(config.title)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
exports.CONNECTOR_API_VERSION = CONNECTOR_API_VERSION;
|
|
72
|
+
exports.DOCUMENT_CREATE_OPERATION = DOCUMENT_CREATE_OPERATION;
|
|
73
|
+
exports.GOOGLE_DOCS = GOOGLE_DOCS;
|
|
74
|
+
exports.GOOGLE_DOCS_BASE_URLS = GOOGLE_DOCS_BASE_URLS;
|
|
75
|
+
exports.GOOGLE_DOCS_REQUIRES = GOOGLE_DOCS_REQUIRES;
|
|
76
|
+
exports.googleDocsAuthorize = googleDocsAuthorize;
|
|
77
|
+
exports.googleDocsDocumentCreate = googleDocsDocumentCreate;
|
|
78
|
+
exports.googleDocsFaker = googleDocsFaker;
|
|
79
|
+
//# sourceMappingURL=index.cjs.map
|
|
80
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/document-create.ts"],"names":["callConnector"],"mappings":";;;;;AAyBA,SAAS,kBAAA,CAAmB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAClE,EAAA,OAAO;AAAA,IACL,YAAA,EAAc,IAAA,CAAK,EAAA,C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AO,UAAU,MAAA,IAAa,MAAA,CAAO,UAAU,IAAA,IAAQ,MAAA,CAAO,UAAU,EAAA,EAAI;AAC9E,IAAA,MAAM,IAAI,MAAM,CAAA,6CAAA,CAA+C,CAAA;AAAA,EACjE;AAEA,EAAA,OAAOA,iCAAc,WAAA,EAAa;AAAA,IAChC,SAAA,EAAW,yBAAA;AAAA,IACX,MAAA;AAAA,IACA,OAAO,OAAA,CAAQ,KAAA;AAAA,IACf,GAAI,QAAQ,WAAA,KAAgB,MAAA,GAAY,EAAC,GAAI,EAAE,WAAA,EAAa,OAAA,CAAQ,WAAA,EAAY;AAAA,IAChF,GAAI,QAAQ,IAAA,KAAS,MAAA,GAAY,EAAC,GAAI,EAAE,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAK;AAAA,IAC3D,GAAI,QAAQ,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,YAAA,EAAc,OAAA,CAAQ,YAAA,EAAa;AAAA,IACnF,GAAI,QAAQ,QAAA,KAAa,MAAA,GAAY,EAAC,GAAI,EAAE,QAAA,EAAU,OAAA,CAAQ,QAAA,EAAS;AAAA,IACvE,GAAI,QAAQ,SAAA,KAAc,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,OAAA,CAAQ,SAAA,EAAU;AAAA,IAC1E,OAAA,EAAS;AAAA,MACP,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,eAAA;AAAA,MACN,IAAA,EAAM;AAAA,QACJ,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK;AAAA;AAC9B;AACF,GACD,CAAA;AACH","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_docs\n */\n\n/**\n * The Google Docs faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Google Docs actually publishes, so an author can wire {{ $json.data.id\n * }} against a fake and have it keep working against the real 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 fakeDocumentCreate({ config, fake }: FakeRequest): unknown {\n return {\n \"documentId\": fake.id(\"1Doc\"),\n \"title\": (config.title !== undefined && config.title !== null && config.title !== \"\" ? String(config.title) : \"Untitled document\"),\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"document_create\":\n return fakeDocumentCreate(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_docs: 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_docs\n */\n\n/**\n * Google Docs, as one service descriptor shared by every Google Docs\n * operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Google Docs: its base URL, its auth\n * 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 Docs. A test document is a real one in a real\n * Drive, so every create is real -- use the faker while developing and clean\n * up any live test documents.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { googleDocsFaker } 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_DOCS_BASE_URLS = {\n \"live\": \"https://docs.googleapis.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const GOOGLE_DOCS_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Google Docs'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 googleDocsAuthorize(\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 Docs service, for the TypeScript runtime. */\nexport const GOOGLE_DOCS: ServiceDescriptor = {\n service: \"google_docs\",\n title: \"Google Docs\",\n sandbox: \"none\",\n baseUrls: { ...GOOGLE_DOCS_BASE_URLS },\n requires: [...GOOGLE_DOCS_REQUIRES],\n authorize: googleDocsAuthorize,\n faker: googleDocsFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/document-create.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/document-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Create a blank Google Docs document.\n *\n * POST /v1/documents —\n * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/create\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 Docs 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_DOCS } from \"../service.js\";\n\nexport const DOCUMENT_CREATE_OPERATION = \"document_create\";\n\nexport type DocumentCreateOptions = {\n /** The node's resolved config. Keys: title. */\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 googleDocsDocumentCreate(options: DocumentCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.title === undefined || config.title === null || config.title === \"\") {\n throw new Error(`document_create: \"title\" is required (Title).`);\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: DOCUMENT_CREATE_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: \"/v1/documents\",\n json: {\n \"title\": String(config.title),\n },\n },\n });\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
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_docs
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Google Docs, as one service descriptor shared by every Google Docs
|
|
15
|
+
* operation.
|
|
16
|
+
*
|
|
17
|
+
* @particle-academy/fancy-connector-core carries what is true of ALL
|
|
18
|
+
* connectors. This carries what is true of Google Docs: its base URL, its auth
|
|
19
|
+
* 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 Docs. A test document is a real one in a real
|
|
24
|
+
* Drive, so every create is real -- use the faker while developing and clean
|
|
25
|
+
* up any live test documents.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The connector API version this package was GENERATED against.
|
|
30
|
+
*
|
|
31
|
+
* A literal, never imported. An imported constant lets an upgrade rewrite the
|
|
32
|
+
* very claim it exists to detect, after which the copy agrees with itself
|
|
33
|
+
* forever.
|
|
34
|
+
*/
|
|
35
|
+
declare const CONNECTOR_API_VERSION = 1;
|
|
36
|
+
declare const GOOGLE_DOCS_BASE_URLS: {
|
|
37
|
+
readonly live: "https://docs.googleapis.com";
|
|
38
|
+
};
|
|
39
|
+
/** Credential keys a remote call cannot proceed without. */
|
|
40
|
+
declare const GOOGLE_DOCS_REQUIRES: readonly ["accessToken", "refreshToken", "clientId", "clientSecret"];
|
|
41
|
+
/**
|
|
42
|
+
* Apply Google Docs's auth scheme to an outgoing request.
|
|
43
|
+
*
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
* The mode is passed in because for some providers auth and estate are the
|
|
47
|
+
* same decision expressed in the URL; here it is unused, and saying so is
|
|
48
|
+
* cheaper than wondering later whether it was forgotten.
|
|
49
|
+
*/
|
|
50
|
+
declare function googleDocsAuthorize(credentials: Record<string, string | undefined>, request: PreparedRequest, _mode: ConnectorMode): void;
|
|
51
|
+
/** The Google Docs service, for the TypeScript runtime. */
|
|
52
|
+
declare const GOOGLE_DOCS: ServiceDescriptor;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* GENERATED FILE — do not edit.
|
|
56
|
+
*
|
|
57
|
+
* Emitted from provider/fixtures/ by weaver's generator.
|
|
58
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
59
|
+
* being rejected, because it works until it silently does not. Fix
|
|
60
|
+
* provider/fixtures/ (or weaver's template/) and regenerate:
|
|
61
|
+
*
|
|
62
|
+
* npm run provider -- google_docs
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* The Google Docs faker.
|
|
66
|
+
*
|
|
67
|
+
* Shapes, not behaviour: the goal is that a downstream node sees the field
|
|
68
|
+
* NAMES Google Docs actually publishes, so an author can wire {{ $json.data.id
|
|
69
|
+
* }} against a fake and have it keep working against the real thing.
|
|
70
|
+
*
|
|
71
|
+
* Deterministic — same inputs, same output. A faker returning a fresh uuid
|
|
72
|
+
* every call cannot be asserted on, so its fixtures degrade to "it did not
|
|
73
|
+
* throw", which is the assertion that catches nothing.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
declare const googleDocsFaker: ConnectorFaker;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* GENERATED FILE — do not edit.
|
|
80
|
+
*
|
|
81
|
+
* Emitted from provider/actions/document-create.json by weaver's generator.
|
|
82
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
83
|
+
* being rejected, because it works until it silently does not. Fix
|
|
84
|
+
* provider/actions/document-create.json (or weaver's template/) and regenerate:
|
|
85
|
+
*
|
|
86
|
+
* npm run provider -- google_docs
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* Create a blank Google Docs document.
|
|
90
|
+
*
|
|
91
|
+
* POST /v1/documents —
|
|
92
|
+
* https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/create
|
|
93
|
+
*
|
|
94
|
+
* Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
|
|
95
|
+
* no fake/real branch. This describes the request; callConnector resolves the
|
|
96
|
+
* connection, picks the estate, and either calls Google Docs or calls the
|
|
97
|
+
* faker.
|
|
98
|
+
*
|
|
99
|
+
* sideEffects: unsafe-to-replay.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
declare const DOCUMENT_CREATE_OPERATION = "document_create";
|
|
103
|
+
type DocumentCreateOptions = {
|
|
104
|
+
/** The node's resolved config. Keys: title. */
|
|
105
|
+
config: Record<string, unknown>;
|
|
106
|
+
credentials?: Record<string, string | undefined>;
|
|
107
|
+
mode?: RequestedMode;
|
|
108
|
+
connectionId?: string | null;
|
|
109
|
+
input?: unknown;
|
|
110
|
+
attempts?: number;
|
|
111
|
+
/** Override the transport. The only way to exercise this without a network. */
|
|
112
|
+
transport?: Transport;
|
|
113
|
+
};
|
|
114
|
+
declare function googleDocsDocumentCreate(options: DocumentCreateOptions): Promise<ConnectorResult>;
|
|
115
|
+
|
|
116
|
+
export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, type DocumentCreateOptions, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
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_docs
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Google Docs, as one service descriptor shared by every Google Docs
|
|
15
|
+
* operation.
|
|
16
|
+
*
|
|
17
|
+
* @particle-academy/fancy-connector-core carries what is true of ALL
|
|
18
|
+
* connectors. This carries what is true of Google Docs: its base URL, its auth
|
|
19
|
+
* 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 Docs. A test document is a real one in a real
|
|
24
|
+
* Drive, so every create is real -- use the faker while developing and clean
|
|
25
|
+
* up any live test documents.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The connector API version this package was GENERATED against.
|
|
30
|
+
*
|
|
31
|
+
* A literal, never imported. An imported constant lets an upgrade rewrite the
|
|
32
|
+
* very claim it exists to detect, after which the copy agrees with itself
|
|
33
|
+
* forever.
|
|
34
|
+
*/
|
|
35
|
+
declare const CONNECTOR_API_VERSION = 1;
|
|
36
|
+
declare const GOOGLE_DOCS_BASE_URLS: {
|
|
37
|
+
readonly live: "https://docs.googleapis.com";
|
|
38
|
+
};
|
|
39
|
+
/** Credential keys a remote call cannot proceed without. */
|
|
40
|
+
declare const GOOGLE_DOCS_REQUIRES: readonly ["accessToken", "refreshToken", "clientId", "clientSecret"];
|
|
41
|
+
/**
|
|
42
|
+
* Apply Google Docs's auth scheme to an outgoing request.
|
|
43
|
+
*
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
* The mode is passed in because for some providers auth and estate are the
|
|
47
|
+
* same decision expressed in the URL; here it is unused, and saying so is
|
|
48
|
+
* cheaper than wondering later whether it was forgotten.
|
|
49
|
+
*/
|
|
50
|
+
declare function googleDocsAuthorize(credentials: Record<string, string | undefined>, request: PreparedRequest, _mode: ConnectorMode): void;
|
|
51
|
+
/** The Google Docs service, for the TypeScript runtime. */
|
|
52
|
+
declare const GOOGLE_DOCS: ServiceDescriptor;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* GENERATED FILE — do not edit.
|
|
56
|
+
*
|
|
57
|
+
* Emitted from provider/fixtures/ by weaver's generator.
|
|
58
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
59
|
+
* being rejected, because it works until it silently does not. Fix
|
|
60
|
+
* provider/fixtures/ (or weaver's template/) and regenerate:
|
|
61
|
+
*
|
|
62
|
+
* npm run provider -- google_docs
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* The Google Docs faker.
|
|
66
|
+
*
|
|
67
|
+
* Shapes, not behaviour: the goal is that a downstream node sees the field
|
|
68
|
+
* NAMES Google Docs actually publishes, so an author can wire {{ $json.data.id
|
|
69
|
+
* }} against a fake and have it keep working against the real thing.
|
|
70
|
+
*
|
|
71
|
+
* Deterministic — same inputs, same output. A faker returning a fresh uuid
|
|
72
|
+
* every call cannot be asserted on, so its fixtures degrade to "it did not
|
|
73
|
+
* throw", which is the assertion that catches nothing.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
declare const googleDocsFaker: ConnectorFaker;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* GENERATED FILE — do not edit.
|
|
80
|
+
*
|
|
81
|
+
* Emitted from provider/actions/document-create.json by weaver's generator.
|
|
82
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
83
|
+
* being rejected, because it works until it silently does not. Fix
|
|
84
|
+
* provider/actions/document-create.json (or weaver's template/) and regenerate:
|
|
85
|
+
*
|
|
86
|
+
* npm run provider -- google_docs
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* Create a blank Google Docs document.
|
|
90
|
+
*
|
|
91
|
+
* POST /v1/documents —
|
|
92
|
+
* https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/create
|
|
93
|
+
*
|
|
94
|
+
* Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
|
|
95
|
+
* no fake/real branch. This describes the request; callConnector resolves the
|
|
96
|
+
* connection, picks the estate, and either calls Google Docs or calls the
|
|
97
|
+
* faker.
|
|
98
|
+
*
|
|
99
|
+
* sideEffects: unsafe-to-replay.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
declare const DOCUMENT_CREATE_OPERATION = "document_create";
|
|
103
|
+
type DocumentCreateOptions = {
|
|
104
|
+
/** The node's resolved config. Keys: title. */
|
|
105
|
+
config: Record<string, unknown>;
|
|
106
|
+
credentials?: Record<string, string | undefined>;
|
|
107
|
+
mode?: RequestedMode;
|
|
108
|
+
connectionId?: string | null;
|
|
109
|
+
input?: unknown;
|
|
110
|
+
attempts?: number;
|
|
111
|
+
/** Override the transport. The only way to exercise this without a network. */
|
|
112
|
+
transport?: Transport;
|
|
113
|
+
};
|
|
114
|
+
declare function googleDocsDocumentCreate(options: DocumentCreateOptions): Promise<ConnectorResult>;
|
|
115
|
+
|
|
116
|
+
export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, type DocumentCreateOptions, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker } from './chunk-2X6MFNGK.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-docs-js",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Google Docs 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-docs.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/Fancy-Friends/google-docs#readme",
|
|
10
|
+
"bugs": "https://github.com/Fancy-Friends/google-docs/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-docs-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_docs",
|
|
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
|
+
}
|