@xata.io/client 0.0.0-next.v6c9e627772cbacc1977ba6ba82e6b403ac64c0b2 → 0.0.0-next.v8c789132fcca7e3aac976aa7b9e1cdd929b3ddab

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @xata.io/client@0.29.1 add-version /home/runner/work/client-ts/client-ts/packages/client
2
+ > @xata.io/client@0.29.2 add-version /home/runner/work/client-ts/client-ts/packages/client
3
3
  > node ../../scripts/add-version-file.mjs
4
4
 
@@ -1,13 +1,13 @@
1
1
 
2
- > @xata.io/client@0.29.1 build /home/runner/work/client-ts/client-ts/packages/client
2
+ > @xata.io/client@0.29.2 build /home/runner/work/client-ts/client-ts/packages/client
3
3
  > rimraf dist && rollup -c
4
4
 
5
5
  
6
6
  src/index.ts → dist/index.cjs...
7
- created dist/index.cjs in 986ms
7
+ created dist/index.cjs in 884ms
8
8
  
9
9
  src/index.ts → dist/index.mjs...
10
- created dist/index.mjs in 696ms
10
+ created dist/index.mjs in 635ms
11
11
  
12
12
  src/index.ts → dist/index.d.ts...
13
- created dist/index.d.ts in 5s
13
+ created dist/index.d.ts in 4s
package/CHANGELOG.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # @xata.io/client
2
2
 
3
- ## 0.0.0-next.v6c9e627772cbacc1977ba6ba82e6b403ac64c0b2
3
+ ## 0.0.0-next.v8c789132fcca7e3aac976aa7b9e1cdd929b3ddab
4
4
 
5
5
  ### Major Changes
6
6
 
