@centrali-io/centrali-sdk 3.0.9 → 3.1.1

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.
Files changed (3) hide show
  1. package/dist/index.js +618 -1
  2. package/index.ts +1082 -10
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.CentraliSDK = exports.AllowedDomainsManager = exports.ValidationManager = exports.AnomalyInsightsManager = exports.SmartQueriesManager = exports.TriggersManager = exports.OrchestrationsManager = exports.RealtimeManager = void 0;
21
+ exports.CentraliSDK = exports.ComputeFunctionsManager = exports.StructuresManager = exports.AllowedDomainsManager = exports.ValidationManager = exports.AnomalyInsightsManager = exports.SmartQueriesManager = exports.TriggersManager = exports.OrchestrationsManager = exports.RealtimeManager = void 0;
22
22
  exports.getApiUrl = getApiUrl;
23
23
  exports.getAuthUrl = getAuthUrl;
24
24
  exports.getRealtimeUrl = getRealtimeUrl;
@@ -41,6 +41,12 @@ exports.getAnomalyInsightDismissApiPath = getAnomalyInsightDismissApiPath;
41
41
  exports.getAnomalyInsightsBulkAcknowledgeApiPath = getAnomalyInsightsBulkAcknowledgeApiPath;
42
42
  exports.getAnomalyAnalysisTriggerApiPath = getAnomalyAnalysisTriggerApiPath;
43
43
  exports.getStructureInsightsApiPath = getStructureInsightsApiPath;
44
+ exports.getStructuresApiPath = getStructuresApiPath;
45
+ exports.getStructureBySlugApiPath = getStructureBySlugApiPath;
46
+ exports.getStructureValidateApiPath = getStructureValidateApiPath;
47
+ exports.getComputeFunctionsApiPath = getComputeFunctionsApiPath;
48
+ exports.getComputeFunctionTestApiPath = getComputeFunctionTestApiPath;
49
+ exports.getSmartQueryTestApiPath = getSmartQueryTestApiPath;
44
50
  exports.getValidationSuggestionsApiPath = getValidationSuggestionsApiPath;
45
51
  exports.getValidationSuggestionAcceptApiPath = getValidationSuggestionAcceptApiPath;
46
52
  exports.getValidationSuggestionRejectApiPath = getValidationSuggestionRejectApiPath;
