@particle-academy/google-docs-js 0.3.4 → 0.5.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 CHANGED
@@ -8,6 +8,42 @@ The four packages share one version, because they are generated from one
8
8
  `provider/` definition and a version that meant something different in each
9
9
  would be a version nobody could reason about.
10
10
 
11
+ ## [0.5.0] — 2026-11-08
12
+
13
+ ### Added
14
+
15
+ - **Laravel integration, in this package** (`src/Laravel/`), auto-discovered
16
+ through composer's `extra.laravel`. Laravel is SUGGESTED, never required:
17
+ outside a Laravel app none of it loads.
18
+ - a service provider that merges `config/google-docs.php` under
19
+ `connectors.google-docs` (credentials from the environment, or per call for a
20
+ multi-account app);
21
+ - the `GoogleDocs` facade: `GoogleDocs::call('<operation>', [...])` runs any action;
22
+ - `GoogleDocs::fake()`, answered from the connector's faker, with
23
+ `assertSent` / `assertNotSent` / `assertNothingSent` / `assertSentCount`;
24
+ - its own Pest test of all of it against a booted Laravel app.
25
+
26
+ ### Changed
27
+
28
+ - **Tests: Pest `^5`**, and `laravel/framework` `^13` as a DEV-ONLY test
29
+ dependency (the framework this package integrates with; nothing ships in
30
+ `require`).
31
+
32
+ ## [0.4.0] — 2026-10-01
33
+
34
+ ### Added
35
+
36
+ - **`text_insert`** — insert plain text into an existing document's body
37
+ (`documents.batchUpdate`, a single `insertText` request). No scope
38
+ change. Until now `document_create` could only make a BLANK document
39
+ with no way to ever put content in it.
40
+ - Deliberately NOT included: the general `batchUpdate` escape hatch (an
41
+ author-supplied array of Google's dozens of typed request kinds —
42
+ `deleteContentRange`, `replaceAllText`, `insertTable`, text styling,
43
+ ...). That needs an array-of-polymorphic-objects config shape nothing
44
+ in this estate has used before — a real second need, not a first
45
+ guess, same bar as everything in `vocabulary-deferred.md`.
46
+
11
47
  ## [0.3.4] — 2026-09-12
12
48
 
13
49
  ### Changed
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Google Docs
2
2
 
