@query-farm/vgi 0.42.0 → 0.43.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/generated/vgi-service.d.ts +1315 -0
- package/dist/index.js +1845 -813
- package/dist/index.js.map +16 -16
- package/dist/protocol/dispatch.d.ts +14 -5
- package/dist/protocol/handlers/aggregate.d.ts +3 -2
- package/dist/protocol/handlers/catalog/admin.d.ts +2 -2
- package/dist/protocol/handlers/catalog/index.d.ts +3 -2
- package/dist/protocol/handlers/catalog/index_methods.d.ts +2 -2
- package/dist/protocol/handlers/catalog/macro.d.ts +2 -2
- package/dist/protocol/handlers/catalog/shared.d.ts +7 -14
- package/dist/protocol/handlers/catalog/table.d.ts +2 -2
- package/dist/protocol/handlers/catalog/view.d.ts +2 -2
- package/dist/protocol/handlers/function.d.ts +3 -2
- package/dist/protocol/handlers/shared.d.ts +0 -1
- package/dist/protocol/handlers/table-buffering.d.ts +3 -2
- package/dist/protocol/handlers/unimplemented.d.ts +4 -17
- package/dist/serve-entry.js +1844 -813
- package/dist/serve-entry.js.map +16 -16
- package/dist/worker-cf-entry.js +1845 -813
- package/dist/worker-cf-entry.js.map +16 -16
- package/package.json +1 -1
- package/src/generated/vgi-service.ts +2678 -0
- package/src/protocol/dispatch.ts +40 -29
- package/src/protocol/handlers/aggregate.ts +205 -232
- package/src/protocol/handlers/catalog/admin.ts +228 -299
- package/src/protocol/handlers/catalog/index.ts +17 -16
- package/src/protocol/handlers/catalog/index_methods.ts +26 -36
- package/src/protocol/handlers/catalog/macro.ts +54 -77
- package/src/protocol/handlers/catalog/shared.ts +30 -47
- package/src/protocol/handlers/catalog/table.ts +205 -270
- package/src/protocol/handlers/catalog/view.ts +59 -85
- package/src/protocol/handlers/function.ts +127 -156
- package/src/protocol/handlers/shared.ts +0 -4
- package/src/protocol/handlers/table-buffering.ts +53 -71
- package/src/protocol/handlers/unimplemented.ts +18 -62
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Catalog admin handlers: attach/detach/create/drop, version, transactions,
|
|
3
3
|
// schemas (list, get, create, drop), schema contents listings.
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { schema } from "../../../arrow/index.js";
|
|
6
|
+
import type { CallContext } from "@query-farm/vgi-rpc";
|
|
7
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
7
8
|
import {
|
|
8
9
|
encodeSchemaInfo,
|
|
9
10
|
encodeTableInfo,
|
|
@@ -15,33 +16,15 @@ import { serveCatalogContents } from "./contents.js";
|
|
|
15
16
|
import { encodeFunctionInfoOnce } from "../../../catalog/item-encoding.js";
|
|
16
17
|
import { encodeCopyFromFormatInfo } from "../../../catalog/interface.js";
|
|
17
18
|
import {
|
|
18
|
-
CatalogAttachParamsSchema,
|
|
19
19
|
CatalogAttachResultSchema,
|
|
20
|
-
CatalogContentsParamsSchema,
|
|
21
|
-
CatalogCatalogsParamsSchema,
|
|
22
20
|
CatalogCatalogsResultSchema,
|
|
23
|
-
CatalogCopyFromFormatsParamsSchema,
|
|
24
21
|
CatalogCopyFromFormatsResultSchema,
|
|
25
|
-
CatalogCreateParamsSchema,
|
|
26
|
-
CatalogDetachParamsSchema,
|
|
27
|
-
CatalogDropParamsSchema,
|
|
28
|
-
CatalogSchemaContentsFunctionsParamsSchema,
|
|
29
22
|
CatalogSchemaContentsFunctionsResultSchema,
|
|
30
|
-
CatalogSchemaContentsTablesParamsSchema,
|
|
31
23
|
CatalogSchemaContentsTablesResultSchema,
|
|
32
|
-
CatalogSchemaContentsViewsParamsSchema,
|
|
33
24
|
CatalogSchemaContentsViewsResultSchema,
|
|
34
|
-
CatalogSchemaCreateParamsSchema,
|
|
35
|
-
CatalogSchemaDropParamsSchema,
|
|
36
|
-
CatalogSchemaGetParamsSchema,
|
|
37
25
|
CatalogSchemaGetResultSchema,
|
|
38
|
-
CatalogSchemasParamsSchema,
|
|
39
26
|
CatalogSchemasResultSchema,
|
|
40
|
-
CatalogTransactionBeginParamsSchema,
|
|
41
27
|
CatalogTransactionBeginResultSchema,
|
|
42
|
-
CatalogTransactionCommitParamsSchema,
|
|
43
|
-
CatalogTransactionRollbackParamsSchema,
|
|
44
|
-
CatalogVersionParamsSchema,
|
|
45
28
|
CatalogVersionResultSchema,
|
|
46
29
|
} from "../../../generated/vgi-protocol-schemas.js";
|
|
47
30
|
import { toUint8Array } from "../../../util/bytes.js";
|
|
@@ -49,216 +32,173 @@ import { redeemAttachTicket } from "../../../attach-ticket.js";
|
|
|
49
32
|
import { currentRequestAuth } from "../../../request-auth.js";
|
|
50
33
|
import { decodeDictValue } from "../../../util/arrow/index.js";
|
|
51
34
|
import {
|
|
52
|
-
REQUEST_PARAMS_SCHEMA,
|
|
53
|
-
RESULT_BINARY_SCHEMA,
|
|
54
35
|
unwrapRequest,
|
|
55
36
|
wrapResult,
|
|
56
37
|
} from "../shared.js";
|
|
57
38
|
import {
|
|
58
39
|
type GetCatalog,
|
|
59
40
|
decodeOptionsBatch,
|
|
60
|
-
|
|
61
|
-
catalogUnary,
|
|
41
|
+
catalogHandler,
|
|
62
42
|
sealAttach,
|
|
63
43
|
openAttach,
|
|
64
44
|
sealTransaction,
|
|
65
45
|
} from "./shared.js";
|
|
66
46
|
|
|
67
|
-
export function
|
|
47
|
+
export function catalogAdminHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService> {
|
|
68
48
|
// catalog_catalogs
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}));
|
|
87
|
-
const items = infos.map((info) => encodeCatalogInfo(info));
|
|
88
|
-
return wrapResult({ items }, CatalogCatalogsResultSchema);
|
|
89
|
-
},
|
|
49
|
+
const catalogCatalogs = catalogHandler(signingKey, async () => {
|
|
50
|
+
const cat = getCatalog();
|
|
51
|
+
// Each catalog advertised as an IPC-serialized CatalogInfo
|
|
52
|
+
// {name, implementation_version?, data_version_spec?}. Versioned workers
|
|
53
|
+
// override catalogsInfo() to supply real values; otherwise both version
|
|
54
|
+
// fields default to null.
|
|
55
|
+
const infos = cat.catalogsInfo
|
|
56
|
+
? await cat.catalogsInfo()
|
|
57
|
+
: cat.catalogs().map((name) => ({
|
|
58
|
+
name,
|
|
59
|
+
implementation_version: null,
|
|
60
|
+
data_version_spec: null,
|
|
61
|
+
attach_option_specs: [],
|
|
62
|
+
releases: [],
|
|
63
|
+
}));
|
|
64
|
+
const items = infos.map((info) => encodeCatalogInfo(info));
|
|
65
|
+
return wrapResult({ items }, CatalogCatalogsResultSchema);
|
|
90
66
|
});
|
|
91
67
|
|
|
92
68
|
// catalog_attach (params wrapped in request: Binary like bind/init)
|
|
93
|
-
|
|
94
|
-
params
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
supports_column_statistics: result.supports_column_statistics ?? true,
|
|
148
|
-
}), CatalogAttachResultSchema);
|
|
149
|
-
},
|
|
150
|
-
});
|
|
69
|
+
const catalogAttach: VgiService["catalogAttach"] = async (params, ctx) => {
|
|
70
|
+
const innerParams = unwrapRequest(params.request);
|
|
71
|
+
const cat = getCatalog();
|
|
72
|
+
// The extension sends user-supplied ATTACH options as an IPC-serialized
|
|
73
|
+
// RecordBatch of typed columns — one column per option. Deserialize
|
|
74
|
+
// once here so workers see an ergonomic {name: value} dict instead of
|
|
75
|
+
// raw bytes. Nullable / absent → {}.
|
|
76
|
+
let optionsDict = decodeOptionsBatch(innerParams.options);
|
|
77
|
+
// A `vgi_attach_ticket` is redeemed here, before any catalog code runs:
|
|
78
|
+
// the request becomes the attach the ticket seals (catalog name,
|
|
79
|
+
// options, version specs). A composite catalog therefore routes on the
|
|
80
|
+
// sealed name, not the request's. The ticket opens only under the
|
|
81
|
+
// caller's principal and this worker's signing key; neither it nor a
|
|
82
|
+
// restored option is ever logged.
|
|
83
|
+
const restored = await redeemAttachTicket(
|
|
84
|
+
optionsDict,
|
|
85
|
+
signingKey,
|
|
86
|
+
(ctx as CallContext | undefined)?.auth ?? currentRequestAuth(),
|
|
87
|
+
);
|
|
88
|
+
if (restored !== null) {
|
|
89
|
+
innerParams.name = restored.name;
|
|
90
|
+
innerParams.options = restored.optionsIpc;
|
|
91
|
+
innerParams.data_version_spec = restored.dataVersionSpec;
|
|
92
|
+
innerParams.implementation_version = restored.implementationVersion;
|
|
93
|
+
optionsDict = restored.options;
|
|
94
|
+
}
|
|
95
|
+
const result = await cat.attach(
|
|
96
|
+
innerParams.name,
|
|
97
|
+
optionsDict,
|
|
98
|
+
innerParams.data_version_spec ?? null,
|
|
99
|
+
innerParams.implementation_version ?? null,
|
|
100
|
+
);
|
|
101
|
+
// Seal the attach value into an AEAD envelope bound to the caller's
|
|
102
|
+
// identity before it leaves the worker (HTTP transport; pass-through
|
|
103
|
+
// when there is no signing key).
|
|
104
|
+
const sealedAttach = await sealAttach(
|
|
105
|
+
toUint8Array(result.attach_opaque_data),
|
|
106
|
+
(ctx as CallContext | undefined)?.auth,
|
|
107
|
+
signingKey,
|
|
108
|
+
);
|
|
109
|
+
// The generated builder emits every column of the pinned
|
|
110
|
+
// CatalogAttachResult schema, filling vgi-python's defaults for any a
|
|
111
|
+
// catalog left out (supports_catalog_contents=false: the client then
|
|
112
|
+
// keeps to the per-schema RPCs).
|
|
113
|
+
return wrapResult(buildCatalogAttachResult({
|
|
114
|
+
...result,
|
|
115
|
+
attach_opaque_data: sealedAttach,
|
|
116
|
+
// SDK default, unlike vgi-python's false: true so DuckDB will route
|
|
117
|
+
// catalog_table_column_statistics_get RPCs to our handler for tables
|
|
118
|
+
// whose TableInfo.supports_column_statistics is also true. Catalogs
|
|
119
|
+
// that never serve column stats set it false in attach().
|
|
120
|
+
supports_column_statistics: result.supports_column_statistics ?? true,
|
|
121
|
+
}), CatalogAttachResultSchema);
|
|
122
|
+
};
|
|
151
123
|
|
|
152
124
|
// catalog_detach
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const cat = getCatalog();
|
|
158
|
-
await cat.detach(toUint8Array(params.attach_opaque_data));
|
|
159
|
-
return {};
|
|
160
|
-
},
|
|
125
|
+
const catalogDetach = catalogHandler(signingKey, async (params) => {
|
|
126
|
+
const cat = getCatalog();
|
|
127
|
+
await cat.detach(toUint8Array(params.attach_opaque_data));
|
|
128
|
+
return {};
|
|
161
129
|
});
|
|
162
130
|
|
|
163
131
|
// catalog_create
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const cat = getCatalog();
|
|
169
|
-
await cat.create(params.name, params.on_conflict, params.options);
|
|
170
|
-
return {};
|
|
171
|
-
},
|
|
132
|
+
const catalogCreate = catalogHandler(signingKey, async (params) => {
|
|
133
|
+
const cat = getCatalog();
|
|
134
|
+
await cat.create(params.name, params.on_conflict, params.options);
|
|
135
|
+
return {};
|
|
172
136
|
});
|
|
173
137
|
|
|
174
138
|
// catalog_drop
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const cat = getCatalog();
|
|
180
|
-
await cat.drop(params.name);
|
|
181
|
-
return {};
|
|
182
|
-
},
|
|
139
|
+
const catalogDrop = catalogHandler(signingKey, async (params) => {
|
|
140
|
+
const cat = getCatalog();
|
|
141
|
+
await cat.drop(params.name);
|
|
142
|
+
return {};
|
|
183
143
|
});
|
|
184
144
|
|
|
185
145
|
// catalog_version
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
194
|
-
);
|
|
195
|
-
return wrapResult({ version }, CatalogVersionResultSchema);
|
|
196
|
-
},
|
|
146
|
+
const catalogVersion = catalogHandler(signingKey, async (params) => {
|
|
147
|
+
const cat = getCatalog();
|
|
148
|
+
const version = await cat.version(
|
|
149
|
+
toUint8Array(params.attach_opaque_data),
|
|
150
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
151
|
+
);
|
|
152
|
+
return wrapResult({ version }, CatalogVersionResultSchema);
|
|
197
153
|
});
|
|
198
154
|
|
|
199
155
|
// catalog_transaction_begin — bespoke: it must keep the *sealed* attach
|
|
200
156
|
// envelope to bind the transaction envelope's AAD, so it cannot route
|
|
201
|
-
// through
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
txPlain != null ? await sealTransaction(toUint8Array(txPlain), sealedAttach, auth, signingKey) : null;
|
|
216
|
-
return wrapResult({ transaction_opaque_data }, CatalogTransactionBeginResultSchema);
|
|
217
|
-
},
|
|
218
|
-
});
|
|
157
|
+
// through catalogHandler (which would replace it with plaintext).
|
|
158
|
+
const catalogTransactionBegin: VgiService["catalogTransactionBegin"] = async (params, ctx) => {
|
|
159
|
+
const auth = (ctx as CallContext | undefined)?.auth;
|
|
160
|
+
const sealedAttach =
|
|
161
|
+
params.attach_opaque_data != null ? toUint8Array(params.attach_opaque_data) : new Uint8Array(0);
|
|
162
|
+
const attachPlain = await openAttach(sealedAttach, auth, signingKey);
|
|
163
|
+
const cat = getCatalog();
|
|
164
|
+
const txPlain = await cat.transactionBegin(attachPlain);
|
|
165
|
+
// Seal the transaction value, binding it to the caller's identity and
|
|
166
|
+
// the parent attach envelope it was minted under. null → null.
|
|
167
|
+
const transaction_opaque_data =
|
|
168
|
+
txPlain != null ? await sealTransaction(toUint8Array(txPlain), sealedAttach, auth, signingKey) : null;
|
|
169
|
+
return wrapResult({ transaction_opaque_data }, CatalogTransactionBeginResultSchema);
|
|
170
|
+
};
|
|
219
171
|
|
|
220
172
|
// catalog_transaction_commit
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
toUint8Array(params.transaction_opaque_data)
|
|
229
|
-
);
|
|
230
|
-
return {};
|
|
231
|
-
},
|
|
173
|
+
const catalogTransactionCommit = catalogHandler(signingKey, async (params) => {
|
|
174
|
+
const cat = getCatalog();
|
|
175
|
+
await cat.transactionCommit(
|
|
176
|
+
toUint8Array(params.attach_opaque_data),
|
|
177
|
+
toUint8Array(params.transaction_opaque_data)
|
|
178
|
+
);
|
|
179
|
+
return {};
|
|
232
180
|
});
|
|
233
181
|
|
|
234
182
|
// catalog_transaction_rollback
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
toUint8Array(params.transaction_opaque_data)
|
|
243
|
-
);
|
|
244
|
-
return {};
|
|
245
|
-
},
|
|
183
|
+
const catalogTransactionRollback = catalogHandler(signingKey, async (params) => {
|
|
184
|
+
const cat = getCatalog();
|
|
185
|
+
await cat.transactionRollback(
|
|
186
|
+
toUint8Array(params.attach_opaque_data),
|
|
187
|
+
toUint8Array(params.transaction_opaque_data)
|
|
188
|
+
);
|
|
189
|
+
return {};
|
|
246
190
|
});
|
|
247
191
|
|
|
248
192
|
// catalog_schemas
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return wrapResult({
|
|
259
|
-
items: schemas.map((s) => encodeSchemaInfo(s)),
|
|
260
|
-
}, CatalogSchemasResultSchema);
|
|
261
|
-
},
|
|
193
|
+
const catalogSchemas = catalogHandler(signingKey, async (params) => {
|
|
194
|
+
const cat = getCatalog();
|
|
195
|
+
const schemas = await cat.schemas(
|
|
196
|
+
toUint8Array(params.attach_opaque_data),
|
|
197
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
198
|
+
);
|
|
199
|
+
return wrapResult({
|
|
200
|
+
items: schemas.map((s) => encodeSchemaInfo(s)),
|
|
201
|
+
}, CatalogSchemasResultSchema);
|
|
262
202
|
});
|
|
263
203
|
|
|
264
204
|
// catalog_contents — every schema and all of its contents in one result,
|
|
@@ -267,134 +207,123 @@ export function registerCatalogAdminMethods(protocol: Protocol, getCatalog: GetC
|
|
|
267
207
|
// the committed catalog at catalog_version. `if_none_match` revalidates a
|
|
268
208
|
// snapshot the client holds (etag / not_modified); see ./contents.ts for the
|
|
269
209
|
// rules, the content-hash etag and the frozen-catalog cache.
|
|
270
|
-
|
|
271
|
-
params:
|
|
272
|
-
|
|
273
|
-
handler: async (params) => {
|
|
274
|
-
const ifNoneMatch = params.if_none_match == null ? null : String(params.if_none_match);
|
|
275
|
-
return serveCatalogContents(getCatalog(), toUint8Array(params.attach_opaque_data), ifNoneMatch);
|
|
276
|
-
},
|
|
210
|
+
const catalogContents = catalogHandler(signingKey, async (params) => {
|
|
211
|
+
const ifNoneMatch = params.if_none_match == null ? null : String(params.if_none_match);
|
|
212
|
+
return serveCatalogContents(getCatalog(), toUint8Array(params.attach_opaque_data), ifNoneMatch);
|
|
277
213
|
});
|
|
278
214
|
|
|
279
215
|
// catalog_copy_from_formats — catalog-level (not schema-scoped). Lists the
|
|
280
216
|
// custom COPY ... FROM formats this catalog advertises; empty list when none.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
return wrapResult({
|
|
291
|
-
items: formats.map((f) => encodeCopyFromFormatInfo(f)),
|
|
292
|
-
}, CatalogCopyFromFormatsResultSchema);
|
|
293
|
-
},
|
|
217
|
+
const catalogCopyFromFormats = catalogHandler(signingKey, async (params) => {
|
|
218
|
+
const cat = getCatalog();
|
|
219
|
+
const formats = await cat.copyFromFormats(
|
|
220
|
+
toUint8Array(params.attach_opaque_data),
|
|
221
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined,
|
|
222
|
+
);
|
|
223
|
+
return wrapResult({
|
|
224
|
+
items: formats.map((f) => encodeCopyFromFormatInfo(f)),
|
|
225
|
+
}, CatalogCopyFromFormatsResultSchema);
|
|
294
226
|
});
|
|
295
227
|
|
|
296
228
|
// catalog_schema_get
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return wrapResult({
|
|
308
|
-
items: info ? [encodeSchemaInfo(info)] : [],
|
|
309
|
-
}, CatalogSchemaGetResultSchema);
|
|
310
|
-
},
|
|
229
|
+
const catalogSchemaGet = catalogHandler(signingKey, async (params) => {
|
|
230
|
+
const cat = getCatalog();
|
|
231
|
+
const info = await cat.schemaGet(
|
|
232
|
+
toUint8Array(params.attach_opaque_data),
|
|
233
|
+
params.path,
|
|
234
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
235
|
+
);
|
|
236
|
+
return wrapResult({
|
|
237
|
+
items: info ? [encodeSchemaInfo(info)] : [],
|
|
238
|
+
}, CatalogSchemaGetResultSchema);
|
|
311
239
|
});
|
|
312
240
|
|
|
313
241
|
// catalog_schema_create
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
325
|
-
);
|
|
326
|
-
return {};
|
|
327
|
-
},
|
|
242
|
+
const catalogSchemaCreate = catalogHandler(signingKey, async (params) => {
|
|
243
|
+
const cat = getCatalog();
|
|
244
|
+
await cat.schemaCreate(
|
|
245
|
+
toUint8Array(params.attach_opaque_data),
|
|
246
|
+
params.path,
|
|
247
|
+
params.comment,
|
|
248
|
+
null, // tags
|
|
249
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
250
|
+
);
|
|
251
|
+
return {};
|
|
328
252
|
});
|
|
329
253
|
|
|
330
254
|
// catalog_schema_drop
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
342
|
-
);
|
|
343
|
-
return {};
|
|
344
|
-
},
|
|
255
|
+
const catalogSchemaDrop = catalogHandler(signingKey, async (params) => {
|
|
256
|
+
const cat = getCatalog();
|
|
257
|
+
await cat.schemaDrop(
|
|
258
|
+
toUint8Array(params.attach_opaque_data),
|
|
259
|
+
params.path,
|
|
260
|
+
params.ignore_not_found,
|
|
261
|
+
params.cascade,
|
|
262
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
263
|
+
);
|
|
264
|
+
return {};
|
|
345
265
|
});
|
|
346
266
|
|
|
347
267
|
// catalog_schema_contents_tables
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return wrapResult({
|
|
359
|
-
items: tables.map((t) => encodeTableInfo(t)),
|
|
360
|
-
}, CatalogSchemaContentsTablesResultSchema);
|
|
361
|
-
},
|
|
268
|
+
const catalogSchemaContentsTables = catalogHandler(signingKey, async (params) => {
|
|
269
|
+
const cat = getCatalog();
|
|
270
|
+
const tables = await cat.schemaContentsTables(
|
|
271
|
+
toUint8Array(params.attach_opaque_data),
|
|
272
|
+
params.path,
|
|
273
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
274
|
+
);
|
|
275
|
+
return wrapResult({
|
|
276
|
+
items: tables.map((t) => encodeTableInfo(t)),
|
|
277
|
+
}, CatalogSchemaContentsTablesResultSchema);
|
|
362
278
|
});
|
|
363
279
|
|
|
364
280
|
// catalog_schema_contents_views
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return wrapResult({
|
|
376
|
-
items: views.map((v) => encodeViewInfo(v)),
|
|
377
|
-
}, CatalogSchemaContentsViewsResultSchema);
|
|
378
|
-
},
|
|
281
|
+
const catalogSchemaContentsViews = catalogHandler(signingKey, async (params) => {
|
|
282
|
+
const cat = getCatalog();
|
|
283
|
+
const views = await cat.schemaContentsViews(
|
|
284
|
+
toUint8Array(params.attach_opaque_data),
|
|
285
|
+
params.path,
|
|
286
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
287
|
+
);
|
|
288
|
+
return wrapResult({
|
|
289
|
+
items: views.map((v) => encodeViewInfo(v)),
|
|
290
|
+
}, CatalogSchemaContentsViewsResultSchema);
|
|
379
291
|
});
|
|
380
292
|
|
|
381
293
|
// catalog_schema_contents_functions
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return wrapResult({
|
|
396
|
-
items: funcs.map((f) => encodeFunctionInfoOnce(f)),
|
|
397
|
-
}, CatalogSchemaContentsFunctionsResultSchema);
|
|
398
|
-
},
|
|
294
|
+
const catalogSchemaContentsFunctions = catalogHandler(signingKey, async (params) => {
|
|
295
|
+
const cat = getCatalog();
|
|
296
|
+
const funcs = await cat.schemaContentsFunctions(
|
|
297
|
+
toUint8Array(params.attach_opaque_data),
|
|
298
|
+
params.path,
|
|
299
|
+
decodeDictValue(params.type),
|
|
300
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
301
|
+
);
|
|
302
|
+
// A frozen item (a descriptor catalog's cached listing) is encoded once;
|
|
303
|
+
// anything else is encoded per call, as before (see item-encoding.ts).
|
|
304
|
+
return wrapResult({
|
|
305
|
+
items: funcs.map((f) => encodeFunctionInfoOnce(f)),
|
|
306
|
+
}, CatalogSchemaContentsFunctionsResultSchema);
|
|
399
307
|
});
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
catalogCatalogs,
|
|
311
|
+
catalogAttach,
|
|
312
|
+
catalogDetach,
|
|
313
|
+
catalogCreate,
|
|
314
|
+
catalogDrop,
|
|
315
|
+
catalogVersion,
|
|
316
|
+
catalogTransactionBegin,
|
|
317
|
+
catalogTransactionCommit,
|
|
318
|
+
catalogTransactionRollback,
|
|
319
|
+
catalogSchemas,
|
|
320
|
+
catalogContents,
|
|
321
|
+
catalogCopyFromFormats,
|
|
322
|
+
catalogSchemaGet,
|
|
323
|
+
catalogSchemaCreate,
|
|
324
|
+
catalogSchemaDrop,
|
|
325
|
+
catalogSchemaContentsTables,
|
|
326
|
+
catalogSchemaContentsViews,
|
|
327
|
+
catalogSchemaContentsFunctions,
|
|
328
|
+
};
|
|
400
329
|
}
|