@@ -197,6 +203,13 @@ class RealtimeManager {
197
203
  if (options.functionId) {
198
204
  url.searchParams.set('functionId', options.functionId);
199
205
  }
206
+ // Add orchestration filters
207
+ if (options.orchestrationId) {
208
+ url.searchParams.set('orchestrationId', options.orchestrationId);
209
+ }
210
+ if (options.runId) {
211
+ url.searchParams.set('runId', options.runId);
212
+ }
200
213
  // Create EventSource (uses polyfill in Node.js)
201
214
  eventSource = new EventSourceImpl(url.toString());
202
215
  // Handle connection open
@@ -456,6 +469,53 @@ function getStructureInsightsApiPath(workspaceId, structureSlug) {
456
469
  return `data/workspace/${workspaceId}/api/v1/structures/${structureSlug}/insights`;
457
470
  }
458
471
  // =====================================================
472
+ // Structure API Path Helpers (Configuration-as-Code)
473
+ // =====================================================
474
+ /**
475
+ * Generate Structures base API URL PATH.
476
+ */
477
+ function getStructuresApiPath(workspaceId, structureId) {
478
+ const basePath = `data/workspace/${workspaceId}/api/v1/structures`;
479
+ return structureId ? `${basePath}/${structureId}` : basePath;
480
+ }
481
+ /**
482
+ * Generate Structure by slug API URL PATH.
483
+ */
484
+ function getStructureBySlugApiPath(workspaceId, recordSlug) {
485
+ return `data/workspace/${workspaceId}/api/v1/structures/slug/${recordSlug}`;
486
+ }
487
+ /**
488
+ * Generate Structure validate API URL PATH.
489
+ */
490
+ function getStructureValidateApiPath(workspaceId) {
491
+ return `data/workspace/${workspaceId}/api/v1/structures/validate`;
492
+ }
493
+ // =====================================================
494
+ // Compute Function API Path Helpers (Configuration-as-Code)
495
+ // =====================================================
496
+ /**
497
+ * Generate Compute Functions base API URL PATH.
498
+ */
499
+ function getComputeFunctionsApiPath(workspaceId, functionId) {
500
+ const basePath = `data/workspace/${workspaceId}/api/v1/compute-functions`;
501
+ return functionId ? `${basePath}/${functionId}` : basePath;
502
+ }
503
+ /**
504
+ * Generate Compute Function test execution API URL PATH.
505
+ */
506
+ function getComputeFunctionTestApiPath(workspaceId) {
507
+ return `data/workspace/${workspaceId}/api/v1/compute-functions/test`;
508
+ }
509
+ // =====================================================
510
+ // Smart Query Test API Path Helper (Configuration-as-Code)
511
+ // =====================================================
512
+ /**
513
+ * Generate Smart Query test execution API URL PATH.
514
+ */
515
+ function getSmartQueryTestApiPath(workspaceId, structureSlug) {
516
+ return `data/workspace/${workspaceId}/api/v1/smart-queries/slug/${structureSlug}/test`;
517
+ }
518
+ // =====================================================
459
519
  // Validation API Path Helpers
460
520
  // =====================================================
461
521
  /**
@@ -990,6 +1050,113 @@ class TriggersManager {
990
1050
  const path = getFunctionTriggerResumeApiPath(this.workspaceId, triggerId);
991
1051
  return this.requestFn('PATCH', path, {});
992
1052
  }
1053
+ /**
1054
+ * Create a new function trigger.
1055
+ *
1056
+ * @param input - The trigger definition
1057
+ * @returns The created trigger
1058
+ *
1059
+ * @example
1060
+ * ```ts
1061
+ * // Create an event-driven trigger
1062
+ * const trigger = await client.triggers.create({
1063
+ * name: 'On Order Created',
1064
+ * functionId: 'function-uuid',
1065
+ * executionType: 'event-driven',
1066
+ * triggerMetadata: { event: 'record.created', recordSlug: 'orders' }
1067
+ * });
1068
+ *
1069
+ * // Create a scheduled trigger
1070
+ * const scheduled = await client.triggers.create({
1071
+ * name: 'Daily Report',
1072
+ * functionId: 'function-uuid',
1073
+ * executionType: 'scheduled',
1074
+ * triggerMetadata: { scheduleType: 'cron', cronExpression: '0 9 * * *', timezone: 'America/New_York' }
1075
+ * });
1076
+ * ```
1077
+ */
1078
+ create(input) {
1079
+ const path = getFunctionTriggersApiPath(this.workspaceId);
1080
+ return this.requestFn('POST', path, input);
1081
+ }
1082
+ /**
1083
+ * Update an existing function trigger.
1084
+ *
1085
+ * @param triggerId - The trigger UUID
1086
+ * @param input - The fields to update
1087
+ * @returns The updated trigger
1088
+ *
1089
+ * @example
1090
+ * ```ts
1091
+ * const updated = await client.triggers.update('trigger-uuid', {
1092
+ * name: 'Updated Trigger Name',
1093
+ * enabled: false
1094
+ * });
1095
+ * ```
1096
+ */
1097
+ update(triggerId, input) {
1098
+ const path = getFunctionTriggersApiPath(this.workspaceId, triggerId);
1099
+ return this.requestFn('PUT', path, input);
1100
+ }
1101
+ /**
1102
+ * Delete a function trigger.
1103
+ *
1104
+ * @param triggerId - The trigger UUID
1105
+ *
1106
+ * @example
1107
+ * ```ts
1108
+ * await client.triggers.delete('trigger-uuid');
1109
+ * ```
1110
+ */
1111
+ delete(triggerId) {
1112
+ const path = getFunctionTriggersApiPath(this.workspaceId, triggerId);
1113
+ return this.requestFn('DELETE', path);
1114
+ }
1115
+ /**
1116
+ * List all triggers in the workspace (not filtered by execution type).
1117
+ * Unlike `list()` which only returns on-demand triggers, `listAll()` returns
1118
+ * triggers of all types with optional filtering.
1119
+ *
1120
+ * @param options - Optional list parameters (pagination, filtering, health)
1121
+ * @returns List of triggers
1122
+ *
1123
+ * @example
1124
+ * ```ts
1125
+ * // List all triggers
1126
+ * const all = await client.triggers.listAll();
1127
+ *
1128
+ * // Filter by execution type
1129
+ * const scheduled = await client.triggers.listAll({ executionType: 'scheduled' });
1130
+ *
1131
+ * // Include health metrics
1132
+ * const withHealth = await client.triggers.listAll({ includeHealth: true });
1133
+ * ```
1134
+ */
1135
+ listAll(options) {
1136
+ const path = getFunctionTriggersApiPath(this.workspaceId);
1137
+ return this.requestFn('GET', path, null, options);
1138
+ }
1139
+ /**
1140
+ * Get a trigger by ID with full details (no on-demand type restriction).
1141
+ * Unlike `get()` which validates on-demand type, `getDetails()` returns
1142
+ * any trigger type.
1143
+ *
1144
+ * @param triggerId - The trigger UUID
1145
+ * @param options - Optional parameters (includeHealth)
1146
+ * @returns The trigger details
1147
+ *
1148
+ * @example
1149
+ * ```ts
1150
+ * const trigger = await client.triggers.getDetails('trigger-uuid');
1151
+ *
1152
+ * // With health metrics
1153
+ * const withHealth = await client.triggers.getDetails('trigger-uuid', { includeHealth: true });
1154
+ * ```
1155
+ */
1156
+ getDetails(triggerId, options) {
1157
+ const path = getFunctionTriggersApiPath(this.workspaceId, triggerId);
1158
+ return this.requestFn('GET', path, null, options);
1159
+ }
993
1160
  }
