@xata.io/client 0.21.6 → 0.22.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/.eslintrc.cjs +2 -1
- package/.turbo/turbo-add-version.log +4 -0
- package/.turbo/turbo-build.log +13 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE +201 -0
- package/README.md +3 -269
- package/dist/index.cjs +98 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1042 -883
- package/dist/index.mjs +96 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/Usage.md +0 -451
package/dist/index.mjs
CHANGED
@@ -299,7 +299,7 @@ function generateUUID() {
|
|
299
299
|
});
|
300
300
|
}
|
301
301
|
|
302
|
-
const VERSION = "0.
|
302
|
+
const VERSION = "0.22.1";
|
303
303
|
|
304
304
|
class ErrorWithCause extends Error {
|
305
305
|
constructor(message, options) {
|
@@ -393,12 +393,13 @@ async function fetch$1({
|
|
393
393
|
clientID,
|
394
394
|
sessionID,
|
395
395
|
clientName,
|
396
|
+
xataAgentExtra,
|
396
397
|
fetchOptions = {}
|
397
398
|
}) {
|
398
399
|
pool.setFetch(fetchImpl);
|
399
400
|
return await trace(
|
400
401
|
`${method.toUpperCase()} ${path}`,
|
401
|
-
async ({
|
402
|
+
async ({ setAttributes }) => {
|
402
403
|
const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
|
403
404
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
404
405
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
@@ -409,7 +410,8 @@ async function fetch$1({
|
|
409
410
|
const xataAgent = compact([
|
410
411
|
["client", "TS_SDK"],
|
411
412
|
["version", VERSION],
|
412
|
-
isDefined(clientName) ? ["service", clientName] : void 0
|
413
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
414
|
+
...Object.entries(xataAgentExtra ?? {})
|
413
415
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
414
416
|
const headers = {
|
415
417
|
"Accept-Encoding": "identity",
|
@@ -511,7 +513,6 @@ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName
|
|
511
513
|
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
|
512
514
|
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
|
513
515
|
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
|
514
|
-
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
515
516
|
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
|
516
517
|
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
517
518
|
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
@@ -578,6 +579,7 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
578
579
|
...variables,
|
579
580
|
signal
|
580
581
|
});
|
582
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
581
583
|
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
582
584
|
const getRecord = (variables, signal) => dataPlaneFetch({
|
583
585
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
@@ -635,16 +637,6 @@ const operationsByTag$2 = {
|
|
635
637
|
previewBranchSchemaEdit,
|
636
638
|
applyBranchSchemaEdit
|
637
639
|
},
|
638
|
-
records: {
|
639
|
-
branchTransaction,
|
640
|
-
insertRecord,
|
641
|
-
getRecord,
|
642
|
-
insertRecordWithID,
|
643
|
-
updateRecordWithID,
|
644
|
-
upsertRecordWithID,
|
645
|
-
deleteRecord,
|
646
|
-
bulkInsertTableRecords
|
647
|
-
},
|
648
640
|
migrationRequests: {
|
649
641
|
queryMigrationRequests,
|
650
642
|
createMigrationRequest,
|
@@ -667,6 +659,16 @@ const operationsByTag$2 = {
|
|
667
659
|
updateColumn,
|
668
660
|
deleteColumn
|
669
661
|
},
|
662
|
+
records: {
|
663
|
+
branchTransaction,
|
664
|
+
insertRecord,
|
665
|
+
getRecord,
|
666
|
+
insertRecordWithID,
|
667
|
+
updateRecordWithID,
|
668
|
+
upsertRecordWithID,
|
669
|
+
deleteRecord,
|
670
|
+
bulkInsertTableRecords
|
671
|
+
},
|
670
672
|
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
671
673
|
};
|
672
674
|
|
@@ -766,6 +768,9 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
766
768
|
});
|
767
769
|
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
768
770
|
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
771
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
772
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
773
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
769
774
|
const listRegions = (variables, signal) => controlPlaneFetch({
|
770
775
|
url: "/workspaces/{workspaceId}/regions",
|
771
776
|
method: "get",
|
@@ -798,6 +803,9 @@ const operationsByTag$1 = {
|
|
798
803
|
deleteDatabase,
|
799
804
|
getDatabaseMetadata,
|
800
805
|
updateDatabaseMetadata,
|
806
|
+
getDatabaseGithubSettings,
|
807
|
+
updateDatabaseGithubSettings,
|
808
|
+
deleteDatabaseGithubSettings,
|
801
809
|
listRegions
|
802
810
|
}
|
803
811
|
};
|
@@ -842,7 +850,8 @@ function parseWorkspacesUrlParts(url) {
|
|
842
850
|
return null;
|
843
851
|
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
844
852
|
const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
|
845
|
-
const
|
853
|
+
const regexDev = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xata\.tech.*/;
|
854
|
+
const match = url.match(regex) || url.match(regexStaging) || url.match(regexDev);
|
846
855
|
if (!match)
|
847
856
|
return null;
|
848
857
|
return { workspace: match[1], region: match[2] };
|
@@ -885,6 +894,7 @@ class XataApiClient {
|
|
885
894
|
apiKey,
|
886
895
|
trace,
|
887
896
|
clientName: options.clientName,
|
897
|
+
xataAgentExtra: options.xataAgentExtra,
|
888
898
|
clientID
|
889
899
|
});
|
890
900
|
}
|
@@ -1760,11 +1770,13 @@ class MigrationsApi {
|
|
1760
1770
|
region,
|
1761
1771
|
database,
|
1762
1772
|
branch,
|
1763
|
-
schema
|
1773
|
+
schema,
|
1774
|
+
schemaOperations,
|
1775
|
+
branchOperations
|
1764
1776
|
}) {
|
1765
1777
|
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1766
1778
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1767
|
-
body: { schema },
|
1779
|
+
body: { schema, schemaOperations, branchOperations },
|
1768
1780
|
...this.extraProps
|
1769
1781
|
});
|
1770
1782
|
}
|
@@ -1774,11 +1786,12 @@ class MigrationsApi {
|
|
1774
1786
|
database,
|
1775
1787
|
branch,
|
1776
1788
|
compare,
|
1777
|
-
|
1789
|
+
sourceBranchOperations,
|
1790
|
+
targetBranchOperations
|
1778
1791
|
}) {
|
1779
1792
|
return operationsByTag.migrations.compareBranchSchemas({
|
1780
1793
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1781
|
-
body: {
|
1794
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
1782
1795
|
...this.extraProps
|
1783
1796
|
});
|
1784
1797
|
}
|
@@ -1872,6 +1885,35 @@ class DatabaseApi {
|
|
1872
1885
|
...this.extraProps
|
1873
1886
|
});
|
1874
1887
|
}
|
1888
|
+
getDatabaseGithubSettings({
|
1889
|
+
workspace,
|
1890
|
+
database
|
1891
|
+
}) {
|
1892
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
1893
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1894
|
+
...this.extraProps
|
1895
|
+
});
|
1896
|
+
}
|
1897
|
+
updateDatabaseGithubSettings({
|
1898
|
+
workspace,
|
1899
|
+
database,
|
1900
|
+
settings
|
1901
|
+
}) {
|
1902
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
1903
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1904
|
+
body: settings,
|
1905
|
+
...this.extraProps
|
1906
|
+
});
|
1907
|
+
}
|
1908
|
+
deleteDatabaseGithubSettings({
|
1909
|
+
workspace,
|
1910
|
+
database
|
1911
|
+
}) {
|
1912
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
1913
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1914
|
+
...this.extraProps
|
1915
|
+
});
|
1916
|
+
}
|
1875
1917
|
listRegions({ workspace }) {
|
1876
1918
|
return operationsByTag.databases.listRegions({
|
1877
1919
|
pathParams: { workspaceId: workspace },
|
@@ -1966,6 +2008,12 @@ const _RecordArray = class extends Array {
|
|
1966
2008
|
toArray() {
|
1967
2009
|
return new Array(...this);
|
1968
2010
|
}
|
2011
|
+
toSerializable() {
|
2012
|
+
return JSON.parse(this.toString());
|
2013
|
+
}
|
2014
|
+
toString() {
|
2015
|
+
return JSON.stringify(this.toArray());
|
2016
|
+
}
|
1969
2017
|
map(callbackfn, thisArg) {
|
1970
2018
|
return this.toArray().map(callbackfn, thisArg);
|
1971
2019
|
}
|
@@ -2933,7 +2981,13 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
2933
2981
|
record.getMetadata = function() {
|
2934
2982
|
return xata;
|
2935
2983
|
};
|
2936
|
-
|
2984
|
+
record.toSerializable = function() {
|
2985
|
+
return JSON.parse(JSON.stringify(transformObjectLinks(data)));
|
2986
|
+
};
|
2987
|
+
record.toString = function() {
|
2988
|
+
return JSON.stringify(transformObjectLinks(data));
|
2989
|
+
};
|
2990
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
2937
2991
|
Object.defineProperty(record, prop, { enumerable: false });
|
2938
2992
|
}
|
2939
2993
|
Object.freeze(record);
|
@@ -3225,7 +3279,8 @@ async function resolveXataBranch(gitBranch, options) {
|
|
3225
3279
|
pathParams: { dbName, workspace, region },
|
3226
3280
|
queryParams: { gitBranch, fallbackBranch },
|
3227
3281
|
trace: defaultTrace,
|
3228
|
-
clientName: options?.clientName
|
3282
|
+
clientName: options?.clientName,
|
3283
|
+
xataAgentExtra: options?.xataAgentExtra
|
3229
3284
|
});
|
3230
3285
|
return branch;
|
3231
3286
|
}
|
@@ -3345,11 +3400,13 @@ const buildClient = (plugins) => {
|
|
3345
3400
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3346
3401
|
const trace = options?.trace ?? defaultTrace;
|
3347
3402
|
const clientName = options?.clientName;
|
3403
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
3348
3404
|
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
|
3349
3405
|
apiKey,
|
3350
3406
|
databaseURL,
|
3351
3407
|
fetchImpl: options?.fetch,
|
3352
|
-
clientName
|
3408
|
+
clientName,
|
3409
|
+
xataAgentExtra
|
3353
3410
|
});
|
3354
3411
|
if (!apiKey) {
|
3355
3412
|
throw new Error("Option apiKey is required");
|
@@ -3357,7 +3414,18 @@ const buildClient = (plugins) => {
|
|
3357
3414
|
if (!databaseURL) {
|
3358
3415
|
throw new Error("Option databaseURL is required");
|
3359
3416
|
}
|
3360
|
-
return {
|
3417
|
+
return {
|
3418
|
+
fetch,
|
3419
|
+
databaseURL,
|
3420
|
+
apiKey,
|
3421
|
+
branch,
|
3422
|
+
cache,
|
3423
|
+
trace,
|
3424
|
+
clientID: generateUUID(),
|
3425
|
+
enableBrowser,
|
3426
|
+
clientName,
|
3427
|
+
xataAgentExtra
|
3428
|
+
};
|
3361
3429
|
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
3362
3430
|
fetch,
|
3363
3431
|
apiKey,
|
@@ -3365,7 +3433,8 @@ const buildClient = (plugins) => {
|
|
3365
3433
|
branch,
|
3366
3434
|
trace,
|
3367
3435
|
clientID,
|
3368
|
-
clientName
|
3436
|
+
clientName,
|
3437
|
+
xataAgentExtra
|
3369
3438
|
}) {
|
3370
3439
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
3371
3440
|
if (!branchValue)
|
@@ -3381,7 +3450,8 @@ const buildClient = (plugins) => {
|
|
3381
3450
|
},
|
3382
3451
|
trace,
|
3383
3452
|
clientID,
|
3384
|
-
clientName
|
3453
|
+
clientName,
|
3454
|
+
xataAgentExtra
|
3385
3455
|
};
|
3386
3456
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
3387
3457
|
if (__privateGet(this, _branch))
|
@@ -3493,5 +3563,5 @@ class XataError extends Error {
|
|
3493
3563
|
}
|
3494
3564
|
}
|
3495
3565
|
|
3496
|
-
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
3566
|
+
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, branchTransaction, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
3497
3567
|
//# sourceMappingURL=index.mjs.map
|