@axonflow/sdk 1.13.0 → 2.0.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 +120 -5
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +363 -37
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/types/config.d.ts +2 -5
- 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 +1 -1
- package/dist/cjs/types/policies.d.ts.map +1 -1
- package/dist/esm/client.d.ts +120 -5
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +363 -37
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/types/config.d.ts +2 -5
- 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 +1 -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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,QAAQ,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
|
@@ -8,6 +8,7 @@ import { generateRequestId, debugLog } from './utils/helpers.js';
|
|
|
8
8
|
export class AxonFlow {
|
|
9
9
|
constructor(config) {
|
|
10
10
|
this.interceptors = [];
|
|
11
|
+
this.sessionCookie = null;
|
|
11
12
|
// Set defaults first to determine endpoint
|
|
12
13
|
const endpoint = config.endpoint || 'https://staging-eu.getaxonflow.com';
|
|
13
14
|
// Credentials are optional for community/self-hosted deployments
|
|
@@ -18,7 +19,6 @@ export class AxonFlow {
|
|
|
18
19
|
apiKey: config.apiKey,
|
|
19
20
|
licenseKey: config.licenseKey,
|
|
20
21
|
endpoint,
|
|
21
|
-
orchestratorEndpoint: config.orchestratorEndpoint,
|
|
22
22
|
mode: config.mode || (hasCredentials ? 'production' : 'sandbox'),
|
|
23
23
|
tenant: config.tenant || 'default',
|
|
24
24
|
debug: config.debug || false,
|
|
@@ -322,7 +322,7 @@ export class AxonFlow {
|
|
|
322
322
|
* ```
|
|
323
323
|
*/
|
|
324
324
|
async orchestratorHealthCheck() {
|
|
325
|
-
const url = `${this.
|
|
325
|
+
const url = `${this.config.endpoint}/health`;
|
|
326
326
|
try {
|
|
327
327
|
const response = await fetch(url, {
|
|
328
328
|
method: 'GET',
|
|
@@ -780,6 +780,7 @@ export class AxonFlow {
|
|
|
780
780
|
const result = {
|
|
781
781
|
contextId: data.context_id,
|
|
782
782
|
approved: data.approved,
|
|
783
|
+
requiresRedaction: data.requires_redaction || false,
|
|
783
784
|
approvedData: data.approved_data || {},
|
|
784
785
|
policies: data.policies || [],
|
|
785
786
|
expiresAt,
|
|
@@ -884,6 +885,153 @@ export class AxonFlow {
|
|
|
884
885
|
return result;
|
|
885
886
|
}
|
|
886
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
|
+
// ============================================================================
|
|
887
1035
|
// Policy CRUD Methods - Static Policies
|
|
888
1036
|
// ============================================================================
|
|
889
1037
|
/**
|
|
@@ -1268,7 +1416,7 @@ export class AxonFlow {
|
|
|
1268
1416
|
if (options?.search)
|
|
1269
1417
|
params.set('search', options.search);
|
|
1270
1418
|
const queryString = params.toString();
|
|
1271
|
-
const path = `/api/v1/policies
|
|
1419
|
+
const path = `/api/v1/dynamic-policies${queryString ? `?${queryString}` : ''}`;
|
|
1272
1420
|
if (this.config.debug) {
|
|
1273
1421
|
debugLog('Listing dynamic policies', { options });
|
|
1274
1422
|
}
|
|
@@ -1284,7 +1432,7 @@ export class AxonFlow {
|
|
|
1284
1432
|
if (this.config.debug) {
|
|
1285
1433
|
debugLog('Getting dynamic policy', { id });
|
|
1286
1434
|
}
|
|
1287
|
-
return this.orchestratorRequest('GET', `/api/v1/policies
|
|
1435
|
+
return this.orchestratorRequest('GET', `/api/v1/dynamic-policies/${id}`);
|
|
1288
1436
|
}
|
|
1289
1437
|
/**
|
|
1290
1438
|
* Create a new dynamic policy.
|
|
@@ -1309,7 +1457,7 @@ export class AxonFlow {
|
|
|
1309
1457
|
if (this.config.debug) {
|
|
1310
1458
|
debugLog('Creating dynamic policy', { name: policy.name });
|
|
1311
1459
|
}
|
|
1312
|
-
return this.orchestratorRequest('POST', '/api/v1/policies
|
|
1460
|
+
return this.orchestratorRequest('POST', '/api/v1/dynamic-policies', policy);
|
|
1313
1461
|
}
|
|
1314
1462
|
/**
|
|
1315
1463
|
* Update an existing dynamic policy.
|
|
@@ -1322,7 +1470,7 @@ export class AxonFlow {
|
|
|
1322
1470
|
if (this.config.debug) {
|
|
1323
1471
|
debugLog('Updating dynamic policy', { id, updates: Object.keys(policy) });
|
|
1324
1472
|
}
|
|
1325
|
-
return this.orchestratorRequest('PUT', `/api/v1/policies
|
|
1473
|
+
return this.orchestratorRequest('PUT', `/api/v1/dynamic-policies/${id}`, policy);
|
|
1326
1474
|
}
|
|
1327
1475
|
/**
|
|
1328
1476
|
* Delete a dynamic policy.
|
|
@@ -1333,7 +1481,7 @@ export class AxonFlow {
|
|
|
1333
1481
|
if (this.config.debug) {
|
|
1334
1482
|
debugLog('Deleting dynamic policy', { id });
|
|
1335
1483
|
}
|
|
1336
|
-
await this.orchestratorRequest('DELETE', `/api/v1/policies
|
|
1484
|
+
await this.orchestratorRequest('DELETE', `/api/v1/dynamic-policies/${id}`);
|
|
1337
1485
|
}
|
|
1338
1486
|
/**
|
|
1339
1487
|
* Toggle a dynamic policy's enabled status.
|
|
@@ -1346,7 +1494,7 @@ export class AxonFlow {
|
|
|
1346
1494
|
if (this.config.debug) {
|
|
1347
1495
|
debugLog('Toggling dynamic policy', { id, enabled });
|
|
1348
1496
|
}
|
|
1349
|
-
return this.orchestratorRequest('PATCH', `/api/v1/policies
|
|
1497
|
+
return this.orchestratorRequest('PATCH', `/api/v1/dynamic-policies/${id}`, {
|
|
1350
1498
|
enabled,
|
|
1351
1499
|
});
|
|
1352
1500
|
}
|
|
@@ -1363,13 +1511,97 @@ export class AxonFlow {
|
|
|
1363
1511
|
if (options?.includeDisabled)
|
|
1364
1512
|
params.set('include_disabled', 'true');
|
|
1365
1513
|
const queryString = params.toString();
|
|
1366
|
-
const path = `/api/v1/policies/
|
|
1514
|
+
const path = `/api/v1/dynamic-policies/effective${queryString ? `?${queryString}` : ''}`;
|
|
1367
1515
|
if (this.config.debug) {
|
|
1368
1516
|
debugLog('Getting effective dynamic policies', { options });
|
|
1369
1517
|
}
|
|
1370
1518
|
return this.orchestratorRequest('GET', path);
|
|
1371
1519
|
}
|
|
1372
1520
|
// ============================================================================
|
|
1521
|
+
// Portal Authentication Methods (Enterprise)
|
|
1522
|
+
// ============================================================================
|
|
1523
|
+
/**
|
|
1524
|
+
* Login to Customer Portal and store session cookie.
|
|
1525
|
+
* Required before using Code Governance methods.
|
|
1526
|
+
*
|
|
1527
|
+
* @param orgId - Organization ID
|
|
1528
|
+
* @param password - Organization password
|
|
1529
|
+
* @returns Login response with session info
|
|
1530
|
+
*
|
|
1531
|
+
* @example
|
|
1532
|
+
* ```typescript
|
|
1533
|
+
* const login = await axonflow.loginToPortal('test-org-001', 'test123');
|
|
1534
|
+
* console.log(`Logged in as ${login.name}`);
|
|
1535
|
+
*
|
|
1536
|
+
* // Now you can use Code Governance methods
|
|
1537
|
+
* const providers = await axonflow.listGitProviders();
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
async loginToPortal(orgId, password) {
|
|
1541
|
+
const url = `${this.config.endpoint}/api/v1/auth/login`;
|
|
1542
|
+
const response = await fetch(url, {
|
|
1543
|
+
method: 'POST',
|
|
1544
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1545
|
+
body: JSON.stringify({ org_id: orgId, password }),
|
|
1546
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
1547
|
+
});
|
|
1548
|
+
if (!response.ok) {
|
|
1549
|
+
const errorText = await response.text();
|
|
1550
|
+
throw new AuthenticationError(`Login failed: ${errorText}`);
|
|
1551
|
+
}
|
|
1552
|
+
const result = (await response.json());
|
|
1553
|
+
// Extract session cookie from response
|
|
1554
|
+
const cookies = response.headers.get('set-cookie');
|
|
1555
|
+
if (cookies) {
|
|
1556
|
+
const match = cookies.match(/axonflow_session=([^;]+)/);
|
|
1557
|
+
if (match) {
|
|
1558
|
+
this.sessionCookie = match[1];
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
// Fallback to session_id in response body
|
|
1562
|
+
if (!this.sessionCookie && result.session_id) {
|
|
1563
|
+
this.sessionCookie = result.session_id;
|
|
1564
|
+
}
|
|
1565
|
+
if (this.config.debug) {
|
|
1566
|
+
debugLog('Portal login successful', { orgId });
|
|
1567
|
+
}
|
|
1568
|
+
return {
|
|
1569
|
+
sessionId: result.session_id,
|
|
1570
|
+
orgId: result.org_id,
|
|
1571
|
+
email: result.email,
|
|
1572
|
+
name: result.name,
|
|
1573
|
+
expiresAt: result.expires_at,
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Logout from Customer Portal and clear session cookie.
|
|
1578
|
+
*/
|
|
1579
|
+
async logoutFromPortal() {
|
|
1580
|
+
if (!this.sessionCookie) {
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
try {
|
|
1584
|
+
await fetch(`${this.config.endpoint}/api/v1/auth/logout`, {
|
|
1585
|
+
method: 'POST',
|
|
1586
|
+
headers: { Cookie: `axonflow_session=${this.sessionCookie}` },
|
|
1587
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
catch {
|
|
1591
|
+
// Ignore logout errors
|
|
1592
|
+
}
|
|
1593
|
+
this.sessionCookie = null;
|
|
1594
|
+
if (this.config.debug) {
|
|
1595
|
+
debugLog('Portal logout successful');
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
/**
|
|
1599
|
+
* Check if logged in to Customer Portal.
|
|
1600
|
+
*/
|
|
1601
|
+
isLoggedIn() {
|
|
1602
|
+
return this.sessionCookie !== null;
|
|
1603
|
+
}
|
|
1604
|
+
// ============================================================================
|
|
1373
1605
|
// Code Governance Methods (Enterprise)
|
|
1374
1606
|
// ============================================================================
|
|
1375
1607
|
/**
|
|
@@ -1411,7 +1643,7 @@ export class AxonFlow {
|
|
|
1411
1643
|
apiRequest.installation_id = request.installationId;
|
|
1412
1644
|
if (request.privateKey)
|
|
1413
1645
|
apiRequest.private_key = request.privateKey;
|
|
1414
|
-
return this.
|
|
1646
|
+
return this.portalRequest('POST', '/api/v1/code-governance/git-providers/validate', apiRequest);
|
|
1415
1647
|
}
|
|
1416
1648
|
/**
|
|
1417
1649
|
* Configure a Git provider for code governance.
|
|
@@ -1462,7 +1694,7 @@ export class AxonFlow {
|
|
|
1462
1694
|
apiRequest.installation_id = request.installationId;
|
|
1463
1695
|
if (request.privateKey)
|
|
1464
1696
|
apiRequest.private_key = request.privateKey;
|
|
1465
|
-
return this.
|
|
1697
|
+
return this.portalRequest('POST', '/api/v1/code-governance/git-providers', apiRequest);
|
|
1466
1698
|
}
|
|
1467
1699
|
/**
|
|
1468
1700
|
* List all configured Git providers for the tenant.
|
|
@@ -1480,7 +1712,7 @@ export class AxonFlow {
|
|
|
1480
1712
|
if (this.config.debug) {
|
|
1481
1713
|
debugLog('Listing Git providers');
|
|
1482
1714
|
}
|
|
1483
|
-
return this.
|
|
1715
|
+
return this.portalRequest('GET', '/api/v1/code-governance/git-providers');
|
|
1484
1716
|
}
|
|
1485
1717
|
/**
|
|
1486
1718
|
* Delete a configured Git provider.
|
|
@@ -1496,7 +1728,7 @@ export class AxonFlow {
|
|
|
1496
1728
|
if (this.config.debug) {
|
|
1497
1729
|
debugLog('Deleting Git provider', { type });
|
|
1498
1730
|
}
|
|
1499
|
-
await this.
|
|
1731
|
+
await this.portalRequest('DELETE', `/api/v1/code-governance/git-providers/${type}`);
|
|
1500
1732
|
}
|
|
1501
1733
|
/**
|
|
1502
1734
|
* Create a Pull Request from LLM-generated code.
|
|
@@ -1564,7 +1796,7 @@ export class AxonFlow {
|
|
|
1564
1796
|
apiRequest.secrets_detected = request.secretsDetected;
|
|
1565
1797
|
if (request.unsafePatterns !== undefined)
|
|
1566
1798
|
apiRequest.unsafe_patterns = request.unsafePatterns;
|
|
1567
|
-
const response = await this.
|
|
1799
|
+
const response = await this.portalRequest('POST', '/api/v1/code-governance/prs', apiRequest);
|
|
1568
1800
|
// Transform snake_case response to camelCase
|
|
1569
1801
|
return {
|
|
1570
1802
|
prId: response.pr_id,
|
|
@@ -1609,10 +1841,10 @@ export class AxonFlow {
|
|
|
1609
1841
|
if (this.config.debug) {
|
|
1610
1842
|
debugLog('Listing PRs', { options });
|
|
1611
1843
|
}
|
|
1612
|
-
const response = await this.
|
|
1844
|
+
const response = await this.portalRequest('GET', path);
|
|
1613
1845
|
// Transform snake_case response to camelCase
|
|
1614
1846
|
return {
|
|
1615
|
-
prs: response.prs.map(pr => ({
|
|
1847
|
+
prs: (response.prs || []).map(pr => ({
|
|
1616
1848
|
id: pr.id,
|
|
1617
1849
|
prNumber: pr.pr_number,
|
|
1618
1850
|
prUrl: pr.pr_url,
|
|
@@ -1648,7 +1880,7 @@ export class AxonFlow {
|
|
|
1648
1880
|
if (this.config.debug) {
|
|
1649
1881
|
debugLog('Getting PR', { prId });
|
|
1650
1882
|
}
|
|
1651
|
-
const response = await this.
|
|
1883
|
+
const response = await this.portalRequest('GET', `/api/v1/code-governance/prs/${prId}`);
|
|
1652
1884
|
// Transform snake_case response to camelCase
|
|
1653
1885
|
return {
|
|
1654
1886
|
id: response.id,
|
|
@@ -1685,7 +1917,7 @@ export class AxonFlow {
|
|
|
1685
1917
|
if (this.config.debug) {
|
|
1686
1918
|
debugLog('Syncing PR status', { prId });
|
|
1687
1919
|
}
|
|
1688
|
-
const response = await this.
|
|
1920
|
+
const response = await this.portalRequest('POST', `/api/v1/code-governance/prs/${prId}/sync`);
|
|
1689
1921
|
// Transform snake_case response to camelCase
|
|
1690
1922
|
return {
|
|
1691
1923
|
id: response.id,
|
|
@@ -1725,7 +1957,7 @@ export class AxonFlow {
|
|
|
1725
1957
|
if (this.config.debug) {
|
|
1726
1958
|
debugLog('Getting code governance metrics');
|
|
1727
1959
|
}
|
|
1728
|
-
const response = await this.
|
|
1960
|
+
const response = await this.portalRequest('GET', '/api/v1/code-governance/metrics');
|
|
1729
1961
|
return {
|
|
1730
1962
|
tenantId: response.tenant_id,
|
|
1731
1963
|
totalPrs: response.total_prs,
|
|
@@ -1773,9 +2005,9 @@ export class AxonFlow {
|
|
|
1773
2005
|
if (this.config.debug) {
|
|
1774
2006
|
debugLog('Exporting code governance data', { path });
|
|
1775
2007
|
}
|
|
1776
|
-
const response = await this.
|
|
2008
|
+
const response = await this.portalRequest('GET', path);
|
|
1777
2009
|
return {
|
|
1778
|
-
records: response.records.map(r => ({
|
|
2010
|
+
records: (response.records || []).map(r => ({
|
|
1779
2011
|
id: r.id,
|
|
1780
2012
|
prNumber: r.pr_number,
|
|
1781
2013
|
prUrl: r.pr_url,
|
|
@@ -1796,33 +2028,93 @@ export class AxonFlow {
|
|
|
1796
2028
|
exportedAt: response.exported_at,
|
|
1797
2029
|
};
|
|
1798
2030
|
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Export code governance data as CSV.
|
|
2033
|
+
*
|
|
2034
|
+
* Returns raw CSV data suitable for saving to file or streaming.
|
|
2035
|
+
*
|
|
2036
|
+
* @param options - Export options (date filters, state filter)
|
|
2037
|
+
* @returns Raw CSV data
|
|
2038
|
+
*
|
|
2039
|
+
* @example
|
|
2040
|
+
* ```typescript
|
|
2041
|
+
* const csvData = await axonflow.exportCodeGovernanceDataCSV();
|
|
2042
|
+
* fs.writeFileSync('pr-audit.csv', csvData);
|
|
2043
|
+
* ```
|
|
2044
|
+
*/
|
|
2045
|
+
async exportCodeGovernanceDataCSV(options) {
|
|
2046
|
+
const params = new URLSearchParams();
|
|
2047
|
+
params.set('format', 'csv');
|
|
2048
|
+
if (options?.startDate)
|
|
2049
|
+
params.set('start_date', options.startDate);
|
|
2050
|
+
if (options?.endDate)
|
|
2051
|
+
params.set('end_date', options.endDate);
|
|
2052
|
+
if (options?.state)
|
|
2053
|
+
params.set('state', options.state);
|
|
2054
|
+
const query = params.toString();
|
|
2055
|
+
const path = `/api/v1/code-governance/export${query ? '?' + query : ''}`;
|
|
2056
|
+
if (this.config.debug) {
|
|
2057
|
+
debugLog('Exporting code governance data as CSV', { path });
|
|
2058
|
+
}
|
|
2059
|
+
return this.portalRequestText('GET', path);
|
|
2060
|
+
}
|
|
1799
2061
|
// ============================================================================
|
|
1800
2062
|
// Execution Replay Methods
|
|
1801
2063
|
// ============================================================================
|
|
1802
2064
|
/**
|
|
1803
|
-
* Get the
|
|
1804
|
-
*
|
|
2065
|
+
* Get the endpoint URL for API requests.
|
|
2066
|
+
* All routes now go through the single Agent endpoint (ADR-026).
|
|
2067
|
+
*/
|
|
2068
|
+
getEndpointUrl() {
|
|
2069
|
+
return this.config.endpoint;
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* Generic HTTP request helper for APIs (routes through single endpoint per ADR-026)
|
|
1805
2073
|
*/
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
2074
|
+
async orchestratorRequest(method, path, body) {
|
|
2075
|
+
const url = `${this.config.endpoint}${path}`;
|
|
2076
|
+
const headers = this.buildAuthHeaders();
|
|
2077
|
+
const options = {
|
|
2078
|
+
method,
|
|
2079
|
+
headers,
|
|
2080
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
2081
|
+
};
|
|
2082
|
+
if (body && (method === 'POST' || method === 'PUT' || method === 'PATCH')) {
|
|
2083
|
+
options.body = JSON.stringify(body);
|
|
1809
2084
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
const
|
|
1813
|
-
|
|
1814
|
-
|
|
2085
|
+
const response = await fetch(url, options);
|
|
2086
|
+
if (!response.ok) {
|
|
2087
|
+
const errorText = await response.text();
|
|
2088
|
+
if (response.status === 401 || response.status === 403) {
|
|
2089
|
+
throw new AuthenticationError(`Request failed: ${errorText}`);
|
|
2090
|
+
}
|
|
2091
|
+
if (response.status === 404) {
|
|
2092
|
+
throw new APIError(404, 'Not Found', errorText);
|
|
2093
|
+
}
|
|
2094
|
+
throw new APIError(response.status, response.statusText, errorText);
|
|
1815
2095
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
2096
|
+
// Handle DELETE responses with no body
|
|
2097
|
+
if (response.status === 204 || method === 'DELETE') {
|
|
2098
|
+
return undefined;
|
|
1818
2099
|
}
|
|
2100
|
+
return response.json();
|
|
1819
2101
|
}
|
|
2102
|
+
// Note: getPortalUrl() was removed in v2.0.0 (ADR-026 Single Entry Point).
|
|
2103
|
+
// All routes now go through the single Agent endpoint (this.config.endpoint).
|
|
1820
2104
|
/**
|
|
1821
|
-
* Generic HTTP request helper for
|
|
2105
|
+
* Generic HTTP request helper for Customer Portal APIs (enterprise features).
|
|
2106
|
+
* Routes through single endpoint per ADR-026.
|
|
2107
|
+
* Requires prior authentication via loginToPortal().
|
|
1822
2108
|
*/
|
|
1823
|
-
async
|
|
1824
|
-
|
|
1825
|
-
|
|
2109
|
+
async portalRequest(method, path, body) {
|
|
2110
|
+
if (!this.sessionCookie) {
|
|
2111
|
+
throw new AuthenticationError('Not logged in to Customer Portal. Call loginToPortal() first.');
|
|
2112
|
+
}
|
|
2113
|
+
const url = `${this.config.endpoint}${path}`;
|
|
2114
|
+
const headers = {
|
|
2115
|
+
'Content-Type': 'application/json',
|
|
2116
|
+
Cookie: `axonflow_session=${this.sessionCookie}`,
|
|
2117
|
+
};
|
|
1826
2118
|
const options = {
|
|
1827
2119
|
method,
|
|
1828
2120
|
headers,
|
|
@@ -1831,6 +2123,9 @@ export class AxonFlow {
|
|
|
1831
2123
|
if (body && (method === 'POST' || method === 'PUT' || method === 'PATCH')) {
|
|
1832
2124
|
options.body = JSON.stringify(body);
|
|
1833
2125
|
}
|
|
2126
|
+
if (this.config.debug) {
|
|
2127
|
+
debugLog('Portal request', { method, path });
|
|
2128
|
+
}
|
|
1834
2129
|
const response = await fetch(url, options);
|
|
1835
2130
|
if (!response.ok) {
|
|
1836
2131
|
const errorText = await response.text();
|
|
@@ -2404,5 +2699,36 @@ export class AxonFlow {
|
|
|
2404
2699
|
},
|
|
2405
2700
|
};
|
|
2406
2701
|
}
|
|
2702
|
+
/**
|
|
2703
|
+
* Generic HTTP request helper for Customer Portal APIs that returns raw text.
|
|
2704
|
+
* Used for CSV exports and other non-JSON responses.
|
|
2705
|
+
* Requires prior authentication via loginToPortal().
|
|
2706
|
+
*/
|
|
2707
|
+
async portalRequestText(method, path) {
|
|
2708
|
+
if (!this.sessionCookie) {
|
|
2709
|
+
throw new AuthenticationError('Not logged in to Customer Portal. Call loginToPortal() first.');
|
|
2710
|
+
}
|
|
2711
|
+
const url = `${this.config.endpoint}${path}`;
|
|
2712
|
+
const headers = {
|
|
2713
|
+
Cookie: `axonflow_session=${this.sessionCookie}`,
|
|
2714
|
+
};
|
|
2715
|
+
const options = {
|
|
2716
|
+
method,
|
|
2717
|
+
headers,
|
|
2718
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
2719
|
+
};
|
|
2720
|
+
if (this.config.debug) {
|
|
2721
|
+
debugLog('Portal request (text)', { method, path });
|
|
2722
|
+
}
|
|
2723
|
+
const response = await fetch(url, options);
|
|
2724
|
+
if (!response.ok) {
|
|
2725
|
+
const errorText = await response.text();
|
|
2726
|
+
if (response.status === 401 || response.status === 403) {
|
|
2727
|
+
throw new AuthenticationError(`Request failed: ${errorText}`);
|
|
2728
|
+
}
|
|
2729
|
+
throw new APIError(response.status, response.statusText, errorText);
|
|
2730
|
+
}
|
|
2731
|
+
return response.text();
|
|
2732
|
+
}
|
|
2407
2733
|
}
|
|
2408
2734
|
//# sourceMappingURL=client.js.map
|