3
+ [![Fancified](art/fancified.svg)](https://particle.academy)
4
+
3
5
  Google Docs for [fancy-flow][flow] — as **four imported, versioned packages**, one
4
6
  per runtime. Not vendored source: a copy cannot be upgraded, and third-party APIs
5
7
  change.
@@ -75,6 +77,18 @@ Create a blank Google Docs document.
75
77
  |---|---|---|
76
78
  | `title` | yes | The title of the new blank document. |
77
79
 
80
+ #### `text_insert` — Insert text into a Google Doc
81
+
82
+ Insert plain text at a position in an existing document's body.
83
+
84
+ `POST /v1/documents/{documentId}:batchUpdate` · **unsafe to replay** — a retried durable run does it TWICE
85
+
86
+ | Input | Required | What it is |
87
+ |---|---|---|
88
+ | `documentId` | yes | From document_create's data.documentId, or the id in the document's own URL. |
89
+ | `text` | yes | Inserted verbatim. A newline in it starts a new paragraph, carrying the style of whatever paragraph the insertion point sits in. |
90
+ | `index` | yes | A zero-based position in UTF-16 code units, but 0 itself is never valid -- Google's body content starts at index 1. 1 is the very beginning of a freshly created blank document. To append after existing content, read the document's own length first (not yet offered by this connector) and insert there instead. |
91
+
78
92
  ## Run it before you have credentials
79
93
 
80
94
  Every operation ships a **faker**, whether or not Google Docs has a sandbox. Set a
@@ -0,0 +1,26 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="28" role="img" aria-label="Fancified — built with Fancy UI">
2
+ <title>Fancified · built with Fancy UI</title>
3
+ <defs>
4
+ <linearGradient id="fcdBg" x1="0" y1="0" x2="1" y2="1">
5
+ <stop offset="0" stop-color="#6d28d9"/>
6
+ <stop offset=".5" stop-color="#9333ea"/>
7
+ <stop offset="1" stop-color="#d946ef"/>
8
+ </linearGradient>
9
+ <linearGradient id="fcdGloss" x1="0" y1="0" x2="0" y2="1">
10
+ <stop offset="0" stop-color="#ffffff" stop-opacity=".30"/>
11
+ <stop offset=".55" stop-color="#ffffff" stop-opacity="0"/>
12
+ </linearGradient>
13
+ <clipPath id="fcdClip"><rect width="128" height="28" rx="7"/></clipPath>
14
+ </defs>
15
+ <g clip-path="url(#fcdClip)">
16
+ <rect width="128" height="28" fill="url(#fcdBg)"/>
17
+ <rect width="34" height="28" fill="#3b0764" fill-opacity=".5"/>
18
+ <rect width="128" height="13" fill="url(#fcdGloss)"/>
19
+ <g fill="#fff">
20
+ <path transform="translate(17 14)" d="M0 -7 C.6 -2.2 2.2 -.6 7 0 C2.2 .6 .6 2.2 0 7 C-.6 2.2 -2.2 .6 -7 0 C-2.2 -.6 -.6 -2.2 0 -7 Z"/>
21
+ <path transform="translate(25.5 7.5) scale(.34)" fill-opacity=".85" d="M0 -7 C.6 -2.2 2.2 -.6 7 0 C2.2 .6 .6 2.2 0 7 C-.6 2.2 -2.2 .6 -7 0 C-2.2 -.6 -.6 -2.2 0 -7 Z"/>
22
+ </g>
23
+ <text x="81" y="18.5" fill="#ffffff" text-anchor="middle" font-family="'Segoe UI',Verdana,'DejaVu Sans',sans-serif" font-size="12" font-weight="700" letter-spacing=".3">Fancified</text>
24
+ </g>
25
+ <rect x=".5" y=".5" width="127" height="27" rx="6.5" fill="none" stroke="#ffffff" stroke-opacity=".22"/>
26
+ </svg>
@@ -0,0 +1,132 @@
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
+ function fakeTextInsert({ config, fake }) {
11
+ return {
12
+ "documentId": config.documentId !== void 0 && config.documentId !== null && config.documentId !== "" ? String(config.documentId) : fake.id("1Doc"),
13
+ "replies": [
14
+ {}
15
+ ]
16
+ };
17
+ }
18
+ var googleDocsFaker = (operation, request) => {
19
+ switch (operation) {
20
+ case "document_create":
21
+ return fakeDocumentCreate(request);
22
+ case "text_insert":
23
+ return fakeTextInsert(request);
24
+ default:
25
+ throw new Error(
26
+ `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.`
27
+ );
28
+ }
29
+ };
30
+
31
+ // src/service.ts
32
+ var CONNECTOR_API_VERSION = 1;
33
+ var GOOGLE_DOCS_BASE_URLS = {
34
+ "live": "https://docs.googleapis.com"
35
+ };
36
+ var GOOGLE_DOCS_REQUIRES = [
37
+ "accessToken",
38
+ "refreshToken",
39
+ "clientId",
40
+ "clientSecret"
41
+ ];
42
+ function googleDocsAuthorize(credentials, request, _mode) {
43
+ request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
44
+ }
45
+ var GOOGLE_DOCS = {
46
+ service: "google_docs",
47
+ title: "Google Docs",
48
+ sandbox: "none",
49
+ baseUrls: { ...GOOGLE_DOCS_BASE_URLS },
50
+ requires: [...GOOGLE_DOCS_REQUIRES],
51
+ authorize: googleDocsAuthorize,
52
+ faker: googleDocsFaker
53
+ };
54
+ var DOCUMENT_CREATE_OPERATION = "document_create";
55
+ async function googleDocsDocumentCreate(options) {
56
+ const config = options.config ?? {};
57
+ if (config.title === void 0 || config.title === null || config.title === "") {
58
+ throw new Error(`document_create: "title" is required (Title).`);
59
+ }
60
+ return callConnector(GOOGLE_DOCS, {
61
+ operation: DOCUMENT_CREATE_OPERATION,
62
+ config,
63
+ input: options.input,
64
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
65
+ ...options.mode === void 0 ? {} : { mode: options.mode },
66
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
67
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
68
+ ...options.transport === void 0 ? {} : { transport: options.transport },
69
+ request: {
70
+ method: "POST",
71
+ path: "/v1/documents",
72
+ json: {
73
+ "title": String(config.title)
74
+ }
75
+ }
76
+ });
77
+ }
78
+ var TEXT_INSERT_OPERATION = "text_insert";
79
+ async function googleDocsTextInsert(options) {
80
+ const config = options.config ?? {};
81
+ if (config.documentId === void 0 || config.documentId === null || config.documentId === "") {
82
+ throw new Error(`text_insert: "documentId" is required (Document ID).`);
83
+ }
84
+ if (config.text === void 0 || config.text === null || config.text === "") {
85
+ throw new Error(`text_insert: "text" is required (Text).`);
86
+ }
87
+ {
88
+ const n = Number(config.index);
89
+ if (!(Number.isInteger(n) && n >= 1)) {
90
+ throw new Error(
91
+ `text_insert: "index" must be a integer, got ${JSON.stringify(config.index)}.`
92
+ );
93
+ }
94
+ }
95
+ return callConnector(GOOGLE_DOCS, {
96
+ operation: TEXT_INSERT_OPERATION,
97
+ config,
98
+ input: options.input,
99
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
100
+ ...options.mode === void 0 ? {} : { mode: options.mode },
101
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
102
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
103
+ ...options.transport === void 0 ? {} : { transport: options.transport },
104
+ request: {
105
+ method: "POST",
106
+ path: `/v1/documents/${encodeURIComponent(String(config.documentId))}:batchUpdate`,
107
+ json: nestFields({
108
+ "requests.0.insertText.text": String(config.text),
109
+ "requests.0.insertText.location.index": Math.trunc(Number(config.index))
110
+ })
111
+ }
112
+ });
113
+ }
114
+ function nestFields(flat) {
115
+ const out = {};
116
+ for (const [path, value] of Object.entries(flat)) {
117
+ const parts = path.split(".");
118
+ let node = out;
119
+ while (parts.length > 1) {
120
+ const key = parts.shift();
121
+ const wantsArray = /^\d+$/.test(parts[0] ?? "");
122
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
123
+ node = node[key];
124
+ }
125
+ node[parts[0]] = value;
126
+ }
127
+ return out;
128
+ }
129
+
130
+ export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert };
131
+ //# sourceMappingURL=chunk-JRH65Q6F.js.map
132
+ //# sourceMappingURL=chunk-JRH65Q6F.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/document-create.ts","../src/actions/text-insert.ts"],"names":["callConnector"],"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;AAEA,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC9D,EAAA,OAAO;AAAA,IACL,cAAe,MAAA,CAAO,UAAA,KAAe,MAAA,IAAa,MAAA,CAAO,eAAe,IAAA,IAAQ,MAAA,CAAO,UAAA,KAAe,EAAA,GAAK,OAAO,MAAA,CAAO,UAAU,CAAA,GAAI,IAAA,CAAK,GAAG,MAAM,CAAA;AAAA,IACrJ,SAAA,EAAW;AAAA,MACT;AAAC;AACH,GACF;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,KAAK,aAAA;AACH,MAAA,OAAO,eAAe,OAAO,CAAA;AAAA,IAE/B;AAIE,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,iDAAiD,SAAS,CAAA,iJAAA;AAAA,OAG5D;AAAA;AAEN;;;ACtBO,IAAM,qBAAA,GAAwB;AAE9B,IAAM,qBAAA,GAAwB;AAAA,EACnC,MAAA,EAAQ;AACV;AAGO,IAAM,oBAAA,GAAuB;AAAA,EAClC,aAAA;AAAA,EACA,cAAA;AA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,GAAO,GAAA;AAEX,IAAA,OAAO,KAAA,CAAM,SAAS,CAAA,EAAG;AACvB,MAAA,MAAM,GAAA,GAAM,MAAM,KAAA,EAAM;AAMxB,MAAA,MAAM,aAAa,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,KAAK,EAAE,CAAA;AAE9C,MAAA,IAAI,OAAO,IAAA,CAAK,GAAG,CAAA,KAAM,YAAY,IAAA,CAAK,GAAG,CAAA,KAAM,IAAA,OAAW,GAAG,CAAA,GAAI,UAAA,GAAa,KAAK,EAAC;AACxF,MAAA,IAAA,GAAO,KAAK,GAAG,CAAA;AAAA,IACjB;AAEA,IAAA,IAAA,CAAK,KAAA,CAAM,CAAC,CAAW,CAAA,GAAI,KAAA;AAAA,EAC7B;AAEA,EAAA,OAAO,GAAA;AACT","file":"chunk-JRH65Q6F.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\nfunction fakeTextInsert({ config, fake }: FakeRequest): unknown {\n return {\n \"documentId\": (config.documentId !== undefined && config.documentId !== null && config.documentId !== \"\" ? String(config.documentId) : fake.id(\"1Doc\")),\n \"replies\": [\n {},\n ],\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"document_create\":\n return fakeDocumentCreate(request);\n\n case \"text_insert\":\n return fakeTextInsert(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/text-insert.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/text-insert.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Insert plain text at a position in an existing document's body.\n *\n * POST /v1/documents/{documentId}:batchUpdate —\n * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate\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 TEXT_INSERT_OPERATION = \"text_insert\";\n\nexport type TextInsertOptions = {\n /** The node's resolved config. Keys: documentId, text, index. */\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 googleDocsTextInsert(options: TextInsertOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.documentId === undefined || config.documentId === null || config.documentId === \"\") {\n throw new Error(`text_insert: \"documentId\" is required (Document ID).`);\n }\n\n if (config.text === undefined || config.text === null || config.text === \"\") {\n throw new Error(`text_insert: \"text\" is required (Text).`);\n }\n\n {\n const n = Number(config.index);\n if (!(Number.isInteger(n) && n >= 1)) {\n throw new Error(\n `text_insert: \"index\" must be a integer, got ${JSON.stringify(config.index)}.`,\n );\n }\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: TEXT_INSERT_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/${encodeURIComponent(String(config.documentId))}:batchUpdate`,\n json: nestFields({\n \"requests.0.insertText.text\": String(config.text),\n \"requests.0.insertText.location.index\": Math.trunc(Number(config.index)),\n }),\n },\n });\n}\n\n/**\n * `{\"properties.email\": x}` -> `{properties: {email: x}}`.\n *\n * A dotted `as` means NESTING, and only a JSON body can nest. The validator\n * refuses that spelling anywhere else, because in a form body it already means\n * something different — a literal dotted key.\n */\nfunction nestFields(flat: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split(\".\");\n let node = out;\n\n while (parts.length > 1) {\n const key = parts.shift() as string;\n // A NUMERIC segment is an array index: `dateRanges.0.startDate` has to\n // become `[{startDate}]`, not `{\"0\": {startDate}}`. PHP produced the\n // array by accident (its integer-keyed arrays serialise as JSON lists)\n // and the other two produced an object, which the provider rejects as\n // the wrong type. The parity suite is what caught the disagreement.\n const wantsArray = /^\\d+$/.test(parts[0] ?? \"\");\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = wantsArray ? [] : {};\n node = node[key] as Record<string, unknown>;\n }\n\n node[parts[0] as string] = value;\n }\n\n return out;\n}\n"]}
package/dist/flow.cjs CHANGED
@@ -12,10 +12,20 @@ function fakeDocumentCreate({ config, fake }) {
12
12
  "title": config.title !== void 0 && config.title !== null && config.title !== "" ? String(config.title) : "Untitled document"
13
13
  };
