@centrali-io/centrali-sdk 2.2.0 → 2.2.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/README.md CHANGED
@@ -97,9 +97,20 @@ await centrali.updateRecord('StructureName', 'record-id', {
97
97
  field1: 'new value'
98
98
  });
99
99
 
100
- // Delete a record
100
+ // Delete a record (soft delete - can be restored)
101
101
  await centrali.deleteRecord('StructureName', 'record-id');
102
102
 
103
+ // Hard delete a record (permanent - cannot be restored)
104
+ await centrali.deleteRecord('StructureName', 'record-id', { hard: true });
105
+
106
+ // Restore a soft-deleted record
107
+ await centrali.restoreRecord('StructureName', 'record-id');
108
+
109
+ // Query archived (soft-deleted) records
110
+ const archived = await centrali.queryRecords('StructureName', {
111
+ includeArchived: true
112
+ });
113
+
103
114
  // Query records
104
115
  const products = await centrali.queryRecords('Product', {
105
116
  filter: 'inStock = true AND price < 100',
package/dist/index.js CHANGED
@@ -607,10 +607,16 @@ class CentraliSDK {
607
607
  const path = getRecordApiPath(this.options.workspaceId, recordSlug, id);
608
608
  return this.request('PUT', path, Object.assign({}, updates));
609
609
  }
610
- /** Delete a record by ID. */
611
- deleteRecord(recordSlug, id) {
610
+ /** Delete a record by ID (soft delete by default, can be restored). */
611
+ deleteRecord(recordSlug, id, options) {
612
612
  const path = getRecordApiPath(this.options.workspaceId, recordSlug, id);
613
- return this.request('DELETE', path);
613
+ const queryParams = (options === null || options === void 0 ? void 0 : options.hard) ? { hard: 'true' } : undefined;
614
+ return this.request('DELETE', path, null, queryParams);
615
+ }
616
+ /** Restore a soft-deleted record by ID. */
617
+ restoreRecord(recordSlug, id) {
618
+ const path = getRecordApiPath(this.options.workspaceId, recordSlug, id) + '/restore';
619
+ return this.request('POST', path);
614
620
  }
615
621
  // ------------------ Storage API Methods ------------------
616
622
  /** Upload a file to the storage service. */
package/index.ts CHANGED
@@ -186,6 +186,14 @@ export interface InvokeTriggerOptions {
186
186
  payload?: Record<string, any>;
187
187
  }
188
188
 
189
+ /**
190
+ * Options for deleting a record.
191
+ */
192
+ export interface DeleteRecordOptions {
193
+ /** Perform a hard delete (permanent). Default: false (soft delete) */
194
+ hard?: boolean;
195
+ }
196
+
189
197
  /**
190
198
  * Response from invoking a trigger.
191
199
  * Currently the API returns the queued job ID as a string.
@@ -894,13 +902,24 @@ export class CentraliSDK {
894
902
  return this.request('PUT', path, { ...updates });
895
903
  }
896
904
 
897
- /** Delete a record by ID. */
905
+ /** Delete a record by ID (soft delete by default, can be restored). */
898
906
  public deleteRecord(
899
907
  recordSlug: string,
900
- id: string
908
+ id: string,
909
+ options?: DeleteRecordOptions
901
910
  ): Promise<ApiResponse<null>> {
902
911
  const path = getRecordApiPath(this.options.workspaceId, recordSlug, id);
903
- return this.request('DELETE', path);
912
+ const queryParams = options?.hard ? { hard: 'true' } : undefined;
913
+ return this.request('DELETE', path, null, queryParams);
914
+ }
915
+
916
+ /** Restore a soft-deleted record by ID. */
917
+ public restoreRecord(
918
+ recordSlug: string,
919
+ id: string
920
+ ): Promise<ApiResponse<null>> {
921
+ const path = getRecordApiPath(this.options.workspaceId, recordSlug, id) + '/restore';
922
+ return this.request('POST', path);
904
923
  }
905
924
 
906
925
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centrali-io/centrali-sdk",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Centrali Node SDK",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",