@xata.io/client 0.0.0-alpha.vf4b92f1 → 0.0.0-alpha.vf5a6674
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/.eslintrc.cjs +1 -2
- package/CHANGELOG.md +288 -0
- package/README.md +273 -1
- package/Usage.md +451 -0
- package/dist/index.cjs +1744 -658
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4062 -753
- package/dist/index.mjs +1684 -663
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
- package/tsconfig.json +1 -0
package/dist/index.cjs
CHANGED
@@ -2,6 +2,46 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
+
function _interopNamespace(e) {
|
6
|
+
if (e && e.__esModule) return e;
|
7
|
+
var n = Object.create(null);
|
8
|
+
if (e) {
|
9
|
+
Object.keys(e).forEach(function (k) {
|
10
|
+
if (k !== 'default') {
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
13
|
+
enumerable: true,
|
14
|
+
get: function () { return e[k]; }
|
15
|
+
});
|
16
|
+
}
|
17
|
+
});
|
18
|
+
}
|
19
|
+
n["default"] = e;
|
20
|
+
return Object.freeze(n);
|
21
|
+
}
|
22
|
+
|
23
|
+
const defaultTrace = async (_name, fn, _options) => {
|
24
|
+
return await fn({
|
25
|
+
setAttributes: () => {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
});
|
29
|
+
};
|
30
|
+
const TraceAttributes = {
|
31
|
+
KIND: "xata.trace.kind",
|
32
|
+
VERSION: "xata.sdk.version",
|
33
|
+
TABLE: "xata.table",
|
34
|
+
HTTP_REQUEST_ID: "http.request_id",
|
35
|
+
HTTP_STATUS_CODE: "http.status_code",
|
36
|
+
HTTP_HOST: "http.host",
|
37
|
+
HTTP_SCHEME: "http.scheme",
|
38
|
+
HTTP_USER_AGENT: "http.user_agent",
|
39
|
+
HTTP_METHOD: "http.method",
|
40
|
+
HTTP_URL: "http.url",
|
41
|
+
HTTP_ROUTE: "http.route",
|
42
|
+
HTTP_TARGET: "http.target"
|
43
|
+
};
|
44
|
+
|
5
45
|
function notEmpty(value) {
|
6
46
|
return value !== null && value !== void 0;
|
7
47
|
}
|
@@ -11,43 +51,101 @@ function compact(arr) {
|
|
11
51
|
function isObject(value) {
|
12
52
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
13
53
|
}
|
54
|
+
function isDefined(value) {
|
55
|
+
return value !== null && value !== void 0;
|
56
|
+
}
|
14
57
|
function isString(value) {
|
15
|
-
return value
|
58
|
+
return isDefined(value) && typeof value === "string";
|
59
|
+
}
|
60
|
+
function isStringArray(value) {
|
61
|
+
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
16
62
|
}
|
17
63
|
function toBase64(value) {
|
18
64
|
try {
|
19
65
|
return btoa(value);
|
20
66
|
} catch (err) {
|
21
|
-
|
67
|
+
const buf = Buffer;
|
68
|
+
return buf.from(value).toString("base64");
|
22
69
|
}
|
23
70
|
}
|
24
71
|
|
25
|
-
function
|
72
|
+
function getEnvironment() {
|
26
73
|
try {
|
27
|
-
if (isObject(process) &&
|
28
|
-
return
|
74
|
+
if (isObject(process) && isObject(process.env)) {
|
75
|
+
return {
|
76
|
+
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
77
|
+
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
78
|
+
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
79
|
+
envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
|
80
|
+
fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
|
81
|
+
};
|
29
82
|
}
|
30
83
|
} catch (err) {
|
31
84
|
}
|
32
85
|
try {
|
33
|
-
if (isObject(Deno) &&
|
34
|
-
return
|
86
|
+
if (isObject(Deno) && isObject(Deno.env)) {
|
87
|
+
return {
|
88
|
+
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
89
|
+
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
90
|
+
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
91
|
+
envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
|
92
|
+
fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
|
93
|
+
};
|
35
94
|
}
|
36
95
|
} catch (err) {
|
37
96
|
}
|
97
|
+
return {
|
98
|
+
apiKey: getGlobalApiKey(),
|
99
|
+
databaseURL: getGlobalDatabaseURL(),
|
100
|
+
branch: getGlobalBranch(),
|
101
|
+
envBranch: void 0,
|
102
|
+
fallbackBranch: getGlobalFallbackBranch()
|
103
|
+
};
|
104
|
+
}
|
105
|
+
function getGlobalApiKey() {
|
106
|
+
try {
|
107
|
+
return XATA_API_KEY;
|
108
|
+
} catch (err) {
|
109
|
+
return void 0;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
function getGlobalDatabaseURL() {
|
113
|
+
try {
|
114
|
+
return XATA_DATABASE_URL;
|
115
|
+
} catch (err) {
|
116
|
+
return void 0;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
function getGlobalBranch() {
|
120
|
+
try {
|
121
|
+
return XATA_BRANCH;
|
122
|
+
} catch (err) {
|
123
|
+
return void 0;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
function getGlobalFallbackBranch() {
|
127
|
+
try {
|
128
|
+
return XATA_FALLBACK_BRANCH;
|
129
|
+
} catch (err) {
|
130
|
+
return void 0;
|
131
|
+
}
|
38
132
|
}
|
39
133
|
async function getGitBranch() {
|
134
|
+
const cmd = ["git", "branch", "--show-current"];
|
135
|
+
const fullCmd = cmd.join(" ");
|
136
|
+
const nodeModule = ["child", "process"].join("_");
|
137
|
+
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
40
138
|
try {
|
41
|
-
|
139
|
+
if (typeof require === "function") {
|
140
|
+
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
141
|
+
}
|
142
|
+
const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
|
143
|
+
return execSync(fullCmd, execOptions).toString().trim();
|
42
144
|
} catch (err) {
|
43
145
|
}
|
44
146
|
try {
|
45
147
|
if (isObject(Deno)) {
|
46
|
-
const process2 = Deno.run({
|
47
|
-
cmd: ["git", "branch", "--show-current"],
|
48
|
-
stdout: "piped",
|
49
|
-
stderr: "piped"
|
50
|
-
});
|
148
|
+
const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
51
149
|
return new TextDecoder().decode(await process2.output()).trim();
|
52
150
|
}
|
53
151
|
} catch (err) {
|
@@ -56,7 +154,8 @@ async function getGitBranch() {
|
|
56
154
|
|
57
155
|
function getAPIKey() {
|
58
156
|
try {
|
59
|
-
|
157
|
+
const { apiKey } = getEnvironment();
|
158
|
+
return apiKey;
|
60
159
|
} catch (err) {
|
61
160
|
return void 0;
|
62
161
|
}
|
@@ -66,21 +165,35 @@ function getFetchImplementation(userFetch) {
|
|
66
165
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
67
166
|
const fetchImpl = userFetch ?? globalFetch;
|
68
167
|
if (!fetchImpl) {
|
69
|
-
throw new Error(
|
168
|
+
throw new Error(
|
169
|
+
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
170
|
+
);
|
70
171
|
}
|
71
172
|
return fetchImpl;
|
72
173
|
}
|
73
174
|
|
74
|
-
|
75
|
-
|
175
|
+
const VERSION = "0.0.0-alpha.vf5a6674";
|
176
|
+
|
177
|
+
class ErrorWithCause extends Error {
|
178
|
+
constructor(message, options) {
|
179
|
+
super(message, options);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
class FetcherError extends ErrorWithCause {
|
183
|
+
constructor(status, data, requestId) {
|
76
184
|
super(getMessage(data));
|
77
185
|
this.status = status;
|
78
186
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
187
|
+
this.requestId = requestId;
|
79
188
|
if (data instanceof Error) {
|
80
189
|
this.stack = data.stack;
|
81
190
|
this.cause = data.cause;
|
82
191
|
}
|
83
192
|
}
|
193
|
+
toString() {
|
194
|
+
const error = super.toString();
|
195
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
196
|
+
}
|
84
197
|
}
|
85
198
|
function isBulkError(error) {
|
86
199
|
return isObject(error) && Array.isArray(error.errors);
|
@@ -103,9 +216,17 @@ function getMessage(data) {
|
|
103
216
|
}
|
104
217
|
|
105
218
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
106
|
-
const
|
219
|
+
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
220
|
+
if (value === void 0 || value === null)
|
221
|
+
return acc;
|
222
|
+
return { ...acc, [key]: value };
|
223
|
+
}, {});
|
224
|
+
const query = new URLSearchParams(cleanQueryParams).toString();
|
107
225
|
const queryString = query.length > 0 ? `?${query}` : "";
|
108
|
-
|
226
|
+
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
227
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
228
|
+
}, {});
|
229
|
+
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
109
230
|
};
|
110
231
|
function buildBaseUrl({
|
111
232
|
path,
|
@@ -113,10 +234,10 @@ function buildBaseUrl({
|
|
113
234
|
apiUrl,
|
114
235
|
pathParams
|
115
236
|
}) {
|
116
|
-
if (
|
237
|
+
if (pathParams?.workspace === void 0 || !path.startsWith("/db"))
|
117
238
|
return `${apiUrl}${path}`;
|
118
239
|
const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
119
|
-
return url.replace("{workspaceId}", pathParams.workspace);
|
240
|
+
return url.replace("{workspaceId}", String(pathParams.workspace));
|
120
241
|
}
|
121
242
|
function hostHeader(url) {
|
122
243
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
@@ -133,254 +254,413 @@ async function fetch$1({
|
|
133
254
|
fetchImpl,
|
134
255
|
apiKey,
|
135
256
|
apiUrl,
|
136
|
-
workspacesApiUrl
|
257
|
+
workspacesApiUrl,
|
258
|
+
trace,
|
259
|
+
signal,
|
260
|
+
clientID,
|
261
|
+
sessionID
|
137
262
|
}) {
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
263
|
+
return trace(
|
264
|
+
`${method.toUpperCase()} ${path}`,
|
265
|
+
async ({ setAttributes }) => {
|
266
|
+
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
267
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
268
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
269
|
+
setAttributes({
|
270
|
+
[TraceAttributes.HTTP_URL]: url,
|
271
|
+
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
272
|
+
});
|
273
|
+
const response = await fetchImpl(url, {
|
274
|
+
method: method.toUpperCase(),
|
275
|
+
body: body ? JSON.stringify(body) : void 0,
|
276
|
+
headers: {
|
277
|
+
"Content-Type": "application/json",
|
278
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
279
|
+
"X-Xata-Client-ID": clientID ?? "",
|
280
|
+
"X-Xata-Session-ID": sessionID ?? "",
|
281
|
+
...headers,
|
282
|
+
...hostHeader(fullUrl),
|
283
|
+
Authorization: `Bearer ${apiKey}`
|
284
|
+
},
|
285
|
+
signal
|
286
|
+
});
|
287
|
+
if (response.status === 204) {
|
288
|
+
return {};
|
289
|
+
}
|
290
|
+
const { host, protocol } = parseUrl(response.url);
|
291
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
292
|
+
setAttributes({
|
293
|
+
[TraceAttributes.KIND]: "http",
|
294
|
+
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
295
|
+
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
296
|
+
[TraceAttributes.HTTP_HOST]: host,
|
297
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
298
|
+
});
|
299
|
+
try {
|
300
|
+
const jsonResponse = await response.json();
|
301
|
+
if (response.ok) {
|
302
|
+
return jsonResponse;
|
303
|
+
}
|
304
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
305
|
+
} catch (error) {
|
306
|
+
throw new FetcherError(response.status, error, requestId);
|
307
|
+
}
|
308
|
+
},
|
309
|
+
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
310
|
+
);
|
311
|
+
}
|
312
|
+
function parseUrl(url) {
|
154
313
|
try {
|
155
|
-
const
|
156
|
-
|
157
|
-
return jsonResponse;
|
158
|
-
}
|
159
|
-
throw new FetcherError(response.status, jsonResponse);
|
314
|
+
const { host, protocol } = new URL(url);
|
315
|
+
return { host, protocol };
|
160
316
|
} catch (error) {
|
161
|
-
|
317
|
+
return {};
|
162
318
|
}
|
163
319
|
}
|
164
320
|
|
165
|
-
const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
|
166
|
-
const updateUser = (variables) => fetch$1({
|
167
|
-
|
168
|
-
|
321
|
+
const getUser = (variables, signal) => fetch$1({ url: "/user", method: "get", ...variables, signal });
|
322
|
+
const updateUser = (variables, signal) => fetch$1({
|
323
|
+
url: "/user",
|
324
|
+
method: "put",
|
325
|
+
...variables,
|
326
|
+
signal
|
327
|
+
});
|
328
|
+
const deleteUser = (variables, signal) => fetch$1({ url: "/user", method: "delete", ...variables, signal });
|
329
|
+
const getUserAPIKeys = (variables, signal) => fetch$1({
|
169
330
|
url: "/user/keys",
|
170
331
|
method: "get",
|
171
|
-
...variables
|
332
|
+
...variables,
|
333
|
+
signal
|
172
334
|
});
|
173
|
-
const createUserAPIKey = (variables) => fetch$1({
|
335
|
+
const createUserAPIKey = (variables, signal) => fetch$1({
|
174
336
|
url: "/user/keys/{keyName}",
|
175
337
|
method: "post",
|
176
|
-
...variables
|
338
|
+
...variables,
|
339
|
+
signal
|
177
340
|
});
|
178
|
-
const deleteUserAPIKey = (variables) => fetch$1({
|
341
|
+
const deleteUserAPIKey = (variables, signal) => fetch$1({
|
179
342
|
url: "/user/keys/{keyName}",
|
180
343
|
method: "delete",
|
181
|
-
...variables
|
344
|
+
...variables,
|
345
|
+
signal
|
182
346
|
});
|
183
|
-
const
|
347
|
+
const getWorkspacesList = (variables, signal) => fetch$1({
|
184
348
|
url: "/workspaces",
|
185
|
-
method: "
|
186
|
-
...variables
|
349
|
+
method: "get",
|
350
|
+
...variables,
|
351
|
+
signal
|
187
352
|
});
|
188
|
-
const
|
353
|
+
const createWorkspace = (variables, signal) => fetch$1({
|
189
354
|
url: "/workspaces",
|
190
|
-
method: "
|
191
|
-
...variables
|
355
|
+
method: "post",
|
356
|
+
...variables,
|
357
|
+
signal
|
192
358
|
});
|
193
|
-
const getWorkspace = (variables) => fetch$1({
|
359
|
+
const getWorkspace = (variables, signal) => fetch$1({
|
194
360
|
url: "/workspaces/{workspaceId}",
|
195
361
|
method: "get",
|
196
|
-
...variables
|
362
|
+
...variables,
|
363
|
+
signal
|
197
364
|
});
|
198
|
-
const updateWorkspace = (variables) => fetch$1({
|
365
|
+
const updateWorkspace = (variables, signal) => fetch$1({
|
199
366
|
url: "/workspaces/{workspaceId}",
|
200
367
|
method: "put",
|
201
|
-
...variables
|
368
|
+
...variables,
|
369
|
+
signal
|
202
370
|
});
|
203
|
-
const deleteWorkspace = (variables) => fetch$1({
|
371
|
+
const deleteWorkspace = (variables, signal) => fetch$1({
|
204
372
|
url: "/workspaces/{workspaceId}",
|
205
373
|
method: "delete",
|
206
|
-
...variables
|
374
|
+
...variables,
|
375
|
+
signal
|
207
376
|
});
|
208
|
-
const getWorkspaceMembersList = (variables) => fetch$1({
|
377
|
+
const getWorkspaceMembersList = (variables, signal) => fetch$1({
|
209
378
|
url: "/workspaces/{workspaceId}/members",
|
210
379
|
method: "get",
|
211
|
-
...variables
|
380
|
+
...variables,
|
381
|
+
signal
|
212
382
|
});
|
213
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
214
|
-
const removeWorkspaceMember = (variables) => fetch$1({
|
383
|
+
const updateWorkspaceMemberRole = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
384
|
+
const removeWorkspaceMember = (variables, signal) => fetch$1({
|
215
385
|
url: "/workspaces/{workspaceId}/members/{userId}",
|
216
386
|
method: "delete",
|
217
|
-
...variables
|
387
|
+
...variables,
|
388
|
+
signal
|
218
389
|
});
|
219
|
-
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
220
|
-
const
|
390
|
+
const inviteWorkspaceMember = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
|
391
|
+
const updateWorkspaceMemberInvite = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
|
392
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
221
393
|
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
222
394
|
method: "delete",
|
223
|
-
...variables
|
395
|
+
...variables,
|
396
|
+
signal
|
224
397
|
});
|
225
|
-
const
|
226
|
-
url: "/workspaces/{workspaceId}/invites/{
|
398
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
399
|
+
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
227
400
|
method: "post",
|
228
|
-
...variables
|
401
|
+
...variables,
|
402
|
+
signal
|
229
403
|
});
|
230
|
-
const
|
231
|
-
url: "/workspaces/{workspaceId}/invites/{
|
404
|
+
const resendWorkspaceMemberInvite = (variables, signal) => fetch$1({
|
405
|
+
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
232
406
|
method: "post",
|
233
|
-
...variables
|
407
|
+
...variables,
|
408
|
+
signal
|
234
409
|
});
|
235
|
-
const getDatabaseList = (variables) => fetch$1({
|
410
|
+
const getDatabaseList = (variables, signal) => fetch$1({
|
236
411
|
url: "/dbs",
|
237
412
|
method: "get",
|
238
|
-
...variables
|
413
|
+
...variables,
|
414
|
+
signal
|
239
415
|
});
|
240
|
-
const getBranchList = (variables) => fetch$1({
|
416
|
+
const getBranchList = (variables, signal) => fetch$1({
|
241
417
|
url: "/dbs/{dbName}",
|
242
418
|
method: "get",
|
243
|
-
...variables
|
419
|
+
...variables,
|
420
|
+
signal
|
244
421
|
});
|
245
|
-
const createDatabase = (variables) => fetch$1({
|
422
|
+
const createDatabase = (variables, signal) => fetch$1({
|
246
423
|
url: "/dbs/{dbName}",
|
247
424
|
method: "put",
|
248
|
-
...variables
|
425
|
+
...variables,
|
426
|
+
signal
|
249
427
|
});
|
250
|
-
const deleteDatabase = (variables) => fetch$1({
|
428
|
+
const deleteDatabase = (variables, signal) => fetch$1({
|
251
429
|
url: "/dbs/{dbName}",
|
252
430
|
method: "delete",
|
253
|
-
...variables
|
431
|
+
...variables,
|
432
|
+
signal
|
254
433
|
});
|
255
|
-
const
|
256
|
-
url: "/
|
434
|
+
const getDatabaseMetadata = (variables, signal) => fetch$1({
|
435
|
+
url: "/dbs/{dbName}/metadata",
|
257
436
|
method: "get",
|
258
|
-
...variables
|
437
|
+
...variables,
|
438
|
+
signal
|
259
439
|
});
|
260
|
-
const
|
440
|
+
const updateDatabaseMetadata = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
441
|
+
const getBranchDetails = (variables, signal) => fetch$1({
|
261
442
|
url: "/db/{dbBranchName}",
|
262
|
-
method: "
|
263
|
-
...variables
|
443
|
+
method: "get",
|
444
|
+
...variables,
|
445
|
+
signal
|
264
446
|
});
|
265
|
-
const
|
447
|
+
const createBranch = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables, signal });
|
448
|
+
const deleteBranch = (variables, signal) => fetch$1({
|
266
449
|
url: "/db/{dbBranchName}",
|
267
450
|
method: "delete",
|
268
|
-
...variables
|
451
|
+
...variables,
|
452
|
+
signal
|
269
453
|
});
|
270
|
-
const updateBranchMetadata = (variables) => fetch$1({
|
454
|
+
const updateBranchMetadata = (variables, signal) => fetch$1({
|
271
455
|
url: "/db/{dbBranchName}/metadata",
|
272
456
|
method: "put",
|
273
|
-
...variables
|
457
|
+
...variables,
|
458
|
+
signal
|
274
459
|
});
|
275
|
-
const getBranchMetadata = (variables) => fetch$1({
|
460
|
+
const getBranchMetadata = (variables, signal) => fetch$1({
|
276
461
|
url: "/db/{dbBranchName}/metadata",
|
277
462
|
method: "get",
|
278
|
-
...variables
|
463
|
+
...variables,
|
464
|
+
signal
|
279
465
|
});
|
280
|
-
const
|
281
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
282
|
-
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
283
|
-
const getBranchStats = (variables) => fetch$1({
|
466
|
+
const getBranchStats = (variables, signal) => fetch$1({
|
284
467
|
url: "/db/{dbBranchName}/stats",
|
285
468
|
method: "get",
|
286
|
-
...variables
|
469
|
+
...variables,
|
470
|
+
signal
|
471
|
+
});
|
472
|
+
const getGitBranchesMapping = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
473
|
+
const addGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
474
|
+
const removeGitBranchesEntry = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
|
475
|
+
const resolveBranch = (variables, signal) => fetch$1({
|
476
|
+
url: "/dbs/{dbName}/resolveBranch",
|
477
|
+
method: "get",
|
478
|
+
...variables,
|
479
|
+
signal
|
480
|
+
});
|
481
|
+
const getBranchMigrationHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
482
|
+
const getBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
483
|
+
const executeBranchMigrationPlan = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
484
|
+
const queryMigrationRequests = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
485
|
+
const createMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
486
|
+
const getMigrationRequest = (variables, signal) => fetch$1({
|
487
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
488
|
+
method: "get",
|
489
|
+
...variables,
|
490
|
+
signal
|
287
491
|
});
|
288
|
-
const
|
492
|
+
const updateMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
|
493
|
+
const listMigrationRequestsCommits = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
|
494
|
+
const compareMigrationRequest = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
|
495
|
+
const getMigrationRequestIsMerged = (variables, signal) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
|
496
|
+
const mergeMigrationRequest = (variables, signal) => fetch$1({
|
497
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
498
|
+
method: "post",
|
499
|
+
...variables,
|
500
|
+
signal
|
501
|
+
});
|
502
|
+
const getBranchSchemaHistory = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
|
503
|
+
const compareBranchWithUserSchema = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
|
504
|
+
const compareBranchSchemas = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
|
505
|
+
const updateBranchSchema = (variables, signal) => fetch$1({
|
506
|
+
url: "/db/{dbBranchName}/schema/update",
|
507
|
+
method: "post",
|
508
|
+
...variables,
|
509
|
+
signal
|
510
|
+
});
|
511
|
+
const previewBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
512
|
+
const applyBranchSchemaEdit = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
513
|
+
const createTable = (variables, signal) => fetch$1({
|
289
514
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
290
515
|
method: "put",
|
291
|
-
...variables
|
516
|
+
...variables,
|
517
|
+
signal
|
292
518
|
});
|
293
|
-
const deleteTable = (variables) => fetch$1({
|
519
|
+
const deleteTable = (variables, signal) => fetch$1({
|
294
520
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
295
521
|
method: "delete",
|
296
|
-
...variables
|
522
|
+
...variables,
|
523
|
+
signal
|
297
524
|
});
|
298
|
-
const updateTable = (variables) => fetch$1({
|
525
|
+
const updateTable = (variables, signal) => fetch$1({
|
299
526
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
300
527
|
method: "patch",
|
301
|
-
...variables
|
528
|
+
...variables,
|
529
|
+
signal
|
302
530
|
});
|
303
|
-
const getTableSchema = (variables) => fetch$1({
|
531
|
+
const getTableSchema = (variables, signal) => fetch$1({
|
304
532
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
305
533
|
method: "get",
|
306
|
-
...variables
|
534
|
+
...variables,
|
535
|
+
signal
|
307
536
|
});
|
308
|
-
const setTableSchema = (variables) => fetch$1({
|
537
|
+
const setTableSchema = (variables, signal) => fetch$1({
|
309
538
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
310
539
|
method: "put",
|
311
|
-
...variables
|
540
|
+
...variables,
|
541
|
+
signal
|
312
542
|
});
|
313
|
-
const getTableColumns = (variables) => fetch$1({
|
543
|
+
const getTableColumns = (variables, signal) => fetch$1({
|
314
544
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
315
545
|
method: "get",
|
316
|
-
...variables
|
546
|
+
...variables,
|
547
|
+
signal
|
317
548
|
});
|
318
|
-
const addTableColumn = (variables) => fetch$1({
|
549
|
+
const addTableColumn = (variables, signal) => fetch$1({
|
319
550
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
320
551
|
method: "post",
|
321
|
-
...variables
|
552
|
+
...variables,
|
553
|
+
signal
|
322
554
|
});
|
323
|
-
const getColumn = (variables) => fetch$1({
|
555
|
+
const getColumn = (variables, signal) => fetch$1({
|
324
556
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
325
557
|
method: "get",
|
326
|
-
...variables
|
558
|
+
...variables,
|
559
|
+
signal
|
327
560
|
});
|
328
|
-
const
|
329
|
-
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
330
|
-
method: "delete",
|
331
|
-
...variables
|
332
|
-
});
|
333
|
-
const updateColumn = (variables) => fetch$1({
|
561
|
+
const updateColumn = (variables, signal) => fetch$1({
|
334
562
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
335
563
|
method: "patch",
|
336
|
-
...variables
|
337
|
-
|
338
|
-
const insertRecord = (variables) => fetch$1({
|
339
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
340
|
-
method: "post",
|
341
|
-
...variables
|
564
|
+
...variables,
|
565
|
+
signal
|
342
566
|
});
|
343
|
-
const
|
344
|
-
|
345
|
-
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
346
|
-
const deleteRecord = (variables) => fetch$1({
|
347
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
567
|
+
const deleteColumn = (variables, signal) => fetch$1({
|
568
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
348
569
|
method: "delete",
|
349
|
-
...variables
|
570
|
+
...variables,
|
571
|
+
signal
|
350
572
|
});
|
351
|
-
const
|
573
|
+
const insertRecord = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
574
|
+
const getRecord = (variables, signal) => fetch$1({
|
352
575
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
353
576
|
method: "get",
|
354
|
-
...variables
|
577
|
+
...variables,
|
578
|
+
signal
|
579
|
+
});
|
580
|
+
const insertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
|
581
|
+
const updateRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
|
582
|
+
const upsertRecordWithID = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
|
583
|
+
const deleteRecord = (variables, signal) => fetch$1({
|
584
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
585
|
+
method: "delete",
|
586
|
+
...variables,
|
587
|
+
signal
|
355
588
|
});
|
356
|
-
const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
|
357
|
-
const queryTable = (variables) => fetch$1({
|
589
|
+
const bulkInsertTableRecords = (variables, signal) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
|
590
|
+
const queryTable = (variables, signal) => fetch$1({
|
358
591
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
359
592
|
method: "post",
|
360
|
-
...variables
|
593
|
+
...variables,
|
594
|
+
signal
|
361
595
|
});
|
362
|
-
const searchBranch = (variables) => fetch$1({
|
596
|
+
const searchBranch = (variables, signal) => fetch$1({
|
363
597
|
url: "/db/{dbBranchName}/search",
|
364
598
|
method: "post",
|
365
|
-
...variables
|
599
|
+
...variables,
|
600
|
+
signal
|
601
|
+
});
|
602
|
+
const searchTable = (variables, signal) => fetch$1({
|
603
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
604
|
+
method: "post",
|
605
|
+
...variables,
|
606
|
+
signal
|
607
|
+
});
|
608
|
+
const summarizeTable = (variables, signal) => fetch$1({
|
609
|
+
url: "/db/{dbBranchName}/tables/{tableName}/summarize",
|
610
|
+
method: "post",
|
611
|
+
...variables,
|
612
|
+
signal
|
613
|
+
});
|
614
|
+
const aggregateTable = (variables, signal) => fetch$1({
|
615
|
+
url: "/db/{dbBranchName}/tables/{tableName}/aggregate",
|
616
|
+
method: "post",
|
617
|
+
...variables,
|
618
|
+
signal
|
619
|
+
});
|
620
|
+
const cPGetDatabaseList = (variables, signal) => fetch$1({
|
621
|
+
url: "/workspaces/{workspaceId}/dbs",
|
622
|
+
method: "get",
|
623
|
+
...variables,
|
624
|
+
signal
|
625
|
+
});
|
626
|
+
const cPCreateDatabase = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
|
627
|
+
const cPDeleteDatabase = (variables, signal) => fetch$1({
|
628
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
629
|
+
method: "delete",
|
630
|
+
...variables,
|
631
|
+
signal
|
632
|
+
});
|
633
|
+
const cPGetCPDatabaseMetadata = (variables, signal) => fetch$1(
|
634
|
+
{ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "get", ...variables, signal }
|
635
|
+
);
|
636
|
+
const cPUpdateCPDatabaseMetadata = (variables, signal) => fetch$1({ url: "/workspaces/{workspaceId}/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
|
637
|
+
const listRegions = (variables, signal) => fetch$1({
|
638
|
+
url: "/workspaces/{workspaceId}/regions",
|
639
|
+
method: "get",
|
640
|
+
...variables,
|
641
|
+
signal
|
366
642
|
});
|
367
643
|
const operationsByTag = {
|
368
|
-
users: { getUser, updateUser, deleteUser
|
644
|
+
users: { getUser, updateUser, deleteUser },
|
645
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
369
646
|
workspaces: {
|
370
|
-
createWorkspace,
|
371
647
|
getWorkspacesList,
|
648
|
+
createWorkspace,
|
372
649
|
getWorkspace,
|
373
650
|
updateWorkspace,
|
374
651
|
deleteWorkspace,
|
375
652
|
getWorkspaceMembersList,
|
376
653
|
updateWorkspaceMemberRole,
|
377
|
-
removeWorkspaceMember
|
654
|
+
removeWorkspaceMember
|
655
|
+
},
|
656
|
+
invites: {
|
378
657
|
inviteWorkspaceMember,
|
658
|
+
updateWorkspaceMemberInvite,
|
379
659
|
cancelWorkspaceMemberInvite,
|
380
|
-
|
381
|
-
|
660
|
+
acceptWorkspaceMemberInvite,
|
661
|
+
resendWorkspaceMemberInvite
|
382
662
|
},
|
383
|
-
database: { getDatabaseList, createDatabase, deleteDatabase },
|
663
|
+
database: { getDatabaseList, createDatabase, deleteDatabase, getDatabaseMetadata, updateDatabaseMetadata },
|
384
664
|
branch: {
|
385
665
|
getBranchList,
|
386
666
|
getBranchDetails,
|
@@ -388,10 +668,32 @@ const operationsByTag = {
|
|
388
668
|
deleteBranch,
|
389
669
|
updateBranchMetadata,
|
390
670
|
getBranchMetadata,
|
671
|
+
getBranchStats,
|
672
|
+
getGitBranchesMapping,
|
673
|
+
addGitBranchesEntry,
|
674
|
+
removeGitBranchesEntry,
|
675
|
+
resolveBranch
|
676
|
+
},
|
677
|
+
migrations: {
|
391
678
|
getBranchMigrationHistory,
|
392
|
-
executeBranchMigrationPlan,
|
393
679
|
getBranchMigrationPlan,
|
394
|
-
|
680
|
+
executeBranchMigrationPlan,
|
681
|
+
getBranchSchemaHistory,
|
682
|
+
compareBranchWithUserSchema,
|
683
|
+
compareBranchSchemas,
|
684
|
+
updateBranchSchema,
|
685
|
+
previewBranchSchemaEdit,
|
686
|
+
applyBranchSchemaEdit
|
687
|
+
},
|
688
|
+
migrationRequests: {
|
689
|
+
queryMigrationRequests,
|
690
|
+
createMigrationRequest,
|
691
|
+
getMigrationRequest,
|
692
|
+
updateMigrationRequest,
|
693
|
+
listMigrationRequestsCommits,
|
694
|
+
compareMigrationRequest,
|
695
|
+
getMigrationRequestIsMerged,
|
696
|
+
mergeMigrationRequest
|
395
697
|
},
|
396
698
|
table: {
|
397
699
|
createTable,
|
@@ -402,26 +704,33 @@ const operationsByTag = {
|
|
402
704
|
getTableColumns,
|
403
705
|
addTableColumn,
|
404
706
|
getColumn,
|
405
|
-
|
406
|
-
|
707
|
+
updateColumn,
|
708
|
+
deleteColumn
|
407
709
|
},
|
408
710
|
records: {
|
409
711
|
insertRecord,
|
712
|
+
getRecord,
|
410
713
|
insertRecordWithID,
|
411
714
|
updateRecordWithID,
|
412
715
|
upsertRecordWithID,
|
413
716
|
deleteRecord,
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
717
|
+
bulkInsertTableRecords
|
718
|
+
},
|
719
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable },
|
720
|
+
databases: {
|
721
|
+
cPGetDatabaseList,
|
722
|
+
cPCreateDatabase,
|
723
|
+
cPDeleteDatabase,
|
724
|
+
cPGetCPDatabaseMetadata,
|
725
|
+
cPUpdateCPDatabaseMetadata,
|
726
|
+
listRegions
|
418
727
|
}
|
419
728
|
};
|
420
729
|
|
421
730
|
function getHostUrl(provider, type) {
|
422
|
-
if (
|
731
|
+
if (isHostProviderAlias(provider)) {
|
423
732
|
return providers[provider][type];
|
424
|
-
} else if (
|
733
|
+
} else if (isHostProviderBuilder(provider)) {
|
425
734
|
return provider[type];
|
426
735
|
}
|
427
736
|
throw new Error("Invalid API provider");
|
@@ -436,18 +745,27 @@ const providers = {
|
|
436
745
|
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
437
746
|
}
|
438
747
|
};
|
439
|
-
function
|
748
|
+
function isHostProviderAlias(alias) {
|
440
749
|
return isString(alias) && Object.keys(providers).includes(alias);
|
441
750
|
}
|
442
|
-
function
|
751
|
+
function isHostProviderBuilder(builder) {
|
443
752
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
444
753
|
}
|
754
|
+
function parseProviderString(provider = "production") {
|
755
|
+
if (isHostProviderAlias(provider)) {
|
756
|
+
return provider;
|
757
|
+
}
|
758
|
+
const [main, workspaces] = provider.split(",");
|
759
|
+
if (!main || !workspaces)
|
760
|
+
return null;
|
761
|
+
return { main, workspaces };
|
762
|
+
}
|
445
763
|
|
446
764
|
var __accessCheck$7 = (obj, member, msg) => {
|
447
765
|
if (!member.has(obj))
|
448
766
|
throw TypeError("Cannot " + msg);
|
449
767
|
};
|
450
|
-
var __privateGet$
|
768
|
+
var __privateGet$7 = (obj, member, getter) => {
|
451
769
|
__accessCheck$7(obj, member, "read from private field");
|
452
770
|
return getter ? getter.call(obj) : member.get(obj);
|
453
771
|
};
|
@@ -456,7 +774,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
456
774
|
throw TypeError("Cannot add the same private member more than once");
|
457
775
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
458
776
|
};
|
459
|
-
var __privateSet$
|
777
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
460
778
|
__accessCheck$7(obj, member, "write to private field");
|
461
779
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
462
780
|
return value;
|
@@ -467,46 +785,78 @@ class XataApiClient {
|
|
467
785
|
__privateAdd$7(this, _extraProps, void 0);
|
468
786
|
__privateAdd$7(this, _namespaces, {});
|
469
787
|
const provider = options.host ?? "production";
|
470
|
-
const apiKey = options
|
788
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
789
|
+
const trace = options.trace ?? defaultTrace;
|
471
790
|
if (!apiKey) {
|
472
791
|
throw new Error("Could not resolve a valid apiKey");
|
473
792
|
}
|
474
|
-
__privateSet$
|
793
|
+
__privateSet$7(this, _extraProps, {
|
475
794
|
apiUrl: getHostUrl(provider, "main"),
|
476
795
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
477
796
|
fetchImpl: getFetchImplementation(options.fetch),
|
478
|
-
apiKey
|
797
|
+
apiKey,
|
798
|
+
trace
|
479
799
|
});
|
480
800
|
}
|
481
801
|
get user() {
|
482
|
-
if (!__privateGet$
|
483
|
-
__privateGet$
|
484
|
-
return __privateGet$
|
802
|
+
if (!__privateGet$7(this, _namespaces).user)
|
803
|
+
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
804
|
+
return __privateGet$7(this, _namespaces).user;
|
805
|
+
}
|
806
|
+
get authentication() {
|
807
|
+
if (!__privateGet$7(this, _namespaces).authentication)
|
808
|
+
__privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
|
809
|
+
return __privateGet$7(this, _namespaces).authentication;
|
485
810
|
}
|
486
811
|
get workspaces() {
|
487
|
-
if (!__privateGet$
|
488
|
-
__privateGet$
|
489
|
-
return __privateGet$
|
812
|
+
if (!__privateGet$7(this, _namespaces).workspaces)
|
813
|
+
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
814
|
+
return __privateGet$7(this, _namespaces).workspaces;
|
490
815
|
}
|
491
|
-
get
|
492
|
-
if (!__privateGet$
|
493
|
-
__privateGet$
|
494
|
-
return __privateGet$
|
816
|
+
get invites() {
|
817
|
+
if (!__privateGet$7(this, _namespaces).invites)
|
818
|
+
__privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
|
819
|
+
return __privateGet$7(this, _namespaces).invites;
|
820
|
+
}
|
821
|
+
get database() {
|
822
|
+
if (!__privateGet$7(this, _namespaces).database)
|
823
|
+
__privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
|
824
|
+
return __privateGet$7(this, _namespaces).database;
|
495
825
|
}
|
496
826
|
get branches() {
|
497
|
-
if (!__privateGet$
|
498
|
-
__privateGet$
|
499
|
-
return __privateGet$
|
827
|
+
if (!__privateGet$7(this, _namespaces).branches)
|
828
|
+
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
829
|
+
return __privateGet$7(this, _namespaces).branches;
|
830
|
+
}
|
831
|
+
get migrations() {
|
832
|
+
if (!__privateGet$7(this, _namespaces).migrations)
|
833
|
+
__privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
|
834
|
+
return __privateGet$7(this, _namespaces).migrations;
|
835
|
+
}
|
836
|
+
get migrationRequests() {
|
837
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
838
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
839
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
500
840
|
}
|
501
841
|
get tables() {
|
502
|
-
if (!__privateGet$
|
503
|
-
__privateGet$
|
504
|
-
return __privateGet$
|
842
|
+
if (!__privateGet$7(this, _namespaces).tables)
|
843
|
+
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
844
|
+
return __privateGet$7(this, _namespaces).tables;
|
505
845
|
}
|
506
846
|
get records() {
|
507
|
-
if (!__privateGet$
|
508
|
-
__privateGet$
|
509
|
-
return __privateGet$
|
847
|
+
if (!__privateGet$7(this, _namespaces).records)
|
848
|
+
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
849
|
+
return __privateGet$7(this, _namespaces).records;
|
850
|
+
}
|
851
|
+
get searchAndFilter() {
|
852
|
+
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
853
|
+
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
854
|
+
return __privateGet$7(this, _namespaces).searchAndFilter;
|
855
|
+
}
|
856
|
+
get databases() {
|
857
|
+
if (!__privateGet$7(this, _namespaces).databases)
|
858
|
+
__privateGet$7(this, _namespaces).databases = new DatabasesApi(__privateGet$7(this, _extraProps));
|
859
|
+
return __privateGet$7(this, _namespaces).databases;
|
510
860
|
}
|
511
861
|
}
|
512
862
|
_extraProps = new WeakMap();
|
@@ -524,17 +874,22 @@ class UserApi {
|
|
524
874
|
deleteUser() {
|
525
875
|
return operationsByTag.users.deleteUser({ ...this.extraProps });
|
526
876
|
}
|
877
|
+
}
|
878
|
+
class AuthenticationApi {
|
879
|
+
constructor(extraProps) {
|
880
|
+
this.extraProps = extraProps;
|
881
|
+
}
|
527
882
|
getUserAPIKeys() {
|
528
|
-
return operationsByTag.
|
883
|
+
return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
|
529
884
|
}
|
530
885
|
createUserAPIKey(keyName) {
|
531
|
-
return operationsByTag.
|
886
|
+
return operationsByTag.authentication.createUserAPIKey({
|
532
887
|
pathParams: { keyName },
|
533
888
|
...this.extraProps
|
534
889
|
});
|
535
890
|
}
|
536
891
|
deleteUserAPIKey(keyName) {
|
537
|
-
return operationsByTag.
|
892
|
+
return operationsByTag.authentication.deleteUserAPIKey({
|
538
893
|
pathParams: { keyName },
|
539
894
|
...this.extraProps
|
540
895
|
});
|
@@ -544,15 +899,15 @@ class WorkspaceApi {
|
|
544
899
|
constructor(extraProps) {
|
545
900
|
this.extraProps = extraProps;
|
546
901
|
}
|
902
|
+
getWorkspacesList() {
|
903
|
+
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
904
|
+
}
|
547
905
|
createWorkspace(workspaceMeta) {
|
548
906
|
return operationsByTag.workspaces.createWorkspace({
|
549
907
|
body: workspaceMeta,
|
550
908
|
...this.extraProps
|
551
909
|
});
|
552
910
|
}
|
553
|
-
getWorkspacesList() {
|
554
|
-
return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
|
555
|
-
}
|
556
911
|
getWorkspace(workspaceId) {
|
557
912
|
return operationsByTag.workspaces.getWorkspace({
|
558
913
|
pathParams: { workspaceId },
|
@@ -591,31 +946,43 @@ class WorkspaceApi {
|
|
591
946
|
...this.extraProps
|
592
947
|
});
|
593
948
|
}
|
949
|
+
}
|
950
|
+
class InvitesApi {
|
951
|
+
constructor(extraProps) {
|
952
|
+
this.extraProps = extraProps;
|
953
|
+
}
|
594
954
|
inviteWorkspaceMember(workspaceId, email, role) {
|
595
|
-
return operationsByTag.
|
955
|
+
return operationsByTag.invites.inviteWorkspaceMember({
|
596
956
|
pathParams: { workspaceId },
|
597
957
|
body: { email, role },
|
598
958
|
...this.extraProps
|
599
959
|
});
|
600
960
|
}
|
601
|
-
|
602
|
-
return operationsByTag.
|
961
|
+
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
962
|
+
return operationsByTag.invites.updateWorkspaceMemberInvite({
|
603
963
|
pathParams: { workspaceId, inviteId },
|
964
|
+
body: { role },
|
604
965
|
...this.extraProps
|
605
966
|
});
|
606
967
|
}
|
607
|
-
|
608
|
-
return operationsByTag.
|
968
|
+
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
969
|
+
return operationsByTag.invites.cancelWorkspaceMemberInvite({
|
609
970
|
pathParams: { workspaceId, inviteId },
|
610
971
|
...this.extraProps
|
611
972
|
});
|
612
973
|
}
|
613
974
|
acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
|
614
|
-
return operationsByTag.
|
975
|
+
return operationsByTag.invites.acceptWorkspaceMemberInvite({
|
615
976
|
pathParams: { workspaceId, inviteKey },
|
616
977
|
...this.extraProps
|
617
978
|
});
|
618
979
|
}
|
980
|
+
resendWorkspaceMemberInvite(workspaceId, inviteId) {
|
981
|
+
return operationsByTag.invites.resendWorkspaceMemberInvite({
|
982
|
+
pathParams: { workspaceId, inviteId },
|
983
|
+
...this.extraProps
|
984
|
+
});
|
985
|
+
}
|
619
986
|
}
|
620
987
|
class DatabaseApi {
|
621
988
|
constructor(extraProps) {
|
@@ -640,6 +1007,19 @@ class DatabaseApi {
|
|
640
1007
|
...this.extraProps
|
641
1008
|
});
|
642
1009
|
}
|
1010
|
+
getDatabaseMetadata(workspace, dbName) {
|
1011
|
+
return operationsByTag.database.getDatabaseMetadata({
|
1012
|
+
pathParams: { workspace, dbName },
|
1013
|
+
...this.extraProps
|
1014
|
+
});
|
1015
|
+
}
|
1016
|
+
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
1017
|
+
return operationsByTag.database.updateDatabaseMetadata({
|
1018
|
+
pathParams: { workspace, dbName },
|
1019
|
+
body: options,
|
1020
|
+
...this.extraProps
|
1021
|
+
});
|
1022
|
+
}
|
643
1023
|
}
|
644
1024
|
class BranchApi {
|
645
1025
|
constructor(extraProps) {
|
@@ -657,10 +1037,10 @@ class BranchApi {
|
|
657
1037
|
...this.extraProps
|
658
1038
|
});
|
659
1039
|
}
|
660
|
-
createBranch(workspace, database, branch, from
|
1040
|
+
createBranch(workspace, database, branch, from, options = {}) {
|
661
1041
|
return operationsByTag.branch.createBranch({
|
662
1042
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
663
|
-
queryParams: { from },
|
1043
|
+
queryParams: isString(from) ? { from } : void 0,
|
664
1044
|
body: options,
|
665
1045
|
...this.extraProps
|
666
1046
|
});
|
@@ -684,30 +1064,36 @@ class BranchApi {
|
|
684
1064
|
...this.extraProps
|
685
1065
|
});
|
686
1066
|
}
|
687
|
-
|
688
|
-
return operationsByTag.branch.
|
1067
|
+
getBranchStats(workspace, database, branch) {
|
1068
|
+
return operationsByTag.branch.getBranchStats({
|
689
1069
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
690
|
-
body: options,
|
691
1070
|
...this.extraProps
|
692
1071
|
});
|
693
1072
|
}
|
694
|
-
|
695
|
-
return operationsByTag.branch.
|
696
|
-
pathParams: { workspace,
|
697
|
-
body: migrationPlan,
|
1073
|
+
getGitBranchesMapping(workspace, dbName) {
|
1074
|
+
return operationsByTag.branch.getGitBranchesMapping({
|
1075
|
+
pathParams: { workspace, dbName },
|
698
1076
|
...this.extraProps
|
699
1077
|
});
|
700
1078
|
}
|
701
|
-
|
702
|
-
return operationsByTag.branch.
|
703
|
-
pathParams: { workspace,
|
704
|
-
body
|
1079
|
+
addGitBranchesEntry(workspace, dbName, body) {
|
1080
|
+
return operationsByTag.branch.addGitBranchesEntry({
|
1081
|
+
pathParams: { workspace, dbName },
|
1082
|
+
body,
|
705
1083
|
...this.extraProps
|
706
1084
|
});
|
707
1085
|
}
|
708
|
-
|
709
|
-
return operationsByTag.branch.
|
710
|
-
pathParams: { workspace,
|
1086
|
+
removeGitBranchesEntry(workspace, dbName, gitBranch) {
|
1087
|
+
return operationsByTag.branch.removeGitBranchesEntry({
|
1088
|
+
pathParams: { workspace, dbName },
|
1089
|
+
queryParams: { gitBranch },
|
1090
|
+
...this.extraProps
|
1091
|
+
});
|
1092
|
+
}
|
1093
|
+
resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
|
1094
|
+
return operationsByTag.branch.resolveBranch({
|
1095
|
+
pathParams: { workspace, dbName },
|
1096
|
+
queryParams: { gitBranch, fallbackBranch },
|
711
1097
|
...this.extraProps
|
712
1098
|
});
|
713
1099
|
}
|
@@ -767,16 +1153,16 @@ class TableApi {
|
|
767
1153
|
...this.extraProps
|
768
1154
|
});
|
769
1155
|
}
|
770
|
-
|
771
|
-
return operationsByTag.table.
|
1156
|
+
updateColumn(workspace, database, branch, tableName, columnName, options) {
|
1157
|
+
return operationsByTag.table.updateColumn({
|
772
1158
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
1159
|
+
body: options,
|
773
1160
|
...this.extraProps
|
774
1161
|
});
|
775
1162
|
}
|
776
|
-
|
777
|
-
return operationsByTag.table.
|
1163
|
+
deleteColumn(workspace, database, branch, tableName, columnName) {
|
1164
|
+
return operationsByTag.table.deleteColumn({
|
778
1165
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName },
|
779
|
-
body: options,
|
780
1166
|
...this.extraProps
|
781
1167
|
});
|
782
1168
|
}
|
@@ -785,13 +1171,21 @@ class RecordsApi {
|
|
785
1171
|
constructor(extraProps) {
|
786
1172
|
this.extraProps = extraProps;
|
787
1173
|
}
|
788
|
-
insertRecord(workspace, database, branch, tableName, record) {
|
1174
|
+
insertRecord(workspace, database, branch, tableName, record, options = {}) {
|
789
1175
|
return operationsByTag.records.insertRecord({
|
790
1176
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1177
|
+
queryParams: options,
|
791
1178
|
body: record,
|
792
1179
|
...this.extraProps
|
793
1180
|
});
|
794
1181
|
}
|
1182
|
+
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
1183
|
+
return operationsByTag.records.getRecord({
|
1184
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1185
|
+
queryParams: options,
|
1186
|
+
...this.extraProps
|
1187
|
+
});
|
1188
|
+
}
|
795
1189
|
insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
796
1190
|
return operationsByTag.records.insertRecordWithID({
|
797
1191
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
@@ -816,88 +1210,292 @@ class RecordsApi {
|
|
816
1210
|
...this.extraProps
|
817
1211
|
});
|
818
1212
|
}
|
819
|
-
deleteRecord(workspace, database, branch, tableName, recordId) {
|
1213
|
+
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
820
1214
|
return operationsByTag.records.deleteRecord({
|
821
1215
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1216
|
+
queryParams: options,
|
822
1217
|
...this.extraProps
|
823
1218
|
});
|
824
1219
|
}
|
825
|
-
|
826
|
-
return operationsByTag.records.getRecord({
|
827
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
828
|
-
...this.extraProps
|
829
|
-
});
|
830
|
-
}
|
831
|
-
bulkInsertTableRecords(workspace, database, branch, tableName, records) {
|
1220
|
+
bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
|
832
1221
|
return operationsByTag.records.bulkInsertTableRecords({
|
833
1222
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1223
|
+
queryParams: options,
|
834
1224
|
body: { records },
|
835
1225
|
...this.extraProps
|
836
1226
|
});
|
837
1227
|
}
|
1228
|
+
}
|
1229
|
+
class SearchAndFilterApi {
|
1230
|
+
constructor(extraProps) {
|
1231
|
+
this.extraProps = extraProps;
|
1232
|
+
}
|
838
1233
|
queryTable(workspace, database, branch, tableName, query) {
|
839
|
-
return operationsByTag.
|
1234
|
+
return operationsByTag.searchAndFilter.queryTable({
|
1235
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1236
|
+
body: query,
|
1237
|
+
...this.extraProps
|
1238
|
+
});
|
1239
|
+
}
|
1240
|
+
searchTable(workspace, database, branch, tableName, query) {
|
1241
|
+
return operationsByTag.searchAndFilter.searchTable({
|
840
1242
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
841
1243
|
body: query,
|
842
1244
|
...this.extraProps
|
843
1245
|
});
|
844
1246
|
}
|
845
1247
|
searchBranch(workspace, database, branch, query) {
|
846
|
-
return operationsByTag.
|
1248
|
+
return operationsByTag.searchAndFilter.searchBranch({
|
847
1249
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
848
1250
|
body: query,
|
849
1251
|
...this.extraProps
|
850
1252
|
});
|
851
1253
|
}
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
1254
|
+
summarizeTable(workspace, database, branch, tableName, query) {
|
1255
|
+
return operationsByTag.searchAndFilter.summarizeTable({
|
1256
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1257
|
+
body: query,
|
1258
|
+
...this.extraProps
|
1259
|
+
});
|
1260
|
+
}
|
1261
|
+
aggregateTable(workspace, database, branch, tableName, query) {
|
1262
|
+
return operationsByTag.searchAndFilter.aggregateTable({
|
1263
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1264
|
+
body: query,
|
1265
|
+
...this.extraProps
|
1266
|
+
});
|
858
1267
|
}
|
859
1268
|
}
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
};
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
1269
|
+
class MigrationRequestsApi {
|
1270
|
+
constructor(extraProps) {
|
1271
|
+
this.extraProps = extraProps;
|
1272
|
+
}
|
1273
|
+
queryMigrationRequests(workspace, database, options = {}) {
|
1274
|
+
return operationsByTag.migrationRequests.queryMigrationRequests({
|
1275
|
+
pathParams: { workspace, dbName: database },
|
1276
|
+
body: options,
|
1277
|
+
...this.extraProps
|
1278
|
+
});
|
1279
|
+
}
|
1280
|
+
createMigrationRequest(workspace, database, options) {
|
1281
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
1282
|
+
pathParams: { workspace, dbName: database },
|
1283
|
+
body: options,
|
1284
|
+
...this.extraProps
|
1285
|
+
});
|
1286
|
+
}
|
1287
|
+
getMigrationRequest(workspace, database, migrationRequest) {
|
1288
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
1289
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1290
|
+
...this.extraProps
|
1291
|
+
});
|
1292
|
+
}
|
1293
|
+
updateMigrationRequest(workspace, database, migrationRequest, options) {
|
1294
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1295
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1296
|
+
body: options,
|
1297
|
+
...this.extraProps
|
1298
|
+
});
|
1299
|
+
}
|
1300
|
+
listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
|
1301
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1302
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1303
|
+
body: options,
|
1304
|
+
...this.extraProps
|
1305
|
+
});
|
1306
|
+
}
|
1307
|
+
compareMigrationRequest(workspace, database, migrationRequest) {
|
1308
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1309
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1310
|
+
...this.extraProps
|
1311
|
+
});
|
1312
|
+
}
|
1313
|
+
getMigrationRequestIsMerged(workspace, database, migrationRequest) {
|
1314
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1315
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1316
|
+
...this.extraProps
|
1317
|
+
});
|
1318
|
+
}
|
1319
|
+
mergeMigrationRequest(workspace, database, migrationRequest) {
|
1320
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1321
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1322
|
+
...this.extraProps
|
1323
|
+
});
|
1324
|
+
}
|
1325
|
+
}
|
1326
|
+
class MigrationsApi {
|
1327
|
+
constructor(extraProps) {
|
1328
|
+
this.extraProps = extraProps;
|
1329
|
+
}
|
1330
|
+
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
1331
|
+
return operationsByTag.migrations.getBranchMigrationHistory({
|
1332
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1333
|
+
body: options,
|
1334
|
+
...this.extraProps
|
1335
|
+
});
|
1336
|
+
}
|
1337
|
+
getBranchMigrationPlan(workspace, database, branch, schema) {
|
1338
|
+
return operationsByTag.migrations.getBranchMigrationPlan({
|
1339
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1340
|
+
body: schema,
|
1341
|
+
...this.extraProps
|
1342
|
+
});
|
1343
|
+
}
|
1344
|
+
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
1345
|
+
return operationsByTag.migrations.executeBranchMigrationPlan({
|
1346
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1347
|
+
body: migrationPlan,
|
1348
|
+
...this.extraProps
|
1349
|
+
});
|
1350
|
+
}
|
1351
|
+
getBranchSchemaHistory(workspace, database, branch, options = {}) {
|
1352
|
+
return operationsByTag.migrations.getBranchSchemaHistory({
|
1353
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1354
|
+
body: options,
|
1355
|
+
...this.extraProps
|
1356
|
+
});
|
1357
|
+
}
|
1358
|
+
compareBranchWithUserSchema(workspace, database, branch, schema) {
|
1359
|
+
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1360
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1361
|
+
body: { schema },
|
1362
|
+
...this.extraProps
|
1363
|
+
});
|
1364
|
+
}
|
1365
|
+
compareBranchSchemas(workspace, database, branch, branchName, schema) {
|
1366
|
+
return operationsByTag.migrations.compareBranchSchemas({
|
1367
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
|
1368
|
+
body: { schema },
|
1369
|
+
...this.extraProps
|
1370
|
+
});
|
1371
|
+
}
|
1372
|
+
updateBranchSchema(workspace, database, branch, migration) {
|
1373
|
+
return operationsByTag.migrations.updateBranchSchema({
|
1374
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1375
|
+
body: migration,
|
1376
|
+
...this.extraProps
|
1377
|
+
});
|
1378
|
+
}
|
1379
|
+
previewBranchSchemaEdit(workspace, database, branch, migration) {
|
1380
|
+
return operationsByTag.migrations.previewBranchSchemaEdit({
|
1381
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1382
|
+
body: migration,
|
1383
|
+
...this.extraProps
|
1384
|
+
});
|
1385
|
+
}
|
1386
|
+
applyBranchSchemaEdit(workspace, database, branch, edits) {
|
1387
|
+
return operationsByTag.migrations.applyBranchSchemaEdit({
|
1388
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1389
|
+
body: { edits },
|
1390
|
+
...this.extraProps
|
1391
|
+
});
|
1392
|
+
}
|
1393
|
+
}
|
1394
|
+
class DatabasesApi {
|
1395
|
+
constructor(extraProps) {
|
1396
|
+
this.extraProps = extraProps;
|
1397
|
+
}
|
1398
|
+
getDatabaseList(workspaceId) {
|
1399
|
+
return operationsByTag.databases.cPGetDatabaseList({
|
1400
|
+
pathParams: { workspaceId },
|
1401
|
+
...this.extraProps
|
1402
|
+
});
|
1403
|
+
}
|
1404
|
+
createDatabase(workspaceId, dbName, options) {
|
1405
|
+
return operationsByTag.databases.cPCreateDatabase({
|
1406
|
+
pathParams: { workspaceId, dbName },
|
1407
|
+
body: options,
|
1408
|
+
...this.extraProps
|
1409
|
+
});
|
1410
|
+
}
|
1411
|
+
deleteDatabase(workspaceId, dbName) {
|
1412
|
+
return operationsByTag.databases.cPDeleteDatabase({
|
1413
|
+
pathParams: { workspaceId, dbName },
|
1414
|
+
...this.extraProps
|
1415
|
+
});
|
1416
|
+
}
|
1417
|
+
getDatabaseMetadata(workspaceId, dbName) {
|
1418
|
+
return operationsByTag.databases.cPGetCPDatabaseMetadata({
|
1419
|
+
pathParams: { workspaceId, dbName },
|
1420
|
+
...this.extraProps
|
1421
|
+
});
|
1422
|
+
}
|
1423
|
+
updateDatabaseMetadata(workspaceId, dbName, metadata) {
|
1424
|
+
return operationsByTag.databases.cPUpdateCPDatabaseMetadata({
|
1425
|
+
pathParams: { workspaceId, dbName },
|
1426
|
+
body: metadata,
|
1427
|
+
...this.extraProps
|
1428
|
+
});
|
1429
|
+
}
|
1430
|
+
listRegions(workspaceId) {
|
1431
|
+
return operationsByTag.databases.listRegions({
|
1432
|
+
pathParams: { workspaceId },
|
1433
|
+
...this.extraProps
|
1434
|
+
});
|
1435
|
+
}
|
1436
|
+
}
|
1437
|
+
|
1438
|
+
class XataApiPlugin {
|
1439
|
+
async build(options) {
|
1440
|
+
const { fetchImpl, apiKey } = await options.getFetchProps();
|
1441
|
+
return new XataApiClient({ fetch: fetchImpl, apiKey });
|
1442
|
+
}
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
class XataPlugin {
|
1446
|
+
}
|
1447
|
+
|
1448
|
+
function generateUUID() {
|
1449
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
1450
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
1451
|
+
return v.toString(16);
|
1452
|
+
});
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
function cleanFilter(filter) {
|
1456
|
+
if (!filter)
|
1457
|
+
return void 0;
|
1458
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1459
|
+
return values.length > 0 ? filter : void 0;
|
1460
|
+
}
|
1461
|
+
|
1462
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
1463
|
+
if (!member.has(obj))
|
1464
|
+
throw TypeError("Cannot " + msg);
|
1465
|
+
};
|
1466
|
+
var __privateGet$6 = (obj, member, getter) => {
|
1467
|
+
__accessCheck$6(obj, member, "read from private field");
|
1468
|
+
return getter ? getter.call(obj) : member.get(obj);
|
1469
|
+
};
|
1470
|
+
var __privateAdd$6 = (obj, member, value) => {
|
1471
|
+
if (member.has(obj))
|
1472
|
+
throw TypeError("Cannot add the same private member more than once");
|
1473
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1474
|
+
};
|
1475
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
1476
|
+
__accessCheck$6(obj, member, "write to private field");
|
1477
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1478
|
+
return value;
|
1479
|
+
};
|
1480
|
+
var _query, _page;
|
1481
|
+
class Page {
|
884
1482
|
constructor(query, meta, records = []) {
|
885
1483
|
__privateAdd$6(this, _query, void 0);
|
886
|
-
__privateSet$
|
1484
|
+
__privateSet$6(this, _query, query);
|
887
1485
|
this.meta = meta;
|
888
|
-
this.records = records;
|
1486
|
+
this.records = new RecordArray(this, records);
|
889
1487
|
}
|
890
1488
|
async nextPage(size, offset) {
|
891
|
-
return __privateGet$
|
1489
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
892
1490
|
}
|
893
1491
|
async previousPage(size, offset) {
|
894
|
-
return __privateGet$
|
1492
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
895
1493
|
}
|
896
1494
|
async firstPage(size, offset) {
|
897
|
-
return __privateGet$
|
1495
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
|
898
1496
|
}
|
899
1497
|
async lastPage(size, offset) {
|
900
|
-
return __privateGet$
|
1498
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
|
901
1499
|
}
|
902
1500
|
hasNextPage() {
|
903
1501
|
return this.meta.page.more;
|
@@ -905,15 +1503,62 @@ class Page {
|
|
905
1503
|
}
|
906
1504
|
_query = new WeakMap();
|
907
1505
|
const PAGINATION_MAX_SIZE = 200;
|
908
|
-
const PAGINATION_DEFAULT_SIZE =
|
1506
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
909
1507
|
const PAGINATION_MAX_OFFSET = 800;
|
910
1508
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1509
|
+
function isCursorPaginationOptions(options) {
|
1510
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
1511
|
+
}
|
1512
|
+
const _RecordArray = class extends Array {
|
1513
|
+
constructor(...args) {
|
1514
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
1515
|
+
__privateAdd$6(this, _page, void 0);
|
1516
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
1517
|
+
}
|
1518
|
+
static parseConstructorParams(...args) {
|
1519
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
1520
|
+
return new Array(args[0]);
|
1521
|
+
}
|
1522
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
1523
|
+
const result = args[1] ?? args[0].records ?? [];
|
1524
|
+
return new Array(...result);
|
1525
|
+
}
|
1526
|
+
return new Array(...args);
|
1527
|
+
}
|
1528
|
+
toArray() {
|
1529
|
+
return new Array(...this);
|
1530
|
+
}
|
1531
|
+
map(callbackfn, thisArg) {
|
1532
|
+
return this.toArray().map(callbackfn, thisArg);
|
1533
|
+
}
|
1534
|
+
async nextPage(size, offset) {
|
1535
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1536
|
+
return new _RecordArray(newPage);
|
1537
|
+
}
|
1538
|
+
async previousPage(size, offset) {
|
1539
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1540
|
+
return new _RecordArray(newPage);
|
1541
|
+
}
|
1542
|
+
async firstPage(size, offset) {
|
1543
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
1544
|
+
return new _RecordArray(newPage);
|
1545
|
+
}
|
1546
|
+
async lastPage(size, offset) {
|
1547
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
1548
|
+
return new _RecordArray(newPage);
|
1549
|
+
}
|
1550
|
+
hasNextPage() {
|
1551
|
+
return __privateGet$6(this, _page).meta.page.more;
|
1552
|
+
}
|
1553
|
+
};
|
1554
|
+
let RecordArray = _RecordArray;
|
1555
|
+
_page = new WeakMap();
|
911
1556
|
|
912
1557
|
var __accessCheck$5 = (obj, member, msg) => {
|
913
1558
|
if (!member.has(obj))
|
914
1559
|
throw TypeError("Cannot " + msg);
|
915
1560
|
};
|
916
|
-
var __privateGet$
|
1561
|
+
var __privateGet$5 = (obj, member, getter) => {
|
917
1562
|
__accessCheck$5(obj, member, "read from private field");
|
918
1563
|
return getter ? getter.call(obj) : member.get(obj);
|
919
1564
|
};
|
@@ -922,34 +1567,40 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
922
1567
|
throw TypeError("Cannot add the same private member more than once");
|
923
1568
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
924
1569
|
};
|
925
|
-
var __privateSet$
|
1570
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
926
1571
|
__accessCheck$5(obj, member, "write to private field");
|
927
1572
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
928
1573
|
return value;
|
929
1574
|
};
|
930
|
-
var
|
1575
|
+
var __privateMethod$3 = (obj, member, method) => {
|
1576
|
+
__accessCheck$5(obj, member, "access private method");
|
1577
|
+
return method;
|
1578
|
+
};
|
1579
|
+
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
931
1580
|
const _Query = class {
|
932
|
-
constructor(repository, table, data,
|
1581
|
+
constructor(repository, table, data, rawParent) {
|
1582
|
+
__privateAdd$5(this, _cleanFilterConstraint);
|
933
1583
|
__privateAdd$5(this, _table$1, void 0);
|
934
1584
|
__privateAdd$5(this, _repository, void 0);
|
935
1585
|
__privateAdd$5(this, _data, { filter: {} });
|
936
1586
|
this.meta = { page: { cursor: "start", more: true } };
|
937
|
-
this.records = [];
|
938
|
-
__privateSet$
|
1587
|
+
this.records = new RecordArray(this, []);
|
1588
|
+
__privateSet$5(this, _table$1, table);
|
939
1589
|
if (repository) {
|
940
|
-
__privateSet$
|
1590
|
+
__privateSet$5(this, _repository, repository);
|
941
1591
|
} else {
|
942
|
-
__privateSet$
|
1592
|
+
__privateSet$5(this, _repository, this);
|
943
1593
|
}
|
944
|
-
|
945
|
-
__privateGet$
|
946
|
-
__privateGet$
|
947
|
-
__privateGet$
|
948
|
-
__privateGet$
|
949
|
-
__privateGet$
|
950
|
-
__privateGet$
|
951
|
-
__privateGet$
|
952
|
-
__privateGet$
|
1594
|
+
const parent = cleanParent(data, rawParent);
|
1595
|
+
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
1596
|
+
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
1597
|
+
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
1598
|
+
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1599
|
+
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1600
|
+
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1601
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
|
1602
|
+
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1603
|
+
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
953
1604
|
this.any = this.any.bind(this);
|
954
1605
|
this.all = this.all.bind(this);
|
955
1606
|
this.not = this.not.bind(this);
|
@@ -960,83 +1611,121 @@ const _Query = class {
|
|
960
1611
|
Object.defineProperty(this, "repository", { enumerable: false });
|
961
1612
|
}
|
962
1613
|
getQueryOptions() {
|
963
|
-
return __privateGet$
|
1614
|
+
return __privateGet$5(this, _data);
|
964
1615
|
}
|
965
1616
|
key() {
|
966
|
-
const { columns = [], filter = {}, sort = [],
|
967
|
-
const key = JSON.stringify({ columns, filter, sort,
|
1617
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
|
1618
|
+
const key = JSON.stringify({ columns, filter, sort, pagination });
|
968
1619
|
return toBase64(key);
|
969
1620
|
}
|
970
1621
|
any(...queries) {
|
971
1622
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
972
|
-
return new _Query(__privateGet$
|
1623
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
973
1624
|
}
|
974
1625
|
all(...queries) {
|
975
1626
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
976
|
-
return new _Query(__privateGet$
|
1627
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
977
1628
|
}
|
978
1629
|
not(...queries) {
|
979
1630
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
980
|
-
return new _Query(__privateGet$
|
1631
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
981
1632
|
}
|
982
1633
|
none(...queries) {
|
983
1634
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
984
|
-
return new _Query(__privateGet$
|
1635
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
985
1636
|
}
|
986
1637
|
filter(a, b) {
|
987
1638
|
if (arguments.length === 1) {
|
988
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({
|
989
|
-
|
990
|
-
|
1639
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
1640
|
+
[column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
|
1641
|
+
}));
|
1642
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1643
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
991
1644
|
} else {
|
992
|
-
const
|
993
|
-
|
1645
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
1646
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1647
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
994
1648
|
}
|
995
1649
|
}
|
996
|
-
sort(column, direction) {
|
997
|
-
const originalSort = [__privateGet$
|
1650
|
+
sort(column, direction = "asc") {
|
1651
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
998
1652
|
const sort = [...originalSort, { column, direction }];
|
999
|
-
return new _Query(__privateGet$
|
1653
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1000
1654
|
}
|
1001
1655
|
select(columns) {
|
1002
|
-
return new _Query(
|
1656
|
+
return new _Query(
|
1657
|
+
__privateGet$5(this, _repository),
|
1658
|
+
__privateGet$5(this, _table$1),
|
1659
|
+
{ columns },
|
1660
|
+
__privateGet$5(this, _data)
|
1661
|
+
);
|
1003
1662
|
}
|
1004
1663
|
getPaginated(options = {}) {
|
1005
|
-
const query = new _Query(__privateGet$
|
1006
|
-
return __privateGet$
|
1664
|
+
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
1665
|
+
return __privateGet$5(this, _repository).query(query);
|
1007
1666
|
}
|
1008
1667
|
async *[Symbol.asyncIterator]() {
|
1009
|
-
for await (const [record] of this.getIterator(1)) {
|
1668
|
+
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
1010
1669
|
yield record;
|
1011
1670
|
}
|
1012
1671
|
}
|
1013
|
-
async *getIterator(
|
1014
|
-
|
1015
|
-
let
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1672
|
+
async *getIterator(options = {}) {
|
1673
|
+
const { batchSize = 1 } = options;
|
1674
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
1675
|
+
let more = page.hasNextPage();
|
1676
|
+
yield page.records;
|
1677
|
+
while (more) {
|
1678
|
+
page = await page.nextPage();
|
1679
|
+
more = page.hasNextPage();
|
1680
|
+
yield page.records;
|
1021
1681
|
}
|
1022
1682
|
}
|
1023
1683
|
async getMany(options = {}) {
|
1024
|
-
const {
|
1025
|
-
|
1684
|
+
const { pagination = {}, ...rest } = options;
|
1685
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
1686
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
1687
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
1688
|
+
const results = [...page.records];
|
1689
|
+
while (page.hasNextPage() && results.length < size) {
|
1690
|
+
page = await page.nextPage();
|
1691
|
+
results.push(...page.records);
|
1692
|
+
}
|
1693
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1694
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1695
|
+
}
|
1696
|
+
const array = new RecordArray(page, results.slice(0, size));
|
1697
|
+
return array;
|
1026
1698
|
}
|
1027
|
-
async getAll(
|
1699
|
+
async getAll(options = {}) {
|
1700
|
+
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
1028
1701
|
const results = [];
|
1029
|
-
for await (const page of this.getIterator(
|
1702
|
+
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
1030
1703
|
results.push(...page);
|
1031
1704
|
}
|
1032
1705
|
return results;
|
1033
1706
|
}
|
1034
1707
|
async getFirst(options = {}) {
|
1035
|
-
const records = await this.getMany({ ...options,
|
1036
|
-
return records[0]
|
1708
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1709
|
+
return records[0] ?? null;
|
1710
|
+
}
|
1711
|
+
async getFirstOrThrow(options = {}) {
|
1712
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1713
|
+
if (records[0] === void 0)
|
1714
|
+
throw new Error("No results found.");
|
1715
|
+
return records[0];
|
1716
|
+
}
|
1717
|
+
async summarize(params = {}) {
|
1718
|
+
const { summaries, summariesFilter, ...options } = params;
|
1719
|
+
const query = new _Query(
|
1720
|
+
__privateGet$5(this, _repository),
|
1721
|
+
__privateGet$5(this, _table$1),
|
1722
|
+
options,
|
1723
|
+
__privateGet$5(this, _data)
|
1724
|
+
);
|
1725
|
+
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
1037
1726
|
}
|
1038
1727
|
cache(ttl) {
|
1039
|
-
return new _Query(__privateGet$
|
1728
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1040
1729
|
}
|
1041
1730
|
nextPage(size, offset) {
|
1042
1731
|
return this.firstPage(size, offset);
|
@@ -1045,10 +1734,10 @@ const _Query = class {
|
|
1045
1734
|
return this.firstPage(size, offset);
|
1046
1735
|
}
|
1047
1736
|
firstPage(size, offset) {
|
1048
|
-
return this.getPaginated({
|
1737
|
+
return this.getPaginated({ pagination: { size, offset } });
|
1049
1738
|
}
|
1050
1739
|
lastPage(size, offset) {
|
1051
|
-
return this.getPaginated({
|
1740
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1052
1741
|
}
|
1053
1742
|
hasNextPage() {
|
1054
1743
|
return this.meta.page.more;
|
@@ -1058,12 +1747,31 @@ let Query = _Query;
|
|
1058
1747
|
_table$1 = new WeakMap();
|
1059
1748
|
_repository = new WeakMap();
|
1060
1749
|
_data = new WeakMap();
|
1750
|
+
_cleanFilterConstraint = new WeakSet();
|
1751
|
+
cleanFilterConstraint_fn = function(column, value) {
|
1752
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
1753
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
1754
|
+
return { $includes: value };
|
1755
|
+
}
|
1756
|
+
if (columnType === "link" && isObject(value) && isString(value.id)) {
|
1757
|
+
return value.id;
|
1758
|
+
}
|
1759
|
+
return value;
|
1760
|
+
};
|
1761
|
+
function cleanParent(data, parent) {
|
1762
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
1763
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
1764
|
+
}
|
1765
|
+
return parent;
|
1766
|
+
}
|
1061
1767
|
|
1062
1768
|
function isIdentifiable(x) {
|
1063
1769
|
return isObject(x) && isString(x?.id);
|
1064
1770
|
}
|
1065
1771
|
function isXataRecord(x) {
|
1066
|
-
|
1772
|
+
const record = x;
|
1773
|
+
const metadata = record?.getMetadata();
|
1774
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1067
1775
|
}
|
1068
1776
|
|
1069
1777
|
function isSortFilterString(value) {
|
@@ -1093,7 +1801,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
1093
1801
|
if (!member.has(obj))
|
1094
1802
|
throw TypeError("Cannot " + msg);
|
1095
1803
|
};
|
1096
|
-
var __privateGet$
|
1804
|
+
var __privateGet$4 = (obj, member, getter) => {
|
1097
1805
|
__accessCheck$4(obj, member, "read from private field");
|
1098
1806
|
return getter ? getter.call(obj) : member.get(obj);
|
1099
1807
|
};
|
@@ -1102,7 +1810,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
1102
1810
|
throw TypeError("Cannot add the same private member more than once");
|
1103
1811
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1104
1812
|
};
|
1105
|
-
var __privateSet$
|
1813
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
1106
1814
|
__accessCheck$4(obj, member, "write to private field");
|
1107
1815
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1108
1816
|
return value;
|
@@ -1111,304 +1819,444 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1111
1819
|
__accessCheck$4(obj, member, "access private method");
|
1112
1820
|
return method;
|
1113
1821
|
};
|
1114
|
-
var _table,
|
1822
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
1115
1823
|
class Repository extends Query {
|
1116
1824
|
}
|
1117
1825
|
class RestRepository extends Query {
|
1118
1826
|
constructor(options) {
|
1119
|
-
super(
|
1827
|
+
super(
|
1828
|
+
null,
|
1829
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
1830
|
+
{}
|
1831
|
+
);
|
1120
1832
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1121
1833
|
__privateAdd$4(this, _insertRecordWithId);
|
1122
1834
|
__privateAdd$4(this, _bulkInsertTableRecords);
|
1123
1835
|
__privateAdd$4(this, _updateRecordWithID);
|
1124
1836
|
__privateAdd$4(this, _upsertRecordWithID);
|
1125
1837
|
__privateAdd$4(this, _deleteRecord);
|
1126
|
-
__privateAdd$4(this, _invalidateCache);
|
1127
|
-
__privateAdd$4(this, _setCacheRecord);
|
1128
|
-
__privateAdd$4(this, _getCacheRecord);
|
1129
1838
|
__privateAdd$4(this, _setCacheQuery);
|
1130
1839
|
__privateAdd$4(this, _getCacheQuery);
|
1840
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
1131
1841
|
__privateAdd$4(this, _table, void 0);
|
1132
|
-
__privateAdd$4(this, _links, void 0);
|
1133
1842
|
__privateAdd$4(this, _getFetchProps, void 0);
|
1843
|
+
__privateAdd$4(this, _db, void 0);
|
1134
1844
|
__privateAdd$4(this, _cache, void 0);
|
1135
|
-
|
1136
|
-
|
1137
|
-
__privateSet$
|
1138
|
-
this
|
1139
|
-
__privateSet$
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
}
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
return record;
|
1153
|
-
}
|
1154
|
-
if (isObject(a) && isString(a.id)) {
|
1155
|
-
if (a.id === "")
|
1156
|
-
throw new Error("The id can't be empty");
|
1157
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
|
1158
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1159
|
-
return record;
|
1160
|
-
}
|
1161
|
-
if (isObject(a)) {
|
1162
|
-
const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
|
1163
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1164
|
-
return record;
|
1165
|
-
}
|
1166
|
-
throw new Error("Invalid arguments for create method");
|
1167
|
-
}
|
1168
|
-
async read(recordId) {
|
1169
|
-
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
|
1170
|
-
if (cacheRecord)
|
1171
|
-
return cacheRecord;
|
1172
|
-
const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
|
1173
|
-
try {
|
1174
|
-
const response = await getRecord({
|
1175
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
|
1176
|
-
...fetchProps
|
1845
|
+
__privateAdd$4(this, _schemaTables$2, void 0);
|
1846
|
+
__privateAdd$4(this, _trace, void 0);
|
1847
|
+
__privateSet$4(this, _table, options.table);
|
1848
|
+
__privateSet$4(this, _db, options.db);
|
1849
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1850
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
1851
|
+
__privateSet$4(this, _getFetchProps, async () => {
|
1852
|
+
const props = await options.pluginOptions.getFetchProps();
|
1853
|
+
return { ...props, sessionID: generateUUID() };
|
1854
|
+
});
|
1855
|
+
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1856
|
+
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1857
|
+
return trace(name, fn, {
|
1858
|
+
...options2,
|
1859
|
+
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
1860
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
1861
|
+
[TraceAttributes.VERSION]: VERSION
|
1177
1862
|
});
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1863
|
+
});
|
1864
|
+
}
|
1865
|
+
async create(a, b, c) {
|
1866
|
+
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
1867
|
+
if (Array.isArray(a)) {
|
1868
|
+
if (a.length === 0)
|
1869
|
+
return [];
|
1870
|
+
const columns = isStringArray(b) ? b : void 0;
|
1871
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
1182
1872
|
}
|
1183
|
-
|
1184
|
-
|
1873
|
+
if (isString(a) && isObject(b)) {
|
1874
|
+
if (a === "")
|
1875
|
+
throw new Error("The id can't be empty");
|
1876
|
+
const columns = isStringArray(c) ? c : void 0;
|
1877
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
1878
|
+
}
|
1879
|
+
if (isObject(a) && isString(a.id)) {
|
1880
|
+
if (a.id === "")
|
1881
|
+
throw new Error("The id can't be empty");
|
1882
|
+
const columns = isStringArray(b) ? b : void 0;
|
1883
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1884
|
+
}
|
1885
|
+
if (isObject(a)) {
|
1886
|
+
const columns = isStringArray(b) ? b : void 0;
|
1887
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
1888
|
+
}
|
1889
|
+
throw new Error("Invalid arguments for create method");
|
1890
|
+
});
|
1185
1891
|
}
|
1186
|
-
async
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1892
|
+
async read(a, b) {
|
1893
|
+
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
1894
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1895
|
+
if (Array.isArray(a)) {
|
1896
|
+
if (a.length === 0)
|
1897
|
+
return [];
|
1898
|
+
const ids = a.map((item) => extractId(item));
|
1899
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
|
1900
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
1901
|
+
acc[object.id] = object;
|
1902
|
+
return acc;
|
1903
|
+
}, {});
|
1904
|
+
return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
|
1190
1905
|
}
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1906
|
+
const id = extractId(a);
|
1907
|
+
if (id) {
|
1908
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1909
|
+
try {
|
1910
|
+
const response = await getRecord({
|
1911
|
+
pathParams: {
|
1912
|
+
workspace: "{workspaceId}",
|
1913
|
+
dbBranchName: "{dbBranch}",
|
1914
|
+
tableName: __privateGet$4(this, _table),
|
1915
|
+
recordId: id
|
1916
|
+
},
|
1917
|
+
queryParams: { columns },
|
1918
|
+
...fetchProps
|
1919
|
+
});
|
1920
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1921
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1922
|
+
} catch (e) {
|
1923
|
+
if (isObject(e) && e.status === 404) {
|
1924
|
+
return null;
|
1925
|
+
}
|
1926
|
+
throw e;
|
1927
|
+
}
|
1928
|
+
}
|
1929
|
+
return null;
|
1930
|
+
});
|
1206
1931
|
}
|
1207
|
-
async
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1932
|
+
async readOrThrow(a, b) {
|
1933
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
1934
|
+
const result = await this.read(a, b);
|
1935
|
+
if (Array.isArray(result)) {
|
1936
|
+
const missingIds = compact(
|
1937
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
1938
|
+
);
|
1939
|
+
if (missingIds.length > 0) {
|
1940
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
1941
|
+
}
|
1942
|
+
return result;
|
1211
1943
|
}
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
return record;
|
1219
|
-
}
|
1220
|
-
if (isObject(a) && isString(a.id)) {
|
1221
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1222
|
-
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
1223
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1224
|
-
return record;
|
1225
|
-
}
|
1226
|
-
throw new Error("Invalid arguments for createOrUpdate method");
|
1944
|
+
if (result === null) {
|
1945
|
+
const id = extractId(a) ?? "unknown";
|
1946
|
+
throw new Error(`Record with id ${id} not found`);
|
1947
|
+
}
|
1948
|
+
return result;
|
1949
|
+
});
|
1227
1950
|
}
|
1228
|
-
async
|
1229
|
-
|
1230
|
-
if (a
|
1231
|
-
|
1951
|
+
async update(a, b, c) {
|
1952
|
+
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
1953
|
+
if (Array.isArray(a)) {
|
1954
|
+
if (a.length === 0)
|
1955
|
+
return [];
|
1956
|
+
if (a.length > 100) {
|
1957
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1958
|
+
}
|
1959
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1960
|
+
return Promise.all(a.map((object) => this.update(object, columns)));
|
1232
1961
|
}
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1962
|
+
if (isString(a) && isObject(b)) {
|
1963
|
+
const columns = isStringArray(c) ? c : void 0;
|
1964
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
1965
|
+
}
|
1966
|
+
if (isObject(a) && isString(a.id)) {
|
1967
|
+
const columns = isStringArray(b) ? b : void 0;
|
1968
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1969
|
+
}
|
1970
|
+
throw new Error("Invalid arguments for update method");
|
1971
|
+
});
|
1972
|
+
}
|
1973
|
+
async updateOrThrow(a, b, c) {
|
1974
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
1975
|
+
const result = await this.update(a, b, c);
|
1976
|
+
if (Array.isArray(result)) {
|
1977
|
+
const missingIds = compact(
|
1978
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
1979
|
+
);
|
1980
|
+
if (missingIds.length > 0) {
|
1981
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
1982
|
+
}
|
1983
|
+
return result;
|
1984
|
+
}
|
1985
|
+
if (result === null) {
|
1986
|
+
const id = extractId(a) ?? "unknown";
|
1987
|
+
throw new Error(`Record with id ${id} not found`);
|
1988
|
+
}
|
1989
|
+
return result;
|
1990
|
+
});
|
1991
|
+
}
|
1992
|
+
async createOrUpdate(a, b, c) {
|
1993
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
1994
|
+
if (Array.isArray(a)) {
|
1995
|
+
if (a.length === 0)
|
1996
|
+
return [];
|
1997
|
+
if (a.length > 100) {
|
1998
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1999
|
+
}
|
2000
|
+
const columns = isStringArray(b) ? b : ["*"];
|
2001
|
+
return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
|
2002
|
+
}
|
2003
|
+
if (isString(a) && isObject(b)) {
|
2004
|
+
const columns = isStringArray(c) ? c : void 0;
|
2005
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
2006
|
+
}
|
2007
|
+
if (isObject(a) && isString(a.id)) {
|
2008
|
+
const columns = isStringArray(c) ? c : void 0;
|
2009
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
2010
|
+
}
|
2011
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
2012
|
+
});
|
2013
|
+
}
|
2014
|
+
async delete(a, b) {
|
2015
|
+
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
2016
|
+
if (Array.isArray(a)) {
|
2017
|
+
if (a.length === 0)
|
2018
|
+
return [];
|
2019
|
+
if (a.length > 100) {
|
2020
|
+
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
2021
|
+
}
|
2022
|
+
return Promise.all(a.map((id) => this.delete(id, b)));
|
2023
|
+
}
|
2024
|
+
if (isString(a)) {
|
2025
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
2026
|
+
}
|
2027
|
+
if (isObject(a) && isString(a.id)) {
|
2028
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
|
2029
|
+
}
|
2030
|
+
throw new Error("Invalid arguments for delete method");
|
2031
|
+
});
|
2032
|
+
}
|
2033
|
+
async deleteOrThrow(a, b) {
|
2034
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
2035
|
+
const result = await this.delete(a, b);
|
2036
|
+
if (Array.isArray(result)) {
|
2037
|
+
const missingIds = compact(
|
2038
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
2039
|
+
);
|
2040
|
+
if (missingIds.length > 0) {
|
2041
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
2042
|
+
}
|
2043
|
+
return result;
|
2044
|
+
} else if (result === null) {
|
2045
|
+
const id = extractId(a) ?? "unknown";
|
2046
|
+
throw new Error(`Record with id ${id} not found`);
|
2047
|
+
}
|
2048
|
+
return result;
|
2049
|
+
});
|
1247
2050
|
}
|
1248
2051
|
async search(query, options = {}) {
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
2052
|
+
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
2053
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2054
|
+
const { records } = await searchTable({
|
2055
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
2056
|
+
body: {
|
2057
|
+
query,
|
2058
|
+
fuzziness: options.fuzziness,
|
2059
|
+
prefix: options.prefix,
|
2060
|
+
highlight: options.highlight,
|
2061
|
+
filter: options.filter,
|
2062
|
+
boosters: options.boosters
|
2063
|
+
},
|
2064
|
+
...fetchProps
|
2065
|
+
});
|
2066
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2067
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2068
|
+
});
|
2069
|
+
}
|
2070
|
+
async aggregate(aggs, filter) {
|
2071
|
+
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2072
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2073
|
+
const result = await aggregateTable({
|
2074
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
2075
|
+
body: { aggs, filter },
|
2076
|
+
...fetchProps
|
2077
|
+
});
|
2078
|
+
return result;
|
1254
2079
|
});
|
1255
|
-
return records.map((item) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), item));
|
1256
2080
|
}
|
1257
2081
|
async query(query) {
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
2082
|
+
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
2083
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
2084
|
+
if (cacheQuery)
|
2085
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
2086
|
+
const data = query.getQueryOptions();
|
2087
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2088
|
+
const { meta, records: objects } = await queryTable({
|
2089
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
2090
|
+
body: {
|
2091
|
+
filter: cleanFilter(data.filter),
|
2092
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2093
|
+
page: data.pagination,
|
2094
|
+
columns: data.columns ?? ["*"]
|
2095
|
+
},
|
2096
|
+
...fetchProps
|
2097
|
+
});
|
2098
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2099
|
+
const records = objects.map(
|
2100
|
+
(record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
|
2101
|
+
);
|
2102
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
2103
|
+
return new Page(query, meta, records);
|
2104
|
+
});
|
2105
|
+
}
|
2106
|
+
async summarizeTable(query, summaries, summariesFilter) {
|
2107
|
+
return __privateGet$4(this, _trace).call(this, "summarize", async () => {
|
2108
|
+
const data = query.getQueryOptions();
|
2109
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2110
|
+
const result = await summarizeTable({
|
2111
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
2112
|
+
body: {
|
2113
|
+
filter: cleanFilter(data.filter),
|
2114
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
2115
|
+
columns: data.columns,
|
2116
|
+
summaries,
|
2117
|
+
summariesFilter
|
2118
|
+
},
|
2119
|
+
...fetchProps
|
2120
|
+
});
|
2121
|
+
return result;
|
1273
2122
|
});
|
1274
|
-
const records = objects.map((record) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), record));
|
1275
|
-
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1276
|
-
return new Page(query, meta, records);
|
1277
2123
|
}
|
1278
2124
|
}
|
1279
2125
|
_table = new WeakMap();
|
1280
|
-
_links = new WeakMap();
|
1281
2126
|
_getFetchProps = new WeakMap();
|
2127
|
+
_db = new WeakMap();
|
1282
2128
|
_cache = new WeakMap();
|
2129
|
+
_schemaTables$2 = new WeakMap();
|
2130
|
+
_trace = new WeakMap();
|
1283
2131
|
_insertRecordWithoutId = new WeakSet();
|
1284
|
-
insertRecordWithoutId_fn = async function(object) {
|
1285
|
-
const fetchProps = await __privateGet$
|
2132
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
2133
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1286
2134
|
const record = transformObjectLinks(object);
|
1287
2135
|
const response = await insertRecord({
|
1288
2136
|
pathParams: {
|
1289
2137
|
workspace: "{workspaceId}",
|
1290
2138
|
dbBranchName: "{dbBranch}",
|
1291
|
-
tableName: __privateGet$
|
2139
|
+
tableName: __privateGet$4(this, _table)
|
1292
2140
|
},
|
2141
|
+
queryParams: { columns },
|
1293
2142
|
body: record,
|
1294
2143
|
...fetchProps
|
1295
2144
|
});
|
1296
|
-
const
|
1297
|
-
|
1298
|
-
throw new Error("The server failed to save the record");
|
1299
|
-
}
|
1300
|
-
return finalObject;
|
2145
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2146
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1301
2147
|
};
|
1302
2148
|
_insertRecordWithId = new WeakSet();
|
1303
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
1304
|
-
const fetchProps = await __privateGet$
|
2149
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
2150
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1305
2151
|
const record = transformObjectLinks(object);
|
1306
2152
|
const response = await insertRecordWithID({
|
1307
2153
|
pathParams: {
|
1308
2154
|
workspace: "{workspaceId}",
|
1309
2155
|
dbBranchName: "{dbBranch}",
|
1310
|
-
tableName: __privateGet$
|
2156
|
+
tableName: __privateGet$4(this, _table),
|
1311
2157
|
recordId
|
1312
2158
|
},
|
1313
2159
|
body: record,
|
1314
|
-
queryParams: { createOnly: true },
|
2160
|
+
queryParams: { createOnly: true, columns },
|
1315
2161
|
...fetchProps
|
1316
2162
|
});
|
1317
|
-
const
|
1318
|
-
|
1319
|
-
throw new Error("The server failed to save the record");
|
1320
|
-
}
|
1321
|
-
return finalObject;
|
2163
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2164
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1322
2165
|
};
|
1323
2166
|
_bulkInsertTableRecords = new WeakSet();
|
1324
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
1325
|
-
const fetchProps = await __privateGet$
|
2167
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
2168
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1326
2169
|
const records = objects.map((object) => transformObjectLinks(object));
|
1327
2170
|
const response = await bulkInsertTableRecords({
|
1328
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
2171
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
2172
|
+
queryParams: { columns },
|
1329
2173
|
body: { records },
|
1330
2174
|
...fetchProps
|
1331
2175
|
});
|
1332
|
-
|
1333
|
-
|
1334
|
-
throw new Error("The server failed to save some records");
|
2176
|
+
if (!isResponseWithRecords(response)) {
|
2177
|
+
throw new Error("Request included columns but server didn't include them");
|
1335
2178
|
}
|
1336
|
-
|
2179
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2180
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, columns));
|
1337
2181
|
};
|
1338
2182
|
_updateRecordWithID = new WeakSet();
|
1339
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
1340
|
-
const fetchProps = await __privateGet$
|
2183
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2184
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1341
2185
|
const record = transformObjectLinks(object);
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
2186
|
+
try {
|
2187
|
+
const response = await updateRecordWithID({
|
2188
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
2189
|
+
queryParams: { columns },
|
2190
|
+
body: record,
|
2191
|
+
...fetchProps
|
2192
|
+
});
|
2193
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2194
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2195
|
+
} catch (e) {
|
2196
|
+
if (isObject(e) && e.status === 404) {
|
2197
|
+
return null;
|
2198
|
+
}
|
2199
|
+
throw e;
|
2200
|
+
}
|
1351
2201
|
};
|
1352
2202
|
_upsertRecordWithID = new WeakSet();
|
1353
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
1354
|
-
const fetchProps = await __privateGet$
|
2203
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
2204
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1355
2205
|
const response = await upsertRecordWithID({
|
1356
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
2206
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
2207
|
+
queryParams: { columns },
|
1357
2208
|
body: object,
|
1358
2209
|
...fetchProps
|
1359
2210
|
});
|
1360
|
-
const
|
1361
|
-
|
1362
|
-
throw new Error("The server failed to save the record");
|
1363
|
-
return item;
|
2211
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2212
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
1364
2213
|
};
|
1365
2214
|
_deleteRecord = new WeakSet();
|
1366
|
-
deleteRecord_fn = async function(recordId) {
|
1367
|
-
const fetchProps = await __privateGet$
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
await __privateGet$3(this, _cache).delete(key);
|
2215
|
+
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
2216
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2217
|
+
try {
|
2218
|
+
const response = await deleteRecord({
|
2219
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
2220
|
+
queryParams: { columns },
|
2221
|
+
...fetchProps
|
2222
|
+
});
|
2223
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2224
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
|
2225
|
+
} catch (e) {
|
2226
|
+
if (isObject(e) && e.status === 404) {
|
2227
|
+
return null;
|
2228
|
+
}
|
2229
|
+
throw e;
|
1382
2230
|
}
|
1383
2231
|
};
|
1384
|
-
_setCacheRecord = new WeakSet();
|
1385
|
-
setCacheRecord_fn = async function(record) {
|
1386
|
-
if (!__privateGet$3(this, _cache).cacheRecords)
|
1387
|
-
return;
|
1388
|
-
await __privateGet$3(this, _cache).set(`rec_${__privateGet$3(this, _table)}:${record.id}`, record);
|
1389
|
-
};
|
1390
|
-
_getCacheRecord = new WeakSet();
|
1391
|
-
getCacheRecord_fn = async function(recordId) {
|
1392
|
-
if (!__privateGet$3(this, _cache).cacheRecords)
|
1393
|
-
return null;
|
1394
|
-
return __privateGet$3(this, _cache).get(`rec_${__privateGet$3(this, _table)}:${recordId}`);
|
1395
|
-
};
|
1396
2232
|
_setCacheQuery = new WeakSet();
|
1397
2233
|
setCacheQuery_fn = async function(query, meta, records) {
|
1398
|
-
await __privateGet$
|
2234
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1399
2235
|
};
|
1400
2236
|
_getCacheQuery = new WeakSet();
|
1401
2237
|
getCacheQuery_fn = async function(query) {
|
1402
|
-
const key = `query_${__privateGet$
|
1403
|
-
const result = await __privateGet$
|
2238
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
2239
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
1404
2240
|
if (!result)
|
1405
2241
|
return null;
|
1406
|
-
const { cache: ttl = __privateGet$
|
1407
|
-
if (
|
1408
|
-
return
|
2242
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
2243
|
+
if (ttl < 0)
|
2244
|
+
return null;
|
1409
2245
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1410
2246
|
return hasExpired ? null : result;
|
1411
2247
|
};
|
2248
|
+
_getSchemaTables$1 = new WeakSet();
|
2249
|
+
getSchemaTables_fn$1 = async function() {
|
2250
|
+
if (__privateGet$4(this, _schemaTables$2))
|
2251
|
+
return __privateGet$4(this, _schemaTables$2);
|
2252
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2253
|
+
const { schema } = await getBranchDetails({
|
2254
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2255
|
+
...fetchProps
|
2256
|
+
});
|
2257
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
2258
|
+
return schema.tables;
|
2259
|
+
};
|
1412
2260
|
const transformObjectLinks = (object) => {
|
1413
2261
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
1414
2262
|
if (key === "xata")
|
@@ -1416,47 +2264,99 @@ const transformObjectLinks = (object) => {
|
|
1416
2264
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1417
2265
|
}, {});
|
1418
2266
|
};
|
1419
|
-
const initObject = (db,
|
2267
|
+
const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
1420
2268
|
const result = {};
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
2269
|
+
const { xata, ...rest } = object ?? {};
|
2270
|
+
Object.assign(result, rest);
|
2271
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
2272
|
+
if (!columns)
|
2273
|
+
console.error(`Table ${table} not found in schema`);
|
2274
|
+
for (const column of columns ?? []) {
|
2275
|
+
if (!isValidColumn(selectedColumns, column))
|
2276
|
+
continue;
|
2277
|
+
const value = result[column.name];
|
2278
|
+
switch (column.type) {
|
2279
|
+
case "datetime": {
|
2280
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
2281
|
+
if (date && isNaN(date.getTime())) {
|
2282
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
2283
|
+
} else if (date) {
|
2284
|
+
result[column.name] = date;
|
2285
|
+
}
|
2286
|
+
break;
|
2287
|
+
}
|
2288
|
+
case "link": {
|
2289
|
+
const linkTable = column.link?.table;
|
2290
|
+
if (!linkTable) {
|
2291
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
2292
|
+
} else if (isObject(value)) {
|
2293
|
+
const selectedLinkColumns = selectedColumns.reduce((acc, item) => {
|
2294
|
+
if (item === column.name) {
|
2295
|
+
return [...acc, "*"];
|
2296
|
+
}
|
2297
|
+
if (item.startsWith(`${column.name}.`)) {
|
2298
|
+
const [, ...path] = item.split(".");
|
2299
|
+
return [...acc, path.join(".")];
|
2300
|
+
}
|
2301
|
+
return acc;
|
2302
|
+
}, []);
|
2303
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
|
2304
|
+
} else {
|
2305
|
+
result[column.name] = null;
|
2306
|
+
}
|
2307
|
+
break;
|
2308
|
+
}
|
2309
|
+
default:
|
2310
|
+
result[column.name] = value ?? null;
|
2311
|
+
if (column.notNull === true && value === null) {
|
2312
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
2313
|
+
}
|
2314
|
+
break;
|
1428
2315
|
}
|
1429
2316
|
}
|
1430
|
-
result.read = function() {
|
1431
|
-
return db[table].read(result["id"]);
|
2317
|
+
result.read = function(columns2) {
|
2318
|
+
return db[table].read(result["id"], columns2);
|
1432
2319
|
};
|
1433
|
-
result.update = function(data) {
|
1434
|
-
return db[table].update(result["id"], data);
|
2320
|
+
result.update = function(data, columns2) {
|
2321
|
+
return db[table].update(result["id"], data, columns2);
|
1435
2322
|
};
|
1436
2323
|
result.delete = function() {
|
1437
2324
|
return db[table].delete(result["id"]);
|
1438
2325
|
};
|
1439
|
-
|
2326
|
+
result.getMetadata = function() {
|
2327
|
+
return xata;
|
2328
|
+
};
|
2329
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1440
2330
|
Object.defineProperty(result, prop, { enumerable: false });
|
1441
2331
|
}
|
1442
2332
|
Object.freeze(result);
|
1443
2333
|
return result;
|
1444
2334
|
};
|
1445
|
-
function
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
if (
|
1450
|
-
return
|
1451
|
-
|
1452
|
-
|
2335
|
+
function isResponseWithRecords(value) {
|
2336
|
+
return isObject(value) && Array.isArray(value.records);
|
2337
|
+
}
|
2338
|
+
function extractId(value) {
|
2339
|
+
if (isString(value))
|
2340
|
+
return value;
|
2341
|
+
if (isObject(value) && isString(value.id))
|
2342
|
+
return value.id;
|
2343
|
+
return void 0;
|
2344
|
+
}
|
2345
|
+
function isValidColumn(columns, column) {
|
2346
|
+
if (columns.includes("*"))
|
2347
|
+
return true;
|
2348
|
+
if (column.type === "link") {
|
2349
|
+
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
2350
|
+
return linkColumns.length > 0;
|
2351
|
+
}
|
2352
|
+
return columns.includes(column.name);
|
1453
2353
|
}
|
1454
2354
|
|
1455
2355
|
var __accessCheck$3 = (obj, member, msg) => {
|
1456
2356
|
if (!member.has(obj))
|
1457
2357
|
throw TypeError("Cannot " + msg);
|
1458
2358
|
};
|
1459
|
-
var __privateGet$
|
2359
|
+
var __privateGet$3 = (obj, member, getter) => {
|
1460
2360
|
__accessCheck$3(obj, member, "read from private field");
|
1461
2361
|
return getter ? getter.call(obj) : member.get(obj);
|
1462
2362
|
};
|
@@ -1465,7 +2365,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1465
2365
|
throw TypeError("Cannot add the same private member more than once");
|
1466
2366
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1467
2367
|
};
|
1468
|
-
var __privateSet$
|
2368
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1469
2369
|
__accessCheck$3(obj, member, "write to private field");
|
1470
2370
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1471
2371
|
return value;
|
@@ -1474,46 +2374,52 @@ var _map;
|
|
1474
2374
|
class SimpleCache {
|
1475
2375
|
constructor(options = {}) {
|
1476
2376
|
__privateAdd$3(this, _map, void 0);
|
1477
|
-
__privateSet$
|
2377
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
1478
2378
|
this.capacity = options.max ?? 500;
|
1479
|
-
this.cacheRecords = options.cacheRecords ?? true;
|
1480
2379
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1481
2380
|
}
|
1482
2381
|
async getAll() {
|
1483
|
-
return Object.fromEntries(__privateGet$
|
2382
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
1484
2383
|
}
|
1485
2384
|
async get(key) {
|
1486
|
-
return __privateGet$
|
2385
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
1487
2386
|
}
|
1488
2387
|
async set(key, value) {
|
1489
2388
|
await this.delete(key);
|
1490
|
-
__privateGet$
|
1491
|
-
if (__privateGet$
|
1492
|
-
const leastRecentlyUsed = __privateGet$
|
2389
|
+
__privateGet$3(this, _map).set(key, value);
|
2390
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
2391
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
1493
2392
|
await this.delete(leastRecentlyUsed);
|
1494
2393
|
}
|
1495
2394
|
}
|
1496
2395
|
async delete(key) {
|
1497
|
-
__privateGet$
|
2396
|
+
__privateGet$3(this, _map).delete(key);
|
1498
2397
|
}
|
1499
2398
|
async clear() {
|
1500
|
-
return __privateGet$
|
2399
|
+
return __privateGet$3(this, _map).clear();
|
1501
2400
|
}
|
1502
2401
|
}
|
1503
2402
|
_map = new WeakMap();
|
1504
2403
|
|
1505
|
-
const
|
1506
|
-
const
|
1507
|
-
const
|
1508
|
-
const
|
1509
|
-
const
|
1510
|
-
const
|
2404
|
+
const greaterThan = (value) => ({ $gt: value });
|
2405
|
+
const gt = greaterThan;
|
2406
|
+
const greaterThanEquals = (value) => ({ $ge: value });
|
2407
|
+
const greaterEquals = greaterThanEquals;
|
2408
|
+
const gte = greaterThanEquals;
|
2409
|
+
const ge = greaterThanEquals;
|
2410
|
+
const lessThan = (value) => ({ $lt: value });
|
2411
|
+
const lt = lessThan;
|
2412
|
+
const lessThanEquals = (value) => ({ $le: value });
|
2413
|
+
const lessEquals = lessThanEquals;
|
2414
|
+
const lte = lessThanEquals;
|
2415
|
+
const le = lessThanEquals;
|
1511
2416
|
const exists = (column) => ({ $exists: column });
|
1512
2417
|
const notExists = (column) => ({ $notExists: column });
|
1513
2418
|
const startsWith = (value) => ({ $startsWith: value });
|
1514
2419
|
const endsWith = (value) => ({ $endsWith: value });
|
1515
2420
|
const pattern = (value) => ({ $pattern: value });
|
1516
2421
|
const is = (value) => ({ $is: value });
|
2422
|
+
const equals = is;
|
1517
2423
|
const isNot = (value) => ({ $isNot: value });
|
1518
2424
|
const contains = (value) => ({ $contains: value });
|
1519
2425
|
const includes = (value) => ({ $includes: value });
|
@@ -1525,7 +2431,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
1525
2431
|
if (!member.has(obj))
|
1526
2432
|
throw TypeError("Cannot " + msg);
|
1527
2433
|
};
|
1528
|
-
var __privateGet$
|
2434
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1529
2435
|
__accessCheck$2(obj, member, "read from private field");
|
1530
2436
|
return getter ? getter.call(obj) : member.get(obj);
|
1531
2437
|
};
|
@@ -1534,130 +2440,178 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1534
2440
|
throw TypeError("Cannot add the same private member more than once");
|
1535
2441
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1536
2442
|
};
|
1537
|
-
var
|
2443
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
2444
|
+
__accessCheck$2(obj, member, "write to private field");
|
2445
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
2446
|
+
return value;
|
2447
|
+
};
|
2448
|
+
var _tables, _schemaTables$1;
|
1538
2449
|
class SchemaPlugin extends XataPlugin {
|
1539
|
-
constructor(
|
2450
|
+
constructor(schemaTables) {
|
1540
2451
|
super();
|
1541
|
-
this.links = links;
|
1542
|
-
this.tableNames = tableNames;
|
1543
2452
|
__privateAdd$2(this, _tables, {});
|
2453
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
2454
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
1544
2455
|
}
|
1545
2456
|
build(pluginOptions) {
|
1546
|
-
const
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
__privateGet$
|
2457
|
+
const db = new Proxy(
|
2458
|
+
{},
|
2459
|
+
{
|
2460
|
+
get: (_target, table) => {
|
2461
|
+
if (!isString(table))
|
2462
|
+
throw new Error("Invalid table name");
|
2463
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
2464
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
2465
|
+
}
|
2466
|
+
return __privateGet$2(this, _tables)[table];
|
1553
2467
|
}
|
1554
|
-
return __privateGet$1(this, _tables)[table];
|
1555
2468
|
}
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
2469
|
+
);
|
2470
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
2471
|
+
for (const table of tableNames) {
|
2472
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1559
2473
|
}
|
1560
2474
|
return db;
|
1561
2475
|
}
|
1562
2476
|
}
|
1563
2477
|
_tables = new WeakMap();
|
2478
|
+
_schemaTables$1 = new WeakMap();
|
1564
2479
|
|
1565
2480
|
var __accessCheck$1 = (obj, member, msg) => {
|
1566
2481
|
if (!member.has(obj))
|
1567
2482
|
throw TypeError("Cannot " + msg);
|
1568
2483
|
};
|
2484
|
+
var __privateGet$1 = (obj, member, getter) => {
|
2485
|
+
__accessCheck$1(obj, member, "read from private field");
|
2486
|
+
return getter ? getter.call(obj) : member.get(obj);
|
2487
|
+
};
|
1569
2488
|
var __privateAdd$1 = (obj, member, value) => {
|
1570
2489
|
if (member.has(obj))
|
1571
2490
|
throw TypeError("Cannot add the same private member more than once");
|
1572
2491
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1573
2492
|
};
|
2493
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
2494
|
+
__accessCheck$1(obj, member, "write to private field");
|
2495
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
2496
|
+
return value;
|
2497
|
+
};
|
1574
2498
|
var __privateMethod$1 = (obj, member, method) => {
|
1575
2499
|
__accessCheck$1(obj, member, "access private method");
|
1576
2500
|
return method;
|
1577
2501
|
};
|
1578
|
-
var _search, search_fn;
|
2502
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
1579
2503
|
class SearchPlugin extends XataPlugin {
|
1580
|
-
constructor(db,
|
2504
|
+
constructor(db, schemaTables) {
|
1581
2505
|
super();
|
1582
2506
|
this.db = db;
|
1583
|
-
this.links = links;
|
1584
2507
|
__privateAdd$1(this, _search);
|
2508
|
+
__privateAdd$1(this, _getSchemaTables);
|
2509
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
2510
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
1585
2511
|
}
|
1586
2512
|
build({ getFetchProps }) {
|
1587
2513
|
return {
|
1588
2514
|
all: async (query, options = {}) => {
|
1589
2515
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
2516
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1590
2517
|
return records.map((record) => {
|
1591
2518
|
const { table = "orphan" } = record.xata;
|
1592
|
-
return { table, record: initObject(this.db,
|
2519
|
+
return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
|
1593
2520
|
});
|
1594
2521
|
},
|
1595
2522
|
byTable: async (query, options = {}) => {
|
1596
2523
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
2524
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1597
2525
|
return records.reduce((acc, record) => {
|
1598
2526
|
const { table = "orphan" } = record.xata;
|
1599
2527
|
const items = acc[table] ?? [];
|
1600
|
-
const item = initObject(this.db,
|
2528
|
+
const item = initObject(this.db, schemaTables, table, record, ["*"]);
|
1601
2529
|
return { ...acc, [table]: [...items, item] };
|
1602
2530
|
}, {});
|
1603
2531
|
}
|
1604
2532
|
};
|
1605
2533
|
}
|
1606
2534
|
}
|
2535
|
+
_schemaTables = new WeakMap();
|
1607
2536
|
_search = new WeakSet();
|
1608
2537
|
search_fn = async function(query, options, getFetchProps) {
|
1609
2538
|
const fetchProps = await getFetchProps();
|
1610
|
-
const { tables, fuzziness } = options ?? {};
|
2539
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
1611
2540
|
const { records } = await searchBranch({
|
1612
2541
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1613
|
-
body: { tables, query, fuzziness },
|
2542
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1614
2543
|
...fetchProps
|
1615
2544
|
});
|
1616
2545
|
return records;
|
1617
2546
|
};
|
2547
|
+
_getSchemaTables = new WeakSet();
|
2548
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
2549
|
+
if (__privateGet$1(this, _schemaTables))
|
2550
|
+
return __privateGet$1(this, _schemaTables);
|
2551
|
+
const fetchProps = await getFetchProps();
|
2552
|
+
const { schema } = await getBranchDetails({
|
2553
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2554
|
+
...fetchProps
|
2555
|
+
});
|
2556
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
2557
|
+
return schema.tables;
|
2558
|
+
};
|
1618
2559
|
|
1619
2560
|
const isBranchStrategyBuilder = (strategy) => {
|
1620
2561
|
return typeof strategy === "function";
|
1621
2562
|
};
|
1622
2563
|
|
1623
|
-
const envBranchNames = [
|
1624
|
-
"XATA_BRANCH",
|
1625
|
-
"VERCEL_GIT_COMMIT_REF",
|
1626
|
-
"CF_PAGES_BRANCH",
|
1627
|
-
"BRANCH"
|
1628
|
-
];
|
1629
|
-
const defaultBranch = "main";
|
1630
2564
|
async function getCurrentBranchName(options) {
|
1631
|
-
const
|
1632
|
-
if (
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
return defaultBranch;
|
2565
|
+
const { branch, envBranch } = getEnvironment();
|
2566
|
+
if (branch) {
|
2567
|
+
const details = await getDatabaseBranch(branch, options);
|
2568
|
+
if (details)
|
2569
|
+
return branch;
|
2570
|
+
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
2571
|
+
}
|
2572
|
+
const gitBranch = envBranch || await getGitBranch();
|
2573
|
+
return resolveXataBranch(gitBranch, options);
|
1641
2574
|
}
|
1642
2575
|
async function getCurrentBranchDetails(options) {
|
1643
|
-
const
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
2576
|
+
const branch = await getCurrentBranchName(options);
|
2577
|
+
return getDatabaseBranch(branch, options);
|
2578
|
+
}
|
2579
|
+
async function resolveXataBranch(gitBranch, options) {
|
2580
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2581
|
+
const apiKey = options?.apiKey || getAPIKey();
|
2582
|
+
if (!databaseURL)
|
2583
|
+
throw new Error(
|
2584
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
2585
|
+
);
|
2586
|
+
if (!apiKey)
|
2587
|
+
throw new Error(
|
2588
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2589
|
+
);
|
2590
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2591
|
+
const [workspace] = host.split(".");
|
2592
|
+
const { fallbackBranch } = getEnvironment();
|
2593
|
+
const { branch } = await resolveBranch({
|
2594
|
+
apiKey,
|
2595
|
+
apiUrl: databaseURL,
|
2596
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2597
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
2598
|
+
pathParams: { dbName, workspace },
|
2599
|
+
queryParams: { gitBranch, fallbackBranch },
|
2600
|
+
trace: defaultTrace
|
2601
|
+
});
|
2602
|
+
return branch;
|
1653
2603
|
}
|
1654
2604
|
async function getDatabaseBranch(branch, options) {
|
1655
2605
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1656
2606
|
const apiKey = options?.apiKey || getAPIKey();
|
1657
2607
|
if (!databaseURL)
|
1658
|
-
throw new Error(
|
2608
|
+
throw new Error(
|
2609
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
2610
|
+
);
|
1659
2611
|
if (!apiKey)
|
1660
|
-
throw new Error(
|
2612
|
+
throw new Error(
|
2613
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2614
|
+
);
|
1661
2615
|
const [protocol, , host, , database] = databaseURL.split("/");
|
1662
2616
|
const [workspace] = host.split(".");
|
1663
2617
|
const dbBranchName = `${database}:${branch}`;
|
@@ -1667,10 +2621,8 @@ async function getDatabaseBranch(branch, options) {
|
|
1667
2621
|
apiUrl: databaseURL,
|
1668
2622
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1669
2623
|
workspacesApiUrl: `${protocol}//${host}`,
|
1670
|
-
pathParams: {
|
1671
|
-
|
1672
|
-
workspace
|
1673
|
-
}
|
2624
|
+
pathParams: { dbBranchName, workspace },
|
2625
|
+
trace: defaultTrace
|
1674
2626
|
});
|
1675
2627
|
} catch (err) {
|
1676
2628
|
if (isObject(err) && err.status === 404)
|
@@ -1678,21 +2630,10 @@ async function getDatabaseBranch(branch, options) {
|
|
1678
2630
|
throw err;
|
1679
2631
|
}
|
1680
2632
|
}
|
1681
|
-
function getBranchByEnvVariable() {
|
1682
|
-
for (const name of envBranchNames) {
|
1683
|
-
const value = getEnvVariable(name);
|
1684
|
-
if (value) {
|
1685
|
-
return value;
|
1686
|
-
}
|
1687
|
-
}
|
1688
|
-
try {
|
1689
|
-
return XATA_BRANCH;
|
1690
|
-
} catch (err) {
|
1691
|
-
}
|
1692
|
-
}
|
1693
2633
|
function getDatabaseURL() {
|
1694
2634
|
try {
|
1695
|
-
|
2635
|
+
const { databaseURL } = getEnvironment();
|
2636
|
+
return databaseURL;
|
1696
2637
|
} catch (err) {
|
1697
2638
|
return void 0;
|
1698
2639
|
}
|
@@ -1721,24 +2662,27 @@ var __privateMethod = (obj, member, method) => {
|
|
1721
2662
|
return method;
|
1722
2663
|
};
|
1723
2664
|
const buildClient = (plugins) => {
|
1724
|
-
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
2665
|
+
var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1725
2666
|
return _a = class {
|
1726
|
-
constructor(options = {},
|
2667
|
+
constructor(options = {}, schemaTables) {
|
1727
2668
|
__privateAdd(this, _parseOptions);
|
1728
2669
|
__privateAdd(this, _getFetchProps);
|
1729
2670
|
__privateAdd(this, _evaluateBranch);
|
1730
2671
|
__privateAdd(this, _branch, void 0);
|
2672
|
+
__privateAdd(this, _options, void 0);
|
1731
2673
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
2674
|
+
__privateSet(this, _options, safeOptions);
|
1732
2675
|
const pluginOptions = {
|
1733
2676
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1734
|
-
cache: safeOptions.cache
|
2677
|
+
cache: safeOptions.cache,
|
2678
|
+
trace: safeOptions.trace
|
1735
2679
|
};
|
1736
|
-
const db = new SchemaPlugin(
|
1737
|
-
const search = new SearchPlugin(db,
|
2680
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
2681
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
1738
2682
|
this.db = db;
|
1739
2683
|
this.search = search;
|
1740
2684
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1741
|
-
if (
|
2685
|
+
if (namespace === void 0)
|
1742
2686
|
continue;
|
1743
2687
|
const result = namespace.build(pluginOptions);
|
1744
2688
|
if (result instanceof Promise) {
|
@@ -1750,21 +2694,32 @@ const buildClient = (plugins) => {
|
|
1750
2694
|
}
|
1751
2695
|
}
|
1752
2696
|
}
|
1753
|
-
|
2697
|
+
async getConfig() {
|
2698
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
2699
|
+
const branch = await __privateGet(this, _options).branch();
|
2700
|
+
return { databaseURL, branch };
|
2701
|
+
}
|
2702
|
+
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
1754
2703
|
const fetch = getFetchImplementation(options?.fetch);
|
1755
2704
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1756
2705
|
const apiKey = options?.apiKey || getAPIKey();
|
1757
|
-
const cache = options?.cache ?? new SimpleCache({
|
1758
|
-
const
|
1759
|
-
|
1760
|
-
|
2706
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
2707
|
+
const trace = options?.trace ?? defaultTrace;
|
2708
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
2709
|
+
if (!apiKey) {
|
2710
|
+
throw new Error("Option apiKey is required");
|
2711
|
+
}
|
2712
|
+
if (!databaseURL) {
|
2713
|
+
throw new Error("Option databaseURL is required");
|
1761
2714
|
}
|
1762
|
-
return { fetch, databaseURL, apiKey, branch, cache };
|
2715
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID() };
|
1763
2716
|
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
1764
2717
|
fetch,
|
1765
2718
|
apiKey,
|
1766
2719
|
databaseURL,
|
1767
|
-
branch
|
2720
|
+
branch,
|
2721
|
+
trace,
|
2722
|
+
clientID
|
1768
2723
|
}) {
|
1769
2724
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
1770
2725
|
if (!branchValue)
|
@@ -1775,14 +2730,16 @@ const buildClient = (plugins) => {
|
|
1775
2730
|
apiUrl: "",
|
1776
2731
|
workspacesApiUrl: (path, params) => {
|
1777
2732
|
const hasBranch = params.dbBranchName ?? params.branch;
|
1778
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
2733
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
1779
2734
|
return databaseURL + newPath;
|
1780
|
-
}
|
2735
|
+
},
|
2736
|
+
trace,
|
2737
|
+
clientID
|
1781
2738
|
};
|
1782
2739
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1783
2740
|
if (__privateGet(this, _branch))
|
1784
2741
|
return __privateGet(this, _branch);
|
1785
|
-
if (
|
2742
|
+
if (param === void 0)
|
1786
2743
|
return void 0;
|
1787
2744
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1788
2745
|
const evaluateBranch = async (strategy) => {
|
@@ -1800,6 +2757,88 @@ const buildClient = (plugins) => {
|
|
1800
2757
|
class BaseClient extends buildClient() {
|
1801
2758
|
}
|
1802
2759
|
|
2760
|
+
const META = "__";
|
2761
|
+
const VALUE = "___";
|
2762
|
+
class Serializer {
|
2763
|
+
constructor() {
|
2764
|
+
this.classes = {};
|
2765
|
+
}
|
2766
|
+
add(clazz) {
|
2767
|
+
this.classes[clazz.name] = clazz;
|
2768
|
+
}
|
2769
|
+
toJSON(data) {
|
2770
|
+
function visit(obj) {
|
2771
|
+
if (Array.isArray(obj))
|
2772
|
+
return obj.map(visit);
|
2773
|
+
const type = typeof obj;
|
2774
|
+
if (type === "undefined")
|
2775
|
+
return { [META]: "undefined" };
|
2776
|
+
if (type === "bigint")
|
2777
|
+
return { [META]: "bigint", [VALUE]: obj.toString() };
|
2778
|
+
if (obj === null || type !== "object")
|
2779
|
+
return obj;
|
2780
|
+
const constructor = obj.constructor;
|
2781
|
+
const o = { [META]: constructor.name };
|
2782
|
+
for (const [key, value] of Object.entries(obj)) {
|
2783
|
+
o[key] = visit(value);
|
2784
|
+
}
|
2785
|
+
if (constructor === Date)
|
2786
|
+
o[VALUE] = obj.toISOString();
|
2787
|
+
if (constructor === Map)
|
2788
|
+
o[VALUE] = Object.fromEntries(obj);
|
2789
|
+
if (constructor === Set)
|
2790
|
+
o[VALUE] = [...obj];
|
2791
|
+
return o;
|
2792
|
+
}
|
2793
|
+
return JSON.stringify(visit(data));
|
2794
|
+
}
|
2795
|
+
fromJSON(json) {
|
2796
|
+
return JSON.parse(json, (key, value) => {
|
2797
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
2798
|
+
const { [META]: clazz, [VALUE]: val, ...rest } = value;
|
2799
|
+
const constructor = this.classes[clazz];
|
2800
|
+
if (constructor) {
|
2801
|
+
return Object.assign(Object.create(constructor.prototype), rest);
|
2802
|
+
}
|
2803
|
+
if (clazz === "Date")
|
2804
|
+
return new Date(val);
|
2805
|
+
if (clazz === "Set")
|
2806
|
+
return new Set(val);
|
2807
|
+
if (clazz === "Map")
|
2808
|
+
return new Map(Object.entries(val));
|
2809
|
+
if (clazz === "bigint")
|
2810
|
+
return BigInt(val);
|
2811
|
+
if (clazz === "undefined")
|
2812
|
+
return void 0;
|
2813
|
+
return rest;
|
2814
|
+
}
|
2815
|
+
return value;
|
2816
|
+
});
|
2817
|
+
}
|
2818
|
+
}
|
2819
|
+
const defaultSerializer = new Serializer();
|
2820
|
+
const serialize = (data) => {
|
2821
|
+
return defaultSerializer.toJSON(data);
|
2822
|
+
};
|
2823
|
+
const deserialize = (json) => {
|
2824
|
+
return defaultSerializer.fromJSON(json);
|
2825
|
+
};
|
2826
|
+
|
2827
|
+
function buildWorkerRunner(config) {
|
2828
|
+
return function xataWorker(name, _worker) {
|
2829
|
+
return async (...args) => {
|
2830
|
+
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
2831
|
+
const result = await fetch(url, {
|
2832
|
+
method: "POST",
|
2833
|
+
headers: { "Content-Type": "application/json" },
|
2834
|
+
body: serialize({ args })
|
2835
|
+
});
|
2836
|
+
const text = await result.text();
|
2837
|
+
return deserialize(text);
|
2838
|
+
};
|
2839
|
+
};
|
2840
|
+
}
|
2841
|
+
|
1803
2842
|
class XataError extends Error {
|
1804
2843
|
constructor(message, status) {
|
1805
2844
|
super(message);
|
@@ -1815,23 +2854,38 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
|
|
1815
2854
|
exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
1816
2855
|
exports.Page = Page;
|
1817
2856
|
exports.Query = Query;
|
2857
|
+
exports.RecordArray = RecordArray;
|
1818
2858
|
exports.Repository = Repository;
|
1819
2859
|
exports.RestRepository = RestRepository;
|
1820
2860
|
exports.SchemaPlugin = SchemaPlugin;
|
1821
2861
|
exports.SearchPlugin = SearchPlugin;
|
2862
|
+
exports.Serializer = Serializer;
|
1822
2863
|
exports.SimpleCache = SimpleCache;
|
1823
2864
|
exports.XataApiClient = XataApiClient;
|
1824
2865
|
exports.XataApiPlugin = XataApiPlugin;
|
1825
2866
|
exports.XataError = XataError;
|
1826
2867
|
exports.XataPlugin = XataPlugin;
|
1827
2868
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2869
|
+
exports.addGitBranchesEntry = addGitBranchesEntry;
|
1828
2870
|
exports.addTableColumn = addTableColumn;
|
2871
|
+
exports.aggregateTable = aggregateTable;
|
2872
|
+
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
1829
2873
|
exports.buildClient = buildClient;
|
2874
|
+
exports.buildWorkerRunner = buildWorkerRunner;
|
1830
2875
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
2876
|
+
exports.cPCreateDatabase = cPCreateDatabase;
|
2877
|
+
exports.cPDeleteDatabase = cPDeleteDatabase;
|
2878
|
+
exports.cPGetCPDatabaseMetadata = cPGetCPDatabaseMetadata;
|
2879
|
+
exports.cPGetDatabaseList = cPGetDatabaseList;
|
2880
|
+
exports.cPUpdateCPDatabaseMetadata = cPUpdateCPDatabaseMetadata;
|
1831
2881
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
2882
|
+
exports.compareBranchSchemas = compareBranchSchemas;
|
2883
|
+
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
2884
|
+
exports.compareMigrationRequest = compareMigrationRequest;
|
1832
2885
|
exports.contains = contains;
|
1833
2886
|
exports.createBranch = createBranch;
|
1834
2887
|
exports.createDatabase = createDatabase;
|
2888
|
+
exports.createMigrationRequest = createMigrationRequest;
|
1835
2889
|
exports.createTable = createTable;
|
1836
2890
|
exports.createUserAPIKey = createUserAPIKey;
|
1837
2891
|
exports.createWorkspace = createWorkspace;
|
@@ -1843,7 +2897,9 @@ exports.deleteTable = deleteTable;
|
|
1843
2897
|
exports.deleteUser = deleteUser;
|
1844
2898
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
1845
2899
|
exports.deleteWorkspace = deleteWorkspace;
|
2900
|
+
exports.deserialize = deserialize;
|
1846
2901
|
exports.endsWith = endsWith;
|
2902
|
+
exports.equals = equals;
|
1847
2903
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
1848
2904
|
exports.exists = exists;
|
1849
2905
|
exports.ge = ge;
|
@@ -1853,12 +2909,18 @@ exports.getBranchList = getBranchList;
|
|
1853
2909
|
exports.getBranchMetadata = getBranchMetadata;
|
1854
2910
|
exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
1855
2911
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
2912
|
+
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
1856
2913
|
exports.getBranchStats = getBranchStats;
|
1857
2914
|
exports.getColumn = getColumn;
|
1858
2915
|
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
1859
2916
|
exports.getCurrentBranchName = getCurrentBranchName;
|
1860
2917
|
exports.getDatabaseList = getDatabaseList;
|
2918
|
+
exports.getDatabaseMetadata = getDatabaseMetadata;
|
1861
2919
|
exports.getDatabaseURL = getDatabaseURL;
|
2920
|
+
exports.getGitBranchesMapping = getGitBranchesMapping;
|
2921
|
+
exports.getHostUrl = getHostUrl;
|
2922
|
+
exports.getMigrationRequest = getMigrationRequest;
|
2923
|
+
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
1862
2924
|
exports.getRecord = getRecord;
|
1863
2925
|
exports.getTableColumns = getTableColumns;
|
1864
2926
|
exports.getTableSchema = getTableSchema;
|
@@ -1867,6 +2929,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
|
|
1867
2929
|
exports.getWorkspace = getWorkspace;
|
1868
2930
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
1869
2931
|
exports.getWorkspacesList = getWorkspacesList;
|
2932
|
+
exports.greaterEquals = greaterEquals;
|
2933
|
+
exports.greaterThan = greaterThan;
|
2934
|
+
exports.greaterThanEquals = greaterThanEquals;
|
1870
2935
|
exports.gt = gt;
|
1871
2936
|
exports.gte = gte;
|
1872
2937
|
exports.includes = includes;
|
@@ -1877,27 +2942,48 @@ exports.insertRecord = insertRecord;
|
|
1877
2942
|
exports.insertRecordWithID = insertRecordWithID;
|
1878
2943
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
1879
2944
|
exports.is = is;
|
2945
|
+
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
2946
|
+
exports.isHostProviderAlias = isHostProviderAlias;
|
2947
|
+
exports.isHostProviderBuilder = isHostProviderBuilder;
|
1880
2948
|
exports.isIdentifiable = isIdentifiable;
|
1881
2949
|
exports.isNot = isNot;
|
1882
2950
|
exports.isXataRecord = isXataRecord;
|
1883
2951
|
exports.le = le;
|
2952
|
+
exports.lessEquals = lessEquals;
|
2953
|
+
exports.lessThan = lessThan;
|
2954
|
+
exports.lessThanEquals = lessThanEquals;
|
2955
|
+
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
2956
|
+
exports.listRegions = listRegions;
|
1884
2957
|
exports.lt = lt;
|
1885
2958
|
exports.lte = lte;
|
2959
|
+
exports.mergeMigrationRequest = mergeMigrationRequest;
|
1886
2960
|
exports.notExists = notExists;
|
1887
2961
|
exports.operationsByTag = operationsByTag;
|
2962
|
+
exports.parseProviderString = parseProviderString;
|
1888
2963
|
exports.pattern = pattern;
|
2964
|
+
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
2965
|
+
exports.queryMigrationRequests = queryMigrationRequests;
|
1889
2966
|
exports.queryTable = queryTable;
|
2967
|
+
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
1890
2968
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
1891
2969
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
2970
|
+
exports.resolveBranch = resolveBranch;
|
1892
2971
|
exports.searchBranch = searchBranch;
|
2972
|
+
exports.searchTable = searchTable;
|
2973
|
+
exports.serialize = serialize;
|
1893
2974
|
exports.setTableSchema = setTableSchema;
|
1894
2975
|
exports.startsWith = startsWith;
|
2976
|
+
exports.summarizeTable = summarizeTable;
|
1895
2977
|
exports.updateBranchMetadata = updateBranchMetadata;
|
2978
|
+
exports.updateBranchSchema = updateBranchSchema;
|
1896
2979
|
exports.updateColumn = updateColumn;
|
2980
|
+
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
2981
|
+
exports.updateMigrationRequest = updateMigrationRequest;
|
1897
2982
|
exports.updateRecordWithID = updateRecordWithID;
|
1898
2983
|
exports.updateTable = updateTable;
|
1899
2984
|
exports.updateUser = updateUser;
|
1900
2985
|
exports.updateWorkspace = updateWorkspace;
|
2986
|
+
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
1901
2987
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
1902
2988
|
exports.upsertRecordWithID = upsertRecordWithID;
|
1903
2989
|
//# sourceMappingURL=index.cjs.map
|