14
14
  }
15
+ function fakeTextInsert({ config, fake }) {
16
+ return {
17
+ "documentId": config.documentId !== void 0 && config.documentId !== null && config.documentId !== "" ? String(config.documentId) : fake.id("1Doc"),
18
+ "replies": [
19
+ {}
20
+ ]
21
+ };
22
+ }
15
23
  var googleDocsFaker = (operation, request) => {
16
24
  switch (operation) {
17
25
  case "document_create":
18
26
  return fakeDocumentCreate(request);
27
+ case "text_insert":
28
+ return fakeTextInsert(request);
19
29
  default:
20
30
  throw new Error(
21
31
  `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.`
@@ -69,6 +79,57 @@ async function googleDocsDocumentCreate(options) {
69
79
  }
70
80
  });
71
81
  }
82
+ var TEXT_INSERT_OPERATION = "text_insert";
83
+ async function googleDocsTextInsert(options) {
84
+ const config = options.config ?? {};
85
+ if (config.documentId === void 0 || config.documentId === null || config.documentId === "") {
86
+ throw new Error(`text_insert: "documentId" is required (Document ID).`);
87
+ }
88
+ if (config.text === void 0 || config.text === null || config.text === "") {
89
+ throw new Error(`text_insert: "text" is required (Text).`);
90
+ }
91
+ {
92
+ const n = Number(config.index);
93
+ if (!(Number.isInteger(n) && n >= 1)) {
94
+ throw new Error(
95
+ `text_insert: "index" must be a integer, got ${JSON.stringify(config.index)}.`
96
+ );
97
+ }
98
+ }
99
+ return fancyConnectorCore.callConnector(GOOGLE_DOCS, {
100
+ operation: TEXT_INSERT_OPERATION,
101
+ config,
102
+ input: options.input,
103
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
104
+ ...options.mode === void 0 ? {} : { mode: options.mode },
105
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
106
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
107
+ ...options.transport === void 0 ? {} : { transport: options.transport },
108
+ request: {
109
+ method: "POST",
110
+ path: `/v1/documents/${encodeURIComponent(String(config.documentId))}:batchUpdate`,
111
+ json: nestFields({
112
+ "requests.0.insertText.text": String(config.text),
113
+ "requests.0.insertText.location.index": Math.trunc(Number(config.index))
114
+ })
115
+ }
116
+ });
117
+ }
118
+ function nestFields(flat) {
119
+ const out = {};
120
+ for (const [path, value] of Object.entries(flat)) {
121
+ const parts = path.split(".");
122
+ let node = out;
123
+ while (parts.length > 1) {
124
+ const key = parts.shift();
125
+ const wantsArray = /^\d+$/.test(parts[0] ?? "");
126
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
127
+ node = node[key];
128
+ }
129
+ node[parts[0]] = value;
130
+ }
131
+ return out;
132
+ }
72
133
 