994
1161
  exports.TriggersManager = TriggersManager;
995
1162
  // =====================================================
@@ -1133,6 +1300,92 @@ class SmartQueriesManager {
1133
1300
  const body = (options === null || options === void 0 ? void 0 : options.variables) ? { variables: options.variables } : undefined;
1134
1301
  return this.requestFn('POST', path, body);
1135
1302
  }
1303
+ /**
1304
+ * Create a new smart query for a structure.
1305
+ *
1306
+ * @param structureSlug - The structure's record slug
1307
+ * @param input - The smart query definition
1308
+ * @returns The created smart query
1309
+ *
1310
+ * @example
1311
+ * ```ts
1312
+ * const query = await client.smartQueries.create('orders', {
1313
+ * name: 'Active Orders',
1314
+ * description: 'All orders with active status',
1315
+ * queryDefinition: {
1316
+ * where: { status: { $eq: 'active' } },
1317
+ * sort: [{ field: 'createdAt', direction: 'desc' }],
1318
+ * limit: 100
1319
+ * }
1320
+ * });
1321
+ * ```
1322
+ */
1323
+ create(structureSlug, input) {
1324
+ const path = getSmartQueriesStructureApiPath(this.workspaceId, structureSlug);
1325
+ return this.requestFn('POST', path, input);
1326
+ }
1327
+ /**
1328
+ * Update an existing smart query.
1329
+ *
1330
+ * @param structureSlug - The structure's record slug
1331
+ * @param queryId - The smart query UUID
1332
+ * @param input - The fields to update
1333
+ * @returns The updated smart query
1334
+ *
1335
+ * @example
1336
+ * ```ts
1337
+ * const updated = await client.smartQueries.update('orders', 'query-uuid', {
1338
+ * name: 'Active Orders v2',
1339
+ * queryDefinition: {
1340
+ * where: { status: { $in: ['active', 'processing'] } },
1341
+ * limit: 200
1342
+ * }
1343
+ * });
1344
+ * ```
1345
+ */
1346
+ update(structureSlug, queryId, input) {
1347
+ const path = getSmartQueriesStructureApiPath(this.workspaceId, structureSlug, queryId);
1348
+ return this.requestFn('PUT', path, input);
1349
+ }
1350
+ /**
1351
+ * Delete a smart query.
1352
+ *
1353
+ * @param structureSlug - The structure's record slug
1354
+ * @param queryId - The smart query UUID
1355
+ *
1356
+ * @example
1357
+ * ```ts
1358
+ * await client.smartQueries.delete('orders', 'query-uuid');
1359
+ * ```
1360
+ */
1361
+ delete(structureSlug, queryId) {
1362
+ const path = getSmartQueriesStructureApiPath(this.workspaceId, structureSlug, queryId);
1363
+ return this.requestFn('DELETE', path);
1364
+ }
1365
+ /**
1366
+ * Test execute a query definition without saving it.
1367
+ * Useful for validating query syntax and previewing results before creating.
1368
+ *
1369
+ * @param structureSlug - The structure's record slug
1370
+ * @param input - The query definition to test and optional variables
1371
+ * @returns Test execution results
1372
+ *
1373
+ * @example
1374
+ * ```ts
1375
+ * const result = await client.smartQueries.test('orders', {
1376
+ * queryDefinition: {
1377
+ * where: { amount: { $gte: 100 } },
1378
+ * select: ['id', 'amount', 'status'],
1379
+ * limit: 5
1380
+ * }
1381
+ * });
1382
+ * console.log('Preview results:', result.data);
1383
+ * ```
1384
+ */
1385
+ test(structureSlug, input) {
1386
+ const path = getSmartQueryTestApiPath(this.workspaceId, structureSlug);
1387
+ return this.requestFn('POST', path, input);
1388
+ }
1136
1389
  }
