@particle-academy/google-docs-js 0.6.0 → 0.7.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/dist/flow.cjs.map CHANGED
@@ -1 +1 @@
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,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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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"]}
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/batch-update.ts","../src/actions/document-create.ts","../src/actions/text-insert.ts","../src/actions/text-replace.ts","../src/flow.ts"],"names":["callConnector","nestFields","googleDocsBatchUpdateKind","googleDocsDocumentKind","googleDocsTextInsertKind","googleDocsTextReplaceKind"],"mappings":";;;;;;;;AAyBA,SAAS,eAAA,CAAgB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC/D,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,KACH;AAAA,IACA,cAAA,EAAgB;AAAA,MACd,oBAAA,EAAsB,IAAA,CAAK,GAAA,CAAI,EAAE;AAAA;AACnC,GACF;AACF;AAEA,SAAS,kBAAA,CAAmB,EAAE,MAAA,EAAQ,IAA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EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,qBAAA,CAAsB;AAAA,IACzC,MAAA;AAAA,IACA,KAAA,EAAO,IAAI,MAAA,EAAQ;AAAA,GACpB,CAAA;AAED,EAAA,GAAA,CAAI,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,yBAAA,EAA6B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GAC1F,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,0BAAA,GAAmD;AAAA,EAC9D,EAAE,GAAGC,sCAAA,EAA2B,QAAA,EAAU,6BAAA,EAA8B;AAAA,EACxE,EAAE,GAAGC,mCAAA,EAAwB,QAAA,EAAU,0BAAA,EAA2B;AAAA,EAClE,EAAE,GAAGC,qCAAA,EAA0B,QAAA,EAAU,4BAAA,EAA6B;AAAA,EACtE,EAAE,GAAGC,sCAAA,EAA2B,QAAA,EAAU,6BAAA;AAC5C","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 fakeBatchUpdate({ 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 \"writeControl\": {\n \"requiredRevisionId\": fake.hex(16),\n },\n };\n}\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\nfunction fakeTextReplace({ 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 \"replaceAllText\": {\n \"occurrencesChanged\": fake.int(1, 9),\n },\n },\n ],\n \"writeControl\": {\n \"requiredRevisionId\": fake.hex(16),\n },\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"batch_update\":\n return fakeBatchUpdate(request);\n\n case \"document_create\":\n return fakeDocumentCreate(request);\n\n case \"text_insert\":\n return fakeTextInsert(request);\n\n case \"text_replace\":\n return fakeTextReplace(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/batch-update.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/batch-update.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Apply a list of Google Doc API requests to a document, all or none.\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 BATCH_UPDATE_OPERATION = \"batch_update\";\n\nexport type BatchUpdateOptions = {\n /** The node's resolved config. Keys: documentId, requests, requiredRevisionId. */\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 googleDocsBatchUpdate(options: BatchUpdateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.documentId === undefined || config.documentId === null || config.documentId === \"\") {\n throw new Error(`batch_update: \"documentId\" is required (Document ID).`);\n }\n\n if (config.requests === undefined || config.requests === null || config.requests === \"\") {\n throw new Error(`batch_update: \"requests\" is required (Requests).`);\n }\n if (typeof config.requests === \"string\" && config.requests !== \"\") {\n try {\n JSON.parse(config.requests);\n } catch (error) {\n throw new Error(`batch_update: \"requests\" must be JSON: ${(error as Error).message}`);\n }\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: BATCH_UPDATE_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 ...(config.requests !== undefined && config.requests !== null && config.requests !== \"\" ? { \"requests\": typeof config.requests === \"string\" ? JSON.parse(config.requests) : config.requests } : {}),\n ...(config.requiredRevisionId !== undefined && config.requiredRevisionId !== null && config.requiredRevisionId !== \"\" ? { \"writeControl.requiredRevisionId\": String(config.requiredRevisionId) } : {}),\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/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/text-replace.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-replace.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Replace every occurrence of a string in a document.\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_REPLACE_OPERATION = \"text_replace\";\n\nexport type TextReplaceOptions = {\n /** The node's resolved config. Keys: documentId, find, replaceWith, matchCase, requiredRevisionId. */\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 googleDocsTextReplace(options: TextReplaceOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.documentId === undefined || config.documentId === null || config.documentId === \"\") {\n throw new Error(`text_replace: \"documentId\" is required (Document ID).`);\n }\n\n if (config.find === undefined || config.find === null || config.find === \"\") {\n throw new Error(`text_replace: \"find\" is required (Find).`);\n }\n\n if (config.replaceWith === undefined || config.replaceWith === null || config.replaceWith === \"\") {\n throw new Error(`text_replace: \"replaceWith\" is required (Replace with).`);\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: TEXT_REPLACE_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.replaceAllText.containsText.text\": String(config.find),\n \"requests.0.replaceAllText.replaceText\": String(config.replaceWith),\n ...(config.matchCase !== undefined && config.matchCase !== null && config.matchCase !== \"\" ? { \"requests.0.replaceAllText.containsText.matchCase\": Boolean(config.matchCase) } : {}),\n ...(config.requiredRevisionId !== undefined && config.requiredRevisionId !== null && config.requiredRevisionId !== \"\" ? { \"writeControl.requiredRevisionId\": String(config.requiredRevisionId) } : {}),\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 googleDocsBatchUpdateKind,\n googleDocsDocumentKind,\n googleDocsTextInsertKind,\n googleDocsTextReplaceKind,\n} from \"@particle-academy/google-docs-ui\";\n\nimport { googleDocsBatchUpdate } from \"./actions/batch-update.js\";\nimport { googleDocsDocumentCreate } from \"./actions/document-create.js\";\nimport { googleDocsTextInsert } from \"./actions/text-insert.js\";\nimport { googleDocsTextReplace } from \"./actions/text-replace.js\";\n\nexport const googleDocsBatchUpdateExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleDocsBatchUpdate({\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 batch_update ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\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\nexport const googleDocsTextReplaceExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleDocsTextReplace({\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_replace ${(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 { ...googleDocsBatchUpdateKind, executor: googleDocsBatchUpdateExecutor },\n { ...googleDocsDocumentKind, executor: googleDocsDocumentExecutor },\n { ...googleDocsTextInsertKind, executor: googleDocsTextInsertExecutor },\n { ...googleDocsTextReplaceKind, executor: googleDocsTextReplaceExecutor },\n];\n"]}
package/dist/flow.d.cts CHANGED
@@ -19,9 +19,11 @@ import { NodeKindDefinition, NodeExecutor } from '@particle-academy/fancy-flow/e
19
19
  * installs the ui package and never this one.