73
134
  // src/flow.ts
74
135
  var googleDocsDocumentExecutor = async (ctx) => {
@@ -85,11 +146,27 @@ var googleDocsDocumentExecutor = async (ctx) => {
85
146
  });
86
147
  return { __port: "out", value: result };
87
148
  };
149
+ var googleDocsTextInsertExecutor = async (ctx) => {
150
+ const config = ctx.node.data?.config ?? {};
151
+ const result = await googleDocsTextInsert({
152
+ config,
153
+ input: ctx.inputs?.in
154
+ });
155
+ ctx.emit({
156
+ type: "log",
157
+ level: "info",
158
+ nodeId: ctx.node.id,
159
+ message: `google_docs text_insert ${result.data?.id} (${result.mode})`
160
+ });
161
+ return { __port: "out", value: result };
162
+ };
88
163
  var GOOGLE_DOCS_RUNNABLE_KINDS = [
89
- { ...googleDocsUi.googleDocsDocumentKind, executor: googleDocsDocumentExecutor }
164
+ { ...googleDocsUi.googleDocsDocumentKind, executor: googleDocsDocumentExecutor },
165
+ { ...googleDocsUi.googleDocsTextInsertKind, executor: googleDocsTextInsertExecutor }
90
166
  ];
91
167
 
92
168
  exports.GOOGLE_DOCS_RUNNABLE_KINDS = GOOGLE_DOCS_RUNNABLE_KINDS;
93
169
  exports.googleDocsDocumentExecutor = googleDocsDocumentExecutor;
170
+ exports.googleDocsTextInsertExecutor = googleDocsTextInsertExecutor;
94
171
  //# sourceMappingURL=flow.cjs.map
95
172
  //# sourceMappingURL=flow.cjs.map
