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