1137
1390
  exports.SmartQueriesManager = SmartQueriesManager;
1138
1391
  // =====================================================
@@ -1626,6 +1879,313 @@ class AllowedDomainsManager {
1626
1879
  }
1627
1880
  }
1628
1881
  exports.AllowedDomainsManager = AllowedDomainsManager;
1882
+ // =====================================================
1883
+ // Structures Manager (Configuration-as-Code)
1884
+ // =====================================================
1885
+ /**
1886
+ * StructuresManager provides methods for managing data structures (schemas).
1887
+ * Structures define the shape of records including properties, validation rules,
1888
+ * and schema discovery modes.
1889
+ * Access via `client.structures`.
1890
+ *
1891
+ * Usage:
1892
+ * ```ts
1893
+ * // List all structures
1894
+ * const structures = await client.structures.list();
1895
+ *
1896
+ * // Create a new structure
1897
+ * const structure = await client.structures.create({
1898
+ * name: 'Orders',
1899
+ * slug: 'orders',
1900
+ * properties: [
1901
+ * { name: 'title', type: 'string', required: true },
1902
+ * { name: 'amount', type: 'number', minimum: 0 }
1903
+ * ]
1904
+ * });
1905
+ *
1906
+ * // Validate before creating
1907
+ * const validation = await client.structures.validate({ slug: 'orders' });
1908
+ * ```
1909
+ */
1910
+ class StructuresManager {
1911
+ constructor(workspaceId, requestFn) {
1912
+ this.workspaceId = workspaceId;
1913
+ this.requestFn = requestFn;
1914
+ }
1915
+ /**
1916
+ * List all structures in the workspace.
1917
+ *
1918
+ * @param options - Optional list parameters (pagination)
1919
+ * @returns List of structures
1920
+ *
1921
+ * @example
1922
+ * ```ts
1923
+ * const structures = await client.structures.list();
1924
+ * const page2 = await client.structures.list({ page: 2, limit: 10 });
1925
+ * ```
1926
+ */
1927
+ list(options) {
1928
+ const path = getStructuresApiPath(this.workspaceId);
1929
+ return this.requestFn('GET', path, null, options);
1930
+ }
1931
+ /**
1932
+ * Get a structure by ID.
1933
+ *
1934
+ * @param structureId - The structure UUID
1935
+ * @returns The structure details
1936
+ *
1937
+ * @example
1938
+ * ```ts
1939
+ * const structure = await client.structures.get('structure-uuid');
1940
+ * console.log('Properties:', structure.data.properties.length);
1941
+ * ```
1942
+ */
1943
+ get(structureId) {
1944
+ const path = getStructuresApiPath(this.workspaceId, structureId);
1945
+ return this.requestFn('GET', path);
1946
+ }
1947
+ /**
1948
+ * Get a structure by its record slug.
1949
+ *
1950
+ * @param recordSlug - The structure's record slug (e.g., "orders")
1951
+ * @returns The structure details
1952
+ *
1953
+ * @example
1954
+ * ```ts
1955
+ * const structure = await client.structures.getBySlug('orders');
1956
+ * console.log('Structure name:', structure.data.name);
1957
+ * ```
1958
+ */
1959
+ getBySlug(recordSlug) {
1960
+ const path = getStructureBySlugApiPath(this.workspaceId, recordSlug);
1961
+ return this.requestFn('GET', path);
1962
+ }
1963
+ /**
1964
+ * Create a new structure.
1965
+ *
1966
+ * @param input - The structure definition
1967
+ * @returns The created structure
1968
+ *
1969
+ * @example
1970
+ * ```ts
1971
+ * const structure = await client.structures.create({
1972
+ * name: 'Orders',
1973
+ * slug: 'orders',
1974
+ * description: 'Customer orders',
1975
+ * properties: [
1976
+ * { name: 'title', type: 'string', required: true },
1977
+ * { name: 'amount', type: 'number', minimum: 0 },
1978
+ * { name: 'status', type: 'string', enum: ['pending', 'completed'] }
1979
+ * ],
1980
+ * enableVersioning: true,
1981
+ * schemaDiscoveryMode: 'strict'
1982
+ * });
1983
+ * ```
1984
+ */
1985
+ create(input) {
1986
+ const path = getStructuresApiPath(this.workspaceId);
1987
+ return this.requestFn('POST', path, input);
1988
+ }
1989
+ /**
1990
+ * Update an existing structure.
1991
+ *
1992
+ * @param structureId - The structure UUID
1993
+ * @param input - The fields to update
1994
+ * @returns The updated structure
1995
+ *
1996
+ * @example
1997
+ * ```ts
1998
+ * const updated = await client.structures.update('structure-uuid', {
1999
+ * name: 'Updated Orders',
2000
+ * properties: [
2001
+ * { name: 'title', type: 'string', required: true },
2002
+ * { name: 'amount', type: 'number', minimum: 0 },
2003
+ * { name: 'priority', type: 'number' }
2004
+ * ]
2005
+ * });
2006
+ * ```
2007
+ */
2008
+ update(structureId, input) {
2009
+ const path = getStructuresApiPath(this.workspaceId, structureId);
2010
+ return this.requestFn('PUT', path, input);
2011
+ }
2012
+ /**
2013
+ * Delete a structure.
2014
+ *
2015
+ * @param structureId - The structure UUID
2016
+ *
2017
+ * @example
2018
+ * ```ts
2019
+ * await client.structures.delete('structure-uuid');
2020
+ * ```
2021
+ */
2022
+ delete(structureId) {
2023
+ const path = getStructuresApiPath(this.workspaceId, structureId);
2024
+ return this.requestFn('DELETE', path);
2025
+ }
2026
+ /**
2027
+ * Validate a structure definition without creating it.
2028
+ * Useful for checking slug uniqueness and property validity before creation.
2029
+ *
2030
+ * @param input - The structure definition to validate
2031
+ * @returns Validation result
2032
+ *
2033
+ * @example
2034
+ * ```ts
2035
+ * const result = await client.structures.validate({
2036
+ * slug: 'orders',
2037
+ * properties: [{ name: 'title', type: 'string' }]
2038
+ * });
2039
+ * ```
2040
+ */
2041
+ validate(input) {
2042
+ const path = getStructureValidateApiPath(this.workspaceId);
2043
+ return this.requestFn('POST', path, input);
2044
+ }
2045
+ }
2046
+ exports.StructuresManager = StructuresManager;
2047
+ // =====================================================
2048
+ // Compute Functions Manager (Configuration-as-Code)
2049
+ // =====================================================
2050
+ /**
2051
+ * ComputeFunctionsManager provides methods for managing compute functions.
2052
+ * Compute functions are JavaScript code blocks that can be executed on triggers,
2053
+ * schedules, or on-demand.
2054
+ * Access via `client.functions`.
2055
+ *
2056
+ * Usage:
2057
+ * ```ts
2058
+ * // List all compute functions
2059
+ * const fns = await client.functions.list();
2060
+ *
2061
+ * // Create a new function
2062
+ * const fn = await client.functions.create({
2063
+ * name: 'Process Order',
2064
+ * slug: 'process-order',
2065
+ * code: 'module.exports = async (ctx) => { return { processed: true }; }'
2066
+ * });
2067
+ *
2068
+ * // Test execute code without saving
2069
+ * const result = await client.functions.testExecute({
2070
+ * code: 'module.exports = async (ctx) => { return ctx.input; }',
2071
+ * input: { orderId: '123' }
2072
+ * });
2073
+ * ```
2074
+ */
2075
+ class ComputeFunctionsManager {
2076
+ constructor(workspaceId, requestFn) {
2077
+ this.workspaceId = workspaceId;
2078
+ this.requestFn = requestFn;
2079
+ }
2080
+ /**
2081
+ * List all compute functions in the workspace.
2082
+ *
2083
+ * @param options - Optional list parameters (pagination, search)
2084
+ * @returns List of compute functions
2085
+ *
2086
+ * @example
2087
+ * ```ts
2088
+ * const fns = await client.functions.list();
2089
+ * const searched = await client.functions.list({ search: 'order', limit: 10 });
2090
+ * ```
2091
+ */
2092
+ list(options) {
2093
+ const path = getComputeFunctionsApiPath(this.workspaceId);
2094
+ return this.requestFn('GET', path, null, options);
2095
+ }
2096
+ /**
2097
+ * Get a compute function by ID.
2098
+ *
2099
+ * @param functionId - The compute function UUID
2100
+ * @returns The compute function details
2101
+ *
2102
+ * @example
2103
+ * ```ts
2104
+ * const fn = await client.functions.get('function-uuid');
2105
+ * console.log('Function name:', fn.data.name);
2106
+ * ```
2107
+ */
2108
+ get(functionId) {
2109
+ const path = getComputeFunctionsApiPath(this.workspaceId, functionId);
2110
+ return this.requestFn('GET', path);
2111
+ }
2112
+ /**
2113
+ * Create a new compute function.
2114
+ *
2115
+ * @param input - The function definition
2116
+ * @returns The created compute function
2117
+ *
2118
+ * @example
2119
+ * ```ts
2120
+ * const fn = await client.functions.create({
2121
+ * name: 'Process Order',
2122
+ * slug: 'process-order',
2123
+ * code: 'module.exports = async (ctx) => { return { processed: true }; }',
2124
+ * description: 'Processes incoming orders',
2125
+ * timeout: 60000
2126
+ * });
2127
+ * ```
2128
+ */
2129
+ create(input) {
2130
+ const path = getComputeFunctionsApiPath(this.workspaceId);
2131
+ return this.requestFn('POST', path, input);
2132
+ }
2133
+ /**
2134
+ * Update an existing compute function.
2135
+ *
2136
+ * @param functionId - The compute function UUID
2137
+ * @param input - The fields to update
2138
+ * @returns The updated compute function
2139
+ *
2140
+ * @example
2141
+ * ```ts
2142
+ * const updated = await client.functions.update('function-uuid', {
2143
+ * code: 'module.exports = async (ctx) => { return { v2: true }; }',
2144
+ * timeout: 120000
2145
+ * });
2146
+ * ```
2147
+ */
2148
+ update(functionId, input) {
2149
+ const path = getComputeFunctionsApiPath(this.workspaceId, functionId);
2150
+ return this.requestFn('PUT', path, input);
2151
+ }
2152
+ /**
2153
+ * Delete a compute function.
2154
+ *
2155
+ * @param functionId - The compute function UUID
2156
+ *
2157
+ * @example
2158
+ * ```ts
2159
+ * await client.functions.delete('function-uuid');
2160
+ * ```
2161
+ */
2162
+ delete(functionId) {
2163
+ const path = getComputeFunctionsApiPath(this.workspaceId, functionId);
2164
+ return this.requestFn('DELETE', path);
2165
+ }
2166
+ /**
2167
+ * Test execute code without saving it as a function.
2168
+ * Useful for validating function code before creating/updating.
2169
+ *
2170
+ * @param input - The code to test and optional input data
2171
+ * @returns Test execution result including output, duration, and logs
2172
+ *
2173
+ * @example
2174
+ * ```ts
2175
+ * const result = await client.functions.testExecute({
2176
+ * code: 'module.exports = async (ctx) => { return { sum: ctx.input.a + ctx.input.b }; }',
2177
+ * input: { a: 1, b: 2 }
2178
+ * });
2179
+ * console.log('Output:', result.data.output); // { sum: 3 }
2180
+ * console.log('Duration:', result.data.duration_ms, 'ms');
2181
+ * ```
2182
+ */
2183
+ testExecute(input) {
2184
+ const path = getComputeFunctionTestApiPath(this.workspaceId);
2185
+ return this.requestFn('POST', path, input);
2186
+ }
2187
+ }
2188
+ exports.ComputeFunctionsManager = ComputeFunctionsManager;
1629
2189
  /**
1630
2190
  * Main Centrali SDK client.
1631
2191
  */
