@objectstack/client 4.1.1 → 4.2.0

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.d.mts CHANGED
@@ -1851,7 +1851,9 @@ declare class ObjectStackClient {
1851
1851
  get: <T = any>(object: string, id: string) => Promise<GetDataResult<T>>;
1852
1852
  create: <T = any>(object: string, data: Partial<T>) => Promise<CreateDataResult<T>>;
1853
1853
  createMany: <T = any>(object: string, data: Partial<T>[]) => Promise<T[]>;
1854
- update: <T = any>(object: string, id: string, data: Partial<T>) => Promise<UpdateDataResult<T>>;
1854
+ update: <T = any>(object: string, id: string, data: Partial<T>, opts?: {
1855
+ ifMatch?: string;
1856
+ }) => Promise<UpdateDataResult<T>>;
1855
1857
  /**
1856
1858
  * Batch update multiple records
1857
1859
  * Uses the new BatchUpdateRequest schema with full control over options
@@ -1865,7 +1867,9 @@ declare class ObjectStackClient {
1865
1867
  id: string;
1866
1868
  data: Partial<T>;
1867
1869
  }>, options?: BatchOptions) => Promise<BatchUpdateResponse>;
1868
- delete: (object: string, id: string) => Promise<DeleteDataResult>;
1870
+ delete: (object: string, id: string, opts?: {
1871
+ ifMatch?: string;
1872
+ }) => Promise<DeleteDataResult>;
1869
1873
  /**
1870
1874
  * Delete multiple records by IDs
1871
1875
  */
package/dist/index.d.ts CHANGED
@@ -1851,7 +1851,9 @@ declare class ObjectStackClient {
1851
1851
  get: <T = any>(object: string, id: string) => Promise<GetDataResult<T>>;
1852
1852
  create: <T = any>(object: string, data: Partial<T>) => Promise<CreateDataResult<T>>;
1853
1853
  createMany: <T = any>(object: string, data: Partial<T>[]) => Promise<T[]>;
1854
- update: <T = any>(object: string, id: string, data: Partial<T>) => Promise<UpdateDataResult<T>>;
1854
+ update: <T = any>(object: string, id: string, data: Partial<T>, opts?: {
1855
+ ifMatch?: string;
1856
+ }) => Promise<UpdateDataResult<T>>;
1855
1857
  /**
1856
1858
  * Batch update multiple records
1857
1859
  * Uses the new BatchUpdateRequest schema with full control over options
@@ -1865,7 +1867,9 @@ declare class ObjectStackClient {
1865
1867
  id: string;
1866
1868
  data: Partial<T>;
1867
1869
  }>, options?: BatchOptions) => Promise<BatchUpdateResponse>;
1868
- delete: (object: string, id: string) => Promise<DeleteDataResult>;
1870
+ delete: (object: string, id: string, opts?: {
1871
+ ifMatch?: string;
1872
+ }) => Promise<DeleteDataResult>;
1869
1873
  /**
1870
1874
  * Delete multiple records by IDs
1871
1875
  */
package/dist/index.js CHANGED
@@ -2653,11 +2653,14 @@ var ObjectStackClient = class {
2653
2653
  });
2654
2654
  return this.unwrapResponse(res);
2655
2655
  },
2656
- update: async (object, id, data) => {
2656
+ update: async (object, id, data, opts) => {
2657
2657
  const route = this.getRoute("data");
2658
+ const headers = {};
2659
+ if (opts?.ifMatch) headers["If-Match"] = String(opts.ifMatch);
2658
2660
  const res = await this.fetch(`${this.baseUrl}${route}/${object}/${id}`, {
2659
2661
  method: "PATCH",
2660
- body: JSON.stringify(data)
2662
+ body: JSON.stringify(data),
2663
+ ...Object.keys(headers).length ? { headers } : {}
2661
2664
  });
2662
2665
  return this.unwrapResponse(res);
2663
2666
  },
@@ -2689,10 +2692,13 @@ var ObjectStackClient = class {
2689
2692
  });
2690
2693
  return this.unwrapResponse(res);
2691
2694
  },
2692
- delete: async (object, id) => {
2695
+ delete: async (object, id, opts) => {
2693
2696
  const route = this.getRoute("data");
2697
+ const headers = {};
2698
+ if (opts?.ifMatch) headers["If-Match"] = String(opts.ifMatch);
2694
2699
  const res = await this.fetch(`${this.baseUrl}${route}/${object}/${id}`, {
2695
- method: "DELETE"
2700
+ method: "DELETE",
2701
+ ...Object.keys(headers).length ? { headers } : {}
2696
2702
  });
2697
2703
  return this.unwrapResponse(res);
2698
2704
  },