package/dist/flow.cjs.map CHANGED
@@ -1 +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,CAA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,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;;;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"]}
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/document-create.ts","../src/actions/text-insert.ts","../src/flow.ts"],"names":["callConnector","googleDocsDocumentKind","googleDocsTextInsertKind"],"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;AAEA,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC9D,EAAA,OAAO;AAAA,IACL,cAAe,MAAA,CAAO,UAAA,KAAe,MAAA,IAAa,MAAA,CAAO,eAAe,IAAA,IAAQ,MAAA,CAAO,UAAA,KAAe,EAAA,GAAK,OAAO,MAAA,CAAO,UAAU,CAAA,GAAI,IAAA,CAAK,GAAG,MAAM,CAAA;AAAA,IACrJ,SAAA,EAAW;AAAA,MACT;AAAC;AACH,G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A,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;AAEO,IAAM,4BAAA,GAA6C,OAAO,GAAA,KAAQ;AACvE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,oBAAA,CAAqB;AAAA,IACxC,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,wBAAA,EAA4B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GACzF,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,EAA2B;AAAA,EAClE,EAAE,GAAGC,qCAAA,EAA0B,QAAA,EAAU,4BAAA;AAC3C","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\nfunction fakeTextInsert({ config, fake }: FakeRequest): unknown {\n return {\n \"documentId\": (config.documentId !== undefined && config.documentId !== null && config.documentId !== \"\" ? String(config.documentId) : fake.id(\"1Doc\")),\n \"replies\": [\n {},\n ],\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"document_create\":\n return fakeDocumentCreate(request);\n\n case \"text_insert\":\n return fakeTextInsert(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/text-insert.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/text-insert.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Insert plain text at a position in an existing document's body.\n *\n * POST /v1/documents/{documentId}:batchUpdate —\n * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate\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 TEXT_INSERT_OPERATION = \"text_insert\";\n\nexport type TextInsertOptions = {\n /** The node's resolved config. Keys: documentId, text, index. */\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 googleDocsTextInsert(options: TextInsertOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.documentId === undefined || config.documentId === null || config.documentId === \"\") {\n throw new Error(`text_insert: \"documentId\" is required (Document ID).`);\n }\n\n if (config.text === undefined || config.text === null || config.text === \"\") {\n throw new Error(`text_insert: \"text\" is required (Text).`);\n }\n\n {\n const n = Number(config.index);\n if (!(Number.isInteger(n) && n >= 1)) {\n throw new Error(\n `text_insert: \"index\" must be a integer, got ${JSON.stringify(config.index)}.`,\n );\n }\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: TEXT_INSERT_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/${encodeURIComponent(String(config.documentId))}:batchUpdate`,\n json: nestFields({\n \"requests.0.insertText.text\": String(config.text),\n \"requests.0.insertText.location.index\": Math.trunc(Number(config.index)),\n }),\n },\n });\n}\n\n/**\n * `{\"properties.email\": x}` -> `{properties: {email: x}}`.\n *\n * A dotted `as` means NESTING, and only a JSON body can nest. The validator\n * refuses that spelling anywhere else, because in a form body it already means\n * something different — a literal dotted key.\n */\nfunction nestFields(flat: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split(\".\");\n let node = out;\n\n while (parts.length > 1) {\n const key = parts.shift() as string;\n // A NUMERIC segment is an array index: `dateRanges.0.startDate` has to\n // become `[{startDate}]`, not `{\"0\": {startDate}}`. PHP produced the\n // array by accident (its integer-keyed arrays serialise as JSON lists)\n // and the other two produced an object, which the provider rejects as\n // the wrong type. The parity suite is what caught the disagreement.\n const wantsArray = /^\\d+$/.test(parts[0] ?? \"\");\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = wantsArray ? [] : {};\n node = node[key] as Record<string, unknown>;\n }\n\n node[parts[0] as string] = value;\n }\n\n return out;\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 googleDocsTextInsertKind,\n} from \"@particle-academy/google-docs-ui\";\n\nimport { googleDocsDocumentCreate } from \"./actions/document-create.js\";\nimport { googleDocsTextInsert } from \"./actions/text-insert.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\nexport const googleDocsTextInsertExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleDocsTextInsert({\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 text_insert ${(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 { ...googleDocsTextInsertKind, executor: googleDocsTextInsertExecutor },\n];\n"]}
package/dist/flow.d.cts CHANGED
@@ -20,7 +20,8 @@ import { NodeKindDefinition, NodeExecutor } from '@particle-academy/fancy-flow/e
20
20
  */
21
21
 
22
22
  declare const googleDocsDocumentExecutor: NodeExecutor;
23
+ declare const googleDocsTextInsertExecutor: NodeExecutor;
23
24
  /** The kinds a TypeScript host registers. */
24
25
  declare const GOOGLE_DOCS_RUNNABLE_KINDS: NodeKindDefinition[];
25
26
 
26
- export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor };
27
+ export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor, googleDocsTextInsertExecutor };
package/dist/flow.d.ts CHANGED
@@ -20,7 +20,8 @@ import { NodeKindDefinition, NodeExecutor } from '@particle-academy/fancy-flow/e
20
20
  */
21
21
 
22
22
  declare const googleDocsDocumentExecutor: NodeExecutor;
23
+ declare const googleDocsTextInsertExecutor: NodeExecutor;
23
24
  /** The kinds a TypeScript host registers. */
24
25
  declare const GOOGLE_DOCS_RUNNABLE_KINDS: NodeKindDefinition[];
25
26
 
26
- export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor };
27
+ export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor, googleDocsTextInsertExecutor };
package/dist/flow.js CHANGED
@@ -1,6 +1,6 @@
1
- import { googleDocsDocumentCreate } from './chunk-2X6MFNGK.js';
1
+ import { googleDocsDocumentCreate, googleDocsTextInsert } from './chunk-JRH65Q6F.js';
2
2
  import '@particle-academy/fancy-connector-core';
3
- import { googleDocsDocumentKind } from '@particle-academy/google-docs-ui';
3
+ import { googleDocsDocumentKind, googleDocsTextInsertKind } from '@particle-academy/google-docs-ui';
4
4
 
5
5
  var googleDocsDocumentExecutor = async (ctx) => {
6
6
  const config = ctx.node.data?.config ?? {};
@@ -16,10 +16,25 @@ var googleDocsDocumentExecutor = async (ctx) => {
16
16
  });
17
17
  return { __port: "out", value: result };
18
18
  };