@@ -1639,6 +2199,8 @@ class CentraliSDK {
1639
2199
  this._validation = null;
1640
2200
  this._orchestrations = null;
1641
2201
  this._allowedDomains = null;
2202
+ this._structures = null;
2203
+ this._functions = null;
1642
2204
  this.isRefreshingToken = false;
1643
2205
  this.tokenRefreshPromise = null;
1644
2206
  this.options = options;
@@ -1907,6 +2469,61 @@ class CentraliSDK {
1907
2469
  }
1908
2470
  return this._allowedDomains;
1909
2471
  }
2472
+ /**
2473
+ * Structures namespace for managing data structures (schemas).
2474
+ * Provides CRUD operations and validation for structure definitions.
2475
+ *
2476
+ * Usage:
2477
+ * ```ts
2478
+ * // List all structures
2479
+ * const structures = await client.structures.list();
2480
+ *
2481
+ * // Create a structure
2482
+ * const structure = await client.structures.create({
2483
+ * name: 'Orders',
2484
+ * slug: 'orders',
2485
+ * properties: [{ name: 'title', type: 'string', required: true }]
2486
+ * });
2487
+ *
2488
+ * // Validate before creating
2489
+ * const result = await client.structures.validate({ slug: 'orders' });
2490
+ * ```
2491
+ */
2492
+ get structures() {
2493
+ if (!this._structures) {
2494
+ this._structures = new StructuresManager(this.options.workspaceId, this.request.bind(this));
2495
+ }
2496
+ return this._structures;
2497
+ }
2498
+ /**
2499
+ * Functions namespace for managing compute functions.
2500
+ * Provides CRUD operations and test execution for compute function code.
2501
+ *
2502
+ * Usage:
2503
+ * ```ts
2504
+ * // List all functions
2505
+ * const fns = await client.functions.list();
2506
+ *
2507
+ * // Create a function
2508
+ * const fn = await client.functions.create({
2509
+ * name: 'Process Order',
2510
+ * slug: 'process-order',
2511
+ * code: 'module.exports = async (ctx) => { return { ok: true }; }'
2512
+ * });
2513
+ *
2514
+ * // Test execute without saving
2515
+ * const result = await client.functions.testExecute({
2516
+ * code: 'module.exports = async (ctx) => { return ctx.input; }',
2517
+ * input: { test: true }
2518
+ * });
2519
+ * ```
2520
+ */
2521
+ get functions() {
2522
+ if (!this._functions) {
2523
+ this._functions = new ComputeFunctionsManager(this.options.workspaceId, this.request.bind(this));
2524
+ }
2525
+ return this._functions;
2526
+ }
1910
2527
  /**
1911
2528
  * Manually set or update the bearer token for subsequent requests.
1912
2529
  */