@axonflow/sdk 1.14.0 → 2.1.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/cjs/client.d.ts +61 -10
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +201 -56
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/types/config.d.ts +2 -10
- package/dist/cjs/types/config.d.ts.map +1 -1
- package/dist/cjs/types/gateway.d.ts +83 -0
- package/dist/cjs/types/gateway.d.ts.map +1 -1
- package/dist/cjs/types/policies.d.ts +14 -1
- package/dist/cjs/types/policies.d.ts.map +1 -1
- package/dist/esm/client.d.ts +61 -10
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +201 -56
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/types/config.d.ts +2 -10
- package/dist/esm/types/config.d.ts.map +1 -1
- package/dist/esm/types/gateway.d.ts +83 -0
- package/dist/esm/types/gateway.d.ts.map +1 -1
- package/dist/esm/types/policies.d.ts +14 -1
- package/dist/esm/types/policies.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAId,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EAEZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EAExB,eAAe,EACf,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,cAAc,EAEd,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EAEtB,MAAM,EACN,eAAe,EACf,YAAY,EAEZ,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,cAAc,EAGd,oBAAoB,EAEpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAOjB;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAId,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAEjB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EAEZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EAExB,eAAe,EACf,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,cAAc,EAEd,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,sBAAsB,EAC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AQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAuBtE;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IA6BvE;;;;;OAKG;IACG,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAe7D;;;;;;OAMG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA6BlF;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoCxF;;;;;;OAMG;IACG,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA2BjF,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,kBAAkB;IAY1B;;;;OAIG;YACW,iBAAiB;CAkChC"}
|
package/dist/esm/client.js
CHANGED
|
@@ -19,8 +19,6 @@ export class AxonFlow {
|
|
|
19
19
|
apiKey: config.apiKey,
|
|
20
20
|
licenseKey: config.licenseKey,
|
|
21
21
|
endpoint,
|
|
22
|
-
orchestratorEndpoint: config.orchestratorEndpoint,
|
|
23
|
-
portalEndpoint: config.portalEndpoint,
|
|
24
22
|
mode: config.mode || (hasCredentials ? 'production' : 'sandbox'),
|
|
25
23
|
tenant: config.tenant || 'default',
|
|
26
24
|
debug: config.debug || false,
|
|
@@ -324,7 +322,7 @@ export class AxonFlow {
|
|
|
324
322
|
* ```
|
|
325
323
|
*/
|
|
326
324
|
async orchestratorHealthCheck() {
|
|
327
|
-
const url = `${this.
|
|
325
|
+
const url = `${this.config.endpoint}/health`;
|
|
328
326
|
try {
|
|
329
327
|
const response = await fetch(url, {
|
|
330
328
|
method: 'GET',
|
|
@@ -782,6 +780,7 @@ export class AxonFlow {
|
|
|
782
780
|
const result = {
|
|
783
781
|
contextId: data.context_id,
|
|
784
782
|
approved: data.approved,
|
|
783
|
+
requiresRedaction: data.requires_redaction || false,
|
|
785
784
|
approvedData: data.approved_data || {},
|
|
786
785
|
policies: data.policies || [],
|
|
787
786
|
expiresAt,
|
|
@@ -886,6 +885,153 @@ export class AxonFlow {
|
|
|
886
885
|
return result;
|
|
887
886
|
}
|
|
888
887
|
// ============================================================================
|
|
888
|
+
// Audit Log Read Methods
|
|
889
|
+
// ============================================================================
|
|
890
|
+
/**
|
|
891
|
+
* Search audit logs with optional filters.
|
|
892
|
+
*
|
|
893
|
+
* Query the AxonFlow orchestrator for audit logs matching the specified
|
|
894
|
+
* criteria. Use this for compliance dashboards, security investigations,
|
|
895
|
+
* and operational monitoring.
|
|
896
|
+
*
|
|
897
|
+
* @param request - Search filters and pagination options
|
|
898
|
+
* @returns Promise resolving to audit search response
|
|
899
|
+
*
|
|
900
|
+
* @example
|
|
901
|
+
* ```typescript
|
|
902
|
+
* // Search for logs from a specific user in the last 24 hours
|
|
903
|
+
* const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000);
|
|
904
|
+
* const result = await client.searchAuditLogs({
|
|
905
|
+
* userEmail: 'analyst@company.com',
|
|
906
|
+
* startTime: yesterday,
|
|
907
|
+
* limit: 100,
|
|
908
|
+
* });
|
|
909
|
+
*
|
|
910
|
+
* for (const entry of result.entries) {
|
|
911
|
+
* console.log(`[${entry.timestamp}] ${entry.userEmail}: ${entry.querySummary}`);
|
|
912
|
+
* }
|
|
913
|
+
* ```
|
|
914
|
+
*/
|
|
915
|
+
async searchAuditLogs(request) {
|
|
916
|
+
const limit = Math.min(request?.limit ?? 100, 1000);
|
|
917
|
+
const offset = request?.offset ?? 0;
|
|
918
|
+
// Build request body with only defined values
|
|
919
|
+
const body = { limit };
|
|
920
|
+
if (request?.userEmail)
|
|
921
|
+
body.user_email = request.userEmail;
|
|
922
|
+
if (request?.clientId)
|
|
923
|
+
body.client_id = request.clientId;
|
|
924
|
+
if (request?.startTime)
|
|
925
|
+
body.start_time = request.startTime.toISOString();
|
|
926
|
+
if (request?.endTime)
|
|
927
|
+
body.end_time = request.endTime.toISOString();
|
|
928
|
+
if (request?.requestType)
|
|
929
|
+
body.request_type = request.requestType;
|
|
930
|
+
if (offset > 0)
|
|
931
|
+
body.offset = offset;
|
|
932
|
+
if (this.config.debug) {
|
|
933
|
+
debugLog('Searching audit logs', { limit, offset });
|
|
934
|
+
}
|
|
935
|
+
const response = await this.orchestratorRequest('POST', '/api/v1/audit/search', body);
|
|
936
|
+
// Handle both array and wrapped response formats
|
|
937
|
+
if (Array.isArray(response)) {
|
|
938
|
+
const entries = response.map(e => this.parseAuditLogEntry(e));
|
|
939
|
+
return {
|
|
940
|
+
entries,
|
|
941
|
+
total: entries.length,
|
|
942
|
+
limit,
|
|
943
|
+
offset,
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
const data = response;
|
|
947
|
+
const entries = (data.entries || []).map(e => this.parseAuditLogEntry(e));
|
|
948
|
+
return {
|
|
949
|
+
entries,
|
|
950
|
+
total: data.total ?? entries.length,
|
|
951
|
+
limit: data.limit ?? limit,
|
|
952
|
+
offset: data.offset ?? offset,
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Get recent audit logs for a specific tenant.
|
|
957
|
+
*
|
|
958
|
+
* Convenience method for tenant-scoped audit queries. Use this when you
|
|
959
|
+
* need to view all recent activity for a specific tenant.
|
|
960
|
+
*
|
|
961
|
+
* @param tenantId - The tenant identifier to query
|
|
962
|
+
* @param options - Pagination options (limit, offset)
|
|
963
|
+
* @returns Promise resolving to audit search response
|
|
964
|
+
* @throws Error if tenantId is empty
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
* ```typescript
|
|
968
|
+
* // Get the last 50 audit logs for a tenant
|
|
969
|
+
* const result = await client.getAuditLogsByTenant('tenant-abc');
|
|
970
|
+
* console.log(`Found ${result.entries.length} entries`);
|
|
971
|
+
*
|
|
972
|
+
* // With custom options
|
|
973
|
+
* const result2 = await client.getAuditLogsByTenant('tenant-abc', {
|
|
974
|
+
* limit: 100,
|
|
975
|
+
* offset: 50,
|
|
976
|
+
* });
|
|
977
|
+
* ```
|
|
978
|
+
*/
|
|
979
|
+
async getAuditLogsByTenant(tenantId, options) {
|
|
980
|
+
if (!tenantId) {
|
|
981
|
+
throw new Error('tenantId is required');
|
|
982
|
+
}
|
|
983
|
+
const limit = Math.min(options?.limit ?? 50, 1000);
|
|
984
|
+
const offset = options?.offset ?? 0;
|
|
985
|
+
if (this.config.debug) {
|
|
986
|
+
debugLog('Getting audit logs for tenant', { tenantId, limit, offset });
|
|
987
|
+
}
|
|
988
|
+
const path = `/api/v1/audit/tenant/${encodeURIComponent(tenantId)}?limit=${limit}&offset=${offset}`;
|
|
989
|
+
const response = await this.orchestratorRequest('GET', path);
|
|
990
|
+
// Handle both array and wrapped response formats
|
|
991
|
+
if (Array.isArray(response)) {
|
|
992
|
+
const entries = response.map(e => this.parseAuditLogEntry(e));
|
|
993
|
+
return {
|
|
994
|
+
entries,
|
|
995
|
+
total: entries.length,
|
|
996
|
+
limit,
|
|
997
|
+
offset,
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
const data = response;
|
|
1001
|
+
const entries = (data.entries || []).map(e => this.parseAuditLogEntry(e));
|
|
1002
|
+
return {
|
|
1003
|
+
entries,
|
|
1004
|
+
total: data.total ?? entries.length,
|
|
1005
|
+
limit: data.limit ?? limit,
|
|
1006
|
+
offset: data.offset ?? offset,
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Parse a raw audit log entry from the API into the typed interface
|
|
1011
|
+
*/
|
|
1012
|
+
parseAuditLogEntry(raw) {
|
|
1013
|
+
const data = raw;
|
|
1014
|
+
return {
|
|
1015
|
+
id: data.id ?? '',
|
|
1016
|
+
requestId: data.request_id ?? '',
|
|
1017
|
+
timestamp: data.timestamp ? new Date(data.timestamp) : new Date(),
|
|
1018
|
+
userEmail: data.user_email ?? '',
|
|
1019
|
+
clientId: data.client_id ?? '',
|
|
1020
|
+
tenantId: data.tenant_id ?? '',
|
|
1021
|
+
requestType: data.request_type ?? '',
|
|
1022
|
+
querySummary: data.query_summary ?? '',
|
|
1023
|
+
success: data.success ?? true,
|
|
1024
|
+
blocked: data.blocked ?? false,
|
|
1025
|
+
riskScore: data.risk_score ?? 0,
|
|
1026
|
+
provider: data.provider ?? '',
|
|
1027
|
+
model: data.model ?? '',
|
|
1028
|
+
tokensUsed: data.tokens_used ?? 0,
|
|
1029
|
+
latencyMs: data.latency_ms ?? 0,
|
|
1030
|
+
policyViolations: data.policy_violations ?? [],
|
|
1031
|
+
metadata: data.metadata ?? {},
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
// ============================================================================
|
|
889
1035
|
// Policy CRUD Methods - Static Policies
|
|
890
1036
|
// ============================================================================
|
|
891
1037
|
/**
|
|
@@ -895,9 +1041,9 @@ export class AxonFlow {
|
|
|
895
1041
|
const headers = {
|
|
896
1042
|
'Content-Type': 'application/json',
|
|
897
1043
|
};
|
|
898
|
-
// Always include tenant ID for policy APIs
|
|
1044
|
+
// Always include tenant ID for policy APIs (X-Org-ID header for server compatibility)
|
|
899
1045
|
if (this.config.tenant) {
|
|
900
|
-
headers['X-
|
|
1046
|
+
headers['X-Org-ID'] = this.config.tenant;
|
|
901
1047
|
}
|
|
902
1048
|
// Add auth headers only when credentials are provided
|
|
903
1049
|
// Community/self-hosted mode works without credentials
|
|
@@ -1169,7 +1315,16 @@ export class AxonFlow {
|
|
|
1169
1315
|
debugLog('Getting static policy versions', { id });
|
|
1170
1316
|
}
|
|
1171
1317
|
const response = await this.policyRequest('GET', `/api/v1/static-policies/${id}/versions`);
|
|
1172
|
-
|
|
1318
|
+
// Transform snake_case API response to camelCase
|
|
1319
|
+
return response.versions.map(v => ({
|
|
1320
|
+
version: v.version,
|
|
1321
|
+
changedBy: v.changed_by,
|
|
1322
|
+
changedAt: v.changed_at,
|
|
1323
|
+
changeType: v.change_type,
|
|
1324
|
+
changeDescription: v.change_description,
|
|
1325
|
+
previousValues: v.previous_values,
|
|
1326
|
+
newValues: v.new_values,
|
|
1327
|
+
}));
|
|
1173
1328
|
}
|
|
1174
1329
|
// ============================================================================
|
|
1175
1330
|
// Policy Override Methods (Enterprise)
|
|
@@ -1270,11 +1425,14 @@ export class AxonFlow {
|
|
|
1270
1425
|
if (options?.search)
|
|
1271
1426
|
params.set('search', options.search);
|
|
1272
1427
|
const queryString = params.toString();
|
|
1273
|
-
const path = `/api/v1/policies
|
|
1428
|
+
const path = `/api/v1/dynamic-policies${queryString ? `?${queryString}` : ''}`;
|
|
1274
1429
|
if (this.config.debug) {
|
|
1275
1430
|
debugLog('Listing dynamic policies', { options });
|
|
1276
1431
|
}
|
|
1277
|
-
|
|
1432
|
+
// API returns {"policies": [...]} wrapper via Agent proxy
|
|
1433
|
+
const response = await this.orchestratorRequest('GET', path);
|
|
1434
|
+
// Handle both wrapped and unwrapped responses for compatibility
|
|
1435
|
+
return Array.isArray(response) ? response : response.policies;
|
|
1278
1436
|
}
|
|
1279
1437
|
/**
|
|
1280
1438
|
* Get a specific dynamic policy by ID.
|
|
@@ -1286,7 +1444,10 @@ export class AxonFlow {
|
|
|
1286
1444
|
if (this.config.debug) {
|
|
1287
1445
|
debugLog('Getting dynamic policy', { id });
|
|
1288
1446
|
}
|
|
1289
|
-
|
|
1447
|
+
// API returns {"policy": {...}} wrapper via Agent proxy
|
|
1448
|
+
const response = await this.orchestratorRequest('GET', `/api/v1/dynamic-policies/${id}`);
|
|
1449
|
+
// Handle both wrapped and unwrapped responses for compatibility
|
|
1450
|
+
return 'policy' in response ? response.policy : response;
|
|
1290
1451
|
}
|
|
1291
1452
|
/**
|
|
1292
1453
|
* Create a new dynamic policy.
|
|
@@ -1311,7 +1472,10 @@ export class AxonFlow {
|
|
|
1311
1472
|
if (this.config.debug) {
|
|
1312
1473
|
debugLog('Creating dynamic policy', { name: policy.name });
|
|
1313
1474
|
}
|
|
1314
|
-
|
|
1475
|
+
// API returns {"policy": {...}} wrapper via Agent proxy
|
|
1476
|
+
const response = await this.orchestratorRequest('POST', '/api/v1/dynamic-policies', policy);
|
|
1477
|
+
// Handle both wrapped and unwrapped responses for compatibility
|
|
1478
|
+
return 'policy' in response ? response.policy : response;
|
|
1315
1479
|
}
|
|
1316
1480
|
/**
|
|
1317
1481
|
* Update an existing dynamic policy.
|
|
@@ -1324,7 +1488,10 @@ export class AxonFlow {
|
|
|
1324
1488
|
if (this.config.debug) {
|
|
1325
1489
|
debugLog('Updating dynamic policy', { id, updates: Object.keys(policy) });
|
|
1326
1490
|
}
|
|
1327
|
-
|
|
1491
|
+
// API returns {"policy": {...}} wrapper via Agent proxy
|
|
1492
|
+
const response = await this.orchestratorRequest('PUT', `/api/v1/dynamic-policies/${id}`, policy);
|
|
1493
|
+
// Handle both wrapped and unwrapped responses for compatibility
|
|
1494
|
+
return 'policy' in response ? response.policy : response;
|
|
1328
1495
|
}
|
|
1329
1496
|
/**
|
|
1330
1497
|
* Delete a dynamic policy.
|
|
@@ -1335,7 +1502,7 @@ export class AxonFlow {
|
|
|
1335
1502
|
if (this.config.debug) {
|
|
1336
1503
|
debugLog('Deleting dynamic policy', { id });
|
|
1337
1504
|
}
|
|
1338
|
-
await this.orchestratorRequest('DELETE', `/api/v1/policies
|
|
1505
|
+
await this.orchestratorRequest('DELETE', `/api/v1/dynamic-policies/${id}`);
|
|
1339
1506
|
}
|
|
1340
1507
|
/**
|
|
1341
1508
|
* Toggle a dynamic policy's enabled status.
|
|
@@ -1348,9 +1515,10 @@ export class AxonFlow {
|
|
|
1348
1515
|
if (this.config.debug) {
|
|
1349
1516
|
debugLog('Toggling dynamic policy', { id, enabled });
|
|
1350
1517
|
}
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1518
|
+
// API returns {"policy": {...}} wrapper via Agent proxy
|
|
1519
|
+
const response = await this.orchestratorRequest('PUT', `/api/v1/dynamic-policies/${id}`, { enabled });
|
|
1520
|
+
// Handle both wrapped and unwrapped responses for compatibility
|
|
1521
|
+
return 'policy' in response ? response.policy : response;
|
|
1354
1522
|
}
|
|
1355
1523
|
/**
|
|
1356
1524
|
* Get effective dynamic policies with tier inheritance applied.
|
|
@@ -1365,11 +1533,14 @@ export class AxonFlow {
|
|
|
1365
1533
|
if (options?.includeDisabled)
|
|
1366
1534
|
params.set('include_disabled', 'true');
|
|
1367
1535
|
const queryString = params.toString();
|
|
1368
|
-
const path = `/api/v1/policies/
|
|
1536
|
+
const path = `/api/v1/dynamic-policies/effective${queryString ? `?${queryString}` : ''}`;
|
|
1369
1537
|
if (this.config.debug) {
|
|
1370
1538
|
debugLog('Getting effective dynamic policies', { options });
|
|
1371
1539
|
}
|
|
1372
|
-
|
|
1540
|
+
// API returns {"policies": [...]} wrapper via Agent proxy
|
|
1541
|
+
const response = await this.orchestratorRequest('GET', path);
|
|
1542
|
+
// Handle both wrapped and unwrapped responses for compatibility
|
|
1543
|
+
return Array.isArray(response) ? response : response.policies;
|
|
1373
1544
|
}
|
|
1374
1545
|
// ============================================================================
|
|
1375
1546
|
// Portal Authentication Methods (Enterprise)
|
|
@@ -1392,7 +1563,7 @@ export class AxonFlow {
|
|
|
1392
1563
|
* ```
|
|
1393
1564
|
*/
|
|
1394
1565
|
async loginToPortal(orgId, password) {
|
|
1395
|
-
const url = `${this.
|
|
1566
|
+
const url = `${this.config.endpoint}/api/v1/auth/login`;
|
|
1396
1567
|
const response = await fetch(url, {
|
|
1397
1568
|
method: 'POST',
|
|
1398
1569
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -1435,7 +1606,7 @@ export class AxonFlow {
|
|
|
1435
1606
|
return;
|
|
1436
1607
|
}
|
|
1437
1608
|
try {
|
|
1438
|
-
await fetch(`${this.
|
|
1609
|
+
await fetch(`${this.config.endpoint}/api/v1/auth/logout`, {
|
|
1439
1610
|
method: 'POST',
|
|
1440
1611
|
headers: { Cookie: `axonflow_session=${this.sessionCookie}` },
|
|
1441
1612
|
signal: AbortSignal.timeout(this.config.timeout),
|
|
@@ -1916,28 +2087,17 @@ export class AxonFlow {
|
|
|
1916
2087
|
// Execution Replay Methods
|
|
1917
2088
|
// ============================================================================
|
|
1918
2089
|
/**
|
|
1919
|
-
* Get the
|
|
1920
|
-
*
|
|
2090
|
+
* Get the endpoint URL for API requests.
|
|
2091
|
+
* All routes now go through the single Agent endpoint (ADR-026).
|
|
1921
2092
|
*/
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
return this.config.orchestratorEndpoint;
|
|
1925
|
-
}
|
|
1926
|
-
// Default: assume orchestrator is on same host as agent, port 8081
|
|
1927
|
-
try {
|
|
1928
|
-
const url = new URL(this.config.endpoint);
|
|
1929
|
-
url.port = '8081';
|
|
1930
|
-
return url.toString().replace(/\/$/, '');
|
|
1931
|
-
}
|
|
1932
|
-
catch {
|
|
1933
|
-
return 'http://localhost:8081';
|
|
1934
|
-
}
|
|
2093
|
+
getEndpointUrl() {
|
|
2094
|
+
return this.config.endpoint;
|
|
1935
2095
|
}
|
|
1936
2096
|
/**
|
|
1937
|
-
* Generic HTTP request helper for
|
|
2097
|
+
* Generic HTTP request helper for APIs (routes through single endpoint per ADR-026)
|
|
1938
2098
|
*/
|
|
1939
2099
|
async orchestratorRequest(method, path, body) {
|
|
1940
|
-
const url = `${this.
|
|
2100
|
+
const url = `${this.config.endpoint}${path}`;
|
|
1941
2101
|
const headers = this.buildAuthHeaders();
|
|
1942
2102
|
const options = {
|
|
1943
2103
|
method,
|
|
@@ -1964,33 +2124,18 @@ export class AxonFlow {
|
|
|
1964
2124
|
}
|
|
1965
2125
|
return response.json();
|
|
1966
2126
|
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
* Falls back to agent endpoint with port 8082 if not configured.
|
|
1970
|
-
*/
|
|
1971
|
-
getPortalUrl() {
|
|
1972
|
-
if (this.config.portalEndpoint) {
|
|
1973
|
-
return this.config.portalEndpoint;
|
|
1974
|
-
}
|
|
1975
|
-
// Default: assume portal is on same host as agent, port 8082
|
|
1976
|
-
try {
|
|
1977
|
-
const url = new URL(this.config.endpoint);
|
|
1978
|
-
url.port = '8082';
|
|
1979
|
-
return url.toString().replace(/\/$/, '');
|
|
1980
|
-
}
|
|
1981
|
-
catch {
|
|
1982
|
-
return 'http://localhost:8082';
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
2127
|
+
// Note: getPortalUrl() was removed in v2.0.0 (ADR-026 Single Entry Point).
|
|
2128
|
+
// All routes now go through the single Agent endpoint (this.config.endpoint).
|
|
1985
2129
|
/**
|
|
1986
2130
|
* Generic HTTP request helper for Customer Portal APIs (enterprise features).
|
|
2131
|
+
* Routes through single endpoint per ADR-026.
|
|
1987
2132
|
* Requires prior authentication via loginToPortal().
|
|
1988
2133
|
*/
|
|
1989
2134
|
async portalRequest(method, path, body) {
|
|
1990
2135
|
if (!this.sessionCookie) {
|
|
1991
2136
|
throw new AuthenticationError('Not logged in to Customer Portal. Call loginToPortal() first.');
|
|
1992
2137
|
}
|
|
1993
|
-
const url = `${this.
|
|
2138
|
+
const url = `${this.config.endpoint}${path}`;
|
|
1994
2139
|
const headers = {
|
|
1995
2140
|
'Content-Type': 'application/json',
|
|
1996
2141
|
Cookie: `axonflow_session=${this.sessionCookie}`,
|
|
@@ -2588,7 +2733,7 @@ export class AxonFlow {
|
|
|
2588
2733
|
if (!this.sessionCookie) {
|
|
2589
2734
|
throw new AuthenticationError('Not logged in to Customer Portal. Call loginToPortal() first.');
|
|
2590
2735
|
}
|
|
2591
|
-
const url = `${this.
|
|
2736
|
+
const url = `${this.config.endpoint}${path}`;
|
|
2592
2737
|
const headers = {
|
|
2593
2738
|
Cookie: `axonflow_session=${this.sessionCookie}`,
|
|
2594
2739
|
};
|