19
+ var googleDocsTextInsertExecutor = async (ctx) => {
20
+ const config = ctx.node.data?.config ?? {};
21
+ const result = await googleDocsTextInsert({
22
+ config,
23
+ input: ctx.inputs?.in
24
+ });
25
+ ctx.emit({
26
+ type: "log",
27
+ level: "info",
28
+ nodeId: ctx.node.id,
29
+ message: `google_docs text_insert ${result.data?.id} (${result.mode})`
30
+ });
31
+ return { __port: "out", value: result };
32
+ };
19
33
  var GOOGLE_DOCS_RUNNABLE_KINDS = [
20
- { ...googleDocsDocumentKind, executor: googleDocsDocumentExecutor }
34
+ { ...googleDocsDocumentKind, executor: googleDocsDocumentExecutor },
35
+ { ...googleDocsTextInsertKind, executor: googleDocsTextInsertExecutor }
21
36
  ];
22
37
 
23
- export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor };
38
+ export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor, googleDocsTextInsertExecutor };
24
39
  //# sourceMappingURL=flow.js.map
25
40
  //# sourceMappingURL=flow.js.map
package/dist/flow.js.map CHANGED
@@ -1 +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"]}
1
+ {"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;;AAsCO,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;AAEO,IAAM,4BAAA,GAA6C,OAAO,GAAA,KAAQ;AACvE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,oBAAA,CAAqB;AAAA,IACxC,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,wBAAA,EAA4B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GACzF,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,EAA2B;AAAA,EAClE,EAAE,GAAG,wBAAA,EAA0B,QAAA,EAAU,4BAAA;AAC3C","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 googleDocsTextInsertKind,\n} from \"@particle-academy/google-docs-ui\";\n\nimport { googleDocsDocumentCreate } from \"./actions/document-create.js\";\nimport { googleDocsTextInsert } from \"./actions/text-insert.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\nexport const googleDocsTextInsertExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleDocsTextInsert({\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 text_insert ${(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 { ...googleDocsTextInsertKind, executor: googleDocsTextInsertExecutor },\n];\n"]}
package/dist/index.cjs CHANGED
@@ -9,10 +9,20 @@ function fakeDocumentCreate({ config, fake }) {
9
9
  "title": config.title !== void 0 && config.title !== null && config.title !== "" ? String(config.title) : "Untitled document"
10
10
  };
11
11
  }
12
+ function fakeTextInsert({ config, fake }) {
13
+ return {
14
+ "documentId": config.documentId !== void 0 && config.documentId !== null && config.documentId !== "" ? String(config.documentId) : fake.id("1Doc"),
15
+ "replies": [
16
+ {}
17
+ ]
18
+ };
19
+ }
12
20
  var googleDocsFaker = (operation, request) => {
13
21
  switch (operation) {
14
22
  case "document_create":
15
23
  return fakeDocumentCreate(request);
24
+ case "text_insert":
25
+ return fakeTextInsert(request);
16
26
  default:
17
27
  throw new Error(
18
28
  `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.`
@@ -67,14 +77,67 @@ async function googleDocsDocumentCreate(options) {
67
77
  }
68
78
  });
69
79
  }
80
+ var TEXT_INSERT_OPERATION = "text_insert";
81
+ async function googleDocsTextInsert(options) {
82
+ const config = options.config ?? {};
83
+ if (config.documentId === void 0 || config.documentId === null || config.documentId === "") {
84
+ throw new Error(`text_insert: "documentId" is required (Document ID).`);
85
+ }
86
+ if (config.text === void 0 || config.text === null || config.text === "") {
87
+ throw new Error(`text_insert: "text" is required (Text).`);
88
+ }
89
+ {
90
+ const n = Number(config.index);
91
+ if (!(Number.isInteger(n) && n >= 1)) {
92
+ throw new Error(
93
+ `text_insert: "index" must be a integer, got ${JSON.stringify(config.index)}.`
94
+ );
95
+ }
96
+ }
97
+ return fancyConnectorCore.callConnector(GOOGLE_DOCS, {
98
+ operation: TEXT_INSERT_OPERATION,
99
+ config,
100
+ input: options.input,
101
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
102
+ ...options.mode === void 0 ? {} : { mode: options.mode },
103
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
104
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
105
+ ...options.transport === void 0 ? {} : { transport: options.transport },
106
+ request: {
107
+ method: "POST",
108
+ path: `/v1/documents/${encodeURIComponent(String(config.documentId))}:batchUpdate`,
109
+ json: nestFields({
110
+ "requests.0.insertText.text": String(config.text),
111
+ "requests.0.insertText.location.index": Math.trunc(Number(config.index))
112
+ })
113
+ }
114
+ });
115
+ }
116
+ function nestFields(flat) {
117
+ const out = {};
118
+ for (const [path, value] of Object.entries(flat)) {
119
+ const parts = path.split(".");
120
+ let node = out;
121
+ while (parts.length > 1) {
122
+ const key = parts.shift();
123
+ const wantsArray = /^\d+$/.test(parts[0] ?? "");
124
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
125
+ node = node[key];
126
+ }
127
+ node[parts[0]] = value;
128
+ }
129
+ return out;
130
+ }
70
131
 
71
132
  exports.CONNECTOR_API_VERSION = CONNECTOR_API_VERSION;
72
133
  exports.DOCUMENT_CREATE_OPERATION = DOCUMENT_CREATE_OPERATION;
73
134
  exports.GOOGLE_DOCS = GOOGLE_DOCS;
