@salesforce/capg-client 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/README.md +122 -0
- package/dist/client.d.ts +86 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +167 -0
- package/dist/client.js.map +1 -0
- package/dist/connect-api-client.d.ts +82 -0
- package/dist/connect-api-client.d.ts.map +1 -0
- package/dist/connect-api-client.js +106 -0
- package/dist/connect-api-client.js.map +1 -0
- package/dist/constants.d.ts +64 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +68 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors/api.d.ts +79 -0
- package/dist/errors/api.d.ts.map +1 -0
- package/dist/errors/api.js +128 -0
- package/dist/errors/api.js.map +1 -0
- package/dist/errors/auth.d.ts +35 -0
- package/dist/errors/auth.d.ts.map +1 -0
- package/dist/errors/auth.js +50 -0
- package/dist/errors/auth.js.map +1 -0
- package/dist/errors/base.d.ts +103 -0
- package/dist/errors/base.d.ts.map +1 -0
- package/dist/errors/base.js +162 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/hub-org.d.ts +108 -0
- package/dist/errors/hub-org.d.ts.map +1 -0
- package/dist/errors/hub-org.js +144 -0
- package/dist/errors/hub-org.js.map +1 -0
- package/dist/errors/index.d.ts +33 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +42 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/network.d.ts +53 -0
- package/dist/errors/network.d.ts.map +1 -0
- package/dist/errors/network.js +77 -0
- package/dist/errors/network.js.map +1 -0
- package/dist/errors/validation.d.ts +69 -0
- package/dist/errors/validation.d.ts.map +1 -0
- package/dist/errors/validation.js +96 -0
- package/dist/errors/validation.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/org-pref-checker.d.ts +129 -0
- package/dist/org-pref-checker.d.ts.map +1 -0
- package/dist/org-pref-checker.js +193 -0
- package/dist/org-pref-checker.js.map +1 -0
- package/dist/policy-fetcher.d.ts +144 -0
- package/dist/policy-fetcher.d.ts.map +1 -0
- package/dist/policy-fetcher.js +241 -0
- package/dist/policy-fetcher.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +532 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/result.d.ts +282 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +351 -0
- package/dist/types/result.js.map +1 -0
- package/dist/utils/error-classifier.d.ts +55 -0
- package/dist/utils/error-classifier.d.ts.map +1 -0
- package/dist/utils/error-classifier.js +90 -0
- package/dist/utils/error-classifier.js.map +1 -0
- package/package.json +143 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core TypeScript interfaces for @salesforce/capg-client
|
|
3
|
+
*
|
|
4
|
+
* This module exports all type definitions for CAPG (Coding Agent Policy Governance)
|
|
5
|
+
* data structures, API requests, and responses.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* @since v1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Policy category classification
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const category: PolicyCategory = 'SECURITY';
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export type PolicyCategory = 'SECURITY' | 'QUALITY' | 'GOVERNANCE';
|
|
19
|
+
/**
|
|
20
|
+
* Policy status
|
|
21
|
+
*/
|
|
22
|
+
export type PolicyStatus = 'ENABLED' | 'DISABLED';
|
|
23
|
+
/**
|
|
24
|
+
* Policy source origin
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const source: PolicySource = 'SALESFORCE_GLOBAL'; // Salesforce-shipped policy
|
|
29
|
+
* const source: PolicySource = 'ISV'; // ISV-provided policy
|
|
30
|
+
* const source: PolicySource = 'ORG_CUSTOM'; // Custom org policy
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type PolicySource = 'SALESFORCE_GLOBAL' | 'ISV' | 'ORG_CUSTOM';
|
|
34
|
+
/**
|
|
35
|
+
* Policy scope type for scoped assignments
|
|
36
|
+
*/
|
|
37
|
+
export type PolicyScope = 'ORG' | 'PROJECT' | 'TEAM' | 'USER';
|
|
38
|
+
/**
|
|
39
|
+
* Tool type classification
|
|
40
|
+
*/
|
|
41
|
+
export type ToolType = 'CLI' | 'API' | 'LIBRARY';
|
|
42
|
+
/**
|
|
43
|
+
* Tool status (access level)
|
|
44
|
+
*/
|
|
45
|
+
export type ToolStatus = 'ALLOWED' | 'BLOCKED' | 'ENFORCED';
|
|
46
|
+
/**
|
|
47
|
+
* Tool category (optional grouping)
|
|
48
|
+
*/
|
|
49
|
+
export type ToolCategory = string;
|
|
50
|
+
/**
|
|
51
|
+
* Surface type - which AI coding surface applies to
|
|
52
|
+
*
|
|
53
|
+
* **Policy vs Tool Usage:**
|
|
54
|
+
* - **Policies**: Surface is NOT a field in DevopsGovernancePolicy BPO. All policies apply to all surfaces.
|
|
55
|
+
* Consumers must filter policies client-side if surface-specific behavior is needed.
|
|
56
|
+
* - **Tools**: Surface is a MULTIENUM field in DevopsToolRegistry BPO. Tools can be configured per-surface
|
|
57
|
+
* (e.g., 'bash' allowed for AFV but blocked for VaaS).
|
|
58
|
+
*
|
|
59
|
+
* **Surface Types:**
|
|
60
|
+
* - `vibes`: AFV (Agentforce Vibes) - AI agent framework
|
|
61
|
+
* - `vaas`: VaaS (Validation as a Service) - Code validation service
|
|
62
|
+
* - `codey`: Codey Studio - IDE extension
|
|
63
|
+
* - `all`: All surfaces (universal tool configuration)
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const surface: SurfaceType = 'vibes'; // AFV (Agentforce Vibes)
|
|
68
|
+
* const surface: SurfaceType = 'vaas'; // VaaS (Validation as a Service)
|
|
69
|
+
* const surface: SurfaceType = 'codey'; // Codey Studio
|
|
70
|
+
* const surface: SurfaceType = 'all'; // All surfaces
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export type SurfaceType = 'vibes' | 'vaas' | 'codey' | 'all';
|
|
74
|
+
/**
|
|
75
|
+
* Fetch method - REST API only (SOQL removed in v2)
|
|
76
|
+
*/
|
|
77
|
+
export type FetchMethod = 'rest';
|
|
78
|
+
/**
|
|
79
|
+
* Severity level
|
|
80
|
+
*/
|
|
81
|
+
export type Severity = 'Low' | 'Medium' | 'High' | 'Critical';
|
|
82
|
+
/**
|
|
83
|
+
* Risk level for tools
|
|
84
|
+
*/
|
|
85
|
+
export type RiskLevel = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
86
|
+
/**
|
|
87
|
+
* DevopsGovernancePolicy - Core governance policy entity
|
|
88
|
+
*
|
|
89
|
+
* Represents a governance policy that can be applied to AI coding agents.
|
|
90
|
+
* Policies contain rule content (markdown) that is injected into LLM prompts.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const policy: DevopsGovernancePolicy = {
|
|
95
|
+
* policyId: 'CAPGP-000001',
|
|
96
|
+
* policyCode: 'DGP-0001',
|
|
97
|
+
* name: 'No SOQL/SOSL Injection',
|
|
98
|
+
* description: 'Prevent SQL injection vulnerabilities',
|
|
99
|
+
* category: 'SECURITY',
|
|
100
|
+
* status: 'ENABLED',
|
|
101
|
+
* ruleContent: '## Rule: No SOQL Injection\n\nNever concatenate...',
|
|
102
|
+
* policySource: 'SALESFORCE_GLOBAL',
|
|
103
|
+
* globalPolicyVersion: '1.0.0',
|
|
104
|
+
* applicableSurfaces: ['vibes', 'vaas'],
|
|
105
|
+
* createdDate: new Date('2024-01-15'),
|
|
106
|
+
* lastModifiedDate: new Date('2024-02-20')
|
|
107
|
+
* };
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export type DevopsGovernancePolicy = {
|
|
111
|
+
/**
|
|
112
|
+
* Policy ID (AUTONUMBER format: CAPGP-000001)
|
|
113
|
+
*/
|
|
114
|
+
policyId: string;
|
|
115
|
+
/**
|
|
116
|
+
* Business key for programmatic reference (e.g., DGP-0001)
|
|
117
|
+
* Used by consumers to reference policies in code
|
|
118
|
+
*/
|
|
119
|
+
policyCode: string;
|
|
120
|
+
/**
|
|
121
|
+
* Display name for the policy (uses platform Name field)
|
|
122
|
+
*/
|
|
123
|
+
name: string;
|
|
124
|
+
/**
|
|
125
|
+
* Short summary for list views
|
|
126
|
+
*/
|
|
127
|
+
description: string;
|
|
128
|
+
/**
|
|
129
|
+
* Policy category classification
|
|
130
|
+
*/
|
|
131
|
+
category: PolicyCategory;
|
|
132
|
+
/**
|
|
133
|
+
* Master on/off switch for the policy
|
|
134
|
+
*/
|
|
135
|
+
status: PolicyStatus;
|
|
136
|
+
/**
|
|
137
|
+
* Complete markdown rule definition consumed by LLM surfaces
|
|
138
|
+
* Can be up to 131K characters (STRINGPLUSCLOB)
|
|
139
|
+
*/
|
|
140
|
+
ruleContent: string;
|
|
141
|
+
/**
|
|
142
|
+
* Policy origin (Salesforce global, ISV, or org custom)
|
|
143
|
+
*/
|
|
144
|
+
policySource: PolicySource;
|
|
145
|
+
/**
|
|
146
|
+
* Semantic version for global policies (e.g., '1.0.0')
|
|
147
|
+
* Major bump (1.x → 2.x) = breaking rule change
|
|
148
|
+
* Minor (1.0 → 1.1) = additive/clarification
|
|
149
|
+
* Patch (1.0.0 → 1.0.1) = wording fix only
|
|
150
|
+
*/
|
|
151
|
+
globalPolicyVersion?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Priority for policy ordering (higher = more important)
|
|
154
|
+
* Optional field for future use
|
|
155
|
+
*/
|
|
156
|
+
priority?: number;
|
|
157
|
+
/**
|
|
158
|
+
* Severity level for the policy
|
|
159
|
+
* Optional field for future use
|
|
160
|
+
*/
|
|
161
|
+
severity?: Severity;
|
|
162
|
+
/**
|
|
163
|
+
* Forward-compatibility escape hatch for future backend fields
|
|
164
|
+
* Allows the library to handle new fields without breaking changes
|
|
165
|
+
*/
|
|
166
|
+
additionalFields?: Record<string, unknown>;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* DevopsToolRegistry - Tool configuration entity
|
|
170
|
+
*
|
|
171
|
+
* Defines which tools are allowed, blocked, or enforced for AI agents.
|
|
172
|
+
* Independent from policies - tool configuration is orthogonal to governance.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const tool: DevopsToolRegistry = {
|
|
177
|
+
* toolId: 'CAPGT-000001',
|
|
178
|
+
* toolName: 'bash',
|
|
179
|
+
* toolType: 'CLI_COMMAND',
|
|
180
|
+
* accessLevel: 'BLOCKED',
|
|
181
|
+
* riskLevel: 'HIGH',
|
|
182
|
+
* description: 'Execute shell commands',
|
|
183
|
+
* applicableSurfaces: ['vibes', 'vaas'],
|
|
184
|
+
* createdDate: new Date(),
|
|
185
|
+
* lastModifiedDate: new Date()
|
|
186
|
+
* };
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export type DevopsToolRegistry = {
|
|
190
|
+
/**
|
|
191
|
+
* Tool ID (AUTONUMBER format: TOOL-0001)
|
|
192
|
+
*/
|
|
193
|
+
toolId: string;
|
|
194
|
+
/**
|
|
195
|
+
* Tool or skill name (e.g., 'bash', 'read', 'sf')
|
|
196
|
+
*/
|
|
197
|
+
toolName: string;
|
|
198
|
+
/**
|
|
199
|
+
* Tool type classification
|
|
200
|
+
*/
|
|
201
|
+
toolType: ToolType;
|
|
202
|
+
/**
|
|
203
|
+
* Access level for this tool (ALLOWED, BLOCKED, ENFORCED)
|
|
204
|
+
*/
|
|
205
|
+
status: ToolStatus;
|
|
206
|
+
/**
|
|
207
|
+
* Surfaces where this tool configuration applies
|
|
208
|
+
* Multi-enum field (multiple surfaces can be selected)
|
|
209
|
+
*/
|
|
210
|
+
surface: SurfaceType[];
|
|
211
|
+
/**
|
|
212
|
+
* Optional grouping label (e.g., 'SALESFORCE_CLI', 'VERSION_CONTROL')
|
|
213
|
+
*/
|
|
214
|
+
category: ToolCategory;
|
|
215
|
+
/**
|
|
216
|
+
* Tool version (optional)
|
|
217
|
+
*/
|
|
218
|
+
version?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Forward-compatibility escape hatch for future backend fields
|
|
221
|
+
*/
|
|
222
|
+
additionalFields?: Record<string, unknown>;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* OrgInfo - Salesforce organization information
|
|
226
|
+
*
|
|
227
|
+
* Represents a Salesforce org (typically a Dev Hub) that contains governance data.
|
|
228
|
+
*
|
|
229
|
+
* @deprecated Hub org auto-detection has been removed in favor of explicit org alias specification.
|
|
230
|
+
* @internal This type is no longer used in the public API. Consumers should provide org alias directly to CAPGClient methods.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const orgInfo: OrgInfo = {
|
|
235
|
+
* username: 'devhub@example.com',
|
|
236
|
+
* instanceUrl: 'https://example.my.salesforce.com',
|
|
237
|
+
* orgId: '00D5e000000AbCd'
|
|
238
|
+
* };
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export type OrgInfo = {
|
|
242
|
+
/**
|
|
243
|
+
* Login username
|
|
244
|
+
*/
|
|
245
|
+
username: string;
|
|
246
|
+
/**
|
|
247
|
+
* 15-character org ID
|
|
248
|
+
*/
|
|
249
|
+
orgId: string;
|
|
250
|
+
/**
|
|
251
|
+
* Instance URL (e.g., 'https://example.my.salesforce.com')
|
|
252
|
+
*/
|
|
253
|
+
instanceUrl: string;
|
|
254
|
+
/**
|
|
255
|
+
* Whether this org is a Dev Hub (optional)
|
|
256
|
+
*/
|
|
257
|
+
isDevHub?: boolean;
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* OrgPreference - Organization preference settings
|
|
261
|
+
*
|
|
262
|
+
* Contains feature gate settings for governance features.
|
|
263
|
+
*
|
|
264
|
+
* @deprecated This type is not currently used in the library implementation.
|
|
265
|
+
* @internal Feature gate checking is handled by checkGovernanceEnabled() method which returns a boolean directly.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* const pref: OrgPreference = {
|
|
270
|
+
* isGovernanceEnabled: true,
|
|
271
|
+
* featureGates: {
|
|
272
|
+
* CAPG_GOVERNANCE: true,
|
|
273
|
+
* CAPG_TOOL_REGISTRY: true
|
|
274
|
+
* }
|
|
275
|
+
* };
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export type OrgPreference = {
|
|
279
|
+
/**
|
|
280
|
+
* Whether CAPG governance is enabled for this org
|
|
281
|
+
* Check this FIRST after hub org resolution to enable early return
|
|
282
|
+
*/
|
|
283
|
+
isGovernanceEnabled: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Feature gate flags
|
|
286
|
+
*/
|
|
287
|
+
featureGates: Record<string, boolean>;
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* PolicyResponse - Response from fetchPolicies()
|
|
291
|
+
*
|
|
292
|
+
* Contains policies and metadata for caching and diagnostics.
|
|
293
|
+
*
|
|
294
|
+
* **Connect API Context:**
|
|
295
|
+
* The PolicyResponse is returned from the Connect API endpoint `/services/data/v62.0/connect/governance/policies`.
|
|
296
|
+
* This endpoint uses the DevopsGovernancePolicy BPO (Business Process Object) to retrieve governance policies.
|
|
297
|
+
*
|
|
298
|
+
* **Metadata Explanation:**
|
|
299
|
+
* - `cacheKey`: Stable identifier for consumer-side caching (format: policies_{orgAlias}_{timestamp})
|
|
300
|
+
* - `fetchedAt`: Timestamp when policies were retrieved from Connect API
|
|
301
|
+
* - `source`: Always 'rest' (indicates REST API was used, not SOQL query)
|
|
302
|
+
* - `etag`: HTTP ETag for conditional requests (supports 304 Not Modified responses)
|
|
303
|
+
* - `expiresAt`: Suggested cache expiration time (consumer can honor or override)
|
|
304
|
+
* - `isPartial`: Indicates if response is paginated (Phase 2 feature)
|
|
305
|
+
* - `totalCount`: Total policies available on server (Phase 2 feature)
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const response: PolicyResponse = {
|
|
310
|
+
* policies: [policy1, policy2],
|
|
311
|
+
* fetchedAt: new Date(),
|
|
312
|
+
* source: 'rest',
|
|
313
|
+
* cacheKey: 'policies_devhub@example.com_vibes_ORG_1.0.0',
|
|
314
|
+
* expiresAt: new Date(Date.now() + 5 * 60 * 1000),
|
|
315
|
+
* etag: '"abc123"',
|
|
316
|
+
* isPartial: false,
|
|
317
|
+
* totalCount: 2
|
|
318
|
+
* };
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
export type PolicyResponse = {
|
|
322
|
+
/**
|
|
323
|
+
* Array of policies (empty if none found)
|
|
324
|
+
*/
|
|
325
|
+
policies: DevopsGovernancePolicy[];
|
|
326
|
+
/**
|
|
327
|
+
* Timestamp when data was fetched
|
|
328
|
+
*/
|
|
329
|
+
fetchedAt: Date;
|
|
330
|
+
/**
|
|
331
|
+
* Method used to fetch data
|
|
332
|
+
*/
|
|
333
|
+
source: FetchMethod;
|
|
334
|
+
/**
|
|
335
|
+
* Stable cache key for consumer's cache
|
|
336
|
+
* Format: policies_{orgAlias}_{surface}_{scopeType}_{version}
|
|
337
|
+
*/
|
|
338
|
+
cacheKey: string;
|
|
339
|
+
/**
|
|
340
|
+
* Server-provided TTL (when cache should expire)
|
|
341
|
+
*/
|
|
342
|
+
expiresAt?: Date;
|
|
343
|
+
/**
|
|
344
|
+
* ETag for conditional requests (HTTP 304 Not Modified)
|
|
345
|
+
*/
|
|
346
|
+
etag?: string;
|
|
347
|
+
/**
|
|
348
|
+
* True if response is incomplete (partial data returned)
|
|
349
|
+
* Optional field for pagination scenarios
|
|
350
|
+
*/
|
|
351
|
+
isPartial?: boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Total number of policies available (for pagination)
|
|
354
|
+
*/
|
|
355
|
+
totalCount?: number;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* ToolResponse - Response from fetchTools()
|
|
359
|
+
*
|
|
360
|
+
* Contains tool registry entries and metadata for caching.
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* const response: ToolResponse = {
|
|
365
|
+
* tools: [tool1, tool2],
|
|
366
|
+
* fetchedAt: new Date(),
|
|
367
|
+
* source: 'rest',
|
|
368
|
+
* cacheKey: 'tools_devhub@example.com_vibes',
|
|
369
|
+
* expiresAt: new Date(Date.now() + 5 * 60 * 1000),
|
|
370
|
+
* etag: '"xyz789"'
|
|
371
|
+
* };
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
export type ToolResponse = {
|
|
375
|
+
/**
|
|
376
|
+
* Array of tool registry entries (empty if none configured)
|
|
377
|
+
*/
|
|
378
|
+
tools: DevopsToolRegistry[];
|
|
379
|
+
/**
|
|
380
|
+
* Timestamp when data was fetched
|
|
381
|
+
*/
|
|
382
|
+
fetchedAt: Date;
|
|
383
|
+
/**
|
|
384
|
+
* Method used to fetch data
|
|
385
|
+
*/
|
|
386
|
+
source: FetchMethod;
|
|
387
|
+
/**
|
|
388
|
+
* Stable cache key for consumer's cache
|
|
389
|
+
* Format: tools_{orgAlias}_{surface}
|
|
390
|
+
*/
|
|
391
|
+
cacheKey: string;
|
|
392
|
+
/**
|
|
393
|
+
* Server-provided TTL (when cache should expire)
|
|
394
|
+
*/
|
|
395
|
+
expiresAt?: Date;
|
|
396
|
+
/**
|
|
397
|
+
* ETag for conditional requests
|
|
398
|
+
*/
|
|
399
|
+
etag?: string;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* GovernanceData - Combined response from fetchGovernanceData()
|
|
403
|
+
*
|
|
404
|
+
* Batch operation result containing both policies and tools.
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const data: GovernanceData = {
|
|
409
|
+
* policies: policyResponse,
|
|
410
|
+
* tools: toolResponse,
|
|
411
|
+
* orgPreference: {
|
|
412
|
+
* isGovernanceEnabled: true,
|
|
413
|
+
* featureGates: { CAPG_GOVERNANCE: true }
|
|
414
|
+
* },
|
|
415
|
+
* metadata: {
|
|
416
|
+
* cacheKey: 'governance_devhub@example.com_vibes',
|
|
417
|
+
* expiresAt: new Date(Date.now() + 5 * 60 * 1000),
|
|
418
|
+
* fetchedAt: new Date(),
|
|
419
|
+
* version: '1.0.0'
|
|
420
|
+
* }
|
|
421
|
+
* };
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
export type GovernanceData = {
|
|
425
|
+
/**
|
|
426
|
+
* Policy response
|
|
427
|
+
*/
|
|
428
|
+
policies: PolicyResponse;
|
|
429
|
+
/**
|
|
430
|
+
* Tool response
|
|
431
|
+
*/
|
|
432
|
+
tools: ToolResponse;
|
|
433
|
+
/**
|
|
434
|
+
* Organization preference settings
|
|
435
|
+
*/
|
|
436
|
+
orgPreference: OrgPreference;
|
|
437
|
+
/**
|
|
438
|
+
* Combined metadata for batch operation
|
|
439
|
+
*/
|
|
440
|
+
metadata: CacheMetadata;
|
|
441
|
+
};
|
|
442
|
+
/**
|
|
443
|
+
* CacheMetadata - Metadata for caching governance data
|
|
444
|
+
*
|
|
445
|
+
* Provides cache keys, TTLs, and version tracking for consumers.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* const metadata: CacheMetadata = {
|
|
450
|
+
* cacheKey: 'governance_devhub@example.com_vibes',
|
|
451
|
+
* expiresAt: new Date(Date.now() + 5 * 60 * 1000),
|
|
452
|
+
* fetchedAt: new Date(),
|
|
453
|
+
* version: '1.0.0'
|
|
454
|
+
* };
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
export type CacheMetadata = {
|
|
458
|
+
/**
|
|
459
|
+
* Stable cache key (hash of fetched data)
|
|
460
|
+
*/
|
|
461
|
+
cacheKey: string;
|
|
462
|
+
/**
|
|
463
|
+
* When cached data expires (TTL timestamp)
|
|
464
|
+
*/
|
|
465
|
+
expiresAt: Date;
|
|
466
|
+
/**
|
|
467
|
+
* When data was fetched
|
|
468
|
+
*/
|
|
469
|
+
fetchedAt: Date;
|
|
470
|
+
/**
|
|
471
|
+
* Policy version for delta detection
|
|
472
|
+
* Used to determine if cached data is stale
|
|
473
|
+
*/
|
|
474
|
+
version: string;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* FetchPoliciesOptions - Options for fetchPolicies()
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```typescript
|
|
481
|
+
* const options: FetchPoliciesOptions = {
|
|
482
|
+
* includeDisabled: false,
|
|
483
|
+
* sinceVersion: 'v1.0.0'
|
|
484
|
+
* };
|
|
485
|
+
* ```
|
|
486
|
+
*
|
|
487
|
+
* @remarks
|
|
488
|
+
* Surface filtering is NOT supported - surface is not a field in DevopsGovernancePolicy BPO.
|
|
489
|
+
* All policies are fetched and consumers filter client-side if needed.
|
|
490
|
+
*
|
|
491
|
+
* **Phase 1 Implementation (Current):**
|
|
492
|
+
* - `includeDisabled`: Filter by policy status (ENABLED vs DISABLED)
|
|
493
|
+
*
|
|
494
|
+
* **Phase 2 Implementation (Future):**
|
|
495
|
+
* - Policy scoping: Filter by ORG, PROJECT, TEAM, USER scope
|
|
496
|
+
* - Delta fetch: Fetch only policies updated since a specific version
|
|
497
|
+
* - Surface filtering: Client-side filtering by AFV, VaaS, Codey surfaces
|
|
498
|
+
*/
|
|
499
|
+
export type FetchPoliciesOptions = {
|
|
500
|
+
/**
|
|
501
|
+
* Include DISABLED policies (defaults to false)
|
|
502
|
+
*
|
|
503
|
+
* When false (default): fetches only ENABLED policies
|
|
504
|
+
* When true: fetches all policies regardless of status
|
|
505
|
+
*/
|
|
506
|
+
includeDisabled?: boolean;
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* FetchToolsOptions - Options for fetchTools()
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* ```typescript
|
|
513
|
+
* const options: FetchToolsOptions = {
|
|
514
|
+
* surface: 'vibes',
|
|
515
|
+
* status: 'ALLOWED'
|
|
516
|
+
* };
|
|
517
|
+
* ```
|
|
518
|
+
*/
|
|
519
|
+
export type FetchToolsOptions = {
|
|
520
|
+
/**
|
|
521
|
+
* Filter by surface (optional, defaults to 'all')
|
|
522
|
+
*/
|
|
523
|
+
surface?: SurfaceType;
|
|
524
|
+
/**
|
|
525
|
+
* Filter by tool status (optional)
|
|
526
|
+
* One of: 'ALLOWED', 'BLOCKED', 'ENFORCED'
|
|
527
|
+
*/
|
|
528
|
+
status?: ToolStatus;
|
|
529
|
+
};
|
|
530
|
+
export type { Result } from './result.js';
|
|
531
|
+
export { ok, err, isOk, isErr, unwrap, unwrapOr, map, mapErr, match } from './result.js';
|
|
532
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAMH;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,KAAK,GAAG,YAAY,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9D;;GAEG;AACH,MAAM,MA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