@xata.io/client 0.22.4 → 0.23.1
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 +12 -0
- package/dist/index.cjs +45 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +76 -20
- package/dist/index.mjs +44 -36
- 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.
|
2
|
+
> @xata.io/client@0.23.1 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 [1m1.
|
7
|
+
[32mcreated [1mdist/index.cjs[22m in [1m1.2s[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 [1m865ms[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 [1m5.6s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.23.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#941](https://github.com/xataio/client-ts/pull/941) [`3026d708`](https://github.com/xataio/client-ts/commit/3026d70847830fd0f2024413d823380ff323806c) Thanks [@SferaDev](https://github.com/SferaDev)! - Expose records in ask SSE
|
8
|
+
|
9
|
+
## 0.23.0
|
10
|
+
|
11
|
+
### Minor Changes
|
12
|
+
|
13
|
+
- [#867](https://github.com/xataio/client-ts/pull/867) [`5838113f`](https://github.com/xataio/client-ts/commit/5838113fca042163b44d7cc7cc1686d5ef89b302) Thanks [@SferaDev](https://github.com/SferaDev)! - [Workflow] Remove fallback branch
|
14
|
+
|
3
15
|
## 0.22.4
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
@@ -93,8 +93,7 @@ function getEnvironment() {
|
|
93
93
|
apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
|
94
94
|
databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
|
95
95
|
branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
|
96
|
-
envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH
|
97
|
-
fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
|
96
|
+
envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH
|
98
97
|
};
|
99
98
|
}
|
100
99
|
} catch (err) {
|
@@ -105,8 +104,7 @@ function getEnvironment() {
|
|
105
104
|
apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
|
106
105
|
databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
|
107
106
|
branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
|
108
|
-
envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH")
|
109
|
-
fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
|
107
|
+
envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH")
|
110
108
|
};
|
111
109
|
}
|
112
110
|
} catch (err) {
|
@@ -115,8 +113,7 @@ function getEnvironment() {
|
|
115
113
|
apiKey: getGlobalApiKey(),
|
116
114
|
databaseURL: getGlobalDatabaseURL(),
|
117
115
|
branch: getGlobalBranch(),
|
118
|
-
envBranch: void 0
|
119
|
-
fallbackBranch: getGlobalFallbackBranch()
|
116
|
+
envBranch: void 0
|
120
117
|
};
|
121
118
|
}
|
122
119
|
function getEnableBrowserVariable() {
|
@@ -159,13 +156,6 @@ function getGlobalBranch() {
|
|
159
156
|
return void 0;
|
160
157
|
}
|
161
158
|
}
|
162
|
-
function getGlobalFallbackBranch() {
|
163
|
-
try {
|
164
|
-
return XATA_FALLBACK_BRANCH;
|
165
|
-
} catch (err) {
|
166
|
-
return void 0;
|
167
|
-
}
|
168
|
-
}
|
169
159
|
function getDatabaseURL() {
|
170
160
|
try {
|
171
161
|
const { databaseURL } = getEnvironment();
|
@@ -174,19 +164,18 @@ function getDatabaseURL() {
|
|
174
164
|
return void 0;
|
175
165
|
}
|
176
166
|
}
|
177
|
-
function
|
167
|
+
function getAPIKey() {
|
178
168
|
try {
|
179
|
-
const {
|
180
|
-
return
|
169
|
+
const { apiKey } = getEnvironment();
|
170
|
+
return apiKey;
|
181
171
|
} catch (err) {
|
182
172
|
return void 0;
|
183
173
|
}
|
184
174
|
}
|
185
|
-
|
186
|
-
function getAPIKey() {
|
175
|
+
function getBranch() {
|
187
176
|
try {
|
188
|
-
const {
|
189
|
-
return
|
177
|
+
const { branch, envBranch } = getEnvironment();
|
178
|
+
return branch ?? envBranch;
|
190
179
|
} catch (err) {
|
191
180
|
return void 0;
|
192
181
|
}
|
@@ -472,7 +461,7 @@ function defaultOnOpen(response) {
|
|
472
461
|
}
|
473
462
|
}
|
474
463
|
|
475
|
-
const VERSION = "0.
|
464
|
+
const VERSION = "0.23.1";
|
476
465
|
|
477
466
|
class ErrorWithCause extends Error {
|
478
467
|
constructor(message, options) {
|
@@ -769,6 +758,7 @@ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{
|
|
769
758
|
const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
|
770
759
|
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
|
771
760
|
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
|
761
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
|
772
762
|
const createTable = (variables, signal) => dataPlaneFetch({
|
773
763
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
774
764
|
method: "put",
|
@@ -875,7 +865,8 @@ const operationsByTag$2 = {
|
|
875
865
|
compareBranchSchemas,
|
876
866
|
updateBranchSchema,
|
877
867
|
previewBranchSchemaEdit,
|
878
|
-
applyBranchSchemaEdit
|
868
|
+
applyBranchSchemaEdit,
|
869
|
+
pushBranchMigrations
|
879
870
|
},
|
880
871
|
migrationRequests: {
|
881
872
|
queryMigrationRequests,
|
@@ -1076,6 +1067,10 @@ const providers = {
|
|
1076
1067
|
staging: {
|
1077
1068
|
main: "https://api.staging-xata.dev",
|
1078
1069
|
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
1070
|
+
},
|
1071
|
+
dev: {
|
1072
|
+
main: "https://api.dev-xata.dev",
|
1073
|
+
workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
|
1079
1074
|
}
|
1080
1075
|
};
|
1081
1076
|
function isHostProviderAlias(alias) {
|
@@ -1093,6 +1088,11 @@ function parseProviderString(provider = "production") {
|
|
1093
1088
|
return null;
|
1094
1089
|
return { main, workspaces };
|
1095
1090
|
}
|
1091
|
+
function buildProviderString(provider) {
|
1092
|
+
if (isHostProviderAlias(provider))
|
1093
|
+
return provider;
|
1094
|
+
return `${provider.main},${provider.workspaces}`;
|
1095
|
+
}
|
1096
1096
|
function parseWorkspacesUrlParts(url) {
|
1097
1097
|
if (!isString(url))
|
1098
1098
|
return null;
|
@@ -2129,6 +2129,19 @@ class MigrationsApi {
|
|
2129
2129
|
...this.extraProps
|
2130
2130
|
});
|
2131
2131
|
}
|
2132
|
+
pushBranchMigrations({
|
2133
|
+
workspace,
|
2134
|
+
region,
|
2135
|
+
database,
|
2136
|
+
branch,
|
2137
|
+
migrations
|
2138
|
+
}) {
|
2139
|
+
return operationsByTag.migrations.pushBranchMigrations({
|
2140
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
2141
|
+
body: { migrations },
|
2142
|
+
...this.extraProps
|
2143
|
+
});
|
2144
|
+
}
|
2132
2145
|
}
|
2133
2146
|
class DatabaseApi {
|
2134
2147
|
constructor(extraProps) {
|
@@ -3013,7 +3026,7 @@ class RestRepository extends Query {
|
|
3013
3026
|
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
3014
3027
|
method: "POST",
|
3015
3028
|
onMessage: (message) => {
|
3016
|
-
options.onMessage?.({ answer: message.text });
|
3029
|
+
options.onMessage?.({ answer: message.text, records: message.records });
|
3017
3030
|
},
|
3018
3031
|
...params
|
3019
3032
|
});
|
@@ -3206,15 +3219,16 @@ deleteRecords_fn = async function(recordIds) {
|
|
3206
3219
|
};
|
3207
3220
|
_setCacheQuery = new WeakSet();
|
3208
3221
|
setCacheQuery_fn = async function(query, meta, records) {
|
3209
|
-
await __privateGet$4(this, _cache)
|
3222
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
3210
3223
|
};
|
3211
3224
|
_getCacheQuery = new WeakSet();
|
3212
3225
|
getCacheQuery_fn = async function(query) {
|
3213
3226
|
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
3214
|
-
const result = await __privateGet$4(this, _cache)
|
3227
|
+
const result = await __privateGet$4(this, _cache)?.get(key);
|
3215
3228
|
if (!result)
|
3216
3229
|
return null;
|
3217
|
-
const
|
3230
|
+
const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
|
3231
|
+
const { cache: ttl = defaultTTL } = query.getQueryOptions();
|
3218
3232
|
if (ttl < 0)
|
3219
3233
|
return null;
|
3220
3234
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
@@ -3596,7 +3610,8 @@ const buildClient = (plugins) => {
|
|
3596
3610
|
__privateSet(this, _options, safeOptions);
|
3597
3611
|
const pluginOptions = {
|
3598
3612
|
...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
3599
|
-
cache: safeOptions.cache
|
3613
|
+
cache: safeOptions.cache,
|
3614
|
+
host: safeOptions.host
|
3600
3615
|
};
|
3601
3616
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
3602
3617
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
@@ -3607,14 +3622,7 @@ const buildClient = (plugins) => {
|
|
3607
3622
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
3608
3623
|
if (namespace === void 0)
|
3609
3624
|
continue;
|
3610
|
-
|
3611
|
-
if (result instanceof Promise) {
|
3612
|
-
void result.then((namespace2) => {
|
3613
|
-
this[key] = namespace2;
|
3614
|
-
});
|
3615
|
-
} else {
|
3616
|
-
this[key] = result;
|
3617
|
-
}
|
3625
|
+
this[key] = namespace.build(pluginOptions);
|
3618
3626
|
}
|
3619
3627
|
}
|
3620
3628
|
async getConfig() {
|
@@ -3804,6 +3812,7 @@ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
|
3804
3812
|
exports.askTable = askTable;
|
3805
3813
|
exports.branchTransaction = branchTransaction;
|
3806
3814
|
exports.buildClient = buildClient;
|
3815
|
+
exports.buildProviderString = buildProviderString;
|
3807
3816
|
exports.buildWorkerRunner = buildWorkerRunner;
|
3808
3817
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
3809
3818
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
@@ -3893,6 +3902,7 @@ exports.parseProviderString = parseProviderString;
|
|
3893
3902
|
exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
|
3894
3903
|
exports.pattern = pattern;
|
3895
3904
|
exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
|
3905
|
+
exports.pushBranchMigrations = pushBranchMigrations;
|
3896
3906
|
exports.queryMigrationRequests = queryMigrationRequests;
|
3897
3907
|
exports.queryTable = queryTable;
|
3898
3908
|
exports.removeGitBranchesEntry = removeGitBranchesEntry;
|