74
135
  exports.GOOGLE_DOCS_BASE_URLS = GOOGLE_DOCS_BASE_URLS;
75
136
  exports.GOOGLE_DOCS_REQUIRES = GOOGLE_DOCS_REQUIRES;
137
+ exports.TEXT_INSERT_OPERATION = TEXT_INSERT_OPERATION;
76
138
  exports.googleDocsAuthorize = googleDocsAuthorize;
77
139
  exports.googleDocsDocumentCreate = googleDocsDocumentCreate;
78
140
  exports.googleDocsFaker = googleDocsFaker;
141
+ exports.googleDocsTextInsert = googleDocsTextInsert;
79
142
  //# sourceMappingURL=index.cjs.map
80
143
  //# sourceMappingURL=index.cjs.map
@@ -1 +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,CAAG,MAAM,CAAA;AAAA,IAC5B,OAAA,EAAU,MAAA,CAAO,KAAA,KAAU,MAAA,IAAa,MAAA,CAAO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,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"]}
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/document-create.ts","../src/actions/text-insert.ts"],"names":["callConnector"],"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;AAEA,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC9D,EAAA,OAAO;AAAA,IACL,cAAe,MAAA,CAAO,UAAA,KAAe,MAAA,IAAa,MAAA,CAAO,eAAe,IAAA,IAAQ,M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AAAA,IAC1E,OAAA,EAAS;AAAA,MACP,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,cAAA,EAAiB,kBAAA,CAAmB,OAAO,MAAA,CAAO,UAAU,CAAC,CAAC,CAAA,YAAA,CAAA;AAAA,MACpE,MAAM,UAAA,CAAW;AAAA,QACf,4BAAA,EAA8B,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA;AAAA,QAChD,wCAAwC,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC;AAAA,OACxE;AAAA;AACH,GACD,CAAA;AACH;AASA,SAAS,WAAW,IAAA,EAAwD;AAC1E,EAAA,MAAM,MAA+B,EAAC;AAEtC,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AAChD,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC5B,IAAA,IAAI,IAAA,GAAO,GAAA;AAEX,IAAA,OAAO,KAAA,CAAM,SAAS,CAAA,EAAG;AACvB,MAAA,MAAM,GAAA,GAAM,MAAM,KAAA,EAAM;AAMxB,MAAA,MAAM,aAAa,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,KAAK,EAAE,CAAA;AAE9C,MAAA,IAAI,OAAO,IAAA,CAAK,GAAG,CAAA,KAAM,YAAY,IAAA,CAAK,GAAG,CAAA,KAAM,IAAA,OAAW,GAAG,CAAA,GAAI,UAAA,GAAa,KAAK,EAAC;AACxF,MAAA,IAAA,GAAO,KAAK,GAAG,CAAA;AAAA,IACjB;AAEA,IAAA,IAAA,CAAK,KAAA,CAAM,CAAC,CAAW,CAAA,GAAI,KAAA;AAAA,EAC7B;AAEA,EAAA,OAAO,GAAA;AACT","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\nfunction fakeTextInsert({ config, fake }: FakeRequest): unknown {\n return {\n \"documentId\": (config.documentId !== undefined && config.documentId !== null && config.documentId !== \"\" ? String(config.documentId) : fake.id(\"1Doc\")),\n \"replies\": [\n {},\n ],\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"document_create\":\n return fakeDocumentCreate(request);\n\n case \"text_insert\":\n return fakeTextInsert(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/text-insert.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/text-insert.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Insert plain text at a position in an existing document's body.\n *\n * POST /v1/documents/{documentId}:batchUpdate —\n * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate\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 TEXT_INSERT_OPERATION = \"text_insert\";\n\nexport type TextInsertOptions = {\n /** The node's resolved config. Keys: documentId, text, index. */\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 googleDocsTextInsert(options: TextInsertOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.documentId === undefined || config.documentId === null || config.documentId === \"\") {\n throw new Error(`text_insert: \"documentId\" is required (Document ID).`);\n }\n\n if (config.text === undefined || config.text === null || config.text === \"\") {\n throw new Error(`text_insert: \"text\" is required (Text).`);\n }\n\n {\n const n = Number(config.index);\n if (!(Number.isInteger(n) && n >= 1)) {\n throw new Error(\n `text_insert: \"index\" must be a integer, got ${JSON.stringify(config.index)}.`,\n );\n }\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: TEXT_INSERT_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/${encodeURIComponent(String(config.documentId))}:batchUpdate`,\n json: nestFields({\n \"requests.0.insertText.text\": String(config.text),\n \"requests.0.insertText.location.index\": Math.trunc(Number(config.index)),\n }),\n },\n });\n}\n\n/**\n * `{\"properties.email\": x}` -> `{properties: {email: x}}`.\n *\n * A dotted `as` means NESTING, and only a JSON body can nest. The validator\n * refuses that spelling anywhere else, because in a form body it already means\n * something different — a literal dotted key.\n */\nfunction nestFields(flat: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split(\".\");\n let node = out;\n\n while (parts.length > 1) {\n const key = parts.shift() as string;\n // A NUMERIC segment is an array index: `dateRanges.0.startDate` has to\n // become `[{startDate}]`, not `{\"0\": {startDate}}`. PHP produced the\n // array by accident (its integer-keyed arrays serialise as JSON lists)\n // and the other two produced an object, which the provider rejects as\n // the wrong type. The parity suite is what caught the disagreement.\n const wantsArray = /^\\d+$/.test(parts[0] ?? \"\");\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = wantsArray ? [] : {};\n node = node[key] as Record<string, unknown>;\n }\n\n node[parts[0] as string] = value;\n }\n\n return out;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -113,4 +113,42 @@ type DocumentCreateOptions = {
113
113
  };
114
114
  declare function googleDocsDocumentCreate(options: DocumentCreateOptions): Promise<ConnectorResult>;
115
115
 
116
- export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, type DocumentCreateOptions, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker };
116
+ /**
117
+ * GENERATED FILE — do not edit.
118
+ *
119
+ * Emitted from provider/actions/text-insert.json by weaver's generator.
120
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
121
+ * being rejected, because it works until it silently does not. Fix
122
+ * provider/actions/text-insert.json (or weaver's template/) and regenerate:
123
+ *
124
+ * npm run provider -- google_docs
125
+ */
126
+ /**
127
+ * Insert plain text at a position in an existing document's body.
128
+ *
129
+ * POST /v1/documents/{documentId}:batchUpdate —
130
+ * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate
131
+ *
132
+ * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
133
+ * no fake/real branch. This describes the request; callConnector resolves the
134
+ * connection, picks the estate, and either calls Google Docs or calls the
135
+ * faker.
136
+ *
137
+ * sideEffects: unsafe-to-replay.
138
+ */
139
+
140
+ declare const TEXT_INSERT_OPERATION = "text_insert";
141
+ type TextInsertOptions = {
142
+ /** The node's resolved config. Keys: documentId, text, index. */
143
+ config: Record<string, unknown>;
144
+ credentials?: Record<string, string | undefined>;
145
+ mode?: RequestedMode;
146
+ connectionId?: string | null;
147
+ input?: unknown;
148
+ attempts?: number;
149
+ /** Override the transport. The only way to exercise this without a network. */
150
+ transport?: Transport;
151
+ };
152
+ declare function googleDocsTextInsert(options: TextInsertOptions): Promise<ConnectorResult>;
153
+
154
+ export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, type DocumentCreateOptions, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, type TextInsertOptions, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert };
package/dist/index.d.ts CHANGED
@@ -113,4 +113,42 @@ type DocumentCreateOptions = {
113
113
  };
