@xata.io/client 0.22.0 → 0.22.2

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/dist/index.mjs CHANGED
@@ -299,7 +299,7 @@ function generateUUID() {
299
299
  });
300
300
  }
301
301
 
302
- const VERSION = "0.22.0";
302
+ const VERSION = "0.22.2";
303
303
 
304
304
  class ErrorWithCause extends Error {
305
305
  constructor(message, options) {
@@ -393,6 +393,7 @@ 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);
@@ -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",
@@ -608,6 +610,7 @@ const searchTable = (variables, signal) => dataPlaneFetch({
608
610
  ...variables,
609
611
  signal
610
612
  });
613
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
611
614
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
612
615
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
613
616
  const operationsByTag$2 = {
@@ -667,7 +670,7 @@ const operationsByTag$2 = {
667
670
  deleteRecord,
668
671
  bulkInsertTableRecords
669
672
  },
670
- searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
673
+ searchAndFilter: { queryTable, searchBranch, searchTable, vectorSearchTable, summarizeTable, aggregateTable }
671
674
  };
672
675
 
673
676
  const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
@@ -766,6 +769,9 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
766
769
  });
767
770
  const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
768
771
  const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
772
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
773
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
774
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
769
775
  const listRegions = (variables, signal) => controlPlaneFetch({
770
776
  url: "/workspaces/{workspaceId}/regions",
771
777
  method: "get",
@@ -798,6 +804,9 @@ const operationsByTag$1 = {
798
804
  deleteDatabase,
799
805
  getDatabaseMetadata,
800
806
  updateDatabaseMetadata,
807
+ getDatabaseGithubSettings,
808
+ updateDatabaseGithubSettings,
809
+ deleteDatabaseGithubSettings,
801
810
  listRegions
802
811
  }
803
812
  };
@@ -818,8 +827,8 @@ const providers = {
818
827
  workspaces: "https://{workspaceId}.{region}.xata.sh"
819
828
  },
820
829
  staging: {
821
- main: "https://staging.xatabase.co",
822
- workspaces: "https://{workspaceId}.staging.{region}.xatabase.co"
830
+ main: "https://api.staging-xata.dev",
831
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
823
832
  }
824
833
  };
825
834
  function isHostProviderAlias(alias) {
@@ -841,8 +850,10 @@ function parseWorkspacesUrlParts(url) {
841
850
  if (!isString(url))
842
851
  return null;
843
852
  const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
844
- const regexStaging = /(?:https:\/\/)?([^.]+)\.staging(?:\.([^.]+))\.xatabase\.co.*/;
845
- const match = url.match(regex) || url.match(regexStaging);
853
+ const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
854
+ const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
855
+ const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
856
+ const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
846
857
  if (!match)
847
858
  return null;
848
859
  return { workspace: match[1], region: match[2] };
@@ -885,6 +896,7 @@ class XataApiClient {
885
896
  apiKey,
886
897
  trace,
887
898
  clientName: options.clientName,
899
+ xataAgentExtra: options.xataAgentExtra,
888
900
  clientID
889
901
  });
890
902
  }
@@ -1760,11 +1772,13 @@ class MigrationsApi {
1760
1772
  region,
1761
1773
  database,
1762
1774
  branch,
1763
- schema
1775
+ schema,
1776
+ schemaOperations,
1777
+ branchOperations
1764
1778
  }) {
1765
1779
  return operationsByTag.migrations.compareBranchWithUserSchema({
1766
1780
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1767
- body: { schema },
1781
+ body: { schema, schemaOperations, branchOperations },
1768
1782
  ...this.extraProps
1769
1783
  });
1770
1784
  }
@@ -1774,11 +1788,12 @@ class MigrationsApi {
1774
1788
  database,
1775
1789
  branch,
1776
1790
  compare,
1777
- schema
1791
+ sourceBranchOperations,
1792
+ targetBranchOperations
1778
1793
  }) {
1779
1794
  return operationsByTag.migrations.compareBranchSchemas({
1780
1795
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
1781
- body: { schema },
1796
+ body: { sourceBranchOperations, targetBranchOperations },
1782
1797
  ...this.extraProps
1783
1798
  });
1784
1799
  }
@@ -1872,6 +1887,35 @@ class DatabaseApi {
1872
1887
  ...this.extraProps
1873
1888
  });
1874
1889
  }
