@xata.io/client 0.0.0-next.va2d8ec2a91aa05ba703071b545a477e727db67d6 → 0.0.0-next.vc4b43f48acaca8f0e2d23ace50c0f4683e20d720
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/.turbo/turbo-add-version.log +1 -1
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +11 -3
- package/dist/index.cjs +56 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +129 -12
- package/dist/index.mjs +54 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
|
2
|
-
> @xata.io/client@0.29.
|
2
|
+
> @xata.io/client@0.29.3 build /home/runner/work/client-ts/client-ts/packages/client
|
3
3
|
> rimraf dist && rollup -c
|
4
4
|
|
5
5
|
[36m
|
6
6
|
[1msrc/index.ts[22m → [1mdist/index.cjs[22m...[39m
|
7
|
-
[32mcreated [1mdist/index.cjs[22m in [
|
7
|
+
[32mcreated [1mdist/index.cjs[22m in [1m902ms[22m[39m
|
8
8
|
[36m
|
9
9
|
[1msrc/index.ts[22m → [1mdist/index.mjs[22m...[39m
|
10
|
-
[32mcreated [1mdist/index.mjs[22m in [
|
10
|
+
[32mcreated [1mdist/index.mjs[22m in [1m621ms[22m[39m
|
11
11
|
[36m
|
12
12
|
[1msrc/index.ts[22m → [1mdist/index.d.ts[22m...[39m
|
13
|
-
[32mcreated [1mdist/index.d.ts[22m in [1m4.
|
13
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m4.2s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
-
## 0.0.0-next.
|
3
|
+
## 0.0.0-next.vc4b43f48acaca8f0e2d23ace50c0f4683e20d720
|
4
4
|
|
5
5
|
### Major Changes
|
6
6
|
|
7
|
-
- [`
|
7
|
+
- [#1412](https://github.com/xataio/client-ts/pull/1412) [`e20389d`](https://github.com/xataio/client-ts/commit/e20389df9b07bd257e1d1d88839cc5c344c7783e) Thanks [@eemmiillyy](https://github.com/eemmiillyy)! - Make XataApiClient to use ES Proxies
|
8
8
|
|
9
|
-
- [`
|
9
|
+
- [#1412](https://github.com/xataio/client-ts/pull/1412) [`72a64e0`](https://github.com/xataio/client-ts/commit/72a64e0fe1fce956a48a6a5f22cc67419b107da3) Thanks [@eemmiillyy](https://github.com/eemmiillyy)! - Version 1.0
|
10
|
+
|
11
|
+
## 0.29.3
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- [#1399](https://github.com/xataio/client-ts/pull/1399) [`02053fb`](https://github.com/xataio/client-ts/commit/02053fbb10479b8e9453691f957d3235762555aa) Thanks [@SferaDev](https://github.com/SferaDev)! - Expose `xata.sql.connectionString` helper
|
16
|
+
|
17
|
+
- [#1398](https://github.com/xataio/client-ts/pull/1398) [`e27cb74`](https://github.com/xataio/client-ts/commit/e27cb74143aa9b6c654713878e5d3776858e5290) Thanks [@SferaDev](https://github.com/SferaDev)! - Add support for array response type
|
10
18
|
|
11
19
|
## 0.29.2
|
12
20
|
|
package/dist/index.cjs
CHANGED
@@ -528,7 +528,7 @@ function defaultOnOpen(response) {
|
|
528
528
|
}
|
529
529
|
}
|
530
530
|
|
531
|
-
const VERSION = "0.29.
|
531
|
+
const VERSION = "0.29.3";
|
532
532
|
|
533
533
|
class ErrorWithCause extends Error {
|
534
534
|
constructor(message, options) {
|
@@ -621,15 +621,15 @@ function parseWorkspacesUrlParts(url) {
|
|
621
621
|
if (!isString(url))
|
622
622
|
return null;
|
623
623
|
const matches = {
|
624
|
-
production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh
|
625
|
-
staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev
|
626
|
-
dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev
|
627
|
-
local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:(
|
624
|
+
production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh\/db\/([^:]+):?(.*)?/),
|
625
|
+
staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev\/db\/([^:]+):?(.*)?/),
|
626
|
+
dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev\/db\/([^:]+):?(.*)?/),
|
627
|
+
local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:([^:]+):?(.*)?/)
|
628
628
|
};
|
629
629
|
const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
|
630
630
|
if (!isHostProviderAlias(host) || !match)
|
631
631
|
return null;
|
632
|
-
return { workspace: match[1], region: match[2], host };
|
632
|
+
return { workspace: match[1], region: match[2], database: match[3], branch: match[4], host };
|
633
633
|
}
|
634
634
|
|
635
635
|
const pool = new ApiRequestPool();
|
@@ -856,6 +856,12 @@ const adaptTable = (variables, signal) => dataPlaneFetch({
|
|
856
856
|
...variables,
|
857
857
|
signal
|
858
858
|
});
|
859
|
+
const adaptAllTables = (variables, signal) => dataPlaneFetch({
|
860
|
+
url: "/db/{dbBranchName}/migrations/adapt",
|
861
|
+
method: "post",
|
862
|
+
...variables,
|
863
|
+
signal
|
864
|
+
});
|
859
865
|
const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/status", method: "get", ...variables, signal });
|
860
866
|
const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/jobs/{jobId}", method: "get", ...variables, signal });
|
861
867
|
const getMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/history", method: "get", ...variables, signal });
|
@@ -1088,6 +1094,7 @@ const operationsByTag$2 = {
|
|
1088
1094
|
migrations: {
|
1089
1095
|
applyMigration,
|
1090
1096
|
adaptTable,
|
1097
|
+
adaptAllTables,
|
1091
1098
|
getBranchMigrationJobStatus,
|
1092
1099
|
getMigrationJobStatus,
|
1093
1100
|
getMigrationHistory,
|
@@ -1259,6 +1266,8 @@ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1259
1266
|
...variables,
|
1260
1267
|
signal
|
1261
1268
|
});
|
1269
|
+
const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "get", ...variables, signal });
|
1270
|
+
const updateWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "patch", ...variables, signal });
|
1262
1271
|
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
1263
1272
|
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
1264
1273
|
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
@@ -1324,6 +1333,8 @@ const operationsByTag$1 = {
|
|
1324
1333
|
getWorkspace,
|
1325
1334
|
updateWorkspace,
|
1326
1335
|
deleteWorkspace,
|
1336
|
+
getWorkspaceSettings,
|
1337
|
+
updateWorkspaceSettings,
|
1327
1338
|
getWorkspaceMembersList,
|
1328
1339
|
updateWorkspaceMemberRole,
|
1329
1340
|
removeWorkspaceMember
|
@@ -3195,19 +3206,19 @@ function prepareParams(param1, param2) {
|
|
3195
3206
|
return { statement, params: param2?.map((value) => prepareValue(value)) };
|
3196
3207
|
}
|
3197
3208
|
if (isObject(param1)) {
|
3198
|
-
const { statement, params, consistency } = param1;
|
3199
|
-
return { statement, params: params?.map((value) => prepareValue(value)), consistency };
|
3209
|
+
const { statement, params, consistency, responseType } = param1;
|
3210
|
+
return { statement, params: params?.map((value) => prepareValue(value)), consistency, responseType };
|
3200
3211
|
}
|
3201
3212
|
throw new Error("Invalid query");
|
3202
3213
|
}
|
3203
3214
|
|
3204
3215
|
class SQLPlugin extends XataPlugin {
|
3205
3216
|
build(pluginOptions) {
|
3206
|
-
|
3217
|
+
const sqlFunction = async (query, ...parameters) => {
|
3207
3218
|
if (!isParamsObject(query) && (!isTemplateStringsArray(query) || !Array.isArray(parameters))) {
|
3208
3219
|
throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
|
3209
3220
|
}
|
3210
|
-
const { statement, params, consistency } = prepareParams(query, parameters);
|
3221
|
+
const { statement, params, consistency, responseType } = prepareParams(query, parameters);
|
3211
3222
|
const {
|
3212
3223
|
records,
|
3213
3224
|
rows,
|
@@ -3215,11 +3226,13 @@ class SQLPlugin extends XataPlugin {
|
|
3215
3226
|
columns = []
|
3216
3227
|
} = await sqlQuery({
|
3217
3228
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3218
|
-
body: { statement, params, consistency },
|
3229
|
+
body: { statement, params, consistency, responseType },
|
3219
3230
|
...pluginOptions
|
3220
3231
|
});
|
3221
3232
|
return { records, rows, warning, columns };
|
3222
3233
|
};
|
3234
|
+
sqlFunction.connectionString = buildConnectionString(pluginOptions);
|
3235
|
+
return sqlFunction;
|
3223
3236
|
}
|
3224
3237
|
}
|
3225
3238
|
function isTemplateStringsArray(strings) {
|
@@ -3228,6 +3241,33 @@ function isTemplateStringsArray(strings) {
|
|
3228
3241
|
function isParamsObject(params) {
|
3229
3242
|
return isObject(params) && "statement" in params;
|
3230
3243
|
}
|
3244
|
+
function buildDomain(host, region) {
|
3245
|
+
switch (host) {
|
3246
|
+
case "production":
|
3247
|
+
return `${region}.sql.xata.sh`;
|
3248
|
+
case "staging":
|
3249
|
+
return `${region}.sql.staging-xata.dev`;
|
3250
|
+
case "dev":
|
3251
|
+
return `${region}.sql.dev-xata.dev`;
|
3252
|
+
case "local":
|
3253
|
+
return "localhost:7654";
|
3254
|
+
default:
|
3255
|
+
throw new Error("Invalid host provider");
|
3256
|
+
}
|
3257
|
+
}
|
3258
|
+
function buildConnectionString({ apiKey, workspacesApiUrl, branch }) {
|
3259
|
+
const url = isString(workspacesApiUrl) ? workspacesApiUrl : workspacesApiUrl("", {});
|
3260
|
+
const parts = parseWorkspacesUrlParts(url);
|
3261
|
+
if (!parts)
|
3262
|
+
throw new Error("Invalid workspaces URL");
|
3263
|
+
const { workspace: workspaceSlug, region, database, host } = parts;
|
3264
|
+
const domain = buildDomain(host, region);
|
3265
|
+
const workspace = workspaceSlug.split("-").pop();
|
3266
|
+
if (!workspace || !region || !database || !apiKey || !branch) {
|
3267
|
+
throw new Error("Unable to build xata connection string");
|
3268
|
+
}
|
3269
|
+
return `postgresql://${workspace}:${apiKey}@${domain}/${database}:${branch}?sslmode=require`;
|
3270
|
+
}
|
3231
3271
|
|
3232
3272
|
class TransactionPlugin extends XataPlugin {
|
3233
3273
|
build(pluginOptions) {
|
@@ -3278,7 +3318,8 @@ const buildClient = (plugins) => {
|
|
3278
3318
|
const pluginOptions = {
|
3279
3319
|
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
3280
3320
|
host: safeOptions.host,
|
3281
|
-
tables
|
3321
|
+
tables,
|
3322
|
+
branch: safeOptions.branch
|
3282
3323
|
};
|
3283
3324
|
const db = new SchemaPlugin().build(pluginOptions);
|
3284
3325
|
const search = new SearchPlugin(db).build(pluginOptions);
|
@@ -3485,6 +3526,7 @@ exports.XataError = XataError;
|
|
3485
3526
|
exports.XataFile = XataFile;
|
3486
3527
|
exports.XataPlugin = XataPlugin;
|
3487
3528
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
3529
|
+
exports.adaptAllTables = adaptAllTables;
|
3488
3530
|
exports.adaptTable = adaptTable;
|
3489
3531
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
3490
3532
|
exports.addTableColumn = addTableColumn;
|
@@ -3569,6 +3611,7 @@ exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
|
|
3569
3611
|
exports.getUserOAuthClients = getUserOAuthClients;
|
3570
3612
|
exports.getWorkspace = getWorkspace;
|
3571
3613
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
3614
|
+
exports.getWorkspaceSettings = getWorkspaceSettings;
|
3572
3615
|
exports.getWorkspacesList = getWorkspacesList;
|
3573
3616
|
exports.grantAuthorizationCode = grantAuthorizationCode;
|
3574
3617
|
exports.greaterEquals = greaterEquals;
|
@@ -3642,6 +3685,7 @@ exports.updateUser = updateUser;
|
|
3642
3685
|
exports.updateWorkspace = updateWorkspace;
|
3643
3686
|
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
3644
3687
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
3688
|
+
exports.updateWorkspaceSettings = updateWorkspaceSettings;
|
3645
3689
|
exports.upsertRecordWithID = upsertRecordWithID;
|
3646
3690
|
exports.vectorSearchTable = vectorSearchTable;
|
3647
3691
|
//# sourceMappingURL=index.cjs.map
|