20
20
  */
21
21
 
22
+ declare const googleDocsBatchUpdateExecutor: NodeExecutor;
22
23
  declare const googleDocsDocumentExecutor: NodeExecutor;
23
24
  declare const googleDocsTextInsertExecutor: NodeExecutor;
25
+ declare const googleDocsTextReplaceExecutor: NodeExecutor;
24
26
  /** The kinds a TypeScript host registers. */
25
27
  declare const GOOGLE_DOCS_RUNNABLE_KINDS: NodeKindDefinition[];
26
28
 
27
- export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor, googleDocsTextInsertExecutor };
29
+ export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsBatchUpdateExecutor, googleDocsDocumentExecutor, googleDocsTextInsertExecutor, googleDocsTextReplaceExecutor };
package/dist/flow.d.ts CHANGED
@@ -19,9 +19,11 @@ import { NodeKindDefinition, NodeExecutor } from '@particle-academy/fancy-flow/e
19
19
  * installs the ui package and never this one.
20
20
  */
21
21
 
22
+ declare const googleDocsBatchUpdateExecutor: NodeExecutor;
22
23
  declare const googleDocsDocumentExecutor: NodeExecutor;
23
24
  declare const googleDocsTextInsertExecutor: NodeExecutor;
25
+ declare const googleDocsTextReplaceExecutor: NodeExecutor;
24
26
  /** The kinds a TypeScript host registers. */
