@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/CHANGELOG.md +13 -0
- package/README.md +26 -0
- package/dist/chunk-VLBBKMA4.js +260 -0
- package/dist/chunk-VLBBKMA4.js.map +1 -0
- package/dist/flow.cjs +163 -3
- package/dist/flow.cjs.map +1 -1
- package/dist/flow.d.cts +3 -1
- package/dist/flow.d.ts +3 -1
- package/dist/flow.js +34 -4
- package/dist/flow.js.map +1 -1
- package/dist/index.cjs +134 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -1
- package/dist/index.d.ts +77 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-JRH65Q6F.js +0 -132
- package/dist/chunk-JRH65Q6F.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -75,6 +75,44 @@ declare const GOOGLE_DOCS: ServiceDescriptor;
|
|
|
75
75
|
|
|
76
76
|
declare const googleDocsFaker: ConnectorFaker;
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* GENERATED FILE — do not edit.
|
|
80
|
+
*
|
|
81
|
+
* Emitted from provider/actions/batch-update.json by weaver's generator.
|
|
82
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
83
|
+
* being rejected, because it works until it silently does not. Fix
|
|
84
|
+
* provider/actions/batch-update.json (or weaver's template/) and regenerate:
|
|
85
|
+
*
|
|
86
|
+
* npm run provider -- google_docs
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* Apply a list of Google Doc API requests to a document, all or none.
|
|
90
|
+
*
|
|
91
|
+
* POST /v1/documents/{documentId}:batchUpdate —
|
|
92
|
+
* https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate
|
|
93
|
+
*
|
|
94
|
+
* Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
|
|
95
|
+
* no fake/real branch. This describes the request; callConnector resolves the
|
|
96
|
+
* connection, picks the estate, and either calls Google Docs or calls the
|
|
97
|
+
* faker.
|
|
98
|
+
*
|
|
99
|
+
* sideEffects: unsafe-to-replay.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
declare const BATCH_UPDATE_OPERATION = "batch_update";
|
|
103
|
+
type BatchUpdateOptions = {
|
|
104
|
+
/** The node's resolved config. Keys: documentId, requests, requiredRevisionId. */
|
|
105
|
+
config: Record<string, unknown>;
|
|
106
|
+
credentials?: Record<string, string | undefined>;
|
|
107
|
+
mode?: RequestedMode;
|
|
108
|
+
connectionId?: string | null;
|
|
109
|
+
input?: unknown;
|
|
110
|
+
attempts?: number;
|
|
111
|
+
/** Override the transport. The only way to exercise this without a network. */
|
|
112
|
+
transport?: Transport;
|
|
113
|
+
};
|
|
114
|
+
declare function googleDocsBatchUpdate(options: BatchUpdateOptions): Promise<ConnectorResult>;
|
|
115
|
+
|
|
78
116
|
/**
|
|
79
117
|
* GENERATED FILE — do not edit.
|
|
80
118
|
*
|
|
@@ -151,4 +189,42 @@ type TextInsertOptions = {
|
|
|
151
189
|
};
|
|
152
190
|
declare function googleDocsTextInsert(options: TextInsertOptions): Promise<ConnectorResult>;
|
|
153
191
|
|
|
154
|
-
|
|
192
|
+
/**
|
|
193
|
+
* GENERATED FILE — do not edit.
|
|
194
|
+
*
|
|
195
|
+
* Emitted from provider/actions/text-replace.json by weaver's generator.
|
|
196
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
197
|
+
* being rejected, because it works until it silently does not. Fix
|
|
198
|
+
* provider/actions/text-replace.json (or weaver's template/) and regenerate:
|
|
199
|
+
*
|
|
200
|
+
* npm run provider -- google_docs
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Replace every occurrence of a string in a document.
|
|
204
|
+
*
|
|
205
|
+
* POST /v1/documents/{documentId}:batchUpdate —
|
|
206
|
+
* https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate
|
|
207
|
+
*
|
|
208
|
+
* Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
|
|
209
|
+
* no fake/real branch. This describes the request; callConnector resolves the
|
|
210
|
+
* connection, picks the estate, and either calls Google Docs or calls the
|
|
211
|
+
* faker.
|
|
212
|
+
*
|
|
213
|
+
* sideEffects: unsafe-to-replay.
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
declare const TEXT_REPLACE_OPERATION = "text_replace";
|
|
217
|
+
type TextReplaceOptions = {
|
|
218
|
+
/** The node's resolved config. Keys: documentId, find, replaceWith, matchCase, requiredRevisionId. */
|
|
219
|
+
config: Record<string, unknown>;
|
|
220
|
+
credentials?: Record<string, string | undefined>;
|
|
221
|
+
mode?: RequestedMode;
|
|
222
|
+
connectionId?: string | null;
|
|
223
|
+
input?: unknown;
|
|
224
|
+
attempts?: number;
|
|
225
|
+
/** Override the transport. The only way to exercise this without a network. */
|
|
226
|
+
transport?: Transport;
|
|
227
|
+
};
|
|
228
|
+
declare function googleDocsTextReplace(options: TextReplaceOptions): Promise<ConnectorResult>;
|
|
229
|
+
|
|
230
|
+
export { BATCH_UPDATE_OPERATION, type BatchUpdateOptions, CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, type DocumentCreateOptions, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, TEXT_REPLACE_OPERATION, type TextInsertOptions, type TextReplaceOptions, googleDocsAuthorize, googleDocsBatchUpdate, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert, googleDocsTextReplace };
|
package/dist/index.d.ts
CHANGED
|
@@ -75,6 +75,44 @@ declare const GOOGLE_DOCS: ServiceDescriptor;
|
|
|
75
75
|
|
|
76
76
|
declare const googleDocsFaker: ConnectorFaker;
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* GENERATED FILE — do not edit.
|
|
80
|
+
*
|
|
81
|
+
* Emitted from provider/actions/batch-update.json by weaver's generator.
|
|
82
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
83
|
+
* being rejected, because it works until it silently does not. Fix
|
|
84
|
+
* provider/actions/batch-update.json (or weaver's template/) and regenerate:
|
|
85
|
+
*
|
|
86
|
+
* npm run provider -- google_docs
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* Apply a list of Google Doc API requests to a document, all or none.
|
|
90
|
+
*
|
|
91
|
+
* POST /v1/documents/{documentId}:batchUpdate —
|
|
92
|
+
* https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate
|
|
93
|
+
*
|
|
94
|
+
* Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
|
|
95
|
+
* no fake/real branch. This describes the request; callConnector resolves the
|
|
96
|
+
* connection, picks the estate, and either calls Google Docs or calls the
|
|
97
|
+
* faker.
|
|
98
|
+
*
|
|
99
|
+
* sideEffects: unsafe-to-replay.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
declare const BATCH_UPDATE_OPERATION = "batch_update";
|
|
103
|
+
type BatchUpdateOptions = {
|
|
104
|
+
/** The node's resolved config. Keys: documentId, requests, requiredRevisionId. */
|
|
105
|
+
config: Record<string, unknown>;
|
|
106
|
+
credentials?: Record<string, string | undefined>;
|
|
107
|
+
mode?: RequestedMode;
|
|
108
|
+
connectionId?: string | null;
|
|
109
|
+
input?: unknown;
|
|
110
|
+
attempts?: number;
|
|
111
|
+
/** Override the transport. The only way to exercise this without a network. */
|
|
112
|
+
transport?: Transport;
|
|
113
|
+
};
|
|
114
|
+
declare function googleDocsBatchUpdate(options: BatchUpdateOptions): Promise<ConnectorResult>;
|
|
115
|
+
|
|
78
116
|
/**
|
|
79
117
|
* GENERATED FILE — do not edit.
|
|
80
118
|
*
|
|
@@ -151,4 +189,42 @@ type TextInsertOptions = {
|
|
|
151
189
|
};
|
|
152
190
|
declare function googleDocsTextInsert(options: TextInsertOptions): Promise<ConnectorResult>;
|
|
153
191
|
|
|
154
|
-
|
|
192
|
+
/**
|
|
193
|
+
* GENERATED FILE — do not edit.
|
|
194
|
+
*
|
|
195
|
+
* Emitted from provider/actions/text-replace.json by weaver's generator.
|
|
196
|
+
* A hand-edit here is destroyed by the next protocol sync, which is worse than
|
|
197
|
+
* being rejected, because it works until it silently does not. Fix
|
|
198
|
+
* provider/actions/text-replace.json (or weaver's template/) and regenerate:
|
|
199
|
+
*
|
|
200
|
+
* npm run provider -- google_docs
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Replace every occurrence of a string in a document.
|
|
204
|
+
*
|
|
205
|
+
* POST /v1/documents/{documentId}:batchUpdate —
|
|
206
|
+
* https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate
|
|
207
|
+
*
|
|
208
|
+
* Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
|
|
209
|
+
* no fake/real branch. This describes the request; callConnector resolves the
|
|
210
|
+
* connection, picks the estate, and either calls Google Docs or calls the
|
|
211
|
+
* faker.
|
|
212
|
+
*
|
|
213
|
+
* sideEffects: unsafe-to-replay.
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
declare const TEXT_REPLACE_OPERATION = "text_replace";
|
|
217
|
+
type TextReplaceOptions = {
|
|
218
|
+
/** The node's resolved config. Keys: documentId, find, replaceWith, matchCase, requiredRevisionId. */
|
|
219
|
+
config: Record<string, unknown>;
|
|
220
|
+
credentials?: Record<string, string | undefined>;
|
|
221
|
+
mode?: RequestedMode;
|
|
222
|
+
connectionId?: string | null;
|
|
223
|
+
input?: unknown;
|
|
224
|
+
attempts?: number;
|
|
225
|
+
/** Override the transport. The only way to exercise this without a network. */
|
|
226
|
+
transport?: Transport;
|
|
227
|
+
};
|
|
228
|
+
declare function googleDocsTextReplace(options: TextReplaceOptions): Promise<ConnectorResult>;
|
|
229
|
+
|
|
230
|
+
export { BATCH_UPDATE_OPERATION, type BatchUpdateOptions, CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, type DocumentCreateOptions, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, TEXT_REPLACE_OPERATION, type TextInsertOptions, type TextReplaceOptions, googleDocsAuthorize, googleDocsBatchUpdate, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert, googleDocsTextReplace };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert } from './chunk-
|
|
1
|
+
export { BATCH_UPDATE_OPERATION, CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, TEXT_REPLACE_OPERATION, googleDocsAuthorize, googleDocsBatchUpdate, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert, googleDocsTextReplace } from './chunk-VLBBKMA4.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-academy/google-docs-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Google Docs for Node — the service descriptor, its faker, its webhook verification, and one function per operation. Plain HTTP on @particle-academy/fancy-connector-core; no vendor SDK.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@particle-academy/fancy-flow": ">=0.47.1 <2.0",
|
|
57
|
-
"@particle-academy/google-docs-ui": ">=0.
|
|
57
|
+
"@particle-academy/google-docs-ui": ">=0.7.0 <0.8.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@particle-academy/fancy-flow": {
|
package/dist/chunk-JRH65Q6F.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { callConnector } from '@particle-academy/fancy-connector-core';
|
|
2
|
-
|
|
3
|
-
// src/faker.ts
|
|
4
|
-
function fakeDocumentCreate({ config, fake }) {
|
|
5
|
-
return {
|
|
6
|
-
"documentId": fake.id("1Doc"),
|
|
7
|
-
"title": config.title !== void 0 && config.title !== null && config.title !== "" ? String(config.title) : "Untitled document"
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
function fakeTextInsert({ config, fake }) {
|
|
11
|
-
return {
|
|
12
|
-
"documentId": config.documentId !== void 0 && config.documentId !== null && config.documentId !== "" ? String(config.documentId) : fake.id("1Doc"),
|
|
13
|
-
"replies": [
|
|
14
|
-
{}
|
|
15
|
-
]
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
var googleDocsFaker = (operation, request) => {
|
|
19
|
-
switch (operation) {
|
|
20
|
-
case "document_create":
|
|
21
|
-
return fakeDocumentCreate(request);
|
|
22
|
-
case "text_insert":
|
|
23
|
-
return fakeTextInsert(request);
|
|
24
|
-
default:
|
|
25
|
-
throw new Error(
|
|
26
|
-
`google_docs: no fake response is defined for "${operation}". Add a fixture under provider/fixtures/ and regenerate \u2014 a connector without a faker cannot be developed against, tested, or demonstrated.`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// src/service.ts
|
|
32
|
-
var CONNECTOR_API_VERSION = 1;
|
|
33
|
-
var GOOGLE_DOCS_BASE_URLS = {
|
|
34
|
-
"live": "https://docs.googleapis.com"
|
|
35
|
-
};
|
|
36
|
-
var GOOGLE_DOCS_REQUIRES = [
|
|
37
|
-
"accessToken",
|
|
38
|
-
"refreshToken",
|
|
39
|
-
"clientId",
|
|
40
|
-
"clientSecret"
|
|
41
|
-
];
|
|
42
|
-
function googleDocsAuthorize(credentials, request, _mode) {
|
|
43
|
-
request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
|
|
44
|
-
}
|
|
45
|
-
var GOOGLE_DOCS = {
|
|
46
|
-
service: "google_docs",
|
|
47
|
-
title: "Google Docs",
|
|
48
|
-
sandbox: "none",
|
|
49
|
-
baseUrls: { ...GOOGLE_DOCS_BASE_URLS },
|
|
50
|
-
requires: [...GOOGLE_DOCS_REQUIRES],
|
|
51
|
-
authorize: googleDocsAuthorize,
|
|
52
|
-
faker: googleDocsFaker
|
|
53
|
-
};
|
|
54
|
-
var DOCUMENT_CREATE_OPERATION = "document_create";
|
|
55
|
-
async function googleDocsDocumentCreate(options) {
|
|
56
|
-
const config = options.config ?? {};
|
|
57
|
-
if (config.title === void 0 || config.title === null || config.title === "") {
|
|
58
|
-
throw new Error(`document_create: "title" is required (Title).`);
|
|
59
|
-
}
|
|
60
|
-
return callConnector(GOOGLE_DOCS, {
|
|
61
|
-
operation: DOCUMENT_CREATE_OPERATION,
|
|
62
|
-
config,
|
|
63
|
-
input: options.input,
|
|
64
|
-
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
65
|
-
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
66
|
-
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
67
|
-
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
68
|
-
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
69
|
-
request: {
|
|
70
|
-
method: "POST",
|
|
71
|
-
path: "/v1/documents",
|
|
72
|
-
json: {
|
|
73
|
-
"title": String(config.title)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
var TEXT_INSERT_OPERATION = "text_insert";
|
|
79
|
-
async function googleDocsTextInsert(options) {
|
|
80
|
-
const config = options.config ?? {};
|
|
81
|
-
if (config.documentId === void 0 || config.documentId === null || config.documentId === "") {
|
|
82
|
-
throw new Error(`text_insert: "documentId" is required (Document ID).`);
|
|
83
|
-
}
|
|
84
|
-
if (config.text === void 0 || config.text === null || config.text === "") {
|
|
85
|
-
throw new Error(`text_insert: "text" is required (Text).`);
|
|
86
|
-
}
|
|
87
|
-
{
|
|
88
|
-
const n = Number(config.index);
|
|
89
|
-
if (!(Number.isInteger(n) && n >= 1)) {
|
|
90
|
-
throw new Error(
|
|
91
|
-
`text_insert: "index" must be a integer, got ${JSON.stringify(config.index)}.`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return callConnector(GOOGLE_DOCS, {
|
|
96
|
-
operation: TEXT_INSERT_OPERATION,
|
|
97
|
-
config,
|
|
98
|
-
input: options.input,
|
|
99
|
-
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
100
|
-
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
101
|
-
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
102
|
-
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
103
|
-
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
104
|
-
request: {
|
|
105
|
-
method: "POST",
|
|
106
|
-
path: `/v1/documents/${encodeURIComponent(String(config.documentId))}:batchUpdate`,
|
|
107
|
-
json: nestFields({
|
|
108
|
-
"requests.0.insertText.text": String(config.text),
|
|
109
|
-
"requests.0.insertText.location.index": Math.trunc(Number(config.index))
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
function nestFields(flat) {
|
|
115
|
-
const out = {};
|
|
116
|
-
for (const [path, value] of Object.entries(flat)) {
|
|
117
|
-
const parts = path.split(".");
|
|
118
|
-
let node = out;
|
|
119
|
-
while (parts.length > 1) {
|
|
120
|
-
const key = parts.shift();
|
|
121
|
-
const wantsArray = /^\d+$/.test(parts[0] ?? "");
|
|
122
|
-
if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
|
|
123
|
-
node = node[key];
|
|
124
|
-
}
|
|
125
|
-
node[parts[0]] = value;
|
|
126
|
-
}
|
|
127
|
-
return out;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export { CONNECTOR_API_VERSION, DOCUMENT_CREATE_OPERATION, GOOGLE_DOCS, GOOGLE_DOCS_BASE_URLS, GOOGLE_DOCS_REQUIRES, TEXT_INSERT_OPERATION, googleDocsAuthorize, googleDocsDocumentCreate, googleDocsFaker, googleDocsTextInsert };
|
|
131
|
-
//# sourceMappingURL=chunk-JRH65Q6F.js.map
|
|
132
|
-
//# sourceMappingURL=chunk-JRH65Q6F.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/document-create.ts","../src/actions/text-insert.ts"],"names":["callConnector"],"mappings":";;;AAyBA,SAAS,kBAAA,CAAmB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAClE,EAAA,OAAO;AAAA,IACL,YAAA,EAAc,IAAA,CAAK,EAAA,CAAG,MAAM,CAAA;AAAA,IAC5B,OAAA,EAAU,MAAA,CAAO,KAAA,KAAU,MAAA,IAAa,MAAA,CAAO,KAAA,KAAU,IAAA,IAAQ,MAAA,CAAO,KAAA,KAAU,EAAA,GAAK,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA,GAAI;AAAA,GAChH;AACF;AAEA,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC9D,EAAA,OAAO;AAAA,IACL,cAAe,MAAA,CAAO,UAAA,KAAe,MAAA,IAAa,MAAA,CAAO,eAAe,IAAA,IAAQ,MAAA,CAAO,UAAA,KAAe,EAAA,GAAK,OAAO,MAAA,CAAO,UAAU,CAAA,GAAI,IAAA,CAAK,GAAG,MAAM,CAAA;AAAA,IACrJ,SAAA,EAAW;AAAA,MACT;AAAC;AACH,GACF;AACF;AAEO,IAAM,eAAA,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AAA,CAAW;AAAA,QACf,4BAAA,EAA8B,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA;AAAA,QAChD,wCAAwC,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC;AAAA,OACxE;AAAA;AACH,GACD,CAAA;AACH;AASA,SAAS,WAAW,IAAA,EAAwD;AAC1E,EAAA,MAAM,MAA+B,EAAC;AAEtC,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AAChD,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC5B,IAAA,IAAI,IAAA,GAAO,GAAA;AAEX,IAAA,OAAO,KAAA,CAAM,SAAS,CAAA,EAAG;AACvB,MAAA,MAAM,GAAA,GAAM,MAAM,KAAA,EAAM;AAMxB,MAAA,MAAM,aAAa,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,KAAK,EAAE,CAAA;AAE9C,MAAA,IAAI,OAAO,IAAA,CAAK,GAAG,CAAA,KAAM,YAAY,IAAA,CAAK,GAAG,CAAA,KAAM,IAAA,OAAW,GAAG,CAAA,GAAI,UAAA,GAAa,KAAK,EAAC;AACxF,MAAA,IAAA,GAAO,KAAK,GAAG,CAAA;AAAA,IACjB;AAEA,IAAA,IAAA,CAAK,KAAA,CAAM,CAAC,CAAW,CAAA,GAAI,KAAA;AAAA,EAC7B;AAEA,EAAA,OAAO,GAAA;AACT","file":"chunk-JRH65Q6F.js","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/fixtures/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * The Google Docs faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Google Docs actually publishes, so an author can wire {{ $json.data.id\n * }} against a fake and have it keep working against the real thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeDocumentCreate({ config, fake }: FakeRequest): unknown {\n return {\n \"documentId\": fake.id(\"1Doc\"),\n \"title\": (config.title !== undefined && config.title !== null && config.title !== \"\" ? String(config.title) : \"Untitled document\"),\n };\n}\n\nfunction fakeTextInsert({ config, fake }: FakeRequest): unknown {\n return {\n \"documentId\": (config.documentId !== undefined && config.documentId !== null && config.documentId !== \"\" ? String(config.documentId) : fake.id(\"1Doc\")),\n \"replies\": [\n {},\n ],\n };\n}\n\nexport const googleDocsFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"document_create\":\n return fakeDocumentCreate(request);\n\n case \"text_insert\":\n return fakeTextInsert(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `google_docs: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Google Docs, as one service descriptor shared by every Google Docs\n * operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Google Docs: its base URL, its auth\n * scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Google has no sandbox for Docs. A test document is a real one in a real\n * Drive, so every create is real -- use the faker while developing and clean\n * up any live test documents.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { googleDocsFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const GOOGLE_DOCS_BASE_URLS = {\n \"live\": \"https://docs.googleapis.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const GOOGLE_DOCS_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Google Docs's auth scheme to an outgoing request.\n *\n *\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function googleDocsAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers.Authorization = `Bearer ${credentials.accessToken ?? \"\"}`;\n}\n\n/** The Google Docs service, for the TypeScript runtime. */\nexport const GOOGLE_DOCS: ServiceDescriptor = {\n service: \"google_docs\",\n title: \"Google Docs\",\n sandbox: \"none\",\n baseUrls: { ...GOOGLE_DOCS_BASE_URLS },\n requires: [...GOOGLE_DOCS_REQUIRES],\n authorize: googleDocsAuthorize,\n faker: googleDocsFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/document-create.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/document-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Create a blank Google Docs document.\n *\n * POST /v1/documents —\n * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/create\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Google Docs or calls the\n * faker.\n *\n * sideEffects: unsafe-to-replay.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { GOOGLE_DOCS } from \"../service.js\";\n\nexport const DOCUMENT_CREATE_OPERATION = \"document_create\";\n\nexport type DocumentCreateOptions = {\n /** The node's resolved config. Keys: title. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function googleDocsDocumentCreate(options: DocumentCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.title === undefined || config.title === null || config.title === \"\") {\n throw new Error(`document_create: \"title\" is required (Title).`);\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: DOCUMENT_CREATE_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: \"/v1/documents\",\n json: {\n \"title\": String(config.title),\n },\n },\n });\n}\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/text-insert.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/text-insert.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_docs\n */\n\n/**\n * Insert plain text at a position in an existing document's body.\n *\n * POST /v1/documents/{documentId}:batchUpdate —\n * https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Google Docs or calls the\n * faker.\n *\n * sideEffects: unsafe-to-replay.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { GOOGLE_DOCS } from \"../service.js\";\n\nexport const TEXT_INSERT_OPERATION = \"text_insert\";\n\nexport type TextInsertOptions = {\n /** The node's resolved config. Keys: documentId, text, index. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function googleDocsTextInsert(options: TextInsertOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.documentId === undefined || config.documentId === null || config.documentId === \"\") {\n throw new Error(`text_insert: \"documentId\" is required (Document ID).`);\n }\n\n if (config.text === undefined || config.text === null || config.text === \"\") {\n throw new Error(`text_insert: \"text\" is required (Text).`);\n }\n\n {\n const n = Number(config.index);\n if (!(Number.isInteger(n) && n >= 1)) {\n throw new Error(\n `text_insert: \"index\" must be a integer, got ${JSON.stringify(config.index)}.`,\n );\n }\n }\n\n return callConnector(GOOGLE_DOCS, {\n operation: TEXT_INSERT_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: `/v1/documents/${encodeURIComponent(String(config.documentId))}:batchUpdate`,\n json: nestFields({\n \"requests.0.insertText.text\": String(config.text),\n \"requests.0.insertText.location.index\": Math.trunc(Number(config.index)),\n }),\n },\n });\n}\n\n/**\n * `{\"properties.email\": x}` -> `{properties: {email: x}}`.\n *\n * A dotted `as` means NESTING, and only a JSON body can nest. The validator\n * refuses that spelling anywhere else, because in a form body it already means\n * something different — a literal dotted key.\n */\nfunction nestFields(flat: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split(\".\");\n let node = out;\n\n while (parts.length > 1) {\n const key = parts.shift() as string;\n // A NUMERIC segment is an array index: `dateRanges.0.startDate` has to\n // become `[{startDate}]`, not `{\"0\": {startDate}}`. PHP produced the\n // array by accident (its integer-keyed arrays serialise as JSON lists)\n // and the other two produced an object, which the provider rejects as\n // the wrong type. The parity suite is what caught the disagreement.\n const wantsArray = /^\\d+$/.test(parts[0] ?? \"\");\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = wantsArray ? [] : {};\n node = node[key] as Record<string, unknown>;\n }\n\n node[parts[0] as string] = value;\n }\n\n return out;\n}\n"]}
|