@xata.io/client 0.0.0-alpha.vfee45b2 → 0.0.0-alpha.vfef462e
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/CHANGELOG.md +120 -0
- package/README.md +271 -1
- package/Usage.md +428 -0
- package/dist/index.cjs +407 -275
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +667 -148
- package/dist/index.mjs +388 -276
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
package/dist/index.cjs
CHANGED
@@ -2,6 +2,24 @@
|
|
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
|
+
|
5
23
|
function notEmpty(value) {
|
6
24
|
return value !== null && value !== void 0;
|
7
25
|
}
|
@@ -17,43 +35,95 @@ function isDefined(value) {
|
|
17
35
|
function isString(value) {
|
18
36
|
return isDefined(value) && typeof value === "string";
|
19
37
|
}
|
38
|
+
function isStringArray(value) {
|
39
|
+
return isDefined(value) && Array.isArray(value) && value.every(isString);
|
40
|
+
}
|
20
41
|
function toBase64(value) {
|
21
42
|
try {
|
22
43
|
return btoa(value);
|
23
44
|
} catch (err) {
|
24
|
-
|
45
|
+
const buf = Buffer;
|
46
|
+
return buf.from(value).toString("base64");
|
25
47
|
}
|
26
48
|
}
|
27
49
|
|
28
|
-
function
|
50
|
+
function getEnvironment() {
|
29
51
|
try {
|
30
|
-
if (isObject(process) &&
|
31
|
-
return
|
52
|
+
if (isObject(process) && isObject(process.env)) {
|
53
|
+
return {
|
54
|
+
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
55
|
+
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
56
|
+
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
57
|
+
envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
|
58
|
+
fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
|
59
|
+
};
|
32
60
|
}
|
33
61
|
} catch (err) {
|
34
62
|
}
|
35
63
|
try {
|
36
|
-
if (isObject(Deno) &&
|
37
|
-
return
|
64
|
+
if (isObject(Deno) && isObject(Deno.env)) {
|
65
|
+
return {
|
66
|
+
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
67
|
+
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
68
|
+
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
69
|
+
envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
|
70
|
+
fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
|
71
|
+
};
|
38
72
|
}
|
39
73
|
} catch (err) {
|
40
74
|
}
|
75
|
+
return {
|
76
|
+
apiKey: getGlobalApiKey(),
|
77
|
+
databaseURL: getGlobalDatabaseURL(),
|
78
|
+
branch: getGlobalBranch(),
|
79
|
+
envBranch: void 0,
|
80
|
+
fallbackBranch: getGlobalFallbackBranch()
|
81
|
+
};
|
82
|
+
}
|
83
|
+
function getGlobalApiKey() {
|
84
|
+
try {
|
85
|
+
return XATA_API_KEY;
|
86
|
+
} catch (err) {
|
87
|
+
return void 0;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
function getGlobalDatabaseURL() {
|
91
|
+
try {
|
92
|
+
return XATA_DATABASE_URL;
|
93
|
+
} catch (err) {
|
94
|
+
return void 0;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
function getGlobalBranch() {
|
98
|
+
try {
|
99
|
+
return XATA_BRANCH;
|
100
|
+
} catch (err) {
|
101
|
+
return void 0;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
function getGlobalFallbackBranch() {
|
105
|
+
try {
|
106
|
+
return XATA_FALLBACK_BRANCH;
|
107
|
+
} catch (err) {
|
108
|
+
return void 0;
|
109
|
+
}
|
41
110
|
}
|
42
111
|
async function getGitBranch() {
|
112
|
+
const cmd = ["git", "branch", "--show-current"];
|
113
|
+
const fullCmd = cmd.join(" ");
|
114
|
+
const nodeModule = ["child", "process"].join("_");
|
115
|
+
const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
|
43
116
|
try {
|
44
117
|
if (typeof require === "function") {
|
45
|
-
|
46
|
-
return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
|
118
|
+
return require(nodeModule).execSync(fullCmd, execOptions).trim();
|
47
119
|
}
|
120
|
+
const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
|
121
|
+
return execSync(fullCmd, execOptions).toString().trim();
|
48
122
|
} catch (err) {
|
49
123
|
}
|
50
124
|
try {
|
51
125
|
if (isObject(Deno)) {
|
52
|
-
const process2 = Deno.run({
|
53
|
-
cmd: ["git", "branch", "--show-current"],
|
54
|
-
stdout: "piped",
|
55
|
-
stderr: "piped"
|
56
|
-
});
|
126
|
+
const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
|
57
127
|
return new TextDecoder().decode(await process2.output()).trim();
|
58
128
|
}
|
59
129
|
} catch (err) {
|
@@ -62,7 +132,8 @@ async function getGitBranch() {
|
|
62
132
|
|
63
133
|
function getAPIKey() {
|
64
134
|
try {
|
65
|
-
|
135
|
+
const { apiKey } = getEnvironment();
|
136
|
+
return apiKey;
|
66
137
|
} catch (err) {
|
67
138
|
return void 0;
|
68
139
|
}
|
@@ -72,26 +143,35 @@ function getFetchImplementation(userFetch) {
|
|
72
143
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
73
144
|
const fetchImpl = userFetch ?? globalFetch;
|
74
145
|
if (!fetchImpl) {
|
75
|
-
throw new Error(
|
146
|
+
throw new Error(
|
147
|
+
`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`
|
148
|
+
);
|
76
149
|
}
|
77
150
|
return fetchImpl;
|
78
151
|
}
|
79
152
|
|
153
|
+
const VERSION = "0.0.0-alpha.vfef462e";
|
154
|
+
|
80
155
|
class ErrorWithCause extends Error {
|
81
156
|
constructor(message, options) {
|
82
157
|
super(message, options);
|
83
158
|
}
|
84
159
|
}
|
85
160
|
class FetcherError extends ErrorWithCause {
|
86
|
-
constructor(status, data) {
|
161
|
+
constructor(status, data, requestId) {
|
87
162
|
super(getMessage(data));
|
88
163
|
this.status = status;
|
89
164
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
165
|
+
this.requestId = requestId;
|
90
166
|
if (data instanceof Error) {
|
91
167
|
this.stack = data.stack;
|
92
168
|
this.cause = data.cause;
|
93
169
|
}
|
94
170
|
}
|
171
|
+
toString() {
|
172
|
+
const error = super.toString();
|
173
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
174
|
+
}
|
95
175
|
}
|
96
176
|
function isBulkError(error) {
|
97
177
|
return isObject(error) && Array.isArray(error.errors);
|
@@ -114,7 +194,12 @@ function getMessage(data) {
|
|
114
194
|
}
|
115
195
|
|
116
196
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
117
|
-
const
|
197
|
+
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
198
|
+
if (value === void 0 || value === null)
|
199
|
+
return acc;
|
200
|
+
return { ...acc, [key]: value };
|
201
|
+
}, {});
|
202
|
+
const query = new URLSearchParams(cleanQueryParams).toString();
|
118
203
|
const queryString = query.length > 0 ? `?${query}` : "";
|
119
204
|
return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
|
120
205
|
};
|
@@ -154,6 +239,7 @@ async function fetch$1({
|
|
154
239
|
body: body ? JSON.stringify(body) : void 0,
|
155
240
|
headers: {
|
156
241
|
"Content-Type": "application/json",
|
242
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
157
243
|
...headers,
|
158
244
|
...hostHeader(fullUrl),
|
159
245
|
Authorization: `Bearer ${apiKey}`
|
@@ -162,14 +248,15 @@ async function fetch$1({
|
|
162
248
|
if (response.status === 204) {
|
163
249
|
return {};
|
164
250
|
}
|
251
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
165
252
|
try {
|
166
253
|
const jsonResponse = await response.json();
|
167
254
|
if (response.ok) {
|
168
255
|
return jsonResponse;
|
169
256
|
}
|
170
|
-
throw new FetcherError(response.status, jsonResponse);
|
257
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
171
258
|
} catch (error) {
|
172
|
-
throw new FetcherError(response.status, error);
|
259
|
+
throw new FetcherError(response.status, error, requestId);
|
173
260
|
}
|
174
261
|
}
|
175
262
|
|
@@ -228,6 +315,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
|
|
228
315
|
...variables
|
229
316
|
});
|
230
317
|
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
318
|
+
const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
|
231
319
|
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
232
320
|
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
233
321
|
method: "delete",
|
@@ -276,11 +364,7 @@ const getBranchDetails = (variables) => fetch$1({
|
|
276
364
|
method: "get",
|
277
365
|
...variables
|
278
366
|
});
|
279
|
-
const createBranch = (variables) => fetch$1({
|
280
|
-
url: "/db/{dbBranchName}",
|
281
|
-
method: "put",
|
282
|
-
...variables
|
283
|
-
});
|
367
|
+
const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
|
284
368
|
const deleteBranch = (variables) => fetch$1({
|
285
369
|
url: "/db/{dbBranchName}",
|
286
370
|
method: "delete",
|
@@ -354,11 +438,7 @@ const updateColumn = (variables) => fetch$1({
|
|
354
438
|
method: "patch",
|
355
439
|
...variables
|
356
440
|
});
|
357
|
-
const insertRecord = (variables) => fetch$1({
|
358
|
-
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
359
|
-
method: "post",
|
360
|
-
...variables
|
361
|
-
});
|
441
|
+
const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
|
362
442
|
const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
|
363
443
|
const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
|
364
444
|
const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
|
@@ -400,6 +480,7 @@ const operationsByTag = {
|
|
400
480
|
updateWorkspaceMemberRole,
|
401
481
|
removeWorkspaceMember,
|
402
482
|
inviteWorkspaceMember,
|
483
|
+
updateWorkspaceMemberInvite,
|
403
484
|
cancelWorkspaceMemberInvite,
|
404
485
|
resendWorkspaceMemberInvite,
|
405
486
|
acceptWorkspaceMemberInvite
|
@@ -489,7 +570,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
489
570
|
throw TypeError("Cannot add the same private member more than once");
|
490
571
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
491
572
|
};
|
492
|
-
var __privateSet$
|
573
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
493
574
|
__accessCheck$7(obj, member, "write to private field");
|
494
575
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
495
576
|
return value;
|
@@ -504,7 +585,7 @@ class XataApiClient {
|
|
504
585
|
if (!apiKey) {
|
505
586
|
throw new Error("Could not resolve a valid apiKey");
|
506
587
|
}
|
507
|
-
__privateSet$
|
588
|
+
__privateSet$7(this, _extraProps, {
|
508
589
|
apiUrl: getHostUrl(provider, "main"),
|
509
590
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
510
591
|
fetchImpl: getFetchImplementation(options.fetch),
|
@@ -631,6 +712,13 @@ class WorkspaceApi {
|
|
631
712
|
...this.extraProps
|
632
713
|
});
|
633
714
|
}
|
715
|
+
updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
|
716
|
+
return operationsByTag.workspaces.updateWorkspaceMemberInvite({
|
717
|
+
pathParams: { workspaceId, inviteId },
|
718
|
+
body: { role },
|
719
|
+
...this.extraProps
|
720
|
+
});
|
721
|
+
}
|
634
722
|
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
635
723
|
return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
|
636
724
|
pathParams: { workspaceId, inviteId },
|
@@ -693,10 +781,10 @@ class DatabaseApi {
|
|
693
781
|
...this.extraProps
|
694
782
|
});
|
695
783
|
}
|
696
|
-
resolveBranch(workspace, dbName, gitBranch) {
|
784
|
+
resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
|
697
785
|
return operationsByTag.database.resolveBranch({
|
698
786
|
pathParams: { workspace, dbName },
|
699
|
-
queryParams: { gitBranch },
|
787
|
+
queryParams: { gitBranch, fallbackBranch },
|
700
788
|
...this.extraProps
|
701
789
|
});
|
702
790
|
}
|
@@ -845,9 +933,10 @@ class RecordsApi {
|
|
845
933
|
constructor(extraProps) {
|
846
934
|
this.extraProps = extraProps;
|
847
935
|
}
|
848
|
-
insertRecord(workspace, database, branch, tableName, record) {
|
936
|
+
insertRecord(workspace, database, branch, tableName, record, options = {}) {
|
849
937
|
return operationsByTag.records.insertRecord({
|
850
938
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
939
|
+
queryParams: options,
|
851
940
|
body: record,
|
852
941
|
...this.extraProps
|
853
942
|
});
|
@@ -876,21 +965,24 @@ class RecordsApi {
|
|
876
965
|
...this.extraProps
|
877
966
|
});
|
878
967
|
}
|
879
|
-
deleteRecord(workspace, database, branch, tableName, recordId) {
|
968
|
+
deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
880
969
|
return operationsByTag.records.deleteRecord({
|
881
970
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
971
|
+
queryParams: options,
|
882
972
|
...this.extraProps
|
883
973
|
});
|
884
974
|
}
|
885
975
|
getRecord(workspace, database, branch, tableName, recordId, options = {}) {
|
886
976
|
return operationsByTag.records.getRecord({
|
887
977
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
|
978
|
+
queryParams: options,
|
888
979
|
...this.extraProps
|
889
980
|
});
|
890
981
|
}
|
891
|
-
bulkInsertTableRecords(workspace, database, branch, tableName, records) {
|
982
|
+
bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
|
892
983
|
return operationsByTag.records.bulkInsertTableRecords({
|
893
984
|
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
985
|
+
queryParams: options,
|
894
986
|
body: { records },
|
895
987
|
...this.extraProps
|
896
988
|
});
|
@@ -941,18 +1033,18 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
941
1033
|
throw TypeError("Cannot add the same private member more than once");
|
942
1034
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
943
1035
|
};
|
944
|
-
var __privateSet$
|
1036
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
945
1037
|
__accessCheck$6(obj, member, "write to private field");
|
946
1038
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
947
1039
|
return value;
|
948
1040
|
};
|
949
|
-
var _query;
|
1041
|
+
var _query, _page;
|
950
1042
|
class Page {
|
951
1043
|
constructor(query, meta, records = []) {
|
952
1044
|
__privateAdd$6(this, _query, void 0);
|
953
|
-
__privateSet$
|
1045
|
+
__privateSet$6(this, _query, query);
|
954
1046
|
this.meta = meta;
|
955
|
-
this.records = records;
|
1047
|
+
this.records = new RecordArray(this, records);
|
956
1048
|
}
|
957
1049
|
async nextPage(size, offset) {
|
958
1050
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
@@ -972,12 +1064,56 @@ class Page {
|
|
972
1064
|
}
|
973
1065
|
_query = new WeakMap();
|
974
1066
|
const PAGINATION_MAX_SIZE = 200;
|
975
|
-
const PAGINATION_DEFAULT_SIZE =
|
1067
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
976
1068
|
const PAGINATION_MAX_OFFSET = 800;
|
977
1069
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
978
1070
|
function isCursorPaginationOptions(options) {
|
979
1071
|
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
980
1072
|
}
|
1073
|
+
const _RecordArray = class extends Array {
|
1074
|
+
constructor(...args) {
|
1075
|
+
super(..._RecordArray.parseConstructorParams(...args));
|
1076
|
+
__privateAdd$6(this, _page, void 0);
|
1077
|
+
__privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
1078
|
+
}
|
1079
|
+
static parseConstructorParams(...args) {
|
1080
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
1081
|
+
return new Array(args[0]);
|
1082
|
+
}
|
1083
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
1084
|
+
const result = args[1] ?? args[0].records ?? [];
|
1085
|
+
return new Array(...result);
|
1086
|
+
}
|
1087
|
+
return new Array(...args);
|
1088
|
+
}
|
1089
|
+
toArray() {
|
1090
|
+
return new Array(...this);
|
1091
|
+
}
|
1092
|
+
map(callbackfn, thisArg) {
|
1093
|
+
return this.toArray().map(callbackfn, thisArg);
|
1094
|
+
}
|
1095
|
+
async nextPage(size, offset) {
|
1096
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1097
|
+
return new _RecordArray(newPage);
|
1098
|
+
}
|
1099
|
+
async previousPage(size, offset) {
|
1100
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1101
|
+
return new _RecordArray(newPage);
|
1102
|
+
}
|
1103
|
+
async firstPage(size, offset) {
|
1104
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
1105
|
+
return new _RecordArray(newPage);
|
1106
|
+
}
|
1107
|
+
async lastPage(size, offset) {
|
1108
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
1109
|
+
return new _RecordArray(newPage);
|
1110
|
+
}
|
1111
|
+
hasNextPage() {
|
1112
|
+
return __privateGet$6(this, _page).meta.page.more;
|
1113
|
+
}
|
1114
|
+
};
|
1115
|
+
let RecordArray = _RecordArray;
|
1116
|
+
_page = new WeakMap();
|
981
1117
|
|
982
1118
|
var __accessCheck$5 = (obj, member, msg) => {
|
983
1119
|
if (!member.has(obj))
|
@@ -992,7 +1128,7 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
992
1128
|
throw TypeError("Cannot add the same private member more than once");
|
993
1129
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
994
1130
|
};
|
995
|
-
var __privateSet$
|
1131
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
996
1132
|
__accessCheck$5(obj, member, "write to private field");
|
997
1133
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
998
1134
|
return value;
|
@@ -1004,12 +1140,12 @@ const _Query = class {
|
|
1004
1140
|
__privateAdd$5(this, _repository, void 0);
|
1005
1141
|
__privateAdd$5(this, _data, { filter: {} });
|
1006
1142
|
this.meta = { page: { cursor: "start", more: true } };
|
1007
|
-
this.records = [];
|
1008
|
-
__privateSet$
|
1143
|
+
this.records = new RecordArray(this, []);
|
1144
|
+
__privateSet$5(this, _table$1, table);
|
1009
1145
|
if (repository) {
|
1010
|
-
__privateSet$
|
1146
|
+
__privateSet$5(this, _repository, repository);
|
1011
1147
|
} else {
|
1012
|
-
__privateSet$
|
1148
|
+
__privateSet$5(this, _repository, this);
|
1013
1149
|
}
|
1014
1150
|
const parent = cleanParent(data, rawParent);
|
1015
1151
|
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
@@ -1070,7 +1206,12 @@ const _Query = class {
|
|
1070
1206
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1071
1207
|
}
|
1072
1208
|
select(columns) {
|
1073
|
-
return new _Query(
|
1209
|
+
return new _Query(
|
1210
|
+
__privateGet$5(this, _repository),
|
1211
|
+
__privateGet$5(this, _table$1),
|
1212
|
+
{ columns },
|
1213
|
+
__privateGet$5(this, _data)
|
1214
|
+
);
|
1074
1215
|
}
|
1075
1216
|
getPaginated(options = {}) {
|
1076
1217
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
@@ -1093,8 +1234,11 @@ const _Query = class {
|
|
1093
1234
|
}
|
1094
1235
|
}
|
1095
1236
|
async getMany(options = {}) {
|
1096
|
-
const
|
1097
|
-
|
1237
|
+
const page = await this.getPaginated(options);
|
1238
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1239
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1240
|
+
}
|
1241
|
+
return page.records;
|
1098
1242
|
}
|
1099
1243
|
async getAll(options = {}) {
|
1100
1244
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1142,7 +1286,9 @@ function isIdentifiable(x) {
|
|
1142
1286
|
return isObject(x) && isString(x?.id);
|
1143
1287
|
}
|
1144
1288
|
function isXataRecord(x) {
|
1145
|
-
|
1289
|
+
const record = x;
|
1290
|
+
const metadata = record?.getMetadata();
|
1291
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1146
1292
|
}
|
1147
1293
|
|
1148
1294
|
function isSortFilterString(value) {
|
@@ -1181,7 +1327,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
1181
1327
|
throw TypeError("Cannot add the same private member more than once");
|
1182
1328
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1183
1329
|
};
|
1184
|
-
var __privateSet$
|
1330
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
1185
1331
|
__accessCheck$4(obj, member, "write to private field");
|
1186
1332
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1187
1333
|
return value;
|
@@ -1190,7 +1336,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1190
1336
|
__accessCheck$4(obj, member, "access private method");
|
1191
1337
|
return method;
|
1192
1338
|
};
|
1193
|
-
var _table, _getFetchProps, _cache,
|
1339
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _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;
|
1194
1340
|
class Repository extends Query {
|
1195
1341
|
}
|
1196
1342
|
class RestRepository extends Query {
|
@@ -1202,111 +1348,122 @@ class RestRepository extends Query {
|
|
1202
1348
|
__privateAdd$4(this, _updateRecordWithID);
|
1203
1349
|
__privateAdd$4(this, _upsertRecordWithID);
|
1204
1350
|
__privateAdd$4(this, _deleteRecord);
|
1205
|
-
__privateAdd$4(this, _invalidateCache);
|
1206
|
-
__privateAdd$4(this, _setCacheRecord);
|
1207
|
-
__privateAdd$4(this, _getCacheRecord);
|
1208
1351
|
__privateAdd$4(this, _setCacheQuery);
|
1209
1352
|
__privateAdd$4(this, _getCacheQuery);
|
1210
|
-
__privateAdd$4(this,
|
1353
|
+
__privateAdd$4(this, _getSchemaTables$1);
|
1211
1354
|
__privateAdd$4(this, _table, void 0);
|
1212
1355
|
__privateAdd$4(this, _getFetchProps, void 0);
|
1356
|
+
__privateAdd$4(this, _db, void 0);
|
1213
1357
|
__privateAdd$4(this, _cache, void 0);
|
1214
|
-
__privateAdd$4(this,
|
1215
|
-
__privateSet$
|
1216
|
-
__privateSet$
|
1217
|
-
this
|
1218
|
-
__privateSet$
|
1219
|
-
|
1220
|
-
|
1358
|
+
__privateAdd$4(this, _schemaTables$2, void 0);
|
1359
|
+
__privateSet$4(this, _table, options.table);
|
1360
|
+
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1361
|
+
__privateSet$4(this, _db, options.db);
|
1362
|
+
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
1363
|
+
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
1364
|
+
}
|
1365
|
+
async create(a, b, c) {
|
1221
1366
|
if (Array.isArray(a)) {
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1367
|
+
if (a.length === 0)
|
1368
|
+
return [];
|
1369
|
+
const columns = isStringArray(b) ? b : void 0;
|
1370
|
+
return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
|
1225
1371
|
}
|
1226
1372
|
if (isString(a) && isObject(b)) {
|
1227
1373
|
if (a === "")
|
1228
1374
|
throw new Error("The id can't be empty");
|
1229
|
-
const
|
1230
|
-
|
1231
|
-
return record;
|
1375
|
+
const columns = isStringArray(c) ? c : void 0;
|
1376
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
|
1232
1377
|
}
|
1233
1378
|
if (isObject(a) && isString(a.id)) {
|
1234
1379
|
if (a.id === "")
|
1235
1380
|
throw new Error("The id can't be empty");
|
1236
|
-
const
|
1237
|
-
|
1238
|
-
return record;
|
1381
|
+
const columns = isStringArray(b) ? b : void 0;
|
1382
|
+
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1239
1383
|
}
|
1240
1384
|
if (isObject(a)) {
|
1241
|
-
const
|
1242
|
-
|
1243
|
-
return record;
|
1385
|
+
const columns = isStringArray(b) ? b : void 0;
|
1386
|
+
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
1244
1387
|
}
|
1245
1388
|
throw new Error("Invalid arguments for create method");
|
1246
1389
|
}
|
1247
|
-
async read(
|
1248
|
-
const
|
1249
|
-
if (
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
const
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
return
|
1259
|
-
}
|
1260
|
-
|
1261
|
-
|
1390
|
+
async read(a, b) {
|
1391
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1392
|
+
if (Array.isArray(a)) {
|
1393
|
+
if (a.length === 0)
|
1394
|
+
return [];
|
1395
|
+
const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
|
1396
|
+
const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
|
1397
|
+
const dictionary = finalObjects.reduce((acc, object) => {
|
1398
|
+
acc[object.id] = object;
|
1399
|
+
return acc;
|
1400
|
+
}, {});
|
1401
|
+
return ids.map((id2) => dictionary[id2] ?? null);
|
1402
|
+
}
|
1403
|
+
const id = isString(a) ? a : a.id;
|
1404
|
+
if (isString(id)) {
|
1405
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1406
|
+
try {
|
1407
|
+
const response = await getRecord({
|
1408
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
|
1409
|
+
queryParams: { columns },
|
1410
|
+
...fetchProps
|
1411
|
+
});
|
1412
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1413
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1414
|
+
} catch (e) {
|
1415
|
+
if (isObject(e) && e.status === 404) {
|
1416
|
+
return null;
|
1417
|
+
}
|
1418
|
+
throw e;
|
1262
1419
|
}
|
1263
|
-
throw e;
|
1264
1420
|
}
|
1421
|
+
return null;
|
1265
1422
|
}
|
1266
|
-
async update(a, b) {
|
1423
|
+
async update(a, b, c) {
|
1267
1424
|
if (Array.isArray(a)) {
|
1425
|
+
if (a.length === 0)
|
1426
|
+
return [];
|
1268
1427
|
if (a.length > 100) {
|
1269
1428
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1270
1429
|
}
|
1271
|
-
|
1430
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1431
|
+
return Promise.all(a.map((object) => this.update(object, columns)));
|
1272
1432
|
}
|
1273
1433
|
if (isString(a) && isObject(b)) {
|
1274
|
-
|
1275
|
-
|
1276
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1277
|
-
return record;
|
1434
|
+
const columns = isStringArray(c) ? c : void 0;
|
1435
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
|
1278
1436
|
}
|
1279
1437
|
if (isObject(a) && isString(a.id)) {
|
1280
|
-
|
1281
|
-
|
1282
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1283
|
-
return record;
|
1438
|
+
const columns = isStringArray(b) ? b : void 0;
|
1439
|
+
return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1284
1440
|
}
|
1285
1441
|
throw new Error("Invalid arguments for update method");
|
1286
1442
|
}
|
1287
|
-
async createOrUpdate(a, b) {
|
1443
|
+
async createOrUpdate(a, b, c) {
|
1288
1444
|
if (Array.isArray(a)) {
|
1445
|
+
if (a.length === 0)
|
1446
|
+
return [];
|
1289
1447
|
if (a.length > 100) {
|
1290
1448
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1291
1449
|
}
|
1292
|
-
|
1450
|
+
const columns = isStringArray(b) ? b : ["*"];
|
1451
|
+
return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
|
1293
1452
|
}
|
1294
1453
|
if (isString(a) && isObject(b)) {
|
1295
|
-
|
1296
|
-
|
1297
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1298
|
-
return record;
|
1454
|
+
const columns = isStringArray(c) ? c : void 0;
|
1455
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
|
1299
1456
|
}
|
1300
1457
|
if (isObject(a) && isString(a.id)) {
|
1301
|
-
|
1302
|
-
|
1303
|
-
await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
|
1304
|
-
return record;
|
1458
|
+
const columns = isStringArray(c) ? c : void 0;
|
1459
|
+
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
|
1305
1460
|
}
|
1306
1461
|
throw new Error("Invalid arguments for createOrUpdate method");
|
1307
1462
|
}
|
1308
1463
|
async delete(a) {
|
1309
1464
|
if (Array.isArray(a)) {
|
1465
|
+
if (a.length === 0)
|
1466
|
+
return;
|
1310
1467
|
if (a.length > 100) {
|
1311
1468
|
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1312
1469
|
}
|
@@ -1315,12 +1472,10 @@ class RestRepository extends Query {
|
|
1315
1472
|
}
|
1316
1473
|
if (isString(a)) {
|
1317
1474
|
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
|
1318
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
|
1319
1475
|
return;
|
1320
1476
|
}
|
1321
1477
|
if (isObject(a) && isString(a.id)) {
|
1322
1478
|
await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
|
1323
|
-
await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
|
1324
1479
|
return;
|
1325
1480
|
}
|
1326
1481
|
throw new Error("Invalid arguments for delete method");
|
@@ -1332,12 +1487,15 @@ class RestRepository extends Query {
|
|
1332
1487
|
body: {
|
1333
1488
|
query,
|
1334
1489
|
fuzziness: options.fuzziness,
|
1335
|
-
|
1490
|
+
prefix: options.prefix,
|
1491
|
+
highlight: options.highlight,
|
1492
|
+
filter: options.filter,
|
1493
|
+
boosters: options.boosters
|
1336
1494
|
},
|
1337
1495
|
...fetchProps
|
1338
1496
|
});
|
1339
|
-
const
|
1340
|
-
return records.map((item) => initObject(this
|
1497
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1498
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
1341
1499
|
}
|
1342
1500
|
async query(query) {
|
1343
1501
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
@@ -1356,18 +1514,19 @@ class RestRepository extends Query {
|
|
1356
1514
|
body,
|
1357
1515
|
...fetchProps
|
1358
1516
|
});
|
1359
|
-
const
|
1360
|
-
const records = objects.map((record) => initObject(this
|
1517
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1518
|
+
const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
|
1361
1519
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1362
1520
|
return new Page(query, meta, records);
|
1363
1521
|
}
|
1364
1522
|
}
|
1365
1523
|
_table = new WeakMap();
|
1366
1524
|
_getFetchProps = new WeakMap();
|
1525
|
+
_db = new WeakMap();
|
1367
1526
|
_cache = new WeakMap();
|
1368
|
-
|
1527
|
+
_schemaTables$2 = new WeakMap();
|
1369
1528
|
_insertRecordWithoutId = new WeakSet();
|
1370
|
-
insertRecordWithoutId_fn = async function(object) {
|
1529
|
+
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
1371
1530
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1372
1531
|
const record = transformObjectLinks(object);
|
1373
1532
|
const response = await insertRecord({
|
@@ -1376,17 +1535,15 @@ insertRecordWithoutId_fn = async function(object) {
|
|
1376
1535
|
dbBranchName: "{dbBranch}",
|
1377
1536
|
tableName: __privateGet$4(this, _table)
|
1378
1537
|
},
|
1538
|
+
queryParams: { columns },
|
1379
1539
|
body: record,
|
1380
1540
|
...fetchProps
|
1381
1541
|
});
|
1382
|
-
const
|
1383
|
-
|
1384
|
-
throw new Error("The server failed to save the record");
|
1385
|
-
}
|
1386
|
-
return finalObject;
|
1542
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1543
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1387
1544
|
};
|
1388
1545
|
_insertRecordWithId = new WeakSet();
|
1389
|
-
insertRecordWithId_fn = async function(recordId, object) {
|
1546
|
+
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
1390
1547
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1391
1548
|
const record = transformObjectLinks(object);
|
1392
1549
|
const response = await insertRecordWithID({
|
@@ -1397,56 +1554,52 @@ insertRecordWithId_fn = async function(recordId, object) {
|
|
1397
1554
|
recordId
|
1398
1555
|
},
|
1399
1556
|
body: record,
|
1400
|
-
queryParams: { createOnly: true },
|
1557
|
+
queryParams: { createOnly: true, columns },
|
1401
1558
|
...fetchProps
|
1402
1559
|
});
|
1403
|
-
const
|
1404
|
-
|
1405
|
-
throw new Error("The server failed to save the record");
|
1406
|
-
}
|
1407
|
-
return finalObject;
|
1560
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1561
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1408
1562
|
};
|
1409
1563
|
_bulkInsertTableRecords = new WeakSet();
|
1410
|
-
bulkInsertTableRecords_fn = async function(objects) {
|
1564
|
+
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
1411
1565
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1412
1566
|
const records = objects.map((object) => transformObjectLinks(object));
|
1413
1567
|
const response = await bulkInsertTableRecords({
|
1414
1568
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1569
|
+
queryParams: { columns },
|
1415
1570
|
body: { records },
|
1416
1571
|
...fetchProps
|
1417
1572
|
});
|
1418
|
-
|
1419
|
-
|
1420
|
-
throw new Error("The server failed to save some records");
|
1573
|
+
if (!isResponseWithRecords(response)) {
|
1574
|
+
throw new Error("Request included columns but server didn't include them");
|
1421
1575
|
}
|
1422
|
-
|
1576
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1577
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
1423
1578
|
};
|
1424
1579
|
_updateRecordWithID = new WeakSet();
|
1425
|
-
updateRecordWithID_fn = async function(recordId, object) {
|
1580
|
+
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1426
1581
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1427
1582
|
const record = transformObjectLinks(object);
|
1428
1583
|
const response = await updateRecordWithID({
|
1429
1584
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1585
|
+
queryParams: { columns },
|
1430
1586
|
body: record,
|
1431
1587
|
...fetchProps
|
1432
1588
|
});
|
1433
|
-
const
|
1434
|
-
|
1435
|
-
throw new Error("The server failed to save the record");
|
1436
|
-
return item;
|
1589
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1590
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1437
1591
|
};
|
1438
1592
|
_upsertRecordWithID = new WeakSet();
|
1439
|
-
upsertRecordWithID_fn = async function(recordId, object) {
|
1593
|
+
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
1440
1594
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1441
1595
|
const response = await upsertRecordWithID({
|
1442
1596
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1597
|
+
queryParams: { columns },
|
1443
1598
|
body: object,
|
1444
1599
|
...fetchProps
|
1445
1600
|
});
|
1446
|
-
const
|
1447
|
-
|
1448
|
-
throw new Error("The server failed to save the record");
|
1449
|
-
return item;
|
1601
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
1602
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
1450
1603
|
};
|
1451
1604
|
_deleteRecord = new WeakSet();
|
1452
1605
|
deleteRecord_fn = async function(recordId) {
|
@@ -1456,29 +1609,6 @@ deleteRecord_fn = async function(recordId) {
|
|
1456
1609
|
...fetchProps
|
1457
1610
|
});
|
1458
1611
|
};
|
1459
|
-
_invalidateCache = new WeakSet();
|
1460
|
-
invalidateCache_fn = async function(recordId) {
|
1461
|
-
await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1462
|
-
const cacheItems = await __privateGet$4(this, _cache).getAll();
|
1463
|
-
const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
|
1464
|
-
for (const [key, value] of queries) {
|
1465
|
-
const ids = getIds(value);
|
1466
|
-
if (ids.includes(recordId))
|
1467
|
-
await __privateGet$4(this, _cache).delete(key);
|
1468
|
-
}
|
1469
|
-
};
|
1470
|
-
_setCacheRecord = new WeakSet();
|
1471
|
-
setCacheRecord_fn = async function(record) {
|
1472
|
-
if (!__privateGet$4(this, _cache).cacheRecords)
|
1473
|
-
return;
|
1474
|
-
await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
|
1475
|
-
};
|
1476
|
-
_getCacheRecord = new WeakSet();
|
1477
|
-
getCacheRecord_fn = async function(recordId) {
|
1478
|
-
if (!__privateGet$4(this, _cache).cacheRecords)
|
1479
|
-
return null;
|
1480
|
-
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1481
|
-
};
|
1482
1612
|
_setCacheQuery = new WeakSet();
|
1483
1613
|
setCacheQuery_fn = async function(query, meta, records) {
|
1484
1614
|
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
@@ -1495,17 +1625,17 @@ getCacheQuery_fn = async function(query) {
|
|
1495
1625
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1496
1626
|
return hasExpired ? null : result;
|
1497
1627
|
};
|
1498
|
-
|
1499
|
-
|
1500
|
-
if (__privateGet$4(this,
|
1501
|
-
return __privateGet$4(this,
|
1628
|
+
_getSchemaTables$1 = new WeakSet();
|
1629
|
+
getSchemaTables_fn$1 = async function() {
|
1630
|
+
if (__privateGet$4(this, _schemaTables$2))
|
1631
|
+
return __privateGet$4(this, _schemaTables$2);
|
1502
1632
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1503
1633
|
const { schema } = await getBranchDetails({
|
1504
1634
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1505
1635
|
...fetchProps
|
1506
1636
|
});
|
1507
|
-
__privateSet$
|
1508
|
-
return schema;
|
1637
|
+
__privateSet$4(this, _schemaTables$2, schema.tables);
|
1638
|
+
return schema.tables;
|
1509
1639
|
};
|
1510
1640
|
const transformObjectLinks = (object) => {
|
1511
1641
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
@@ -1514,20 +1644,21 @@ const transformObjectLinks = (object) => {
|
|
1514
1644
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1515
1645
|
}, {});
|
1516
1646
|
};
|
1517
|
-
const initObject = (db,
|
1647
|
+
const initObject = (db, schemaTables, table, object) => {
|
1518
1648
|
const result = {};
|
1519
|
-
|
1520
|
-
|
1649
|
+
const { xata, ...rest } = object ?? {};
|
1650
|
+
Object.assign(result, rest);
|
1651
|
+
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
1521
1652
|
if (!columns)
|
1522
1653
|
console.error(`Table ${table} not found in schema`);
|
1523
1654
|
for (const column of columns ?? []) {
|
1524
1655
|
const value = result[column.name];
|
1525
1656
|
switch (column.type) {
|
1526
1657
|
case "datetime": {
|
1527
|
-
const date = new Date(value);
|
1528
|
-
if (isNaN(date.getTime())) {
|
1658
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
1659
|
+
if (date && isNaN(date.getTime())) {
|
1529
1660
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1530
|
-
} else {
|
1661
|
+
} else if (date) {
|
1531
1662
|
result[column.name] = date;
|
1532
1663
|
}
|
1533
1664
|
break;
|
@@ -1537,35 +1668,32 @@ const initObject = (db, schema, table, object) => {
|
|
1537
1668
|
if (!linkTable) {
|
1538
1669
|
console.error(`Failed to parse link for field ${column.name}`);
|
1539
1670
|
} else if (isObject(value)) {
|
1540
|
-
result[column.name] = initObject(db,
|
1671
|
+
result[column.name] = initObject(db, schemaTables, linkTable, value);
|
1541
1672
|
}
|
1542
1673
|
break;
|
1543
1674
|
}
|
1544
1675
|
}
|
1545
1676
|
}
|
1546
|
-
result.read = function() {
|
1547
|
-
return db[table].read(result["id"]);
|
1677
|
+
result.read = function(columns2) {
|
1678
|
+
return db[table].read(result["id"], columns2);
|
1548
1679
|
};
|
1549
|
-
result.update = function(data) {
|
1550
|
-
return db[table].update(result["id"], data);
|
1680
|
+
result.update = function(data, columns2) {
|
1681
|
+
return db[table].update(result["id"], data, columns2);
|
1551
1682
|
};
|
1552
1683
|
result.delete = function() {
|
1553
1684
|
return db[table].delete(result["id"]);
|
1554
1685
|
};
|
1555
|
-
|
1686
|
+
result.getMetadata = function() {
|
1687
|
+
return xata;
|
1688
|
+
};
|
1689
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1556
1690
|
Object.defineProperty(result, prop, { enumerable: false });
|
1557
1691
|
}
|
1558
1692
|
Object.freeze(result);
|
1559
1693
|
return result;
|
1560
1694
|
};
|
1561
|
-
function
|
1562
|
-
|
1563
|
-
return value.map((item) => getIds(item)).flat();
|
1564
|
-
}
|
1565
|
-
if (!isObject(value))
|
1566
|
-
return [];
|
1567
|
-
const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
|
1568
|
-
return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
|
1695
|
+
function isResponseWithRecords(value) {
|
1696
|
+
return isObject(value) && Array.isArray(value.records);
|
1569
1697
|
}
|
1570
1698
|
|
1571
1699
|
var __accessCheck$3 = (obj, member, msg) => {
|
@@ -1581,7 +1709,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1581
1709
|
throw TypeError("Cannot add the same private member more than once");
|
1582
1710
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1583
1711
|
};
|
1584
|
-
var __privateSet$
|
1712
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1585
1713
|
__accessCheck$3(obj, member, "write to private field");
|
1586
1714
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1587
1715
|
return value;
|
@@ -1590,9 +1718,8 @@ var _map;
|
|
1590
1718
|
class SimpleCache {
|
1591
1719
|
constructor(options = {}) {
|
1592
1720
|
__privateAdd$3(this, _map, void 0);
|
1593
|
-
__privateSet$
|
1721
|
+
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
1594
1722
|
this.capacity = options.max ?? 500;
|
1595
|
-
this.cacheRecords = options.cacheRecords ?? true;
|
1596
1723
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1597
1724
|
}
|
1598
1725
|
async getAll() {
|
@@ -1650,31 +1777,42 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1650
1777
|
throw TypeError("Cannot add the same private member more than once");
|
1651
1778
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1652
1779
|
};
|
1653
|
-
var
|
1780
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
1781
|
+
__accessCheck$2(obj, member, "write to private field");
|
1782
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1783
|
+
return value;
|
1784
|
+
};
|
1785
|
+
var _tables, _schemaTables$1;
|
1654
1786
|
class SchemaPlugin extends XataPlugin {
|
1655
|
-
constructor(
|
1787
|
+
constructor(schemaTables) {
|
1656
1788
|
super();
|
1657
|
-
this.tableNames = tableNames;
|
1658
1789
|
__privateAdd$2(this, _tables, {});
|
1790
|
+
__privateAdd$2(this, _schemaTables$1, void 0);
|
1791
|
+
__privateSet$2(this, _schemaTables$1, schemaTables);
|
1659
1792
|
}
|
1660
1793
|
build(pluginOptions) {
|
1661
|
-
const db = new Proxy(
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1794
|
+
const db = new Proxy(
|
1795
|
+
{},
|
1796
|
+
{
|
1797
|
+
get: (_target, table) => {
|
1798
|
+
if (!isString(table))
|
1799
|
+
throw new Error("Invalid table name");
|
1800
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1801
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1802
|
+
}
|
1803
|
+
return __privateGet$2(this, _tables)[table];
|
1667
1804
|
}
|
1668
|
-
return __privateGet$2(this, _tables)[table];
|
1669
1805
|
}
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1806
|
+
);
|
1807
|
+
const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
|
1808
|
+
for (const table of tableNames) {
|
1809
|
+
db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
|
1673
1810
|
}
|
1674
1811
|
return db;
|
1675
1812
|
}
|
1676
1813
|
}
|
1677
1814
|
_tables = new WeakMap();
|
1815
|
+
_schemaTables$1 = new WeakMap();
|
1678
1816
|
|
1679
1817
|
var __accessCheck$1 = (obj, member, msg) => {
|
1680
1818
|
if (!member.has(obj))
|
@@ -1698,82 +1836,77 @@ var __privateMethod$1 = (obj, member, method) => {
|
|
1698
1836
|
__accessCheck$1(obj, member, "access private method");
|
1699
1837
|
return method;
|
1700
1838
|
};
|
1701
|
-
var
|
1839
|
+
var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
|
1702
1840
|
class SearchPlugin extends XataPlugin {
|
1703
|
-
constructor(db) {
|
1841
|
+
constructor(db, schemaTables) {
|
1704
1842
|
super();
|
1705
1843
|
this.db = db;
|
1706
1844
|
__privateAdd$1(this, _search);
|
1707
|
-
__privateAdd$1(this,
|
1708
|
-
__privateAdd$1(this,
|
1845
|
+
__privateAdd$1(this, _getSchemaTables);
|
1846
|
+
__privateAdd$1(this, _schemaTables, void 0);
|
1847
|
+
__privateSet$1(this, _schemaTables, schemaTables);
|
1709
1848
|
}
|
1710
1849
|
build({ getFetchProps }) {
|
1711
1850
|
return {
|
1712
1851
|
all: async (query, options = {}) => {
|
1713
1852
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1714
|
-
const
|
1853
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1715
1854
|
return records.map((record) => {
|
1716
1855
|
const { table = "orphan" } = record.xata;
|
1717
|
-
return { table, record: initObject(this.db,
|
1856
|
+
return { table, record: initObject(this.db, schemaTables, table, record) };
|
1718
1857
|
});
|
1719
1858
|
},
|
1720
1859
|
byTable: async (query, options = {}) => {
|
1721
1860
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1722
|
-
const
|
1861
|
+
const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
|
1723
1862
|
return records.reduce((acc, record) => {
|
1724
1863
|
const { table = "orphan" } = record.xata;
|
1725
1864
|
const items = acc[table] ?? [];
|
1726
|
-
const item = initObject(this.db,
|
1865
|
+
const item = initObject(this.db, schemaTables, table, record);
|
1727
1866
|
return { ...acc, [table]: [...items, item] };
|
1728
1867
|
}, {});
|
1729
1868
|
}
|
1730
1869
|
};
|
1731
1870
|
}
|
1732
1871
|
}
|
1733
|
-
|
1872
|
+
_schemaTables = new WeakMap();
|
1734
1873
|
_search = new WeakSet();
|
1735
1874
|
search_fn = async function(query, options, getFetchProps) {
|
1736
1875
|
const fetchProps = await getFetchProps();
|
1737
|
-
const { tables, fuzziness } = options ?? {};
|
1876
|
+
const { tables, fuzziness, highlight, prefix } = options ?? {};
|
1738
1877
|
const { records } = await searchBranch({
|
1739
1878
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1740
|
-
body: { tables, query, fuzziness },
|
1879
|
+
body: { tables, query, fuzziness, prefix, highlight },
|
1741
1880
|
...fetchProps
|
1742
1881
|
});
|
1743
1882
|
return records;
|
1744
1883
|
};
|
1745
|
-
|
1746
|
-
|
1747
|
-
if (__privateGet$1(this,
|
1748
|
-
return __privateGet$1(this,
|
1884
|
+
_getSchemaTables = new WeakSet();
|
1885
|
+
getSchemaTables_fn = async function(getFetchProps) {
|
1886
|
+
if (__privateGet$1(this, _schemaTables))
|
1887
|
+
return __privateGet$1(this, _schemaTables);
|
1749
1888
|
const fetchProps = await getFetchProps();
|
1750
1889
|
const { schema } = await getBranchDetails({
|
1751
1890
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1752
1891
|
...fetchProps
|
1753
1892
|
});
|
1754
|
-
__privateSet$1(this,
|
1755
|
-
return schema;
|
1893
|
+
__privateSet$1(this, _schemaTables, schema.tables);
|
1894
|
+
return schema.tables;
|
1756
1895
|
};
|
1757
1896
|
|
1758
1897
|
const isBranchStrategyBuilder = (strategy) => {
|
1759
1898
|
return typeof strategy === "function";
|
1760
1899
|
};
|
1761
1900
|
|
1762
|
-
const envBranchNames = [
|
1763
|
-
"XATA_BRANCH",
|
1764
|
-
"VERCEL_GIT_COMMIT_REF",
|
1765
|
-
"CF_PAGES_BRANCH",
|
1766
|
-
"BRANCH"
|
1767
|
-
];
|
1768
1901
|
async function getCurrentBranchName(options) {
|
1769
|
-
const
|
1770
|
-
if (
|
1771
|
-
const details = await getDatabaseBranch(
|
1902
|
+
const { branch, envBranch } = getEnvironment();
|
1903
|
+
if (branch) {
|
1904
|
+
const details = await getDatabaseBranch(branch, options);
|
1772
1905
|
if (details)
|
1773
|
-
return
|
1774
|
-
console.warn(`Branch ${
|
1906
|
+
return branch;
|
1907
|
+
console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
|
1775
1908
|
}
|
1776
|
-
const gitBranch = await getGitBranch();
|
1909
|
+
const gitBranch = envBranch || await getGitBranch();
|
1777
1910
|
return resolveXataBranch(gitBranch, options);
|
1778
1911
|
}
|
1779
1912
|
async function getCurrentBranchDetails(options) {
|
@@ -1784,18 +1917,23 @@ async function resolveXataBranch(gitBranch, options) {
|
|
1784
1917
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1785
1918
|
const apiKey = options?.apiKey || getAPIKey();
|
1786
1919
|
if (!databaseURL)
|
1787
|
-
throw new Error(
|
1920
|
+
throw new Error(
|
1921
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
1922
|
+
);
|
1788
1923
|
if (!apiKey)
|
1789
|
-
throw new Error(
|
1924
|
+
throw new Error(
|
1925
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
1926
|
+
);
|
1790
1927
|
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1791
1928
|
const [workspace] = host.split(".");
|
1929
|
+
const { fallbackBranch } = getEnvironment();
|
1792
1930
|
const { branch } = await resolveBranch({
|
1793
1931
|
apiKey,
|
1794
1932
|
apiUrl: databaseURL,
|
1795
1933
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1796
1934
|
workspacesApiUrl: `${protocol}//${host}`,
|
1797
1935
|
pathParams: { dbName, workspace },
|
1798
|
-
queryParams: { gitBranch, fallbackBranch
|
1936
|
+
queryParams: { gitBranch, fallbackBranch }
|
1799
1937
|
});
|
1800
1938
|
return branch;
|
1801
1939
|
}
|
@@ -1803,9 +1941,13 @@ async function getDatabaseBranch(branch, options) {
|
|
1803
1941
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1804
1942
|
const apiKey = options?.apiKey || getAPIKey();
|
1805
1943
|
if (!databaseURL)
|
1806
|
-
throw new Error(
|
1944
|
+
throw new Error(
|
1945
|
+
"A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
|
1946
|
+
);
|
1807
1947
|
if (!apiKey)
|
1808
|
-
throw new Error(
|
1948
|
+
throw new Error(
|
1949
|
+
"An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
|
1950
|
+
);
|
1809
1951
|
const [protocol, , host, , database] = databaseURL.split("/");
|
1810
1952
|
const [workspace] = host.split(".");
|
1811
1953
|
const dbBranchName = `${database}:${branch}`;
|
@@ -1815,10 +1957,7 @@ async function getDatabaseBranch(branch, options) {
|
|
1815
1957
|
apiUrl: databaseURL,
|
1816
1958
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1817
1959
|
workspacesApiUrl: `${protocol}//${host}`,
|
1818
|
-
pathParams: {
|
1819
|
-
dbBranchName,
|
1820
|
-
workspace
|
1821
|
-
}
|
1960
|
+
pathParams: { dbBranchName, workspace }
|
1822
1961
|
});
|
1823
1962
|
} catch (err) {
|
1824
1963
|
if (isObject(err) && err.status === 404)
|
@@ -1826,21 +1965,10 @@ async function getDatabaseBranch(branch, options) {
|
|
1826
1965
|
throw err;
|
1827
1966
|
}
|
1828
1967
|
}
|
1829
|
-
function getBranchByEnvVariable() {
|
1830
|
-
for (const name of envBranchNames) {
|
1831
|
-
const value = getEnvVariable(name);
|
1832
|
-
if (value) {
|
1833
|
-
return value;
|
1834
|
-
}
|
1835
|
-
}
|
1836
|
-
try {
|
1837
|
-
return XATA_BRANCH;
|
1838
|
-
} catch (err) {
|
1839
|
-
}
|
1840
|
-
}
|
1841
1968
|
function getDatabaseURL() {
|
1842
1969
|
try {
|
1843
|
-
|
1970
|
+
const { databaseURL } = getEnvironment();
|
1971
|
+
return databaseURL;
|
1844
1972
|
} catch (err) {
|
1845
1973
|
return void 0;
|
1846
1974
|
}
|
@@ -1869,20 +1997,22 @@ var __privateMethod = (obj, member, method) => {
|
|
1869
1997
|
return method;
|
1870
1998
|
};
|
1871
1999
|
const buildClient = (plugins) => {
|
1872
|
-
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
2000
|
+
var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1873
2001
|
return _a = class {
|
1874
|
-
constructor(options = {},
|
2002
|
+
constructor(options = {}, schemaTables) {
|
1875
2003
|
__privateAdd(this, _parseOptions);
|
1876
2004
|
__privateAdd(this, _getFetchProps);
|
1877
2005
|
__privateAdd(this, _evaluateBranch);
|
1878
2006
|
__privateAdd(this, _branch, void 0);
|
2007
|
+
__privateAdd(this, _options, void 0);
|
1879
2008
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
2009
|
+
__privateSet(this, _options, safeOptions);
|
1880
2010
|
const pluginOptions = {
|
1881
2011
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1882
2012
|
cache: safeOptions.cache
|
1883
2013
|
};
|
1884
|
-
const db = new SchemaPlugin(
|
1885
|
-
const search = new SearchPlugin(db).build(pluginOptions);
|
2014
|
+
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
2015
|
+
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
1886
2016
|
this.db = db;
|
1887
2017
|
this.search = search;
|
1888
2018
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
@@ -1898,22 +2028,22 @@ const buildClient = (plugins) => {
|
|
1898
2028
|
}
|
1899
2029
|
}
|
1900
2030
|
}
|
1901
|
-
|
2031
|
+
async getConfig() {
|
2032
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
2033
|
+
const branch = await __privateGet(this, _options).branch();
|
2034
|
+
return { databaseURL, branch };
|
2035
|
+
}
|
2036
|
+
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
1902
2037
|
const fetch = getFetchImplementation(options?.fetch);
|
1903
2038
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1904
2039
|
const apiKey = options?.apiKey || getAPIKey();
|
1905
|
-
const cache = options?.cache ?? new SimpleCache({
|
2040
|
+
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
1906
2041
|
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1907
2042
|
if (!databaseURL || !apiKey) {
|
1908
2043
|
throw new Error("Options databaseURL and apiKey are required");
|
1909
2044
|
}
|
1910
2045
|
return { fetch, databaseURL, apiKey, branch, cache };
|
1911
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
1912
|
-
fetch,
|
1913
|
-
apiKey,
|
1914
|
-
databaseURL,
|
1915
|
-
branch
|
1916
|
-
}) {
|
2046
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch }) {
|
1917
2047
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
1918
2048
|
if (!branchValue)
|
1919
2049
|
throw new Error("Unable to resolve branch value");
|
@@ -1963,6 +2093,7 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
|
|
1963
2093
|
exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
1964
2094
|
exports.Page = Page;
|
1965
2095
|
exports.Query = Query;
|
2096
|
+
exports.RecordArray = RecordArray;
|
1966
2097
|
exports.Repository = Repository;
|
1967
2098
|
exports.RestRepository = RestRepository;
|
1968
2099
|
exports.SchemaPlugin = SchemaPlugin;
|
@@ -2052,6 +2183,7 @@ exports.updateRecordWithID = updateRecordWithID;
|
|
2052
2183
|
exports.updateTable = updateTable;
|
2053
2184
|
exports.updateUser = updateUser;
|
2054
2185
|
exports.updateWorkspace = updateWorkspace;
|
2186
|
+
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
2055
2187
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
2056
2188
|
exports.upsertRecordWithID = upsertRecordWithID;
|
2057
2189
|
//# sourceMappingURL=index.cjs.map
|