25
27
  declare const GOOGLE_DOCS_RUNNABLE_KINDS: NodeKindDefinition[];
26
28
 
27
- export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor, googleDocsTextInsertExecutor };
29
+ export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsBatchUpdateExecutor, googleDocsDocumentExecutor, googleDocsTextInsertExecutor, googleDocsTextReplaceExecutor };
package/dist/flow.js CHANGED
@@ -1,7 +1,21 @@
1
- import { googleDocsDocumentCreate, googleDocsTextInsert } from './chunk-JRH65Q6F.js';
1
+ import { googleDocsBatchUpdate, googleDocsDocumentCreate, googleDocsTextInsert, googleDocsTextReplace } from './chunk-VLBBKMA4.js';
2
2
  import '@particle-academy/fancy-connector-core';
3
- import { googleDocsDocumentKind, googleDocsTextInsertKind } from '@particle-academy/google-docs-ui';
3
+ import { googleDocsBatchUpdateKind, googleDocsDocumentKind, googleDocsTextInsertKind, googleDocsTextReplaceKind } from '@particle-academy/google-docs-ui';
4
4
 
5
+ var googleDocsBatchUpdateExecutor = async (ctx) => {
6
+ const config = ctx.node.data?.config ?? {};
7
+ const result = await googleDocsBatchUpdate({
8
+ config,
9
+ input: ctx.inputs?.in
10
+ });
11
+ ctx.emit({
12
+ type: "log",
13
+ level: "info",
14
+ nodeId: ctx.node.id,
15
+ message: `google_docs batch_update ${result.data?.id} (${result.mode})`
16
+ });
17
+ return { __port: "out", value: result };
18
+ };
5
19
  var googleDocsDocumentExecutor = async (ctx) => {
6
20
  const config = ctx.node.data?.config ?? {};
7
21
  const result = await googleDocsDocumentCreate({
@@ -30,11 +44,27 @@ var googleDocsTextInsertExecutor = async (ctx) => {
30
44
  });
31
45
  return { __port: "out", value: result };
32
46
  };
47
+ var googleDocsTextReplaceExecutor = async (ctx) => {
48
+ const config = ctx.node.data?.config ?? {};
49
+ const result = await googleDocsTextReplace({
50
+ config,
51
+ input: ctx.inputs?.in
52
+ });
53
+ ctx.emit({
54
+ type: "log",
55
+ level: "info",
56
+ nodeId: ctx.node.id,
57
+ message: `google_docs text_replace ${result.data?.id} (${result.mode})`
58
+ });
59
+ return { __port: "out", value: result };
60
+ };
33
61
  var GOOGLE_DOCS_RUNNABLE_KINDS = [
62
+ { ...googleDocsBatchUpdateKind, executor: googleDocsBatchUpdateExecutor },
34
63
  { ...googleDocsDocumentKind, executor: googleDocsDocumentExecutor },
35
- { ...googleDocsTextInsertKind, executor: googleDocsTextInsertExecutor }
64
+ { ...googleDocsTextInsertKind, executor: googleDocsTextInsertExecutor },
65
+ { ...googleDocsTextReplaceKind, executor: googleDocsTextReplaceExecutor }
36
66
  ];
37
67
 
38
- export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsDocumentExecutor, googleDocsTextInsertExecutor };
68
+ export { GOOGLE_DOCS_RUNNABLE_KINDS, googleDocsBatchUpdateExecutor, googleDocsDocumentExecutor, googleDocsTextInsertExecutor, googleDocsTextReplaceExecutor };
39
69
  //# sourceMappingURL=flow.js.map
40
70
  //# sourceMappingURL=flow.js.map
