@xata.io/client 0.0.0-alpha.ved00a04 → 0.0.0-alpha.ved155c7
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 +230 -0
- package/README.md +273 -1
- package/Usage.md +449 -0
- package/dist/index.cjs +1215 -520
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1874 -372
- package/dist/index.mjs +1165 -520
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- package/tsconfig.json +1 -0
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
function _interopNamespace(e) {
|
|
6
|
+
if (e && e.__esModule) return e;
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n["default"] = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const defaultTrace = async (_name, fn, _options) => {
|
|
24
|
+
return await fn({
|
|
25
|
+
setAttributes: () => {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const TraceAttributes = {
|
|
31
|
+
KIND: "xata.trace.kind",
|
|
32
|
+
VERSION: "xata.sdk.version",
|
|
33
|
+
TABLE: "xata.table",
|
|
34
|
+
HTTP_REQUEST_ID: "http.request_id",
|
|
35
|
+
HTTP_STATUS_CODE: "http.status_code",
|
|
36
|
+
HTTP_HOST: "http.host",
|
|
37
|
+
HTTP_SCHEME: "http.scheme",
|
|
38
|
+
HTTP_USER_AGENT: "http.user_agent",
|
|
39
|
+
HTTP_METHOD: "http.method",
|
|
40
|
+
HTTP_URL: "http.url",
|
|
41
|
+
HTTP_ROUTE: "http.route",
|
|
42
|
+
HTTP_TARGET: "http.target"
|
|
43
|
+
};
|
|
44
|
+
|
|
5
45
|
function notEmpty(value) {
|
|
6
46
|
return value !== null && value !== void 0;
|
|
7
47
|
}
|
|
@@ -11,43 +51,101 @@ function compact(arr) {
|
|
|
11
51
|
function isObject(value) {
|
|
12
52
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
13
53
|
}
|
|
54
|
+
function isDefined(value) {
|
|
55
|
+
return value !== null && value !== void 0;
|
|
56
|
+
}
|
|
14
57
|
function isString(value) {
|
|
15
|
-
return value
|
|
58
|
+
return isDefined(value) && typeof value === "string";
|
|
59
|
+
}
|
|
60
|
+
function isStringArray(value) {
|
|
61
|
+
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
|
16
62
|
}
|
|
17
63
|
function toBase64(value) {
|
|
18
64
|
try {
|
|
19
65
|
return btoa(value);
|
|
20
66
|
} catch (err) {
|
|
21
|
-
|
|
67
|
+
const buf = Buffer;
|
|
68
|
+
return buf.from(value).toString("base64");
|
|
22
69
|
}
|
|
23
70
|
}
|
|
24
71
|
|
|
25
|
-
function
|
|
72
|
+
function getEnvironment() {
|
|
26
73
|
try {
|
|
27
|
-
if (isObject(process) &&
|
|
28
|
-
return
|
|
74
|
+
if (isObject(process) && isObject(process.env)) {
|
|
75
|
+
return {
|
|
76
|
+
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
|
77
|
+
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
|
78
|
+
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
|
79
|
+
envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
|
|
80
|
+
fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
|
|
81
|
+
};
|
|
29
82
|
}
|
|
30
83
|
} catch (err) {
|
|
31
84
|
}
|
|
32
85
|
try {
|
|
33
|
-
if (isObject(Deno) &&
|
|
34
|
-
return
|
|
86
|
+
if (isObject(Deno) && isObject(Deno.env)) {
|
|
87
|
+
return {
|
|
88
|
+
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
|
89
|
+
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
|
90
|
+
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
|
91
|
+
envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
|
|
92
|
+
fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
|
|
93
|
+
};
|
|
35
94
|
}
|
|
36
95
|
} catch (err) {
|
|
37
96
|
}
|
|
97
|
+
return {
|
|
98
|
+
apiKey: getGlobalApiKey(),
|
|
99
|
+
databaseURL: getGlobalDatabaseURL(),
|
|
100
|
+
branch: getGlobalBranch(),
|
|
101
|
+
envBranch: void 0,
|
|
102
|
+
fallbackBranch: getGlobalFallbackBranch()
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function getGlobalApiKey() {
|
|
106
|
+
try {
|
|
107
|
+
return XATA_API_KEY;
|
|
108
|
+
} catch (err) {
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function getGlobalDatabaseURL() {
|
|
113
|
+
try {
|
|
114
|
+
return XATA_DATABASE_URL;
|
|
115
|
+
} catch (err) {
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function getGlobalBranch() {
|
|
120
|
+
try {
|
|
121
|
+
return XATA_BRANCH;
|
|
122
|
+
} catch (err) {
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function getGlobalFallbackBranch() {
|
|
127
|
+
try {
|
|
128
|
+
return XATA_FALLBACK_BRANCH;
|
|
129
|
+
} catch (err) {
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
38
132
|
}
|
|
39
133
|
async function getGitBranch() {
|
|
134
|
+
const cmd = ["git", "branch", "--show-current"];
|
|
135
|
+
const fullCmd = cmd.join(" ");
|
|
136
|
+
const nodeModule = ["child", "process"].join("_");
|
|
137
|
+
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
|
40
138
|
try {
|
|
41
|
-
|
|
139
|
+
if (typeof require === "function") {
|
|
140
|
+
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
|
141
|
+
}
|
|
142
|
+
const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
|
|
143
|
+
return execSync(fullCmd, execOptions).toString().trim();
|
|
42
144
|
} catch (err) {
|
|
43
145
|
}
|
|
44
146
|
try {
|
|
45
147
|
if (isObject(Deno)) {
|
|
46
|
-
const process2 = Deno.run({
|
|
47
|
-
cmd: ["git", "branch", "--show-current"],
|
|
48
|
-
stdout: "piped",
|
|
49
|
-
stderr: "piped"
|
|
50
|
-
});
|
|
148
|
+
const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
|
51
149
|
return new TextDecoder().decode(await process2.output()).trim();
|
|
52
150
|
}
|
|
53
151
|
} catch (err) {
|
|
@@ -56,7 +154,8 @@ async function getGitBranch() {
|
|
|
56
154
|
|
|
57
155
|
function getAPIKey() {
|
|
58
156
|
try {
|
|
59
|
-
|
|
157
|
+
const { apiKey } = getEnvironment();
|
|
158
|
+
return apiKey;
|
|
60
159
|
} catch (err) {
|
|
61
160
|
return void 0;
|
|
62
161
|
}
|
|
@@ -66,21 +165,35 @@ function getFetchImplementation(userFetch) {
|
|
|
66
165
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
|
67
166
|
const fetchImpl = userFetch ?? globalFetch;
|
|
68
167
|
if (!fetchImpl) {
|
|
69
|
-
throw new Error(
|
|
168
|
+
throw new Error(
|
|
169
|
+
`Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
|
|
170
|
+
);
|
|
70
171
|
}
|
|
71
172
|
return fetchImpl;
|
|
72
173
|
}
|
|
73
174
|
|
|
74
|
-
|
|
75
|
-
|
|
175
|
+
const VERSION = "0.0.0-alpha.ved155c7";
|
|
176
|
+
|
|
177
|
+
class ErrorWithCause extends Error {
|
|
178
|
+
constructor(message, options) {
|
|
179
|
+
super(message, options);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
class FetcherError extends ErrorWithCause {
|
|
183
|
+
constructor(status, data, requestId) {
|
|
76
184
|
super(getMessage(data));
|
|
77
185
|
this.status = status;
|
|
78
186
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
|
187
|
+
this.requestId = requestId;
|
|
79
188
|
if (data instanceof Error) {
|
|
80
189
|
this.stack = data.stack;
|
|
81
190
|
this.cause = data.cause;
|
|
82
191
|
}
|
|
83
192
|
}
|
|
193
|
+
toString() {
|
|
194
|
+
const error = super.toString();
|
|
195
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
|
196
|
+
}
|
|
84
197
|
}
|
|
85
198
|
function isBulkError(error) {
|
|
86
199
|
return isObject(error) && Array.isArray(error.errors);
|
|
@@ -103,9 +216,17 @@ function getMessage(data) {
|
|
|
103
216
|
}
|
|
104
217
|
|
|
105
218
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
106
|
-
const
|
|
219
|
+
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
|
220
|
+
if (value === void 0 || value === null)
|
|
221
|
+
return acc;
|
|
222
|
+
return { ...acc, [key]: value };
|
|
223
|
+
}, {});
|
|
224
|
+
const query = new URLSearchParams(cleanQueryParams).toString();
|
|
107
225
|
const queryString = query.length > 0 ? `?${query}` : "";
|
|
108
|
-
|
|
226
|
+
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
|
227
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
|
228
|
+
}, {});
|
|
229
|
+
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
|
109
230
|
};
|
|
110
231
|
function buildBaseUrl({
|
|
111
232
|
path,
|
|
@@ -113,10 +234,10 @@ function buildBaseUrl({
|
|
|
113
234
|
apiUrl,
|
|
114
235
|
pathParams
|
|
115
236
|
}) {
|
|
116
|
-
if (
|
|
237
|
+
if (pathParams?.workspace === void 0)
|
|
117
238
|
return `${apiUrl}${path}`;
|
|
118
239
|
const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
|
119
|
-
return url.replace("{workspaceId}", pathParams.workspace);
|
|
240
|
+
return url.replace("{workspaceId}", String(pathParams.workspace));
|
|
120
241
|
}
|
|
121
242
|
function hostHeader(url) {
|
|
122
243
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
|
@@ -133,32 +254,61 @@ async function fetch$1({
|
|
|
133
254
|
fetchImpl,
|
|
134
255
|
apiKey,
|
|
135
256
|
apiUrl,
|
|
136
|
-
workspacesApiUrl
|
|
257
|
+
workspacesApiUrl,
|
|
258
|
+
trace
|
|
137
259
|
}) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
260
|
+
return trace(
|
|
261
|
+
`${method.toUpperCase()} ${path}`,
|
|
262
|
+
async ({ setAttributes }) => {
|
|
263
|
+
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
|
264
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
|
265
|
+
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
|
266
|
+
setAttributes({
|
|
267
|
+
[TraceAttributes.HTTP_URL]: url,
|
|
268
|
+
[TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
|
|
269
|
+
});
|
|
270
|
+
const response = await fetchImpl(url, {
|
|
271
|
+
method: method.toUpperCase(),
|
|
272
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
273
|
+
headers: {
|
|
274
|
+
"Content-Type": "application/json",
|
|
275
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
|
276
|
+
...headers,
|
|
277
|
+
...hostHeader(fullUrl),
|
|
278
|
+
Authorization: `Bearer ${apiKey}`
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
if (response.status === 204) {
|
|
282
|
+
return {};
|
|
283
|
+
}
|
|
284
|
+
const { host, protocol } = parseUrl(response.url);
|
|
285
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
|
286
|
+
setAttributes({
|
|
287
|
+
[TraceAttributes.KIND]: "http",
|
|
288
|
+
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
|
289
|
+
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
|
290
|
+
[TraceAttributes.HTTP_HOST]: host,
|
|
291
|
+
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
|
292
|
+
});
|
|
293
|
+
try {
|
|
294
|
+
const jsonResponse = await response.json();
|
|
295
|
+
if (response.ok) {
|
|
296
|
+
return jsonResponse;
|
|
297
|
+
}
|
|
298
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
|
299
|
+
} catch (error) {
|
|
300
|
+
throw new FetcherError(response.status, error, requestId);
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
function parseUrl(url) {
|
|
154
307
|
try {
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
return jsonResponse;
|
|
158
|
-
}
|
|
159
|
-
throw new FetcherError(response.status, jsonResponse);
|
|
308
|
+
const { host, protocol } = new URL(url);
|
|
309
|
+
return { host, protocol };
|
|
160
310
|
} catch (error) {
|
|
161
|
-
|
|
311
|
+
return {};
|
|
162
312
|
}
|
|
163
313
|
}
|
|
164
314
|
|
|
@@ -217,6 +367,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
|
|
|
217
367
|
...variables
|
|
218
368
|
});
|
|
219
369
|
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
|
370
|
+
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
|
220
371
|
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
|
221
372
|
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
|
222
373
|
method: "delete",
|
|
@@ -252,16 +403,42 @@ const deleteDatabase = (variables) => fetch$1({
|
|
|
252
403
|
method: "delete",
|
|
253
404
|
...variables
|
|
254
405
|
});
|
|
255
|
-
const
|
|
256
|
-
url: "/
|
|
406
|
+
const getDatabaseMetadata = (variables) => fetch$1({
|
|
407
|
+
url: "/dbs/{dbName}/metadata",
|
|
257
408
|
method: "get",
|
|
258
409
|
...variables
|
|
259
410
|
});
|
|
260
|
-
const
|
|
411
|
+
const patchDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
|
|
412
|
+
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
|
413
|
+
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
|
414
|
+
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
|
415
|
+
const resolveBranch = (variables) => fetch$1({
|
|
416
|
+
url: "/dbs/{dbName}/resolveBranch",
|
|
417
|
+
method: "get",
|
|
418
|
+
...variables
|
|
419
|
+
});
|
|
420
|
+
const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
|
|
421
|
+
const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
|
|
422
|
+
const getMigrationRequest = (variables) => fetch$1({
|
|
423
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
|
424
|
+
method: "get",
|
|
425
|
+
...variables
|
|
426
|
+
});
|
|
427
|
+
const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
|
|
428
|
+
const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
|
|
429
|
+
const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
|
|
430
|
+
const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
|
|
431
|
+
const mergeMigrationRequest = (variables) => fetch$1({
|
|
432
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
|
433
|
+
method: "post",
|
|
434
|
+
...variables
|
|
435
|
+
});
|
|
436
|
+
const getBranchDetails = (variables) => fetch$1({
|
|
261
437
|
url: "/db/{dbBranchName}",
|
|
262
|
-
method: "
|
|
438
|
+
method: "get",
|
|
263
439
|
...variables
|
|
264
440
|
});
|
|
441
|
+
const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
|
|
265
442
|
const deleteBranch = (variables) => fetch$1({
|
|
266
443
|
url: "/db/{dbBranchName}",
|
|
267
444
|
method: "delete",
|
|
@@ -280,16 +457,15 @@ const getBranchMetadata = (variables) => fetch$1({
|
|
|
280
457
|
const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
|
|
281
458
|
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
|
282
459
|
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
method: "post",
|
|
286
|
-
...variables
|
|
287
|
-
});
|
|
460
|
+
const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
|
|
461
|
+
const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
|
|
288
462
|
const updateBranchSchema = (variables) => fetch$1({
|
|
289
463
|
url: "/db/{dbBranchName}/schema/update",
|
|
290
464
|
method: "post",
|
|
291
465
|
...variables
|
|
292
466
|
});
|
|
467
|
+
const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
|
|
468
|
+
const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
|
|
293
469
|
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
|
294
470
|
const getBranchStats = (variables) => fetch$1({
|
|
295
471
|
url: "/db/{dbBranchName}/stats",
|
|
@@ -346,11 +522,7 @@ const updateColumn = (variables) => fetch$1({
|
|
|
346
522
|
method: "patch",
|
|
347
523
|
...variables
|
|
348
524
|
});
|
|
349
|
-
const insertRecord = (variables) => fetch$1({
|
|
350
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
|
351
|
-
method: "post",
|
|
352
|
-
...variables
|
|
353
|
-
});
|
|
525
|
+
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
|
354
526
|
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
|
355
527
|
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
|
356
528
|
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
|
@@ -370,6 +542,11 @@ const queryTable = (variables) => fetch$1({
|
|
|
370
542
|
method: "post",
|
|
371
543
|
...variables
|
|
372
544
|
});
|
|
545
|
+
const searchTable = (variables) => fetch$1({
|
|
546
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
|
547
|
+
method: "post",
|
|
548
|
+
...variables
|
|
549
|
+
});
|
|
373
550
|
const searchBranch = (variables) => fetch$1({
|
|
374
551
|
url: "/db/{dbBranchName}/search",
|
|
375
552
|
method: "post",
|
|
@@ -387,11 +564,22 @@ const operationsByTag = {
|
|
|
387
564
|
updateWorkspaceMemberRole,
|
|
388
565
|
removeWorkspaceMember,
|
|
389
566
|
inviteWorkspaceMember,
|
|
567
|
+
updateWorkspaceMemberInvite,
|
|
390
568
|
cancelWorkspaceMemberInvite,
|
|
391
569
|
resendWorkspaceMemberInvite,
|
|
392
570
|
acceptWorkspaceMemberInvite
|
|
393
571
|
},
|
|
394
|
-
database: {
|
|
572
|
+
database: {
|
|
573
|
+
getDatabaseList,
|
|
574
|
+
createDatabase,
|
|
575
|
+
deleteDatabase,
|
|
576
|
+
getDatabaseMetadata,
|
|
577
|
+
patchDatabaseMetadata,
|
|
578
|
+
getGitBranchesMapping,
|
|
579
|
+
addGitBranchesEntry,
|
|
580
|
+
removeGitBranchesEntry,
|
|
581
|
+
resolveBranch
|
|
582
|
+
},
|
|
395
583
|
branch: {
|
|
396
584
|
getBranchList,
|
|
397
585
|
getBranchDetails,
|
|
@@ -399,13 +587,28 @@ const operationsByTag = {
|
|
|
399
587
|
deleteBranch,
|
|
400
588
|
updateBranchMetadata,
|
|
401
589
|
getBranchMetadata,
|
|
590
|
+
getBranchStats
|
|
591
|
+
},
|
|
592
|
+
migrationRequests: {
|
|
593
|
+
listMigrationRequests,
|
|
594
|
+
createMigrationRequest,
|
|
595
|
+
getMigrationRequest,
|
|
596
|
+
updateMigrationRequest,
|
|
597
|
+
listMigrationRequestsCommits,
|
|
598
|
+
compareMigrationRequest,
|
|
599
|
+
getMigrationRequestIsMerged,
|
|
600
|
+
mergeMigrationRequest
|
|
601
|
+
},
|
|
602
|
+
branchSchema: {
|
|
402
603
|
getBranchMigrationHistory,
|
|
403
604
|
executeBranchMigrationPlan,
|
|
404
605
|
getBranchMigrationPlan,
|
|
405
|
-
|
|
606
|
+
compareBranchWithUserSchema,
|
|
607
|
+
compareBranchSchemas,
|
|
406
608
|
updateBranchSchema,
|
|
407
|
-
|
|
408
|
-
|
|
609
|
+
previewBranchSchemaEdit,
|
|
610
|
+
applyBranchSchemaEdit,
|
|
611
|
+
getBranchSchemaHistory
|
|
409
612
|
},
|
|
410
613
|
table: {
|
|
411
614
|
createTable,
|
|
@@ -428,14 +631,15 @@ const operationsByTag = {
|
|
|
428
631
|
getRecord,
|
|
429
632
|
bulkInsertTableRecords,
|
|
430
633
|
queryTable,
|
|
634
|
+
searchTable,
|
|
431
635
|
searchBranch
|
|
432
636
|
}
|
|
433
637
|
};
|
|
434
638
|
|
|
435
639
|
function getHostUrl(provider, type) {
|
|
436
|
-
if (
|
|
640
|
+
if (isHostProviderAlias(provider)) {
|
|
437
641
|
return providers[provider][type];
|
|
438
|
-
} else if (
|
|
642
|
+
} else if (isHostProviderBuilder(provider)) {
|
|
439
643
|
return provider[type];
|
|
440
644
|
}
|
|
441
645
|
throw new Error("Invalid API provider");
|
|
@@ -450,10 +654,10 @@ const providers = {
|
|
|
450
654
|
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
|
451
655
|
}
|
|
452
656
|
};
|
|
453
|
-
function
|
|
657
|
+
function isHostProviderAlias(alias) {
|
|
454
658
|
return isString(alias) && Object.keys(providers).includes(alias);
|
|
455
659
|
}
|
|
456
|
-
function
|
|
660
|
+
function isHostProviderBuilder(builder) {
|
|
457
661
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
|
458
662
|
}
|
|
459
663
|
|
|
@@ -461,7 +665,7 @@ var __accessCheck$7 = (obj, member, msg) => {
|
|
|
461
665
|
if (!member.has(obj))
|
|
462
666
|
throw TypeError("Cannot " + msg);
|
|
463
667
|
};
|
|
464
|
-
var __privateGet$
|
|
668
|
+
var __privateGet$7 = (obj, member, getter) => {
|
|
465
669
|
__accessCheck$7(obj, member, "read from private field");
|
|
466
670
|
return getter ? getter.call(obj) : member.get(obj);
|
|
467
671
|
};
|
|
@@ -470,7 +674,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
|
470
674
|
throw TypeError("Cannot add the same private member more than once");
|
|
471
675
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
472
676
|
};
|
|
473
|
-
var __privateSet$
|
|
677
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
|
474
678
|
__accessCheck$7(obj, member, "write to private field");
|
|
475
679
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
476
680
|
return value;
|
|
@@ -481,46 +685,58 @@ class XataApiClient {
|
|
|
481
685
|
__privateAdd$7(this, _extraProps, void 0);
|
|
482
686
|
__privateAdd$7(this, _namespaces, {});
|
|
483
687
|
const provider = options.host ?? "production";
|
|
484
|
-
const apiKey = options
|
|
688
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
|
689
|
+
const trace = options.trace ?? defaultTrace;
|
|
485
690
|
if (!apiKey) {
|
|
486
691
|
throw new Error("Could not resolve a valid apiKey");
|
|
487
692
|
}
|
|
488
|
-
__privateSet$
|
|
693
|
+
__privateSet$7(this, _extraProps, {
|
|
489
694
|
apiUrl: getHostUrl(provider, "main"),
|
|
490
695
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
|
491
696
|
fetchImpl: getFetchImplementation(options.fetch),
|
|
492
|
-
apiKey
|
|
697
|
+
apiKey,
|
|
698
|
+
trace
|
|
493
699
|
});
|
|
494
700
|
}
|
|
495
701
|
get user() {
|
|
496
|
-
if (!__privateGet$
|
|
497
|
-
__privateGet$
|
|
498
|
-
return __privateGet$
|
|
702
|
+
if (!__privateGet$7(this, _namespaces).user)
|
|
703
|
+
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
|
704
|
+
return __privateGet$7(this, _namespaces).user;
|
|
499
705
|
}
|
|
500
706
|
get workspaces() {
|
|
501
|
-
if (!__privateGet$
|
|
502
|
-
__privateGet$
|
|
503
|
-
return __privateGet$
|
|
707
|
+
if (!__privateGet$7(this, _namespaces).workspaces)
|
|
708
|
+
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
|
709
|
+
return __privateGet$7(this, _namespaces).workspaces;
|
|
504
710
|
}
|
|
505
711
|
get databases() {
|
|
506
|
-
if (!__privateGet$
|
|
507
|
-
__privateGet$
|
|
508
|
-
return __privateGet$
|
|
712
|
+
if (!__privateGet$7(this, _namespaces).databases)
|
|
713
|
+
__privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
|
|
714
|
+
return __privateGet$7(this, _namespaces).databases;
|
|
509
715
|
}
|
|
510
716
|
get branches() {
|
|
511
|
-
if (!__privateGet$
|
|
512
|
-
__privateGet$
|
|
513
|
-
return __privateGet$
|
|
717
|
+
if (!__privateGet$7(this, _namespaces).branches)
|
|
718
|
+
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
|
719
|
+
return __privateGet$7(this, _namespaces).branches;
|
|
514
720
|
}
|
|
515
721
|
get tables() {
|
|
516
|
-
if (!__privateGet$
|
|
517
|
-
__privateGet$
|
|
518
|
-
return __privateGet$
|
|
722
|
+
if (!__privateGet$7(this, _namespaces).tables)
|
|
723
|
+
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
|
724
|
+
return __privateGet$7(this, _namespaces).tables;
|
|
519
725
|
}
|
|
520
726
|
get records() {
|
|
521
|
-
if (!__privateGet$
|
|
522
|
-
__privateGet$
|
|
523
|
-
return __privateGet$
|
|
727
|
+
if (!__privateGet$7(this, _namespaces).records)
|
|
728
|
+
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
|
729
|
+
return __privateGet$7(this, _namespaces).records;
|
|
730
|
+
}
|
|
731
|
+
get migrationRequests() {
|
|
732
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
|
733
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
|
734
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
|
735
|
+
}
|
|
736
|
+
get branchSchema() {
|
|
737
|
+
if (!__privateGet$7(this, _namespaces).branchSchema)
|
|
738
|
+
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
|
739
|
+
return __privateGet$7(this, _namespaces).branchSchema;
|
|
524
740
|
}
|
|
525
741
|
}
|
|
526
742
|
_extraProps = new WeakMap();
|
|
@@ -612,6 +828,13 @@ class WorkspaceApi {
|
|
|
612
828
|
...this.extraProps
|
|
613
829
|
});
|
|
614
830
|
}
|
|
831
|
+
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
|
832
|
+
return operationsByTag.workspaces.updateWorkspaceMemberInvite({
|
|
833
|
+
pathParams: { workspaceId, inviteId },
|
|
834
|
+
body: { role },
|
|
835
|
+
...this.extraProps
|
|
836
|
+
});
|
|
837
|
+
}
|
|
615
838
|
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
|
616
839
|
return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
|
|
617
840
|
pathParams: { workspaceId, inviteId },
|
|
@@ -654,6 +877,46 @@ class DatabaseApi {
|
|
|
654
877
|
...this.extraProps
|
|
655
878
|
});
|
|
656
879
|
}
|
|
880
|
+
getDatabaseMetadata(workspace, dbName) {
|
|
881
|
+
return operationsByTag.database.getDatabaseMetadata({
|
|
882
|
+
pathParams: { workspace, dbName },
|
|
883
|
+
...this.extraProps
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
patchDatabaseMetadata(workspace, dbName, options = {}) {
|
|
887
|
+
return operationsByTag.database.patchDatabaseMetadata({
|
|
888
|
+
pathParams: { workspace, dbName },
|
|
889
|
+
body: options,
|
|
890
|
+
...this.extraProps
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
getGitBranchesMapping(workspace, dbName) {
|
|
894
|
+
return operationsByTag.database.getGitBranchesMapping({
|
|
895
|
+
pathParams: { workspace, dbName },
|
|
896
|
+
...this.extraProps
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
addGitBranchesEntry(workspace, dbName, body) {
|
|
900
|
+
return operationsByTag.database.addGitBranchesEntry({
|
|
901
|
+
pathParams: { workspace, dbName },
|
|
902
|
+
body,
|
|
903
|
+
...this.extraProps
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
removeGitBranchesEntry(workspace, dbName, gitBranch) {
|
|
907
|
+
return operationsByTag.database.removeGitBranchesEntry({
|
|
908
|
+
pathParams: { workspace, dbName },
|
|
909
|
+
queryParams: { gitBranch },
|
|
910
|
+
...this.extraProps
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
|
|
914
|
+
return operationsByTag.database.resolveBranch({
|
|
915
|
+
pathParams: { workspace, dbName },
|
|
916
|
+
queryParams: { gitBranch, fallbackBranch },
|
|
917
|
+
...this.extraProps
|
|
918
|
+
});
|
|
919
|
+
}
|
|
657
920
|
}
|
|
658
921
|
class BranchApi {
|
|
659
922
|
constructor(extraProps) {
|
|
@@ -671,10 +934,10 @@ class BranchApi {
|
|
|
671
934
|
...this.extraProps
|
|
672
935
|
});
|
|
673
936
|
}
|
|
674
|
-
createBranch(workspace, database, branch, from
|
|
937
|
+
createBranch(workspace, database, branch, from, options = {}) {
|
|
675
938
|
return operationsByTag.branch.createBranch({
|
|
676
939
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
677
|
-
queryParams: { from },
|
|
940
|
+
queryParams: isString(from) ? { from } : void 0,
|
|
678
941
|
body: options,
|
|
679
942
|
...this.extraProps
|
|
680
943
|
});
|
|
@@ -698,27 +961,6 @@ class BranchApi {
|
|
|
698
961
|
...this.extraProps
|
|
699
962
|
});
|
|
700
963
|
}
|
|
701
|
-
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
|
702
|
-
return operationsByTag.branch.getBranchMigrationHistory({
|
|
703
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
704
|
-
body: options,
|
|
705
|
-
...this.extraProps
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
|
709
|
-
return operationsByTag.branch.executeBranchMigrationPlan({
|
|
710
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
711
|
-
body: migrationPlan,
|
|
712
|
-
...this.extraProps
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
getBranchMigrationPlan(workspace, database, branch, schema) {
|
|
716
|
-
return operationsByTag.branch.getBranchMigrationPlan({
|
|
717
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
718
|
-
body: schema,
|
|
719
|
-
...this.extraProps
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
964
|
getBranchStats(workspace, database, branch) {
|
|
723
965
|
return operationsByTag.branch.getBranchStats({
|
|
724
966
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
@@ -799,9 +1041,10 @@ class RecordsApi {
|
|
|
799
1041
|
constructor(extraProps) {
|
|
800
1042
|
this.extraProps = extraProps;
|
|
801
1043
|
}
|
|
802
|
-
insertRecord(workspace, database, branch, tableName, record) {
|
|
1044
|
+
insertRecord(workspace, database, branch, tableName, record, options = {}) {
|
|
803
1045
|
return operationsByTag.records.insertRecord({
|
|
804
1046
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1047
|
+
queryParams: options,
|
|
805
1048
|
body: record,
|
|
806
1049
|
...this.extraProps
|
|
807
1050
|
});
|
|
@@ -830,21 +1073,24 @@ class RecordsApi {
|
|
|
830
1073
|
...this.extraProps
|
|
831
1074
|
});
|
|
832
1075
|
}
|
|
833
|
-
deleteRecord(workspace, database, branch, tableName, recordId) {
|
|
1076
|
+
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
|
834
1077
|
return operationsByTag.records.deleteRecord({
|
|
835
1078
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1079
|
+
queryParams: options,
|
|
836
1080
|
...this.extraProps
|
|
837
1081
|
});
|
|
838
1082
|
}
|
|
839
1083
|
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
|
840
1084
|
return operationsByTag.records.getRecord({
|
|
841
1085
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
|
1086
|
+
queryParams: options,
|
|
842
1087
|
...this.extraProps
|
|
843
1088
|
});
|
|
844
1089
|
}
|
|
845
|
-
bulkInsertTableRecords(workspace, database, branch, tableName, records) {
|
|
1090
|
+
bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
|
|
846
1091
|
return operationsByTag.records.bulkInsertTableRecords({
|
|
847
1092
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1093
|
+
queryParams: options,
|
|
848
1094
|
body: { records },
|
|
849
1095
|
...this.extraProps
|
|
850
1096
|
});
|
|
@@ -856,6 +1102,13 @@ class RecordsApi {
|
|
|
856
1102
|
...this.extraProps
|
|
857
1103
|
});
|
|
858
1104
|
}
|
|
1105
|
+
searchTable(workspace, database, branch, tableName, query) {
|
|
1106
|
+
return operationsByTag.records.searchTable({
|
|
1107
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
|
1108
|
+
body: query,
|
|
1109
|
+
...this.extraProps
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
859
1112
|
searchBranch(workspace, database, branch, query) {
|
|
860
1113
|
return operationsByTag.records.searchBranch({
|
|
861
1114
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
@@ -864,6 +1117,131 @@ class RecordsApi {
|
|
|
864
1117
|
});
|
|
865
1118
|
}
|
|
866
1119
|
}
|
|
1120
|
+
class MigrationRequestsApi {
|
|
1121
|
+
constructor(extraProps) {
|
|
1122
|
+
this.extraProps = extraProps;
|
|
1123
|
+
}
|
|
1124
|
+
listMigrationRequests(workspace, database, options = {}) {
|
|
1125
|
+
return operationsByTag.migrationRequests.listMigrationRequests({
|
|
1126
|
+
pathParams: { workspace, dbName: database },
|
|
1127
|
+
body: options,
|
|
1128
|
+
...this.extraProps
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
createMigrationRequest(workspace, database, options) {
|
|
1132
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
|
1133
|
+
pathParams: { workspace, dbName: database },
|
|
1134
|
+
body: options,
|
|
1135
|
+
...this.extraProps
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
getMigrationRequest(workspace, database, migrationRequest) {
|
|
1139
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
|
1140
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1141
|
+
...this.extraProps
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
updateMigrationRequest(workspace, database, migrationRequest, options) {
|
|
1145
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
|
1146
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1147
|
+
body: options,
|
|
1148
|
+
...this.extraProps
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
|
|
1152
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
|
1153
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1154
|
+
body: options,
|
|
1155
|
+
...this.extraProps
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
compareMigrationRequest(workspace, database, migrationRequest) {
|
|
1159
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
|
1160
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1161
|
+
...this.extraProps
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
getMigrationRequestIsMerged(workspace, database, migrationRequest) {
|
|
1165
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
|
1166
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1167
|
+
...this.extraProps
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
mergeMigrationRequest(workspace, database, migrationRequest) {
|
|
1171
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
|
1172
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
|
1173
|
+
...this.extraProps
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
class BranchSchemaApi {
|
|
1178
|
+
constructor(extraProps) {
|
|
1179
|
+
this.extraProps = extraProps;
|
|
1180
|
+
}
|
|
1181
|
+
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
|
1182
|
+
return operationsByTag.branchSchema.getBranchMigrationHistory({
|
|
1183
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1184
|
+
body: options,
|
|
1185
|
+
...this.extraProps
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
|
1189
|
+
return operationsByTag.branchSchema.executeBranchMigrationPlan({
|
|
1190
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1191
|
+
body: migrationPlan,
|
|
1192
|
+
...this.extraProps
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
getBranchMigrationPlan(workspace, database, branch, schema) {
|
|
1196
|
+
return operationsByTag.branchSchema.getBranchMigrationPlan({
|
|
1197
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1198
|
+
body: schema,
|
|
1199
|
+
...this.extraProps
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
compareBranchWithUserSchema(workspace, database, branch, schema) {
|
|
1203
|
+
return operationsByTag.branchSchema.compareBranchWithUserSchema({
|
|
1204
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1205
|
+
body: { schema },
|
|
1206
|
+
...this.extraProps
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
compareBranchSchemas(workspace, database, branch, branchName, schema) {
|
|
1210
|
+
return operationsByTag.branchSchema.compareBranchSchemas({
|
|
1211
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
|
|
1212
|
+
body: { schema },
|
|
1213
|
+
...this.extraProps
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
updateBranchSchema(workspace, database, branch, migration) {
|
|
1217
|
+
return operationsByTag.branchSchema.updateBranchSchema({
|
|
1218
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1219
|
+
body: migration,
|
|
1220
|
+
...this.extraProps
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
previewBranchSchemaEdit(workspace, database, branch, migration) {
|
|
1224
|
+
return operationsByTag.branchSchema.previewBranchSchemaEdit({
|
|
1225
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1226
|
+
body: migration,
|
|
1227
|
+
...this.extraProps
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
applyBranchSchemaEdit(workspace, database, branch, edits) {
|
|
1231
|
+
return operationsByTag.branchSchema.applyBranchSchemaEdit({
|
|
1232
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1233
|
+
body: { edits },
|
|
1234
|
+
...this.extraProps
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
getBranchSchemaHistory(workspace, database, branch, options = {}) {
|
|
1238
|
+
return operationsByTag.branchSchema.getBranchSchemaHistory({
|
|
1239
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
|
1240
|
+
body: options,
|
|
1241
|
+
...this.extraProps
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
867
1245
|
|
|
868
1246
|
class XataApiPlugin {
|
|
869
1247
|
async build(options) {
|
|
@@ -879,7 +1257,7 @@ var __accessCheck$6 = (obj, member, msg) => {
|
|
|
879
1257
|
if (!member.has(obj))
|
|
880
1258
|
throw TypeError("Cannot " + msg);
|
|
881
1259
|
};
|
|
882
|
-
var __privateGet$
|
|
1260
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
883
1261
|
__accessCheck$6(obj, member, "read from private field");
|
|
884
1262
|
return getter ? getter.call(obj) : member.get(obj);
|
|
885
1263
|
};
|
|
@@ -888,30 +1266,30 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
|
888
1266
|
throw TypeError("Cannot add the same private member more than once");
|
|
889
1267
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
890
1268
|
};
|
|
891
|
-
var __privateSet$
|
|
1269
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
892
1270
|
__accessCheck$6(obj, member, "write to private field");
|
|
893
1271
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
894
1272
|
return value;
|
|
895
1273
|
};
|
|
896
|
-
var _query;
|
|
1274
|
+
var _query, _page;
|
|
897
1275
|
class Page {
|
|
898
1276
|
constructor(query, meta, records = []) {
|
|
899
1277
|
__privateAdd$6(this, _query, void 0);
|
|
900
|
-
__privateSet$
|
|
1278
|
+
__privateSet$6(this, _query, query);
|
|
901
1279
|
this.meta = meta;
|
|
902
|
-
this.records = records;
|
|
1280
|
+
this.records = new RecordArray(this, records);
|
|
903
1281
|
}
|
|
904
1282
|
async nextPage(size, offset) {
|
|
905
|
-
return __privateGet$
|
|
1283
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
|
906
1284
|
}
|
|
907
1285
|
async previousPage(size, offset) {
|
|
908
|
-
return __privateGet$
|
|
1286
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
|
909
1287
|
}
|
|
910
1288
|
async firstPage(size, offset) {
|
|
911
|
-
return __privateGet$
|
|
1289
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
|
|
912
1290
|
}
|
|
913
1291
|
async lastPage(size, offset) {
|
|
914
|
-
return __privateGet$
|
|
1292
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
|
|
915
1293
|
}
|
|
916
1294
|
hasNextPage() {
|
|
917
1295
|
return this.meta.page.more;
|
|
@@ -919,15 +1297,62 @@ class Page {
|
|
|
919
1297
|
}
|
|
920
1298
|
_query = new WeakMap();
|
|
921
1299
|
const PAGINATION_MAX_SIZE = 200;
|
|
922
|
-
const PAGINATION_DEFAULT_SIZE =
|
|
1300
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
|
923
1301
|
const PAGINATION_MAX_OFFSET = 800;
|
|
924
1302
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
|
1303
|
+
function isCursorPaginationOptions(options) {
|
|
1304
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
|
1305
|
+
}
|
|
1306
|
+
const _RecordArray = class extends Array {
|
|
1307
|
+
constructor(...args) {
|
|
1308
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
|
1309
|
+
__privateAdd$6(this, _page, void 0);
|
|
1310
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
|
1311
|
+
}
|
|
1312
|
+
static parseConstructorParams(...args) {
|
|
1313
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
|
1314
|
+
return new Array(args[0]);
|
|
1315
|
+
}
|
|
1316
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
|
1317
|
+
const result = args[1] ?? args[0].records ?? [];
|
|
1318
|
+
return new Array(...result);
|
|
1319
|
+
}
|
|
1320
|
+
return new Array(...args);
|
|
1321
|
+
}
|
|
1322
|
+
toArray() {
|
|
1323
|
+
return new Array(...this);
|
|
1324
|
+
}
|
|
1325
|
+
map(callbackfn, thisArg) {
|
|
1326
|
+
return this.toArray().map(callbackfn, thisArg);
|
|
1327
|
+
}
|
|
1328
|
+
async nextPage(size, offset) {
|
|
1329
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
|
1330
|
+
return new _RecordArray(newPage);
|
|
1331
|
+
}
|
|
1332
|
+
async previousPage(size, offset) {
|
|
1333
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
|
1334
|
+
return new _RecordArray(newPage);
|
|
1335
|
+
}
|
|
1336
|
+
async firstPage(size, offset) {
|
|
1337
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
|
1338
|
+
return new _RecordArray(newPage);
|
|
1339
|
+
}
|
|
1340
|
+
async lastPage(size, offset) {
|
|
1341
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
|
1342
|
+
return new _RecordArray(newPage);
|
|
1343
|
+
}
|
|
1344
|
+
hasNextPage() {
|
|
1345
|
+
return __privateGet$6(this, _page).meta.page.more;
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
let RecordArray = _RecordArray;
|
|
1349
|
+
_page = new WeakMap();
|
|
925
1350
|
|
|
926
1351
|
var __accessCheck$5 = (obj, member, msg) => {
|
|
927
1352
|
if (!member.has(obj))
|
|
928
1353
|
throw TypeError("Cannot " + msg);
|
|
929
1354
|
};
|
|
930
|
-
var __privateGet$
|
|
1355
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
931
1356
|
__accessCheck$5(obj, member, "read from private field");
|
|
932
1357
|
return getter ? getter.call(obj) : member.get(obj);
|
|
933
1358
|
};
|
|
@@ -936,34 +1361,35 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
|
936
1361
|
throw TypeError("Cannot add the same private member more than once");
|
|
937
1362
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
938
1363
|
};
|
|
939
|
-
var __privateSet$
|
|
1364
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
940
1365
|
__accessCheck$5(obj, member, "write to private field");
|
|
941
1366
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
942
1367
|
return value;
|
|
943
1368
|
};
|
|
944
1369
|
var _table$1, _repository, _data;
|
|
945
1370
|
const _Query = class {
|
|
946
|
-
constructor(repository, table, data,
|
|
1371
|
+
constructor(repository, table, data, rawParent) {
|
|
947
1372
|
__privateAdd$5(this, _table$1, void 0);
|
|
948
1373
|
__privateAdd$5(this, _repository, void 0);
|
|
949
1374
|
__privateAdd$5(this, _data, { filter: {} });
|
|
950
1375
|
this.meta = { page: { cursor: "start", more: true } };
|
|
951
|
-
this.records = [];
|
|
952
|
-
__privateSet$
|
|
1376
|
+
this.records = new RecordArray(this, []);
|
|
1377
|
+
__privateSet$5(this, _table$1, table);
|
|
953
1378
|
if (repository) {
|
|
954
|
-
__privateSet$
|
|
1379
|
+
__privateSet$5(this, _repository, repository);
|
|
955
1380
|
} else {
|
|
956
|
-
__privateSet$
|
|
1381
|
+
__privateSet$5(this, _repository, this);
|
|
957
1382
|
}
|
|
958
|
-
|
|
959
|
-
__privateGet$
|
|
960
|
-
__privateGet$
|
|
961
|
-
__privateGet$
|
|
962
|
-
__privateGet$
|
|
963
|
-
__privateGet$
|
|
964
|
-
__privateGet$
|
|
965
|
-
__privateGet$
|
|
966
|
-
__privateGet$
|
|
1383
|
+
const parent = cleanParent(data, rawParent);
|
|
1384
|
+
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
|
1385
|
+
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
|
1386
|
+
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
|
1387
|
+
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
|
1388
|
+
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
|
1389
|
+
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
|
1390
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
|
|
1391
|
+
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
|
1392
|
+
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
|
967
1393
|
this.any = this.any.bind(this);
|
|
968
1394
|
this.all = this.all.bind(this);
|
|
969
1395
|
this.not = this.not.bind(this);
|
|
@@ -974,83 +1400,101 @@ const _Query = class {
|
|
|
974
1400
|
Object.defineProperty(this, "repository", { enumerable: false });
|
|
975
1401
|
}
|
|
976
1402
|
getQueryOptions() {
|
|
977
|
-
return __privateGet$
|
|
1403
|
+
return __privateGet$5(this, _data);
|
|
978
1404
|
}
|
|
979
1405
|
key() {
|
|
980
|
-
const { columns = [], filter = {}, sort = [],
|
|
981
|
-
const key = JSON.stringify({ columns, filter, sort,
|
|
1406
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
|
|
1407
|
+
const key = JSON.stringify({ columns, filter, sort, pagination });
|
|
982
1408
|
return toBase64(key);
|
|
983
1409
|
}
|
|
984
1410
|
any(...queries) {
|
|
985
1411
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
986
|
-
return new _Query(__privateGet$
|
|
1412
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
|
987
1413
|
}
|
|
988
1414
|
all(...queries) {
|
|
989
1415
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
990
|
-
return new _Query(__privateGet$
|
|
1416
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
991
1417
|
}
|
|
992
1418
|
not(...queries) {
|
|
993
1419
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
994
|
-
return new _Query(__privateGet$
|
|
1420
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
|
995
1421
|
}
|
|
996
1422
|
none(...queries) {
|
|
997
1423
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
|
998
|
-
return new _Query(__privateGet$
|
|
1424
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
|
999
1425
|
}
|
|
1000
1426
|
filter(a, b) {
|
|
1001
1427
|
if (arguments.length === 1) {
|
|
1002
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
|
1003
|
-
const $all = compact([__privateGet$
|
|
1004
|
-
return new _Query(__privateGet$
|
|
1428
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
|
|
1429
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
|
1430
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1005
1431
|
} else {
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1432
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
|
|
1433
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
|
1434
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
defaultFilter(column, value) {
|
|
1438
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
|
1439
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
|
1440
|
+
return { $includes: value };
|
|
1008
1441
|
}
|
|
1442
|
+
return value;
|
|
1009
1443
|
}
|
|
1010
|
-
sort(column, direction) {
|
|
1011
|
-
const originalSort = [__privateGet$
|
|
1444
|
+
sort(column, direction = "asc") {
|
|
1445
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
|
1012
1446
|
const sort = [...originalSort, { column, direction }];
|
|
1013
|
-
return new _Query(__privateGet$
|
|
1447
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
|
1014
1448
|
}
|
|
1015
1449
|
select(columns) {
|
|
1016
|
-
return new _Query(
|
|
1450
|
+
return new _Query(
|
|
1451
|
+
__privateGet$5(this, _repository),
|
|
1452
|
+
__privateGet$5(this, _table$1),
|
|
1453
|
+
{ columns },
|
|
1454
|
+
__privateGet$5(this, _data)
|
|
1455
|
+
);
|
|
1017
1456
|
}
|
|
1018
1457
|
getPaginated(options = {}) {
|
|
1019
|
-
const query = new _Query(__privateGet$
|
|
1020
|
-
return __privateGet$
|
|
1458
|
+
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
|
1459
|
+
return __privateGet$5(this, _repository).query(query);
|
|
1021
1460
|
}
|
|
1022
1461
|
async *[Symbol.asyncIterator]() {
|
|
1023
|
-
for await (const [record] of this.getIterator(1)) {
|
|
1462
|
+
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
|
1024
1463
|
yield record;
|
|
1025
1464
|
}
|
|
1026
1465
|
}
|
|
1027
|
-
async *getIterator(
|
|
1028
|
-
|
|
1029
|
-
let
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1466
|
+
async *getIterator(options = {}) {
|
|
1467
|
+
const { batchSize = 1 } = options;
|
|
1468
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
|
1469
|
+
let more = page.hasNextPage();
|
|
1470
|
+
yield page.records;
|
|
1471
|
+
while (more) {
|
|
1472
|
+
page = await page.nextPage();
|
|
1473
|
+
more = page.hasNextPage();
|
|
1474
|
+
yield page.records;
|
|
1035
1475
|
}
|
|
1036
1476
|
}
|
|
1037
1477
|
async getMany(options = {}) {
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1478
|
+
const page = await this.getPaginated(options);
|
|
1479
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
|
1480
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
|
1481
|
+
}
|
|
1482
|
+
return page.records;
|
|
1040
1483
|
}
|
|
1041
|
-
async getAll(
|
|
1484
|
+
async getAll(options = {}) {
|
|
1485
|
+
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
|
1042
1486
|
const results = [];
|
|
1043
|
-
for await (const page of this.getIterator(
|
|
1487
|
+
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
|
1044
1488
|
results.push(...page);
|
|
1045
1489
|
}
|
|
1046
1490
|
return results;
|
|
1047
1491
|
}
|
|
1048
1492
|
async getFirst(options = {}) {
|
|
1049
|
-
const records = await this.getMany({ ...options,
|
|
1050
|
-
return records[0]
|
|
1493
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
|
1494
|
+
return records[0] ?? null;
|
|
1051
1495
|
}
|
|
1052
1496
|
cache(ttl) {
|
|
1053
|
-
return new _Query(__privateGet$
|
|
1497
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
|
1054
1498
|
}
|
|
1055
1499
|
nextPage(size, offset) {
|
|
1056
1500
|
return this.firstPage(size, offset);
|
|
@@ -1059,10 +1503,10 @@ const _Query = class {
|
|
|
1059
1503
|
return this.firstPage(size, offset);
|
|
1060
1504
|
}
|
|
1061
1505
|
firstPage(size, offset) {
|
|
1062
|
-
return this.getPaginated({
|
|
1506
|
+
return this.getPaginated({ pagination: { size, offset } });
|
|
1063
1507
|
}
|
|
1064
1508
|
lastPage(size, offset) {
|
|
1065
|
-
return this.getPaginated({
|
|
1509
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
|
1066
1510
|
}
|
|
1067
1511
|
hasNextPage() {
|
|
1068
1512
|
return this.meta.page.more;
|
|
@@ -1072,12 +1516,20 @@ let Query = _Query;
|
|
|
1072
1516
|
_table$1 = new WeakMap();
|
|
1073
1517
|
_repository = new WeakMap();
|
|
1074
1518
|
_data = new WeakMap();
|
|
1519
|
+
function cleanParent(data, parent) {
|
|
1520
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
|
1521
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
|
1522
|
+
}
|
|
1523
|
+
return parent;
|
|
1524
|
+
}
|
|
1075
1525
|
|
|
1076
1526
|
function isIdentifiable(x) {
|
|
1077
1527
|
return isObject(x) && isString(x?.id);
|
|
1078
1528
|
}
|
|
1079
1529
|
function isXataRecord(x) {
|
|
1080
|
-
|
|
1530
|
+
const record = x;
|
|
1531
|
+
const metadata = record?.getMetadata();
|
|
1532
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
|
1081
1533
|
}
|
|
1082
1534
|
|
|
1083
1535
|
function isSortFilterString(value) {
|
|
@@ -1107,7 +1559,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
|
1107
1559
|
if (!member.has(obj))
|
|
1108
1560
|
throw TypeError("Cannot " + msg);
|
|
1109
1561
|
};
|
|
1110
|
-
var __privateGet$
|
|
1562
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
1111
1563
|
__accessCheck$4(obj, member, "read from private field");
|
|
1112
1564
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1113
1565
|
};
|
|
@@ -1116,7 +1568,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
|
1116
1568
|
throw TypeError("Cannot add the same private member more than once");
|
|
1117
1569
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1118
1570
|
};
|
|
1119
|
-
var __privateSet$
|
|
1571
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
1120
1572
|
__accessCheck$4(obj, member, "write to private field");
|
|
1121
1573
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1122
1574
|
return value;
|
|
@@ -1125,304 +1577,355 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
|
1125
1577
|
__accessCheck$4(obj, member, "access private method");
|
|
1126
1578
|
return method;
|
|
1127
1579
|
};
|
|
1128
|
-
var _table,
|
|
1580
|
+
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;
|
|
1129
1581
|
class Repository extends Query {
|
|
1130
1582
|
}
|
|
1131
1583
|
class RestRepository extends Query {
|
|
1132
1584
|
constructor(options) {
|
|
1133
|
-
super(
|
|
1585
|
+
super(
|
|
1586
|
+
null,
|
|
1587
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
|
1588
|
+
{}
|
|
1589
|
+
);
|
|
1134
1590
|
__privateAdd$4(this, _insertRecordWithoutId);
|
|
1135
1591
|
__privateAdd$4(this, _insertRecordWithId);
|
|
1136
1592
|
__privateAdd$4(this, _bulkInsertTableRecords);
|
|
1137
1593
|
__privateAdd$4(this, _updateRecordWithID);
|
|
1138
1594
|
__privateAdd$4(this, _upsertRecordWithID);
|
|
1139
1595
|
__privateAdd$4(this, _deleteRecord);
|
|
1140
|
-
__privateAdd$4(this, _invalidateCache);
|
|
1141
|
-
__privateAdd$4(this, _setCacheRecord);
|
|
1142
|
-
__privateAdd$4(this, _getCacheRecord);
|
|
1143
1596
|
__privateAdd$4(this, _setCacheQuery);
|
|
1144
1597
|
__privateAdd$4(this, _getCacheQuery);
|
|
1598
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
|
1145
1599
|
__privateAdd$4(this, _table, void 0);
|
|
1146
|
-
__privateAdd$4(this, _links, void 0);
|
|
1147
1600
|
__privateAdd$4(this, _getFetchProps, void 0);
|
|
1601
|
+
__privateAdd$4(this, _db, void 0);
|
|
1148
1602
|
__privateAdd$4(this, _cache, void 0);
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
__privateSet$
|
|
1152
|
-
this
|
|
1153
|
-
__privateSet$
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
throw new Error("The id can't be empty");
|
|
1164
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
|
|
1165
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
|
1166
|
-
return record;
|
|
1167
|
-
}
|
|
1168
|
-
if (isObject(a) && isString(a.id)) {
|
|
1169
|
-
if (a.id === "")
|
|
1170
|
-
throw new Error("The id can't be empty");
|
|
1171
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
|
|
1172
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
|
1173
|
-
return record;
|
|
1174
|
-
}
|
|
1175
|
-
if (isObject(a)) {
|
|
1176
|
-
const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
|
|
1177
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
|
1178
|
-
return record;
|
|
1179
|
-
}
|
|
1180
|
-
throw new Error("Invalid arguments for create method");
|
|
1181
|
-
}
|
|
1182
|
-
async read(recordId) {
|
|
1183
|
-
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
|
|
1184
|
-
if (cacheRecord)
|
|
1185
|
-
return cacheRecord;
|
|
1186
|
-
const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
|
|
1187
|
-
try {
|
|
1188
|
-
const response = await getRecord({
|
|
1189
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
|
|
1190
|
-
...fetchProps
|
|
1603
|
+
__privateAdd$4(this, _schemaTables$2, void 0);
|
|
1604
|
+
__privateAdd$4(this, _trace, void 0);
|
|
1605
|
+
__privateSet$4(this, _table, options.table);
|
|
1606
|
+
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
|
1607
|
+
__privateSet$4(this, _db, options.db);
|
|
1608
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
|
1609
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
|
1610
|
+
const trace = options.pluginOptions.trace ?? defaultTrace;
|
|
1611
|
+
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
|
1612
|
+
return trace(name, fn, {
|
|
1613
|
+
...options2,
|
|
1614
|
+
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
|
1615
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
|
1616
|
+
[TraceAttributes.VERSION]: VERSION
|
|
1191
1617
|
});
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
async create(a, b, c) {
|
|
1621
|
+
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
|
1622
|
+
if (Array.isArray(a)) {
|
|
1623
|
+
if (a.length === 0)
|
|
1624
|
+
return [];
|
|
1625
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
1626
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
|
1196
1627
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1628
|
+
if (isString(a) && isObject(b)) {
|
|
1629
|
+
if (a === "")
|
|
1630
|
+
throw new Error("The id can't be empty");
|
|
1631
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
1632
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
|
1633
|
+
}
|
|
1634
|
+
if (isObject(a) && isString(a.id)) {
|
|
1635
|
+
if (a.id === "")
|
|
1636
|
+
throw new Error("The id can't be empty");
|
|
1637
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
1638
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
1639
|
+
}
|
|
1640
|
+
if (isObject(a)) {
|
|
1641
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
1642
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
|
1643
|
+
}
|
|
1644
|
+
throw new Error("Invalid arguments for create method");
|
|
1645
|
+
});
|
|
1199
1646
|
}
|
|
1200
|
-
async
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1647
|
+
async read(a, b) {
|
|
1648
|
+
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
|
1649
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
1650
|
+
if (Array.isArray(a)) {
|
|
1651
|
+
if (a.length === 0)
|
|
1652
|
+
return [];
|
|
1653
|
+
const ids = a.map((item) => extractId(item));
|
|
1654
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
|
|
1655
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
|
1656
|
+
acc[object.id] = object;
|
|
1657
|
+
return acc;
|
|
1658
|
+
}, {});
|
|
1659
|
+
return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
|
|
1204
1660
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1661
|
+
const id = extractId(a);
|
|
1662
|
+
if (id) {
|
|
1663
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1664
|
+
try {
|
|
1665
|
+
const response = await getRecord({
|
|
1666
|
+
pathParams: {
|
|
1667
|
+
workspace: "{workspaceId}",
|
|
1668
|
+
dbBranchName: "{dbBranch}",
|
|
1669
|
+
tableName: __privateGet$4(this, _table),
|
|
1670
|
+
recordId: id
|
|
1671
|
+
},
|
|
1672
|
+
queryParams: { columns },
|
|
1673
|
+
...fetchProps
|
|
1674
|
+
});
|
|
1675
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1676
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1677
|
+
} catch (e) {
|
|
1678
|
+
if (isObject(e) && e.status === 404) {
|
|
1679
|
+
return null;
|
|
1680
|
+
}
|
|
1681
|
+
throw e;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
return null;
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
async update(a, b, c) {
|
|
1688
|
+
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
|
1689
|
+
if (Array.isArray(a)) {
|
|
1690
|
+
if (a.length === 0)
|
|
1691
|
+
return [];
|
|
1692
|
+
if (a.length > 100) {
|
|
1693
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
|
1694
|
+
}
|
|
1695
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
1696
|
+
return Promise.all(a.map((object) => this.update(object, columns)));
|
|
1697
|
+
}
|
|
1698
|
+
if (isString(a) && isObject(b)) {
|
|
1699
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
1700
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
|
1701
|
+
}
|
|
1702
|
+
if (isObject(a) && isString(a.id)) {
|
|
1703
|
+
const columns = isStringArray(b) ? b : void 0;
|
|
1704
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
1705
|
+
}
|
|
1706
|
+
throw new Error("Invalid arguments for update method");
|
|
1707
|
+
});
|
|
1220
1708
|
}
|
|
1221
|
-
async createOrUpdate(a, b) {
|
|
1222
|
-
|
|
1223
|
-
if (a
|
|
1224
|
-
|
|
1709
|
+
async createOrUpdate(a, b, c) {
|
|
1710
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
|
1711
|
+
if (Array.isArray(a)) {
|
|
1712
|
+
if (a.length === 0)
|
|
1713
|
+
return [];
|
|
1714
|
+
if (a.length > 100) {
|
|
1715
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
|
1716
|
+
}
|
|
1717
|
+
const columns = isStringArray(b) ? b : ["*"];
|
|
1718
|
+
return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
|
|
1225
1719
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
|
1237
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
|
1238
|
-
return record;
|
|
1239
|
-
}
|
|
1240
|
-
throw new Error("Invalid arguments for createOrUpdate method");
|
|
1720
|
+
if (isString(a) && isObject(b)) {
|
|
1721
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
1722
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
|
1723
|
+
}
|
|
1724
|
+
if (isObject(a) && isString(a.id)) {
|
|
1725
|
+
const columns = isStringArray(c) ? c : void 0;
|
|
1726
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
|
1727
|
+
}
|
|
1728
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
|
1729
|
+
});
|
|
1241
1730
|
}
|
|
1242
|
-
async delete(a) {
|
|
1243
|
-
|
|
1244
|
-
if (a
|
|
1245
|
-
|
|
1731
|
+
async delete(a, b) {
|
|
1732
|
+
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
|
1733
|
+
if (Array.isArray(a)) {
|
|
1734
|
+
if (a.length === 0)
|
|
1735
|
+
return [];
|
|
1736
|
+
if (a.length > 100) {
|
|
1737
|
+
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
|
1738
|
+
}
|
|
1739
|
+
return Promise.all(a.map((id) => this.delete(id, b)));
|
|
1246
1740
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
}
|
|
1255
|
-
if (isObject(a) && isString(a.id)) {
|
|
1256
|
-
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
|
|
1257
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
|
1258
|
-
return;
|
|
1259
|
-
}
|
|
1260
|
-
throw new Error("Invalid arguments for delete method");
|
|
1741
|
+
if (isString(a)) {
|
|
1742
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
|
1743
|
+
}
|
|
1744
|
+
if (isObject(a) && isString(a.id)) {
|
|
1745
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
|
|
1746
|
+
}
|
|
1747
|
+
throw new Error("Invalid arguments for delete method");
|
|
1748
|
+
});
|
|
1261
1749
|
}
|
|
1262
1750
|
async search(query, options = {}) {
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1751
|
+
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
|
1752
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1753
|
+
const { records } = await searchTable({
|
|
1754
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
|
1755
|
+
body: {
|
|
1756
|
+
query,
|
|
1757
|
+
fuzziness: options.fuzziness,
|
|
1758
|
+
prefix: options.prefix,
|
|
1759
|
+
highlight: options.highlight,
|
|
1760
|
+
filter: options.filter,
|
|
1761
|
+
boosters: options.boosters
|
|
1762
|
+
},
|
|
1763
|
+
...fetchProps
|
|
1764
|
+
});
|
|
1765
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1766
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
|
1268
1767
|
});
|
|
1269
|
-
return records.map((item) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), item));
|
|
1270
1768
|
}
|
|
1271
1769
|
async query(query) {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1770
|
+
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
|
1771
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
|
1772
|
+
if (cacheQuery)
|
|
1773
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
|
1774
|
+
const data = query.getQueryOptions();
|
|
1775
|
+
const body = {
|
|
1776
|
+
filter: cleanFilter(data.filter),
|
|
1777
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
|
1778
|
+
page: data.pagination,
|
|
1779
|
+
columns: data.columns
|
|
1780
|
+
};
|
|
1781
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1782
|
+
const { meta, records: objects } = await queryTable({
|
|
1783
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
|
1784
|
+
body,
|
|
1785
|
+
...fetchProps
|
|
1786
|
+
});
|
|
1787
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1788
|
+
const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
|
|
1789
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
|
1790
|
+
return new Page(query, meta, records);
|
|
1287
1791
|
});
|
|
1288
|
-
const records = objects.map((record) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), record));
|
|
1289
|
-
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
|
1290
|
-
return new Page(query, meta, records);
|
|
1291
1792
|
}
|
|
1292
1793
|
}
|
|
1293
1794
|
_table = new WeakMap();
|
|
1294
|
-
_links = new WeakMap();
|
|
1295
1795
|
_getFetchProps = new WeakMap();
|
|
1796
|
+
_db = new WeakMap();
|
|
1296
1797
|
_cache = new WeakMap();
|
|
1798
|
+
_schemaTables$2 = new WeakMap();
|
|
1799
|
+
_trace = new WeakMap();
|
|
1297
1800
|
_insertRecordWithoutId = new WeakSet();
|
|
1298
|
-
insertRecordWithoutId_fn = async function(object) {
|
|
1299
|
-
const fetchProps = await __privateGet$
|
|
1801
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
1802
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1300
1803
|
const record = transformObjectLinks(object);
|
|
1301
1804
|
const response = await insertRecord({
|
|
1302
1805
|
pathParams: {
|
|
1303
1806
|
workspace: "{workspaceId}",
|
|
1304
1807
|
dbBranchName: "{dbBranch}",
|
|
1305
|
-
tableName: __privateGet$
|
|
1808
|
+
tableName: __privateGet$4(this, _table)
|
|
1306
1809
|
},
|
|
1810
|
+
queryParams: { columns },
|
|
1307
1811
|
body: record,
|
|
1308
1812
|
...fetchProps
|
|
1309
1813
|
});
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1312
|
-
throw new Error("The server failed to save the record");
|
|
1313
|
-
}
|
|
1314
|
-
return finalObject;
|
|
1814
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1815
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1315
1816
|
};
|
|
1316
1817
|
_insertRecordWithId = new WeakSet();
|
|
1317
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
|
1318
|
-
const fetchProps = await __privateGet$
|
|
1818
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
|
1819
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1319
1820
|
const record = transformObjectLinks(object);
|
|
1320
1821
|
const response = await insertRecordWithID({
|
|
1321
1822
|
pathParams: {
|
|
1322
1823
|
workspace: "{workspaceId}",
|
|
1323
1824
|
dbBranchName: "{dbBranch}",
|
|
1324
|
-
tableName: __privateGet$
|
|
1825
|
+
tableName: __privateGet$4(this, _table),
|
|
1325
1826
|
recordId
|
|
1326
1827
|
},
|
|
1327
1828
|
body: record,
|
|
1328
|
-
queryParams: { createOnly: true },
|
|
1829
|
+
queryParams: { createOnly: true, columns },
|
|
1329
1830
|
...fetchProps
|
|
1330
1831
|
});
|
|
1331
|
-
const
|
|
1332
|
-
|
|
1333
|
-
throw new Error("The server failed to save the record");
|
|
1334
|
-
}
|
|
1335
|
-
return finalObject;
|
|
1832
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1833
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1336
1834
|
};
|
|
1337
1835
|
_bulkInsertTableRecords = new WeakSet();
|
|
1338
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
|
1339
|
-
const fetchProps = await __privateGet$
|
|
1836
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
1837
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1340
1838
|
const records = objects.map((object) => transformObjectLinks(object));
|
|
1341
1839
|
const response = await bulkInsertTableRecords({
|
|
1342
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
|
1840
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
|
1841
|
+
queryParams: { columns },
|
|
1343
1842
|
body: { records },
|
|
1344
1843
|
...fetchProps
|
|
1345
1844
|
});
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
throw new Error("The server failed to save some records");
|
|
1845
|
+
if (!isResponseWithRecords(response)) {
|
|
1846
|
+
throw new Error("Request included columns but server didn't include them");
|
|
1349
1847
|
}
|
|
1350
|
-
|
|
1848
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1849
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
|
1351
1850
|
};
|
|
1352
1851
|
_updateRecordWithID = new WeakSet();
|
|
1353
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
|
1354
|
-
const fetchProps = await __privateGet$
|
|
1852
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1853
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1355
1854
|
const record = transformObjectLinks(object);
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1855
|
+
try {
|
|
1856
|
+
const response = await updateRecordWithID({
|
|
1857
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
|
1858
|
+
queryParams: { columns },
|
|
1859
|
+
body: record,
|
|
1860
|
+
...fetchProps
|
|
1861
|
+
});
|
|
1862
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1863
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1864
|
+
} catch (e) {
|
|
1865
|
+
if (isObject(e) && e.status === 404) {
|
|
1866
|
+
return null;
|
|
1867
|
+
}
|
|
1868
|
+
throw e;
|
|
1869
|
+
}
|
|
1365
1870
|
};
|
|
1366
1871
|
_upsertRecordWithID = new WeakSet();
|
|
1367
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
|
1368
|
-
const fetchProps = await __privateGet$
|
|
1872
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
1873
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1369
1874
|
const response = await upsertRecordWithID({
|
|
1370
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
|
1875
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
|
1876
|
+
queryParams: { columns },
|
|
1371
1877
|
body: object,
|
|
1372
1878
|
...fetchProps
|
|
1373
1879
|
});
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1376
|
-
throw new Error("The server failed to save the record");
|
|
1377
|
-
return item;
|
|
1880
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1881
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1378
1882
|
};
|
|
1379
1883
|
_deleteRecord = new WeakSet();
|
|
1380
|
-
deleteRecord_fn = async function(recordId) {
|
|
1381
|
-
const fetchProps = await __privateGet$
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
await __privateGet$3(this, _cache).delete(key);
|
|
1884
|
+
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
1885
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1886
|
+
try {
|
|
1887
|
+
const response = await deleteRecord({
|
|
1888
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
|
1889
|
+
queryParams: { columns },
|
|
1890
|
+
...fetchProps
|
|
1891
|
+
});
|
|
1892
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1893
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1894
|
+
} catch (e) {
|
|
1895
|
+
if (isObject(e) && e.status === 404) {
|
|
1896
|
+
return null;
|
|
1897
|
+
}
|
|
1898
|
+
throw e;
|
|
1396
1899
|
}
|
|
1397
1900
|
};
|
|
1398
|
-
_setCacheRecord = new WeakSet();
|
|
1399
|
-
setCacheRecord_fn = async function(record) {
|
|
1400
|
-
if (!__privateGet$3(this, _cache).cacheRecords)
|
|
1401
|
-
return;
|
|
1402
|
-
await __privateGet$3(this, _cache).set(`rec_${__privateGet$3(this, _table)}:${record.id}`, record);
|
|
1403
|
-
};
|
|
1404
|
-
_getCacheRecord = new WeakSet();
|
|
1405
|
-
getCacheRecord_fn = async function(recordId) {
|
|
1406
|
-
if (!__privateGet$3(this, _cache).cacheRecords)
|
|
1407
|
-
return null;
|
|
1408
|
-
return __privateGet$3(this, _cache).get(`rec_${__privateGet$3(this, _table)}:${recordId}`);
|
|
1409
|
-
};
|
|
1410
1901
|
_setCacheQuery = new WeakSet();
|
|
1411
1902
|
setCacheQuery_fn = async function(query, meta, records) {
|
|
1412
|
-
await __privateGet$
|
|
1903
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
|
1413
1904
|
};
|
|
1414
1905
|
_getCacheQuery = new WeakSet();
|
|
1415
1906
|
getCacheQuery_fn = async function(query) {
|
|
1416
|
-
const key = `query_${__privateGet$
|
|
1417
|
-
const result = await __privateGet$
|
|
1907
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
|
1908
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
|
1418
1909
|
if (!result)
|
|
1419
1910
|
return null;
|
|
1420
|
-
const { cache: ttl = __privateGet$
|
|
1421
|
-
if (
|
|
1422
|
-
return
|
|
1911
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
|
1912
|
+
if (ttl < 0)
|
|
1913
|
+
return null;
|
|
1423
1914
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
|
1424
1915
|
return hasExpired ? null : result;
|
|
1425
1916
|
};
|
|
1917
|
+
_getSchemaTables$1 = new WeakSet();
|
|
1918
|
+
getSchemaTables_fn$1 = async function() {
|
|
1919
|
+
if (__privateGet$4(this, _schemaTables$2))
|
|
1920
|
+
return __privateGet$4(this, _schemaTables$2);
|
|
1921
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
|
1922
|
+
const { schema } = await getBranchDetails({
|
|
1923
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
1924
|
+
...fetchProps
|
|
1925
|
+
});
|
|
1926
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
|
1927
|
+
return schema.tables;
|
|
1928
|
+
};
|
|
1426
1929
|
const transformObjectLinks = (object) => {
|
|
1427
1930
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
|
1428
1931
|
if (key === "xata")
|
|
@@ -1430,47 +1933,76 @@ const transformObjectLinks = (object) => {
|
|
|
1430
1933
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
|
1431
1934
|
}, {});
|
|
1432
1935
|
};
|
|
1433
|
-
const initObject = (db,
|
|
1936
|
+
const initObject = (db, schemaTables, table, object) => {
|
|
1434
1937
|
const result = {};
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1938
|
+
const { xata, ...rest } = object ?? {};
|
|
1939
|
+
Object.assign(result, rest);
|
|
1940
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
|
1941
|
+
if (!columns)
|
|
1942
|
+
console.error(`Table ${table} not found in schema`);
|
|
1943
|
+
for (const column of columns ?? []) {
|
|
1944
|
+
const value = result[column.name];
|
|
1945
|
+
switch (column.type) {
|
|
1946
|
+
case "datetime": {
|
|
1947
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
|
1948
|
+
if (date && isNaN(date.getTime())) {
|
|
1949
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
|
1950
|
+
} else if (date) {
|
|
1951
|
+
result[column.name] = date;
|
|
1952
|
+
}
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
case "link": {
|
|
1956
|
+
const linkTable = column.link?.table;
|
|
1957
|
+
if (!linkTable) {
|
|
1958
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
|
1959
|
+
} else if (isObject(value)) {
|
|
1960
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value);
|
|
1961
|
+
}
|
|
1962
|
+
break;
|
|
1963
|
+
}
|
|
1442
1964
|
}
|
|
1443
1965
|
}
|
|
1444
|
-
result.read = function() {
|
|
1445
|
-
return db[table].read(result["id"]);
|
|
1966
|
+
result.read = function(columns2) {
|
|
1967
|
+
return db[table].read(result["id"], columns2);
|
|
1446
1968
|
};
|
|
1447
|
-
result.update = function(data) {
|
|
1448
|
-
return db[table].update(result["id"], data);
|
|
1969
|
+
result.update = function(data, columns2) {
|
|
1970
|
+
return db[table].update(result["id"], data, columns2);
|
|
1449
1971
|
};
|
|
1450
1972
|
result.delete = function() {
|
|
1451
1973
|
return db[table].delete(result["id"]);
|
|
1452
1974
|
};
|
|
1453
|
-
|
|
1975
|
+
result.getMetadata = function() {
|
|
1976
|
+
return xata;
|
|
1977
|
+
};
|
|
1978
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
|
1454
1979
|
Object.defineProperty(result, prop, { enumerable: false });
|
|
1455
1980
|
}
|
|
1456
1981
|
Object.freeze(result);
|
|
1457
1982
|
return result;
|
|
1458
1983
|
};
|
|
1459
|
-
function
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
if (
|
|
1464
|
-
return
|
|
1465
|
-
|
|
1466
|
-
|
|
1984
|
+
function isResponseWithRecords(value) {
|
|
1985
|
+
return isObject(value) && Array.isArray(value.records);
|
|
1986
|
+
}
|
|
1987
|
+
function extractId(value) {
|
|
1988
|
+
if (isString(value))
|
|
1989
|
+
return value;
|
|
1990
|
+
if (isObject(value) && isString(value.id))
|
|
1991
|
+
return value.id;
|
|
1992
|
+
return void 0;
|
|
1993
|
+
}
|
|
1994
|
+
function cleanFilter(filter) {
|
|
1995
|
+
if (!filter)
|
|
1996
|
+
return void 0;
|
|
1997
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
|
1998
|
+
return values.length > 0 ? filter : void 0;
|
|
1467
1999
|
}
|
|
1468
2000
|
|
|
1469
2001
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
1470
2002
|
if (!member.has(obj))
|
|
1471
2003
|
throw TypeError("Cannot " + msg);
|
|
1472
2004
|
};
|
|
1473
|
-
var __privateGet$
|
|
2005
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
1474
2006
|
__accessCheck$3(obj, member, "read from private field");
|
|
1475
2007
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1476
2008
|
};
|
|
@@ -1479,7 +2011,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
|
1479
2011
|
throw TypeError("Cannot add the same private member more than once");
|
|
1480
2012
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1481
2013
|
};
|
|
1482
|
-
var __privateSet$
|
|
2014
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
|
1483
2015
|
__accessCheck$3(obj, member, "write to private field");
|
|
1484
2016
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1485
2017
|
return value;
|
|
@@ -1488,46 +2020,52 @@ var _map;
|
|
|
1488
2020
|
class SimpleCache {
|
|
1489
2021
|
constructor(options = {}) {
|
|
1490
2022
|
__privateAdd$3(this, _map, void 0);
|
|
1491
|
-
__privateSet$
|
|
2023
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
|
1492
2024
|
this.capacity = options.max ?? 500;
|
|
1493
|
-
this.cacheRecords = options.cacheRecords ?? true;
|
|
1494
2025
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
|
1495
2026
|
}
|
|
1496
2027
|
async getAll() {
|
|
1497
|
-
return Object.fromEntries(__privateGet$
|
|
2028
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
|
1498
2029
|
}
|
|
1499
2030
|
async get(key) {
|
|
1500
|
-
return __privateGet$
|
|
2031
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
|
1501
2032
|
}
|
|
1502
2033
|
async set(key, value) {
|
|
1503
2034
|
await this.delete(key);
|
|
1504
|
-
__privateGet$
|
|
1505
|
-
if (__privateGet$
|
|
1506
|
-
const leastRecentlyUsed = __privateGet$
|
|
2035
|
+
__privateGet$3(this, _map).set(key, value);
|
|
2036
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
|
2037
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
|
1507
2038
|
await this.delete(leastRecentlyUsed);
|
|
1508
2039
|
}
|
|
1509
2040
|
}
|
|
1510
2041
|
async delete(key) {
|
|
1511
|
-
__privateGet$
|
|
2042
|
+
__privateGet$3(this, _map).delete(key);
|
|
1512
2043
|
}
|
|
1513
2044
|
async clear() {
|
|
1514
|
-
return __privateGet$
|
|
2045
|
+
return __privateGet$3(this, _map).clear();
|
|
1515
2046
|
}
|
|
1516
2047
|
}
|
|
1517
2048
|
_map = new WeakMap();
|
|
1518
2049
|
|
|
1519
|
-
const
|
|
1520
|
-
const
|
|
1521
|
-
const
|
|
1522
|
-
const
|
|
1523
|
-
const
|
|
1524
|
-
const
|
|
2050
|
+
const greaterThan = (value) => ({ $gt: value });
|
|
2051
|
+
const gt = greaterThan;
|
|
2052
|
+
const greaterThanEquals = (value) => ({ $ge: value });
|
|
2053
|
+
const greaterEquals = greaterThanEquals;
|
|
2054
|
+
const gte = greaterThanEquals;
|
|
2055
|
+
const ge = greaterThanEquals;
|
|
2056
|
+
const lessThan = (value) => ({ $lt: value });
|
|
2057
|
+
const lt = lessThan;
|
|
2058
|
+
const lessThanEquals = (value) => ({ $le: value });
|
|
2059
|
+
const lessEquals = lessThanEquals;
|
|
2060
|
+
const lte = lessThanEquals;
|
|
2061
|
+
const le = lessThanEquals;
|
|
1525
2062
|
const exists = (column) => ({ $exists: column });
|
|
1526
2063
|
const notExists = (column) => ({ $notExists: column });
|
|
1527
2064
|
const startsWith = (value) => ({ $startsWith: value });
|
|
1528
2065
|
const endsWith = (value) => ({ $endsWith: value });
|
|
1529
2066
|
const pattern = (value) => ({ $pattern: value });
|
|
1530
2067
|
const is = (value) => ({ $is: value });
|
|
2068
|
+
const equals = is;
|
|
1531
2069
|
const isNot = (value) => ({ $isNot: value });
|
|
1532
2070
|
const contains = (value) => ({ $contains: value });
|
|
1533
2071
|
const includes = (value) => ({ $includes: value });
|
|
@@ -1539,7 +2077,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
|
1539
2077
|
if (!member.has(obj))
|
|
1540
2078
|
throw TypeError("Cannot " + msg);
|
|
1541
2079
|
};
|
|
1542
|
-
var __privateGet$
|
|
2080
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
1543
2081
|
__accessCheck$2(obj, member, "read from private field");
|
|
1544
2082
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1545
2083
|
};
|
|
@@ -1548,130 +2086,178 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
|
1548
2086
|
throw TypeError("Cannot add the same private member more than once");
|
|
1549
2087
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1550
2088
|
};
|
|
1551
|
-
var
|
|
2089
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
|
2090
|
+
__accessCheck$2(obj, member, "write to private field");
|
|
2091
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
2092
|
+
return value;
|
|
2093
|
+
};
|
|
2094
|
+
var _tables, _schemaTables$1;
|
|
1552
2095
|
class SchemaPlugin extends XataPlugin {
|
|
1553
|
-
constructor(
|
|
2096
|
+
constructor(schemaTables) {
|
|
1554
2097
|
super();
|
|
1555
|
-
this.links = links;
|
|
1556
|
-
this.tableNames = tableNames;
|
|
1557
2098
|
__privateAdd$2(this, _tables, {});
|
|
2099
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
|
2100
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
|
1558
2101
|
}
|
|
1559
2102
|
build(pluginOptions) {
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
__privateGet$
|
|
2103
|
+
const db = new Proxy(
|
|
2104
|
+
{},
|
|
2105
|
+
{
|
|
2106
|
+
get: (_target, table) => {
|
|
2107
|
+
if (!isString(table))
|
|
2108
|
+
throw new Error("Invalid table name");
|
|
2109
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
|
2110
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
|
2111
|
+
}
|
|
2112
|
+
return __privateGet$2(this, _tables)[table];
|
|
1567
2113
|
}
|
|
1568
|
-
return __privateGet$1(this, _tables)[table];
|
|
1569
2114
|
}
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
2115
|
+
);
|
|
2116
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
|
2117
|
+
for (const table of tableNames) {
|
|
2118
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
|
1573
2119
|
}
|
|
1574
2120
|
return db;
|
|
1575
2121
|
}
|
|
1576
2122
|
}
|
|
1577
2123
|
_tables = new WeakMap();
|
|
2124
|
+
_schemaTables$1 = new WeakMap();
|
|
1578
2125
|
|
|
1579
2126
|
var __accessCheck$1 = (obj, member, msg) => {
|
|
1580
2127
|
if (!member.has(obj))
|
|
1581
2128
|
throw TypeError("Cannot " + msg);
|
|
1582
2129
|
};
|
|
2130
|
+
var __privateGet$1 = (obj, member, getter) => {
|
|
2131
|
+
__accessCheck$1(obj, member, "read from private field");
|
|
2132
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
2133
|
+
};
|
|
1583
2134
|
var __privateAdd$1 = (obj, member, value) => {
|
|
1584
2135
|
if (member.has(obj))
|
|
1585
2136
|
throw TypeError("Cannot add the same private member more than once");
|
|
1586
2137
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1587
2138
|
};
|
|
2139
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
|
2140
|
+
__accessCheck$1(obj, member, "write to private field");
|
|
2141
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
2142
|
+
return value;
|
|
2143
|
+
};
|
|
1588
2144
|
var __privateMethod$1 = (obj, member, method) => {
|
|
1589
2145
|
__accessCheck$1(obj, member, "access private method");
|
|
1590
2146
|
return method;
|
|
1591
2147
|
};
|
|
1592
|
-
var _search, search_fn;
|
|
2148
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
|
1593
2149
|
class SearchPlugin extends XataPlugin {
|
|
1594
|
-
constructor(db,
|
|
2150
|
+
constructor(db, schemaTables) {
|
|
1595
2151
|
super();
|
|
1596
2152
|
this.db = db;
|
|
1597
|
-
this.links = links;
|
|
1598
2153
|
__privateAdd$1(this, _search);
|
|
2154
|
+
__privateAdd$1(this, _getSchemaTables);
|
|
2155
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
|
2156
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
|
1599
2157
|
}
|
|
1600
2158
|
build({ getFetchProps }) {
|
|
1601
2159
|
return {
|
|
1602
2160
|
all: async (query, options = {}) => {
|
|
1603
2161
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
|
2162
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
|
1604
2163
|
return records.map((record) => {
|
|
1605
2164
|
const { table = "orphan" } = record.xata;
|
|
1606
|
-
return { table, record: initObject(this.db,
|
|
2165
|
+
return { table, record: initObject(this.db, schemaTables, table, record) };
|
|
1607
2166
|
});
|
|
1608
2167
|
},
|
|
1609
2168
|
byTable: async (query, options = {}) => {
|
|
1610
2169
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
|
2170
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
|
1611
2171
|
return records.reduce((acc, record) => {
|
|
1612
2172
|
const { table = "orphan" } = record.xata;
|
|
1613
2173
|
const items = acc[table] ?? [];
|
|
1614
|
-
const item = initObject(this.db,
|
|
2174
|
+
const item = initObject(this.db, schemaTables, table, record);
|
|
1615
2175
|
return { ...acc, [table]: [...items, item] };
|
|
1616
2176
|
}, {});
|
|
1617
2177
|
}
|
|
1618
2178
|
};
|
|
1619
2179
|
}
|
|
1620
2180
|
}
|
|
2181
|
+
_schemaTables = new WeakMap();
|
|
1621
2182
|
_search = new WeakSet();
|
|
1622
2183
|
search_fn = async function(query, options, getFetchProps) {
|
|
1623
2184
|
const fetchProps = await getFetchProps();
|
|
1624
|
-
const { tables, fuzziness } = options ?? {};
|
|
2185
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
|
1625
2186
|
const { records } = await searchBranch({
|
|
1626
2187
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
1627
|
-
body: { tables, query, fuzziness },
|
|
2188
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
|
1628
2189
|
...fetchProps
|
|
1629
2190
|
});
|
|
1630
2191
|
return records;
|
|
1631
2192
|
};
|
|
2193
|
+
_getSchemaTables = new WeakSet();
|
|
2194
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
|
2195
|
+
if (__privateGet$1(this, _schemaTables))
|
|
2196
|
+
return __privateGet$1(this, _schemaTables);
|
|
2197
|
+
const fetchProps = await getFetchProps();
|
|
2198
|
+
const { schema } = await getBranchDetails({
|
|
2199
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
|
2200
|
+
...fetchProps
|
|
2201
|
+
});
|
|
2202
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
|
2203
|
+
return schema.tables;
|
|
2204
|
+
};
|
|
1632
2205
|
|
|
1633
2206
|
const isBranchStrategyBuilder = (strategy) => {
|
|
1634
2207
|
return typeof strategy === "function";
|
|
1635
2208
|
};
|
|
1636
2209
|
|
|
1637
|
-
const envBranchNames = [
|
|
1638
|
-
"XATA_BRANCH",
|
|
1639
|
-
"VERCEL_GIT_COMMIT_REF",
|
|
1640
|
-
"CF_PAGES_BRANCH",
|
|
1641
|
-
"BRANCH"
|
|
1642
|
-
];
|
|
1643
|
-
const defaultBranch = "main";
|
|
1644
2210
|
async function getCurrentBranchName(options) {
|
|
1645
|
-
const
|
|
1646
|
-
if (
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
return defaultBranch;
|
|
2211
|
+
const { branch, envBranch } = getEnvironment();
|
|
2212
|
+
if (branch) {
|
|
2213
|
+
const details = await getDatabaseBranch(branch, options);
|
|
2214
|
+
if (details)
|
|
2215
|
+
return branch;
|
|
2216
|
+
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
|
2217
|
+
}
|
|
2218
|
+
const gitBranch = envBranch || await getGitBranch();
|
|
2219
|
+
return resolveXataBranch(gitBranch, options);
|
|
1655
2220
|
}
|
|
1656
2221
|
async function getCurrentBranchDetails(options) {
|
|
1657
|
-
const
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
2222
|
+
const branch = await getCurrentBranchName(options);
|
|
2223
|
+
return getDatabaseBranch(branch, options);
|
|
2224
|
+
}
|
|
2225
|
+
async function resolveXataBranch(gitBranch, options) {
|
|
2226
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2227
|
+
const apiKey = options?.apiKey || getAPIKey();
|
|
2228
|
+
if (!databaseURL)
|
|
2229
|
+
throw new Error(
|
|
2230
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2231
|
+
);
|
|
2232
|
+
if (!apiKey)
|
|
2233
|
+
throw new Error(
|
|
2234
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2235
|
+
);
|
|
2236
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
|
2237
|
+
const [workspace] = host.split(".");
|
|
2238
|
+
const { fallbackBranch } = getEnvironment();
|
|
2239
|
+
const { branch } = await resolveBranch({
|
|
2240
|
+
apiKey,
|
|
2241
|
+
apiUrl: databaseURL,
|
|
2242
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
2243
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
|
2244
|
+
pathParams: { dbName, workspace },
|
|
2245
|
+
queryParams: { gitBranch, fallbackBranch },
|
|
2246
|
+
trace: defaultTrace
|
|
2247
|
+
});
|
|
2248
|
+
return branch;
|
|
1667
2249
|
}
|
|
1668
2250
|
async function getDatabaseBranch(branch, options) {
|
|
1669
2251
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
1670
2252
|
const apiKey = options?.apiKey || getAPIKey();
|
|
1671
2253
|
if (!databaseURL)
|
|
1672
|
-
throw new Error(
|
|
2254
|
+
throw new Error(
|
|
2255
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
|
2256
|
+
);
|
|
1673
2257
|
if (!apiKey)
|
|
1674
|
-
throw new Error(
|
|
2258
|
+
throw new Error(
|
|
2259
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
|
2260
|
+
);
|
|
1675
2261
|
const [protocol, , host, , database] = databaseURL.split("/");
|
|
1676
2262
|
const [workspace] = host.split(".");
|
|
1677
2263
|
const dbBranchName = `${database}:${branch}`;
|
|
@@ -1681,10 +2267,8 @@ async function getDatabaseBranch(branch, options) {
|
|
|
1681
2267
|
apiUrl: databaseURL,
|
|
1682
2268
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
|
1683
2269
|
workspacesApiUrl: `${protocol}//${host}`,
|
|
1684
|
-
pathParams: {
|
|
1685
|
-
|
|
1686
|
-
workspace
|
|
1687
|
-
}
|
|
2270
|
+
pathParams: { dbBranchName, workspace },
|
|
2271
|
+
trace: defaultTrace
|
|
1688
2272
|
});
|
|
1689
2273
|
} catch (err) {
|
|
1690
2274
|
if (isObject(err) && err.status === 404)
|
|
@@ -1692,21 +2276,10 @@ async function getDatabaseBranch(branch, options) {
|
|
|
1692
2276
|
throw err;
|
|
1693
2277
|
}
|
|
1694
2278
|
}
|
|
1695
|
-
function getBranchByEnvVariable() {
|
|
1696
|
-
for (const name of envBranchNames) {
|
|
1697
|
-
const value = getEnvVariable(name);
|
|
1698
|
-
if (value) {
|
|
1699
|
-
return value;
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
try {
|
|
1703
|
-
return XATA_BRANCH;
|
|
1704
|
-
} catch (err) {
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
2279
|
function getDatabaseURL() {
|
|
1708
2280
|
try {
|
|
1709
|
-
|
|
2281
|
+
const { databaseURL } = getEnvironment();
|
|
2282
|
+
return databaseURL;
|
|
1710
2283
|
} catch (err) {
|
|
1711
2284
|
return void 0;
|
|
1712
2285
|
}
|
|
@@ -1735,24 +2308,27 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1735
2308
|
return method;
|
|
1736
2309
|
};
|
|
1737
2310
|
const buildClient = (plugins) => {
|
|
1738
|
-
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
|
2311
|
+
var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
|
1739
2312
|
return _a = class {
|
|
1740
|
-
constructor(options = {},
|
|
2313
|
+
constructor(options = {}, schemaTables) {
|
|
1741
2314
|
__privateAdd(this, _parseOptions);
|
|
1742
2315
|
__privateAdd(this, _getFetchProps);
|
|
1743
2316
|
__privateAdd(this, _evaluateBranch);
|
|
1744
2317
|
__privateAdd(this, _branch, void 0);
|
|
2318
|
+
__privateAdd(this, _options, void 0);
|
|
1745
2319
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
|
2320
|
+
__privateSet(this, _options, safeOptions);
|
|
1746
2321
|
const pluginOptions = {
|
|
1747
2322
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
|
1748
|
-
cache: safeOptions.cache
|
|
2323
|
+
cache: safeOptions.cache,
|
|
2324
|
+
trace: safeOptions.trace
|
|
1749
2325
|
};
|
|
1750
|
-
const db = new SchemaPlugin(
|
|
1751
|
-
const search = new SearchPlugin(db,
|
|
2326
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
|
2327
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
|
1752
2328
|
this.db = db;
|
|
1753
2329
|
this.search = search;
|
|
1754
2330
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
|
1755
|
-
if (
|
|
2331
|
+
if (namespace === void 0)
|
|
1756
2332
|
continue;
|
|
1757
2333
|
const result = namespace.build(pluginOptions);
|
|
1758
2334
|
if (result instanceof Promise) {
|
|
@@ -1764,22 +2340,26 @@ const buildClient = (plugins) => {
|
|
|
1764
2340
|
}
|
|
1765
2341
|
}
|
|
1766
2342
|
}
|
|
1767
|
-
|
|
2343
|
+
async getConfig() {
|
|
2344
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
|
2345
|
+
const branch = await __privateGet(this, _options).branch();
|
|
2346
|
+
return { databaseURL, branch };
|
|
2347
|
+
}
|
|
2348
|
+
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
|
1768
2349
|
const fetch = getFetchImplementation(options?.fetch);
|
|
1769
2350
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
1770
2351
|
const apiKey = options?.apiKey || getAPIKey();
|
|
1771
|
-
const cache = options?.cache ?? new SimpleCache({
|
|
1772
|
-
const
|
|
1773
|
-
|
|
1774
|
-
|
|
2352
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
|
2353
|
+
const trace = options?.trace ?? defaultTrace;
|
|
2354
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
|
2355
|
+
if (!apiKey) {
|
|
2356
|
+
throw new Error("Option apiKey is required");
|
|
1775
2357
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
apiKey,
|
|
1780
|
-
|
|
1781
|
-
branch
|
|
1782
|
-
}) {
|
|
2358
|
+
if (!databaseURL) {
|
|
2359
|
+
throw new Error("Option databaseURL is required");
|
|
2360
|
+
}
|
|
2361
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
|
2362
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
|
1783
2363
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
|
1784
2364
|
if (!branchValue)
|
|
1785
2365
|
throw new Error("Unable to resolve branch value");
|
|
@@ -1789,14 +2369,15 @@ const buildClient = (plugins) => {
|
|
|
1789
2369
|
apiUrl: "",
|
|
1790
2370
|
workspacesApiUrl: (path, params) => {
|
|
1791
2371
|
const hasBranch = params.dbBranchName ?? params.branch;
|
|
1792
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
|
2372
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
|
1793
2373
|
return databaseURL + newPath;
|
|
1794
|
-
}
|
|
2374
|
+
},
|
|
2375
|
+
trace
|
|
1795
2376
|
};
|
|
1796
2377
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
|
1797
2378
|
if (__privateGet(this, _branch))
|
|
1798
2379
|
return __privateGet(this, _branch);
|
|
1799
|
-
if (
|
|
2380
|
+
if (param === void 0)
|
|
1800
2381
|
return void 0;
|
|
1801
2382
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
|
1802
2383
|
const evaluateBranch = async (strategy) => {
|
|
@@ -1814,6 +2395,88 @@ const buildClient = (plugins) => {
|
|
|
1814
2395
|
class BaseClient extends buildClient() {
|
|
1815
2396
|
}
|
|
1816
2397
|
|
|
2398
|
+
const META = "__";
|
|
2399
|
+
const VALUE = "___";
|
|
2400
|
+
class Serializer {
|
|
2401
|
+
constructor() {
|
|
2402
|
+
this.classes = {};
|
|
2403
|
+
}
|
|
2404
|
+
add(clazz) {
|
|
2405
|
+
this.classes[clazz.name] = clazz;
|
|
2406
|
+
}
|
|
2407
|
+
toJSON(data) {
|
|
2408
|
+
function visit(obj) {
|
|
2409
|
+
if (Array.isArray(obj))
|
|
2410
|
+
return obj.map(visit);
|
|
2411
|
+
const type = typeof obj;
|
|
2412
|
+
if (type === "undefined")
|
|
2413
|
+
return { [META]: "undefined" };
|
|
2414
|
+
if (type === "bigint")
|
|
2415
|
+
return { [META]: "bigint", [VALUE]: obj.toString() };
|
|
2416
|
+
if (obj === null || type !== "object")
|
|
2417
|
+
return obj;
|
|
2418
|
+
const constructor = obj.constructor;
|
|
2419
|
+
const o = { [META]: constructor.name };
|
|
2420
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2421
|
+
o[key] = visit(value);
|
|
2422
|
+
}
|
|
2423
|
+
if (constructor === Date)
|
|
2424
|
+
o[VALUE] = obj.toISOString();
|
|
2425
|
+
if (constructor === Map)
|
|
2426
|
+
o[VALUE] = Object.fromEntries(obj);
|
|
2427
|
+
if (constructor === Set)
|
|
2428
|
+
o[VALUE] = [...obj];
|
|
2429
|
+
return o;
|
|
2430
|
+
}
|
|
2431
|
+
return JSON.stringify(visit(data));
|
|
2432
|
+
}
|
|
2433
|
+
fromJSON(json) {
|
|
2434
|
+
return JSON.parse(json, (key, value) => {
|
|
2435
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2436
|
+
const { [META]: clazz, [VALUE]: val, ...rest } = value;
|
|
2437
|
+
const constructor = this.classes[clazz];
|
|
2438
|
+
if (constructor) {
|
|
2439
|
+
return Object.assign(Object.create(constructor.prototype), rest);
|
|
2440
|
+
}
|
|
2441
|
+
if (clazz === "Date")
|
|
2442
|
+
return new Date(val);
|
|
2443
|
+
if (clazz === "Set")
|
|
2444
|
+
return new Set(val);
|
|
2445
|
+
if (clazz === "Map")
|
|
2446
|
+
return new Map(Object.entries(val));
|
|
2447
|
+
if (clazz === "bigint")
|
|
2448
|
+
return BigInt(val);
|
|
2449
|
+
if (clazz === "undefined")
|
|
2450
|
+
return void 0;
|
|
2451
|
+
return rest;
|
|
2452
|
+
}
|
|
2453
|
+
return value;
|
|
2454
|
+
});
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
const defaultSerializer = new Serializer();
|
|
2458
|
+
const serialize = (data) => {
|
|
2459
|
+
return defaultSerializer.toJSON(data);
|
|
2460
|
+
};
|
|
2461
|
+
const deserialize = (json) => {
|
|
2462
|
+
return defaultSerializer.fromJSON(json);
|
|
2463
|
+
};
|
|
2464
|
+
|
|
2465
|
+
function buildWorkerRunner(config) {
|
|
2466
|
+
return function xataWorker(name, _worker) {
|
|
2467
|
+
return async (...args) => {
|
|
2468
|
+
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
|
2469
|
+
const result = await fetch(url, {
|
|
2470
|
+
method: "POST",
|
|
2471
|
+
headers: { "Content-Type": "application/json" },
|
|
2472
|
+
body: serialize({ args })
|
|
2473
|
+
});
|
|
2474
|
+
const text = await result.text();
|
|
2475
|
+
return deserialize(text);
|
|
2476
|
+
};
|
|
2477
|
+
};
|
|
2478
|
+
}
|
|
2479
|
+
|
|
1817
2480
|
class XataError extends Error {
|
|
1818
2481
|
constructor(message, status) {
|
|
1819
2482
|
super(message);
|
|
@@ -1829,24 +2492,32 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
|
|
|
1829
2492
|
exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
|
1830
2493
|
exports.Page = Page;
|
|
1831
2494
|
exports.Query = Query;
|
|
2495
|
+
exports.RecordArray = RecordArray;
|
|
1832
2496
|
exports.Repository = Repository;
|
|
1833
2497
|
exports.RestRepository = RestRepository;
|
|
1834
2498
|
exports.SchemaPlugin = SchemaPlugin;
|
|
1835
2499
|
exports.SearchPlugin = SearchPlugin;
|
|
2500
|
+
exports.Serializer = Serializer;
|
|
1836
2501
|
exports.SimpleCache = SimpleCache;
|
|
1837
2502
|
exports.XataApiClient = XataApiClient;
|
|
1838
2503
|
exports.XataApiPlugin = XataApiPlugin;
|
|
1839
2504
|
exports.XataError = XataError;
|
|
1840
2505
|
exports.XataPlugin = XataPlugin;
|
|
1841
2506
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
|
2507
|
+
exports.addGitBranchesEntry = addGitBranchesEntry;
|
|
1842
2508
|
exports.addTableColumn = addTableColumn;
|
|
2509
|
+
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
|
1843
2510
|
exports.buildClient = buildClient;
|
|
2511
|
+
exports.buildWorkerRunner = buildWorkerRunner;
|
|
1844
2512
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
|
1845
2513
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
|
1846
|
-
exports.
|
|
2514
|
+
exports.compareBranchSchemas = compareBranchSchemas;
|
|
2515
|
+
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
|
2516
|
+
exports.compareMigrationRequest = compareMigrationRequest;
|
|
1847
2517
|
exports.contains = contains;
|
|
1848
2518
|
exports.createBranch = createBranch;
|
|
1849
2519
|
exports.createDatabase = createDatabase;
|
|
2520
|
+
exports.createMigrationRequest = createMigrationRequest;
|
|
1850
2521
|
exports.createTable = createTable;
|
|
1851
2522
|
exports.createUserAPIKey = createUserAPIKey;
|
|
1852
2523
|
exports.createWorkspace = createWorkspace;
|
|
@@ -1858,7 +2529,9 @@ exports.deleteTable = deleteTable;
|
|
|
1858
2529
|
exports.deleteUser = deleteUser;
|
|
1859
2530
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
|
1860
2531
|
exports.deleteWorkspace = deleteWorkspace;
|
|
2532
|
+
exports.deserialize = deserialize;
|
|
1861
2533
|
exports.endsWith = endsWith;
|
|
2534
|
+
exports.equals = equals;
|
|
1862
2535
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
|
1863
2536
|
exports.exists = exists;
|
|
1864
2537
|
exports.ge = ge;
|
|
@@ -1874,7 +2547,11 @@ exports.getColumn = getColumn;
|
|
|
1874
2547
|
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
|
1875
2548
|
exports.getCurrentBranchName = getCurrentBranchName;
|
|
1876
2549
|
exports.getDatabaseList = getDatabaseList;
|
|
2550
|
+
exports.getDatabaseMetadata = getDatabaseMetadata;
|
|
1877
2551
|
exports.getDatabaseURL = getDatabaseURL;
|
|
2552
|
+
exports.getGitBranchesMapping = getGitBranchesMapping;
|
|
2553
|
+
exports.getMigrationRequest = getMigrationRequest;
|
|
2554
|
+
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
|
1878
2555
|
exports.getRecord = getRecord;
|
|
1879
2556
|
exports.getTableColumns = getTableColumns;
|
|
1880
2557
|
exports.getTableSchema = getTableSchema;
|
|
@@ -1883,6 +2560,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
|
|
|
1883
2560
|
exports.getWorkspace = getWorkspace;
|
|
1884
2561
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
|
1885
2562
|
exports.getWorkspacesList = getWorkspacesList;
|
|
2563
|
+
exports.greaterEquals = greaterEquals;
|
|
2564
|
+
exports.greaterThan = greaterThan;
|
|
2565
|
+
exports.greaterThanEquals = greaterThanEquals;
|
|
1886
2566
|
exports.gt = gt;
|
|
1887
2567
|
exports.gte = gte;
|
|
1888
2568
|
exports.includes = includes;
|
|
@@ -1893,28 +2573,43 @@ exports.insertRecord = insertRecord;
|
|
|
1893
2573
|
exports.insertRecordWithID = insertRecordWithID;
|
|
1894
2574
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
|
1895
2575
|
exports.is = is;
|
|
2576
|
+
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
|
1896
2577
|
exports.isIdentifiable = isIdentifiable;
|
|
1897
2578
|
exports.isNot = isNot;
|
|
1898
2579
|
exports.isXataRecord = isXataRecord;
|
|
1899
2580
|
exports.le = le;
|
|
2581
|
+
exports.lessEquals = lessEquals;
|
|
2582
|
+
exports.lessThan = lessThan;
|
|
2583
|
+
exports.lessThanEquals = lessThanEquals;
|
|
2584
|
+
exports.listMigrationRequests = listMigrationRequests;
|
|
2585
|
+
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
|
1900
2586
|
exports.lt = lt;
|
|
1901
2587
|
exports.lte = lte;
|
|
2588
|
+
exports.mergeMigrationRequest = mergeMigrationRequest;
|
|
1902
2589
|
exports.notExists = notExists;
|
|
1903
2590
|
exports.operationsByTag = operationsByTag;
|
|
2591
|
+
exports.patchDatabaseMetadata = patchDatabaseMetadata;
|
|
1904
2592
|
exports.pattern = pattern;
|
|
2593
|
+
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
|
1905
2594
|
exports.queryTable = queryTable;
|
|
2595
|
+
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
|
1906
2596
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
|
1907
2597
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
|
2598
|
+
exports.resolveBranch = resolveBranch;
|
|
1908
2599
|
exports.searchBranch = searchBranch;
|
|
2600
|
+
exports.searchTable = searchTable;
|
|
2601
|
+
exports.serialize = serialize;
|
|
1909
2602
|
exports.setTableSchema = setTableSchema;
|
|
1910
2603
|
exports.startsWith = startsWith;
|
|
1911
2604
|
exports.updateBranchMetadata = updateBranchMetadata;
|
|
1912
2605
|
exports.updateBranchSchema = updateBranchSchema;
|
|
1913
2606
|
exports.updateColumn = updateColumn;
|
|
2607
|
+
exports.updateMigrationRequest = updateMigrationRequest;
|
|
1914
2608
|
exports.updateRecordWithID = updateRecordWithID;
|
|
1915
2609
|
exports.updateTable = updateTable;
|
|
1916
2610
|
exports.updateUser = updateUser;
|
|
1917
2611
|
exports.updateWorkspace = updateWorkspace;
|
|
2612
|
+
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
|
1918
2613
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
|
1919
2614
|
exports.upsertRecordWithID = upsertRecordWithID;
|
|
1920
2615
|
//# sourceMappingURL=index.cjs.map
|