@xata.io/client 0.29.2 → 0.29.3
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 +8 -0
- package/dist/index.cjs +48 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +89 -5
- package/dist/index.mjs +47 -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 [1m1s[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 [1m671ms[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 [
|
13
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m5s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.29.3
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#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
|
8
|
+
|
9
|
+
- [#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
|
+
|
3
11
|
## 0.29.2
|
4
12
|
|
5
13
|
### Patch Changes
|
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();
|
@@ -1257,6 +1257,8 @@ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
|
1257
1257
|
...variables,
|
1258
1258
|
signal
|
1259
1259
|
});
|
1260
|
+
const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "get", ...variables, signal });
|
1261
|
+
const updateWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "patch", ...variables, signal });
|
1260
1262
|
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
|
1261
1263
|
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
|
1262
1264
|
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
@@ -1322,6 +1324,8 @@ const operationsByTag$1 = {
|
|
1322
1324
|
getWorkspace,
|
1323
1325
|
updateWorkspace,
|
1324
1326
|
deleteWorkspace,
|
1327
|
+
getWorkspaceSettings,
|
1328
|
+
updateWorkspaceSettings,
|
1325
1329
|
getWorkspaceMembersList,
|
1326
1330
|
updateWorkspaceMemberRole,
|
1327
1331
|
removeWorkspaceMember
|
@@ -4589,19 +4593,19 @@ function prepareParams(param1, param2) {
|
|
4589
4593
|
return { statement, params: param2?.map((value) => prepareValue(value)) };
|
4590
4594
|
}
|
4591
4595
|
if (isObject(param1)) {
|
4592
|
-
const { statement, params, consistency } = param1;
|
4593
|
-
return { statement, params: params?.map((value) => prepareValue(value)), consistency };
|
4596
|
+
const { statement, params, consistency, responseType } = param1;
|
4597
|
+
return { statement, params: params?.map((value) => prepareValue(value)), consistency, responseType };
|
4594
4598
|
}
|
4595
4599
|
throw new Error("Invalid query");
|
4596
4600
|
}
|
4597
4601
|
|
4598
4602
|
class SQLPlugin extends XataPlugin {
|
4599
4603
|
build(pluginOptions) {
|
4600
|
-
|
4604
|
+
const sqlFunction = async (query, ...parameters) => {
|
4601
4605
|
if (!isParamsObject(query) && (!isTemplateStringsArray(query) || !Array.isArray(parameters))) {
|
4602
4606
|
throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
|
4603
4607
|
}
|
4604
|
-
const { statement, params, consistency } = prepareParams(query, parameters);
|
4608
|
+
const { statement, params, consistency, responseType } = prepareParams(query, parameters);
|
4605
4609
|
const {
|
4606
4610
|
records,
|
4607
4611
|
rows,
|
@@ -4609,11 +4613,13 @@ class SQLPlugin extends XataPlugin {
|
|
4609
4613
|
columns = []
|
4610
4614
|
} = await sqlQuery({
|
4611
4615
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4612
|
-
body: { statement, params, consistency },
|
4616
|
+
body: { statement, params, consistency, responseType },
|
4613
4617
|
...pluginOptions
|
4614
4618
|
});
|
4615
4619
|
return { records, rows, warning, columns };
|
4616
4620
|
};
|
4621
|
+
sqlFunction.connectionString = buildConnectionString(pluginOptions);
|
4622
|
+
return sqlFunction;
|
4617
4623
|
}
|
4618
4624
|
}
|
4619
4625
|
function isTemplateStringsArray(strings) {
|
@@ -4622,6 +4628,33 @@ function isTemplateStringsArray(strings) {
|
|
4622
4628
|
function isParamsObject(params) {
|
4623
4629
|
return isObject(params) && "statement" in params;
|
4624
4630
|
}
|
4631
|
+
function buildDomain(host, region) {
|
4632
|
+
switch (host) {
|
4633
|
+
case "production":
|
4634
|
+
return `${region}.sql.xata.sh`;
|
4635
|
+
case "staging":
|
4636
|
+
return `${region}.sql.staging-xata.dev`;
|
4637
|
+
case "dev":
|
4638
|
+
return `${region}.sql.dev-xata.dev`;
|
4639
|
+
case "local":
|
4640
|
+
return "localhost:7654";
|
4641
|
+
default:
|
4642
|
+
throw new Error("Invalid host provider");
|
4643
|
+
}
|
4644
|
+
}
|
4645
|
+
function buildConnectionString({ apiKey, workspacesApiUrl, branch }) {
|
4646
|
+
const url = isString(workspacesApiUrl) ? workspacesApiUrl : workspacesApiUrl("", {});
|
4647
|
+
const parts = parseWorkspacesUrlParts(url);
|
4648
|
+
if (!parts)
|
4649
|
+
throw new Error("Invalid workspaces URL");
|
4650
|
+
const { workspace: workspaceSlug, region, database, host } = parts;
|
4651
|
+
const domain = buildDomain(host, region);
|
4652
|
+
const workspace = workspaceSlug.split("-").pop();
|
4653
|
+
if (!workspace || !region || !database || !apiKey || !branch) {
|
4654
|
+
throw new Error("Unable to build xata connection string");
|
4655
|
+
}
|
4656
|
+
return `postgresql://${workspace}:${apiKey}@${domain}/${database}:${branch}?sslmode=require`;
|
4657
|
+
}
|
4625
4658
|
|
4626
4659
|
class TransactionPlugin extends XataPlugin {
|
4627
4660
|
build(pluginOptions) {
|
@@ -4673,7 +4706,8 @@ const buildClient = (plugins) => {
|
|
4673
4706
|
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
4674
4707
|
cache: safeOptions.cache,
|
4675
4708
|
host: safeOptions.host,
|
4676
|
-
tables
|
4709
|
+
tables,
|
4710
|
+
branch: safeOptions.branch
|
4677
4711
|
};
|
4678
4712
|
const db = new SchemaPlugin().build(pluginOptions);
|
4679
4713
|
const search = new SearchPlugin(db).build(pluginOptions);
|
@@ -4967,6 +5001,7 @@ exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
|
|
4967
5001
|
exports.getUserOAuthClients = getUserOAuthClients;
|
4968
5002
|
exports.getWorkspace = getWorkspace;
|
4969
5003
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
5004
|
+
exports.getWorkspaceSettings = getWorkspaceSettings;
|
4970
5005
|
exports.getWorkspacesList = getWorkspacesList;
|
4971
5006
|
exports.grantAuthorizationCode = grantAuthorizationCode;
|
4972
5007
|
exports.greaterEquals = greaterEquals;
|
@@ -5041,6 +5076,7 @@ exports.updateUser = updateUser;
|
|
5041
5076
|
exports.updateWorkspace = updateWorkspace;
|
5042
5077
|
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
5043
5078
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
5079
|
+
exports.updateWorkspaceSettings = updateWorkspaceSettings;
|
5044
5080
|
exports.upsertRecordWithID = upsertRecordWithID;
|
5045
5081
|
exports.vectorSearchTable = vectorSearchTable;
|
5046
5082
|
//# sourceMappingURL=index.cjs.map
|