package/dist/flow.js.map CHANGED
@@ -1 +1 @@
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"]}
1
+ {"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;;AA0CO,IAAM,6BAAA,GAA8C,OAAO,GAAA,KAAQ;AACxE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,qBAAA,CAAsB;AAAA,IACzC,MAAA;AAAA,IACA,KAAA,EAAO,IAAI,MAAA,EAAQ;AAAA,GACpB,CAAA;AAED,EAAA,GAAA,CAAI,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EA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,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;AAEO,IAAM,6BAAA,GAA8C,OAAO,GAAA,KAAQ;AACxE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,qBAAA,CAAsB;AAAA,IACzC,MAAA;AAAA,IACA,KAAA,EAAO,IAAI,MAAA,EAAQ;AAAA,GACpB,CAAA;AAED,EAAA,GAAA,CAAI,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,yBAAA,EAA6B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GAC1F,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,0BAAA,GAAmD;AAAA,EAC9D,EAAE,GAAG,yBAAA,EAA2B,QAAA,EAAU,6BAAA,EAA8B;AAAA,EACxE,EAAE,GAAG,sBAAA,EAAwB,QAAA,EAAU,0BAAA,EAA2B;AAAA,EAClE,EAAE,GAAG,wBAAA,EAA0B,QAAA,EAAU,4BAAA,EAA6B;AAAA,EACtE,EAAE,GAAG,yBAAA,EAA2B,QAAA,EAAU,6BAAA;AAC5C","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 googleDocsBatchUpdateKind,\n googleDocsDocumentKind,\n googleDocsTextInsertKind,\n googleDocsTextReplaceKind,\n} from \"@particle-academy/google-docs-ui\";\n\nimport { googleDocsBatchUpdate } from \"./actions/batch-update.js\";\nimport { googleDocsDocumentCreate } from \"./actions/document-create.js\";\nimport { googleDocsTextInsert } from \"./actions/text-insert.js\";\nimport { googleDocsTextReplace } from \"./actions/text-replace.js\";\n\nexport const googleDocsBatchUpdateExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleDocsBatchUpdate({\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 batch_update ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\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\nexport const googleDocsTextReplaceExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await googleDocsTextReplace({\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_replace ${(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 { ...googleDocsBatchUpdateKind, executor: googleDocsBatchUpdateExecutor },\n { ...googleDocsDocumentKind, executor: googleDocsDocumentExecutor },\n { ...googleDocsTextInsertKind, executor: googleDocsTextInsertExecutor },\n { ...googleDocsTextReplaceKind, executor: googleDocsTextReplaceExecutor },\n];\n"]}
package/dist/index.cjs CHANGED
@@ -3,6 +3,17 @@
3
3
  var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
4
4
 
5
5
  // src/faker.ts
6
+ function fakeBatchUpdate({ config, fake }) {
7
+ return {
8
+ "documentId": config.documentId !== void 0 && config.documentId !== null && config.documentId !== "" ? String(config.documentId) : fake.id("1Doc"),
9
+ "replies": [
10
+ {}
11
+ ],
12
+ "writeControl": {
13
+ "requiredRevisionId": fake.hex(16)
14
+ }
15
+ };
16
+ }
6
17
  function fakeDocumentCreate({ config, fake }) {
7
18
  return {
8
19
  "documentId": fake.id("1Doc"),
@@ -17,12 +28,31 @@ function fakeTextInsert({ config, fake }) {
17
28
  ]
18
29
  };
19
30
  }