7
- - [`56ef053`](https://github.com/xataio/client-ts/commit/56ef053db251511857c7c40e15cb6cd4b16ca30f) Thanks [@SferaDev](https://github.com/SferaDev)! - Make XataApiClient to use ES Proxies
7
+ - [`0fcca8b`](https://github.com/xataio/client-ts/commit/0fcca8b8218f02bebe2d724368ad6b4f71fe9ab7) Thanks [@SferaDev](https://github.com/SferaDev)! - Make XataApiClient to use ES Proxies
8
8
 
9
- - [`f60ef87`](https://github.com/xataio/client-ts/commit/f60ef8714614d5f7a6ddb28ae96ea99d13e8a0ed) Thanks [@SferaDev](https://github.com/SferaDev)! - Version 1.0
9
+ - [`22d0b54`](https://github.com/xataio/client-ts/commit/22d0b540336295383d96ee1de9da9d87ab8967f4) Thanks [@SferaDev](https://github.com/SferaDev)! - Version 1.0
10
+
11
+ ## 0.29.2
10
12
 
11
13
  ### Patch Changes
12
14
 
package/dist/index.cjs CHANGED
@@ -528,7 +528,7 @@ function defaultOnOpen(response) {
528
528
  }
529
529
  }
530
530
 
531
- const VERSION = "0.29.1";
531
+ const VERSION = "0.29.2";
532
532
 
533
533
  class ErrorWithCause extends Error {
534
534
  constructor(message, options) {
@@ -740,6 +740,8 @@ async function fetch$1({
740
740
  "X-Xata-Client-ID": clientID ?? defaultClientID,
741
741
  "X-Xata-Session-ID": sessionID ?? generateUUID(),
742
742
  "X-Xata-Agent": xataAgent,
743
+ // Force field rename to xata_ internal properties
744
+ "X-Features": compact(["feat-internal-field-rename-api=1", customHeaders?.["X-Features"]]).join(" "),
743
745
  ...customHeaders,
744
746
  ...hostHeader(fullUrl),
745
747
  Authorization: `Bearer ${apiKey}`
@@ -1257,6 +1259,8 @@ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
1257
1259
  ...variables,
1258
1260
  signal
1259
1261
  });
1262
+ const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "get", ...variables, signal });
1263
+ const updateWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "patch", ...variables, signal });
1260
1264
  const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
1261
1265
  const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
1262
1266
  const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
@@ -1322,6 +1326,8 @@ const operationsByTag$1 = {
1322
1326
  getWorkspace,
1323
1327
  updateWorkspace,
1324
1328
  deleteWorkspace,
1329
+ getWorkspaceSettings,
1330
+ updateWorkspaceSettings,
1325
1331
  getWorkspaceMembersList,
1326
1332
  updateWorkspaceMemberRole,
1327
1333
  removeWorkspaceMember
@@ -2025,8 +2031,8 @@ cleanFilterConstraint_fn = function(column, value) {
2025
2031
  if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
2026
2032
  return { $includes: value };
2027
2033
  }
2028
- if (columnType === "link" && isObject(value) && isString(value.id)) {
2029
- return value.id;
2034
+ if (columnType === "link" && isObject(value) && isString(value.xata_id)) {
2035
+ return value.xata_id;
2030
2036
  }
2031
2037
  return value;
2032
2038
  };
@@ -2054,12 +2060,7 @@ const RecordColumnTypes = [
2054
2060
  "json"
2055
2061
  ];
2056
2062
  function isIdentifiable(x) {
2057
- return isObject(x) && isString(x?.id);
2058
- }
2059
- function isXataRecord(x) {
2060
- const record = x;
2061
- const metadata = record?.getMetadata();
2062
- return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
2063
+ return isObject(x) && isString(x?.xata_id);
2063
2064
  }
2064
2065
 
2065
2066
  function isValidExpandedColumn(column) {
@@ -2186,11 +2187,14 @@ class RestRepository extends Query {
2186
2187
  const columns = isValidSelectableColumns(c) ? c : void 0;
2187
2188
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
2188
2189
  }
2189
- if (isObject(a) && isString(a.id)) {
2190
- if (a.id === "")
2190
+ if (isObject(a) && isString(a.xata_id)) {
2191
+ if (a.xata_id === "")
2191
2192
  throw new Error("The id can't be empty");
2192
2193
  const columns = isValidSelectableColumns(b) ? b : void 0;
2193
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
2194
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
2195
+ createOnly: true,
2196
+ ifVersion
2197
+ });
2194
2198
  }
2195
2199
  if (isObject(a)) {
2196
2200
  const columns = isValidSelectableColumns(b) ? b : void 0;
@@ -2206,9 +2210,9 @@ class RestRepository extends Query {
2206
2210
  if (a.length === 0)
2207
2211
  return [];
2208
2212
  const ids = a.map((item) => extractId(item));
2209
- const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
2213
+ const finalObjects = await this.getAll({ filter: { xata_id: { $any: compact(ids) } }, columns });
2210
2214
  const dictionary = finalObjects.reduce((acc, object) => {
2211
- acc[object.id] = object;
2215
+ acc[object.xata_id] = object;
2212
2216
  return acc;
2213
2217
  }, {});
2214
2218
  return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
@@ -2270,7 +2274,7 @@ class RestRepository extends Query {
2270
2274
  if (Array.isArray(a)) {
2271
2275
  if (a.length === 0)
2272
2276
  return [];
2273
- const existing = await this.read(a, ["id"]);
2277
+ const existing = await this.read(a, ["xata_id"]);
2274
2278
  const updates = a.filter((_item, index) => existing[index] !== null);
2275
2279
  await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
2276
2280
  ifVersion,
@@ -2285,9 +2289,9 @@ class RestRepository extends Query {
2285
2289
  const columns = isValidSelectableColumns(c) ? c : void 0;
2286
2290
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2287
2291
  }
2288
- if (isObject(a) && isString(a.id)) {
2292
+ if (isObject(a) && isString(a.xata_id)) {
2289
2293
  const columns = isValidSelectableColumns(b) ? b : void 0;
2290
- return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2294
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
2291
2295
  }
2292
2296
  } catch (error) {
2293
2297
  if (error.status === 422)
@@ -2336,16 +2340,16 @@ class RestRepository extends Query {
2336
2340
  const columns = isValidSelectableColumns(c) ? c : void 0;
2337
2341
  return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2338
2342
  }
2339
- if (isObject(a) && isString(a.id)) {
2340
- if (a.id === "")
2343
+ if (isObject(a) && isString(a.xata_id)) {
2344
+ if (a.xata_id === "")
2341
2345
  throw new Error("The id can't be empty");
2342
2346
  const columns = isValidSelectableColumns(c) ? c : void 0;
2343
- return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2347
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
2344
2348
  }
2345
2349
  if (!isDefined(a) && isObject(b)) {
2346
2350
  return await this.create(b, c);
2347
2351
  }
2348
- if (isObject(a) && !isDefined(a.id)) {
2352
+ if (isObject(a) && !isDefined(a.xata_id)) {
2349
2353
  return await this.create(a, b);
2350
2354
  }
2351
2355
  throw new Error("Invalid arguments for createOrUpdate method");
@@ -2368,16 +2372,19 @@ class RestRepository extends Query {
2368
2372
  const columns = isValidSelectableColumns(c) ? c : void 0;
2369
2373
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2370
2374
  }
2371
- if (isObject(a) && isString(a.id)) {
2372
- if (a.id === "")
2375
+ if (isObject(a) && isString(a.xata_id)) {
2376
+ if (a.xata_id === "")
2373
2377
  throw new Error("The id can't be empty");
2374
2378
  const columns = isValidSelectableColumns(c) ? c : void 0;
2375
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
2379
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
2380
+ createOnly: false,
2381
+ ifVersion
2382
+ });
2376
2383
  }
2377
2384
  if (!isDefined(a) && isObject(b)) {
2378
2385
  return await this.create(b, c);
2379
2386
  }
2380
- if (isObject(a) && !isDefined(a.id)) {
2387
+ if (isObject(a) && !isDefined(a.xata_id)) {
2381
2388
  return await this.create(a, b);
2382
2389
  }
2383
2390
  throw new Error("Invalid arguments for createOrReplace method");
@@ -2391,8 +2398,8 @@ class RestRepository extends Query {
2391
2398
  const ids = a.map((o) => {
2392
2399
  if (isString(o))
2393
2400
  return o;
2394
- if (isString(o.id))
2395
- return o.id;
2401
+ if (isString(o.xata_id))
2402
+ return o.xata_id;
2396
2403
  throw new Error("Invalid arguments for delete method");
2397
2404
  });
2398
2405
  const columns = isValidSelectableColumns(b) ? b : ["*"];
@@ -2403,8 +2410,8 @@ class RestRepository extends Query {
2403
2410
  if (isString(a)) {
2404
2411
  return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
2405
2412
  }
2406
- if (isObject(a) && isString(a.id)) {
2407
- return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
2413
+ if (isObject(a) && isString(a.xata_id)) {
2414
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.xata_id, b);
2408
2415
  }
2409
2416
  throw new Error("Invalid arguments for delete method");
2410
2417
  });
@@ -2666,7 +2673,7 @@ _updateRecordWithID = new WeakSet();
2666
2673
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
2667
2674
  if (!recordId)
2668
2675
  return null;
2669
- const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2676
+ const { xata_id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2670
2677
  try {
2671
2678
  const response = await updateRecordWithID({
2672
2679
  pathParams: {
@@ -2691,9 +2698,9 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
2691
2698
  };
2692
2699
  _updateRecords = new WeakSet();
2693
2700
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
2694
- const operations = await promiseMap(objects, async ({ id, ...object }) => {
2701
+ const operations = await promiseMap(objects, async ({ xata_id, ...object }) => {
2695
2702
  const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
2696
- return { update: { table: __privateGet$2(this, _table), id, ifVersion, upsert, fields } };
2703
+ return { update: { table: __privateGet$2(this, _table), id: xata_id, ifVersion, upsert, fields } };
2697
2704
  });
2698
2705
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
2699
2706
  const ids = [];
@@ -2798,12 +2805,12 @@ transformObjectToApi_fn = async function(object) {
2798
2805
  throw new Error(`Table ${__privateGet$2(this, _table)} not found in schema`);
2799
2806
  const result = {};
2800
2807
  for (const [key, value] of Object.entries(object)) {
2801
- if (key === "xata")
2808
+ if (["xata_version", "xata_createdat", "xata_updatedat"].includes(key))
2802
2809
  continue;
2803
2810
  const type = schema.columns.find((column) => column.name === key)?.type;
2804
2811
  switch (type) {
2805
2812
  case "link": {
2806
- result[key] = isIdentifiable(value) ? value.id : value;
2813
+ result[key] = isIdentifiable(value) ? value.xata_id : value;
2807
2814
  break;
2808
2815
  }
2809
2816
  case "datetime": {
@@ -2827,8 +2834,7 @@ transformObjectToApi_fn = async function(object) {
2827
2834
  };
2828
2835
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
2829
2836
  const data = {};
2830
- const { xata, ...rest } = object ?? {};
2831
- Object.assign(data, rest);
2837
+ Object.assign(data, { ...object });
2832
2838
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2833
2839
  if (!columns)
2834
2840
  console.error(`Table ${table} not found in schema`);
@@ -2891,28 +2897,21 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2891
2897
  }
2892
2898
  }
2893
2899
  const record = { ...data };
2894
- const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
2895
2900
  record.read = function(columns2) {
2896
- return db[table].read(record["id"], columns2);
2901
+ return db[table].read(record["xata_id"], columns2);
2897
2902
  };
2898
2903
  record.update = function(data2, b, c) {
2899
2904
  const columns2 = isValidSelectableColumns(b) ? b : ["*"];
2900
2905
  const ifVersion = parseIfVersion(b, c);
2901
- return db[table].update(record["id"], data2, columns2, { ifVersion });
2906
+ return db[table].update(record["xata_id"], data2, columns2, { ifVersion });
2902
2907
  };
2903
2908
  record.replace = function(data2, b, c) {
2904
2909
  const columns2 = isValidSelectableColumns(b) ? b : ["*"];
2905
2910
  const ifVersion = parseIfVersion(b, c);
2906
- return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2911
+ return db[table].createOrReplace(record["xata_id"], data2, columns2, { ifVersion });
2907
2912
  };
2908
2913
  record.delete = function() {
2909
- return db[table].delete(record["id"]);
2910
- };
2911
- if (metadata !== void 0) {
2912
- record.xata = Object.freeze(metadata);
2913
- }
2914
- record.getMetadata = function() {
2915
- return record.xata;
2914
+ return db[table].delete(record["xata_id"]);
2916
2915
  };
2917
2916
  record.toSerializable = function() {
2918
2917
  return JSON.parse(JSON.stringify(record));
@@ -2920,7 +2919,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2920
2919
  record.toString = function() {
2921
2920
  return JSON.stringify(record);
2922
2921
  };
2923
- for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
2922
+ for (const prop of ["read", "update", "replace", "delete", "toSerializable", "toString"]) {
2924
2923
  Object.defineProperty(record, prop, { enumerable: false });
2925
2924
  }
2926
2925
  Object.freeze(record);
@@ -2929,8 +2928,8 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2929
2928
  function extractId(value) {
2930
2929
  if (isString(value))
2931
2930
  return value;
2932
- if (isObject(value) && isString(value.id))
2933
- return value.id;
2931
+ if (isObject(value) && isString(value.xata_id))
2932
+ return value.xata_id;
2934
2933
  return void 0;
2935
2934
  }
2936
2935
  function isValidColumn(columns, column) {
@@ -3118,7 +3117,7 @@ class SearchPlugin extends XataPlugin {
3118
3117
  return {
3119
3118
  totalCount,
3120
3119
  records: records.map((record) => {
3121
- const { table = "orphan" } = record.xata;
3120
+ const table = record.xata_table;
3122
3121
  return { table, record: initObject(this.db, pluginOptions.tables, table, record, ["*"]) };
3123
3122
  })
3124
3123
  };
@@ -3126,7 +3125,7 @@ class SearchPlugin extends XataPlugin {
3126
3125
  byTable: async (query, options = {}) => {
3127
3126
  const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3128
3127
  const records = rawRecords.reduce((acc, record) => {
3129
- const { table = "orphan" } = record.xata;
3128
+ const table = record.xata_table;
3130
3129
  const items = acc[table] ?? [];
3131
3130
  const item = initObject(this.db, pluginOptions.tables, table, record, ["*"]);
3132
3131
  return { ...acc, [table]: [...items, item] };
@@ -3574,6 +3573,7 @@ exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
3574
3573
  exports.getUserOAuthClients = getUserOAuthClients;
3575
3574
  exports.getWorkspace = getWorkspace;
3576
3575
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
3576
+ exports.getWorkspaceSettings = getWorkspaceSettings;
3577
3577
  exports.getWorkspacesList = getWorkspacesList;
3578
3578
  exports.grantAuthorizationCode = grantAuthorizationCode;
3579
3579
  exports.greaterEquals = greaterEquals;
@@ -3598,7 +3598,6 @@ exports.isIdentifiable = isIdentifiable;
3598
3598
  exports.isNot = isNot;
3599
3599
  exports.isValidExpandedColumn = isValidExpandedColumn;
3600
3600
  exports.isValidSelectableColumns = isValidSelectableColumns;
3601
- exports.isXataRecord = isXataRecord;
3602
3601
  exports.le = le;
3603
3602
  exports.lessEquals = lessEquals;
3604
3603
  exports.lessThan = lessThan;
@@ -3648,6 +3647,7 @@ exports.updateUser = updateUser;
3648
3647
  exports.updateWorkspace = updateWorkspace;
3649
3648
  exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
3650
3649
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
3650
+ exports.updateWorkspaceSettings = updateWorkspaceSettings;
3651
3651
  exports.upsertRecordWithID = upsertRecordWithID;
3652
3652
  exports.vectorSearchTable = vectorSearchTable;
3653
3653
  //# sourceMappingURL=index.cjs.map