@axonflow/sdk 1.6.0 → 1.7.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 +161 -1
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +336 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/code-governance.d.ts +157 -0
- package/dist/cjs/types/code-governance.d.ts.map +1 -0
- package/dist/cjs/types/code-governance.js +9 -0
- package/dist/cjs/types/code-governance.js.map +1 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/client.d.ts +161 -1
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +336 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/code-governance.d.ts +157 -0
- package/dist/esm/types/code-governance.d.ts.map +1 -0
- package/dist/esm/types/code-governance.js +8 -0
- package/dist/esm/types/code-governance.js.map +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxonFlowConfig, ConnectorMetadata, ConnectorInstallRequest, ConnectorResponse, PlanResponse, PlanExecutionResponse, PolicyApprovalResult, PolicyApprovalOptions, AuditResult, AuditOptions, ExecuteQueryOptions, ExecuteQueryResponse, HealthStatus, StaticPolicy, DynamicPolicy, PolicyOverride, ListStaticPoliciesOptions, ListDynamicPoliciesOptions, CreateStaticPolicyRequest, UpdateStaticPolicyRequest, CreateDynamicPolicyRequest, UpdateDynamicPolicyRequest, CreatePolicyOverrideRequest, TestPatternResult, PolicyVersion, EffectivePoliciesOptions } from './types';
|
|
1
|
+
import { AxonFlowConfig, ConnectorMetadata, ConnectorInstallRequest, ConnectorResponse, PlanResponse, PlanExecutionResponse, PolicyApprovalResult, PolicyApprovalOptions, AuditResult, AuditOptions, ExecuteQueryOptions, ExecuteQueryResponse, HealthStatus, StaticPolicy, DynamicPolicy, PolicyOverride, ListStaticPoliciesOptions, ListDynamicPoliciesOptions, CreateStaticPolicyRequest, UpdateStaticPolicyRequest, CreateDynamicPolicyRequest, UpdateDynamicPolicyRequest, CreatePolicyOverrideRequest, TestPatternResult, PolicyVersion, EffectivePoliciesOptions, GitProviderType, ConfigureGitProviderRequest, ConfigureGitProviderResponse, ValidateGitProviderRequest, ValidateGitProviderResponse, ListGitProvidersResponse, CreatePRRequest, CreatePRResponse, PRRecord, ListPRsOptions, ListPRsResponse } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Main AxonFlow client for invisible AI governance
|
|
4
4
|
*/
|
|
@@ -458,5 +458,165 @@ export declare class AxonFlow {
|
|
|
458
458
|
* @returns Array of effective dynamic policies
|
|
459
459
|
*/
|
|
460
460
|
getEffectiveDynamicPolicies(options?: EffectivePoliciesOptions): Promise<DynamicPolicy[]>;
|
|
461
|
+
/**
|
|
462
|
+
* Validate Git provider credentials before configuration.
|
|
463
|
+
* Use this to verify tokens and connectivity before saving.
|
|
464
|
+
*
|
|
465
|
+
* @param request - Validation request with provider type and credentials
|
|
466
|
+
* @returns Validation result indicating if credentials are valid
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* const result = await axonflow.validateGitProvider({
|
|
471
|
+
* type: 'github',
|
|
472
|
+
* token: 'ghp_xxxxxxxxxxxx'
|
|
473
|
+
* });
|
|
474
|
+
*
|
|
475
|
+
* if (result.valid) {
|
|
476
|
+
* console.log('Credentials are valid');
|
|
477
|
+
* } else {
|
|
478
|
+
* console.log('Invalid:', result.message);
|
|
479
|
+
* }
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
validateGitProvider(request: ValidateGitProviderRequest): Promise<ValidateGitProviderResponse>;
|
|
483
|
+
/**
|
|
484
|
+
* Configure a Git provider for code governance.
|
|
485
|
+
* Supports GitHub, GitLab, and Bitbucket (cloud and self-hosted).
|
|
486
|
+
*
|
|
487
|
+
* @param request - Configuration request with provider type and credentials
|
|
488
|
+
* @returns Configuration result
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```typescript
|
|
492
|
+
* // Configure GitHub with personal access token
|
|
493
|
+
* await axonflow.configureGitProvider({
|
|
494
|
+
* type: 'github',
|
|
495
|
+
* token: 'ghp_xxxxxxxxxxxx'
|
|
496
|
+
* });
|
|
497
|
+
*
|
|
498
|
+
* // Configure GitLab self-hosted
|
|
499
|
+
* await axonflow.configureGitProvider({
|
|
500
|
+
* type: 'gitlab',
|
|
501
|
+
* token: 'glpat-xxxxxxxxxxxx',
|
|
502
|
+
* baseUrl: 'https://gitlab.mycompany.com'
|
|
503
|
+
* });
|
|
504
|
+
*
|
|
505
|
+
* // Configure GitHub App
|
|
506
|
+
* await axonflow.configureGitProvider({
|
|
507
|
+
* type: 'github',
|
|
508
|
+
* appId: 12345,
|
|
509
|
+
* installationId: 67890,
|
|
510
|
+
* privateKey: '-----BEGIN RSA PRIVATE KEY-----\n...'
|
|
511
|
+
* });
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
configureGitProvider(request: ConfigureGitProviderRequest): Promise<ConfigureGitProviderResponse>;
|
|
515
|
+
/**
|
|
516
|
+
* List all configured Git providers for the tenant.
|
|
517
|
+
*
|
|
518
|
+
* @returns List of configured providers
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* ```typescript
|
|
522
|
+
* const { providers, count } = await axonflow.listGitProviders();
|
|
523
|
+
* console.log(`${count} providers configured:`);
|
|
524
|
+
* providers.forEach(p => console.log(` - ${p.type}`));
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
527
|
+
listGitProviders(): Promise<ListGitProvidersResponse>;
|
|
528
|
+
/**
|
|
529
|
+
* Delete a configured Git provider.
|
|
530
|
+
*
|
|
531
|
+
* @param type - Provider type to delete (github, gitlab, or bitbucket)
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```typescript
|
|
535
|
+
* await axonflow.deleteGitProvider('github');
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
deleteGitProvider(type: GitProviderType): Promise<void>;
|
|
539
|
+
/**
|
|
540
|
+
* Create a Pull Request from LLM-generated code.
|
|
541
|
+
* This creates a PR with full audit trail linking back to the AI request.
|
|
542
|
+
*
|
|
543
|
+
* @param request - PR creation request with repository info and files
|
|
544
|
+
* @returns Created PR details including URL and number
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* ```typescript
|
|
548
|
+
* const pr = await axonflow.createPR({
|
|
549
|
+
* owner: 'myorg',
|
|
550
|
+
* repo: 'myrepo',
|
|
551
|
+
* title: 'feat: add user validation utilities',
|
|
552
|
+
* description: 'LLM-generated validation functions',
|
|
553
|
+
* files: [
|
|
554
|
+
* {
|
|
555
|
+
* path: 'src/utils/validation.ts',
|
|
556
|
+
* content: generatedCode,
|
|
557
|
+
* language: 'typescript',
|
|
558
|
+
* action: 'create'
|
|
559
|
+
* }
|
|
560
|
+
* ],
|
|
561
|
+
* agentRequestId: 'req_123',
|
|
562
|
+
* model: 'gpt-4',
|
|
563
|
+
* policiesChecked: ['code-secrets', 'code-unsafe'],
|
|
564
|
+
* secretsDetected: 0,
|
|
565
|
+
* unsafePatterns: 0
|
|
566
|
+
* });
|
|
567
|
+
*
|
|
568
|
+
* console.log(`PR created: ${pr.prUrl}`);
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
createPR(request: CreatePRRequest): Promise<CreatePRResponse>;
|
|
572
|
+
/**
|
|
573
|
+
* List Pull Requests created through code governance.
|
|
574
|
+
*
|
|
575
|
+
* @param options - Filtering and pagination options
|
|
576
|
+
* @returns List of PR records
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```typescript
|
|
580
|
+
* const { prs, count } = await axonflow.listPRs({
|
|
581
|
+
* state: 'open',
|
|
582
|
+
* limit: 10
|
|
583
|
+
* });
|
|
584
|
+
*
|
|
585
|
+
* prs.forEach(pr => {
|
|
586
|
+
* console.log(`#${pr.prNumber}: ${pr.title} (${pr.state})`);
|
|
587
|
+
* if (pr.secretsDetected > 0) {
|
|
588
|
+
* console.log(` Warning: ${pr.secretsDetected} secrets detected`);
|
|
589
|
+
* }
|
|
590
|
+
* });
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
listPRs(options?: ListPRsOptions): Promise<ListPRsResponse>;
|
|
594
|
+
/**
|
|
595
|
+
* Get a specific PR record by ID.
|
|
596
|
+
*
|
|
597
|
+
* @param prId - PR record ID (internal ID, not GitHub PR number)
|
|
598
|
+
* @returns PR record details
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```typescript
|
|
602
|
+
* const pr = await axonflow.getPR('pr_123');
|
|
603
|
+
* console.log(`PR #${pr.prNumber}: ${pr.title}`);
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
getPR(prId: string): Promise<PRRecord>;
|
|
607
|
+
/**
|
|
608
|
+
* Sync PR status with the Git provider.
|
|
609
|
+
* This updates the local record with the current state from GitHub/GitLab/Bitbucket.
|
|
610
|
+
*
|
|
611
|
+
* @param prId - PR record ID
|
|
612
|
+
* @returns Updated PR record
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* ```typescript
|
|
616
|
+
* const pr = await axonflow.syncPRStatus('pr_123');
|
|
617
|
+
* console.log(`PR is now ${pr.state}`);
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
syncPRStatus(prId: string): Promise<PRRecord>;
|
|
461
621
|
}
|
|
462
622
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/cjs/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,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,
|
|
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,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,EAChB,MAAM,SAAS,CAAC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AO,CAAC,2BAA2B,CAAC;IAsBvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,oBAAoB,CACxB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,4BAA4B,CAAC;IAsBxC;;;;;;;;;;;OAWG;IACG,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAW3D;;;;;;;;;OASG;IACG,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA+CnE;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IA0DjE;;;;;;;;;;;OAWG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IA2C5C;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CA0CpD"}
|
package/dist/cjs/client.js
CHANGED
|
@@ -1292,6 +1292,342 @@ class AxonFlow {
|
|
|
1292
1292
|
}
|
|
1293
1293
|
return this.policyRequest('GET', path);
|
|
1294
1294
|
}
|
|
1295
|
+
// ============================================================================
|
|
1296
|
+
// Code Governance Methods (Enterprise)
|
|
1297
|
+
// ============================================================================
|
|
1298
|
+
/**
|
|
1299
|
+
* Validate Git provider credentials before configuration.
|
|
1300
|
+
* Use this to verify tokens and connectivity before saving.
|
|
1301
|
+
*
|
|
1302
|
+
* @param request - Validation request with provider type and credentials
|
|
1303
|
+
* @returns Validation result indicating if credentials are valid
|
|
1304
|
+
*
|
|
1305
|
+
* @example
|
|
1306
|
+
* ```typescript
|
|
1307
|
+
* const result = await axonflow.validateGitProvider({
|
|
1308
|
+
* type: 'github',
|
|
1309
|
+
* token: 'ghp_xxxxxxxxxxxx'
|
|
1310
|
+
* });
|
|
1311
|
+
*
|
|
1312
|
+
* if (result.valid) {
|
|
1313
|
+
* console.log('Credentials are valid');
|
|
1314
|
+
* } else {
|
|
1315
|
+
* console.log('Invalid:', result.message);
|
|
1316
|
+
* }
|
|
1317
|
+
* ```
|
|
1318
|
+
*/
|
|
1319
|
+
async validateGitProvider(request) {
|
|
1320
|
+
if (this.config.debug) {
|
|
1321
|
+
(0, helpers_1.debugLog)('Validating Git provider', { type: request.type });
|
|
1322
|
+
}
|
|
1323
|
+
// Transform camelCase to snake_case for API
|
|
1324
|
+
const apiRequest = {
|
|
1325
|
+
type: request.type,
|
|
1326
|
+
};
|
|
1327
|
+
if (request.token)
|
|
1328
|
+
apiRequest.token = request.token;
|
|
1329
|
+
if (request.baseUrl)
|
|
1330
|
+
apiRequest.base_url = request.baseUrl;
|
|
1331
|
+
if (request.appId)
|
|
1332
|
+
apiRequest.app_id = request.appId;
|
|
1333
|
+
if (request.installationId)
|
|
1334
|
+
apiRequest.installation_id = request.installationId;
|
|
1335
|
+
if (request.privateKey)
|
|
1336
|
+
apiRequest.private_key = request.privateKey;
|
|
1337
|
+
return this.policyRequest('POST', '/api/v1/code-governance/git-providers/validate', apiRequest);
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Configure a Git provider for code governance.
|
|
1341
|
+
* Supports GitHub, GitLab, and Bitbucket (cloud and self-hosted).
|
|
1342
|
+
*
|
|
1343
|
+
* @param request - Configuration request with provider type and credentials
|
|
1344
|
+
* @returns Configuration result
|
|
1345
|
+
*
|
|
1346
|
+
* @example
|
|
1347
|
+
* ```typescript
|
|
1348
|
+
* // Configure GitHub with personal access token
|
|
1349
|
+
* await axonflow.configureGitProvider({
|
|
1350
|
+
* type: 'github',
|
|
1351
|
+
* token: 'ghp_xxxxxxxxxxxx'
|
|
1352
|
+
* });
|
|
1353
|
+
*
|
|
1354
|
+
* // Configure GitLab self-hosted
|
|
1355
|
+
* await axonflow.configureGitProvider({
|
|
1356
|
+
* type: 'gitlab',
|
|
1357
|
+
* token: 'glpat-xxxxxxxxxxxx',
|
|
1358
|
+
* baseUrl: 'https://gitlab.mycompany.com'
|
|
1359
|
+
* });
|
|
1360
|
+
*
|
|
1361
|
+
* // Configure GitHub App
|
|
1362
|
+
* await axonflow.configureGitProvider({
|
|
1363
|
+
* type: 'github',
|
|
1364
|
+
* appId: 12345,
|
|
1365
|
+
* installationId: 67890,
|
|
1366
|
+
* privateKey: '-----BEGIN RSA PRIVATE KEY-----\n...'
|
|
1367
|
+
* });
|
|
1368
|
+
* ```
|
|
1369
|
+
*/
|
|
1370
|
+
async configureGitProvider(request) {
|
|
1371
|
+
if (this.config.debug) {
|
|
1372
|
+
(0, helpers_1.debugLog)('Configuring Git provider', { type: request.type });
|
|
1373
|
+
}
|
|
1374
|
+
// Transform camelCase to snake_case for API
|
|
1375
|
+
const apiRequest = {
|
|
1376
|
+
type: request.type,
|
|
1377
|
+
};
|
|
1378
|
+
if (request.token)
|
|
1379
|
+
apiRequest.token = request.token;
|
|
1380
|
+
if (request.baseUrl)
|
|
1381
|
+
apiRequest.base_url = request.baseUrl;
|
|
1382
|
+
if (request.appId)
|
|
1383
|
+
apiRequest.app_id = request.appId;
|
|
1384
|
+
if (request.installationId)
|
|
1385
|
+
apiRequest.installation_id = request.installationId;
|
|
1386
|
+
if (request.privateKey)
|
|
1387
|
+
apiRequest.private_key = request.privateKey;
|
|
1388
|
+
return this.policyRequest('POST', '/api/v1/code-governance/git-providers', apiRequest);
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* List all configured Git providers for the tenant.
|
|
1392
|
+
*
|
|
1393
|
+
* @returns List of configured providers
|
|
1394
|
+
*
|
|
1395
|
+
* @example
|
|
1396
|
+
* ```typescript
|
|
1397
|
+
* const { providers, count } = await axonflow.listGitProviders();
|
|
1398
|
+
* console.log(`${count} providers configured:`);
|
|
1399
|
+
* providers.forEach(p => console.log(` - ${p.type}`));
|
|
1400
|
+
* ```
|
|
1401
|
+
*/
|
|
1402
|
+
async listGitProviders() {
|
|
1403
|
+
if (this.config.debug) {
|
|
1404
|
+
(0, helpers_1.debugLog)('Listing Git providers');
|
|
1405
|
+
}
|
|
1406
|
+
return this.policyRequest('GET', '/api/v1/code-governance/git-providers');
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Delete a configured Git provider.
|
|
1410
|
+
*
|
|
1411
|
+
* @param type - Provider type to delete (github, gitlab, or bitbucket)
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```typescript
|
|
1415
|
+
* await axonflow.deleteGitProvider('github');
|
|
1416
|
+
* ```
|
|
1417
|
+
*/
|
|
1418
|
+
async deleteGitProvider(type) {
|
|
1419
|
+
if (this.config.debug) {
|
|
1420
|
+
(0, helpers_1.debugLog)('Deleting Git provider', { type });
|
|
1421
|
+
}
|
|
1422
|
+
await this.policyRequest('DELETE', `/api/v1/code-governance/git-providers/${type}`);
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Create a Pull Request from LLM-generated code.
|
|
1426
|
+
* This creates a PR with full audit trail linking back to the AI request.
|
|
1427
|
+
*
|
|
1428
|
+
* @param request - PR creation request with repository info and files
|
|
1429
|
+
* @returns Created PR details including URL and number
|
|
1430
|
+
*
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```typescript
|
|
1433
|
+
* const pr = await axonflow.createPR({
|
|
1434
|
+
* owner: 'myorg',
|
|
1435
|
+
* repo: 'myrepo',
|
|
1436
|
+
* title: 'feat: add user validation utilities',
|
|
1437
|
+
* description: 'LLM-generated validation functions',
|
|
1438
|
+
* files: [
|
|
1439
|
+
* {
|
|
1440
|
+
* path: 'src/utils/validation.ts',
|
|
1441
|
+
* content: generatedCode,
|
|
1442
|
+
* language: 'typescript',
|
|
1443
|
+
* action: 'create'
|
|
1444
|
+
* }
|
|
1445
|
+
* ],
|
|
1446
|
+
* agentRequestId: 'req_123',
|
|
1447
|
+
* model: 'gpt-4',
|
|
1448
|
+
* policiesChecked: ['code-secrets', 'code-unsafe'],
|
|
1449
|
+
* secretsDetected: 0,
|
|
1450
|
+
* unsafePatterns: 0
|
|
1451
|
+
* });
|
|
1452
|
+
*
|
|
1453
|
+
* console.log(`PR created: ${pr.prUrl}`);
|
|
1454
|
+
* ```
|
|
1455
|
+
*/
|
|
1456
|
+
async createPR(request) {
|
|
1457
|
+
if (this.config.debug) {
|
|
1458
|
+
(0, helpers_1.debugLog)('Creating PR', { owner: request.owner, repo: request.repo, title: request.title });
|
|
1459
|
+
}
|
|
1460
|
+
// Transform camelCase to snake_case for API
|
|
1461
|
+
const apiRequest = {
|
|
1462
|
+
owner: request.owner,
|
|
1463
|
+
repo: request.repo,
|
|
1464
|
+
title: request.title,
|
|
1465
|
+
files: request.files.map((f) => ({
|
|
1466
|
+
path: f.path,
|
|
1467
|
+
content: f.content,
|
|
1468
|
+
language: f.language,
|
|
1469
|
+
action: f.action,
|
|
1470
|
+
})),
|
|
1471
|
+
};
|
|
1472
|
+
if (request.description)
|
|
1473
|
+
apiRequest.description = request.description;
|
|
1474
|
+
if (request.baseBranch)
|
|
1475
|
+
apiRequest.base_branch = request.baseBranch;
|
|
1476
|
+
if (request.branchName)
|
|
1477
|
+
apiRequest.branch_name = request.branchName;
|
|
1478
|
+
if (request.draft !== undefined)
|
|
1479
|
+
apiRequest.draft = request.draft;
|
|
1480
|
+
if (request.agentRequestId)
|
|
1481
|
+
apiRequest.agent_request_id = request.agentRequestId;
|
|
1482
|
+
if (request.model)
|
|
1483
|
+
apiRequest.model = request.model;
|
|
1484
|
+
if (request.policiesChecked)
|
|
1485
|
+
apiRequest.policies_checked = request.policiesChecked;
|
|
1486
|
+
if (request.secretsDetected !== undefined)
|
|
1487
|
+
apiRequest.secrets_detected = request.secretsDetected;
|
|
1488
|
+
if (request.unsafePatterns !== undefined)
|
|
1489
|
+
apiRequest.unsafe_patterns = request.unsafePatterns;
|
|
1490
|
+
const response = await this.policyRequest('POST', '/api/v1/code-governance/prs', apiRequest);
|
|
1491
|
+
// Transform snake_case response to camelCase
|
|
1492
|
+
return {
|
|
1493
|
+
prId: response.pr_id,
|
|
1494
|
+
prNumber: response.pr_number,
|
|
1495
|
+
prUrl: response.pr_url,
|
|
1496
|
+
state: response.state,
|
|
1497
|
+
headBranch: response.head_branch,
|
|
1498
|
+
createdAt: response.created_at,
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* List Pull Requests created through code governance.
|
|
1503
|
+
*
|
|
1504
|
+
* @param options - Filtering and pagination options
|
|
1505
|
+
* @returns List of PR records
|
|
1506
|
+
*
|
|
1507
|
+
* @example
|
|
1508
|
+
* ```typescript
|
|
1509
|
+
* const { prs, count } = await axonflow.listPRs({
|
|
1510
|
+
* state: 'open',
|
|
1511
|
+
* limit: 10
|
|
1512
|
+
* });
|
|
1513
|
+
*
|
|
1514
|
+
* prs.forEach(pr => {
|
|
1515
|
+
* console.log(`#${pr.prNumber}: ${pr.title} (${pr.state})`);
|
|
1516
|
+
* if (pr.secretsDetected > 0) {
|
|
1517
|
+
* console.log(` Warning: ${pr.secretsDetected} secrets detected`);
|
|
1518
|
+
* }
|
|
1519
|
+
* });
|
|
1520
|
+
* ```
|
|
1521
|
+
*/
|
|
1522
|
+
async listPRs(options) {
|
|
1523
|
+
const params = new URLSearchParams();
|
|
1524
|
+
if (options?.limit)
|
|
1525
|
+
params.set('limit', String(options.limit));
|
|
1526
|
+
if (options?.offset)
|
|
1527
|
+
params.set('offset', String(options.offset));
|
|
1528
|
+
if (options?.state)
|
|
1529
|
+
params.set('state', options.state);
|
|
1530
|
+
const queryString = params.toString();
|
|
1531
|
+
const path = `/api/v1/code-governance/prs${queryString ? `?${queryString}` : ''}`;
|
|
1532
|
+
if (this.config.debug) {
|
|
1533
|
+
(0, helpers_1.debugLog)('Listing PRs', { options });
|
|
1534
|
+
}
|
|
1535
|
+
const response = await this.policyRequest('GET', path);
|
|
1536
|
+
// Transform snake_case response to camelCase
|
|
1537
|
+
return {
|
|
1538
|
+
prs: response.prs.map((pr) => ({
|
|
1539
|
+
id: pr.id,
|
|
1540
|
+
prNumber: pr.pr_number,
|
|
1541
|
+
prUrl: pr.pr_url,
|
|
1542
|
+
title: pr.title,
|
|
1543
|
+
state: pr.state,
|
|
1544
|
+
owner: pr.owner,
|
|
1545
|
+
repo: pr.repo,
|
|
1546
|
+
headBranch: pr.head_branch,
|
|
1547
|
+
baseBranch: pr.base_branch,
|
|
1548
|
+
filesCount: pr.files_count,
|
|
1549
|
+
secretsDetected: pr.secrets_detected,
|
|
1550
|
+
unsafePatterns: pr.unsafe_patterns,
|
|
1551
|
+
createdAt: pr.created_at,
|
|
1552
|
+
createdBy: pr.created_by,
|
|
1553
|
+
providerType: pr.provider_type,
|
|
1554
|
+
})),
|
|
1555
|
+
count: response.count,
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Get a specific PR record by ID.
|
|
1560
|
+
*
|
|
1561
|
+
* @param prId - PR record ID (internal ID, not GitHub PR number)
|
|
1562
|
+
* @returns PR record details
|
|
1563
|
+
*
|
|
1564
|
+
* @example
|
|
1565
|
+
* ```typescript
|
|
1566
|
+
* const pr = await axonflow.getPR('pr_123');
|
|
1567
|
+
* console.log(`PR #${pr.prNumber}: ${pr.title}`);
|
|
1568
|
+
* ```
|
|
1569
|
+
*/
|
|
1570
|
+
async getPR(prId) {
|
|
1571
|
+
if (this.config.debug) {
|
|
1572
|
+
(0, helpers_1.debugLog)('Getting PR', { prId });
|
|
1573
|
+
}
|
|
1574
|
+
const response = await this.policyRequest('GET', `/api/v1/code-governance/prs/${prId}`);
|
|
1575
|
+
// Transform snake_case response to camelCase
|
|
1576
|
+
return {
|
|
1577
|
+
id: response.id,
|
|
1578
|
+
prNumber: response.pr_number,
|
|
1579
|
+
prUrl: response.pr_url,
|
|
1580
|
+
title: response.title,
|
|
1581
|
+
state: response.state,
|
|
1582
|
+
owner: response.owner,
|
|
1583
|
+
repo: response.repo,
|
|
1584
|
+
headBranch: response.head_branch,
|
|
1585
|
+
baseBranch: response.base_branch,
|
|
1586
|
+
filesCount: response.files_count,
|
|
1587
|
+
secretsDetected: response.secrets_detected,
|
|
1588
|
+
unsafePatterns: response.unsafe_patterns,
|
|
1589
|
+
createdAt: response.created_at,
|
|
1590
|
+
createdBy: response.created_by,
|
|
1591
|
+
providerType: response.provider_type,
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Sync PR status with the Git provider.
|
|
1596
|
+
* This updates the local record with the current state from GitHub/GitLab/Bitbucket.
|
|
1597
|
+
*
|
|
1598
|
+
* @param prId - PR record ID
|
|
1599
|
+
* @returns Updated PR record
|
|
1600
|
+
*
|
|
1601
|
+
* @example
|
|
1602
|
+
* ```typescript
|
|
1603
|
+
* const pr = await axonflow.syncPRStatus('pr_123');
|
|
1604
|
+
* console.log(`PR is now ${pr.state}`);
|
|
1605
|
+
* ```
|
|
1606
|
+
*/
|
|
1607
|
+
async syncPRStatus(prId) {
|
|
1608
|
+
if (this.config.debug) {
|
|
1609
|
+
(0, helpers_1.debugLog)('Syncing PR status', { prId });
|
|
1610
|
+
}
|
|
1611
|
+
const response = await this.policyRequest('POST', `/api/v1/code-governance/prs/${prId}/sync`);
|
|
1612
|
+
// Transform snake_case response to camelCase
|
|
1613
|
+
return {
|
|
1614
|
+
id: response.id,
|
|
1615
|
+
prNumber: response.pr_number,
|
|
1616
|
+
prUrl: response.pr_url,
|
|
1617
|
+
title: response.title,
|
|
1618
|
+
state: response.state,
|
|
1619
|
+
owner: response.owner,
|
|
1620
|
+
repo: response.repo,
|
|
1621
|
+
headBranch: response.head_branch,
|
|
1622
|
+
baseBranch: response.base_branch,
|
|
1623
|
+
filesCount: response.files_count,
|
|
1624
|
+
secretsDetected: response.secrets_detected,
|
|
1625
|
+
unsafePatterns: response.unsafe_patterns,
|
|
1626
|
+
createdAt: response.created_at,
|
|
1627
|
+
createdBy: response.created_by,
|
|
1628
|
+
providerType: response.provider_type,
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1295
1631
|
}
|
|
1296
1632
|
exports.AxonFlow = AxonFlow;
|
|
1297
1633
|
//# sourceMappingURL=client.js.map
|