@veltrixsecops/app-sdk 2.3.0 → 2.4.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/{chunk-2GPEESFB.js → chunk-TE4UNXKW.js} +78 -1
- package/dist/chunk-TE4UNXKW.js.map +1 -0
- package/dist/client/index.cjs +82 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +18 -3
- package/dist/client/index.d.ts +18 -3
- package/dist/client/index.js +11 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/{index-CKeIf4Jx.d.cts → index-BynfArFw.d.cts} +1 -1
- package/dist/{index-CKeIf4Jx.d.ts → index-BynfArFw.d.ts} +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/pipeline/index.d.cts +1 -1
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/{use-app-context-Dh1S28Cv.d.cts → use-app-context-Df_dfcOm.d.cts} +56 -1
- package/dist/{use-app-context-Dh1S28Cv.d.ts → use-app-context-Df_dfcOm.d.ts} +56 -1
- package/package.json +1 -1
- package/dist/chunk-2GPEESFB.js.map +0 -1
|
@@ -265,6 +265,61 @@ interface InventoryItemInput {
|
|
|
265
265
|
toolId?: string;
|
|
266
266
|
connectivityProviderId?: string | null;
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* An Access Server — a Zero-Trust Access (ZTNA) gateway an app manages, each
|
|
270
|
+
* optionally linked to one of the customer's connectivity providers. This is a
|
|
271
|
+
* typed surface over the platform's access-servers API (`/api/access-servers`).
|
|
272
|
+
* Use the helpers in `@veltrixsecops/app-sdk/client`
|
|
273
|
+
* (listAccessServers / addAccessServer / updateAccessServer / removeAccessServer).
|
|
274
|
+
*/
|
|
275
|
+
interface AccessServer {
|
|
276
|
+
id: string;
|
|
277
|
+
/** Human-readable name of the access server. */
|
|
278
|
+
name: string;
|
|
279
|
+
/** Reachable endpoint (host, host:port, or URL) of the gateway. */
|
|
280
|
+
endpoint: string;
|
|
281
|
+
/** Gateway type (e.g. "gateway"). */
|
|
282
|
+
type?: string;
|
|
283
|
+
/** Region the gateway lives in, or null when unspecified. */
|
|
284
|
+
region?: string | null;
|
|
285
|
+
/** Operational status (e.g. "active", "degraded"). */
|
|
286
|
+
status?: string;
|
|
287
|
+
/** Free-text description, or null when none. */
|
|
288
|
+
description?: string | null;
|
|
289
|
+
/** Linked ZTNA connectivity provider id, or null when unlinked. */
|
|
290
|
+
connectivityProviderId?: string | null;
|
|
291
|
+
/** Expanded reference to the linked connectivity provider, when present. */
|
|
292
|
+
connectivityProvider?: {
|
|
293
|
+
id: string;
|
|
294
|
+
name: string;
|
|
295
|
+
} | null;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Input accepted by `addAccessServer` / `updateAccessServer`. Mirrors the
|
|
299
|
+
* platform access-servers API create/update body. `name` and `endpoint` are
|
|
300
|
+
* required; `connectivityProviderId` links the server to a ZTNA connectivity
|
|
301
|
+
* provider (pass null to unlink).
|
|
302
|
+
*/
|
|
303
|
+
interface AccessServerInput {
|
|
304
|
+
name: string;
|
|
305
|
+
endpoint: string;
|
|
306
|
+
type?: string;
|
|
307
|
+
region?: string;
|
|
308
|
+
status?: string;
|
|
309
|
+
description?: string;
|
|
310
|
+
connectivityProviderId?: string | null;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* A lightweight reference to a ZTNA connectivity provider, as returned by the
|
|
314
|
+
* platform's `/api/connectivity-providers` endpoint. Used to populate the ZTNA
|
|
315
|
+
* link picker when creating or editing an {@link AccessServer}.
|
|
316
|
+
*/
|
|
317
|
+
interface ConnectivityProviderRef {
|
|
318
|
+
id: string;
|
|
319
|
+
name: string;
|
|
320
|
+
providerType?: string;
|
|
321
|
+
status?: string;
|
|
322
|
+
}
|
|
268
323
|
interface Credential {
|
|
269
324
|
id: string;
|
|
270
325
|
name: string;
|
|
@@ -371,4 +426,4 @@ declare const AppContext: Context<AppContextValue | null>;
|
|
|
371
426
|
*/
|
|
372
427
|
declare function useAppContext(): AppContextValue;
|
|
373
428
|
|
|
374
|
-
export { type AppBrandingDeclaration as A, type Component as C, type InventoryItem as I, type PlatformDatabaseClient as P, type Tag as T, type User as U, AppContext as a, type AppContextValue as b, APP_PAGE_LAYOUTS as c, APP_PAGE_NAV as d, type
|
|
429
|
+
export { type AppBrandingDeclaration as A, type Customer as B, type Component as C, type InventoryItemInput as D, type InventoryItem as I, type PlatformDatabaseClient as P, type Tag as T, type User as U, AppContext as a, type AppContextValue as b, APP_PAGE_LAYOUTS as c, APP_PAGE_NAV as d, type AccessServer as e, type AccessServerInput as f, type AppConfigurationTypeManifest as g, type AppDetail as h, type AppHookContext as i, type AppInstallationDetail as j, type AppInstallationStatus as k, type AppListItem as l, type AppManifest as m, type AppPageDeclaration as n, type AppPageLayout as o, type AppPageNav as p, type AppPagePermission as q, type AppPermissionDeclaration as r, type AppRouteContext as s, type AppSettingDeclaration as t, useAppContext as u, type AppSource as v, type AppStatusType as w, type Connectivity as x, type ConnectivityProviderRef as y, type Credential as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltrixsecops/app-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Official SDK for building Veltrix Security-as-Code apps — typed pipeline handler contracts, lifecycle hook types, manifest types, and React hooks.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/inventory.ts","../src/client/index.ts"],"sourcesContent":["// ========================================================================\n// Inventory — the deployment targets an app can deploy configuration to.\n//\n// \"Inventory\" is the app-facing name for the platform's *components*: the\n// servers (hostname/port), domains, and IP/CIDR ranges a customer has\n// registered as deploy targets. These helpers are a typed, convenient\n// surface over the platform's components API (/api/components), enriched\n// with `domains` and `ipRanges`.\n//\n// Framework-free (no React) — safe to import from any client code. Every\n// call goes through the same `authFetch` the '/client' subpath exports, so\n// requests carry the platform's Authorization header. Non-2xx responses are\n// surfaced as thrown Errors carrying the platform's error text.\n// ========================================================================\n\nimport type { InventoryItem, InventoryItemInput } from '../types/platform'\nimport { authFetch } from './index'\n\n/** Base route for the platform's components (inventory) API. */\nconst INVENTORY_API = '/api/components'\n\n/**\n * Loosely-typed shape of a raw component as returned by the platform, before\n * it is normalized down to the {@link InventoryItem} surface.\n */\ninterface RawInventoryItem {\n id: string\n hostname?: string\n port?: string\n type?: string[]\n domains?: string[]\n ipRanges?: string[]\n tags?: Array<{ id: string; name: string }>\n connectivityProviderId?: string | null\n}\n\n/** Build an Error from a non-2xx response, preferring the platform's message. */\nasync function inventoryError(res: Response): Promise<Error> {\n const text = await res.text().catch(() => '')\n if (text) {\n try {\n const body = JSON.parse(text) as { error?: string; message?: string }\n const message = body?.error ?? body?.message\n if (message) return new Error(message)\n } catch {\n // Body was not JSON — fall through and use the raw text.\n }\n return new Error(text)\n }\n return new Error(`HTTP ${res.status}`)\n}\n\n/** Normalize a raw platform component into the typed InventoryItem surface. */\nfunction toInventoryItem(raw: RawInventoryItem): InventoryItem {\n return {\n id: String(raw.id),\n hostname: raw.hostname ?? '',\n port: raw.port ?? undefined,\n type: Array.isArray(raw.type) ? raw.type : undefined,\n domains: Array.isArray(raw.domains) ? raw.domains : [],\n ipRanges: Array.isArray(raw.ipRanges) ? raw.ipRanges : [],\n tags: Array.isArray(raw.tags)\n ? raw.tags.map((tag) => ({ id: String(tag.id), name: String(tag.name) }))\n : [],\n connectivityProviderId: raw.connectivityProviderId ?? null,\n }\n}\n\n/**\n * A platform Tool. Each installed app is upserted as a Tool keyed by its\n * manifest `name`, and inventory items (components) belong to a tool.\n */\nexport interface Tool {\n id: string\n name: string\n vendor?: string\n}\n\n/**\n * Resolve the platform Tool for an app by its manifest name (the platform\n * upserts `Tool.name === app name`). The tool id is required by the platform\n * when creating an inventory item, so call this once and pass the id as\n * `toolId` to {@link addInventoryItem}. Returns null when no tool matches.\n *\n * GET /api/tools (the endpoint is paginated — `{ data, pagination }` — or a\n * bare array; both are handled).\n */\nexport async function resolveTool(name: string): Promise<Tool | null> {\n const res = await authFetch('/api/tools')\n if (!res.ok) throw await inventoryError(res)\n const body = (await res.json()) as unknown\n const tools: Tool[] = Array.isArray(body)\n ? (body as Tool[])\n : Array.isArray((body as { data?: unknown })?.data)\n ? ((body as { data: Tool[] }).data)\n : []\n return tools.find((tool) => tool.name === name) ?? null\n}\n\n/** List the customer's inventory (deployment targets). GET /api/components */\nexport async function listInventory(): Promise<InventoryItem[]> {\n const res = await authFetch(INVENTORY_API)\n if (!res.ok) throw await inventoryError(res)\n const data = (await res.json()) as RawInventoryItem[]\n return Array.isArray(data) ? data.map(toInventoryItem) : []\n}\n\n/** Add a new inventory item (deployment target). POST /api/components */\nexport async function addInventoryItem(input: InventoryItemInput): Promise<InventoryItem> {\n const res = await authFetch(INVENTORY_API, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(input),\n })\n if (!res.ok) throw await inventoryError(res)\n return toInventoryItem((await res.json()) as RawInventoryItem)\n}\n\n/** Update an existing inventory item. PUT /api/components/:id */\nexport async function updateInventoryItem(\n id: string,\n input: InventoryItemInput,\n): Promise<InventoryItem> {\n const res = await authFetch(`${INVENTORY_API}/${encodeURIComponent(id)}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(input),\n })\n if (!res.ok) throw await inventoryError(res)\n return toInventoryItem((await res.json()) as RawInventoryItem)\n}\n\n/** Remove an inventory item. DELETE /api/components/:id */\nexport async function removeInventoryItem(id: string): Promise<void> {\n const res = await authFetch(`${INVENTORY_API}/${encodeURIComponent(id)}`, {\n method: 'DELETE',\n })\n // 204 No Content is the platform's success response for delete.\n if (!res.ok && res.status !== 204) throw await inventoryError(res)\n}\n","// ========================================================================\n// Client runtime contract — how app client bundles talk to the host.\n//\n// App client code is packaged as a hermetic ESM bundle in which `react`,\n// `react-dom`, `react/jsx-runtime`, and every `@veltrixsecops/app-sdk`\n// subpath are compile-time shims that read the host-provided runtime from\n// `globalThis.__VELTRIX_APP_RUNTIME__`. The platform installs that global\n// (with ITS React instance, the shared AppContext, and an authenticated\n// fetch) before dynamically importing any app bundle, so app components\n// render inside the host React tree with working hooks and context.\n//\n// App authors: import from '@veltrixsecops/app-sdk/client' (and /hooks) —\n// never bundle your own copy of react. Use `authFetch` for calls to your\n// app's server routes (/api/apps/<app-id>/...): plain fetch() lacks the\n// platform's Authorization header and will receive 401s.\n// ========================================================================\n\nimport type { ComponentType, Context, LazyExoticComponent } from 'react'\nimport type { AppContextValue } from '../hooks/use-app-context'\n\nexport type { AppBrandingDeclaration } from '../types/manifest'\n\n// Inventory — typed helpers over the platform's components API (deployment\n// targets: servers, domains, IP/CIDR ranges). Framework-free; they use the\n// `authFetch` exported below internally.\nexport {\n listInventory,\n addInventoryItem,\n updateInventoryItem,\n removeInventoryItem,\n resolveTool,\n} from './inventory'\nexport type { Tool } from './inventory'\nexport type { InventoryItem, InventoryItemInput } from '../types/platform'\n\n/** Name of the global the platform installs before loading app bundles. */\nexport const HOST_RUNTIME_GLOBAL = '__VELTRIX_APP_RUNTIME__'\n\n/**\n * The runtime surface the platform exposes to app client bundles.\n * The react/reactDom/jsxRuntime members are the host's own module objects —\n * app bundles are compiled with shims that re-export them, guaranteeing a\n * single React instance per page.\n */\nexport interface VeltrixHostRuntime {\n /** The host's `react` module object. */\n react: unknown\n /** The host's `react-dom` module object. */\n reactDom: unknown\n /** The host's `react-dom/client` module object. */\n reactDomClient?: unknown\n /** The host's `react/jsx-runtime` module object. */\n jsxRuntime: unknown\n /** Shared app context — the host wraps app pages in its Provider. */\n AppContext: Context<AppContextValue | null>\n /** fetch() with the platform's Authorization header attached. */\n authFetch: (input: string, init?: RequestInit) => Promise<Response>\n /**\n * The SDK surface app bundles receive for `@veltrixsecops/app-sdk`,\n * `.../hooks`, and `.../client` imports (useAppContext, AppContext,\n * usePipelineStatus, authFetch, getHostRuntime, ...).\n */\n sdk: Record<string, unknown>\n /**\n * The platform's design-system components and hooks, host-owned so they\n * share the single host React instance. Keyed by the exact component/hook\n * names re-exported from `@veltrixsecops/app-sdk/ui` (Button, Input, Card,\n * DataTable, useToast, ...). Present only inside the platform.\n */\n ui?: Record<string, unknown>\n}\n\n/** Read the host runtime, or null outside the platform (tests, storybook). */\nexport function getHostRuntime(): VeltrixHostRuntime | null {\n const runtime = (globalThis as Record<string, unknown>)[HOST_RUNTIME_GLOBAL]\n return (runtime as VeltrixHostRuntime) ?? null\n}\n\n/** Read the host runtime, throwing a diagnosable error when absent. */\nexport function requireHostRuntime(): VeltrixHostRuntime {\n const runtime = getHostRuntime()\n if (!runtime) {\n throw new Error(\n 'Veltrix host runtime not found — app client bundles only run inside the ' +\n `Veltrix platform (missing globalThis.${HOST_RUNTIME_GLOBAL})`,\n )\n }\n return runtime\n}\n\n/**\n * fetch() that carries the platform's Authorization header. Required for an\n * app page to call its own server routes (/api/apps/<app-id>/...), which are\n * bearer-token protected. Falls back to plain fetch outside the platform.\n */\nexport function authFetch(input: string, init?: RequestInit): Promise<Response> {\n const runtime = getHostRuntime()\n if (runtime) return runtime.authFetch(input, init)\n return fetch(input, init)\n}\n\n/** A sidebar entry contributed by the app's client entry module. */\nexport interface AppSidebarItem {\n path: string\n label: string\n icon?: string\n}\n\n/**\n * Shape of the default export of an app's `client/index.tsx`.\n * `pages` keys must match `manifest.client.pages[].component`.\n */\nexport interface AppClientModule {\n id: string\n pages: Record<string, ComponentType | LazyExoticComponent<ComponentType>>\n sidebarItems?: AppSidebarItem[]\n}\n"],"mappings":";AAmBA,IAAM,gBAAgB;AAkBtB,eAAe,eAA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