31
+ function fakeTextReplace({ config, fake }) {
32
+ return {
33
+ "documentId": config.documentId !== void 0 && config.documentId !== null && config.documentId !== "" ? String(config.documentId) : fake.id("1Doc"),
34
+ "replies": [
35
+ {
36
+ "replaceAllText": {
37
+ "occurrencesChanged": fake.int(1, 9)
38
+ }
39
+ }
40
+ ],
41
+ "writeControl": {
42
+ "requiredRevisionId": fake.hex(16)
43
+ }
44
+ };
45
+ }
20
46
  var googleDocsFaker = (operation, request) => {
21
47
  switch (operation) {
48
+ case "batch_update":
49
+ return fakeBatchUpdate(request);
22
50
  case "document_create":
23
51
  return fakeDocumentCreate(request);
24
52
  case "text_insert":
25
53
  return fakeTextInsert(request);
54
+ case "text_replace":
55
+ return fakeTextReplace(request);
26
56
  default:
27
57
  throw new Error(
28
58
  `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.`
@@ -53,6 +83,56 @@ var GOOGLE_DOCS = {
53
83
  authorize: googleDocsAuthorize,
54
84
  faker: googleDocsFaker
55
85
  };
86
+ var BATCH_UPDATE_OPERATION = "batch_update";
87
+ async function googleDocsBatchUpdate(options) {
88
+ const config = options.config ?? {};
89
+ if (config.documentId === void 0 || config.documentId === null || config.documentId === "") {
90
+ throw new Error(`batch_update: "documentId" is required (Document ID).`);
91
+ }
92
+ if (config.requests === void 0 || config.requests === null || config.requests === "") {
93
+ throw new Error(`batch_update: "requests" is required (Requests).`);
94
+ }
95
+ if (typeof config.requests === "string" && config.requests !== "") {
96
+ try {
97
+ JSON.parse(config.requests);
98
+ } catch (error) {
99
+ throw new Error(`batch_update: "requests" must be JSON: ${error.message}`);
100
+ }
101
+ }
102
+ return fancyConnectorCore.callConnector(GOOGLE_DOCS, {
103
+ operation: BATCH_UPDATE_OPERATION,
104
+ config,
105
+ input: options.input,
106
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
107
+ ...options.mode === void 0 ? {} : { mode: options.mode },
108
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
109
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
110
+ ...options.transport === void 0 ? {} : { transport: options.transport },
111
+ request: {
112
+ method: "POST",
113
+ path: `/v1/documents/${encodeURIComponent(String(config.documentId))}:batchUpdate`,
114
+ json: nestFields({
115
+ ...config.requests !== void 0 && config.requests !== null && config.requests !== "" ? { "requests": typeof config.requests === "string" ? JSON.parse(config.requests) : config.requests } : {},
116
+ ...config.requiredRevisionId !== void 0 && config.requiredRevisionId !== null && config.requiredRevisionId !== "" ? { "writeControl.requiredRevisionId": String(config.requiredRevisionId) } : {}
117
+ })
118
+ }
119
+ });
120
+ }
121
+ function nestFields(flat) {
122
+ const out = {};
123
+ for (const [path, value] of Object.entries(flat)) {
124
+ const parts = path.split(".");
125
+ let node = out;
126
+ while (parts.length > 1) {
127
+ const key = parts.shift();
128
+ const wantsArray = /^\d+$/.test(parts[0] ?? "");
129
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
130
+ node = node[key];
131
+ }
132
+ node[parts[0]] = value;
133
+ }
134
+ return out;
135
+ }
56
136
  var DOCUMENT_CREATE_OPERATION = "document_create";
57
137
  async function googleDocsDocumentCreate(options) {
58
138
  const config = options.config ?? {};
@@ -106,14 +186,62 @@ async function googleDocsTextInsert(options) {
106
186
  request: {
107
187
  method: "POST",
108
188
  path: `/v1/documents/${encodeURIComponent(String(config.documentId))}:batchUpdate`,
109
- json: nestFields({
189
+ json: nestFields2({
110
190
  "requests.0.insertText.text": String(config.text),
111
191
  "requests.0.insertText.location.index": Math.trunc(Number(config.index))
112
192
  })
113
193
  }
114
194
  });
115
195
  }
116
- function nestFields(flat) {
196
+ function nestFields2(flat) {
197
+ const out = {};
198
+ for (const [path, value] of Object.entries(flat)) {
199
+ const parts = path.split(".");
200
+ let node = out;
201
+ while (parts.length > 1) {
202
+ const key = parts.shift();
203
+ const wantsArray = /^\d+$/.test(parts[0] ?? "");
204
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
205
+ node = node[key];
206
+ }
207
+ node[parts[0]] = value;
208
+ }
209
+ return out;
210
+ }
211
+ var TEXT_REPLACE_OPERATION = "text_replace";
212
+ async function googleDocsTextReplace(options) {
213
+ const config = options.config ?? {};
214
+ if (config.documentId === void 0 || config.documentId === null || config.documentId === "") {
215
+ throw new Error(`text_replace: "documentId" is required (Document ID).`);
216
+ }
217
+ if (config.find === void 0 || config.find === null || config.find === "") {
218
+ throw new Error(`text_replace: "find" is required (Find).`);
219
+ }
220
+ if (config.replaceWith === void 0 || config.replaceWith === null || config.replaceWith === "") {
221
+ throw new Error(`text_replace: "replaceWith" is required (Replace with).`);
222
+ }
223
+ return fancyConnectorCore.callConnector(GOOGLE_DOCS, {
224
+ operation: TEXT_REPLACE_OPERATION,
225
+ config,
226
+ input: options.input,
227
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
228
+ ...options.mode === void 0 ? {} : { mode: options.mode },
229
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
230
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
231
+ ...options.transport === void 0 ? {} : { transport: options.transport },
232
+ request: {
233
+ method: "POST",
234
+ path: `/v1/documents/${encodeURIComponent(String(config.documentId))}:batchUpdate`,
235
+ json: nestFields3({
236
+ "requests.0.replaceAllText.containsText.text": String(config.find),
237
+ "requests.0.replaceAllText.replaceText": String(config.replaceWith),
238
+ ...config.matchCase !== void 0 && config.matchCase !== null && config.matchCase !== "" ? { "requests.0.replaceAllText.containsText.matchCase": Boolean(config.matchCase) } : {},
239
+ ...config.requiredRevisionId !== void 0 && config.requiredRevisionId !== null && config.requiredRevisionId !== "" ? { "writeControl.requiredRevisionId": String(config.requiredRevisionId) } : {}
240
+ })
241
+ }
242
+ });
243
+ }
244
+ function nestFields3(flat) {
117
245
  const out = {};
118
246
  for (const [path, value] of Object.entries(flat)) {
119
247
  const parts = path.split(".");
@@ -129,15 +257,19 @@ function nestFields(flat) {
129
257
  return out;
130
258
  }
131
259
 
260
+ exports.BATCH_UPDATE_OPERATION = BATCH_UPDATE_OPERATION;
132
261
  exports.CONNECTOR_API_VERSION = CONNECTOR_API_VERSION;
133
262
  exports.DOCUMENT_CREATE_OPERATION = DOCUMENT_CREATE_OPERATION;
134
263
  exports.GOOGLE_DOCS = GOOGLE_DOCS;
135
264
  exports.GOOGLE_DOCS_BASE_URLS = GOOGLE_DOCS_BASE_URLS;
136
265
  exports.GOOGLE_DOCS_REQUIRES = GOOGLE_DOCS_REQUIRES;
137
266
  exports.TEXT_INSERT_OPERATION = TEXT_INSERT_OPERATION;
267
+ exports.TEXT_REPLACE_OPERATION = TEXT_REPLACE_OPERATION;
138
268
  exports.googleDocsAuthorize = googleDocsAuthorize;
269
+ exports.googleDocsBatchUpdate = googleDocsBatchUpdate;
139
270
  exports.googleDocsDocumentCreate = googleDocsDocumentCreate;
140
271
  exports.googleDocsFaker = googleDocsFaker;
141
272
  exports.googleDocsTextInsert = googleDocsTextInsert;
273
+ exports.googleDocsTextReplace = googleDocsTextReplace;
142
274
  //# sourceMappingURL=index.cjs.map
143
275
  //# sourceMappingURL=index.cjs.map
@@ -1 +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,M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B;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"]}
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/batch-update.ts","../src/actions/document-create.ts","../src/actions/text-insert.ts","../src/actions/text-replace.ts"],"names":["callConnector","nestFields"],"mappings":";;;;;AAyBA,SAAS,eAAA,CAAgB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC/D,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,C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C1E,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 fakeBatchUpdate({ 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 \"writeControl\": {\n \"requiredRevisionId\": fake.hex(16),\n },\n };\n}\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\nfunction fakeTextReplace({ 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 \"replaceAllText\": {\n \"occurrencesChanged\": fake.int(1, 9),\n },\n },\n ],\n \"writeControl\": {\n \"requiredRevisionId\": fake.hex(16),\n },\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"batch_update\":\n return fakeBatchUpdate(request);\n\n case \"document_create\":\n return fakeDocumentCreate(request);\n\n case \"text_insert\":\n return fakeTextInsert(request);\n\n case \"text_replace\":\n return fakeTextReplace(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/batch-update.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/batch-update.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Apply a list of Google Doc API requests to a document, all or none.\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 BATCH_UPDATE_OPERATION = \"batch_update\";\n\nexport type BatchUpdateOptions = {\n /** The node's resolved config. Keys: documentId, requests, requiredRevisionId. */\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 googleDocsBatchUpdate(options: BatchUpdateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.documentId === undefined || config.documentId === null || config.documentId === \"\") {\n throw new Error(`batch_update: \"documentId\" is required (Document ID).`);\n }\n\n if (config.requests === undefined || config.requests === null || config.requests === \"\") {\n throw new Error(`batch_update: \"requests\" is required (Requests).`);\n }\n if (typeof config.requests === \"string\" && config.requests !== \"\") {\n try {\n JSON.parse(config.requests);\n } catch (error) {\n throw new Error(`batch_update: \"requests\" must be JSON: ${(error as Error).message}`);\n }\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: BATCH_UPDATE_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 ...(config.requests !== undefined && config.requests !== null && config.requests !== \"\" ? { \"requests\": typeof config.requests === \"string\" ? JSON.parse(config.requests) : config.requests } : {}),\n ...(config.requiredRevisionId !== undefined && config.requiredRevisionId !== null && config.requiredRevisionId !== \"\" ? { \"writeControl.requiredRevisionId\": String(config.requiredRevisionId) } : {}),\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/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/text-replace.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-replace.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Replace every occurrence of a string in a document.\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_REPLACE_OPERATION = \"text_replace\";\n\nexport type TextReplaceOptions = {\n /** The node's resolved config. Keys: documentId, find, replaceWith, matchCase, requiredRevisionId. */\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 googleDocsTextReplace(options: TextReplaceOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.documentId === undefined || config.documentId === null || config.documentId === \"\") {\n throw new Error(`text_replace: \"documentId\" is required (Document ID).`);\n }\n\n if (config.find === undefined || config.find === null || config.find === \"\") {\n throw new Error(`text_replace: \"find\" is required (Find).`);\n }\n\n if (config.replaceWith === undefined || config.replaceWith === null || config.replaceWith === \"\") {\n throw new Error(`text_replace: \"replaceWith\" is required (Replace with).`);\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: TEXT_REPLACE_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.replaceAllText.containsText.text\": String(config.find),\n \"requests.0.replaceAllText.replaceText\": String(config.replaceWith),\n ...(config.matchCase !== undefined && config.matchCase !== null && config.matchCase !== \"\" ? { \"requests.0.replaceAllText.containsText.matchCase\": Boolean(config.matchCase) } : {}),\n ...(config.requiredRevisionId !== undefined && config.requiredRevisionId !== null && config.requiredRevisionId !== \"\" ? { \"writeControl.requiredRevisionId\": String(config.requiredRevisionId) } : {}),\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"]}