@superdurable/connector-coda 0.1.1 → 0.2.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/README.md +22 -3
- package/dex-connector.json +351 -4
- package/dist/chunk-KSTUDMMZ.js +373 -0
- package/dist/connection-CYkN7IqB.d.ts +260 -0
- package/dist/index.d.ts +309 -7
- package/dist/index.js +376 -17
- package/dist/mock.d.ts +107 -2
- package/dist/mock.js +259 -2
- package/package.json +3 -2
- package/dist/chunk-ZY4WUCOW.js +0 -132
- package/dist/connection-Bh8uZ-8W.d.ts +0 -99
package/dist/index.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ColumnSchema,
|
|
3
|
+
ColumnsPageSchema,
|
|
2
4
|
ConfigSchema,
|
|
3
5
|
Connection,
|
|
4
6
|
ConnectorID,
|
|
7
|
+
CredentialMaterialError,
|
|
8
|
+
DocSchema,
|
|
9
|
+
DocsPageSchema,
|
|
10
|
+
GetDocBranch,
|
|
11
|
+
GetDocBranchDefect,
|
|
12
|
+
GetDocBranchFound,
|
|
13
|
+
GetDocBranchInvalidResponse,
|
|
14
|
+
GetDocBranchNotFound,
|
|
15
|
+
GetDocBranchProviderRejected,
|
|
16
|
+
GetDocDefinition,
|
|
17
|
+
GetDocInputSchema,
|
|
18
|
+
GetDocMetadata,
|
|
5
19
|
GetRowBranch,
|
|
6
20
|
GetRowBranchDefect,
|
|
7
21
|
GetRowBranchFound,
|
|
@@ -12,6 +26,32 @@ import {
|
|
|
12
26
|
GetRowInputSchema,
|
|
13
27
|
GetRowMetadata,
|
|
14
28
|
GetRowOutputSchema,
|
|
29
|
+
GetTableBranch,
|
|
30
|
+
GetTableBranchDefect,
|
|
31
|
+
GetTableBranchFound,
|
|
32
|
+
GetTableBranchInvalidResponse,
|
|
33
|
+
GetTableBranchNotFound,
|
|
34
|
+
GetTableBranchProviderRejected,
|
|
35
|
+
GetTableDefinition,
|
|
36
|
+
GetTableInputSchema,
|
|
37
|
+
GetTableMetadata,
|
|
38
|
+
ListColumnsBranch,
|
|
39
|
+
ListColumnsBranchDefect,
|
|
40
|
+
ListColumnsBranchInvalidResponse,
|
|
41
|
+
ListColumnsBranchListed,
|
|
42
|
+
ListColumnsBranchNotFound,
|
|
43
|
+
ListColumnsBranchProviderRejected,
|
|
44
|
+
ListColumnsDefinition,
|
|
45
|
+
ListColumnsInputSchema,
|
|
46
|
+
ListColumnsMetadata,
|
|
47
|
+
ListDocsBranch,
|
|
48
|
+
ListDocsBranchDefect,
|
|
49
|
+
ListDocsBranchInvalidResponse,
|
|
50
|
+
ListDocsBranchListed,
|
|
51
|
+
ListDocsBranchProviderRejected,
|
|
52
|
+
ListDocsDefinition,
|
|
53
|
+
ListDocsInputSchema,
|
|
54
|
+
ListDocsMetadata,
|
|
15
55
|
ListRowsBranch,
|
|
16
56
|
ListRowsBranchDefect,
|
|
17
57
|
ListRowsBranchInvalidResponse,
|
|
@@ -21,42 +61,249 @@ import {
|
|
|
21
61
|
ListRowsInputSchema,
|
|
22
62
|
ListRowsMetadata,
|
|
23
63
|
ListRowsOutputSchema,
|
|
64
|
+
ListTablesBranch,
|
|
65
|
+
ListTablesBranchDefect,
|
|
66
|
+
ListTablesBranchInvalidResponse,
|
|
67
|
+
ListTablesBranchListed,
|
|
68
|
+
ListTablesBranchNotFound,
|
|
69
|
+
ListTablesBranchProviderRejected,
|
|
70
|
+
ListTablesDefinition,
|
|
71
|
+
ListTablesInputSchema,
|
|
72
|
+
ListTablesMetadata,
|
|
24
73
|
ProviderID,
|
|
25
|
-
|
|
26
|
-
|
|
74
|
+
TableSchema,
|
|
75
|
+
TablesPageSchema,
|
|
76
|
+
decodeCredentials,
|
|
77
|
+
isCredentialMaterialError,
|
|
27
78
|
newProjectConnection
|
|
28
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-KSTUDMMZ.js";
|
|
29
80
|
|
|
30
81
|
// src/generated/steps.ts
|
|
31
82
|
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
32
83
|
function newListRowsStep(configuration) {
|
|
33
|
-
const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
84
|
+
const { connection, connectionName, listed, providerRejected, invalidResponse: invalidResponse2, defect, ...stepConfiguration } = configuration;
|
|
34
85
|
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
35
86
|
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listRows(), connection: connection.reference, branches: [
|
|
36
87
|
goToBranch("listed", listed),
|
|
37
88
|
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
38
|
-
...
|
|
89
|
+
...invalidResponse2 ? [goToBranch("invalidResponse", invalidResponse2)] : [],
|
|
39
90
|
...defect ? [goToBranch("defect", defect)] : []
|
|
40
91
|
] });
|
|
41
92
|
}
|
|
42
93
|
function newGetRowStep(configuration) {
|
|
43
|
-
const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
94
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse: invalidResponse2, defect, ...stepConfiguration } = configuration;
|
|
44
95
|
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
45
96
|
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getRow(), connection: connection.reference, branches: [
|
|
46
97
|
goToBranch("found", found),
|
|
47
98
|
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
48
99
|
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
49
|
-
...
|
|
100
|
+
...invalidResponse2 ? [goToBranch("invalidResponse", invalidResponse2)] : [],
|
|
101
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
102
|
+
] });
|
|
103
|
+
}
|
|
104
|
+
function newListDocsStep(configuration) {
|
|
105
|
+
const { connection, connectionName, listed, providerRejected, invalidResponse: invalidResponse2, defect, ...stepConfiguration } = configuration;
|
|
106
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
107
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listDocs(), connection: connection.reference, branches: [
|
|
108
|
+
goToBranch("listed", listed),
|
|
109
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
110
|
+
...invalidResponse2 ? [goToBranch("invalidResponse", invalidResponse2)] : [],
|
|
111
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
function newGetDocStep(configuration) {
|
|
115
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse: invalidResponse2, defect, ...stepConfiguration } = configuration;
|
|
116
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
117
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getDoc(), connection: connection.reference, branches: [
|
|
118
|
+
goToBranch("found", found),
|
|
119
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
120
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
121
|
+
...invalidResponse2 ? [goToBranch("invalidResponse", invalidResponse2)] : [],
|
|
122
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
123
|
+
] });
|
|
124
|
+
}
|
|
125
|
+
function newListTablesStep(configuration) {
|
|
126
|
+
const { connection, connectionName, listed, notFound, providerRejected, invalidResponse: invalidResponse2, defect, ...stepConfiguration } = configuration;
|
|
127
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
128
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listTables(), connection: connection.reference, branches: [
|
|
129
|
+
goToBranch("listed", listed),
|
|
130
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
131
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
132
|
+
...invalidResponse2 ? [goToBranch("invalidResponse", invalidResponse2)] : [],
|
|
50
133
|
...defect ? [goToBranch("defect", defect)] : []
|
|
51
134
|
] });
|
|
52
135
|
}
|
|
136
|
+
function newGetTableStep(configuration) {
|
|
137
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse: invalidResponse2, defect, ...stepConfiguration } = configuration;
|
|
138
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
139
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getTable(), connection: connection.reference, branches: [
|
|
140
|
+
goToBranch("found", found),
|
|
141
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
142
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
143
|
+
...invalidResponse2 ? [goToBranch("invalidResponse", invalidResponse2)] : [],
|
|
144
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
145
|
+
] });
|
|
146
|
+
}
|
|
147
|
+
function newListColumnsStep(configuration) {
|
|
148
|
+
const { connection, connectionName, listed, notFound, providerRejected, invalidResponse: invalidResponse2, defect, ...stepConfiguration } = configuration;
|
|
149
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
150
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listColumns(), connection: connection.reference, branches: [
|
|
151
|
+
goToBranch("listed", listed),
|
|
152
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
153
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
154
|
+
...invalidResponse2 ? [goToBranch("invalidResponse", invalidResponse2)] : [],
|
|
155
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/connection.ts
|
|
160
|
+
var Connection2 = Connection;
|
|
161
|
+
function newConnection(client, reference) {
|
|
162
|
+
return new Connection2(reference, client);
|
|
163
|
+
}
|
|
164
|
+
function newConnectionWithOperations(operations, reference) {
|
|
165
|
+
return new Connection2(reference, operations);
|
|
166
|
+
}
|
|
53
167
|
|
|
54
168
|
// src/client.ts
|
|
55
169
|
import { SecretString } from "@superdurable/connectors-sdk";
|
|
56
170
|
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
57
171
|
|
|
58
|
-
// src/
|
|
172
|
+
// src/metadata.ts
|
|
59
173
|
import { newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
174
|
+
function validID(value) {
|
|
175
|
+
return typeof value === "string" && value.length > 0 && !/[^A-Za-z0-9_-]/.test(value);
|
|
176
|
+
}
|
|
177
|
+
function metadataFields(value) {
|
|
178
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
179
|
+
return Object.fromEntries(Object.entries(value).map(([key, field]) => [key.toLowerCase(), field]));
|
|
180
|
+
}
|
|
181
|
+
function identity(value) {
|
|
182
|
+
const fields = metadataFields(value);
|
|
183
|
+
if (!fields || typeof fields.id !== "string" || !fields.id || typeof fields.name !== "string" || !fields.name) return void 0;
|
|
184
|
+
return { id: fields.id, name: fields.name };
|
|
185
|
+
}
|
|
186
|
+
function invalidInput(operation, empty) {
|
|
187
|
+
return newQueryBranch("defect", empty, {}, { kind: "VALIDATION", provider: "coda", operation, message: "invalid Coda metadata input" });
|
|
188
|
+
}
|
|
189
|
+
function invalidResponse(operation, empty) {
|
|
190
|
+
return newQueryBranch("invalidResponse", empty, {}, { kind: "PROTOCOL", provider: "coda", operation, message: "provider returned incomplete metadata" });
|
|
191
|
+
}
|
|
192
|
+
function exchangeFailure(outcome, empty) {
|
|
193
|
+
return outcome.branch === "retry" ? newQueryRetry(outcome.failure, outcome.retryAfterMs) : newQueryBranch(outcome.branch, empty, {}, outcome.failure);
|
|
194
|
+
}
|
|
195
|
+
async function getMetadata(client, call, operation, path) {
|
|
196
|
+
const empty = { id: "", name: "" };
|
|
197
|
+
const result = await client.exchange(call, operation, path, new URLSearchParams(), true);
|
|
198
|
+
if ("outcome" in result) return exchangeFailure(result.outcome, empty);
|
|
199
|
+
const item = identity(JSON.parse(Buffer.from(result.body).toString("utf8")));
|
|
200
|
+
return item ? newQueryBranch("found", item) : invalidResponse(operation, empty);
|
|
201
|
+
}
|
|
202
|
+
async function listMetadata(client, call, operation, path, input, hasNotFound) {
|
|
203
|
+
const empty = { items: [], nextPageToken: "" };
|
|
204
|
+
const limit = input.limit === void 0 ? 0 : input.limit;
|
|
205
|
+
const token = input.pageToken === void 0 ? "" : input.pageToken;
|
|
206
|
+
if (!Number.isInteger(limit) || limit < 0 || limit > 500 || typeof token !== "string" || Buffer.byteLength(token) > 2048) return invalidInput(operation, empty);
|
|
207
|
+
const query = new URLSearchParams();
|
|
208
|
+
if (limit) query.set("limit", String(limit));
|
|
209
|
+
if (token) query.set("pageToken", token);
|
|
210
|
+
const result = await client.exchange(call, operation, path, query, hasNotFound);
|
|
211
|
+
if ("outcome" in result) return exchangeFailure(result.outcome, empty);
|
|
212
|
+
const fields = metadataFields(JSON.parse(Buffer.from(result.body).toString("utf8")));
|
|
213
|
+
if (!fields || !Array.isArray(fields.items)) return invalidResponse(operation, empty);
|
|
214
|
+
const nextPageToken = fields.nextpagetoken ?? "";
|
|
215
|
+
if (typeof nextPageToken !== "string") return invalidResponse(operation, empty);
|
|
216
|
+
const items = [];
|
|
217
|
+
for (const value of fields.items) {
|
|
218
|
+
const item = identity(value);
|
|
219
|
+
if (!item) return invalidResponse(operation, empty);
|
|
220
|
+
items.push(item);
|
|
221
|
+
}
|
|
222
|
+
return newQueryBranch("listed", { items, nextPageToken });
|
|
223
|
+
}
|
|
224
|
+
var ListDocsOperation = class {
|
|
225
|
+
/** Bind this operation to the provider client. */
|
|
226
|
+
constructor(client) {
|
|
227
|
+
this.client = client;
|
|
228
|
+
}
|
|
229
|
+
client;
|
|
230
|
+
/** Return the manifest definition and retry policy. */
|
|
231
|
+
definition() {
|
|
232
|
+
return ListDocsDefinition;
|
|
233
|
+
}
|
|
234
|
+
/** Validate the request and return the provider outcome. */
|
|
235
|
+
async invoke(call, input) {
|
|
236
|
+
if (!input) return invalidInput("listDocs", { items: [], nextPageToken: "" });
|
|
237
|
+
return listMetadata(this.client, call, "listDocs", "/docs", input, false);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
var GetDocOperation = class {
|
|
241
|
+
/** Bind this operation to the provider client. */
|
|
242
|
+
constructor(client) {
|
|
243
|
+
this.client = client;
|
|
244
|
+
}
|
|
245
|
+
client;
|
|
246
|
+
/** Return the manifest definition and retry policy. */
|
|
247
|
+
definition() {
|
|
248
|
+
return GetDocDefinition;
|
|
249
|
+
}
|
|
250
|
+
/** Validate the request and return the provider outcome. */
|
|
251
|
+
async invoke(call, input) {
|
|
252
|
+
if (!input || !validID(input.docId)) return invalidInput("getDoc", { id: "", name: "" });
|
|
253
|
+
return getMetadata(this.client, call, "getDoc", `/docs/${input.docId}`);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
var ListTablesOperation = class {
|
|
257
|
+
/** Bind this operation to the provider client. */
|
|
258
|
+
constructor(client) {
|
|
259
|
+
this.client = client;
|
|
260
|
+
}
|
|
261
|
+
client;
|
|
262
|
+
/** Return the manifest definition and retry policy. */
|
|
263
|
+
definition() {
|
|
264
|
+
return ListTablesDefinition;
|
|
265
|
+
}
|
|
266
|
+
/** Validate the request and return the provider outcome. */
|
|
267
|
+
async invoke(call, input) {
|
|
268
|
+
if (!input || !validID(input.docId)) return invalidInput("listTables", { items: [], nextPageToken: "" });
|
|
269
|
+
return listMetadata(this.client, call, "listTables", `/docs/${input.docId}/tables`, input, true);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
var GetTableOperation = class {
|
|
273
|
+
/** Bind this operation to the provider client. */
|
|
274
|
+
constructor(client) {
|
|
275
|
+
this.client = client;
|
|
276
|
+
}
|
|
277
|
+
client;
|
|
278
|
+
/** Return the manifest definition and retry policy. */
|
|
279
|
+
definition() {
|
|
280
|
+
return GetTableDefinition;
|
|
281
|
+
}
|
|
282
|
+
/** Validate the request and return the provider outcome. */
|
|
283
|
+
async invoke(call, input) {
|
|
284
|
+
if (!input || !validID(input.docId) || !validID(input.tableId)) return invalidInput("getTable", { id: "", name: "" });
|
|
285
|
+
return getMetadata(this.client, call, "getTable", `/docs/${input.docId}/tables/${input.tableId}`);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var ListColumnsOperation = class {
|
|
289
|
+
/** Bind this operation to the provider client. */
|
|
290
|
+
constructor(client) {
|
|
291
|
+
this.client = client;
|
|
292
|
+
}
|
|
293
|
+
client;
|
|
294
|
+
/** Return the manifest definition and retry policy. */
|
|
295
|
+
definition() {
|
|
296
|
+
return ListColumnsDefinition;
|
|
297
|
+
}
|
|
298
|
+
/** Validate the request and return the provider outcome. */
|
|
299
|
+
async invoke(call, input) {
|
|
300
|
+
if (!input || !validID(input.docId) || !validID(input.tableId)) return invalidInput("listColumns", { items: [], nextPageToken: "" });
|
|
301
|
+
return listMetadata(this.client, call, "listColumns", `/docs/${input.docId}/tables/${input.tableId}/columns`, input, true);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// src/operations.ts
|
|
306
|
+
import { newQueryBranch as newQueryBranch2, newQueryRetry as newQueryRetry2 } from "@superdurable/connectors-sdk";
|
|
60
307
|
var identifier = /^[A-Za-z0-9_-]+$/;
|
|
61
308
|
var emptyOutput = { data: null };
|
|
62
309
|
var ListRowsOperation = class {
|
|
@@ -81,7 +328,7 @@ var ListRowsOperation = class {
|
|
|
81
328
|
if ("outcome" in result) return classifyOutcome(result.outcome);
|
|
82
329
|
const decoded = decodeObject(result);
|
|
83
330
|
if (!decoded || !Array.isArray(decoded.items)) return failedBranch("invalidResponse", "listRows", "PROTOCOL", "provider returned an incomplete response");
|
|
84
|
-
return
|
|
331
|
+
return newQueryBranch2("listed", { data: decoded });
|
|
85
332
|
}
|
|
86
333
|
};
|
|
87
334
|
var GetRowOperation = class {
|
|
@@ -103,7 +350,7 @@ var GetRowOperation = class {
|
|
|
103
350
|
if ("outcome" in result) return classifyOutcome(result.outcome);
|
|
104
351
|
const decoded = decodeObject(result);
|
|
105
352
|
if (!decoded || typeof decoded.id !== "string" || !decoded.id) return failedBranch("invalidResponse", "getRow", "PROTOCOL", "provider returned an incomplete response");
|
|
106
|
-
return
|
|
353
|
+
return newQueryBranch2("found", { data: decoded });
|
|
107
354
|
}
|
|
108
355
|
};
|
|
109
356
|
function decodeObject(result) {
|
|
@@ -117,11 +364,11 @@ function decodeObject(result) {
|
|
|
117
364
|
}
|
|
118
365
|
}
|
|
119
366
|
function classifyOutcome(outcome) {
|
|
120
|
-
if (outcome.branch === "retry") return
|
|
121
|
-
return
|
|
367
|
+
if (outcome.branch === "retry") return newQueryRetry2(outcome.failure, outcome.retryAfterMs);
|
|
368
|
+
return newQueryBranch2(outcome.branch, emptyOutput, {}, outcome.failure);
|
|
122
369
|
}
|
|
123
370
|
function failedBranch(branch, operation, kind, message) {
|
|
124
|
-
return
|
|
371
|
+
return newQueryBranch2(branch, emptyOutput, {}, { kind, provider: "coda", operation, message });
|
|
125
372
|
}
|
|
126
373
|
|
|
127
374
|
// src/client.ts
|
|
@@ -145,6 +392,26 @@ var CodaClient = class {
|
|
|
145
392
|
this.credentials = credentials;
|
|
146
393
|
this.send = options.send ?? sendProviderRequest;
|
|
147
394
|
}
|
|
395
|
+
/** Bind the listDocs Query. */
|
|
396
|
+
listDocs() {
|
|
397
|
+
return new ListDocsOperation(this);
|
|
398
|
+
}
|
|
399
|
+
/** Bind the getDoc Query. */
|
|
400
|
+
getDoc() {
|
|
401
|
+
return new GetDocOperation(this);
|
|
402
|
+
}
|
|
403
|
+
/** Bind the listTables Query. */
|
|
404
|
+
listTables() {
|
|
405
|
+
return new ListTablesOperation(this);
|
|
406
|
+
}
|
|
407
|
+
/** Bind the getTable Query. */
|
|
408
|
+
getTable() {
|
|
409
|
+
return new GetTableOperation(this);
|
|
410
|
+
}
|
|
411
|
+
/** Bind the listColumns Query. */
|
|
412
|
+
listColumns() {
|
|
413
|
+
return new ListColumnsOperation(this);
|
|
414
|
+
}
|
|
148
415
|
/** Bind the list query. */
|
|
149
416
|
listRows() {
|
|
150
417
|
return new ListRowsOperation(this);
|
|
@@ -164,7 +431,7 @@ var CodaClient = class {
|
|
|
164
431
|
} catch {
|
|
165
432
|
return { outcome: this.failure("defect", operation, "AUTHENTICATION", "connection credentials are unavailable") };
|
|
166
433
|
}
|
|
167
|
-
const address = this.baseUrl + path + (query.size ? `?${query.toString()}` : "");
|
|
434
|
+
const address = this.baseUrl + path + (query.size ? `?${query.toString().replace(/\*/g, "%2A").replace(/%7E/g, "~")}` : "");
|
|
168
435
|
let response;
|
|
169
436
|
try {
|
|
170
437
|
response = await this.send({
|
|
@@ -177,8 +444,10 @@ var CodaClient = class {
|
|
|
177
444
|
signal: call.context.cancellationSignal
|
|
178
445
|
});
|
|
179
446
|
} catch (error) {
|
|
180
|
-
if (error instanceof BodyTooLargeError)
|
|
181
|
-
|
|
447
|
+
if (error instanceof BodyTooLargeError) {
|
|
448
|
+
if (error.status === void 0 || error.status === 200) return { outcome: this.failure("invalidResponse", operation, "RESPONSE_TOO_LARGE", "provider response exceeded the configured limit") };
|
|
449
|
+
response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
|
|
450
|
+
} else return { outcome: this.failure("retry", operation, "AVAILABILITY", "provider request failed") };
|
|
182
451
|
}
|
|
183
452
|
const status = response.status;
|
|
184
453
|
if (status === 429 || status === 408 || status === 409 || status >= 500) {
|
|
@@ -191,17 +460,44 @@ var CodaClient = class {
|
|
|
191
460
|
const kind = status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : status === 400 || status === 422 ? "VALIDATION" : "PROVIDER_REJECTION";
|
|
192
461
|
return { outcome: this.failure("providerRejected", operation, kind, `provider rejected the request with HTTP ${status}`) };
|
|
193
462
|
}
|
|
463
|
+
if (response.body.byteLength > this.maxResponseBytes) {
|
|
464
|
+
return { outcome: this.failure("invalidResponse", operation, "RESPONSE_TOO_LARGE", "provider response exceeded the configured limit") };
|
|
465
|
+
}
|
|
194
466
|
try {
|
|
195
467
|
JSON.parse(Buffer.from(response.body).toString("utf8"));
|
|
196
468
|
} catch {
|
|
197
469
|
return { outcome: this.failure("invalidResponse", operation, "PROTOCOL", "provider returned malformed JSON") };
|
|
198
470
|
}
|
|
471
|
+
if (containsAccessToken(response.body, token)) return { outcome: this.failure("defect", operation, "AUTHENTICATION", "provider returned the connection credential") };
|
|
199
472
|
return { body: response.body };
|
|
200
473
|
}
|
|
201
474
|
failure(branch, operation, kind, message, retryAfterMs = 0) {
|
|
202
475
|
return { branch, failure: { kind, provider: "coda", operation, message }, retryAfterMs };
|
|
203
476
|
}
|
|
204
477
|
};
|
|
478
|
+
function containsAccessToken(body, token) {
|
|
479
|
+
const bytes = Buffer.from(body);
|
|
480
|
+
if (bytes.includes(token)) return true;
|
|
481
|
+
if (!bytes.includes(92)) return false;
|
|
482
|
+
let document;
|
|
483
|
+
try {
|
|
484
|
+
document = JSON.parse(bytes.toString("utf8"));
|
|
485
|
+
} catch {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
const pending = [document];
|
|
489
|
+
while (pending.length) {
|
|
490
|
+
const value = pending.pop();
|
|
491
|
+
if (typeof value === "string" && value.includes(token)) return true;
|
|
492
|
+
if (value !== null && typeof value === "object") {
|
|
493
|
+
for (const [name, field] of Object.entries(value)) {
|
|
494
|
+
if (name.includes(token)) return true;
|
|
495
|
+
pending.push(field);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
205
501
|
|
|
206
502
|
// src/project.ts
|
|
207
503
|
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
@@ -248,9 +544,24 @@ function parseDurationMilliseconds(value) {
|
|
|
248
544
|
}
|
|
249
545
|
export {
|
|
250
546
|
CodaClient,
|
|
547
|
+
ColumnSchema,
|
|
548
|
+
ColumnsPageSchema,
|
|
251
549
|
ConfigSchema,
|
|
252
|
-
Connection,
|
|
550
|
+
Connection2 as Connection,
|
|
253
551
|
ConnectorID,
|
|
552
|
+
CredentialMaterialError,
|
|
553
|
+
DocSchema,
|
|
554
|
+
DocsPageSchema,
|
|
555
|
+
GetDocBranch,
|
|
556
|
+
GetDocBranchDefect,
|
|
557
|
+
GetDocBranchFound,
|
|
558
|
+
GetDocBranchInvalidResponse,
|
|
559
|
+
GetDocBranchNotFound,
|
|
560
|
+
GetDocBranchProviderRejected,
|
|
561
|
+
GetDocDefinition,
|
|
562
|
+
GetDocInputSchema,
|
|
563
|
+
GetDocMetadata,
|
|
564
|
+
GetDocOperation,
|
|
254
565
|
GetRowBranch,
|
|
255
566
|
GetRowBranchDefect,
|
|
256
567
|
GetRowBranchFound,
|
|
@@ -262,6 +573,35 @@ export {
|
|
|
262
573
|
GetRowMetadata,
|
|
263
574
|
GetRowOperation,
|
|
264
575
|
GetRowOutputSchema,
|
|
576
|
+
GetTableBranch,
|
|
577
|
+
GetTableBranchDefect,
|
|
578
|
+
GetTableBranchFound,
|
|
579
|
+
GetTableBranchInvalidResponse,
|
|
580
|
+
GetTableBranchNotFound,
|
|
581
|
+
GetTableBranchProviderRejected,
|
|
582
|
+
GetTableDefinition,
|
|
583
|
+
GetTableInputSchema,
|
|
584
|
+
GetTableMetadata,
|
|
585
|
+
GetTableOperation,
|
|
586
|
+
ListColumnsBranch,
|
|
587
|
+
ListColumnsBranchDefect,
|
|
588
|
+
ListColumnsBranchInvalidResponse,
|
|
589
|
+
ListColumnsBranchListed,
|
|
590
|
+
ListColumnsBranchNotFound,
|
|
591
|
+
ListColumnsBranchProviderRejected,
|
|
592
|
+
ListColumnsDefinition,
|
|
593
|
+
ListColumnsInputSchema,
|
|
594
|
+
ListColumnsMetadata,
|
|
595
|
+
ListColumnsOperation,
|
|
596
|
+
ListDocsBranch,
|
|
597
|
+
ListDocsBranchDefect,
|
|
598
|
+
ListDocsBranchInvalidResponse,
|
|
599
|
+
ListDocsBranchListed,
|
|
600
|
+
ListDocsBranchProviderRejected,
|
|
601
|
+
ListDocsDefinition,
|
|
602
|
+
ListDocsInputSchema,
|
|
603
|
+
ListDocsMetadata,
|
|
604
|
+
ListDocsOperation,
|
|
265
605
|
ListRowsBranch,
|
|
266
606
|
ListRowsBranchDefect,
|
|
267
607
|
ListRowsBranchInvalidResponse,
|
|
@@ -272,10 +612,29 @@ export {
|
|
|
272
612
|
ListRowsMetadata,
|
|
273
613
|
ListRowsOperation,
|
|
274
614
|
ListRowsOutputSchema,
|
|
615
|
+
ListTablesBranch,
|
|
616
|
+
ListTablesBranchDefect,
|
|
617
|
+
ListTablesBranchInvalidResponse,
|
|
618
|
+
ListTablesBranchListed,
|
|
619
|
+
ListTablesBranchNotFound,
|
|
620
|
+
ListTablesBranchProviderRejected,
|
|
621
|
+
ListTablesDefinition,
|
|
622
|
+
ListTablesInputSchema,
|
|
623
|
+
ListTablesMetadata,
|
|
624
|
+
ListTablesOperation,
|
|
275
625
|
ProviderID,
|
|
626
|
+
TableSchema,
|
|
627
|
+
TablesPageSchema,
|
|
628
|
+
decodeCredentials,
|
|
629
|
+
isCredentialMaterialError,
|
|
276
630
|
newConnection,
|
|
277
631
|
newConnectionWithOperations,
|
|
632
|
+
newGetDocStep,
|
|
278
633
|
newGetRowStep,
|
|
634
|
+
newGetTableStep,
|
|
635
|
+
newListColumnsStep,
|
|
636
|
+
newListDocsStep,
|
|
279
637
|
newListRowsStep,
|
|
638
|
+
newListTablesStep,
|
|
280
639
|
newProjectConnection2 as newProjectConnection
|
|
281
640
|
};
|
package/dist/mock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
2
|
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
-
import { O as Operations, C as Connection,
|
|
3
|
+
import { O as Operations, C as Connection, g as ListRowsInput, h as ListRowsOutput, a as GetRowInput, b as GetRowOutput, e as ListDocsInput, f as DocsPage, G as GetDocInput, D as Doc, i as ListTablesInput, j as TablesPage, c as GetTableInput, T as Table, L as ListColumnsInput, d as ColumnsPage, m as Column } from './connection-CYkN7IqB.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
/** Go zero value for ListRowsInput in scripted cases. */
|
|
@@ -11,6 +11,28 @@ declare const emptyListRowsOutput: ListRowsOutput;
|
|
|
11
11
|
declare const emptyGetRowInput: GetRowInput;
|
|
12
12
|
/** Go zero value for GetRowOutput in scripted cases. */
|
|
13
13
|
declare const emptyGetRowOutput: GetRowOutput;
|
|
14
|
+
/** Go zero value for ListDocsInput in scripted cases. */
|
|
15
|
+
declare const emptyListDocsInput: ListDocsInput;
|
|
16
|
+
/** Go zero value for Doc in scripted cases. */
|
|
17
|
+
declare const emptyDoc: Doc;
|
|
18
|
+
/** Go zero value for DocsPage in scripted cases. */
|
|
19
|
+
declare const emptyDocsPage: DocsPage;
|
|
20
|
+
/** Go zero value for GetDocInput in scripted cases. */
|
|
21
|
+
declare const emptyGetDocInput: GetDocInput;
|
|
22
|
+
/** Go zero value for ListTablesInput in scripted cases. */
|
|
23
|
+
declare const emptyListTablesInput: ListTablesInput;
|
|
24
|
+
/** Go zero value for Table in scripted cases. */
|
|
25
|
+
declare const emptyTable: Table;
|
|
26
|
+
/** Go zero value for TablesPage in scripted cases. */
|
|
27
|
+
declare const emptyTablesPage: TablesPage;
|
|
28
|
+
/** Go zero value for GetTableInput in scripted cases. */
|
|
29
|
+
declare const emptyGetTableInput: GetTableInput;
|
|
30
|
+
/** Go zero value for ListColumnsInput in scripted cases. */
|
|
31
|
+
declare const emptyListColumnsInput: ListColumnsInput;
|
|
32
|
+
/** Go zero value for Column in scripted cases. */
|
|
33
|
+
declare const emptyColumn: Column;
|
|
34
|
+
/** Go zero value for ColumnsPage in scripted cases. */
|
|
35
|
+
declare const emptyColumnsPage: ColumnsPage;
|
|
14
36
|
/** Script the listed branch. */
|
|
15
37
|
declare function listRowsListed(value: ListRowsOutput, failure?: Failure): Case<ListRowsOutput>;
|
|
16
38
|
/** Script the providerRejected branch. */
|
|
@@ -41,6 +63,84 @@ declare function getRowRetry(failure: Failure, retryAfterMs?: number): Case<GetR
|
|
|
41
63
|
declare function getRowDefaultGetRow(): Case<GetRowOutput>;
|
|
42
64
|
/** Default getRow scenario. */
|
|
43
65
|
declare function getRowDefault(): Case<GetRowOutput>;
|
|
66
|
+
/** Script the listed branch. */
|
|
67
|
+
declare function listDocsListed(value: DocsPage, failure?: Failure): Case<DocsPage>;
|
|
68
|
+
/** Script the providerRejected branch. */
|
|
69
|
+
declare function listDocsProviderRejected(value: DocsPage, failure?: Failure): Case<DocsPage>;
|
|
70
|
+
/** Script the invalidResponse branch. */
|
|
71
|
+
declare function listDocsInvalidResponse(value: DocsPage, failure?: Failure): Case<DocsPage>;
|
|
72
|
+
/** Script the defect branch. */
|
|
73
|
+
declare function listDocsDefect(value: DocsPage, failure?: Failure): Case<DocsPage>;
|
|
74
|
+
/** Script a safe retry of listDocs. */
|
|
75
|
+
declare function listDocsRetry(failure: Failure, retryAfterMs?: number): Case<DocsPage>;
|
|
76
|
+
/** Manifest scenario listedDefault for listDocs. */
|
|
77
|
+
declare function listDocsListedDefault(): Case<DocsPage>;
|
|
78
|
+
/** Default listDocs scenario. */
|
|
79
|
+
declare function listDocsDefault(): Case<DocsPage>;
|
|
80
|
+
/** Script the found branch. */
|
|
81
|
+
declare function getDocFound(value: Doc, failure?: Failure): Case<Doc>;
|
|
82
|
+
/** Script the notFound branch. */
|
|
83
|
+
declare function getDocNotFound(value: Doc, failure?: Failure): Case<Doc>;
|
|
84
|
+
/** Script the providerRejected branch. */
|
|
85
|
+
declare function getDocProviderRejected(value: Doc, failure?: Failure): Case<Doc>;
|
|
86
|
+
/** Script the invalidResponse branch. */
|
|
87
|
+
declare function getDocInvalidResponse(value: Doc, failure?: Failure): Case<Doc>;
|
|
88
|
+
/** Script the defect branch. */
|
|
89
|
+
declare function getDocDefect(value: Doc, failure?: Failure): Case<Doc>;
|
|
90
|
+
/** Script a safe retry of getDoc. */
|
|
91
|
+
declare function getDocRetry(failure: Failure, retryAfterMs?: number): Case<Doc>;
|
|
92
|
+
/** Manifest scenario foundDefault for getDoc. */
|
|
93
|
+
declare function getDocFoundDefault(): Case<Doc>;
|
|
94
|
+
/** Default getDoc scenario. */
|
|
95
|
+
declare function getDocDefault(): Case<Doc>;
|
|
96
|
+
/** Script the listed branch. */
|
|
97
|
+
declare function listTablesListed(value: TablesPage, failure?: Failure): Case<TablesPage>;
|
|
98
|
+
/** Script the notFound branch. */
|
|
99
|
+
declare function listTablesNotFound(value: TablesPage, failure?: Failure): Case<TablesPage>;
|
|
100
|
+
/** Script the providerRejected branch. */
|
|
101
|
+
declare function listTablesProviderRejected(value: TablesPage, failure?: Failure): Case<TablesPage>;
|
|
102
|
+
/** Script the invalidResponse branch. */
|
|
103
|
+
declare function listTablesInvalidResponse(value: TablesPage, failure?: Failure): Case<TablesPage>;
|
|
104
|
+
/** Script the defect branch. */
|
|
105
|
+
declare function listTablesDefect(value: TablesPage, failure?: Failure): Case<TablesPage>;
|
|
106
|
+
/** Script a safe retry of listTables. */
|
|
107
|
+
declare function listTablesRetry(failure: Failure, retryAfterMs?: number): Case<TablesPage>;
|
|
108
|
+
/** Manifest scenario listedDefault for listTables. */
|
|
109
|
+
declare function listTablesListedDefault(): Case<TablesPage>;
|
|
110
|
+
/** Default listTables scenario. */
|
|
111
|
+
declare function listTablesDefault(): Case<TablesPage>;
|
|
112
|
+
/** Script the found branch. */
|
|
113
|
+
declare function getTableFound(value: Table, failure?: Failure): Case<Table>;
|
|
114
|
+
/** Script the notFound branch. */
|
|
115
|
+
declare function getTableNotFound(value: Table, failure?: Failure): Case<Table>;
|
|
116
|
+
/** Script the providerRejected branch. */
|
|
117
|
+
declare function getTableProviderRejected(value: Table, failure?: Failure): Case<Table>;
|
|
118
|
+
/** Script the invalidResponse branch. */
|
|
119
|
+
declare function getTableInvalidResponse(value: Table, failure?: Failure): Case<Table>;
|
|
120
|
+
/** Script the defect branch. */
|
|
121
|
+
declare function getTableDefect(value: Table, failure?: Failure): Case<Table>;
|
|
122
|
+
/** Script a safe retry of getTable. */
|
|
123
|
+
declare function getTableRetry(failure: Failure, retryAfterMs?: number): Case<Table>;
|
|
124
|
+
/** Manifest scenario foundDefault for getTable. */
|
|
125
|
+
declare function getTableFoundDefault(): Case<Table>;
|
|
126
|
+
/** Default getTable scenario. */
|
|
127
|
+
declare function getTableDefault(): Case<Table>;
|
|
128
|
+
/** Script the listed branch. */
|
|
129
|
+
declare function listColumnsListed(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
|
|
130
|
+
/** Script the notFound branch. */
|
|
131
|
+
declare function listColumnsNotFound(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
|
|
132
|
+
/** Script the providerRejected branch. */
|
|
133
|
+
declare function listColumnsProviderRejected(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
|
|
134
|
+
/** Script the invalidResponse branch. */
|
|
135
|
+
declare function listColumnsInvalidResponse(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
|
|
136
|
+
/** Script the defect branch. */
|
|
137
|
+
declare function listColumnsDefect(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
|
|
138
|
+
/** Script a safe retry of listColumns. */
|
|
139
|
+
declare function listColumnsRetry(failure: Failure, retryAfterMs?: number): Case<ColumnsPage>;
|
|
140
|
+
/** Manifest scenario listedDefault for listColumns. */
|
|
141
|
+
declare function listColumnsListedDefault(): Case<ColumnsPage>;
|
|
142
|
+
/** Default listColumns scenario. */
|
|
143
|
+
declare function listColumnsDefault(): Case<ColumnsPage>;
|
|
44
144
|
/** Scripted operations and manifest defaults for this connector. */
|
|
45
145
|
declare class GeneratedMock implements Operations {
|
|
46
146
|
#private;
|
|
@@ -48,7 +148,12 @@ declare class GeneratedMock implements Operations {
|
|
|
48
148
|
connection(): Connection;
|
|
49
149
|
listRows(): MockQuery<ListRowsInput, ListRowsOutput>;
|
|
50
150
|
getRow(): MockQuery<GetRowInput, GetRowOutput>;
|
|
151
|
+
listDocs(): MockQuery<ListDocsInput, DocsPage>;
|
|
152
|
+
getDoc(): MockQuery<GetDocInput, Doc>;
|
|
153
|
+
listTables(): MockQuery<ListTablesInput, TablesPage>;
|
|
154
|
+
getTable(): MockQuery<GetTableInput, Table>;
|
|
155
|
+
listColumns(): MockQuery<ListColumnsInput, ColumnsPage>;
|
|
51
156
|
assertNoFailures(): void;
|
|
52
157
|
}
|
|
53
158
|
|
|
54
|
-
export { GeneratedMock, emptyGetRowInput, emptyGetRowOutput, emptyListRowsInput, emptyListRowsOutput, getRowDefault, getRowDefaultGetRow, getRowDefect, getRowFound, getRowInvalidResponse, getRowNotFound, getRowProviderRejected, getRowRetry, listRowsDefault, listRowsDefaultListRows, listRowsDefect, listRowsInvalidResponse, listRowsListed, listRowsProviderRejected, listRowsRetry };
|
|
159
|
+
export { GeneratedMock, emptyColumn, emptyColumnsPage, emptyDoc, emptyDocsPage, emptyGetDocInput, emptyGetRowInput, emptyGetRowOutput, emptyGetTableInput, emptyListColumnsInput, emptyListDocsInput, emptyListRowsInput, emptyListRowsOutput, emptyListTablesInput, emptyTable, emptyTablesPage, getDocDefault, getDocDefect, getDocFound, getDocFoundDefault, getDocInvalidResponse, getDocNotFound, getDocProviderRejected, getDocRetry, getRowDefault, getRowDefaultGetRow, getRowDefect, getRowFound, getRowInvalidResponse, getRowNotFound, getRowProviderRejected, getRowRetry, getTableDefault, getTableDefect, getTableFound, getTableFoundDefault, getTableInvalidResponse, getTableNotFound, getTableProviderRejected, getTableRetry, listColumnsDefault, listColumnsDefect, listColumnsInvalidResponse, listColumnsListed, listColumnsListedDefault, listColumnsNotFound, listColumnsProviderRejected, listColumnsRetry, listDocsDefault, listDocsDefect, listDocsInvalidResponse, listDocsListed, listDocsListedDefault, listDocsProviderRejected, listDocsRetry, listRowsDefault, listRowsDefaultListRows, listRowsDefect, listRowsInvalidResponse, listRowsListed, listRowsProviderRejected, listRowsRetry, listTablesDefault, listTablesDefect, listTablesInvalidResponse, listTablesListed, listTablesListedDefault, listTablesNotFound, listTablesProviderRejected, listTablesRetry };
|