@centrali-io/centrali-sdk 9.10.0 → 9.12.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/README.md CHANGED
@@ -730,6 +730,10 @@ const subscription = centrali.realtime.subscribe({
730
730
  | `anomaly_insight_created` | AI detected a data anomaly |
731
731
  | `anomaly_detection_completed` | Anomaly detection scan finished |
732
732
 
733
+ The `data` of validation and anomaly events carries the collection slug as
734
+ `recordSlug`. `structureSlug` holds the same value and remains for existing
735
+ clients; `recordSlug` is optional in the SDK types because older servers omit it.
736
+
733
737
  #### Subscribing to Validation Events
734
738
 
735
739
  ```typescript
@@ -1106,7 +1110,7 @@ console.log('Pending issues:', count.data.pendingCount);
1106
1110
  AI-powered anomaly detection to identify unusual patterns in your data:
1107
1111
 
1108
1112
  ```typescript
1109
- // Trigger anomaly analysis for a structure
1113
+ // Trigger anomaly analysis for a collection
1110
1114
  const result = await centrali.anomalyInsights.triggerAnalysis('orders');
1111
1115
  if (result.data.success) {
1112
1116
  console.log('Analysis started:', result.data.batchId);
@@ -1118,9 +1122,12 @@ const insights = await centrali.anomalyInsights.list({
1118
1122
  severity: 'critical' // 'info' | 'warning' | 'critical'
1119
1123
  });
1120
1124
 
1121
- // List insights for a specific structure
1125
+ // List insights for a specific collection
1122
1126
  const orderInsights = await centrali.anomalyInsights.listByStructure('orders');
1123
1127
 
1128
+ // Or filter the workspace-wide list by collection slug
1129
+ const filtered = await centrali.anomalyInsights.list({ recordSlug: 'orders' });
1130
+
1124
1131
  // Get a single insight
1125
1132
  const insight = await centrali.anomalyInsights.get('insight-id');
1126
1133
  console.log('Title:', insight.data.title);
@@ -1142,6 +1149,15 @@ console.log('Active:', summary.data.active);
1142
1149
  console.log('By severity:', summary.data.bySeverity);
1143
1150
  ```
1144
1151
 
1152
+ Filter by collection with `recordSlug`. `structureSlug` remains accepted as a
1153
+ legacy alias in `list()` options; when both names are supplied, nonempty values
1154
+ must match, and a conflict rejects the returned promise before any request is
1155
+ sent. Empty list/summary filters are treated as omitted. The SDK sends both names
1156
+ for list filters, summaries, and analysis requests so filtering also works on
1157
+ older servers. Insight objects include `recordSlug` alongside `structureSlug` on
1158
+ updated servers; `recordSlug` is optional in the SDK type because older servers
1159
+ omit it.
1160
+
1145
1161
  #### Insight Types
1146
1162
 
1147
1163
  | Type | Description |
@@ -1256,6 +1272,11 @@ await centrali.orchestrations.delete('orch-id');
1256
1272
  | `scheduled` | Run on a schedule (cron, interval, or once) |
1257
1273
  | `http-trigger` | External webhook endpoint |
1258
1274
 
1275
+ Event-driven triggers name the collection to watch with `recordSlug`.
1276
+ `structureSlug` remains accepted as a legacy alias, and updated servers return
1277
+ both. If both are sent they must match, so when editing a trigger you read from
1278
+ the API, change `recordSlug` and drop `structureSlug` (or change both).
1279
+
1259
1280
  #### Step Types
1260
1281
 
1261
1282
  | Type | Description |
package/dist/index.d.ts CHANGED
@@ -516,6 +516,11 @@ interface RealtimeRecordEvent {
516
516
  interface ValidationSuggestionData {
517
517
  /** Structure slug */
518
518
  structureSlug: string;
519
+ /**
520
+ * Collection slug; same value as `structureSlug`. Optional because
521
+ * servers older than this field omit it.
522
+ */
523
+ recordSlug?: string;
519
524
  /** Field with the issue */
520
525
  field: string;
521
526
  /** Type of issue */
@@ -555,6 +560,11 @@ interface RealtimeValidationSuggestionEvent {
555
560
  interface ValidationBatchData {
556
561
  /** Structure slug that was scanned */
557
562
  structureSlug: string;
563
+ /**
564
+ * Collection slug; same value as `structureSlug`. Optional because
565
+ * servers older than this field omit it.
566
+ */
567
+ recordSlug?: string;
558
568
  /** Batch ID */
559
569
  batchId: string;
560
570
  /** Total records processed */
@@ -598,6 +608,11 @@ interface AnomalyInsightData {
598
608
  structureId: string;
599
609
  /** Structure slug */
600
610
  structureSlug: string;
611
+ /**
612
+ * Collection slug; same value as `structureSlug`. Optional because
613
+ * servers older than this field omit it.
614
+ */
615
+ recordSlug?: string;
601
616
  /** Insight ID */
602
617
  insightId: string;
603
618
  /** Type of anomaly detected */
@@ -643,6 +658,11 @@ interface AnomalyDetectionData {
643
658
  structureId: string;
644
659
  /** Structure slug */
645
660
  structureSlug: string;
661
+ /**
662
+ * Collection slug; same value as `structureSlug`. Optional because
663
+ * servers older than this field omit it.
664
+ */
665
+ recordSlug?: string;
646
666
  /** Batch ID */
647
667
  batchId: string;
648
668
  /** Number of insights created */
@@ -1611,7 +1631,13 @@ interface OrchestrationTrigger {
1611
1631
  type: OrchestrationTriggerType;
1612
1632
  /** Event type for event-driven triggers */
1613
1633
  eventType?: string;
1614
- /** Structure slug to watch */
1634
+ /** Collection slug to watch. Returned alongside `structureSlug` by updated servers. */
1635
+ recordSlug?: string;
1636
+ /**
1637
+ * Legacy alias for `recordSlug`. If both are sent they must match, so when
1638
+ * editing a trigger read from the API, change `recordSlug` and drop
1639
+ * `structureSlug` (or change both).
1640
+ */
1615
1641
  structureSlug?: string;
1616
1642
  /** Schedule type for scheduled triggers */
1617
1643
  scheduleType?: OrchestrationScheduleType;
@@ -2596,7 +2622,9 @@ interface AnomalyInsight {
2596
2622
  workspaceSlug: string;
2597
2623
  /** Structure ID */
2598
2624
  structureId: string;
2599
- /** Structure slug */
2625
+ /** Collection slug. Optional because older servers return only `structureSlug`. */
2626
+ recordSlug?: string;
2627
+ /** Legacy name for `recordSlug`; carries the same value. */
2600
2628
  structureSlug: string;
2601
2629
  /** Batch ID if created in batch */
2602
2630
  batchId: string | null;
@@ -2637,7 +2665,9 @@ interface ListInsightsOptions {
2637
2665
  status?: InsightStatus;
2638
2666
  /** Filter by insight type */
2639
2667
  type?: InsightType;
2640
- /** Filter by structure slug */
2668
+ /** Filter by collection slug */
2669
+ recordSlug?: string;
2670
+ /** Legacy alias of `recordSlug`. If both are supplied they must match. */
2641
2671
  structureSlug?: string;
2642
2672
  /** Maximum results */
2643
2673
  limit?: number;
@@ -4270,7 +4300,7 @@ declare class SmartQueriesManager {
4270
4300
  * // List all active insights
4271
4301
  * const insights = await client.anomalyInsights.list({ status: 'active' });
4272
4302
  *
4273
- * // Get insights for a specific structure
4303
+ * // Get insights for a specific collection
4274
4304
  * const orderInsights = await client.anomalyInsights.listByStructure('orders');
4275
4305
  *
4276
4306
  * // Get insight summary
@@ -4301,26 +4331,26 @@ declare class AnomalyInsightsManager {
4301
4331
  * severity: 'critical'
4302
4332
  * });
4303
4333
  *
4304
- * // List insights for a specific structure
4334
+ * // List insights for a specific collection
4305
4335
  * const orderInsights = await client.anomalyInsights.list({
4306
- * structureSlug: 'orders'
4336
+ * recordSlug: 'orders'
4307
4337
  * });
4308
4338
  * ```
4309
4339
  */
4310
4340
  list(options?: ListInsightsOptions): Promise<ApiResponse<AnomalyInsight[]>>;
4311
4341
  /**
4312
- * List insights for a specific structure.
4342
+ * List insights for a specific collection.
4313
4343
  *
4314
- * @param structureSlug - The structure's record slug
4344
+ * @param recordSlug - The collection slug
4315
4345
  * @param options - Optional filter options
4316
- * @returns List of insights for the structure
4346
+ * @returns List of insights for the collection
4317
4347
  *
4318
4348
  * @example
4319
4349
  * ```ts
4320
4350
  * const insights = await client.anomalyInsights.listByStructure('orders');
4321
4351
  * ```
4322
4352
  */
4323
- listByStructure(structureSlug: string, options?: Omit<ListInsightsOptions, 'structureSlug'>): Promise<ApiResponse<AnomalyInsight[]>>;
4353
+ listByStructure(recordSlug: string, options?: Omit<ListInsightsOptions, 'recordSlug' | 'structureSlug'>): Promise<ApiResponse<AnomalyInsight[]>>;
4324
4354
  /**
4325
4355
  * Get a single insight by ID.
4326
4356
  *
@@ -4379,7 +4409,7 @@ declare class AnomalyInsightsManager {
4379
4409
  /**
4380
4410
  * Get insights summary/statistics.
4381
4411
  *
4382
- * @param structureSlug - Optional structure to filter summary
4412
+ * @param recordSlug - Optional collection slug to filter summary
4383
4413
  * @returns Summary of insights by status and severity
4384
4414
  *
4385
4415
  * @example
@@ -4388,16 +4418,16 @@ declare class AnomalyInsightsManager {
4388
4418
  * const summary = await client.anomalyInsights.getSummary();
4389
4419
  * console.log('Critical insights:', summary.data.bySeverity.critical);
4390
4420
  *
4391
- * // Get summary for a specific structure
4421
+ * // Get summary for a specific collection
4392
4422
  * const orderSummary = await client.anomalyInsights.getSummary('orders');
4393
4423
  * ```
4394
4424
  */
4395
- getSummary(structureSlug?: string): Promise<ApiResponse<InsightsSummary>>;
4425
+ getSummary(recordSlug?: string): Promise<ApiResponse<InsightsSummary>>;
4396
4426
  /**
4397
- * Trigger anomaly analysis for a structure.
4398
- * Starts an AI-powered analysis to detect anomalies in the structure's data.
4427
+ * Trigger anomaly analysis for a collection.
4428
+ * Starts an AI-powered analysis to detect anomalies in the collection's data.
4399
4429
  *
4400
- * @param structureSlug - The structure's record slug to analyze
4430
+ * @param recordSlug - The collection slug to analyze
4401
4431
  * @returns Result indicating if analysis was triggered and the batch ID
4402
4432
  *
4403
4433
  * @example
@@ -4408,7 +4438,7 @@ declare class AnomalyInsightsManager {
4408
4438
  * }
4409
4439
  * ```
4410
4440
  */
4411
- triggerAnalysis(structureSlug: string): Promise<ApiResponse<AnomalyAnalysisResult>>;
4441
+ triggerAnalysis(recordSlug: string): Promise<ApiResponse<AnomalyAnalysisResult>>;
4412
4442
  }
4413
4443
 
4414
4444
  /**
package/dist/index.js CHANGED
@@ -6938,6 +6938,22 @@ var SmartQueriesManager = class {
6938
6938
  }
6939
6939
  };
6940
6940
 
6941
+ // src/internal/collectionSlug.ts
6942
+ function optionalCollectionSlug(value, name = "recordSlug") {
6943
+ if (value !== void 0 && typeof value !== "string") {
6944
+ throw new TypeError(`${name} must be a string`);
6945
+ }
6946
+ return value === "" ? void 0 : value;
6947
+ }
6948
+ function resolveCollectionSlug(recordSlug, structureSlug) {
6949
+ const canonical = optionalCollectionSlug(recordSlug);
6950
+ const legacy = optionalCollectionSlug(structureSlug, "structureSlug");
6951
+ if (canonical !== void 0 && legacy !== void 0 && canonical !== legacy) {
6952
+ throw new Error("recordSlug and structureSlug must match");
6953
+ }
6954
+ return canonical != null ? canonical : legacy;
6955
+ }
6956
+
6941
6957
  // src/managers/anomalyInsights.ts
6942
6958
  var AnomalyInsightsManager = class {
6943
6959
  constructor(workspaceId, requestFn) {
@@ -6958,30 +6974,40 @@ var AnomalyInsightsManager = class {
6958
6974
  * severity: 'critical'
6959
6975
  * });
6960
6976
  *
6961
- * // List insights for a specific structure
6977
+ * // List insights for a specific collection
6962
6978
  * const orderInsights = await client.anomalyInsights.list({
6963
- * structureSlug: 'orders'
6979
+ * recordSlug: 'orders'
6964
6980
  * });
6965
6981
  * ```
6966
6982
  */
6967
6983
  list(options) {
6968
- const path = getAnomalyInsightsApiPath(this.workspaceId);
6969
- return this.requestFn("GET", path, null, options);
6984
+ return __async(this, null, function* () {
6985
+ const path = getAnomalyInsightsApiPath(this.workspaceId);
6986
+ if (!options) return this.requestFn("GET", path, null, options);
6987
+ const _a = options, { recordSlug, structureSlug } = _a, query = __objRest(_a, ["recordSlug", "structureSlug"]);
6988
+ const slug = resolveCollectionSlug(recordSlug, structureSlug);
6989
+ const params = __spreadValues({}, query);
6990
+ if (slug !== void 0) {
6991
+ params.recordSlug = slug;
6992
+ params.structureSlug = slug;
6993
+ }
6994
+ return this.requestFn("GET", path, null, params);
6995
+ });
6970
6996
  }
6971
6997
  /**
6972
- * List insights for a specific structure.
6998
+ * List insights for a specific collection.
6973
6999
  *
6974
- * @param structureSlug - The structure's record slug
7000
+ * @param recordSlug - The collection slug
6975
7001
  * @param options - Optional filter options
6976
- * @returns List of insights for the structure
7002
+ * @returns List of insights for the collection
6977
7003
  *
6978
7004
  * @example
6979
7005
  * ```ts
6980
7006
  * const insights = await client.anomalyInsights.listByStructure('orders');
6981
7007
  * ```
6982
7008
  */
6983
- listByStructure(structureSlug, options) {
6984
- const path = getStructureInsightsApiPath(this.workspaceId, structureSlug);
7009
+ listByStructure(recordSlug, options) {
7010
+ const path = getStructureInsightsApiPath(this.workspaceId, recordSlug);
6985
7011
  return this.requestFn("GET", path, null, options);
6986
7012
  }
6987
7013
  /**
@@ -7051,7 +7077,7 @@ var AnomalyInsightsManager = class {
7051
7077
  /**
7052
7078
  * Get insights summary/statistics.
7053
7079
  *
7054
- * @param structureSlug - Optional structure to filter summary
7080
+ * @param recordSlug - Optional collection slug to filter summary
7055
7081
  * @returns Summary of insights by status and severity
7056
7082
  *
7057
7083
  * @example
@@ -7060,20 +7086,23 @@ var AnomalyInsightsManager = class {
7060
7086
  * const summary = await client.anomalyInsights.getSummary();
7061
7087
  * console.log('Critical insights:', summary.data.bySeverity.critical);
7062
7088
  *
7063
- * // Get summary for a specific structure
7089
+ * // Get summary for a specific collection
7064
7090
  * const orderSummary = await client.anomalyInsights.getSummary('orders');
7065
7091
  * ```
7066
7092
  */
7067
- getSummary(structureSlug) {
7068
- const path = getAnomalyInsightsSummaryApiPath(this.workspaceId);
7069
- const params = structureSlug ? { structureSlug } : void 0;
7070
- return this.requestFn("GET", path, null, params);
7093
+ getSummary(recordSlug) {
7094
+ return __async(this, null, function* () {
7095
+ const slug = optionalCollectionSlug(recordSlug);
7096
+ const path = getAnomalyInsightsSummaryApiPath(this.workspaceId);
7097
+ const params = slug !== void 0 ? { recordSlug: slug, structureSlug: slug } : void 0;
7098
+ return this.requestFn("GET", path, null, params);
7099
+ });
7071
7100
  }
7072
7101
  /**
7073
- * Trigger anomaly analysis for a structure.
7074
- * Starts an AI-powered analysis to detect anomalies in the structure's data.
7102
+ * Trigger anomaly analysis for a collection.
7103
+ * Starts an AI-powered analysis to detect anomalies in the collection's data.
7075
7104
  *
7076
- * @param structureSlug - The structure's record slug to analyze
7105
+ * @param recordSlug - The collection slug to analyze
7077
7106
  * @returns Result indicating if analysis was triggered and the batch ID
7078
7107
  *
7079
7108
  * @example
@@ -7084,9 +7113,13 @@ var AnomalyInsightsManager = class {
7084
7113
  * }
7085
7114
  * ```
7086
7115
  */
7087
- triggerAnalysis(structureSlug) {
7088
- const path = getAnomalyAnalysisTriggerApiPath(this.workspaceId);
7089
- return this.requestFn("POST", path, { structureSlug });
7116
+ triggerAnalysis(recordSlug) {
7117
+ return __async(this, null, function* () {
7118
+ const slug = optionalCollectionSlug(recordSlug);
7119
+ if (slug === void 0) throw new TypeError("recordSlug is required");
7120
+ const path = getAnomalyAnalysisTriggerApiPath(this.workspaceId);
7121
+ return this.requestFn("POST", path, { recordSlug: slug, structureSlug: slug });
7122
+ });
7090
7123
  }
7091
7124
  };
7092
7125
 
@@ -7203,12 +7236,6 @@ var AlertDefinitionsManager = class {
7203
7236
  };
7204
7237
 
7205
7238
  // src/managers/validation.ts
7206
- function optionalCollectionSlug(value, name = "recordSlug") {
7207
- if (value !== void 0 && typeof value !== "string") {
7208
- throw new TypeError(`${name} must be a string`);
7209
- }
7210
- return value === "" ? void 0 : value;
7211
- }
7212
7239
  var ValidationManager = class {
7213
7240
  constructor(workspaceId, requestFn) {
7214
7241
  this.workspaceId = workspaceId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centrali-io/centrali-sdk",
3
- "version": "9.10.0",
3
+ "version": "9.12.0",
4
4
  "description": "Centrali Node SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,28 @@
1
+ // `recordSlug` is the current name for a collection's slug; `structureSlug` is
2
+ // the legacy name for the same value. These helpers resolve the two aliases
3
+ // before a request is built.
4
+
5
+ /**
6
+ * Optional filters preserve empty-string compatibility (empty means "no
7
+ * filter"), but reject non-string JavaScript inputs before query serialization
8
+ * can erase the filter and widen the request to the whole workspace.
9
+ */
10
+ export function optionalCollectionSlug(value: unknown, name = 'recordSlug'): string | undefined {
11
+ if (value !== undefined && typeof value !== 'string') {
12
+ throw new TypeError(`${name} must be a string`);
13
+ }
14
+ return value === '' ? undefined : value;
15
+ }
16
+
17
+ /**
18
+ * Resolve a canonical/legacy alias pair to one slug. Nonempty aliases must
19
+ * match; `undefined` means neither was supplied.
20
+ */
21
+ export function resolveCollectionSlug(recordSlug: unknown, structureSlug: unknown): string | undefined {
22
+ const canonical = optionalCollectionSlug(recordSlug);
23
+ const legacy = optionalCollectionSlug(structureSlug, 'structureSlug');
24
+ if (canonical !== undefined && legacy !== undefined && canonical !== legacy) {
25
+ throw new Error('recordSlug and structureSlug must match');
26
+ }
27
+ return canonical ?? legacy;
28
+ }
@@ -19,6 +19,7 @@ import {
19
19
  getAnomalyInsightsSummaryApiPath,
20
20
  getAnomalyAnalysisTriggerApiPath,
21
21
  } from '../internal/paths';
22
+ import { optionalCollectionSlug, resolveCollectionSlug } from '../internal/collectionSlug';
22
23
 
23
24
  // =====================================================
24
25
  // Anomaly Insights Manager
@@ -33,7 +34,7 @@ import {
33
34
  * // List all active insights
34
35
  * const insights = await client.anomalyInsights.list({ status: 'active' });
35
36
  *
36
- * // Get insights for a specific structure
37
+ * // Get insights for a specific collection
37
38
  * const orderInsights = await client.anomalyInsights.listByStructure('orders');
38
39
  *
39
40
  * // Get insight summary
@@ -72,23 +73,32 @@ export class AnomalyInsightsManager {
72
73
  * severity: 'critical'
73
74
  * });
74
75
  *
75
- * // List insights for a specific structure
76
+ * // List insights for a specific collection
76
77
  * const orderInsights = await client.anomalyInsights.list({
77
- * structureSlug: 'orders'
78
+ * recordSlug: 'orders'
78
79
  * });
79
80
  * ```
80
81
  */
81
- public list(options?: ListInsightsOptions): Promise<ApiResponse<AnomalyInsight[]>> {
82
+ public async list(options?: ListInsightsOptions): Promise<ApiResponse<AnomalyInsight[]>> {
82
83
  const path = getAnomalyInsightsApiPath(this.workspaceId);
83
- return this.requestFn<AnomalyInsight[]>('GET', path, null, options);
84
+ if (!options) return this.requestFn<AnomalyInsight[]>('GET', path, null, options);
85
+ const { recordSlug, structureSlug, ...query } = options;
86
+ const slug = resolveCollectionSlug(recordSlug, structureSlug);
87
+ // Send both names so filtering still applies against an older server.
88
+ const params: ListInsightsOptions = { ...query };
89
+ if (slug !== undefined) {
90
+ params.recordSlug = slug;
91
+ params.structureSlug = slug;
92
+ }
93
+ return this.requestFn<AnomalyInsight[]>('GET', path, null, params);
84
94
  }
85
95
 
86
96
  /**
87
- * List insights for a specific structure.
97
+ * List insights for a specific collection.
88
98
  *
89
- * @param structureSlug - The structure's record slug
99
+ * @param recordSlug - The collection slug
90
100
  * @param options - Optional filter options
91
- * @returns List of insights for the structure
101
+ * @returns List of insights for the collection
92
102
  *
93
103
  * @example
94
104
  * ```ts
@@ -96,10 +106,10 @@ export class AnomalyInsightsManager {
96
106
  * ```
97
107
  */
98
108
  public listByStructure(
99
- structureSlug: string,
100
- options?: Omit<ListInsightsOptions, 'structureSlug'>
109
+ recordSlug: string,
110
+ options?: Omit<ListInsightsOptions, 'recordSlug' | 'structureSlug'>
101
111
  ): Promise<ApiResponse<AnomalyInsight[]>> {
102
- const path = getStructureInsightsApiPath(this.workspaceId, structureSlug);
112
+ const path = getStructureInsightsApiPath(this.workspaceId, recordSlug);
103
113
  return this.requestFn<AnomalyInsight[]>('GET', path, null, options);
104
114
  }
105
115
 
@@ -174,7 +184,7 @@ export class AnomalyInsightsManager {
174
184
  /**
175
185
  * Get insights summary/statistics.
176
186
  *
177
- * @param structureSlug - Optional structure to filter summary
187
+ * @param recordSlug - Optional collection slug to filter summary
178
188
  * @returns Summary of insights by status and severity
179
189
  *
180
190
  * @example
@@ -183,21 +193,23 @@ export class AnomalyInsightsManager {
183
193
  * const summary = await client.anomalyInsights.getSummary();
184
194
  * console.log('Critical insights:', summary.data.bySeverity.critical);
185
195
  *
186
- * // Get summary for a specific structure
196
+ * // Get summary for a specific collection
187
197
  * const orderSummary = await client.anomalyInsights.getSummary('orders');
188
198
  * ```
189
199
  */
190
- public getSummary(structureSlug?: string): Promise<ApiResponse<InsightsSummary>> {
200
+ public async getSummary(recordSlug?: string): Promise<ApiResponse<InsightsSummary>> {
201
+ const slug = optionalCollectionSlug(recordSlug);
191
202
  const path = getAnomalyInsightsSummaryApiPath(this.workspaceId);
192
- const params = structureSlug ? { structureSlug } : undefined;
203
+ // Send both names so filtering still applies against an older server.
204
+ const params = slug !== undefined ? { recordSlug: slug, structureSlug: slug } : undefined;
193
205
  return this.requestFn<InsightsSummary>('GET', path, null, params);
194
206
  }
195
207
 
196
208
  /**
197
- * Trigger anomaly analysis for a structure.
198
- * Starts an AI-powered analysis to detect anomalies in the structure's data.
209
+ * Trigger anomaly analysis for a collection.
210
+ * Starts an AI-powered analysis to detect anomalies in the collection's data.
199
211
  *
200
- * @param structureSlug - The structure's record slug to analyze
212
+ * @param recordSlug - The collection slug to analyze
201
213
  * @returns Result indicating if analysis was triggered and the batch ID
202
214
  *
203
215
  * @example
@@ -208,8 +220,11 @@ export class AnomalyInsightsManager {
208
220
  * }
209
221
  * ```
210
222
  */
211
- public triggerAnalysis(structureSlug: string): Promise<ApiResponse<AnomalyAnalysisResult>> {
223
+ public async triggerAnalysis(recordSlug: string): Promise<ApiResponse<AnomalyAnalysisResult>> {
224
+ const slug = optionalCollectionSlug(recordSlug);
225
+ if (slug === undefined) throw new TypeError('recordSlug is required');
212
226
  const path = getAnomalyAnalysisTriggerApiPath(this.workspaceId);
213
- return this.requestFn<AnomalyAnalysisResult>('POST', path, { structureSlug });
227
+ // Send both names so the request still works against an older server.
228
+ return this.requestFn<AnomalyAnalysisResult>('POST', path, { recordSlug: slug, structureSlug: slug });
214
229
  }
215
230
  }
@@ -27,20 +27,12 @@ import {
27
27
  getValidationSummaryApiPath,
28
28
  getValidationPendingCountApiPath,
29
29
  } from '../internal/paths';
30
+ import { optionalCollectionSlug } from '../internal/collectionSlug';
30
31
 
31
32
  // =====================================================
32
33
  // Validation Manager (Data Quality)
33
34
  // =====================================================
34
35
 
35
- // Optional list/summary filters preserve empty-string compatibility, but reject
36
- // non-string JavaScript inputs before query serialization can erase the filter.
37
- function optionalCollectionSlug(value: unknown, name = 'recordSlug'): string | undefined {
38
- if (value !== undefined && typeof value !== 'string') {
39
- throw new TypeError(`${name} must be a string`);
40
- }
41
- return value === '' ? undefined : value;
42
- }
43
-
44
36
  /**
45
37
  * ValidationManager provides methods for AI-powered data quality validation.
46
38
  * Access via `client.validation`.
@@ -27,7 +27,9 @@ export interface AnomalyInsight {
27
27
  workspaceSlug: string;
28
28
  /** Structure ID */
29
29
  structureId: string;
30
- /** Structure slug */
30
+ /** Collection slug. Optional because older servers return only `structureSlug`. */
31
+ recordSlug?: string;
32
+ /** Legacy name for `recordSlug`; carries the same value. */
31
33
  structureSlug: string;
32
34
  /** Batch ID if created in batch */
33
35
  batchId: string | null;
@@ -69,7 +71,9 @@ export interface ListInsightsOptions {
69
71
  status?: InsightStatus;
70
72
  /** Filter by insight type */
71
73
  type?: InsightType;
72
- /** Filter by structure slug */
74
+ /** Filter by collection slug */
75
+ recordSlug?: string;
76
+ /** Legacy alias of `recordSlug`. If both are supplied they must match. */
73
77
  structureSlug?: string;
74
78
  /** Maximum results */
75
79
  limit?: number;
@@ -47,7 +47,13 @@ export interface OrchestrationTrigger {
47
47
  // Event-driven trigger config
48
48
  /** Event type for event-driven triggers */
49
49
  eventType?: string;
50
- /** Structure slug to watch */
50
+ /** Collection slug to watch. Returned alongside `structureSlug` by updated servers. */
51
+ recordSlug?: string;
52
+ /**
53
+ * Legacy alias for `recordSlug`. If both are sent they must match, so when
54
+ * editing a trigger read from the API, change `recordSlug` and drop
55
+ * `structureSlug` (or change both).
56
+ */
51
57
  structureSlug?: string;
52
58
 
53
59
  // Scheduled trigger config
@@ -64,6 +64,11 @@ export interface RealtimeRecordEvent {
64
64
  export interface ValidationSuggestionData {
65
65
  /** Structure slug */
66
66
  structureSlug: string;
67
+ /**
68
+ * Collection slug; same value as `structureSlug`. Optional because
69
+ * servers older than this field omit it.
70
+ */
71
+ recordSlug?: string;
67
72
  /** Field with the issue */
68
73
  field: string;
69
74
  /** Type of issue */
@@ -105,6 +110,11 @@ export interface RealtimeValidationSuggestionEvent {
105
110
  export interface ValidationBatchData {
106
111
  /** Structure slug that was scanned */
107
112
  structureSlug: string;
113
+ /**
114
+ * Collection slug; same value as `structureSlug`. Optional because
115
+ * servers older than this field omit it.
116
+ */
117
+ recordSlug?: string;
108
118
  /** Batch ID */
109
119
  batchId: string;
110
120
  /** Total records processed */
@@ -150,6 +160,11 @@ export interface AnomalyInsightData {
150
160
  structureId: string;
151
161
  /** Structure slug */
152
162
  structureSlug: string;
163
+ /**
164
+ * Collection slug; same value as `structureSlug`. Optional because
165
+ * servers older than this field omit it.
166
+ */
167
+ recordSlug?: string;
153
168
  /** Insight ID */
154
169
  insightId: string;
155
170
  /** Type of anomaly detected */
@@ -197,6 +212,11 @@ export interface AnomalyDetectionData {
197
212
  structureId: string;
198
213
  /** Structure slug */
199
214
  structureSlug: string;
215
+ /**
216
+ * Collection slug; same value as `structureSlug`. Optional because
217
+ * servers older than this field omit it.
218
+ */
219
+ recordSlug?: string;
200
220
  /** Batch ID */
201
221
  batchId: string;
202
222
  /** Number of insights created */