@veltrixsecops/app-sdk 1.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/README.md +92 -0
- package/dist/chunk-PJCHU6ZZ.js +33 -0
- package/dist/chunk-PJCHU6ZZ.js.map +1 -0
- package/dist/chunk-TSEIWO6T.js +43 -0
- package/dist/chunk-TSEIWO6T.js.map +1 -0
- package/dist/hooks/index.cjs +71 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +2 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index-BI8f_mBw.d.cts +286 -0
- package/dist/index-BI8f_mBw.d.ts +286 -0
- package/dist/index-CKeIf4Jx.d.cts +239 -0
- package/dist/index-CKeIf4Jx.d.ts +239 -0
- package/dist/index.cjs +106 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline/index.cjs +63 -0
- package/dist/pipeline/index.cjs.map +1 -0
- package/dist/pipeline/index.d.cts +1 -0
- package/dist/pipeline/index.d.ts +1 -0
- package/dist/pipeline/index.js +15 -0
- package/dist/pipeline/index.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
interface ValidationError {
|
|
2
|
+
field: string;
|
|
3
|
+
message: string;
|
|
4
|
+
code: string;
|
|
5
|
+
}
|
|
6
|
+
interface ValidationWarning {
|
|
7
|
+
field: string;
|
|
8
|
+
message: string;
|
|
9
|
+
code: string;
|
|
10
|
+
}
|
|
11
|
+
interface ValidationResult {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
errors: ValidationError[];
|
|
14
|
+
warnings: ValidationWarning[];
|
|
15
|
+
}
|
|
16
|
+
interface DeployResult {
|
|
17
|
+
success: boolean;
|
|
18
|
+
message: string;
|
|
19
|
+
artifacts?: Record<string, unknown>;
|
|
20
|
+
rollbackData?: unknown;
|
|
21
|
+
}
|
|
22
|
+
interface RollbackResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
interface HealthCheck {
|
|
27
|
+
name: string;
|
|
28
|
+
passed: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
latencyMs?: number;
|
|
31
|
+
}
|
|
32
|
+
interface HealthCheckResult {
|
|
33
|
+
healthy: boolean;
|
|
34
|
+
score: number;
|
|
35
|
+
checks: HealthCheck[];
|
|
36
|
+
}
|
|
37
|
+
interface DriftDiff {
|
|
38
|
+
field: string;
|
|
39
|
+
expected: unknown;
|
|
40
|
+
actual: unknown;
|
|
41
|
+
severity: 'info' | 'warning' | 'critical';
|
|
42
|
+
}
|
|
43
|
+
interface DriftResult {
|
|
44
|
+
hasDrift: boolean;
|
|
45
|
+
diffs: DriftDiff[];
|
|
46
|
+
}
|
|
47
|
+
interface ComponentConfigStatus {
|
|
48
|
+
componentId: string;
|
|
49
|
+
hostname: string;
|
|
50
|
+
deployed: boolean;
|
|
51
|
+
version?: string;
|
|
52
|
+
lastDeployedAt?: string;
|
|
53
|
+
healthy?: boolean;
|
|
54
|
+
healthScore?: number;
|
|
55
|
+
}
|
|
56
|
+
interface ConfigStatus {
|
|
57
|
+
deployed: boolean;
|
|
58
|
+
version: string;
|
|
59
|
+
lastDeployedAt: string;
|
|
60
|
+
componentStatuses: ComponentConfigStatus[];
|
|
61
|
+
}
|
|
62
|
+
interface CanvasSectionSnapshot {
|
|
63
|
+
name: string;
|
|
64
|
+
fields: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
interface CanvasSnapshot {
|
|
67
|
+
id: string;
|
|
68
|
+
canvasId: string;
|
|
69
|
+
version: number;
|
|
70
|
+
name: string;
|
|
71
|
+
toolType: string;
|
|
72
|
+
entityType: string;
|
|
73
|
+
sections: CanvasSectionSnapshot[];
|
|
74
|
+
snapshot: Record<string, unknown>;
|
|
75
|
+
}
|
|
76
|
+
type DeploymentStrategy = 'DIRECT' | 'CANARY' | 'BLUE_GREEN' | 'ROLLING';
|
|
77
|
+
interface EnvironmentRef {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
}
|
|
81
|
+
interface UserRef {
|
|
82
|
+
id: string;
|
|
83
|
+
email: string;
|
|
84
|
+
name: string | null;
|
|
85
|
+
}
|
|
86
|
+
interface ComponentRef {
|
|
87
|
+
id: string;
|
|
88
|
+
hostname: string;
|
|
89
|
+
port: string;
|
|
90
|
+
type: string[];
|
|
91
|
+
toolId: string;
|
|
92
|
+
}
|
|
93
|
+
interface CredentialRef {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
username: string;
|
|
97
|
+
password: string;
|
|
98
|
+
apiToken: string | null;
|
|
99
|
+
certificate: string | null;
|
|
100
|
+
}
|
|
101
|
+
interface ConnectivityRef {
|
|
102
|
+
id: string;
|
|
103
|
+
status: string;
|
|
104
|
+
sshCommand: string | null;
|
|
105
|
+
httpsUrl: string | null;
|
|
106
|
+
tailscaleDeviceIP: string | null;
|
|
107
|
+
}
|
|
108
|
+
/** Provider-aware connectivity passed to handlers when a ConnectivityProvider is configured */
|
|
109
|
+
interface ConnectivityProviderRef {
|
|
110
|
+
id: string;
|
|
111
|
+
providerType: string;
|
|
112
|
+
name: string;
|
|
113
|
+
status: string;
|
|
114
|
+
config: Record<string, unknown>;
|
|
115
|
+
}
|
|
116
|
+
/** Summary of a deployment record, returned by PlatformDataApi */
|
|
117
|
+
interface DeploymentSummary {
|
|
118
|
+
id: string;
|
|
119
|
+
canvasId: string;
|
|
120
|
+
status: string;
|
|
121
|
+
healthScore: number | null;
|
|
122
|
+
startedAt: string;
|
|
123
|
+
completedAt: string | null;
|
|
124
|
+
environment: EnvironmentRef;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Tenant-scoped, read-only access to platform data, provided on every
|
|
128
|
+
* handler context as `ctx.platform`. Apps must use this instead of
|
|
129
|
+
* querying the platform database directly — it is the only supported
|
|
130
|
+
* way to read platform records from an app.
|
|
131
|
+
*/
|
|
132
|
+
interface PlatformDataApi {
|
|
133
|
+
/** Latest deployment for a canvas, optionally filtered by status (e.g. 'SUCCEEDED'). */
|
|
134
|
+
getLatestDeployment(canvasId: string, opts?: {
|
|
135
|
+
status?: string;
|
|
136
|
+
}): Promise<DeploymentSummary | null>;
|
|
137
|
+
/** Components for the current customer, optionally filtered by component types. */
|
|
138
|
+
listComponents(filter?: {
|
|
139
|
+
types?: string[];
|
|
140
|
+
}): Promise<ComponentRef[]>;
|
|
141
|
+
}
|
|
142
|
+
interface PipelineContext {
|
|
143
|
+
appId: string;
|
|
144
|
+
customerId: string;
|
|
145
|
+
configTypeId: string;
|
|
146
|
+
canvas: CanvasSnapshot;
|
|
147
|
+
environment: EnvironmentRef;
|
|
148
|
+
user: UserRef;
|
|
149
|
+
settings: Record<string, unknown>;
|
|
150
|
+
platform: PlatformDataApi;
|
|
151
|
+
}
|
|
152
|
+
interface DeployContext extends PipelineContext {
|
|
153
|
+
component: ComponentRef;
|
|
154
|
+
credential: CredentialRef | null;
|
|
155
|
+
connectivity: ConnectivityRef | null;
|
|
156
|
+
connectivityProvider: ConnectivityProviderRef | null;
|
|
157
|
+
previousConfig: CanvasSnapshot | null;
|
|
158
|
+
strategy: DeploymentStrategy;
|
|
159
|
+
canaryPercent?: number;
|
|
160
|
+
}
|
|
161
|
+
interface RollbackContext extends PipelineContext {
|
|
162
|
+
component: ComponentRef;
|
|
163
|
+
credential: CredentialRef | null;
|
|
164
|
+
connectivity: ConnectivityRef | null;
|
|
165
|
+
connectivityProvider: ConnectivityProviderRef | null;
|
|
166
|
+
rollbackData: unknown;
|
|
167
|
+
targetVersion: CanvasSnapshot;
|
|
168
|
+
}
|
|
169
|
+
interface HealthCheckContext extends PipelineContext {
|
|
170
|
+
component: ComponentRef;
|
|
171
|
+
credential: CredentialRef | null;
|
|
172
|
+
connectivity: ConnectivityRef | null;
|
|
173
|
+
connectivityProvider: ConnectivityProviderRef | null;
|
|
174
|
+
}
|
|
175
|
+
interface DriftContext extends PipelineContext {
|
|
176
|
+
component: ComponentRef;
|
|
177
|
+
credential: CredentialRef | null;
|
|
178
|
+
connectivity: ConnectivityRef | null;
|
|
179
|
+
connectivityProvider: ConnectivityProviderRef | null;
|
|
180
|
+
deployedConfig: CanvasSnapshot;
|
|
181
|
+
}
|
|
182
|
+
type ValidateHandler = (ctx: PipelineContext) => Promise<ValidationResult>;
|
|
183
|
+
type DeployHandler = (ctx: DeployContext) => Promise<DeployResult>;
|
|
184
|
+
type RollbackHandler = (ctx: RollbackContext) => Promise<RollbackResult>;
|
|
185
|
+
type HealthCheckHandler = (ctx: HealthCheckContext) => Promise<HealthCheckResult>;
|
|
186
|
+
type DriftDetectHandler = (ctx: DriftContext) => Promise<DriftResult>;
|
|
187
|
+
type GetStatusHandler = (ctx: PipelineContext) => Promise<ConfigStatus>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Define a validation handler for a configuration type.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* import { defineValidator } from '@veltrixsecops/app-sdk/pipeline'
|
|
195
|
+
*
|
|
196
|
+
* export default defineValidator(async (ctx) => {
|
|
197
|
+
* const errors = []
|
|
198
|
+
* const name = ctx.canvas.sections[0]?.fields['name']
|
|
199
|
+
* if (!name) {
|
|
200
|
+
* errors.push({ field: 'name', message: 'Name is required', code: 'REQUIRED' })
|
|
201
|
+
* }
|
|
202
|
+
* return { valid: errors.length === 0, errors, warnings: [] }
|
|
203
|
+
* })
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
declare function defineValidator(handler: (ctx: PipelineContext) => Promise<ValidationResult>): (ctx: PipelineContext) => Promise<ValidationResult>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Define a deploy handler for a configuration type.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* import { defineDeployer } from '@veltrixsecops/app-sdk/pipeline'
|
|
214
|
+
*
|
|
215
|
+
* export default defineDeployer(async (ctx) => {
|
|
216
|
+
* const { component, credential, connectivity, canvas } = ctx
|
|
217
|
+
* // Push configuration to the tool
|
|
218
|
+
* return { success: true, message: 'Deployed', rollbackData: previousState }
|
|
219
|
+
* })
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare function defineDeployer(handler: (ctx: DeployContext) => Promise<DeployResult>): (ctx: DeployContext) => Promise<DeployResult>;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Define a rollback handler for a configuration type.
|
|
226
|
+
*/
|
|
227
|
+
declare function defineRollbackHandler(handler: (ctx: RollbackContext) => Promise<RollbackResult>): (ctx: RollbackContext) => Promise<RollbackResult>;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Define a health check handler for a configuration type.
|
|
231
|
+
*/
|
|
232
|
+
declare function defineHealthChecker(handler: (ctx: HealthCheckContext) => Promise<HealthCheckResult>): (ctx: HealthCheckContext) => Promise<HealthCheckResult>;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Define a drift detection handler for a configuration type.
|
|
236
|
+
*/
|
|
237
|
+
declare function defineDriftDetector(handler: (ctx: DriftContext) => Promise<DriftResult>): (ctx: DriftContext) => Promise<DriftResult>;
|
|
238
|
+
|
|
239
|
+
export { defineHealthChecker as A, defineRollbackHandler as B, type CanvasSectionSnapshot as C, type DeployContext as D, type EnvironmentRef as E, defineValidator as F, type GetStatusHandler as G, type HealthCheck as H, type PipelineContext as P, type RollbackContext as R, type UserRef as U, type ValidateHandler as V, type CanvasSnapshot as a, type ComponentConfigStatus as b, type ComponentRef as c, type ConfigStatus as d, type ConnectivityProviderRef as e, type ConnectivityRef as f, type CredentialRef as g, type DeployHandler as h, type DeployResult as i, type DeploymentStrategy as j, type DeploymentSummary as k, type DriftContext as l, type DriftDetectHandler as m, type DriftDiff as n, type DriftResult as o, type HealthCheckContext as p, type HealthCheckHandler as q, type HealthCheckResult as r, type PlatformDataApi as s, type RollbackHandler as t, type RollbackResult as u, type ValidationError as v, type ValidationResult as w, type ValidationWarning as x, defineDeployer as y, defineDriftDetector as z };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
AppContext: () => AppContext,
|
|
24
|
+
defineDeployer: () => defineDeployer,
|
|
25
|
+
defineDriftDetector: () => defineDriftDetector,
|
|
26
|
+
defineHealthChecker: () => defineHealthChecker,
|
|
27
|
+
defineRollbackHandler: () => defineRollbackHandler,
|
|
28
|
+
defineValidator: () => defineValidator,
|
|
29
|
+
useAppContext: () => useAppContext,
|
|
30
|
+
usePipelineStatus: () => usePipelineStatus
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
|
|
34
|
+
// src/pipeline/define-validator.ts
|
|
35
|
+
function defineValidator(handler) {
|
|
36
|
+
return handler;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/pipeline/define-deployer.ts
|
|
40
|
+
function defineDeployer(handler) {
|
|
41
|
+
return handler;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/pipeline/define-rollback-handler.ts
|
|
45
|
+
function defineRollbackHandler(handler) {
|
|
46
|
+
return handler;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/pipeline/define-health-checker.ts
|
|
50
|
+
function defineHealthChecker(handler) {
|
|
51
|
+
return handler;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/pipeline/define-drift-detector.ts
|
|
55
|
+
function defineDriftDetector(handler) {
|
|
56
|
+
return handler;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/hooks/use-app-context.ts
|
|
60
|
+
var import_react = require("react");
|
|
61
|
+
var AppContext = (0, import_react.createContext)(null);
|
|
62
|
+
function useAppContext() {
|
|
63
|
+
const ctx = (0, import_react.useContext)(AppContext);
|
|
64
|
+
if (!ctx) {
|
|
65
|
+
throw new Error("useAppContext must be used within an AppContextProvider");
|
|
66
|
+
}
|
|
67
|
+
return ctx;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/hooks/use-pipeline-status.ts
|
|
71
|
+
var import_react2 = require("react");
|
|
72
|
+
function usePipelineStatus(appId) {
|
|
73
|
+
const [data, setData] = (0, import_react2.useState)(null);
|
|
74
|
+
const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
|
|
75
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
76
|
+
const refresh = (0, import_react2.useCallback)(async () => {
|
|
77
|
+
try {
|
|
78
|
+
setIsLoading(true);
|
|
79
|
+
const response = await fetch(`/api/pipeline/summary?appId=${appId}`);
|
|
80
|
+
if (!response.ok) throw new Error(`Failed to fetch pipeline status`);
|
|
81
|
+
const result = await response.json();
|
|
82
|
+
setData(result);
|
|
83
|
+
setError(null);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
setError(err instanceof Error ? err : new Error("Unknown error"));
|
|
86
|
+
} finally {
|
|
87
|
+
setIsLoading(false);
|
|
88
|
+
}
|
|
89
|
+
}, [appId]);
|
|
90
|
+
(0, import_react2.useEffect)(() => {
|
|
91
|
+
refresh();
|
|
92
|
+
}, [refresh]);
|
|
93
|
+
return { data, isLoading, error, refresh };
|
|
94
|
+
}
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
AppContext,
|
|
98
|
+
defineDeployer,
|
|
99
|
+
defineDriftDetector,
|
|
100
|
+
defineHealthChecker,
|
|
101
|
+
defineRollbackHandler,
|
|
102
|
+
defineValidator,
|
|
103
|
+
useAppContext,
|
|
104
|
+
usePipelineStatus
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/pipeline/define-validator.ts","../src/pipeline/define-deployer.ts","../src/pipeline/define-rollback-handler.ts","../src/pipeline/define-health-checker.ts","../src/pipeline/define-drift-detector.ts","../src/hooks/use-app-context.ts","../src/hooks/use-pipeline-status.ts"],"sourcesContent":["// ========================================================================\n// @veltrixsecops/app-sdk\n//\n// The official SDK for building Veltrix Security-as-Code apps.\n// Import pipeline helpers, hooks, and types to build your app.\n//\n// Usage:\n// import { defineValidator, defineDeployer } from '@veltrixsecops/app-sdk/pipeline'\n// import { useAppContext, usePipelineStatus } from '@veltrixsecops/app-sdk/hooks'\n// import type { PipelineContext, DeployContext } from '@veltrixsecops/app-sdk'\n// ========================================================================\n\n// Pipeline handler helpers\nexport {\n defineValidator,\n defineDeployer,\n defineRollbackHandler,\n defineHealthChecker,\n defineDriftDetector,\n} from './pipeline'\n\n// React hooks\nexport {\n useAppContext,\n AppContext,\n usePipelineStatus,\n} from './hooks'\n\n// Pipeline types\nexport type {\n PipelineContext,\n DeployContext,\n RollbackContext,\n HealthCheckContext,\n DriftContext,\n ValidationResult,\n ValidationError,\n ValidationWarning,\n DeployResult,\n RollbackResult,\n HealthCheckResult,\n HealthCheck,\n DriftResult,\n DriftDiff,\n ConfigStatus,\n ComponentConfigStatus,\n CanvasSnapshot,\n CanvasSectionSnapshot,\n DeploymentStrategy,\n EnvironmentRef,\n UserRef,\n ComponentRef,\n CredentialRef,\n ConnectivityRef,\n ConnectivityProviderRef,\n PlatformDataApi,\n DeploymentSummary,\n ValidateHandler,\n DeployHandler,\n RollbackHandler,\n HealthCheckHandler,\n DriftDetectHandler,\n GetStatusHandler,\n} from './types/pipeline'\n\n// Platform types\nexport type {\n Component,\n Credential,\n Connectivity,\n Tag,\n User,\n Customer,\n PlatformDatabaseClient,\n AppHookContext,\n AppRouteContext,\n} from './types/platform'\n\n// Manifest types\nexport type {\n AppManifest,\n AppConfigurationTypeManifest,\n AppPermissionDeclaration,\n AppPageDeclaration,\n AppSettingDeclaration,\n AppSource,\n AppStatusType,\n AppInstallationStatus,\n AppListItem,\n AppDetail,\n AppInstallationDetail,\n} from './types/manifest'\n\n// Hooks types\nexport type { AppContextValue, PipelineStatusData } from './hooks'\n","import type { PipelineContext, ValidationResult } from '../types/pipeline'\n\n/**\n * Define a validation handler for a configuration type.\n *\n * @example\n * ```ts\n * import { defineValidator } from '@veltrixsecops/app-sdk/pipeline'\n *\n * export default defineValidator(async (ctx) => {\n * const errors = []\n * const name = ctx.canvas.sections[0]?.fields['name']\n * if (!name) {\n * errors.push({ field: 'name', message: 'Name is required', code: 'REQUIRED' })\n * }\n * return { valid: errors.length === 0, errors, warnings: [] }\n * })\n * ```\n */\nexport function defineValidator(\n handler: (ctx: PipelineContext) => Promise<ValidationResult>,\n): (ctx: PipelineContext) => Promise<ValidationResult> {\n return handler\n}\n","import type { DeployContext, DeployResult } from '../types/pipeline'\n\n/**\n * Define a deploy handler for a configuration type.\n *\n * @example\n * ```ts\n * import { defineDeployer } from '@veltrixsecops/app-sdk/pipeline'\n *\n * export default defineDeployer(async (ctx) => {\n * const { component, credential, connectivity, canvas } = ctx\n * // Push configuration to the tool\n * return { success: true, message: 'Deployed', rollbackData: previousState }\n * })\n * ```\n */\nexport function defineDeployer(\n handler: (ctx: DeployContext) => Promise<DeployResult>,\n): (ctx: DeployContext) => Promise<DeployResult> {\n return handler\n}\n","import type { RollbackContext, RollbackResult } from '../types/pipeline'\r\n\r\n/**\r\n * Define a rollback handler for a configuration type.\r\n */\r\nexport function defineRollbackHandler(\r\n handler: (ctx: RollbackContext) => Promise<RollbackResult>,\r\n): (ctx: RollbackContext) => Promise<RollbackResult> {\r\n return handler\r\n}\r\n","import type { HealthCheckContext, HealthCheckResult } from '../types/pipeline'\r\n\r\n/**\r\n * Define a health check handler for a configuration type.\r\n */\r\nexport function defineHealthChecker(\r\n handler: (ctx: HealthCheckContext) => Promise<HealthCheckResult>,\r\n): (ctx: HealthCheckContext) => Promise<HealthCheckResult> {\r\n return handler\r\n}\r\n","import type { DriftContext, DriftResult } from '../types/pipeline'\r\n\r\n/**\r\n * Define a drift detection handler for a configuration type.\r\n */\r\nexport function defineDriftDetector(\r\n handler: (ctx: DriftContext) => Promise<DriftResult>,\r\n): (ctx: DriftContext) => Promise<DriftResult> {\r\n return handler\r\n}\r\n","// ========================================================================\n// React hooks for app developers\n// These provide access to platform data and pipeline state\n// ========================================================================\n\nimport { createContext, useContext } from 'react'\nimport type { Component, Credential, Tag, User, Customer } from '../types/platform'\n\nexport interface AppContextValue {\n appId: string\n customerId: string\n user: User | null\n customer: Customer | null\n\n // Platform data accessors\n getComponents: () => Promise<Component[]>\n getCredentials: () => Promise<Credential[]>\n getTags: () => Promise<Tag[]>\n\n // App settings\n settings: Record<string, unknown>\n}\n\nexport const AppContext = createContext<AppContextValue | null>(null)\n\n/**\n * Access the app context in any app component.\n *\n * @example\n * ```tsx\n * import { useAppContext } from '@veltrixsecops/app-sdk/hooks'\n *\n * function MyComponent() {\n * const { appId, settings, getComponents } = useAppContext()\n * // ...\n * }\n * ```\n */\nexport function useAppContext(): AppContextValue {\n const ctx = useContext(AppContext)\n if (!ctx) {\n throw new Error('useAppContext must be used within an AppContextProvider')\n }\n return ctx\n}\n","import { useState, useEffect, useCallback } from 'react'\n\nexport interface PipelineStatusData {\n pendingApprovals: number\n activeDeployments: number\n failedDeployments: number\n unresolvedDrifts: number\n recentDeployments: Array<{\n id: string\n canvasName: string\n environment: string\n status: string\n startedAt: string\n completedAt?: string\n }>\n}\n\n/**\n * Hook to access pipeline status for the current app/customer.\n *\n * @example\n * ```tsx\n * import { usePipelineStatus } from '@veltrixsecops/app-sdk/hooks'\n *\n * function Dashboard() {\n * const { data, isLoading } = usePipelineStatus('my-app')\n * if (isLoading) return <Spinner />\n * return <div>{data.activeDeployments} active deployments</div>\n * }\n * ```\n */\nexport function usePipelineStatus(appId: string) {\n const [data, setData] = useState<PipelineStatusData | null>(null)\n const [isLoading, setIsLoading] = useState(true)\n const [error, setError] = useState<Error | null>(null)\n\n const refresh = useCallback(async () => {\n try {\n setIsLoading(true)\n const response = await fetch(`/api/pipeline/summary?appId=${appId}`)\n if (!response.ok) throw new Error(`Failed to fetch pipeline status`)\n const result = await response.json()\n setData(result)\n setError(null)\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'))\n } finally {\n setIsLoading(false)\n }\n }, [appId])\n\n useEffect(() => {\n refresh()\n }, [refresh])\n\n return { data, isLoading, error, refresh }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBO,SAAS,gBACd,SACqD;AACrD,SAAO;AACT;;;ACPO,SAAS,eACd,SAC+C;AAC/C,SAAO;AACT;;;ACfO,SAAS,sBACd,SACmD;AACnD,SAAO;AACT;;;ACJO,SAAS,oBACd,SACyD;AACzD,SAAO;AACT;;;ACJO,SAAS,oBACd,SAC6C;AAC7C,SAAO;AACT;;;ACJA,mBAA0C;AAkBnC,IAAM,iBAAa,4BAAsC,IAAI;AAe7D,SAAS,gBAAiC;AAC/C,QAAM,UAAM,yBAAW,UAAU;AACjC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AACA,SAAO;AACT;;;AC5CA,IAAAA,gBAAiD;AA+B1C,SAAS,kBAAkB,OAAe;AAC/C,QAAM,CAAC,MAAM,OAAO,QAAI,wBAAoC,IAAI;AAChE,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAuB,IAAI;AAErD,QAAM,cAAU,2BAAY,YAAY;AACtC,QAAI;AACF,mBAAa,IAAI;AACjB,YAAM,WAAW,MAAM,MAAM,+BAA+B,KAAK,EAAE;AACnE,UAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,iCAAiC;AACnE,YAAM,SAAS,MAAM,SAAS,KAAK;AACnC,cAAQ,MAAM;AACd,eAAS,IAAI;AAAA,IACf,SAAS,KAAK;AACZ,eAAS,eAAe,QAAQ,MAAM,IAAI,MAAM,eAAe,CAAC;AAAA,IAClE,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,KAAK,CAAC;AAEV,+BAAU,MAAM;AACd,YAAQ;AAAA,EACV,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,MAAM,WAAW,OAAO,QAAQ;AAC3C;","names":["import_react"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { C as CanvasSectionSnapshot, a as CanvasSnapshot, b as ComponentConfigStatus, c as ComponentRef, d as ConfigStatus, e as ConnectivityProviderRef, f as ConnectivityRef, g as CredentialRef, D as DeployContext, h as DeployHandler, i as DeployResult, j as DeploymentStrategy, k as DeploymentSummary, l as DriftContext, m as DriftDetectHandler, n as DriftDiff, o as DriftResult, E as EnvironmentRef, G as GetStatusHandler, H as HealthCheck, p as HealthCheckContext, q as HealthCheckHandler, r as HealthCheckResult, P as PipelineContext, s as PlatformDataApi, R as RollbackContext, t as RollbackHandler, u as RollbackResult, U as UserRef, V as ValidateHandler, v as ValidationError, w as ValidationResult, x as ValidationWarning, y as defineDeployer, z as defineDriftDetector, A as defineHealthChecker, B as defineRollbackHandler, F as defineValidator } from './index-CKeIf4Jx.cjs';
|
|
2
|
+
export { A as AppConfigurationTypeManifest, a as AppContext, b as AppContextValue, c as AppDetail, d as AppHookContext, e as AppInstallationDetail, f as AppInstallationStatus, g as AppListItem, h as AppManifest, i as AppPageDeclaration, j as AppPermissionDeclaration, k as AppRouteContext, l as AppSettingDeclaration, m as AppSource, n as AppStatusType, C as Component, o as Connectivity, p as Credential, q as Customer, P as PipelineStatusData, r as PlatformDatabaseClient, T as Tag, U as User, u as useAppContext, s as usePipelineStatus } from './index-BI8f_mBw.cjs';
|
|
3
|
+
import 'react';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { C as CanvasSectionSnapshot, a as CanvasSnapshot, b as ComponentConfigStatus, c as ComponentRef, d as ConfigStatus, e as ConnectivityProviderRef, f as ConnectivityRef, g as CredentialRef, D as DeployContext, h as DeployHandler, i as DeployResult, j as DeploymentStrategy, k as DeploymentSummary, l as DriftContext, m as DriftDetectHandler, n as DriftDiff, o as DriftResult, E as EnvironmentRef, G as GetStatusHandler, H as HealthCheck, p as HealthCheckContext, q as HealthCheckHandler, r as HealthCheckResult, P as PipelineContext, s as PlatformDataApi, R as RollbackContext, t as RollbackHandler, u as RollbackResult, U as UserRef, V as ValidateHandler, v as ValidationError, w as ValidationResult, x as ValidationWarning, y as defineDeployer, z as defineDriftDetector, A as defineHealthChecker, B as defineRollbackHandler, F as defineValidator } from './index-CKeIf4Jx.js';
|
|
2
|
+
export { A as AppConfigurationTypeManifest, a as AppContext, b as AppContextValue, c as AppDetail, d as AppHookContext, e as AppInstallationDetail, f as AppInstallationStatus, g as AppListItem, h as AppManifest, i as AppPageDeclaration, j as AppPermissionDeclaration, k as AppRouteContext, l as AppSettingDeclaration, m as AppSource, n as AppStatusType, C as Component, o as Connectivity, p as Credential, q as Customer, P as PipelineStatusData, r as PlatformDatabaseClient, T as Tag, U as User, u as useAppContext, s as usePipelineStatus } from './index-BI8f_mBw.js';
|
|
3
|
+
import 'react';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineDeployer,
|
|
3
|
+
defineDriftDetector,
|
|
4
|
+
defineHealthChecker,
|
|
5
|
+
defineRollbackHandler,
|
|
6
|
+
defineValidator
|
|
7
|
+
} from "./chunk-PJCHU6ZZ.js";
|
|
8
|
+
import {
|
|
9
|
+
AppContext,
|
|
10
|
+
useAppContext,
|
|
11
|
+
usePipelineStatus
|
|
12
|
+
} from "./chunk-TSEIWO6T.js";
|
|
13
|
+
export {
|
|
14
|
+
AppContext,
|
|
15
|
+
defineDeployer,
|
|
16
|
+
defineDriftDetector,
|
|
17
|
+
defineHealthChecker,
|
|
18
|
+
defineRollbackHandler,
|
|
19
|
+
defineValidator,
|
|
20
|
+
useAppContext,
|
|
21
|
+
usePipelineStatus
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/pipeline/index.ts
|
|
21
|
+
var pipeline_exports = {};
|
|
22
|
+
__export(pipeline_exports, {
|
|
23
|
+
defineDeployer: () => defineDeployer,
|
|
24
|
+
defineDriftDetector: () => defineDriftDetector,
|
|
25
|
+
defineHealthChecker: () => defineHealthChecker,
|
|
26
|
+
defineRollbackHandler: () => defineRollbackHandler,
|
|
27
|
+
defineValidator: () => defineValidator
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(pipeline_exports);
|
|
30
|
+
|
|
31
|
+
// src/pipeline/define-validator.ts
|
|
32
|
+
function defineValidator(handler) {
|
|
33
|
+
return handler;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/pipeline/define-deployer.ts
|
|
37
|
+
function defineDeployer(handler) {
|
|
38
|
+
return handler;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/pipeline/define-rollback-handler.ts
|
|
42
|
+
function defineRollbackHandler(handler) {
|
|
43
|
+
return handler;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/pipeline/define-health-checker.ts
|
|
47
|
+
function defineHealthChecker(handler) {
|
|
48
|
+
return handler;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/pipeline/define-drift-detector.ts
|
|
52
|
+
function defineDriftDetector(handler) {
|
|
53
|
+
return handler;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
defineDeployer,
|
|
58
|
+
defineDriftDetector,
|
|
59
|
+
defineHealthChecker,
|
|
60
|
+
defineRollbackHandler,
|
|
61
|
+
defineValidator
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/pipeline/index.ts","../../src/pipeline/define-validator.ts","../../src/pipeline/define-deployer.ts","../../src/pipeline/define-rollback-handler.ts","../../src/pipeline/define-health-checker.ts","../../src/pipeline/define-drift-detector.ts"],"sourcesContent":["export { defineValidator } from './define-validator'\r\nexport { defineDeployer } from './define-deployer'\r\nexport { defineRollbackHandler } from './define-rollback-handler'\r\nexport { defineHealthChecker } from './define-health-checker'\r\nexport { defineDriftDetector } from './define-drift-detector'\r\n","import type { PipelineContext, ValidationResult } from '../types/pipeline'\n\n/**\n * Define a validation handler for a configuration type.\n *\n * @example\n * ```ts\n * import { defineValidator } from '@veltrixsecops/app-sdk/pipeline'\n *\n * export default defineValidator(async (ctx) => {\n * const errors = []\n * const name = ctx.canvas.sections[0]?.fields['name']\n * if (!name) {\n * errors.push({ field: 'name', message: 'Name is required', code: 'REQUIRED' })\n * }\n * return { valid: errors.length === 0, errors, warnings: [] }\n * })\n * ```\n */\nexport function defineValidator(\n handler: (ctx: PipelineContext) => Promise<ValidationResult>,\n): (ctx: PipelineContext) => Promise<ValidationResult> {\n return handler\n}\n","import type { DeployContext, DeployResult } from '../types/pipeline'\n\n/**\n * Define a deploy handler for a configuration type.\n *\n * @example\n * ```ts\n * import { defineDeployer } from '@veltrixsecops/app-sdk/pipeline'\n *\n * export default defineDeployer(async (ctx) => {\n * const { component, credential, connectivity, canvas } = ctx\n * // Push configuration to the tool\n * return { success: true, message: 'Deployed', rollbackData: previousState }\n * })\n * ```\n */\nexport function defineDeployer(\n handler: (ctx: DeployContext) => Promise<DeployResult>,\n): (ctx: DeployContext) => Promise<DeployResult> {\n return handler\n}\n","import type { RollbackContext, RollbackResult } from '../types/pipeline'\r\n\r\n/**\r\n * Define a rollback handler for a configuration type.\r\n */\r\nexport function defineRollbackHandler(\r\n handler: (ctx: RollbackContext) => Promise<RollbackResult>,\r\n): (ctx: RollbackContext) => Promise<RollbackResult> {\r\n return handler\r\n}\r\n","import type { HealthCheckContext, HealthCheckResult } from '../types/pipeline'\r\n\r\n/**\r\n * Define a health check handler for a configuration type.\r\n */\r\nexport function defineHealthChecker(\r\n handler: (ctx: HealthCheckContext) => Promise<HealthCheckResult>,\r\n): (ctx: HealthCheckContext) => Promise<HealthCheckResult> {\r\n return handler\r\n}\r\n","import type { DriftContext, DriftResult } from '../types/pipeline'\r\n\r\n/**\r\n * Define a drift detection handler for a configuration type.\r\n */\r\nexport function defineDriftDetector(\r\n handler: (ctx: DriftContext) => Promise<DriftResult>,\r\n): (ctx: DriftContext) => Promise<DriftResult> {\r\n return handler\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBO,SAAS,gBACd,SACqD;AACrD,SAAO;AACT;;;ACPO,SAAS,eACd,SAC+C;AAC/C,SAAO;AACT;;;ACfO,SAAS,sBACd,SACmD;AACnD,SAAO;AACT;;;ACJO,SAAS,oBACd,SACyD;AACzD,SAAO;AACT;;;ACJO,SAAS,oBACd,SAC6C;AAC7C,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { y as defineDeployer, z as defineDriftDetector, A as defineHealthChecker, B as defineRollbackHandler, F as defineValidator } from '../index-CKeIf4Jx.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { y as defineDeployer, z as defineDriftDetector, A as defineHealthChecker, B as defineRollbackHandler, F as defineValidator } from '../index-CKeIf4Jx.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineDeployer,
|
|
3
|
+
defineDriftDetector,
|
|
4
|
+
defineHealthChecker,
|
|
5
|
+
defineRollbackHandler,
|
|
6
|
+
defineValidator
|
|
7
|
+
} from "../chunk-PJCHU6ZZ.js";
|
|
8
|
+
export {
|
|
9
|
+
defineDeployer,
|
|
10
|
+
defineDriftDetector,
|
|
11
|
+
defineHealthChecker,
|
|
12
|
+
defineRollbackHandler,
|
|
13
|
+
defineValidator
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@veltrixsecops/app-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official SDK for building Veltrix Security-as-Code apps — typed pipeline handler contracts, lifecycle hook types, manifest types, and React hooks.",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"./pipeline": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/pipeline/index.d.ts",
|
|
24
|
+
"default": "./dist/pipeline/index.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/pipeline/index.d.cts",
|
|
28
|
+
"default": "./dist/pipeline/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./hooks": {
|
|
32
|
+
"import": {
|
|
33
|
+
"types": "./dist/hooks/index.d.ts",
|
|
34
|
+
"default": "./dist/hooks/index.js"
|
|
35
|
+
},
|
|
36
|
+
"require": {
|
|
37
|
+
"types": "./dist/hooks/index.d.cts",
|
|
38
|
+
"default": "./dist/hooks/index.cjs"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"dev": "tsup --watch",
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"prepublishOnly": "npm run typecheck && npm run build"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"react": ">=18.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"react": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^20.0.0",
|
|
65
|
+
"@types/react": "^18.0.0",
|
|
66
|
+
"tsup": "^8.0.0",
|
|
67
|
+
"typescript": "^5.6.0"
|
|
68
|
+
},
|
|
69
|
+
"keywords": [
|
|
70
|
+
"veltrix",
|
|
71
|
+
"security-as-code",
|
|
72
|
+
"secops",
|
|
73
|
+
"app-sdk",
|
|
74
|
+
"pipeline",
|
|
75
|
+
"plugin"
|
|
76
|
+
],
|
|
77
|
+
"license": "MIT",
|
|
78
|
+
"homepage": "https://github.com/captivatortechnologies/Veltrix/tree/main/app-sdk",
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "https://github.com/captivatortechnologies/Veltrix.git",
|
|
82
|
+
"directory": "app-sdk"
|
|
83
|
+
}
|
|
84
|
+
}
|