1890
+ getDatabaseGithubSettings({
1891
+ workspace,
1892
+ database
1893
+ }) {
1894
+ return operationsByTag.databases.getDatabaseGithubSettings({
1895
+ pathParams: { workspaceId: workspace, dbName: database },
1896
+ ...this.extraProps
1897
+ });
1898
+ }
1899
+ updateDatabaseGithubSettings({
1900
+ workspace,
1901
+ database,
1902
+ settings
1903
+ }) {
1904
+ return operationsByTag.databases.updateDatabaseGithubSettings({
1905
+ pathParams: { workspaceId: workspace, dbName: database },
1906
+ body: settings,
1907
+ ...this.extraProps
1908
+ });
1909
+ }
1910
+ deleteDatabaseGithubSettings({
1911
+ workspace,
1912
+ database
1913
+ }) {
1914
+ return operationsByTag.databases.deleteDatabaseGithubSettings({
1915
+ pathParams: { workspaceId: workspace, dbName: database },
1916
+ ...this.extraProps
1917
+ });
1918
+ }
1875
1919
  listRegions({ workspace }) {
1876
1920
  return operationsByTag.databases.listRegions({
1877
1921
  pathParams: { workspaceId: workspace },
@@ -2570,6 +2614,29 @@ class RestRepository extends Query {
2570
2614
  return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
2571
2615
  });
2572
2616
  }
2617
+ async vectorSearch(column, query, options) {
2618
+ return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
2619
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
2620
+ const { records } = await vectorSearchTable({
2621
+ pathParams: {
2622
+ workspace: "{workspaceId}",
2623
+ dbBranchName: "{dbBranch}",
2624
+ region: "{region}",
2625
+ tableName: __privateGet$4(this, _table)
2626
+ },
2627
+ body: {
2628
+ column,
2629
+ queryVector: query,
2630
+ similarityFunction: options?.similarityFunction,
2631
+ size: options?.size,
2632
+ filter: options?.filter
2633
+ },
2634
+ ...fetchProps
2635
+ });
2636
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2637
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
2638
+ });
2639
+ }
2573
2640
  async aggregate(aggs, filter) {
2574
2641
  return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
2575
2642
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
@@ -3237,7 +3304,8 @@ async function resolveXataBranch(gitBranch, options) {
3237
3304
  pathParams: { dbName, workspace, region },
3238
3305
  queryParams: { gitBranch, fallbackBranch },
3239
3306
  trace: defaultTrace,
3240
- clientName: options?.clientName
3307
+ clientName: options?.clientName,
3308
+ xataAgentExtra: options?.xataAgentExtra
3241
3309
  });
3242
3310
  return branch;
3243
3311
  }
@@ -3357,11 +3425,13 @@ const buildClient = (plugins) => {
3357
3425
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3358
3426
  const trace = options?.trace ?? defaultTrace;
3359
3427
  const clientName = options?.clientName;
3428
+ const xataAgentExtra = options?.xataAgentExtra;
3360
3429
  const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
3361
3430
  apiKey,
3362
3431
  databaseURL,
3363
3432
  fetchImpl: options?.fetch,
3364
- clientName: options?.clientName
3433
+ clientName,
3434
+ xataAgentExtra
3365
3435
  });
3366
3436
  if (!apiKey) {
3367
3437
  throw new Error("Option apiKey is required");
@@ -3369,7 +3439,18 @@ const buildClient = (plugins) => {
3369
3439
  if (!databaseURL) {
3370
3440
  throw new Error("Option databaseURL is required");
3371
3441
  }
3372
- return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser, clientName };
3442
+ return {
3443
+ fetch,
3444
+ databaseURL,
3445
+ apiKey,
3446
+ branch,
3447
+ cache,
3448
+ trace,
3449
+ clientID: generateUUID(),
3450
+ enableBrowser,
3451
+ clientName,
3452
+ xataAgentExtra
3453
+ };
3373
3454
  }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
3374
3455
  fetch,
3375
3456
  apiKey,
@@ -3377,7 +3458,8 @@ const buildClient = (plugins) => {
3377
3458
  branch,
3378
3459
  trace,
3379
3460
  clientID,
3380
- clientName
3461
+ clientName,
3462
+ xataAgentExtra
3381
3463
  }) {
3382
3464
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
3383
3465
  if (!branchValue)
@@ -3393,7 +3475,8 @@ const buildClient = (plugins) => {
3393
3475
  },
3394
3476
  trace,
3395
3477
  clientID,
3396
- clientName
3478
+ clientName,
3479
+ xataAgentExtra
3397
3480
  };
3398
3481
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
3399
3482
  if (__privateGet(this, _branch))
@@ -3505,5 +3588,5 @@ class XataError extends Error {
3505
3588
  }
3506
3589
  }
3507
3590
 
3508
- 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 };
3591
+ 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, vectorSearchTable };
3509
3592
  //# sourceMappingURL=index.mjs.map