@xata.io/client 0.0.0-alpha.vf4b92f1 → 0.0.0-alpha.vf683143
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 +224 -0
- package/README.md +273 -1
- package/Usage.md +451 -0
- package/dist/index.cjs +1318 -513
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2144 -325
- package/dist/index.mjs +1265 -514
- 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.vf683143";
|
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",
|
408
|
+
method: "get",
|
409
|
+
...variables
|
410
|
+
});
|
411
|
+
const updateDatabaseMetadata = (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}",
|
257
424
|
method: "get",
|
258
425
|
...variables
|
259
426
|
});
|
260
|
-
const
|
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,6 +457,16 @@ 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 });
|
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 });
|
462
|
+
const updateBranchSchema = (variables) => fetch$1({
|
463
|
+
url: "/db/{dbBranchName}/schema/update",
|
464
|
+
method: "post",
|
465
|
+
...variables
|
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 });
|
469
|
+
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
283
470
|
const getBranchStats = (variables) => fetch$1({
|
284
471
|
url: "/db/{dbBranchName}/stats",
|
285
472
|
method: "get",
|
@@ -335,11 +522,7 @@ const updateColumn = (variables) => fetch$1({
|
|
335
522
|
method: "patch",
|
336
523
|
...variables
|
337
524
|
});
|
338
|
-
const insertRecord = (variables) => fetch$1({
|
339
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
340
|
-
method: "post",
|
341
|
-
...variables
|
342
|
-
});
|
525
|
+
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
343
526
|
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
344
527
|
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
345
528
|
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
@@ -359,11 +542,21 @@ const queryTable = (variables) => fetch$1({
|
|
359
542
|
method: "post",
|
360
543
|
...variables
|
361
544
|
});
|
545
|
+
const searchTable = (variables) => fetch$1({
|
546
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
547
|
+
method: "post",
|
548
|
+
...variables
|
549
|
+
});
|
362
550
|
const searchBranch = (variables) => fetch$1({
|
363
551
|
url: "/db/{dbBranchName}/search",
|
364
552
|
method: "post",
|
365
553
|
...variables
|
366
554
|
});
|
555
|
+
const summarizeTable = (variables) => fetch$1({
|
556
|
+
url: "/db/{dbBranchName}/tables/{tableName}/summarize",
|
557
|
+
method: "post",
|
558
|
+
...variables
|
559
|
+
});
|
367
560
|
const operationsByTag = {
|
368
561
|
users: { getUser, updateUser, deleteUser, getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
369
562
|
workspaces: {
|
@@ -376,11 +569,22 @@ const operationsByTag = {
|
|
376
569
|
updateWorkspaceMemberRole,
|
377
570
|
removeWorkspaceMember,
|
378
571
|
inviteWorkspaceMember,
|
572
|
+
updateWorkspaceMemberInvite,
|
379
573
|
cancelWorkspaceMemberInvite,
|
380
574
|
resendWorkspaceMemberInvite,
|
381
575
|
acceptWorkspaceMemberInvite
|
382
576
|
},
|
383
|
-
database: {
|
577
|
+
database: {
|
578
|
+
getDatabaseList,
|
579
|
+
createDatabase,
|
580
|
+
deleteDatabase,
|
581
|
+
getDatabaseMetadata,
|
582
|
+
updateDatabaseMetadata,
|
583
|
+
getGitBranchesMapping,
|
584
|
+
addGitBranchesEntry,
|
585
|
+
removeGitBranchesEntry,
|
586
|
+
resolveBranch
|
587
|
+
},
|
384
588
|
branch: {
|
385
589
|
getBranchList,
|
386
590
|
getBranchDetails,
|
@@ -388,10 +592,28 @@ const operationsByTag = {
|
|
388
592
|
deleteBranch,
|
389
593
|
updateBranchMetadata,
|
390
594
|
getBranchMetadata,
|
595
|
+
getBranchStats
|
596
|
+
},
|
597
|
+
migrationRequests: {
|
598
|
+
listMigrationRequests,
|
599
|
+
createMigrationRequest,
|
600
|
+
getMigrationRequest,
|
601
|
+
updateMigrationRequest,
|
602
|
+
listMigrationRequestsCommits,
|
603
|
+
compareMigrationRequest,
|
604
|
+
getMigrationRequestIsMerged,
|
605
|
+
mergeMigrationRequest
|
606
|
+
},
|
607
|
+
branchSchema: {
|
391
608
|
getBranchMigrationHistory,
|
392
609
|
executeBranchMigrationPlan,
|
393
610
|
getBranchMigrationPlan,
|
394
|
-
|
611
|
+
compareBranchWithUserSchema,
|
612
|
+
compareBranchSchemas,
|
613
|
+
updateBranchSchema,
|
614
|
+
previewBranchSchemaEdit,
|
615
|
+
applyBranchSchemaEdit,
|
616
|
+
getBranchSchemaHistory
|
395
617
|
},
|
396
618
|
table: {
|
397
619
|
createTable,
|
@@ -414,14 +636,16 @@ const operationsByTag = {
|
|
414
636
|
getRecord,
|
415
637
|
bulkInsertTableRecords,
|
416
638
|
queryTable,
|
417
|
-
|
639
|
+
searchTable,
|
640
|
+
searchBranch,
|
641
|
+
summarizeTable
|
418
642
|
}
|
419
643
|
};
|
420
644
|
|
421
645
|
function getHostUrl(provider, type) {
|
422
|
-
if (
|
646
|
+
if (isHostProviderAlias(provider)) {
|
423
647
|
return providers[provider][type];
|
424
|
-
} else if (
|
648
|
+
} else if (isHostProviderBuilder(provider)) {
|
425
649
|
return provider[type];
|
426
650
|
}
|
427
651
|
throw new Error("Invalid API provider");
|
@@ -436,10 +660,10 @@ const providers = {
|
|
436
660
|
workspaces: "https://{workspaceId}.staging.xatabase.co"
|
437
661
|
}
|
438
662
|
};
|
439
|
-
function
|
663
|
+
function isHostProviderAlias(alias) {
|
440
664
|
return isString(alias) && Object.keys(providers).includes(alias);
|
441
665
|
}
|
442
|
-
function
|
666
|
+
function isHostProviderBuilder(builder) {
|
443
667
|
return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
|
444
668
|
}
|
445
669
|
|
@@ -447,7 +671,7 @@ var __accessCheck$7 = (obj, member, msg) => {
|
|
447
671
|
if (!member.has(obj))
|
448
672
|
throw TypeError("Cannot " + msg);
|
449
673
|
};
|
450
|
-
var __privateGet$
|
674
|
+
var __privateGet$7 = (obj, member, getter) => {
|
451
675
|
__accessCheck$7(obj, member, "read from private field");
|
452
676
|
return getter ? getter.call(obj) : member.get(obj);
|
453
677
|
};
|
@@ -456,7 +680,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
456
680
|
throw TypeError("Cannot add the same private member more than once");
|
457
681
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
458
682
|
};
|
459
|
-
var __privateSet$
|
683
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
460
684
|
__accessCheck$7(obj, member, "write to private field");
|
461
685
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
462
686
|
return value;
|
@@ -467,46 +691,58 @@ class XataApiClient {
|
|
467
691
|
__privateAdd$7(this, _extraProps, void 0);
|
468
692
|
__privateAdd$7(this, _namespaces, {});
|
469
693
|
const provider = options.host ?? "production";
|
470
|
-
const apiKey = options
|
694
|
+
const apiKey = options.apiKey ?? getAPIKey();
|
695
|
+
const trace = options.trace ?? defaultTrace;
|
471
696
|
if (!apiKey) {
|
472
697
|
throw new Error("Could not resolve a valid apiKey");
|
473
698
|
}
|
474
|
-
__privateSet$
|
699
|
+
__privateSet$7(this, _extraProps, {
|
475
700
|
apiUrl: getHostUrl(provider, "main"),
|
476
701
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
477
702
|
fetchImpl: getFetchImplementation(options.fetch),
|
478
|
-
apiKey
|
703
|
+
apiKey,
|
704
|
+
trace
|
479
705
|
});
|
480
706
|
}
|
481
707
|
get user() {
|
482
|
-
if (!__privateGet$
|
483
|
-
__privateGet$
|
484
|
-
return __privateGet$
|
708
|
+
if (!__privateGet$7(this, _namespaces).user)
|
709
|
+
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
710
|
+
return __privateGet$7(this, _namespaces).user;
|
485
711
|
}
|
486
712
|
get workspaces() {
|
487
|
-
if (!__privateGet$
|
488
|
-
__privateGet$
|
489
|
-
return __privateGet$
|
713
|
+
if (!__privateGet$7(this, _namespaces).workspaces)
|
714
|
+
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
715
|
+
return __privateGet$7(this, _namespaces).workspaces;
|
490
716
|
}
|
491
717
|
get databases() {
|
492
|
-
if (!__privateGet$
|
493
|
-
__privateGet$
|
494
|
-
return __privateGet$
|
718
|
+
if (!__privateGet$7(this, _namespaces).databases)
|
719
|
+
__privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
|
720
|
+
return __privateGet$7(this, _namespaces).databases;
|
495
721
|
}
|
496
722
|
get branches() {
|
497
|
-
if (!__privateGet$
|
498
|
-
__privateGet$
|
499
|
-
return __privateGet$
|
723
|
+
if (!__privateGet$7(this, _namespaces).branches)
|
724
|
+
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
725
|
+
return __privateGet$7(this, _namespaces).branches;
|
500
726
|
}
|
501
727
|
get tables() {
|
502
|
-
if (!__privateGet$
|
503
|
-
__privateGet$
|
504
|
-
return __privateGet$
|
728
|
+
if (!__privateGet$7(this, _namespaces).tables)
|
729
|
+
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
730
|
+
return __privateGet$7(this, _namespaces).tables;
|
505
731
|
}
|
506
732
|
get records() {
|
507
|
-
if (!__privateGet$
|
508
|
-
__privateGet$
|
509
|
-
return __privateGet$
|
733
|
+
if (!__privateGet$7(this, _namespaces).records)
|
734
|
+
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
735
|
+
return __privateGet$7(this, _namespaces).records;
|
736
|
+
}
|
737
|
+
get migrationRequests() {
|
738
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
739
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
740
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
741
|
+
}
|
742
|
+
get branchSchema() {
|
743
|
+
if (!__privateGet$7(this, _namespaces).branchSchema)
|
744
|
+
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
745
|
+
return __privateGet$7(this, _namespaces).branchSchema;
|
510
746
|
}
|
511
747
|
}
|
512
748
|
_extraProps = new WeakMap();
|
@@ -598,6 +834,13 @@ class WorkspaceApi {
|
|
598
834
|
...this.extraProps
|
599
835
|
});
|
600
836
|
}
|
837
|
+
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
838
|
+
return operationsByTag.workspaces.updateWorkspaceMemberInvite({
|
839
|
+
pathParams: { workspaceId, inviteId },
|
840
|
+
body: { role },
|
841
|
+
...this.extraProps
|
842
|
+
});
|
843
|
+
}
|
601
844
|
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
602
845
|
return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
|
603
846
|
pathParams: { workspaceId, inviteId },
|
@@ -640,6 +883,46 @@ class DatabaseApi {
|
|
640
883
|
...this.extraProps
|
641
884
|
});
|
642
885
|
}
|
886
|
+
getDatabaseMetadata(workspace, dbName) {
|
887
|
+
return operationsByTag.database.getDatabaseMetadata({
|
888
|
+
pathParams: { workspace, dbName },
|
889
|
+
...this.extraProps
|
890
|
+
});
|
891
|
+
}
|
892
|
+
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
893
|
+
return operationsByTag.database.updateDatabaseMetadata({
|
894
|
+
pathParams: { workspace, dbName },
|
895
|
+
body: options,
|
896
|
+
...this.extraProps
|
897
|
+
});
|
898
|
+
}
|
899
|
+
getGitBranchesMapping(workspace, dbName) {
|
900
|
+
return operationsByTag.database.getGitBranchesMapping({
|
901
|
+
pathParams: { workspace, dbName },
|
902
|
+
...this.extraProps
|
903
|
+
});
|
904
|
+
}
|
905
|
+
addGitBranchesEntry(workspace, dbName, body) {
|
906
|
+
return operationsByTag.database.addGitBranchesEntry({
|
907
|
+
pathParams: { workspace, dbName },
|
908
|
+
body,
|
909
|
+
...this.extraProps
|
910
|
+
});
|
911
|
+
}
|
912
|
+
removeGitBranchesEntry(workspace, dbName, gitBranch) {
|
913
|
+
return operationsByTag.database.removeGitBranchesEntry({
|
914
|
+
pathParams: { workspace, dbName },
|
915
|
+
queryParams: { gitBranch },
|
916
|
+
...this.extraProps
|
917
|
+
});
|
918
|
+
}
|
919
|
+
resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
|
920
|
+
return operationsByTag.database.resolveBranch({
|
921
|
+
pathParams: { workspace, dbName },
|
922
|
+
queryParams: { gitBranch, fallbackBranch },
|
923
|
+
...this.extraProps
|
924
|
+
});
|
925
|
+
}
|
643
926
|
}
|
644
927
|
class BranchApi {
|
645
928
|
constructor(extraProps) {
|
@@ -657,10 +940,10 @@ class BranchApi {
|
|
657
940
|
...this.extraProps
|
658
941
|
});
|
659
942
|
}
|
660
|
-
createBranch(workspace, database, branch, from
|
943
|
+
createBranch(workspace, database, branch, from, options = {}) {
|
661
944
|
return operationsByTag.branch.createBranch({
|
662
945
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
663
|
-
queryParams: { from },
|
946
|
+
queryParams: isString(from) ? { from } : void 0,
|
664
947
|
body: options,
|
665
948
|
...this.extraProps
|
666
949
|
});
|
@@ -684,27 +967,6 @@ class BranchApi {
|
|
684
967
|
...this.extraProps
|
685
968
|
});
|
686
969
|
}
|
687
|
-
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
688
|
-
return operationsByTag.branch.getBranchMigrationHistory({
|
689
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
690
|
-
body: options,
|
691
|
-
...this.extraProps
|
692
|
-
});
|
693
|
-
}
|
694
|
-
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
695
|
-
return operationsByTag.branch.executeBranchMigrationPlan({
|
696
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
697
|
-
body: migrationPlan,
|
698
|
-
...this.extraProps
|
699
|
-
});
|
700
|
-
}
|
701
|
-
getBranchMigrationPlan(workspace, database, branch, schema) {
|
702
|
-
return operationsByTag.branch.getBranchMigrationPlan({
|
703
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
704
|
-
body: schema,
|
705
|
-
...this.extraProps
|
706
|
-
});
|
707
|
-
}
|
708
970
|
getBranchStats(workspace, database, branch) {
|
709
971
|
return operationsByTag.branch.getBranchStats({
|
710
972
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
@@ -785,9 +1047,10 @@ class RecordsApi {
|
|
785
1047
|
constructor(extraProps) {
|
786
1048
|
this.extraProps = extraProps;
|
787
1049
|
}
|
788
|
-
insertRecord(workspace, database, branch, tableName, record) {
|
1050
|
+
insertRecord(workspace, database, branch, tableName, record, options = {}) {
|
789
1051
|
return operationsByTag.records.insertRecord({
|
790
1052
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1053
|
+
queryParams: options,
|
791
1054
|
body: record,
|
792
1055
|
...this.extraProps
|
793
1056
|
});
|
@@ -816,21 +1079,24 @@ class RecordsApi {
|
|
816
1079
|
...this.extraProps
|
817
1080
|
});
|
818
1081
|
}
|
819
|
-
deleteRecord(workspace, database, branch, tableName, recordId) {
|
1082
|
+
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
820
1083
|
return operationsByTag.records.deleteRecord({
|
821
1084
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1085
|
+
queryParams: options,
|
822
1086
|
...this.extraProps
|
823
1087
|
});
|
824
1088
|
}
|
825
1089
|
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
826
1090
|
return operationsByTag.records.getRecord({
|
827
1091
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
1092
|
+
queryParams: options,
|
828
1093
|
...this.extraProps
|
829
1094
|
});
|
830
1095
|
}
|
831
|
-
bulkInsertTableRecords(workspace, database, branch, tableName, records) {
|
1096
|
+
bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
|
832
1097
|
return operationsByTag.records.bulkInsertTableRecords({
|
833
1098
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1099
|
+
queryParams: options,
|
834
1100
|
body: { records },
|
835
1101
|
...this.extraProps
|
836
1102
|
});
|
@@ -842,6 +1108,13 @@ class RecordsApi {
|
|
842
1108
|
...this.extraProps
|
843
1109
|
});
|
844
1110
|
}
|
1111
|
+
searchTable(workspace, database, branch, tableName, query) {
|
1112
|
+
return operationsByTag.records.searchTable({
|
1113
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1114
|
+
body: query,
|
1115
|
+
...this.extraProps
|
1116
|
+
});
|
1117
|
+
}
|
845
1118
|
searchBranch(workspace, database, branch, query) {
|
846
1119
|
return operationsByTag.records.searchBranch({
|
847
1120
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
@@ -849,6 +1122,138 @@ class RecordsApi {
|
|
849
1122
|
...this.extraProps
|
850
1123
|
});
|
851
1124
|
}
|
1125
|
+
summarizeTable(workspace, database, branch, tableName, query) {
|
1126
|
+
return operationsByTag.records.summarizeTable({
|
1127
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
1128
|
+
body: query,
|
1129
|
+
...this.extraProps
|
1130
|
+
});
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
class MigrationRequestsApi {
|
1134
|
+
constructor(extraProps) {
|
1135
|
+
this.extraProps = extraProps;
|
1136
|
+
}
|
1137
|
+
listMigrationRequests(workspace, database, options = {}) {
|
1138
|
+
return operationsByTag.migrationRequests.listMigrationRequests({
|
1139
|
+
pathParams: { workspace, dbName: database },
|
1140
|
+
body: options,
|
1141
|
+
...this.extraProps
|
1142
|
+
});
|
1143
|
+
}
|
1144
|
+
createMigrationRequest(workspace, database, options) {
|
1145
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
1146
|
+
pathParams: { workspace, dbName: database },
|
1147
|
+
body: options,
|
1148
|
+
...this.extraProps
|
1149
|
+
});
|
1150
|
+
}
|
1151
|
+
getMigrationRequest(workspace, database, migrationRequest) {
|
1152
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
1153
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1154
|
+
...this.extraProps
|
1155
|
+
});
|
1156
|
+
}
|
1157
|
+
updateMigrationRequest(workspace, database, migrationRequest, options) {
|
1158
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1159
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1160
|
+
body: options,
|
1161
|
+
...this.extraProps
|
1162
|
+
});
|
1163
|
+
}
|
1164
|
+
listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
|
1165
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1166
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1167
|
+
body: options,
|
1168
|
+
...this.extraProps
|
1169
|
+
});
|
1170
|
+
}
|
1171
|
+
compareMigrationRequest(workspace, database, migrationRequest) {
|
1172
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1173
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1174
|
+
...this.extraProps
|
1175
|
+
});
|
1176
|
+
}
|
1177
|
+
getMigrationRequestIsMerged(workspace, database, migrationRequest) {
|
1178
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1179
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1180
|
+
...this.extraProps
|
1181
|
+
});
|
1182
|
+
}
|
1183
|
+
mergeMigrationRequest(workspace, database, migrationRequest) {
|
1184
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1185
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1186
|
+
...this.extraProps
|
1187
|
+
});
|
1188
|
+
}
|
1189
|
+
}
|
1190
|
+
class BranchSchemaApi {
|
1191
|
+
constructor(extraProps) {
|
1192
|
+
this.extraProps = extraProps;
|
1193
|
+
}
|
1194
|
+
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
1195
|
+
return operationsByTag.branchSchema.getBranchMigrationHistory({
|
1196
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1197
|
+
body: options,
|
1198
|
+
...this.extraProps
|
1199
|
+
});
|
1200
|
+
}
|
1201
|
+
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
1202
|
+
return operationsByTag.branchSchema.executeBranchMigrationPlan({
|
1203
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1204
|
+
body: migrationPlan,
|
1205
|
+
...this.extraProps
|
1206
|
+
});
|
1207
|
+
}
|
1208
|
+
getBranchMigrationPlan(workspace, database, branch, schema) {
|
1209
|
+
return operationsByTag.branchSchema.getBranchMigrationPlan({
|
1210
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1211
|
+
body: schema,
|
1212
|
+
...this.extraProps
|
1213
|
+
});
|
1214
|
+
}
|
1215
|
+
compareBranchWithUserSchema(workspace, database, branch, schema) {
|
1216
|
+
return operationsByTag.branchSchema.compareBranchWithUserSchema({
|
1217
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1218
|
+
body: { schema },
|
1219
|
+
...this.extraProps
|
1220
|
+
});
|
1221
|
+
}
|
1222
|
+
compareBranchSchemas(workspace, database, branch, branchName, schema) {
|
1223
|
+
return operationsByTag.branchSchema.compareBranchSchemas({
|
1224
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
|
1225
|
+
body: { schema },
|
1226
|
+
...this.extraProps
|
1227
|
+
});
|
1228
|
+
}
|
1229
|
+
updateBranchSchema(workspace, database, branch, migration) {
|
1230
|
+
return operationsByTag.branchSchema.updateBranchSchema({
|
1231
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1232
|
+
body: migration,
|
1233
|
+
...this.extraProps
|
1234
|
+
});
|
1235
|
+
}
|
1236
|
+
previewBranchSchemaEdit(workspace, database, branch, migration) {
|
1237
|
+
return operationsByTag.branchSchema.previewBranchSchemaEdit({
|
1238
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1239
|
+
body: migration,
|
1240
|
+
...this.extraProps
|
1241
|
+
});
|
1242
|
+
}
|
1243
|
+
applyBranchSchemaEdit(workspace, database, branch, edits) {
|
1244
|
+
return operationsByTag.branchSchema.applyBranchSchemaEdit({
|
1245
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1246
|
+
body: { edits },
|
1247
|
+
...this.extraProps
|
1248
|
+
});
|
1249
|
+
}
|
1250
|
+
getBranchSchemaHistory(workspace, database, branch, options = {}) {
|
1251
|
+
return operationsByTag.branchSchema.getBranchSchemaHistory({
|
1252
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1253
|
+
body: options,
|
1254
|
+
...this.extraProps
|
1255
|
+
});
|
1256
|
+
}
|
852
1257
|
}
|
853
1258
|
|
854
1259
|
class XataApiPlugin {
|
@@ -865,7 +1270,7 @@ var __accessCheck$6 = (obj, member, msg) => {
|
|
865
1270
|
if (!member.has(obj))
|
866
1271
|
throw TypeError("Cannot " + msg);
|
867
1272
|
};
|
868
|
-
var __privateGet$
|
1273
|
+
var __privateGet$6 = (obj, member, getter) => {
|
869
1274
|
__accessCheck$6(obj, member, "read from private field");
|
870
1275
|
return getter ? getter.call(obj) : member.get(obj);
|
871
1276
|
};
|
@@ -874,30 +1279,30 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
874
1279
|
throw TypeError("Cannot add the same private member more than once");
|
875
1280
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
876
1281
|
};
|
877
|
-
var __privateSet$
|
1282
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
878
1283
|
__accessCheck$6(obj, member, "write to private field");
|
879
1284
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
880
1285
|
return value;
|
881
1286
|
};
|
882
|
-
var _query;
|
1287
|
+
var _query, _page;
|
883
1288
|
class Page {
|
884
1289
|
constructor(query, meta, records = []) {
|
885
1290
|
__privateAdd$6(this, _query, void 0);
|
886
|
-
__privateSet$
|
1291
|
+
__privateSet$6(this, _query, query);
|
887
1292
|
this.meta = meta;
|
888
|
-
this.records = records;
|
1293
|
+
this.records = new RecordArray(this, records);
|
889
1294
|
}
|
890
1295
|
async nextPage(size, offset) {
|
891
|
-
return __privateGet$
|
1296
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
892
1297
|
}
|
893
1298
|
async previousPage(size, offset) {
|
894
|
-
return __privateGet$
|
1299
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
895
1300
|
}
|
896
1301
|
async firstPage(size, offset) {
|
897
|
-
return __privateGet$
|
1302
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
|
898
1303
|
}
|
899
1304
|
async lastPage(size, offset) {
|
900
|
-
return __privateGet$
|
1305
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
|
901
1306
|
}
|
902
1307
|
hasNextPage() {
|
903
1308
|
return this.meta.page.more;
|
@@ -905,15 +1310,62 @@ class Page {
|
|
905
1310
|
}
|
906
1311
|
_query = new WeakMap();
|
907
1312
|
const PAGINATION_MAX_SIZE = 200;
|
908
|
-
const PAGINATION_DEFAULT_SIZE =
|
1313
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
909
1314
|
const PAGINATION_MAX_OFFSET = 800;
|
910
1315
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
1316
|
+
function isCursorPaginationOptions(options) {
|
1317
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
1318
|
+
}
|
1319
|
+
const _RecordArray = class extends Array {
|
1320
|
+
constructor(...args) {
|
1321
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
1322
|
+
__privateAdd$6(this, _page, void 0);
|
1323
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
1324
|
+
}
|
1325
|
+
static parseConstructorParams(...args) {
|
1326
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
1327
|
+
return new Array(args[0]);
|
1328
|
+
}
|
1329
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
1330
|
+
const result = args[1] ?? args[0].records ?? [];
|
1331
|
+
return new Array(...result);
|
1332
|
+
}
|
1333
|
+
return new Array(...args);
|
1334
|
+
}
|
1335
|
+
toArray() {
|
1336
|
+
return new Array(...this);
|
1337
|
+
}
|
1338
|
+
map(callbackfn, thisArg) {
|
1339
|
+
return this.toArray().map(callbackfn, thisArg);
|
1340
|
+
}
|
1341
|
+
async nextPage(size, offset) {
|
1342
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1343
|
+
return new _RecordArray(newPage);
|
1344
|
+
}
|
1345
|
+
async previousPage(size, offset) {
|
1346
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1347
|
+
return new _RecordArray(newPage);
|
1348
|
+
}
|
1349
|
+
async firstPage(size, offset) {
|
1350
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
1351
|
+
return new _RecordArray(newPage);
|
1352
|
+
}
|
1353
|
+
async lastPage(size, offset) {
|
1354
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
1355
|
+
return new _RecordArray(newPage);
|
1356
|
+
}
|
1357
|
+
hasNextPage() {
|
1358
|
+
return __privateGet$6(this, _page).meta.page.more;
|
1359
|
+
}
|
1360
|
+
};
|
1361
|
+
let RecordArray = _RecordArray;
|
1362
|
+
_page = new WeakMap();
|
911
1363
|
|
912
1364
|
var __accessCheck$5 = (obj, member, msg) => {
|
913
1365
|
if (!member.has(obj))
|
914
1366
|
throw TypeError("Cannot " + msg);
|
915
1367
|
};
|
916
|
-
var __privateGet$
|
1368
|
+
var __privateGet$5 = (obj, member, getter) => {
|
917
1369
|
__accessCheck$5(obj, member, "read from private field");
|
918
1370
|
return getter ? getter.call(obj) : member.get(obj);
|
919
1371
|
};
|
@@ -922,34 +1374,35 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
922
1374
|
throw TypeError("Cannot add the same private member more than once");
|
923
1375
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
924
1376
|
};
|
925
|
-
var __privateSet$
|
1377
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
926
1378
|
__accessCheck$5(obj, member, "write to private field");
|
927
1379
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
928
1380
|
return value;
|
929
1381
|
};
|
930
1382
|
var _table$1, _repository, _data;
|
931
1383
|
const _Query = class {
|
932
|
-
constructor(repository, table, data,
|
1384
|
+
constructor(repository, table, data, rawParent) {
|
933
1385
|
__privateAdd$5(this, _table$1, void 0);
|
934
1386
|
__privateAdd$5(this, _repository, void 0);
|
935
1387
|
__privateAdd$5(this, _data, { filter: {} });
|
936
1388
|
this.meta = { page: { cursor: "start", more: true } };
|
937
|
-
this.records = [];
|
938
|
-
__privateSet$
|
1389
|
+
this.records = new RecordArray(this, []);
|
1390
|
+
__privateSet$5(this, _table$1, table);
|
939
1391
|
if (repository) {
|
940
|
-
__privateSet$
|
1392
|
+
__privateSet$5(this, _repository, repository);
|
941
1393
|
} else {
|
942
|
-
__privateSet$
|
1394
|
+
__privateSet$5(this, _repository, this);
|
943
1395
|
}
|
944
|
-
|
945
|
-
__privateGet$
|
946
|
-
__privateGet$
|
947
|
-
__privateGet$
|
948
|
-
__privateGet$
|
949
|
-
__privateGet$
|
950
|
-
__privateGet$
|
951
|
-
__privateGet$
|
952
|
-
__privateGet$
|
1396
|
+
const parent = cleanParent(data, rawParent);
|
1397
|
+
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
1398
|
+
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
1399
|
+
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
1400
|
+
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1401
|
+
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1402
|
+
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1403
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
|
1404
|
+
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1405
|
+
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
953
1406
|
this.any = this.any.bind(this);
|
954
1407
|
this.all = this.all.bind(this);
|
955
1408
|
this.not = this.not.bind(this);
|
@@ -960,83 +1413,116 @@ const _Query = class {
|
|
960
1413
|
Object.defineProperty(this, "repository", { enumerable: false });
|
961
1414
|
}
|
962
1415
|
getQueryOptions() {
|
963
|
-
return __privateGet$
|
1416
|
+
return __privateGet$5(this, _data);
|
964
1417
|
}
|
965
1418
|
key() {
|
966
|
-
const { columns = [], filter = {}, sort = [],
|
967
|
-
const key = JSON.stringify({ columns, filter, sort,
|
1419
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
|
1420
|
+
const key = JSON.stringify({ columns, filter, sort, pagination });
|
968
1421
|
return toBase64(key);
|
969
1422
|
}
|
970
1423
|
any(...queries) {
|
971
1424
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
972
|
-
return new _Query(__privateGet$
|
1425
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
973
1426
|
}
|
974
1427
|
all(...queries) {
|
975
1428
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
976
|
-
return new _Query(__privateGet$
|
1429
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
977
1430
|
}
|
978
1431
|
not(...queries) {
|
979
1432
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
980
|
-
return new _Query(__privateGet$
|
1433
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
981
1434
|
}
|
982
1435
|
none(...queries) {
|
983
1436
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
984
|
-
return new _Query(__privateGet$
|
1437
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
985
1438
|
}
|
986
1439
|
filter(a, b) {
|
987
1440
|
if (arguments.length === 1) {
|
988
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
989
|
-
const $all = compact([__privateGet$
|
990
|
-
return new _Query(__privateGet$
|
1441
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
|
1442
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1443
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
991
1444
|
} else {
|
992
|
-
const
|
993
|
-
|
1445
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
|
1446
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1447
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1448
|
+
}
|
1449
|
+
}
|
1450
|
+
defaultFilter(column, value) {
|
1451
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
1452
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
1453
|
+
return { $includes: value };
|
994
1454
|
}
|
1455
|
+
return value;
|
995
1456
|
}
|
996
|
-
sort(column, direction) {
|
997
|
-
const originalSort = [__privateGet$
|
1457
|
+
sort(column, direction = "asc") {
|
1458
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
998
1459
|
const sort = [...originalSort, { column, direction }];
|
999
|
-
return new _Query(__privateGet$
|
1460
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1000
1461
|
}
|
1001
1462
|
select(columns) {
|
1002
|
-
return new _Query(
|
1463
|
+
return new _Query(
|
1464
|
+
__privateGet$5(this, _repository),
|
1465
|
+
__privateGet$5(this, _table$1),
|
1466
|
+
{ columns },
|
1467
|
+
__privateGet$5(this, _data)
|
1468
|
+
);
|
1003
1469
|
}
|
1004
1470
|
getPaginated(options = {}) {
|
1005
|
-
const query = new _Query(__privateGet$
|
1006
|
-
return __privateGet$
|
1471
|
+
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
1472
|
+
return __privateGet$5(this, _repository).query(query);
|
1007
1473
|
}
|
1008
1474
|
async *[Symbol.asyncIterator]() {
|
1009
|
-
for await (const [record] of this.getIterator(1)) {
|
1475
|
+
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
1010
1476
|
yield record;
|
1011
1477
|
}
|
1012
1478
|
}
|
1013
|
-
async *getIterator(
|
1014
|
-
|
1015
|
-
let
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1479
|
+
async *getIterator(options = {}) {
|
1480
|
+
const { batchSize = 1 } = options;
|
1481
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
1482
|
+
let more = page.hasNextPage();
|
1483
|
+
yield page.records;
|
1484
|
+
while (more) {
|
1485
|
+
page = await page.nextPage();
|
1486
|
+
more = page.hasNextPage();
|
1487
|
+
yield page.records;
|
1021
1488
|
}
|
1022
1489
|
}
|
1023
1490
|
async getMany(options = {}) {
|
1024
|
-
const {
|
1025
|
-
|
1491
|
+
const { pagination = {}, ...rest } = options;
|
1492
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
1493
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
1494
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
1495
|
+
const results = [...page.records];
|
1496
|
+
while (page.hasNextPage() && results.length < size) {
|
1497
|
+
page = await page.nextPage();
|
1498
|
+
results.push(...page.records);
|
1499
|
+
}
|
1500
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1501
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1502
|
+
}
|
1503
|
+
const array = new RecordArray(page, results.slice(0, size));
|
1504
|
+
return array;
|
1026
1505
|
}
|
1027
|
-
async getAll(
|
1506
|
+
async getAll(options = {}) {
|
1507
|
+
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
1028
1508
|
const results = [];
|
1029
|
-
for await (const page of this.getIterator(
|
1509
|
+
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
1030
1510
|
results.push(...page);
|
1031
1511
|
}
|
1032
1512
|
return results;
|
1033
1513
|
}
|
1034
1514
|
async getFirst(options = {}) {
|
1035
|
-
const records = await this.getMany({ ...options,
|
1036
|
-
return records[0]
|
1515
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1516
|
+
return records[0] ?? null;
|
1517
|
+
}
|
1518
|
+
async getFirstOrThrow(options = {}) {
|
1519
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1520
|
+
if (records[0] === void 0)
|
1521
|
+
throw new Error("No results found.");
|
1522
|
+
return records[0];
|
1037
1523
|
}
|
1038
1524
|
cache(ttl) {
|
1039
|
-
return new _Query(__privateGet$
|
1525
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1040
1526
|
}
|
1041
1527
|
nextPage(size, offset) {
|
1042
1528
|
return this.firstPage(size, offset);
|
@@ -1045,10 +1531,10 @@ const _Query = class {
|
|
1045
1531
|
return this.firstPage(size, offset);
|
1046
1532
|
}
|
1047
1533
|
firstPage(size, offset) {
|
1048
|
-
return this.getPaginated({
|
1534
|
+
return this.getPaginated({ pagination: { size, offset } });
|
1049
1535
|
}
|
1050
1536
|
lastPage(size, offset) {
|
1051
|
-
return this.getPaginated({
|
1537
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1052
1538
|
}
|
1053
1539
|
hasNextPage() {
|
1054
1540
|
return this.meta.page.more;
|
@@ -1058,12 +1544,20 @@ let Query = _Query;
|
|
1058
1544
|
_table$1 = new WeakMap();
|
1059
1545
|
_repository = new WeakMap();
|
1060
1546
|
_data = new WeakMap();
|
1547
|
+
function cleanParent(data, parent) {
|
1548
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
1549
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
1550
|
+
}
|
1551
|
+
return parent;
|
1552
|
+
}
|
1061
1553
|
|
1062
1554
|
function isIdentifiable(x) {
|
1063
1555
|
return isObject(x) && isString(x?.id);
|
1064
1556
|
}
|
1065
1557
|
function isXataRecord(x) {
|
1066
|
-
|
1558
|
+
const record = x;
|
1559
|
+
const metadata = record?.getMetadata();
|
1560
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1067
1561
|
}
|
1068
1562
|
|
1069
1563
|
function isSortFilterString(value) {
|
@@ -1093,7 +1587,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
1093
1587
|
if (!member.has(obj))
|
1094
1588
|
throw TypeError("Cannot " + msg);
|
1095
1589
|
};
|
1096
|
-
var __privateGet$
|
1590
|
+
var __privateGet$4 = (obj, member, getter) => {
|
1097
1591
|
__accessCheck$4(obj, member, "read from private field");
|
1098
1592
|
return getter ? getter.call(obj) : member.get(obj);
|
1099
1593
|
};
|
@@ -1102,7 +1596,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
1102
1596
|
throw TypeError("Cannot add the same private member more than once");
|
1103
1597
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1104
1598
|
};
|
1105
|
-
var __privateSet$
|
1599
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
1106
1600
|
__accessCheck$4(obj, member, "write to private field");
|
1107
1601
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1108
1602
|
return value;
|
@@ -1111,304 +1605,411 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1111
1605
|
__accessCheck$4(obj, member, "access private method");
|
1112
1606
|
return method;
|
1113
1607
|
};
|
1114
|
-
var _table,
|
1608
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
1115
1609
|
class Repository extends Query {
|
1116
1610
|
}
|
1117
1611
|
class RestRepository extends Query {
|
1118
1612
|
constructor(options) {
|
1119
|
-
super(
|
1613
|
+
super(
|
1614
|
+
null,
|
1615
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
1616
|
+
{}
|
1617
|
+
);
|
1120
1618
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1121
1619
|
__privateAdd$4(this, _insertRecordWithId);
|
1122
1620
|
__privateAdd$4(this, _bulkInsertTableRecords);
|
1123
1621
|
__privateAdd$4(this, _updateRecordWithID);
|
1124
1622
|
__privateAdd$4(this, _upsertRecordWithID);
|
1125
1623
|
__privateAdd$4(this, _deleteRecord);
|
1126
|
-
__privateAdd$4(this, _invalidateCache);
|
1127
|
-
__privateAdd$4(this, _setCacheRecord);
|
1128
|
-
__privateAdd$4(this, _getCacheRecord);
|
1129
1624
|
__privateAdd$4(this, _setCacheQuery);
|
1130
1625
|
__privateAdd$4(this, _getCacheQuery);
|
1626
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
1131
1627
|
__privateAdd$4(this, _table, void 0);
|
1132
|
-
__privateAdd$4(this, _links, void 0);
|
1133
1628
|
__privateAdd$4(this, _getFetchProps, void 0);
|
1629
|
+
__privateAdd$4(this, _db, void 0);
|
1134
1630
|
__privateAdd$4(this, _cache, void 0);
|
1135
|
-
|
1136
|
-
|
1137
|
-
__privateSet$
|
1138
|
-
this
|
1139
|
-
__privateSet$
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
throw new Error("The id can't be empty");
|
1150
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
|
1151
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1152
|
-
return record;
|
1153
|
-
}
|
1154
|
-
if (isObject(a) && isString(a.id)) {
|
1155
|
-
if (a.id === "")
|
1156
|
-
throw new Error("The id can't be empty");
|
1157
|
-
const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
|
1158
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1159
|
-
return record;
|
1160
|
-
}
|
1161
|
-
if (isObject(a)) {
|
1162
|
-
const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
|
1163
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1164
|
-
return record;
|
1165
|
-
}
|
1166
|
-
throw new Error("Invalid arguments for create method");
|
1167
|
-
}
|
1168
|
-
async read(recordId) {
|
1169
|
-
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
|
1170
|
-
if (cacheRecord)
|
1171
|
-
return cacheRecord;
|
1172
|
-
const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
|
1173
|
-
try {
|
1174
|
-
const response = await getRecord({
|
1175
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
|
1176
|
-
...fetchProps
|
1631
|
+
__privateAdd$4(this, _schemaTables$2, void 0);
|
1632
|
+
__privateAdd$4(this, _trace, void 0);
|
1633
|
+
__privateSet$4(this, _table, options.table);
|
1634
|
+
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1635
|
+
__privateSet$4(this, _db, options.db);
|
1636
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1637
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
1638
|
+
const trace = options.pluginOptions.trace ?? defaultTrace;
|
1639
|
+
__privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
|
1640
|
+
return trace(name, fn, {
|
1641
|
+
...options2,
|
1642
|
+
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
1643
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
1644
|
+
[TraceAttributes.VERSION]: VERSION
|
1177
1645
|
});
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1646
|
+
});
|
1647
|
+
}
|
1648
|
+
async create(a, b, c) {
|
1649
|
+
return __privateGet$4(this, _trace).call(this, "create", async () => {
|
1650
|
+
if (Array.isArray(a)) {
|
1651
|
+
if (a.length === 0)
|
1652
|
+
return [];
|
1653
|
+
const columns = isStringArray(b) ? b : void 0;
|
1654
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
1182
1655
|
}
|
1183
|
-
|
1184
|
-
|
1656
|
+
if (isString(a) && isObject(b)) {
|
1657
|
+
if (a === "")
|
1658
|
+
throw new Error("The id can't be empty");
|
1659
|
+
const columns = isStringArray(c) ? c : void 0;
|
1660
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
1661
|
+
}
|
1662
|
+
if (isObject(a) && isString(a.id)) {
|
1663
|
+
if (a.id === "")
|
1664
|
+
throw new Error("The id can't be empty");
|
1665
|
+
const columns = isStringArray(b) ? b : void 0;
|
1666
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1667
|
+
}
|
1668
|
+
if (isObject(a)) {
|
1669
|
+
const columns = isStringArray(b) ? b : void 0;
|
1670
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
1671
|
+
}
|
1672
|
+
throw new Error("Invalid arguments for create method");
|
1673
|
+
});
|
1185
1674
|
}
|
1186
|
-
async
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1675
|
+
async read(a, b) {
|
1676
|
+
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
1677
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1678
|
+
if (Array.isArray(a)) {
|
1679
|
+
if (a.length === 0)
|
1680
|
+
return [];
|
1681
|
+
const ids = a.map((item) => extractId(item));
|
1682
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
|
1683
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
1684
|
+
acc[object.id] = object;
|
1685
|
+
return acc;
|
1686
|
+
}, {});
|
1687
|
+
return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
|
1190
1688
|
}
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1689
|
+
const id = extractId(a);
|
1690
|
+
if (id) {
|
1691
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1692
|
+
try {
|
1693
|
+
const response = await getRecord({
|
1694
|
+
pathParams: {
|
1695
|
+
workspace: "{workspaceId}",
|
1696
|
+
dbBranchName: "{dbBranch}",
|
1697
|
+
tableName: __privateGet$4(this, _table),
|
1698
|
+
recordId: id
|
1699
|
+
},
|
1700
|
+
queryParams: { columns },
|
1701
|
+
...fetchProps
|
1702
|
+
});
|
1703
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1704
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1705
|
+
} catch (e) {
|
1706
|
+
if (isObject(e) && e.status === 404) {
|
1707
|
+
return null;
|
1708
|
+
}
|
1709
|
+
throw e;
|
1710
|
+
}
|
1711
|
+
}
|
1712
|
+
return null;
|
1713
|
+
});
|
1206
1714
|
}
|
1207
|
-
async
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1715
|
+
async readOrThrow(a, b) {
|
1716
|
+
return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
|
1717
|
+
const result = await this.read(a, b);
|
1718
|
+
if (Array.isArray(result)) {
|
1719
|
+
const missingIds = compact(
|
1720
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
1721
|
+
);
|
1722
|
+
if (missingIds.length > 0) {
|
1723
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
1724
|
+
}
|
1725
|
+
return result;
|
1211
1726
|
}
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
return record;
|
1219
|
-
}
|
1220
|
-
if (isObject(a) && isString(a.id)) {
|
1221
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1222
|
-
const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
|
1223
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1224
|
-
return record;
|
1225
|
-
}
|
1226
|
-
throw new Error("Invalid arguments for createOrUpdate method");
|
1727
|
+
if (result === null) {
|
1728
|
+
const id = extractId(a) ?? "unknown";
|
1729
|
+
throw new Error(`Record with id ${id} not found`);
|
1730
|
+
}
|
1731
|
+
return result;
|
1732
|
+
});
|
1227
1733
|
}
|
1228
|
-
async
|
1229
|
-
|
1230
|
-
if (a
|
1231
|
-
|
1734
|
+
async update(a, b, c) {
|
1735
|
+
return __privateGet$4(this, _trace).call(this, "update", async () => {
|
1736
|
+
if (Array.isArray(a)) {
|
1737
|
+
if (a.length === 0)
|
1738
|
+
return [];
|
1739
|
+
if (a.length > 100) {
|
1740
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1741
|
+
}
|
1742
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1743
|
+
return Promise.all(a.map((object) => this.update(object, columns)));
|
1232
1744
|
}
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1745
|
+
if (isString(a) && isObject(b)) {
|
1746
|
+
const columns = isStringArray(c) ? c : void 0;
|
1747
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
1748
|
+
}
|
1749
|
+
if (isObject(a) && isString(a.id)) {
|
1750
|
+
const columns = isStringArray(b) ? b : void 0;
|
1751
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1752
|
+
}
|
1753
|
+
throw new Error("Invalid arguments for update method");
|
1754
|
+
});
|
1755
|
+
}
|
1756
|
+
async updateOrThrow(a, b, c) {
|
1757
|
+
return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
|
1758
|
+
const result = await this.update(a, b, c);
|
1759
|
+
if (Array.isArray(result)) {
|
1760
|
+
const missingIds = compact(
|
1761
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
1762
|
+
);
|
1763
|
+
if (missingIds.length > 0) {
|
1764
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
1765
|
+
}
|
1766
|
+
return result;
|
1767
|
+
}
|
1768
|
+
if (result === null) {
|
1769
|
+
const id = extractId(a) ?? "unknown";
|
1770
|
+
throw new Error(`Record with id ${id} not found`);
|
1771
|
+
}
|
1772
|
+
return result;
|
1773
|
+
});
|
1774
|
+
}
|
1775
|
+
async createOrUpdate(a, b, c) {
|
1776
|
+
return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
|
1777
|
+
if (Array.isArray(a)) {
|
1778
|
+
if (a.length === 0)
|
1779
|
+
return [];
|
1780
|
+
if (a.length > 100) {
|
1781
|
+
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1782
|
+
}
|
1783
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1784
|
+
return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
|
1785
|
+
}
|
1786
|
+
if (isString(a) && isObject(b)) {
|
1787
|
+
const columns = isStringArray(c) ? c : void 0;
|
1788
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
1789
|
+
}
|
1790
|
+
if (isObject(a) && isString(a.id)) {
|
1791
|
+
const columns = isStringArray(c) ? c : void 0;
|
1792
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1793
|
+
}
|
1794
|
+
throw new Error("Invalid arguments for createOrUpdate method");
|
1795
|
+
});
|
1796
|
+
}
|
1797
|
+
async delete(a, b) {
|
1798
|
+
return __privateGet$4(this, _trace).call(this, "delete", async () => {
|
1799
|
+
if (Array.isArray(a)) {
|
1800
|
+
if (a.length === 0)
|
1801
|
+
return [];
|
1802
|
+
if (a.length > 100) {
|
1803
|
+
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1804
|
+
}
|
1805
|
+
return Promise.all(a.map((id) => this.delete(id, b)));
|
1806
|
+
}
|
1807
|
+
if (isString(a)) {
|
1808
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
|
1809
|
+
}
|
1810
|
+
if (isObject(a) && isString(a.id)) {
|
1811
|
+
return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
|
1812
|
+
}
|
1813
|
+
throw new Error("Invalid arguments for delete method");
|
1814
|
+
});
|
1815
|
+
}
|
1816
|
+
async deleteOrThrow(a, b) {
|
1817
|
+
return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
|
1818
|
+
const result = await this.delete(a, b);
|
1819
|
+
if (Array.isArray(result)) {
|
1820
|
+
const missingIds = compact(
|
1821
|
+
a.filter((_item, index) => result[index] === null).map((item) => extractId(item))
|
1822
|
+
);
|
1823
|
+
if (missingIds.length > 0) {
|
1824
|
+
throw new Error(`Could not find records with ids: ${missingIds.join(", ")}`);
|
1825
|
+
}
|
1826
|
+
return result;
|
1827
|
+
} else if (result === null) {
|
1828
|
+
const id = extractId(a) ?? "unknown";
|
1829
|
+
throw new Error(`Record with id ${id} not found`);
|
1830
|
+
}
|
1831
|
+
return result;
|
1832
|
+
});
|
1247
1833
|
}
|
1248
1834
|
async search(query, options = {}) {
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1835
|
+
return __privateGet$4(this, _trace).call(this, "search", async () => {
|
1836
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1837
|
+
const { records } = await searchTable({
|
1838
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1839
|
+
body: {
|
1840
|
+
query,
|
1841
|
+
fuzziness: options.fuzziness,
|
1842
|
+
prefix: options.prefix,
|
1843
|
+
highlight: options.highlight,
|
1844
|
+
filter: options.filter,
|
1845
|
+
boosters: options.boosters
|
1846
|
+
},
|
1847
|
+
...fetchProps
|
1848
|
+
});
|
1849
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1850
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
1254
1851
|
});
|
1255
|
-
return records.map((item) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), item));
|
1256
1852
|
}
|
1257
1853
|
async query(query) {
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1854
|
+
return __privateGet$4(this, _trace).call(this, "query", async () => {
|
1855
|
+
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
1856
|
+
if (cacheQuery)
|
1857
|
+
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1858
|
+
const data = query.getQueryOptions();
|
1859
|
+
const body = {
|
1860
|
+
filter: cleanFilter(data.filter),
|
1861
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1862
|
+
page: data.pagination,
|
1863
|
+
columns: data.columns
|
1864
|
+
};
|
1865
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1866
|
+
const { meta, records: objects } = await queryTable({
|
1867
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1868
|
+
body,
|
1869
|
+
...fetchProps
|
1870
|
+
});
|
1871
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1872
|
+
const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
|
1873
|
+
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1874
|
+
return new Page(query, meta, records);
|
1273
1875
|
});
|
1274
|
-
const records = objects.map((record) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), record));
|
1275
|
-
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1276
|
-
return new Page(query, meta, records);
|
1277
1876
|
}
|
1278
1877
|
}
|
1279
1878
|
_table = new WeakMap();
|
1280
|
-
_links = new WeakMap();
|
1281
1879
|
_getFetchProps = new WeakMap();
|
1880
|
+
_db = new WeakMap();
|
1282
1881
|
_cache = new WeakMap();
|
1882
|
+
_schemaTables$2 = new WeakMap();
|
1883
|
+
_trace = new WeakMap();
|
1283
1884
|
_insertRecordWithoutId = new WeakSet();
|
1284
|
-
insertRecordWithoutId_fn = async function(object) {
|
1285
|
-
const fetchProps = await __privateGet$
|
1885
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
1886
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1286
1887
|
const record = transformObjectLinks(object);
|
1287
1888
|
const response = await insertRecord({
|
1288
1889
|
pathParams: {
|
1289
1890
|
workspace: "{workspaceId}",
|
1290
1891
|
dbBranchName: "{dbBranch}",
|
1291
|
-
tableName: __privateGet$
|
1892
|
+
tableName: __privateGet$4(this, _table)
|
1292
1893
|
},
|
1894
|
+
queryParams: { columns },
|
1293
1895
|
body: record,
|
1294
1896
|
...fetchProps
|
1295
1897
|
});
|
1296
|
-
const
|
1297
|
-
|
1298
|
-
throw new Error("The server failed to save the record");
|
1299
|
-
}
|
1300
|
-
return finalObject;
|
1898
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1899
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1301
1900
|
};
|
1302
1901
|
_insertRecordWithId = new WeakSet();
|
1303
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
1304
|
-
const fetchProps = await __privateGet$
|
1902
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
1903
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1305
1904
|
const record = transformObjectLinks(object);
|
1306
1905
|
const response = await insertRecordWithID({
|
1307
1906
|
pathParams: {
|
1308
1907
|
workspace: "{workspaceId}",
|
1309
1908
|
dbBranchName: "{dbBranch}",
|
1310
|
-
tableName: __privateGet$
|
1909
|
+
tableName: __privateGet$4(this, _table),
|
1311
1910
|
recordId
|
1312
1911
|
},
|
1313
1912
|
body: record,
|
1314
|
-
queryParams: { createOnly: true },
|
1913
|
+
queryParams: { createOnly: true, columns },
|
1315
1914
|
...fetchProps
|
1316
1915
|
});
|
1317
|
-
const
|
1318
|
-
|
1319
|
-
throw new Error("The server failed to save the record");
|
1320
|
-
}
|
1321
|
-
return finalObject;
|
1916
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1917
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1322
1918
|
};
|
1323
1919
|
_bulkInsertTableRecords = new WeakSet();
|
1324
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
1325
|
-
const fetchProps = await __privateGet$
|
1920
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1921
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1326
1922
|
const records = objects.map((object) => transformObjectLinks(object));
|
1327
1923
|
const response = await bulkInsertTableRecords({
|
1328
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1924
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1925
|
+
queryParams: { columns },
|
1329
1926
|
body: { records },
|
1330
1927
|
...fetchProps
|
1331
1928
|
});
|
1332
|
-
|
1333
|
-
|
1334
|
-
throw new Error("The server failed to save some records");
|
1929
|
+
if (!isResponseWithRecords(response)) {
|
1930
|
+
throw new Error("Request included columns but server didn't include them");
|
1335
1931
|
}
|
1336
|
-
|
1932
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1933
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
1337
1934
|
};
|
1338
1935
|
_updateRecordWithID = new WeakSet();
|
1339
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
1340
|
-
const fetchProps = await __privateGet$
|
1936
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1937
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1341
1938
|
const record = transformObjectLinks(object);
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1939
|
+
try {
|
1940
|
+
const response = await updateRecordWithID({
|
1941
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1942
|
+
queryParams: { columns },
|
1943
|
+
body: record,
|
1944
|
+
...fetchProps
|
1945
|
+
});
|
1946
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1947
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1948
|
+
} catch (e) {
|
1949
|
+
if (isObject(e) && e.status === 404) {
|
1950
|
+
return null;
|
1951
|
+
}
|
1952
|
+
throw e;
|
1953
|
+
}
|
1351
1954
|
};
|
1352
1955
|
_upsertRecordWithID = new WeakSet();
|
1353
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
1354
|
-
const fetchProps = await __privateGet$
|
1956
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1957
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1355
1958
|
const response = await upsertRecordWithID({
|
1356
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1959
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1960
|
+
queryParams: { columns },
|
1357
1961
|
body: object,
|
1358
1962
|
...fetchProps
|
1359
1963
|
});
|
1360
|
-
const
|
1361
|
-
|
1362
|
-
throw new Error("The server failed to save the record");
|
1363
|
-
return item;
|
1964
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1965
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1364
1966
|
};
|
1365
1967
|
_deleteRecord = new WeakSet();
|
1366
|
-
deleteRecord_fn = async function(recordId) {
|
1367
|
-
const fetchProps = await __privateGet$
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
await __privateGet$3(this, _cache).delete(key);
|
1968
|
+
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
1969
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1970
|
+
try {
|
1971
|
+
const response = await deleteRecord({
|
1972
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1973
|
+
queryParams: { columns },
|
1974
|
+
...fetchProps
|
1975
|
+
});
|
1976
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1977
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1978
|
+
} catch (e) {
|
1979
|
+
if (isObject(e) && e.status === 404) {
|
1980
|
+
return null;
|
1981
|
+
}
|
1982
|
+
throw e;
|
1382
1983
|
}
|
1383
1984
|
};
|
1384
|
-
_setCacheRecord = new WeakSet();
|
1385
|
-
setCacheRecord_fn = async function(record) {
|
1386
|
-
if (!__privateGet$3(this, _cache).cacheRecords)
|
1387
|
-
return;
|
1388
|
-
await __privateGet$3(this, _cache).set(`rec_${__privateGet$3(this, _table)}:${record.id}`, record);
|
1389
|
-
};
|
1390
|
-
_getCacheRecord = new WeakSet();
|
1391
|
-
getCacheRecord_fn = async function(recordId) {
|
1392
|
-
if (!__privateGet$3(this, _cache).cacheRecords)
|
1393
|
-
return null;
|
1394
|
-
return __privateGet$3(this, _cache).get(`rec_${__privateGet$3(this, _table)}:${recordId}`);
|
1395
|
-
};
|
1396
1985
|
_setCacheQuery = new WeakSet();
|
1397
1986
|
setCacheQuery_fn = async function(query, meta, records) {
|
1398
|
-
await __privateGet$
|
1987
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1399
1988
|
};
|
1400
1989
|
_getCacheQuery = new WeakSet();
|
1401
1990
|
getCacheQuery_fn = async function(query) {
|
1402
|
-
const key = `query_${__privateGet$
|
1403
|
-
const result = await __privateGet$
|
1991
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1992
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
1404
1993
|
if (!result)
|
1405
1994
|
return null;
|
1406
|
-
const { cache: ttl = __privateGet$
|
1407
|
-
if (
|
1408
|
-
return
|
1995
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
1996
|
+
if (ttl < 0)
|
1997
|
+
return null;
|
1409
1998
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1410
1999
|
return hasExpired ? null : result;
|
1411
2000
|
};
|
2001
|
+
_getSchemaTables$1 = new WeakSet();
|
2002
|
+
getSchemaTables_fn$1 = async function() {
|
2003
|
+
if (__privateGet$4(this, _schemaTables$2))
|
2004
|
+
return __privateGet$4(this, _schemaTables$2);
|
2005
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2006
|
+
const { schema } = await getBranchDetails({
|
2007
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2008
|
+
...fetchProps
|
2009
|
+
});
|
2010
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
2011
|
+
return schema.tables;
|
2012
|
+
};
|
1412
2013
|
const transformObjectLinks = (object) => {
|
1413
2014
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
1414
2015
|
if (key === "xata")
|
@@ -1416,47 +2017,84 @@ const transformObjectLinks = (object) => {
|
|
1416
2017
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1417
2018
|
}, {});
|
1418
2019
|
};
|
1419
|
-
const initObject = (db,
|
2020
|
+
const initObject = (db, schemaTables, table, object) => {
|
1420
2021
|
const result = {};
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
2022
|
+
const { xata, ...rest } = object ?? {};
|
2023
|
+
Object.assign(result, rest);
|
2024
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
2025
|
+
if (!columns)
|
2026
|
+
console.error(`Table ${table} not found in schema`);
|
2027
|
+
for (const column of columns ?? []) {
|
2028
|
+
const value = result[column.name];
|
2029
|
+
switch (column.type) {
|
2030
|
+
case "datetime": {
|
2031
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
2032
|
+
if (date && isNaN(date.getTime())) {
|
2033
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
2034
|
+
} else if (date) {
|
2035
|
+
result[column.name] = date;
|
2036
|
+
}
|
2037
|
+
break;
|
2038
|
+
}
|
2039
|
+
case "link": {
|
2040
|
+
const linkTable = column.link?.table;
|
2041
|
+
if (!linkTable) {
|
2042
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
2043
|
+
} else if (isObject(value)) {
|
2044
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value);
|
2045
|
+
} else {
|
2046
|
+
result[column.name] = null;
|
2047
|
+
}
|
2048
|
+
break;
|
2049
|
+
}
|
2050
|
+
default:
|
2051
|
+
result[column.name] = value ?? null;
|
2052
|
+
if (column.notNull === true && value === null) {
|
2053
|
+
console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
|
2054
|
+
}
|
2055
|
+
break;
|
1428
2056
|
}
|
1429
2057
|
}
|
1430
|
-
result.read = function() {
|
1431
|
-
return db[table].read(result["id"]);
|
2058
|
+
result.read = function(columns2) {
|
2059
|
+
return db[table].read(result["id"], columns2);
|
1432
2060
|
};
|
1433
|
-
result.update = function(data) {
|
1434
|
-
return db[table].update(result["id"], data);
|
2061
|
+
result.update = function(data, columns2) {
|
2062
|
+
return db[table].update(result["id"], data, columns2);
|
1435
2063
|
};
|
1436
2064
|
result.delete = function() {
|
1437
2065
|
return db[table].delete(result["id"]);
|
1438
2066
|
};
|
1439
|
-
|
2067
|
+
result.getMetadata = function() {
|
2068
|
+
return xata;
|
2069
|
+
};
|
2070
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1440
2071
|
Object.defineProperty(result, prop, { enumerable: false });
|
1441
2072
|
}
|
1442
2073
|
Object.freeze(result);
|
1443
2074
|
return result;
|
1444
2075
|
};
|
1445
|
-
function
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
if (
|
1450
|
-
return
|
1451
|
-
|
1452
|
-
|
2076
|
+
function isResponseWithRecords(value) {
|
2077
|
+
return isObject(value) && Array.isArray(value.records);
|
2078
|
+
}
|
2079
|
+
function extractId(value) {
|
2080
|
+
if (isString(value))
|
2081
|
+
return value;
|
2082
|
+
if (isObject(value) && isString(value.id))
|
2083
|
+
return value.id;
|
2084
|
+
return void 0;
|
2085
|
+
}
|
2086
|
+
function cleanFilter(filter) {
|
2087
|
+
if (!filter)
|
2088
|
+
return void 0;
|
2089
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
2090
|
+
return values.length > 0 ? filter : void 0;
|
1453
2091
|
}
|
1454
2092
|
|
1455
2093
|
var __accessCheck$3 = (obj, member, msg) => {
|
1456
2094
|
if (!member.has(obj))
|
1457
2095
|
throw TypeError("Cannot " + msg);
|
1458
2096
|
};
|
1459
|
-
var __privateGet$
|
2097
|
+
var __privateGet$3 = (obj, member, getter) => {
|
1460
2098
|
__accessCheck$3(obj, member, "read from private field");
|
1461
2099
|
return getter ? getter.call(obj) : member.get(obj);
|
1462
2100
|
};
|
@@ -1465,7 +2103,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1465
2103
|
throw TypeError("Cannot add the same private member more than once");
|
1466
2104
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1467
2105
|
};
|
1468
|
-
var __privateSet$
|
2106
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1469
2107
|
__accessCheck$3(obj, member, "write to private field");
|
1470
2108
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1471
2109
|
return value;
|
@@ -1474,46 +2112,52 @@ var _map;
|
|
1474
2112
|
class SimpleCache {
|
1475
2113
|
constructor(options = {}) {
|
1476
2114
|
__privateAdd$3(this, _map, void 0);
|
1477
|
-
__privateSet$
|
2115
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
1478
2116
|
this.capacity = options.max ?? 500;
|
1479
|
-
this.cacheRecords = options.cacheRecords ?? true;
|
1480
2117
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1481
2118
|
}
|
1482
2119
|
async getAll() {
|
1483
|
-
return Object.fromEntries(__privateGet$
|
2120
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
1484
2121
|
}
|
1485
2122
|
async get(key) {
|
1486
|
-
return __privateGet$
|
2123
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
1487
2124
|
}
|
1488
2125
|
async set(key, value) {
|
1489
2126
|
await this.delete(key);
|
1490
|
-
__privateGet$
|
1491
|
-
if (__privateGet$
|
1492
|
-
const leastRecentlyUsed = __privateGet$
|
2127
|
+
__privateGet$3(this, _map).set(key, value);
|
2128
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
2129
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
1493
2130
|
await this.delete(leastRecentlyUsed);
|
1494
2131
|
}
|
1495
2132
|
}
|
1496
2133
|
async delete(key) {
|
1497
|
-
__privateGet$
|
2134
|
+
__privateGet$3(this, _map).delete(key);
|
1498
2135
|
}
|
1499
2136
|
async clear() {
|
1500
|
-
return __privateGet$
|
2137
|
+
return __privateGet$3(this, _map).clear();
|
1501
2138
|
}
|
1502
2139
|
}
|
1503
2140
|
_map = new WeakMap();
|
1504
2141
|
|
1505
|
-
const
|
1506
|
-
const
|
1507
|
-
const
|
1508
|
-
const
|
1509
|
-
const
|
1510
|
-
const
|
2142
|
+
const greaterThan = (value) => ({ $gt: value });
|
2143
|
+
const gt = greaterThan;
|
2144
|
+
const greaterThanEquals = (value) => ({ $ge: value });
|
2145
|
+
const greaterEquals = greaterThanEquals;
|
2146
|
+
const gte = greaterThanEquals;
|
2147
|
+
const ge = greaterThanEquals;
|
2148
|
+
const lessThan = (value) => ({ $lt: value });
|
2149
|
+
const lt = lessThan;
|
2150
|
+
const lessThanEquals = (value) => ({ $le: value });
|
2151
|
+
const lessEquals = lessThanEquals;
|
2152
|
+
const lte = lessThanEquals;
|
2153
|
+
const le = lessThanEquals;
|
1511
2154
|
const exists = (column) => ({ $exists: column });
|
1512
2155
|
const notExists = (column) => ({ $notExists: column });
|
1513
2156
|
const startsWith = (value) => ({ $startsWith: value });
|
1514
2157
|
const endsWith = (value) => ({ $endsWith: value });
|
1515
2158
|
const pattern = (value) => ({ $pattern: value });
|
1516
2159
|
const is = (value) => ({ $is: value });
|
2160
|
+
const equals = is;
|
1517
2161
|
const isNot = (value) => ({ $isNot: value });
|
1518
2162
|
const contains = (value) => ({ $contains: value });
|
1519
2163
|
const includes = (value) => ({ $includes: value });
|
@@ -1525,7 +2169,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
1525
2169
|
if (!member.has(obj))
|
1526
2170
|
throw TypeError("Cannot " + msg);
|
1527
2171
|
};
|
1528
|
-
var __privateGet$
|
2172
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1529
2173
|
__accessCheck$2(obj, member, "read from private field");
|
1530
2174
|
return getter ? getter.call(obj) : member.get(obj);
|
1531
2175
|
};
|
@@ -1534,130 +2178,178 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1534
2178
|
throw TypeError("Cannot add the same private member more than once");
|
1535
2179
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1536
2180
|
};
|
1537
|
-
var
|
2181
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
2182
|
+
__accessCheck$2(obj, member, "write to private field");
|
2183
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
2184
|
+
return value;
|
2185
|
+
};
|
2186
|
+
var _tables, _schemaTables$1;
|
1538
2187
|
class SchemaPlugin extends XataPlugin {
|
1539
|
-
constructor(
|
2188
|
+
constructor(schemaTables) {
|
1540
2189
|
super();
|
1541
|
-
this.links = links;
|
1542
|
-
this.tableNames = tableNames;
|
1543
2190
|
__privateAdd$2(this, _tables, {});
|
2191
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
2192
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
1544
2193
|
}
|
1545
2194
|
build(pluginOptions) {
|
1546
|
-
const
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
__privateGet$
|
2195
|
+
const db = new Proxy(
|
2196
|
+
{},
|
2197
|
+
{
|
2198
|
+
get: (_target, table) => {
|
2199
|
+
if (!isString(table))
|
2200
|
+
throw new Error("Invalid table name");
|
2201
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
2202
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
2203
|
+
}
|
2204
|
+
return __privateGet$2(this, _tables)[table];
|
1553
2205
|
}
|
1554
|
-
return __privateGet$1(this, _tables)[table];
|
1555
2206
|
}
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
2207
|
+
);
|
2208
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
2209
|
+
for (const table of tableNames) {
|
2210
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1559
2211
|
}
|
1560
2212
|
return db;
|
1561
2213
|
}
|
1562
2214
|
}
|
1563
2215
|
_tables = new WeakMap();
|
2216
|
+
_schemaTables$1 = new WeakMap();
|
1564
2217
|
|
1565
2218
|
var __accessCheck$1 = (obj, member, msg) => {
|
1566
2219
|
if (!member.has(obj))
|
1567
2220
|
throw TypeError("Cannot " + msg);
|
1568
2221
|
};
|
2222
|
+
var __privateGet$1 = (obj, member, getter) => {
|
2223
|
+
__accessCheck$1(obj, member, "read from private field");
|
2224
|
+
return getter ? getter.call(obj) : member.get(obj);
|
2225
|
+
};
|
1569
2226
|
var __privateAdd$1 = (obj, member, value) => {
|
1570
2227
|
if (member.has(obj))
|
1571
2228
|
throw TypeError("Cannot add the same private member more than once");
|
1572
2229
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1573
2230
|
};
|
2231
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
2232
|
+
__accessCheck$1(obj, member, "write to private field");
|
2233
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
2234
|
+
return value;
|
2235
|
+
};
|
1574
2236
|
var __privateMethod$1 = (obj, member, method) => {
|
1575
2237
|
__accessCheck$1(obj, member, "access private method");
|
1576
2238
|
return method;
|
1577
2239
|
};
|
1578
|
-
var _search, search_fn;
|
2240
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
1579
2241
|
class SearchPlugin extends XataPlugin {
|
1580
|
-
constructor(db,
|
2242
|
+
constructor(db, schemaTables) {
|
1581
2243
|
super();
|
1582
2244
|
this.db = db;
|
1583
|
-
this.links = links;
|
1584
2245
|
__privateAdd$1(this, _search);
|
2246
|
+
__privateAdd$1(this, _getSchemaTables);
|
2247
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
2248
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
1585
2249
|
}
|
1586
2250
|
build({ getFetchProps }) {
|
1587
2251
|
return {
|
1588
2252
|
all: async (query, options = {}) => {
|
1589
2253
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
2254
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1590
2255
|
return records.map((record) => {
|
1591
2256
|
const { table = "orphan" } = record.xata;
|
1592
|
-
return { table, record: initObject(this.db,
|
2257
|
+
return { table, record: initObject(this.db, schemaTables, table, record) };
|
1593
2258
|
});
|
1594
2259
|
},
|
1595
2260
|
byTable: async (query, options = {}) => {
|
1596
2261
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
2262
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1597
2263
|
return records.reduce((acc, record) => {
|
1598
2264
|
const { table = "orphan" } = record.xata;
|
1599
2265
|
const items = acc[table] ?? [];
|
1600
|
-
const item = initObject(this.db,
|
2266
|
+
const item = initObject(this.db, schemaTables, table, record);
|
1601
2267
|
return { ...acc, [table]: [...items, item] };
|
1602
2268
|
}, {});
|
1603
2269
|
}
|
1604
2270
|
};
|
1605
2271
|
}
|
1606
2272
|
}
|
2273
|
+
_schemaTables = new WeakMap();
|
1607
2274
|
_search = new WeakSet();
|
1608
2275
|
search_fn = async function(query, options, getFetchProps) {
|
1609
2276
|
const fetchProps = await getFetchProps();
|
1610
|
-
const { tables, fuzziness } = options ?? {};
|
2277
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
1611
2278
|
const { records } = await searchBranch({
|
1612
2279
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1613
|
-
body: { tables, query, fuzziness },
|
2280
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1614
2281
|
...fetchProps
|
1615
2282
|
});
|
1616
2283
|
return records;
|
1617
2284
|
};
|
2285
|
+
_getSchemaTables = new WeakSet();
|
2286
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
2287
|
+
if (__privateGet$1(this, _schemaTables))
|
2288
|
+
return __privateGet$1(this, _schemaTables);
|
2289
|
+
const fetchProps = await getFetchProps();
|
2290
|
+
const { schema } = await getBranchDetails({
|
2291
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
2292
|
+
...fetchProps
|
2293
|
+
});
|
2294
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
2295
|
+
return schema.tables;
|
2296
|
+
};
|
1618
2297
|
|
1619
2298
|
const isBranchStrategyBuilder = (strategy) => {
|
1620
2299
|
return typeof strategy === "function";
|
1621
2300
|
};
|
1622
2301
|
|
1623
|
-
const envBranchNames = [
|
1624
|
-
"XATA_BRANCH",
|
1625
|
-
"VERCEL_GIT_COMMIT_REF",
|
1626
|
-
"CF_PAGES_BRANCH",
|
1627
|
-
"BRANCH"
|
1628
|
-
];
|
1629
|
-
const defaultBranch = "main";
|
1630
2302
|
async function getCurrentBranchName(options) {
|
1631
|
-
const
|
1632
|
-
if (
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
return defaultBranch;
|
2303
|
+
const { branch, envBranch } = getEnvironment();
|
2304
|
+
if (branch) {
|
2305
|
+
const details = await getDatabaseBranch(branch, options);
|
2306
|
+
if (details)
|
2307
|
+
return branch;
|
2308
|
+
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
2309
|
+
}
|
2310
|
+
const gitBranch = envBranch || await getGitBranch();
|
2311
|
+
return resolveXataBranch(gitBranch, options);
|
1641
2312
|
}
|
1642
2313
|
async function getCurrentBranchDetails(options) {
|
1643
|
-
const
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
2314
|
+
const branch = await getCurrentBranchName(options);
|
2315
|
+
return getDatabaseBranch(branch, options);
|
2316
|
+
}
|
2317
|
+
async function resolveXataBranch(gitBranch, options) {
|
2318
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
2319
|
+
const apiKey = options?.apiKey || getAPIKey();
|
2320
|
+
if (!databaseURL)
|
2321
|
+
throw new Error(
|
2322
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
2323
|
+
);
|
2324
|
+
if (!apiKey)
|
2325
|
+
throw new Error(
|
2326
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2327
|
+
);
|
2328
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
2329
|
+
const [workspace] = host.split(".");
|
2330
|
+
const { fallbackBranch } = getEnvironment();
|
2331
|
+
const { branch } = await resolveBranch({
|
2332
|
+
apiKey,
|
2333
|
+
apiUrl: databaseURL,
|
2334
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
2335
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
2336
|
+
pathParams: { dbName, workspace },
|
2337
|
+
queryParams: { gitBranch, fallbackBranch },
|
2338
|
+
trace: defaultTrace
|
2339
|
+
});
|
2340
|
+
return branch;
|
1653
2341
|
}
|
1654
2342
|
async function getDatabaseBranch(branch, options) {
|
1655
2343
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1656
2344
|
const apiKey = options?.apiKey || getAPIKey();
|
1657
2345
|
if (!databaseURL)
|
1658
|
-
throw new Error(
|
2346
|
+
throw new Error(
|
2347
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
2348
|
+
);
|
1659
2349
|
if (!apiKey)
|
1660
|
-
throw new Error(
|
2350
|
+
throw new Error(
|
2351
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
2352
|
+
);
|
1661
2353
|
const [protocol, , host, , database] = databaseURL.split("/");
|
1662
2354
|
const [workspace] = host.split(".");
|
1663
2355
|
const dbBranchName = `${database}:${branch}`;
|
@@ -1667,10 +2359,8 @@ async function getDatabaseBranch(branch, options) {
|
|
1667
2359
|
apiUrl: databaseURL,
|
1668
2360
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1669
2361
|
workspacesApiUrl: `${protocol}//${host}`,
|
1670
|
-
pathParams: {
|
1671
|
-
|
1672
|
-
workspace
|
1673
|
-
}
|
2362
|
+
pathParams: { dbBranchName, workspace },
|
2363
|
+
trace: defaultTrace
|
1674
2364
|
});
|
1675
2365
|
} catch (err) {
|
1676
2366
|
if (isObject(err) && err.status === 404)
|
@@ -1678,21 +2368,10 @@ async function getDatabaseBranch(branch, options) {
|
|
1678
2368
|
throw err;
|
1679
2369
|
}
|
1680
2370
|
}
|
1681
|
-
function getBranchByEnvVariable() {
|
1682
|
-
for (const name of envBranchNames) {
|
1683
|
-
const value = getEnvVariable(name);
|
1684
|
-
if (value) {
|
1685
|
-
return value;
|
1686
|
-
}
|
1687
|
-
}
|
1688
|
-
try {
|
1689
|
-
return XATA_BRANCH;
|
1690
|
-
} catch (err) {
|
1691
|
-
}
|
1692
|
-
}
|
1693
2371
|
function getDatabaseURL() {
|
1694
2372
|
try {
|
1695
|
-
|
2373
|
+
const { databaseURL } = getEnvironment();
|
2374
|
+
return databaseURL;
|
1696
2375
|
} catch (err) {
|
1697
2376
|
return void 0;
|
1698
2377
|
}
|
@@ -1721,24 +2400,27 @@ var __privateMethod = (obj, member, method) => {
|
|
1721
2400
|
return method;
|
1722
2401
|
};
|
1723
2402
|
const buildClient = (plugins) => {
|
1724
|
-
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
2403
|
+
var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1725
2404
|
return _a = class {
|
1726
|
-
constructor(options = {},
|
2405
|
+
constructor(options = {}, schemaTables) {
|
1727
2406
|
__privateAdd(this, _parseOptions);
|
1728
2407
|
__privateAdd(this, _getFetchProps);
|
1729
2408
|
__privateAdd(this, _evaluateBranch);
|
1730
2409
|
__privateAdd(this, _branch, void 0);
|
2410
|
+
__privateAdd(this, _options, void 0);
|
1731
2411
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
2412
|
+
__privateSet(this, _options, safeOptions);
|
1732
2413
|
const pluginOptions = {
|
1733
2414
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1734
|
-
cache: safeOptions.cache
|
2415
|
+
cache: safeOptions.cache,
|
2416
|
+
trace: safeOptions.trace
|
1735
2417
|
};
|
1736
|
-
const db = new SchemaPlugin(
|
1737
|
-
const search = new SearchPlugin(db,
|
2418
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
2419
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
1738
2420
|
this.db = db;
|
1739
2421
|
this.search = search;
|
1740
2422
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1741
|
-
if (
|
2423
|
+
if (namespace === void 0)
|
1742
2424
|
continue;
|
1743
2425
|
const result = namespace.build(pluginOptions);
|
1744
2426
|
if (result instanceof Promise) {
|
@@ -1750,22 +2432,26 @@ const buildClient = (plugins) => {
|
|
1750
2432
|
}
|
1751
2433
|
}
|
1752
2434
|
}
|
1753
|
-
|
2435
|
+
async getConfig() {
|
2436
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
2437
|
+
const branch = await __privateGet(this, _options).branch();
|
2438
|
+
return { databaseURL, branch };
|
2439
|
+
}
|
2440
|
+
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
1754
2441
|
const fetch = getFetchImplementation(options?.fetch);
|
1755
2442
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1756
2443
|
const apiKey = options?.apiKey || getAPIKey();
|
1757
|
-
const cache = options?.cache ?? new SimpleCache({
|
1758
|
-
const
|
1759
|
-
|
1760
|
-
|
2444
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
2445
|
+
const trace = options?.trace ?? defaultTrace;
|
2446
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
2447
|
+
if (!apiKey) {
|
2448
|
+
throw new Error("Option apiKey is required");
|
1761
2449
|
}
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
apiKey,
|
1766
|
-
|
1767
|
-
branch
|
1768
|
-
}) {
|
2450
|
+
if (!databaseURL) {
|
2451
|
+
throw new Error("Option databaseURL is required");
|
2452
|
+
}
|
2453
|
+
return { fetch, databaseURL, apiKey, branch, cache, trace };
|
2454
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch, trace }) {
|
1769
2455
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
1770
2456
|
if (!branchValue)
|
1771
2457
|
throw new Error("Unable to resolve branch value");
|
@@ -1775,14 +2461,15 @@ const buildClient = (plugins) => {
|
|
1775
2461
|
apiUrl: "",
|
1776
2462
|
workspacesApiUrl: (path, params) => {
|
1777
2463
|
const hasBranch = params.dbBranchName ?? params.branch;
|
1778
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
2464
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
1779
2465
|
return databaseURL + newPath;
|
1780
|
-
}
|
2466
|
+
},
|
2467
|
+
trace
|
1781
2468
|
};
|
1782
2469
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1783
2470
|
if (__privateGet(this, _branch))
|
1784
2471
|
return __privateGet(this, _branch);
|
1785
|
-
if (
|
2472
|
+
if (param === void 0)
|
1786
2473
|
return void 0;
|
1787
2474
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1788
2475
|
const evaluateBranch = async (strategy) => {
|
@@ -1800,6 +2487,88 @@ const buildClient = (plugins) => {
|
|
1800
2487
|
class BaseClient extends buildClient() {
|
1801
2488
|
}
|
1802
2489
|
|
2490
|
+
const META = "__";
|
2491
|
+
const VALUE = "___";
|
2492
|
+
class Serializer {
|
2493
|
+
constructor() {
|
2494
|
+
this.classes = {};
|
2495
|
+
}
|
2496
|
+
add(clazz) {
|
2497
|
+
this.classes[clazz.name] = clazz;
|
2498
|
+
}
|
2499
|
+
toJSON(data) {
|
2500
|
+
function visit(obj) {
|
2501
|
+
if (Array.isArray(obj))
|
2502
|
+
return obj.map(visit);
|
2503
|
+
const type = typeof obj;
|
2504
|
+
if (type === "undefined")
|
2505
|
+
return { [META]: "undefined" };
|
2506
|
+
if (type === "bigint")
|
2507
|
+
return { [META]: "bigint", [VALUE]: obj.toString() };
|
2508
|
+
if (obj === null || type !== "object")
|
2509
|
+
return obj;
|
2510
|
+
const constructor = obj.constructor;
|
2511
|
+
const o = { [META]: constructor.name };
|
2512
|
+
for (const [key, value] of Object.entries(obj)) {
|
2513
|
+
o[key] = visit(value);
|
2514
|
+
}
|
2515
|
+
if (constructor === Date)
|
2516
|
+
o[VALUE] = obj.toISOString();
|
2517
|
+
if (constructor === Map)
|
2518
|
+
o[VALUE] = Object.fromEntries(obj);
|
2519
|
+
if (constructor === Set)
|
2520
|
+
o[VALUE] = [...obj];
|
2521
|
+
return o;
|
2522
|
+
}
|
2523
|
+
return JSON.stringify(visit(data));
|
2524
|
+
}
|
2525
|
+
fromJSON(json) {
|
2526
|
+
return JSON.parse(json, (key, value) => {
|
2527
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
2528
|
+
const { [META]: clazz, [VALUE]: val, ...rest } = value;
|
2529
|
+
const constructor = this.classes[clazz];
|
2530
|
+
if (constructor) {
|
2531
|
+
return Object.assign(Object.create(constructor.prototype), rest);
|
2532
|
+
}
|
2533
|
+
if (clazz === "Date")
|
2534
|
+
return new Date(val);
|
2535
|
+
if (clazz === "Set")
|
2536
|
+
return new Set(val);
|
2537
|
+
if (clazz === "Map")
|
2538
|
+
return new Map(Object.entries(val));
|
2539
|
+
if (clazz === "bigint")
|
2540
|
+
return BigInt(val);
|
2541
|
+
if (clazz === "undefined")
|
2542
|
+
return void 0;
|
2543
|
+
return rest;
|
2544
|
+
}
|
2545
|
+
return value;
|
2546
|
+
});
|
2547
|
+
}
|
2548
|
+
}
|
2549
|
+
const defaultSerializer = new Serializer();
|
2550
|
+
const serialize = (data) => {
|
2551
|
+
return defaultSerializer.toJSON(data);
|
2552
|
+
};
|
2553
|
+
const deserialize = (json) => {
|
2554
|
+
return defaultSerializer.fromJSON(json);
|
2555
|
+
};
|
2556
|
+
|
2557
|
+
function buildWorkerRunner(config) {
|
2558
|
+
return function xataWorker(name, _worker) {
|
2559
|
+
return async (...args) => {
|
2560
|
+
const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
|
2561
|
+
const result = await fetch(url, {
|
2562
|
+
method: "POST",
|
2563
|
+
headers: { "Content-Type": "application/json" },
|
2564
|
+
body: serialize({ args })
|
2565
|
+
});
|
2566
|
+
const text = await result.text();
|
2567
|
+
return deserialize(text);
|
2568
|
+
};
|
2569
|
+
};
|
2570
|
+
}
|
2571
|
+
|
1803
2572
|
class XataError extends Error {
|
1804
2573
|
constructor(message, status) {
|
1805
2574
|
super(message);
|
@@ -1815,23 +2584,32 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
|
|
1815
2584
|
exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
1816
2585
|
exports.Page = Page;
|
1817
2586
|
exports.Query = Query;
|
2587
|
+
exports.RecordArray = RecordArray;
|
1818
2588
|
exports.Repository = Repository;
|
1819
2589
|
exports.RestRepository = RestRepository;
|
1820
2590
|
exports.SchemaPlugin = SchemaPlugin;
|
1821
2591
|
exports.SearchPlugin = SearchPlugin;
|
2592
|
+
exports.Serializer = Serializer;
|
1822
2593
|
exports.SimpleCache = SimpleCache;
|
1823
2594
|
exports.XataApiClient = XataApiClient;
|
1824
2595
|
exports.XataApiPlugin = XataApiPlugin;
|
1825
2596
|
exports.XataError = XataError;
|
1826
2597
|
exports.XataPlugin = XataPlugin;
|
1827
2598
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
2599
|
+
exports.addGitBranchesEntry = addGitBranchesEntry;
|
1828
2600
|
exports.addTableColumn = addTableColumn;
|
2601
|
+
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
1829
2602
|
exports.buildClient = buildClient;
|
2603
|
+
exports.buildWorkerRunner = buildWorkerRunner;
|
1830
2604
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
1831
2605
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
2606
|
+
exports.compareBranchSchemas = compareBranchSchemas;
|
2607
|
+
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
2608
|
+
exports.compareMigrationRequest = compareMigrationRequest;
|
1832
2609
|
exports.contains = contains;
|
1833
2610
|
exports.createBranch = createBranch;
|
1834
2611
|
exports.createDatabase = createDatabase;
|
2612
|
+
exports.createMigrationRequest = createMigrationRequest;
|
1835
2613
|
exports.createTable = createTable;
|
1836
2614
|
exports.createUserAPIKey = createUserAPIKey;
|
1837
2615
|
exports.createWorkspace = createWorkspace;
|
@@ -1843,7 +2621,9 @@ exports.deleteTable = deleteTable;
|
|
1843
2621
|
exports.deleteUser = deleteUser;
|
1844
2622
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
1845
2623
|
exports.deleteWorkspace = deleteWorkspace;
|
2624
|
+
exports.deserialize = deserialize;
|
1846
2625
|
exports.endsWith = endsWith;
|
2626
|
+
exports.equals = equals;
|
1847
2627
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
1848
2628
|
exports.exists = exists;
|
1849
2629
|
exports.ge = ge;
|
@@ -1853,12 +2633,17 @@ exports.getBranchList = getBranchList;
|
|
1853
2633
|
exports.getBranchMetadata = getBranchMetadata;
|
1854
2634
|
exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
1855
2635
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
2636
|
+
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
1856
2637
|
exports.getBranchStats = getBranchStats;
|
1857
2638
|
exports.getColumn = getColumn;
|
1858
2639
|
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
1859
2640
|
exports.getCurrentBranchName = getCurrentBranchName;
|
1860
2641
|
exports.getDatabaseList = getDatabaseList;
|
2642
|
+
exports.getDatabaseMetadata = getDatabaseMetadata;
|
1861
2643
|
exports.getDatabaseURL = getDatabaseURL;
|
2644
|
+
exports.getGitBranchesMapping = getGitBranchesMapping;
|
2645
|
+
exports.getMigrationRequest = getMigrationRequest;
|
2646
|
+
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
1862
2647
|
exports.getRecord = getRecord;
|
1863
2648
|
exports.getTableColumns = getTableColumns;
|
1864
2649
|
exports.getTableSchema = getTableSchema;
|
@@ -1867,6 +2652,9 @@ exports.getUserAPIKeys = getUserAPIKeys;
|
|
1867
2652
|
exports.getWorkspace = getWorkspace;
|
1868
2653
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
1869
2654
|
exports.getWorkspacesList = getWorkspacesList;
|
2655
|
+
exports.greaterEquals = greaterEquals;
|
2656
|
+
exports.greaterThan = greaterThan;
|
2657
|
+
exports.greaterThanEquals = greaterThanEquals;
|
1870
2658
|
exports.gt = gt;
|
1871
2659
|
exports.gte = gte;
|
1872
2660
|
exports.includes = includes;
|
@@ -1877,27 +2665,44 @@ exports.insertRecord = insertRecord;
|
|
1877
2665
|
exports.insertRecordWithID = insertRecordWithID;
|
1878
2666
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
1879
2667
|
exports.is = is;
|
2668
|
+
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
1880
2669
|
exports.isIdentifiable = isIdentifiable;
|
1881
2670
|
exports.isNot = isNot;
|
1882
2671
|
exports.isXataRecord = isXataRecord;
|
1883
2672
|
exports.le = le;
|
2673
|
+
exports.lessEquals = lessEquals;
|
2674
|
+
exports.lessThan = lessThan;
|
2675
|
+
exports.lessThanEquals = lessThanEquals;
|
2676
|
+
exports.listMigrationRequests = listMigrationRequests;
|
2677
|
+
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
1884
2678
|
exports.lt = lt;
|
1885
2679
|
exports.lte = lte;
|
2680
|
+
exports.mergeMigrationRequest = mergeMigrationRequest;
|
1886
2681
|
exports.notExists = notExists;
|
1887
2682
|
exports.operationsByTag = operationsByTag;
|
1888
2683
|
exports.pattern = pattern;
|
2684
|
+
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
1889
2685
|
exports.queryTable = queryTable;
|
2686
|
+
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|
1890
2687
|
exports.removeWorkspaceMember = removeWorkspaceMember;
|
1891
2688
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
2689
|
+
exports.resolveBranch = resolveBranch;
|
1892
2690
|
exports.searchBranch = searchBranch;
|
2691
|
+
exports.searchTable = searchTable;
|
2692
|
+
exports.serialize = serialize;
|
1893
2693
|
exports.setTableSchema = setTableSchema;
|
1894
2694
|
exports.startsWith = startsWith;
|
2695
|
+
exports.summarizeTable = summarizeTable;
|
1895
2696
|
exports.updateBranchMetadata = updateBranchMetadata;
|
2697
|
+
exports.updateBranchSchema = updateBranchSchema;
|
1896
2698
|
exports.updateColumn = updateColumn;
|
2699
|
+
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
2700
|
+
exports.updateMigrationRequest = updateMigrationRequest;
|
1897
2701
|
exports.updateRecordWithID = updateRecordWithID;
|
1898
2702
|
exports.updateTable = updateTable;
|
1899
2703
|
exports.updateUser = updateUser;
|
1900
2704
|
exports.updateWorkspace = updateWorkspace;
|
2705
|
+
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
1901
2706
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
1902
2707
|
exports.upsertRecordWithID = upsertRecordWithID;
|
1903
2708
|
//# sourceMappingURL=index.cjs.map
|