114
114
  declare function googleDocsDocumentCreate(options: DocumentCreateOptions): Promise<ConnectorResult>;
115
115
 
116
- export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, type DocumentCreateOptions, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker };
116
+ /**
117
+ * GENERATED FILE — do not edit.
118
+ *
119
+ * Emitted from provider/actions/text-insert.json by weaver's generator.
120
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
121
+ * being rejected, because it works until it silently does not. Fix
122
+ * provider/actions/text-insert.json (or weaver's template/) and regenerate:
123
+ *
124
+ * npm run provider -- google_docs
125
+ */
126
+ /**
127
+ * Insert plain text at a position in an existing document's body.
128
+ *
129
+ * POST /v1/documents/{documentId}:batchUpdate —
130
+ * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate
131
+ *
132
+ * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
133
+ * no fake/real branch. This describes the request; callConnector resolves the
134
+ * connection, picks the estate, and either calls Google Docs or calls the
135
+ * faker.
136
+ *
137
+ * sideEffects: unsafe-to-replay.
138
+ */
139
+
140
+ declare const TEXT_INSERT_OPERATION = "text_insert";
141
+ type TextInsertOptions = {
142
+ /** The node's resolved config. Keys: documentId, text, index. */
143
+ config: Record<string, unknown>;
144
+ credentials?: Record<string, string | undefined>;
145
+ mode?: RequestedMode;
146
+ connectionId?: string | null;
147
+ input?: unknown;
148
+ attempts?: number;
149
+ /** Override the transport. The only way to exercise this without a network. */
150
+ transport?: Transport;
151
+ };
152
+ declare function googleDocsTextInsert(options: TextInsertOptions): Promise<ConnectorResult>;
153
+
154
+ export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, type DocumentCreateOptions, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, type TextInsertOptions, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert };
package/dist/index.js CHANGED
@@ -1,3 +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';
1
+ export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert } from './chunk-JRH65Q6F.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-academy/google-docs-js",
3
- "version": "0.3.4",
3
+ "version": "0.5.0",
4
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
5
  "repository": {
6
6
  "type": "git",
@@ -38,6 +38,7 @@
38
38
  },
39
39
  "files": [
40
40
  "dist",
41
+ "art",
41
42
  "README.md",
42
43
  "CHANGELOG.md",
43
44
  "LICENSE"
@@ -53,7 +54,7 @@
53
54
  },
54
55
  "peerDependencies": {
55
56
  "@particle-academy/fancy-flow": ">=0.47.1 <2.0",
56
- "@particle-academy/google-docs-ui": ">=0.3.0 <0.4.0"
57
+ "@particle-academy/google-docs-ui": ">=0.5.0 <0.6.0"
57
58
  },
58
59
  "peerDependenciesMeta": {
59
60
  "@particle-academy/fancy-flow": {
@@ -1,71 +0,0 @@
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-2X6MFNGK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/document-create.ts"],"names":[],"mappings":";;;AAyBA,SAAS,kBAAA,CAAmB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAClE,EAAA,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Q,MAAA,IAAU,EAAC;AAElC,EAAA,IAAI,MAAA,CAAO,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,OAAO,cAAc,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":"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"]}