@axonflow/sdk 1.13.0 → 1.14.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.
@@ -5,6 +5,7 @@ import { AxonFlowConfig, ConnectorMetadata, ConnectorInstallRequest, ConnectorRe
5
5
  export declare class AxonFlow {
6
6
  private config;
7
7
  private interceptors;
8
+ private sessionCookie;
8
9
  constructor(config: AxonFlowConfig);
9
10
  /**
10
11
  * Main method to protect AI calls with governance
@@ -498,6 +499,38 @@ export declare class AxonFlow {
498
499
  * @returns Array of effective dynamic policies
499
500
  */
500
501
  getEffectiveDynamicPolicies(options?: EffectivePoliciesOptions): Promise<DynamicPolicy[]>;
502
+ /**
503
+ * Login to Customer Portal and store session cookie.
504
+ * Required before using Code Governance methods.
505
+ *
506
+ * @param orgId - Organization ID
507
+ * @param password - Organization password
508
+ * @returns Login response with session info
509
+ *
510
+ * @example
511
+ * ```typescript
512
+ * const login = await axonflow.loginToPortal('test-org-001', 'test123');
513
+ * console.log(`Logged in as ${login.name}`);
514
+ *
515
+ * // Now you can use Code Governance methods
516
+ * const providers = await axonflow.listGitProviders();
517
+ * ```
518
+ */
519
+ loginToPortal(orgId: string, password: string): Promise<{
520
+ sessionId: string;
521
+ orgId: string;
522
+ email: string;
523
+ name: string;
524
+ expiresAt: string;
525
+ }>;
526
+ /**
527
+ * Logout from Customer Portal and clear session cookie.
528
+ */
529
+ logoutFromPortal(): Promise<void>;
530
+ /**
531
+ * Check if logged in to Customer Portal.
532
+ */
533
+ isLoggedIn(): boolean;
501
534
  /**
502
535
  * Validate Git provider credentials before configuration.
503
536
  * Use this to verify tokens and connectivity before saving.
@@ -693,6 +726,21 @@ export declare class AxonFlow {
693
726
  * ```
694
727
  */
695
728
  exportCodeGovernanceData(options?: ExportOptions): Promise<ExportResponse>;
729
+ /**
730
+ * Export code governance data as CSV.
731
+ *
732
+ * Returns raw CSV data suitable for saving to file or streaming.
733
+ *
734
+ * @param options - Export options (date filters, state filter)
735
+ * @returns Raw CSV data
736
+ *
737
+ * @example
738
+ * ```typescript
739
+ * const csvData = await axonflow.exportCodeGovernanceDataCSV();
740
+ * fs.writeFileSync('pr-audit.csv', csvData);
741
+ * ```
742
+ */
743
+ exportCodeGovernanceDataCSV(options?: ExportOptions): Promise<string>;
696
744
  /**
697
745
  * Get the orchestrator URL for Execution Replay API.
698
746
  * Falls back to agent endpoint with port 8081 if not configured.
@@ -702,6 +750,16 @@ export declare class AxonFlow {
702
750
  * Generic HTTP request helper for orchestrator APIs
703
751
  */
704
752
  private orchestratorRequest;
753
+ /**
754
+ * Get the portal URL for enterprise PR workflow features.
755
+ * Falls back to agent endpoint with port 8082 if not configured.
756
+ */
757
+ private getPortalUrl;
758
+ /**
759
+ * Generic HTTP request helper for Customer Portal APIs (enterprise features).
760
+ * Requires prior authentication via loginToPortal().
761
+ */
762
+ private portalRequest;
705
763
  /**
706
764
  * List workflow executions with optional filtering and pagination.
707
765
  *
@@ -891,5 +949,11 @@ export declare class AxonFlow {
891
949
  getPricing(provider?: string, model?: string): Promise<PricingListResponse>;
892
950
  private mapBudgetResponse;
893
951
  private mapPricingResponse;
952
+ /**
953
+ * Generic HTTP request helper for Customer Portal APIs that returns raw text.
954
+ * Used for CSV exports and other non-JSON responses.
955
+ * Requires prior authentication via loginToPortal().
956
+ */
957
+ private portalRequestText;
894
958
  }
895
959
  //# sourceMappingURL=client.d.ts.map
@@ -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,yBA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11,6 +11,7 @@ const helpers_1 = require("./utils/helpers");
11
11
  class AxonFlow {
12
12
  constructor(config) {
13
13
  this.interceptors = [];
14
+ this.sessionCookie = null;
14
15
  // Set defaults first to determine endpoint
15
16
  const endpoint = config.endpoint || 'https://staging-eu.getaxonflow.com';
16
17
  // Credentials are optional for community/self-hosted deployments
@@ -22,6 +23,7 @@ class AxonFlow {
22
23
  licenseKey: config.licenseKey,
23
24
  endpoint,
24
25
  orchestratorEndpoint: config.orchestratorEndpoint,
26
+ portalEndpoint: config.portalEndpoint,
25
27
  mode: config.mode || (hasCredentials ? 'production' : 'sandbox'),
26
28
  tenant: config.tenant || 'default',
27
29
  debug: config.debug || false,
@@ -1373,6 +1375,90 @@ class AxonFlow {
1373
1375
  return this.orchestratorRequest('GET', path);
1374
1376
  }
1375
1377
  // ============================================================================
1378
+ // Portal Authentication Methods (Enterprise)
1379
+ // ============================================================================
1380
+ /**
1381
+ * Login to Customer Portal and store session cookie.
1382
+ * Required before using Code Governance methods.
1383
+ *
1384
+ * @param orgId - Organization ID
1385
+ * @param password - Organization password
1386
+ * @returns Login response with session info
1387
+ *
1388
+ * @example
1389
+ * ```typescript
1390
+ * const login = await axonflow.loginToPortal('test-org-001', 'test123');
1391
+ * console.log(`Logged in as ${login.name}`);
1392
+ *
1393
+ * // Now you can use Code Governance methods
1394
+ * const providers = await axonflow.listGitProviders();
1395
+ * ```
1396
+ */
1397
+ async loginToPortal(orgId, password) {
1398
+ const url = `${this.getPortalUrl()}/api/v1/auth/login`;
1399
+ const response = await fetch(url, {
1400
+ method: 'POST',
1401
+ headers: { 'Content-Type': 'application/json' },
1402
+ body: JSON.stringify({ org_id: orgId, password }),
1403
+ signal: AbortSignal.timeout(this.config.timeout),
1404
+ });
1405
+ if (!response.ok) {
1406
+ const errorText = await response.text();
1407
+ throw new errors_1.AuthenticationError(`Login failed: ${errorText}`);
1408
+ }
1409
+ const result = (await response.json());
1410
+ // Extract session cookie from response
1411
+ const cookies = response.headers.get('set-cookie');
1412
+ if (cookies) {
1413
+ const match = cookies.match(/axonflow_session=([^;]+)/);
1414
+ if (match) {
1415
+ this.sessionCookie = match[1];
1416
+ }
1417
+ }
1418
+ // Fallback to session_id in response body
1419
+ if (!this.sessionCookie && result.session_id) {
1420
+ this.sessionCookie = result.session_id;
1421
+ }
1422
+ if (this.config.debug) {
1423
+ (0, helpers_1.debugLog)('Portal login successful', { orgId });
1424
+ }
1425
+ return {
1426
+ sessionId: result.session_id,
1427
+ orgId: result.org_id,
1428
+ email: result.email,
1429
+ name: result.name,
1430
+ expiresAt: result.expires_at,
1431
+ };
1432
+ }
1433
+ /**
1434
+ * Logout from Customer Portal and clear session cookie.
1435
+ */
1436
+ async logoutFromPortal() {
1437
+ if (!this.sessionCookie) {
1438
+ return;
1439
+ }
1440
+ try {
1441
+ await fetch(`${this.getPortalUrl()}/api/v1/auth/logout`, {
1442
+ method: 'POST',
1443
+ headers: { Cookie: `axonflow_session=${this.sessionCookie}` },
1444
+ signal: AbortSignal.timeout(this.config.timeout),
1445
+ });
1446
+ }
1447
+ catch {
1448
+ // Ignore logout errors
1449
+ }
1450
+ this.sessionCookie = null;
1451
+ if (this.config.debug) {
1452
+ (0, helpers_1.debugLog)('Portal logout successful');
1453
+ }
1454
+ }
1455
+ /**
1456
+ * Check if logged in to Customer Portal.
1457
+ */
1458
+ isLoggedIn() {
1459
+ return this.sessionCookie !== null;
1460
+ }
1461
+ // ============================================================================
1376
1462
  // Code Governance Methods (Enterprise)
1377
1463
  // ============================================================================
1378
1464
  /**
@@ -1414,7 +1500,7 @@ class AxonFlow {
1414
1500
  apiRequest.installation_id = request.installationId;
1415
1501
  if (request.privateKey)
1416
1502
  apiRequest.private_key = request.privateKey;
1417
- return this.policyRequest('POST', '/api/v1/code-governance/git-providers/validate', apiRequest);
1503
+ return this.portalRequest('POST', '/api/v1/code-governance/git-providers/validate', apiRequest);
1418
1504
  }
1419
1505
  /**
1420
1506
  * Configure a Git provider for code governance.
@@ -1465,7 +1551,7 @@ class AxonFlow {
1465
1551
  apiRequest.installation_id = request.installationId;
1466
1552
  if (request.privateKey)
1467
1553
  apiRequest.private_key = request.privateKey;
1468
- return this.policyRequest('POST', '/api/v1/code-governance/git-providers', apiRequest);
1554
+ return this.portalRequest('POST', '/api/v1/code-governance/git-providers', apiRequest);
1469
1555
  }
1470
1556
  /**
1471
1557
  * List all configured Git providers for the tenant.
@@ -1483,7 +1569,7 @@ class AxonFlow {
1483
1569
  if (this.config.debug) {
1484
1570
  (0, helpers_1.debugLog)('Listing Git providers');
1485
1571
  }
1486
- return this.policyRequest('GET', '/api/v1/code-governance/git-providers');
1572
+ return this.portalRequest('GET', '/api/v1/code-governance/git-providers');
1487
1573
  }
1488
1574
  /**
1489
1575
  * Delete a configured Git provider.
@@ -1499,7 +1585,7 @@ class AxonFlow {
1499
1585
  if (this.config.debug) {
1500
1586
  (0, helpers_1.debugLog)('Deleting Git provider', { type });
1501
1587
  }
1502
- await this.policyRequest('DELETE', `/api/v1/code-governance/git-providers/${type}`);
1588
+ await this.portalRequest('DELETE', `/api/v1/code-governance/git-providers/${type}`);
1503
1589
  }
1504
1590
  /**
1505
1591
  * Create a Pull Request from LLM-generated code.
@@ -1567,7 +1653,7 @@ class AxonFlow {
1567
1653
  apiRequest.secrets_detected = request.secretsDetected;
1568
1654
  if (request.unsafePatterns !== undefined)
1569
1655
  apiRequest.unsafe_patterns = request.unsafePatterns;
1570
- const response = await this.policyRequest('POST', '/api/v1/code-governance/prs', apiRequest);
1656
+ const response = await this.portalRequest('POST', '/api/v1/code-governance/prs', apiRequest);
1571
1657
  // Transform snake_case response to camelCase
1572
1658
  return {
1573
1659
  prId: response.pr_id,
@@ -1612,10 +1698,10 @@ class AxonFlow {
1612
1698
  if (this.config.debug) {
1613
1699
  (0, helpers_1.debugLog)('Listing PRs', { options });
1614
1700
  }
1615
- const response = await this.policyRequest('GET', path);
1701
+ const response = await this.portalRequest('GET', path);
1616
1702
  // Transform snake_case response to camelCase
1617
1703
  return {
1618
- prs: response.prs.map(pr => ({
1704
+ prs: (response.prs || []).map(pr => ({
1619
1705
  id: pr.id,
1620
1706
  prNumber: pr.pr_number,
1621
1707
  prUrl: pr.pr_url,
@@ -1651,7 +1737,7 @@ class AxonFlow {
1651
1737
  if (this.config.debug) {
1652
1738
  (0, helpers_1.debugLog)('Getting PR', { prId });
1653
1739
  }
1654
- const response = await this.policyRequest('GET', `/api/v1/code-governance/prs/${prId}`);
1740
+ const response = await this.portalRequest('GET', `/api/v1/code-governance/prs/${prId}`);
1655
1741
  // Transform snake_case response to camelCase
1656
1742
  return {
1657
1743
  id: response.id,
@@ -1688,7 +1774,7 @@ class AxonFlow {
1688
1774
  if (this.config.debug) {
1689
1775
  (0, helpers_1.debugLog)('Syncing PR status', { prId });
1690
1776
  }
1691
- const response = await this.policyRequest('POST', `/api/v1/code-governance/prs/${prId}/sync`);
1777
+ const response = await this.portalRequest('POST', `/api/v1/code-governance/prs/${prId}/sync`);
1692
1778
  // Transform snake_case response to camelCase
1693
1779
  return {
1694
1780
  id: response.id,
@@ -1728,7 +1814,7 @@ class AxonFlow {
1728
1814
  if (this.config.debug) {
1729
1815
  (0, helpers_1.debugLog)('Getting code governance metrics');
1730
1816
  }
1731
- const response = await this.policyRequest('GET', '/api/v1/code-governance/metrics');
1817
+ const response = await this.portalRequest('GET', '/api/v1/code-governance/metrics');
1732
1818
  return {
1733
1819
  tenantId: response.tenant_id,
1734
1820
  totalPrs: response.total_prs,
@@ -1776,9 +1862,9 @@ class AxonFlow {
1776
1862
  if (this.config.debug) {
1777
1863
  (0, helpers_1.debugLog)('Exporting code governance data', { path });
1778
1864
  }
1779
- const response = await this.policyRequest('GET', path);
1865
+ const response = await this.portalRequest('GET', path);
1780
1866
  return {
1781
- records: response.records.map(r => ({
1867
+ records: (response.records || []).map(r => ({
1782
1868
  id: r.id,
1783
1869
  prNumber: r.pr_number,
1784
1870
  prUrl: r.pr_url,
@@ -1799,6 +1885,36 @@ class AxonFlow {
1799
1885
  exportedAt: response.exported_at,
1800
1886
  };
1801
1887
  }
1888
+ /**
1889
+ * Export code governance data as CSV.
1890
+ *
1891
+ * Returns raw CSV data suitable for saving to file or streaming.
1892
+ *
1893
+ * @param options - Export options (date filters, state filter)
1894
+ * @returns Raw CSV data
1895
+ *
1896
+ * @example
1897
+ * ```typescript
1898
+ * const csvData = await axonflow.exportCodeGovernanceDataCSV();
1899
+ * fs.writeFileSync('pr-audit.csv', csvData);
1900
+ * ```
1901
+ */
1902
+ async exportCodeGovernanceDataCSV(options) {
1903
+ const params = new URLSearchParams();
1904
+ params.set('format', 'csv');
1905
+ if (options?.startDate)
1906
+ params.set('start_date', options.startDate);
1907
+ if (options?.endDate)
1908
+ params.set('end_date', options.endDate);
1909
+ if (options?.state)
1910
+ params.set('state', options.state);
1911
+ const query = params.toString();
1912
+ const path = `/api/v1/code-governance/export${query ? '?' + query : ''}`;
1913
+ if (this.config.debug) {
1914
+ (0, helpers_1.debugLog)('Exporting code governance data as CSV', { path });
1915
+ }
1916
+ return this.portalRequestText('GET', path);
1917
+ }
1802
1918
  // ============================================================================
1803
1919
  // Execution Replay Methods
1804
1920
  // ============================================================================
@@ -1851,6 +1967,65 @@ class AxonFlow {
1851
1967
  }
1852
1968
  return response.json();
1853
1969
  }
1970
+ /**
1971
+ * Get the portal URL for enterprise PR workflow features.
1972
+ * Falls back to agent endpoint with port 8082 if not configured.
1973
+ */
1974
+ getPortalUrl() {
1975
+ if (this.config.portalEndpoint) {
1976
+ return this.config.portalEndpoint;
1977
+ }
1978
+ // Default: assume portal is on same host as agent, port 8082
1979
+ try {
1980
+ const url = new URL(this.config.endpoint);
1981
+ url.port = '8082';
1982
+ return url.toString().replace(/\/$/, '');
1983
+ }
1984
+ catch {
1985
+ return 'http://localhost:8082';
1986
+ }
1987
+ }
1988
+ /**
1989
+ * Generic HTTP request helper for Customer Portal APIs (enterprise features).
1990
+ * Requires prior authentication via loginToPortal().
1991
+ */
1992
+ async portalRequest(method, path, body) {
1993
+ if (!this.sessionCookie) {
1994
+ throw new errors_1.AuthenticationError('Not logged in to Customer Portal. Call loginToPortal() first.');
1995
+ }
1996
+ const url = `${this.getPortalUrl()}${path}`;
1997
+ const headers = {
1998
+ 'Content-Type': 'application/json',
1999
+ Cookie: `axonflow_session=${this.sessionCookie}`,
2000
+ };
2001
+ const options = {
2002
+ method,
2003
+ headers,
2004
+ signal: AbortSignal.timeout(this.config.timeout),
2005
+ };
2006
+ if (body && (method === 'POST' || method === 'PUT' || method === 'PATCH')) {
2007
+ options.body = JSON.stringify(body);
2008
+ }
2009
+ if (this.config.debug) {
2010
+ (0, helpers_1.debugLog)('Portal request', { method, path });
2011
+ }
2012
+ const response = await fetch(url, options);
2013
+ if (!response.ok) {
2014
+ const errorText = await response.text();
2015
+ if (response.status === 401 || response.status === 403) {
2016
+ throw new errors_1.AuthenticationError(`Request failed: ${errorText}`);
2017
+ }
2018
+ if (response.status === 404) {
2019
+ throw new errors_1.APIError(404, 'Not Found', errorText);
2020
+ }
2021
+ throw new errors_1.APIError(response.status, response.statusText, errorText);
2022
+ }
2023
+ // Handle DELETE responses with no body
2024
+ if (response.status === 204 || method === 'DELETE') {
2025
+ return undefined;
2026
+ }
2027
+ return response.json();
2028
+ }
1854
2029
  /**
1855
2030
  * List workflow executions with optional filtering and pagination.
1856
2031
  *
@@ -2407,6 +2582,37 @@ class AxonFlow {
2407
2582
  },
2408
2583
  };
2409
2584
  }
2585
+ /**
2586
+ * Generic HTTP request helper for Customer Portal APIs that returns raw text.
2587
+ * Used for CSV exports and other non-JSON responses.
2588
+ * Requires prior authentication via loginToPortal().
2589
+ */
2590
+ async portalRequestText(method, path) {
2591
+ if (!this.sessionCookie) {
2592
+ throw new errors_1.AuthenticationError('Not logged in to Customer Portal. Call loginToPortal() first.');
2593
+ }
2594
+ const url = `${this.getPortalUrl()}${path}`;
2595
+ const headers = {
2596
+ Cookie: `axonflow_session=${this.sessionCookie}`,
2597
+ };
2598
+ const options = {
2599
+ method,
2600
+ headers,
2601
+ signal: AbortSignal.timeout(this.config.timeout),
2602
+ };
2603
+ if (this.config.debug) {
2604
+ (0, helpers_1.debugLog)('Portal request (text)', { method, path });
2605
+ }
2606
+ const response = await fetch(url, options);
2607
+ if (!response.ok) {
2608
+ const errorText = await response.text();
2609
+ if (response.status === 401 || response.status === 403) {
2610
+ throw new errors_1.AuthenticationError(`Request failed: ${errorText}`);
2611
+ }
2612
+ throw new errors_1.APIError(response.status, response.statusText, errorText);
2613
+ }
2614
+ return response.text();
2615
+ }
2410
2616
  }
2411
2617
  exports.AxonFlow = AxonFlow;
2412
2618
  //# sourceMappingURL=client.js.map