@7k-inari/ui-plugin-sdk 0.1.1 → 0.1.6

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.
@@ -83,6 +83,9 @@ declare function AuthProvider(props: {
83
83
  value: AuthState;
84
84
  children: ReactNode;
85
85
  }): react.FunctionComponentElement<react.ProviderProps<AuthState | null>>;
86
+ /** getAuthState returns the active AuthState outside React (null before the
87
+ * provider mounts). Prefer useAuth() inside components. */
88
+ declare function getAuthState(): AuthState | null;
86
89
  declare function useAuth(): AuthState;
87
90
  declare function usePrincipal(): Principal | null;
88
91
 
@@ -116,7 +119,7 @@ interface Cluster {
116
119
  interface CatalogItem {
117
120
  id: string;
118
121
  name: string;
119
- source: 'discovered' | 'curated' | 'platform';
122
+ source: 'discovered' | 'curated' | 'platform' | 'template';
120
123
  version: string;
121
124
  description?: string;
122
125
  schema?: Record<string, unknown>;
@@ -164,4 +167,4 @@ declare class ApiClient {
164
167
  approveApproval(id: string): Promise<ApprovalRequest>;
165
168
  }
166
169
 
167
- export { type AnySlotContribution as A, type CatalogItem as C, type ExtensionManifestInput as E, type InariExtension as I, type ParsedExtensionManifest as P, type ResourceInstance as R, type SlotContribution as S, type TenantChangeEvent as T, type Cluster as a, type SlotContext as b, ApiClient as c, type ApiClientOptions as d, ApiError as e, type ApprovalRequest as f, AuthContext as g, AuthProvider as h, type AuthState as i, type Principal as j, SLOT_KINDS as k, type SlotKind as l, type TenantChangeListener as m, TenantContext as n, TenantProvider as o, type TenantRef as p, type TenantState as q, createTenantState as r, extensionManifestSchema as s, parseExtensionManifest as t, useAuth as u, usePrincipal as v, useTenant as w };
170
+ export { type AnySlotContribution as A, type CatalogItem as C, type ExtensionManifestInput as E, type InariExtension as I, type ParsedExtensionManifest as P, type ResourceInstance as R, type SlotContribution as S, type TenantChangeEvent as T, type Cluster as a, type SlotContext as b, ApiClient as c, type ApiClientOptions as d, ApiError as e, type ApprovalRequest as f, AuthContext as g, AuthProvider as h, type AuthState as i, type Principal as j, SLOT_KINDS as k, type SlotKind as l, type TenantChangeListener as m, TenantContext as n, TenantProvider as o, type TenantRef as p, type TenantState as q, createTenantState as r, extensionManifestSchema as s, getAuthState as t, parseExtensionManifest as u, useAuth as v, usePrincipal as w, useTenant as x };
@@ -83,6 +83,9 @@ declare function AuthProvider(props: {
83
83
  value: AuthState;
84
84
  children: ReactNode;
85
85
  }): react.FunctionComponentElement<react.ProviderProps<AuthState | null>>;
86
+ /** getAuthState returns the active AuthState outside React (null before the
87
+ * provider mounts). Prefer useAuth() inside components. */
88
+ declare function getAuthState(): AuthState | null;
86
89
  declare function useAuth(): AuthState;
87
90
  declare function usePrincipal(): Principal | null;
88
91
 
@@ -116,7 +119,7 @@ interface Cluster {
116
119
  interface CatalogItem {
117
120
  id: string;
118
121
  name: string;
119
- source: 'discovered' | 'curated' | 'platform';
122
+ source: 'discovered' | 'curated' | 'platform' | 'template';
120
123
  version: string;
121
124
  description?: string;
122
125
  schema?: Record<string, unknown>;
@@ -164,4 +167,4 @@ declare class ApiClient {
164
167
  approveApproval(id: string): Promise<ApprovalRequest>;
165
168
  }
166
169
 
167
- export { type AnySlotContribution as A, type CatalogItem as C, type ExtensionManifestInput as E, type InariExtension as I, type ParsedExtensionManifest as P, type ResourceInstance as R, type SlotContribution as S, type TenantChangeEvent as T, type Cluster as a, type SlotContext as b, ApiClient as c, type ApiClientOptions as d, ApiError as e, type ApprovalRequest as f, AuthContext as g, AuthProvider as h, type AuthState as i, type Principal as j, SLOT_KINDS as k, type SlotKind as l, type TenantChangeListener as m, TenantContext as n, TenantProvider as o, type TenantRef as p, type TenantState as q, createTenantState as r, extensionManifestSchema as s, parseExtensionManifest as t, useAuth as u, usePrincipal as v, useTenant as w };
170
+ export { type AnySlotContribution as A, type CatalogItem as C, type ExtensionManifestInput as E, type InariExtension as I, type ParsedExtensionManifest as P, type ResourceInstance as R, type SlotContribution as S, type TenantChangeEvent as T, type Cluster as a, type SlotContext as b, ApiClient as c, type ApiClientOptions as d, ApiError as e, type ApprovalRequest as f, AuthContext as g, AuthProvider as h, type AuthState as i, type Principal as j, SLOT_KINDS as k, type SlotKind as l, type TenantChangeListener as m, TenantContext as n, TenantProvider as o, type TenantRef as p, type TenantState as q, createTenantState as r, extensionManifestSchema as s, getAuthState as t, parseExtensionManifest as u, useAuth as v, usePrincipal as w, useTenant as x };
@@ -100,4 +100,4 @@ export {
100
100
  ApiError,
101
101
  ApiClient
102
102
  };
103
- //# sourceMappingURL=chunk-OCKSMPCZ.js.map
103
+ //# sourceMappingURL=chunk-E5P565T6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/host/tenant.ts","../src/host/api.ts"],"sourcesContent":["import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface TenantRef {\n orgId: string;\n orgName: string;\n team?: string;\n}\n\nexport interface TenantChangeEvent {\n previous: TenantRef | null;\n current: TenantRef;\n}\n\nexport type TenantChangeListener = (event: TenantChangeEvent) => void;\n\nexport interface TenantState {\n current: TenantRef | null;\n available: TenantRef[];\n switchTenant: (orgId: string, team?: string) => void;\n onTenantChange: (listener: TenantChangeListener) => () => void;\n}\n\nexport const TenantContext = createContext<TenantState | null>(null);\n\nexport function TenantProvider(props: { value: TenantState; children: ReactNode }) {\n return createElement(TenantContext.Provider, { value: props.value }, props.children);\n}\n\nexport function useTenant(): TenantState {\n const ctx = useContext(TenantContext);\n if (!ctx) throw new Error('useTenant must be used within a TenantProvider');\n return ctx;\n}\n\nexport function createTenantState(available: TenantRef[]): TenantState & { _listeners: Set<TenantChangeListener> } {\n const listeners = new Set<TenantChangeListener>();\n const state = {\n current: available[0] ?? null,\n available,\n _listeners: listeners,\n switchTenant(orgId: string, team?: string) {\n const next = available.find((t) => t.orgId === orgId && (team === undefined || t.team === team));\n if (!next) throw new Error(`unknown tenant: ${orgId}${team ? `/${team}` : ''}`);\n const previous = state.current;\n state.current = next;\n listeners.forEach((l) => l({ previous, current: next }));\n },\n onTenantChange(listener: TenantChangeListener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return state;\n}\n","export interface Cluster {\n id: string;\n name: string;\n tenantId: string;\n state: 'Pending' | 'Active' | 'Degraded' | 'Cordoned' | 'Decommissioned';\n kubernetesVersion?: string;\n labels?: Record<string, string>;\n}\n\nexport interface CatalogItem {\n id: string;\n name: string;\n source: 'discovered' | 'curated' | 'platform' | 'template';\n version: string;\n description?: string;\n schema?: Record<string, unknown>;\n uiHints?: Record<string, unknown>;\n}\n\nexport interface ResourceInstance {\n id: string;\n catalogItemId: string;\n clusterId: string;\n cloudAccountId?: string;\n name: string;\n namespace?: string;\n health?: string;\n status?: Record<string, unknown>;\n ownerTeam?: string;\n}\n\nexport interface ApprovalRequest {\n id: string;\n action: string;\n requester: string;\n state: 'pending' | 'approved' | 'rejected';\n}\n\nexport interface ApiClientOptions {\n baseUrl: string;\n getToken: () => Promise<string | undefined> | string | undefined;\n fetchImpl?: typeof fetch;\n}\n\nexport class ApiError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport class ApiClient {\n private readonly baseUrl: string;\n private readonly getToken: ApiClientOptions['getToken'];\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: ApiClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '');\n this.getToken = options.getToken;\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const token = await this.getToken();\n const res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers: {\n 'content-type': 'application/json',\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n if (!res.ok) {\n throw new ApiError(res.status, `${method} ${path} failed: ${res.status}`);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n\n listClusters(): Promise<Cluster[]> {\n return this.request('GET', '/api/v1/clusters');\n }\n\n getCluster(id: string): Promise<Cluster> {\n return this.request('GET', `/api/v1/clusters/${encodeURIComponent(id)}`);\n }\n\n listCatalogItems(clusterId?: string): Promise<CatalogItem[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/catalog/items${q}`);\n }\n\n getCatalogItem(id: string): Promise<CatalogItem> {\n return this.request('GET', `/api/v1/catalog/items/${encodeURIComponent(id)}`);\n }\n\n listResourceInstances(clusterId?: string): Promise<ResourceInstance[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/resources${q}`);\n }\n\n getResourceInstance(id: string): Promise<ResourceInstance> {\n return this.request('GET', `/api/v1/resources/${encodeURIComponent(id)}`);\n }\n\n listApprovals(): Promise<ApprovalRequest[]> {\n return this.request('GET', '/api/v1/approvals');\n }\n\n approveApproval(id: string): Promise<ApprovalRequest> {\n return this.request('POST', `/api/v1/approvals/${encodeURIComponent(id)}/approve`);\n }\n}\n"],"mappings":";AAAA,SAAS,eAAe,eAAe,kBAAkC;AAsBlE,IAAM,gBAAgB,cAAkC,IAAI;AAE5D,SAAS,eAAe,OAAoD;AACjF,SAAO,cAAc,cAAc,UAAU,EAAE,OAAO,MAAM,MAAM,GAAG,MAAM,QAAQ;AACrF;AAEO,SAAS,YAAyB;AACvC,QAAM,MAAM,WAAW,aAAa;AACpC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,gDAAgD;AAC1E,SAAO;AACT;AAEO,SAAS,kBAAkB,WAAiF;AACjH,QAAM,YAAY,oBAAI,IAA0B;AAChD,QAAM,QAAQ;AAAA,IACZ,SAAS,UAAU,CAAC,KAAK;AAAA,IACzB;AAAA,IACA,YAAY;AAAA,IACZ,aAAa,OAAe,MAAe;AACzC,YAAM,OAAO,UAAU,KAAK,CAAC,MAAM,EAAE,UAAU,UAAU,SAAS,UAAa,EAAE,SAAS,KAAK;AAC/F,UAAI,CAAC,KAAM,OAAM,IAAI,MA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AmC;AACjC,WAAO,KAAK,QAAQ,OAAO,kBAAkB;AAAA,EAC/C;AAAA,EAEA,WAAW,IAA8B;AACvC,WAAO,KAAK,QAAQ,OAAO,oBAAoB,mBAAmB,EAAE,CAAC,EAAE;AAAA,EACzE;AAAA,EAEA,iBAAiB,WAA4C;AAC3D,UAAM,IAAI,YAAY,cAAc,mBAAmB,SAAS,CAAC,KAAK;AACtE,WAAO,KAAK,QAAQ,OAAO,wBAAwB,CAAC,EAAE;AAAA,EACxD;AAAA,EAEA,eAAe,IAAkC;AAC/C,WAAO,KAAK,QAAQ,OAAO,yBAAyB,mBAAmB,EAAE,CAAC,EAAE;AAAA,EAC9E;AAAA,EAEA,sBAAsB,WAAiD;AACrE,UAAM,IAAI,YAAY,cAAc,mBAAmB,SAAS,CAAC,KAAK;AACtE,WAAO,KAAK,QAAQ,OAAO,oBAAoB,CAAC,EAAE;AAAA,EACpD;AAAA,EAEA,oBAAoB,IAAuC;AACzD,WAAO,KAAK,QAAQ,OAAO,qBAAqB,mBAAmB,EAAE,CAAC,EAAE;AAAA,EAC1E;AAAA,EAEA,gBAA4C;AAC1C,WAAO,KAAK,QAAQ,OAAO,mBAAmB;AAAA,EAChD;AAAA,EAEA,gBAAgB,IAAsC;AACpD,WAAO,KAAK,QAAQ,QAAQ,qBAAqB,mBAAmB,EAAE,CAAC,UAAU;AAAA,EACnF;AACF;","names":[]}
@@ -170,7 +170,7 @@ async function startDevHarness(options) {
170
170
  }
171
171
  ],
172
172
  resolve: {
173
- alias: [{ find: "@inari/ui-plugin-sdk", replacement: sdkEntry }],
173
+ alias: [{ find: "@7k-inari/ui-plugin-sdk", replacement: sdkEntry }],
174
174
  dedupe: ["react", "react-dom", "react-router-dom", "zod"]
175
175
  },
176
176
  optimizeDeps: { noDiscovery: true },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../harness/index.ts","../../harness/server.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { createServer as createViteServer, type ViteDevServer } from 'vite';\nimport { startMockControlPlane, type MockFixtures } from './server.js';\n\nfunction resolveShellRoot(): string {\n const srcLayout = fileURLToPath(new URL('./shell', import.meta.url));\n if (existsSync(srcLayout)) return srcLayout;\n return fileURLToPath(new URL('../../harness/shell', import.meta.url));\n}\n\nfunction resolveSdkEntry(): string {\n const srcLayout = fileURLToPath(new URL('../src/index.ts', import.meta.url));\n if (existsSync(srcLayout)) return srcLayout;\n return fileURLToPath(new URL('../index.js', import.meta.url));\n}\n\nexport interface DevHarnessOptions {\n extensionEntry: string;\n port?: number;\n apiPort?: number;\n fixtures?: MockFixtures;\n}\n\nexport interface DevHarness {\n url: string;\n apiUrl: string;\n vite: ViteDevServer;\n close: () => Promise<void>;\n}\n\nexport async function startDevHarness(options: DevHarnessOptions): Promise<DevHarness> {\n const port = options.port ?? 5173;\n const apiPort = options.apiPort ?? 9099;\n const api = await startMockControlPlane(apiPort, options.fixtures);\n const shellRoot = resolveShellRoot();\n const sdkEntry = resolveSdkEntry();\n const vite = await createViteServer({\n root: shellRoot,\n server: { port },\n plugins: [\n {\n name: 'inari-harness-config',\n transformIndexHtml() {\n return [\n {\n tag: 'script',\n injectTo: 'head-prepend',\n children: [\n `window.__INARI_API_URL__ = ${JSON.stringify(api.url)};`,\n `window.__INARI_EXTENSION_ENTRY__ = ${JSON.stringify(`/@fs${options.extensionEntry}`)};`,\n ].join('\\n'),\n },\n ];\n },\n },\n ],\n resolve: {\n alias: [{ find: '@inari/ui-plugin-sdk', replacement: sdkEntry }],\n dedupe: ['react', 'react-dom', 'react-router-dom', 'zod'],\n },\n optimizeDeps: { noDiscovery: true },\n logLevel: 'warn',\n });\n await vite.listen();\n const actualUrl = vite.resolvedUrls?.local[0] ?? `http://localhost:${port}/`;\n return {\n url: actualUrl.replace(/\\/$/, ''),\n apiUrl: api.url,\n vite,\n close: async () => {\n await vite.close();\n await api.close();\n },\n };\n}\n\nexport { createMockControlPlane, startMockControlPlane } from './server.js';\nexport type { MockFixtures } from './server.js';\n","import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http';\n\nexport interface MockFixtures {\n clusters?: unknown[];\n catalogItems?: unknown[];\n resources?: unknown[];\n approvals?: unknown[];\n tenants?: unknown[];\n}\n\nexport const defaultFixtures: Required<MockFixtures> = {\n tenants: [\n { orgId: 'org:acme', orgName: 'Acme', team: 'platform-team' },\n { orgId: 'org:globex', orgName: 'Globex' },\n ],\n clusters: [\n {\n id: 'cluster-1',\n name: 'dev-eu-1',\n tenantId: 'org:acme',\n state: 'Active',\n kubernetesVersion: '1.31',\n labels: { env: 'dev', region: 'eu-west-1' },\n },\n ],\n catalogItems: [\n {\n id: 'item-1',\n name: 'namespace-as-a-service',\n source: 'curated',\n version: '1.0.0',\n description: 'Golden-path namespace',\n },\n ],\n resources: [\n {\n id: 'res-1',\n catalogItemId: 'item-1',\n clusterId: 'cluster-1',\n name: 'demo-ns',\n namespace: 'demo-ns',\n health: 'Healthy',\n ownerTeam: 'platform-team',\n },\n ],\n approvals: [],\n};\n\nfunction readBody(req: IncomingMessage): Promise<string> {\n return new Promise((resolve) => {\n let data = '';\n req.on('data', (c) => (data += c));\n req.on('end', () => resolve(data));\n });\n}\n\nexport function createMockControlPlane(fixtures: MockFixtures = {}): Server {\n const fx: Required<MockFixtures> = { ...defaultFixtures, ...fixtures };\n return createServer(async (req: IncomingMessage, res: ServerResponse) => {\n const url = new URL(req.url ?? '/', 'http://localhost');\n const path = url.pathname;\n res.setHeader('content-type', 'application/json');\n res.setHeader('access-control-allow-origin', '*');\n res.setHeader('access-control-allow-headers', 'content-type, authorization');\n res.setHeader('access-control-allow-methods', 'GET,POST,OPTIONS');\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n const send = (body: unknown, status = 200) => {\n res.statusCode = status;\n res.end(JSON.stringify(body));\n };\n if (req.method === 'GET' && path === '/api/v1/tenants') return send(fx.tenants);\n if (req.method === 'GET' && path === '/api/v1/clusters') return send(fx.clusters);\n if (req.method === 'GET' && path === '/api/v1/catalog/items') return send(fx.catalogItems);\n if (req.method === 'GET' && path === '/api/v1/resources') return send(fx.resources);\n if (req.method === 'GET' && path === '/api/v1/approvals') return send(fx.approvals);\n const clusterMatch = path.match(/^\\/api\\/v1\\/clusters\\/([^/]+)$/);\n if (req.method === 'GET' && clusterMatch) {\n const c = fx.clusters.find((x) => (x as { id: string }).id === clusterMatch[1]);\n return c ? send(c) : send({ message: 'not found' }, 404);\n }\n const resMatch = path.match(/^\\/api\\/v1\\/resources\\/([^/]+)$/);\n if (req.method === 'GET' && resMatch) {\n const r = fx.resources.find((x) => (x as { id: string }).id === resMatch[1]);\n return r ? send(r) : send({ message: 'not found' }, 404);\n }\n const approveMatch = path.match(/^\\/api\\/v1\\/approvals\\/([^/]+)\\/approve$/);\n if (req.method === 'POST' && approveMatch) {\n await readBody(req);\n return send({ id: approveMatch[1], state: 'approved' });\n }\n send({ message: 'not found' }, 404);\n });\n}\n\nexport function startMockControlPlane(\n port: number,\n fixtures?: MockFixtures,\n): Promise<{ server: Server; url: string; close: () => Promise<void> }> {\n const server = createMockControlPlane(fixtures);\n return new Promise((resolve) => {\n server.listen(port, () => {\n const addr = server.address();\n const actualPort = typeof addr === 'object' && addr ? addr.port : port;\n resolve({\n server,\n url: `http://localhost:${actualPort}`,\n close: () => new Promise((r) => server.close(() => r())),\n });\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA2B;AAC3B,sBAA8B;AAC9B,kBAAqE;;;ACFrE,uBAAqF;AAU9E,IAAM,kBAA0C;AAAA,EACrD,SAAS;AAAA,IACP,EAAE,OAAO,YAAY,SAAS,QAAQ,MAAM,gBAAgB;AAAA,IAC5D,EAAE,OAAO,cAAc,SAAS,SAAS;AAAA,EAC3C;AAAA,EACA,UAAU;AAAA,IACR;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAA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A,SAAS;AAAA,MACP,OAAO,CAAC,EAAE,MAAM,wBAAwB,aAAa,SAAS,CAAC;AAAA,MAC/D,QAAQ,CAAC,SAAS,aAAa,oBAAoB,KAAK;AAAA,IAC1D;AAAA,IACA,cAAc,EAAE,aAAa,KAAK;AAAA,IAClC,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,KAAK,OAAO;AAClB,QAAM,YAAY,KAAK,cAAc,MAAM,CAAC,KAAK,oBAAoB,IAAI;AACzE,SAAO;AAAA,IACL,KAAK,UAAU,QAAQ,OAAO,EAAE;AAAA,IAChC,QAAQ,IAAI;AAAA,IACZ;AAAA,IACA,OAAO,YAAY;AACjB,YAAM,KAAK,MAAM;AACjB,YAAM,IAAI,MAAM;AAAA,IAClB;AAAA,EACF;AACF;","names":["createViteServer"]}
1
+ {"version":3,"sources":["../../harness/index.ts","../../harness/server.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { createServer as createViteServer, type ViteDevServer } from 'vite';\nimport { startMockControlPlane, type MockFixtures } from './server.js';\n\nfunction resolveShellRoot(): string {\n const srcLayout = fileURLToPath(new URL('./shell', import.meta.url));\n if (existsSync(srcLayout)) return srcLayout;\n return fileURLToPath(new URL('../../harness/shell', import.meta.url));\n}\n\nfunction resolveSdkEntry(): string {\n const srcLayout = fileURLToPath(new URL('../src/index.ts', import.meta.url));\n if (existsSync(srcLayout)) return srcLayout;\n return fileURLToPath(new URL('../index.js', import.meta.url));\n}\n\nexport interface DevHarnessOptions {\n extensionEntry: string;\n port?: number;\n apiPort?: number;\n fixtures?: MockFixtures;\n}\n\nexport interface DevHarness {\n url: string;\n apiUrl: string;\n vite: ViteDevServer;\n close: () => Promise<void>;\n}\n\nexport async function startDevHarness(options: DevHarnessOptions): Promise<DevHarness> {\n const port = options.port ?? 5173;\n const apiPort = options.apiPort ?? 9099;\n const api = await startMockControlPlane(apiPort, options.fixtures);\n const shellRoot = resolveShellRoot();\n const sdkEntry = resolveSdkEntry();\n const vite = await createViteServer({\n root: shellRoot,\n server: { port },\n plugins: [\n {\n name: 'inari-harness-config',\n transformIndexHtml() {\n return [\n {\n tag: 'script',\n injectTo: 'head-prepend',\n children: [\n `window.__INARI_API_URL__ = ${JSON.stringify(api.url)};`,\n `window.__INARI_EXTENSION_ENTRY__ = ${JSON.stringify(`/@fs${options.extensionEntry}`)};`,\n ].join('\\n'),\n },\n ];\n },\n },\n ],\n resolve: {\n alias: [{ find: '@7k-inari/ui-plugin-sdk', replacement: sdkEntry }],\n dedupe: ['react', 'react-dom', 'react-router-dom', 'zod'],\n },\n optimizeDeps: { noDiscovery: true },\n logLevel: 'warn',\n });\n await vite.listen();\n const actualUrl = vite.resolvedUrls?.local[0] ?? `http://localhost:${port}/`;\n return {\n url: actualUrl.replace(/\\/$/, ''),\n apiUrl: api.url,\n vite,\n close: async () => {\n await vite.close();\n await api.close();\n },\n };\n}\n\nexport { createMockControlPlane, startMockControlPlane } from './server.js';\nexport type { MockFixtures } from './server.js';\n","import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http';\n\nexport interface MockFixtures {\n clusters?: unknown[];\n catalogItems?: unknown[];\n resources?: unknown[];\n approvals?: unknown[];\n tenants?: unknown[];\n}\n\nexport const defaultFixtures: Required<MockFixtures> = {\n tenants: [\n { orgId: 'org:acme', orgName: 'Acme', team: 'platform-team' },\n { orgId: 'org:globex', orgName: 'Globex' },\n ],\n clusters: [\n {\n id: 'cluster-1',\n name: 'dev-eu-1',\n tenantId: 'org:acme',\n state: 'Active',\n kubernetesVersion: '1.31',\n labels: { env: 'dev', region: 'eu-west-1' },\n },\n ],\n catalogItems: [\n {\n id: 'item-1',\n name: 'namespace-as-a-service',\n source: 'curated',\n version: '1.0.0',\n description: 'Golden-path namespace',\n },\n ],\n resources: [\n {\n id: 'res-1',\n catalogItemId: 'item-1',\n clusterId: 'cluster-1',\n name: 'demo-ns',\n namespace: 'demo-ns',\n health: 'Healthy',\n ownerTeam: 'platform-team',\n },\n ],\n approvals: [],\n};\n\nfunction readBody(req: IncomingMessage): Promise<string> {\n return new Promise((resolve) => {\n let data = '';\n req.on('data', (c) => (data += c));\n req.on('end', () => resolve(data));\n });\n}\n\nexport function createMockControlPlane(fixtures: MockFixtures = {}): Server {\n const fx: Required<MockFixtures> = { ...defaultFixtures, ...fixtures };\n return createServer(async (req: IncomingMessage, res: ServerResponse) => {\n const url = new URL(req.url ?? '/', 'http://localhost');\n const path = url.pathname;\n res.setHeader('content-type', 'application/json');\n res.setHeader('access-control-allow-origin', '*');\n res.setHeader('access-control-allow-headers', 'content-type, authorization');\n res.setHeader('access-control-allow-methods', 'GET,POST,OPTIONS');\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n const send = (body: unknown, status = 200) => {\n res.statusCode = status;\n res.end(JSON.stringify(body));\n };\n if (req.method === 'GET' && path === '/api/v1/tenants') return send(fx.tenants);\n if (req.method === 'GET' && path === '/api/v1/clusters') return send(fx.clusters);\n if (req.method === 'GET' && path === '/api/v1/catalog/items') return send(fx.catalogItems);\n if (req.method === 'GET' && path === '/api/v1/resources') return send(fx.resources);\n if (req.method === 'GET' && path === '/api/v1/approvals') return send(fx.approvals);\n const clusterMatch = path.match(/^\\/api\\/v1\\/clusters\\/([^/]+)$/);\n if (req.method === 'GET' && clusterMatch) {\n const c = fx.clusters.find((x) => (x as { id: string }).id === clusterMatch[1]);\n return c ? send(c) : send({ message: 'not found' }, 404);\n }\n const resMatch = path.match(/^\\/api\\/v1\\/resources\\/([^/]+)$/);\n if (req.method === 'GET' && resMatch) {\n const r = fx.resources.find((x) => (x as { id: string }).id === resMatch[1]);\n return r ? send(r) : send({ message: 'not found' }, 404);\n }\n const approveMatch = path.match(/^\\/api\\/v1\\/approvals\\/([^/]+)\\/approve$/);\n if (req.method === 'POST' && approveMatch) {\n await readBody(req);\n return send({ id: approveMatch[1], state: 'approved' });\n }\n send({ message: 'not found' }, 404);\n });\n}\n\nexport function startMockControlPlane(\n port: number,\n fixtures?: MockFixtures,\n): Promise<{ server: Server; url: string; close: () => Promise<void> }> {\n const server = createMockControlPlane(fixtures);\n return new Promise((resolve) => {\n server.listen(port, () => {\n const addr = server.address();\n const actualPort = typeof addr === 'object' && addr ? addr.port : port;\n resolve({\n server,\n url: `http://localhost:${actualPort}`,\n close: () => new Promise((r) => server.close(() => r())),\n });\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA2B;AAC3B,sBAA8B;AAC9B,kBAAqE;;;ACFrE,uBAAqF;AAU9E,IAAM,kBAA0C;AAAA,EACrD,SAAS;AAAA,IACP,EAAE,OAAO,YAAY,SAAS,QAAQ,MAAM,gBAAgB;AAAA,IAC5D,EAAE,OAAO,cAAc,SAAS,SAAS;AAAA,EAC3C;AAAA,EACA,UAAU;AAAA,IACR;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,QAAQ,EAAE,KAAK,OAAO,QAAQ,YAAY;AAAA,IAC5C;AAAA,EACF;AAAA,EACA,cAAc;AAAA,IACZ;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACT;AAAA,MACE,IAAI;AAAA,MACJ,eAAe;AAAA,MACf,WAAW;AAAA,MACX,MAAM;AAAA,MACN,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,WAAW,CAAC;AACd;AAEA,SAAS,SAAS,KAAuC;AACvD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,QAAI,OAAO;AACX,QAAI,GAAG,QAAQ,CAAC,MAAO,QAAQ,CAAE;AACjC,QAAI,GAAG,OAAO,MAAM,QAAQ,IAAI,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AAiD;AACrF,QAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,MAAM,MAAM,sBAAsB,SAAS,QAAQ,QAAQ;AACjE,QAAM,YAAY,iBAAiB;AACnC,QAAM,WAAW,gBAAgB;AACjC,QAAM,OAAO,UAAM,YAAAA,cAAiB;AAAA,IAClC,MAAM;AAAA,IACN,QAAQ,EAAE,KAAK;AAAA,IACf,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,qBAAqB;AACnB,iBAAO;AAAA,YACL;AAAA,cACE,KAAK;AAAA,cACL,UAAU;AAAA,cACV,UAAU;AAAA,gBACR,8BAA8B,KAAK,UAAU,IAAI,GAAG,CAAC;AAAA,gBACrD,sCAAsC,KAAK,UAAU,OAAO,QAAQ,cAAc,EAAE,CAAC;AAAA,cACvF,EAAE,KAAK,IAAI;AAAA,YACb;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,OAAO,CAAC,EAAE,MAAM,2BAA2B,aAAa,SAAS,CAAC;AAAA,MAClE,QAAQ,CAAC,SAAS,aAAa,oBAAoB,KAAK;AAAA,IAC1D;AAAA,IACA,cAAc,EAAE,aAAa,KAAK;AAAA,IAClC,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,KAAK,OAAO;AAClB,QAAM,YAAY,KAAK,cAAc,MAAM,CAAC,KAAK,oBAAoB,IAAI;AACzE,SAAO;AAAA,IACL,KAAK,UAAU,QAAQ,OAAO,EAAE;AAAA,IAChC,QAAQ,IAAI;AAAA,IACZ;AAAA,IACA,OAAO,YAAY;AACjB,YAAM,KAAK,MAAM;AACjB,YAAM,IAAI,MAAM;AAAA,IAClB;AAAA,EACF;AACF;","names":["createViteServer"]}
@@ -143,7 +143,7 @@ async function startDevHarness(options) {
143
143
  }
144
144
  ],
145
145
  resolve: {
146
- alias: [{ find: "@inari/ui-plugin-sdk", replacement: sdkEntry }],
146
+ alias: [{ find: "@7k-inari/ui-plugin-sdk", replacement: sdkEntry }],
147
147
  dedupe: ["react", "react-dom", "react-router-dom", "zod"]
148
148
  },
149
149
  optimizeDeps: { noDiscovery: true },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../harness/index.ts","../../harness/server.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { createServer as createViteServer, type ViteDevServer } from 'vite';\nimport { startMockControlPlane, type MockFixtures } from './server.js';\n\nfunction resolveShellRoot(): string {\n const srcLayout = fileURLToPath(new URL('./shell', import.meta.url));\n if (existsSync(srcLayout)) return srcLayout;\n return fileURLToPath(new URL('../../harness/shell', import.meta.url));\n}\n\nfunction resolveSdkEntry(): string {\n const srcLayout = fileURLToPath(new URL('../src/index.ts', import.meta.url));\n if (existsSync(srcLayout)) return srcLayout;\n return fileURLToPath(new URL('../index.js', import.meta.url));\n}\n\nexport interface DevHarnessOptions {\n extensionEntry: string;\n port?: number;\n apiPort?: number;\n fixtures?: MockFixtures;\n}\n\nexport interface DevHarness {\n url: string;\n apiUrl: string;\n vite: ViteDevServer;\n close: () => Promise<void>;\n}\n\nexport async function startDevHarness(options: DevHarnessOptions): Promise<DevHarness> {\n const port = options.port ?? 5173;\n const apiPort = options.apiPort ?? 9099;\n const api = await startMockControlPlane(apiPort, options.fixtures);\n const shellRoot = resolveShellRoot();\n const sdkEntry = resolveSdkEntry();\n const vite = await createViteServer({\n root: shellRoot,\n server: { port },\n plugins: [\n {\n name: 'inari-harness-config',\n transformIndexHtml() {\n return [\n {\n tag: 'script',\n injectTo: 'head-prepend',\n children: [\n `window.__INARI_API_URL__ = ${JSON.stringify(api.url)};`,\n `window.__INARI_EXTENSION_ENTRY__ = ${JSON.stringify(`/@fs${options.extensionEntry}`)};`,\n ].join('\\n'),\n },\n ];\n },\n },\n ],\n resolve: {\n alias: [{ find: '@inari/ui-plugin-sdk', replacement: sdkEntry }],\n dedupe: ['react', 'react-dom', 'react-router-dom', 'zod'],\n },\n optimizeDeps: { noDiscovery: true },\n logLevel: 'warn',\n });\n await vite.listen();\n const actualUrl = vite.resolvedUrls?.local[0] ?? `http://localhost:${port}/`;\n return {\n url: actualUrl.replace(/\\/$/, ''),\n apiUrl: api.url,\n vite,\n close: async () => {\n await vite.close();\n await api.close();\n },\n };\n}\n\nexport { createMockControlPlane, startMockControlPlane } from './server.js';\nexport type { MockFixtures } from './server.js';\n","import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http';\n\nexport interface MockFixtures {\n clusters?: unknown[];\n catalogItems?: unknown[];\n resources?: unknown[];\n approvals?: unknown[];\n tenants?: unknown[];\n}\n\nexport const defaultFixtures: Required<MockFixtures> = {\n tenants: [\n { orgId: 'org:acme', orgName: 'Acme', team: 'platform-team' },\n { orgId: 'org:globex', orgName: 'Globex' },\n ],\n clusters: [\n {\n id: 'cluster-1',\n name: 'dev-eu-1',\n tenantId: 'org:acme',\n state: 'Active',\n kubernetesVersion: '1.31',\n labels: { env: 'dev', region: 'eu-west-1' },\n },\n ],\n catalogItems: [\n {\n id: 'item-1',\n name: 'namespace-as-a-service',\n source: 'curated',\n version: '1.0.0',\n description: 'Golden-path namespace',\n },\n ],\n resources: [\n {\n id: 'res-1',\n catalogItemId: 'item-1',\n clusterId: 'cluster-1',\n name: 'demo-ns',\n namespace: 'demo-ns',\n health: 'Healthy',\n ownerTeam: 'platform-team',\n },\n ],\n approvals: [],\n};\n\nfunction readBody(req: IncomingMessage): Promise<string> {\n return new Promise((resolve) => {\n let data = '';\n req.on('data', (c) => (data += c));\n req.on('end', () => resolve(data));\n });\n}\n\nexport function createMockControlPlane(fixtures: MockFixtures = {}): Server {\n const fx: Required<MockFixtures> = { ...defaultFixtures, ...fixtures };\n return createServer(async (req: IncomingMessage, res: ServerResponse) => {\n const url = new URL(req.url ?? '/', 'http://localhost');\n const path = url.pathname;\n res.setHeader('content-type', 'application/json');\n res.setHeader('access-control-allow-origin', '*');\n res.setHeader('access-control-allow-headers', 'content-type, authorization');\n res.setHeader('access-control-allow-methods', 'GET,POST,OPTIONS');\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n const send = (body: unknown, status = 200) => {\n res.statusCode = status;\n res.end(JSON.stringify(body));\n };\n if (req.method === 'GET' && path === '/api/v1/tenants') return send(fx.tenants);\n if (req.method === 'GET' && path === '/api/v1/clusters') return send(fx.clusters);\n if (req.method === 'GET' && path === '/api/v1/catalog/items') return send(fx.catalogItems);\n if (req.method === 'GET' && path === '/api/v1/resources') return send(fx.resources);\n if (req.method === 'GET' && path === '/api/v1/approvals') return send(fx.approvals);\n const clusterMatch = path.match(/^\\/api\\/v1\\/clusters\\/([^/]+)$/);\n if (req.method === 'GET' && clusterMatch) {\n const c = fx.clusters.find((x) => (x as { id: string }).id === clusterMatch[1]);\n return c ? send(c) : send({ message: 'not found' }, 404);\n }\n const resMatch = path.match(/^\\/api\\/v1\\/resources\\/([^/]+)$/);\n if (req.method === 'GET' && resMatch) {\n const r = fx.resources.find((x) => (x as { id: string }).id === resMatch[1]);\n return r ? send(r) : send({ message: 'not found' }, 404);\n }\n const approveMatch = path.match(/^\\/api\\/v1\\/approvals\\/([^/]+)\\/approve$/);\n if (req.method === 'POST' && approveMatch) {\n await readBody(req);\n return send({ id: approveMatch[1], state: 'approved' });\n }\n send({ message: 'not found' }, 404);\n });\n}\n\nexport function startMockControlPlane(\n port: number,\n fixtures?: MockFixtures,\n): Promise<{ server: Server; url: string; close: () => Promise<void> }> {\n const server = createMockControlPlane(fixtures);\n return new Promise((resolve) => {\n server.listen(port, () => {\n const addr = server.address();\n const actualPort = typeof addr === 'object' && addr ? addr.port : port;\n resolve({\n server,\n url: `http://localhost:${actualPort}`,\n close: () => new Promise((r) => server.close(() => r())),\n });\n });\n });\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,wBAA4C;;;ACFrE,SAAS,oBAA4E;AAU9E,IAAM,kBAA0C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AAK,UAAU,IAAI,GAAG,CAAC;AAAA,gBACrD,sCAAsC,KAAK,UAAU,OAAO,QAAQ,cAAc,EAAE,CAAC;AAAA,cACvF,EAAE,KAAK,IAAI;AAAA,YACb;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,OAAO,CAAC,EAAE,MAAM,wBAAwB,aAAa,SAAS,CAAC;AAAA,MAC/D,QAAQ,CAAC,SAAS,aAAa,oBAAoB,KAAK;AAAA,IAC1D;AAAA,IACA,cAAc,EAAE,aAAa,KAAK;AAAA,IAClC,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,KAAK,OAAO;AAClB,QAAM,YAAY,KAAK,cAAc,MAAM,CAAC,KAAK,oBAAoB,IAAI;AACzE,SAAO;AAAA,IACL,KAAK,UAAU,QAAQ,OAAO,EAAE;AAAA,IAChC,QAAQ,IAAI;AAAA,IACZ;AAAA,IACA,OAAO,YAAY;AACjB,YAAM,KAAK,MAAM;AACjB,YAAM,IAAI,MAAM;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../harness/index.ts","../../harness/server.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { createServer as createViteServer, type ViteDevServer } from 'vite';\nimport { startMockControlPlane, type MockFixtures } from './server.js';\n\nfunction resolveShellRoot(): string {\n const srcLayout = fileURLToPath(new URL('./shell', import.meta.url));\n if (existsSync(srcLayout)) return srcLayout;\n return fileURLToPath(new URL('../../harness/shell', import.meta.url));\n}\n\nfunction resolveSdkEntry(): string {\n const srcLayout = fileURLToPath(new URL('../src/index.ts', import.meta.url));\n if (existsSync(srcLayout)) return srcLayout;\n return fileURLToPath(new URL('../index.js', import.meta.url));\n}\n\nexport interface DevHarnessOptions {\n extensionEntry: string;\n port?: number;\n apiPort?: number;\n fixtures?: MockFixtures;\n}\n\nexport interface DevHarness {\n url: string;\n apiUrl: string;\n vite: ViteDevServer;\n close: () => Promise<void>;\n}\n\nexport async function startDevHarness(options: DevHarnessOptions): Promise<DevHarness> {\n const port = options.port ?? 5173;\n const apiPort = options.apiPort ?? 9099;\n const api = await startMockControlPlane(apiPort, options.fixtures);\n const shellRoot = resolveShellRoot();\n const sdkEntry = resolveSdkEntry();\n const vite = await createViteServer({\n root: shellRoot,\n server: { port },\n plugins: [\n {\n name: 'inari-harness-config',\n transformIndexHtml() {\n return [\n {\n tag: 'script',\n injectTo: 'head-prepend',\n children: [\n `window.__INARI_API_URL__ = ${JSON.stringify(api.url)};`,\n `window.__INARI_EXTENSION_ENTRY__ = ${JSON.stringify(`/@fs${options.extensionEntry}`)};`,\n ].join('\\n'),\n },\n ];\n },\n },\n ],\n resolve: {\n alias: [{ find: '@7k-inari/ui-plugin-sdk', replacement: sdkEntry }],\n dedupe: ['react', 'react-dom', 'react-router-dom', 'zod'],\n },\n optimizeDeps: { noDiscovery: true },\n logLevel: 'warn',\n });\n await vite.listen();\n const actualUrl = vite.resolvedUrls?.local[0] ?? `http://localhost:${port}/`;\n return {\n url: actualUrl.replace(/\\/$/, ''),\n apiUrl: api.url,\n vite,\n close: async () => {\n await vite.close();\n await api.close();\n },\n };\n}\n\nexport { createMockControlPlane, startMockControlPlane } from './server.js';\nexport type { MockFixtures } from './server.js';\n","import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http';\n\nexport interface MockFixtures {\n clusters?: unknown[];\n catalogItems?: unknown[];\n resources?: unknown[];\n approvals?: unknown[];\n tenants?: unknown[];\n}\n\nexport const defaultFixtures: Required<MockFixtures> = {\n tenants: [\n { orgId: 'org:acme', orgName: 'Acme', team: 'platform-team' },\n { orgId: 'org:globex', orgName: 'Globex' },\n ],\n clusters: [\n {\n id: 'cluster-1',\n name: 'dev-eu-1',\n tenantId: 'org:acme',\n state: 'Active',\n kubernetesVersion: '1.31',\n labels: { env: 'dev', region: 'eu-west-1' },\n },\n ],\n catalogItems: [\n {\n id: 'item-1',\n name: 'namespace-as-a-service',\n source: 'curated',\n version: '1.0.0',\n description: 'Golden-path namespace',\n },\n ],\n resources: [\n {\n id: 'res-1',\n catalogItemId: 'item-1',\n clusterId: 'cluster-1',\n name: 'demo-ns',\n namespace: 'demo-ns',\n health: 'Healthy',\n ownerTeam: 'platform-team',\n },\n ],\n approvals: [],\n};\n\nfunction readBody(req: IncomingMessage): Promise<string> {\n return new Promise((resolve) => {\n let data = '';\n req.on('data', (c) => (data += c));\n req.on('end', () => resolve(data));\n });\n}\n\nexport function createMockControlPlane(fixtures: MockFixtures = {}): Server {\n const fx: Required<MockFixtures> = { ...defaultFixtures, ...fixtures };\n return createServer(async (req: IncomingMessage, res: ServerResponse) => {\n const url = new URL(req.url ?? '/', 'http://localhost');\n const path = url.pathname;\n res.setHeader('content-type', 'application/json');\n res.setHeader('access-control-allow-origin', '*');\n res.setHeader('access-control-allow-headers', 'content-type, authorization');\n res.setHeader('access-control-allow-methods', 'GET,POST,OPTIONS');\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n const send = (body: unknown, status = 200) => {\n res.statusCode = status;\n res.end(JSON.stringify(body));\n };\n if (req.method === 'GET' && path === '/api/v1/tenants') return send(fx.tenants);\n if (req.method === 'GET' && path === '/api/v1/clusters') return send(fx.clusters);\n if (req.method === 'GET' && path === '/api/v1/catalog/items') return send(fx.catalogItems);\n if (req.method === 'GET' && path === '/api/v1/resources') return send(fx.resources);\n if (req.method === 'GET' && path === '/api/v1/approvals') return send(fx.approvals);\n const clusterMatch = path.match(/^\\/api\\/v1\\/clusters\\/([^/]+)$/);\n if (req.method === 'GET' && clusterMatch) {\n const c = fx.clusters.find((x) => (x as { id: string }).id === clusterMatch[1]);\n return c ? send(c) : send({ message: 'not found' }, 404);\n }\n const resMatch = path.match(/^\\/api\\/v1\\/resources\\/([^/]+)$/);\n if (req.method === 'GET' && resMatch) {\n const r = fx.resources.find((x) => (x as { id: string }).id === resMatch[1]);\n return r ? send(r) : send({ message: 'not found' }, 404);\n }\n const approveMatch = path.match(/^\\/api\\/v1\\/approvals\\/([^/]+)\\/approve$/);\n if (req.method === 'POST' && approveMatch) {\n await readBody(req);\n return send({ id: approveMatch[1], state: 'approved' });\n }\n send({ message: 'not found' }, 404);\n });\n}\n\nexport function startMockControlPlane(\n port: number,\n fixtures?: MockFixtures,\n): Promise<{ server: Server; url: string; close: () => Promise<void> }> {\n const server = createMockControlPlane(fixtures);\n return new Promise((resolve) => {\n server.listen(port, () => {\n const addr = server.address();\n const actualPort = typeof addr === 'object' && addr ? addr.port : port;\n resolve({\n server,\n url: `http://localhost:${actualPort}`,\n close: () => new Promise((r) => server.close(() => r())),\n });\n });\n });\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,wBAA4C;;;ACFrE,SAAS,oBAA4E;AAU9E,IAAM,kBAA0C;AAAA,EACrD,SAAS;AAAA,IACP,EAAE,OAAO,YAAY,SAAS,QAAQ,MAAM,gBAAgB;AAAA,IAC5D,EAAE,OAAO,cAAc,SAAS,SAAS;AAAA,EAC3C;AAAA,EACA,UAAU;AAAA,IACR;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,QAAQ,EAAE,KAAK,OAAO,QAAQ,YAAY;AAAA,IAC5C;AAAA,EACF;AAAA,EACA,cAAc;AAAA,IACZ;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACT;AAAA,MACE,IAAI;AAAA,MACJ,eAAe;AAAA,MACf,WAAW;AAAA,MACX,MAAM;AAAA,MACN,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,WAAW,CAAC;AACd;AAEA,SAAS,SAAS,KAAuC;AAC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cjs CHANGED
@@ -36,6 +36,7 @@ __export(src_exports, {
36
36
  createExtension: () => createExtension,
37
37
  createTenantState: () => createTenantState,
38
38
  extensionManifestSchema: () => extensionManifestSchema,
39
+ getAuthState: () => getAuthState,
39
40
  parseExtensionManifest: () => parseExtensionManifest,
40
41
  useAuth: () => useAuth,
41
42
  usePrincipal: () => usePrincipal,
@@ -137,9 +138,14 @@ var PageBlueprint = (params) => ({
137
138
  // src/host/auth.ts
138
139
  var import_react = require("react");
139
140
  var AuthContext = (0, import_react.createContext)(null);
141
+ var currentAuth = null;
140
142
  function AuthProvider(props) {
143
+ currentAuth = props.value;
141
144
  return (0, import_react.createElement)(AuthContext.Provider, { value: props.value }, props.children);
142
145
  }
146
+ function getAuthState() {
147
+ return currentAuth;
148
+ }
143
149
  function useAuth() {
144
150
  const ctx = (0, import_react.useContext)(AuthContext);
145
151
  if (!ctx) throw new Error("useAuth must be used within an AuthProvider");
@@ -260,6 +266,7 @@ var ApiClient = class {
260
266
  createExtension,
261
267
  createTenantState,
262
268
  extensionManifestSchema,
269
+ getAuthState,
263
270
  parseExtensionManifest,
264
271
  useAuth,
265
272
  usePrincipal,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/manifest.ts","../src/extension.ts","../src/blueprints/types.ts","../src/blueprints/nav-item.ts","../src/blueprints/catalog-card.ts","../src/blueprints/cluster-tab.ts","../src/blueprints/instance-action.ts","../src/blueprints/form-widget.ts","../src/blueprints/page.ts","../src/host/auth.ts","../src/host/tenant.ts","../src/host/api.ts"],"sourcesContent":["export * from './manifest';\nexport * from './extension';\nexport * from './blueprints';\nexport * from './host';\n","import { z } from 'zod';\n\nconst nameSchema = z\n .string()\n .min(1)\n .regex(/^[a-z0-9][a-z0-9-]*$/, 'name must be kebab-case');\n\nconst slotContributionSchema = z.object({\n kind: z.enum([\n 'nav-item',\n 'catalog-card',\n 'cluster-tab',\n 'instance-action',\n 'form-widget',\n 'page',\n ]),\n name: nameSchema,\n});\n\nexport const extensionManifestSchema = z.object({\n name: nameSchema,\n version: z.string().min(1),\n kind: z.literal('ui'),\n title: z.string().optional(),\n description: z.string().optional(),\n slots: z.array(slotContributionSchema).min(1),\n});\n\nexport type ExtensionManifestInput = z.input<typeof extensionManifestSchema>;\nexport type ParsedExtensionManifest = z.output<typeof extensionManifestSchema>;\n\nexport function parseExtensionManifest(input: unknown): ParsedExtensionManifest {\n return extensionManifestSchema.parse(input);\n}\n","import type { ExtensionManifestInput } from './manifest';\nimport { parseExtensionManifest } from './manifest';\nimport type { AnySlotContribution, InariExtension } from './blueprints/types';\n\nexport interface CreateExtensionParams {\n manifest: Omit<ExtensionManifestInput, 'slots'>;\n slots: AnySlotContribution[];\n}\n\nexport function createExtension(params: CreateExtensionParams): InariExtension {\n const slotDescriptors = params.slots.map((s) => ({ kind: s.kind, name: s.name }));\n const manifest = parseExtensionManifest({ ...params.manifest, slots: slotDescriptors });\n return { manifest, slots: params.slots };\n}\n","import type { ComponentType } from 'react';\n\nexport const SLOT_KINDS = [\n 'nav-item',\n 'catalog-card',\n 'cluster-tab',\n 'instance-action',\n 'form-widget',\n 'page',\n] as const;\n\nexport type SlotKind = (typeof SLOT_KINDS)[number];\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport interface SlotContribution<K extends SlotKind = SlotKind, P = unknown, O = unknown> {\n readonly kind: K;\n readonly name: string;\n readonly props: P;\n readonly options?: O;\n readonly component?: ComponentType<any>;\n}\n\nexport type AnySlotContribution = SlotContribution<SlotKind, any, any>;\n\nexport interface InariExtension {\n readonly manifest: import('../manifest.js').ParsedExtensionManifest;\n readonly slots: readonly AnySlotContribution[];\n}\n\nexport interface SlotContext {\n auth: import('../host/auth.js').AuthState;\n tenant: import('../host/tenant.js').TenantState;\n}\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\n\nexport interface NavItemProps {\n title: string;\n path: string;\n icon?: ComponentType;\n}\n\nexport const NavItemBlueprint = (params: { name: string } & NavItemProps): SlotContribution<'nav-item', NavItemProps> => ({\n kind: 'nav-item',\n name: params.name,\n props: { title: params.title, path: params.path, icon: params.icon },\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\nimport type { CatalogItem } from '../host/api';\n\nexport interface CatalogCardSlotProps {\n catalogItem: CatalogItem;\n}\n\nexport const CatalogCardBlueprint = (params: {\n name: string;\n component: ComponentType<CatalogCardSlotProps>;\n}): SlotContribution<'catalog-card', CatalogCardSlotProps> => ({\n kind: 'catalog-card',\n name: params.name,\n props: {} as CatalogCardSlotProps,\n component: params.component,\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\nimport type { Cluster } from '../host/api';\n\nexport interface ClusterTabSlotProps {\n cluster: Cluster;\n}\n\nexport interface ClusterTabOptions {\n title: string;\n}\n\nexport const ClusterTabBlueprint = (params: {\n name: string;\n title: string;\n component: ComponentType<ClusterTabSlotProps>;\n}): SlotContribution<'cluster-tab', ClusterTabSlotProps, ClusterTabOptions> => ({\n kind: 'cluster-tab',\n name: params.name,\n props: {} as ClusterTabSlotProps,\n options: { title: params.title },\n component: params.component,\n});\n","import type { SlotContribution } from './types';\nimport type { ResourceInstance } from '../host/api';\n\nexport interface InstanceActionSlotProps {\n instance: ResourceInstance;\n}\n\nexport interface InstanceActionProps {\n label: string;\n run: (instance: ResourceInstance) => Promise<void> | void;\n}\n\nexport const InstanceActionBlueprint = (params: {\n name: string;\n label: string;\n run: (instance: ResourceInstance) => Promise<void> | void;\n}): SlotContribution<'instance-action', InstanceActionProps> => ({\n kind: 'instance-action',\n name: params.name,\n props: { label: params.label, run: params.run },\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\n\nexport interface FormWidgetSlotProps<T = unknown> {\n value: T | undefined;\n onChange: (value: T) => void;\n schema: Record<string, unknown>;\n disabled?: boolean;\n}\n\nexport const FormWidgetBlueprint = <T = unknown>(params: {\n name: string;\n component: ComponentType<FormWidgetSlotProps<T>>;\n schemaType?: string;\n}): SlotContribution<'form-widget', FormWidgetSlotProps<T>> => ({\n kind: 'form-widget',\n name: params.name,\n props: {} as FormWidgetSlotProps<T>,\n component: params.component as ComponentType<FormWidgetSlotProps<T>>,\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution, SlotContext } from './types';\n\nexport interface PageSlotProps {\n context: SlotContext;\n}\n\nexport interface PageOptions {\n path: string;\n title?: string;\n}\n\nexport const PageBlueprint = (params: {\n name: string;\n path: string;\n title?: string;\n component: ComponentType<PageSlotProps>;\n}): SlotContribution<'page', PageSlotProps, PageOptions> => ({\n kind: 'page',\n name: params.name,\n props: {} as PageSlotProps,\n options: { path: params.path, title: params.title },\n component: params.component,\n});\n","import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface Principal {\n subject: string;\n displayName: string;\n groups: string[];\n}\n\nexport interface AuthState {\n principal: Principal | null;\n getToken: () => Promise<string | undefined> | string | undefined;\n}\n\nexport const AuthContext = createContext<AuthState | null>(null);\n\nexport function AuthProvider(props: { value: AuthState; children: ReactNode }) {\n return createElement(AuthContext.Provider, { value: props.value }, props.children);\n}\n\nexport function useAuth(): AuthState {\n const ctx = useContext(AuthContext);\n if (!ctx) throw new Error('useAuth must be used within an AuthProvider');\n return ctx;\n}\n\nexport function usePrincipal(): Principal | null {\n return useAuth().principal;\n}\n","import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface TenantRef {\n orgId: string;\n orgName: string;\n team?: string;\n}\n\nexport interface TenantChangeEvent {\n previous: TenantRef | null;\n current: TenantRef;\n}\n\nexport type TenantChangeListener = (event: TenantChangeEvent) => void;\n\nexport interface TenantState {\n current: TenantRef | null;\n available: TenantRef[];\n switchTenant: (orgId: string, team?: string) => void;\n onTenantChange: (listener: TenantChangeListener) => () => void;\n}\n\nexport const TenantContext = createContext<TenantState | null>(null);\n\nexport function TenantProvider(props: { value: TenantState; children: ReactNode }) {\n return createElement(TenantContext.Provider, { value: props.value }, props.children);\n}\n\nexport function useTenant(): TenantState {\n const ctx = useContext(TenantContext);\n if (!ctx) throw new Error('useTenant must be used within a TenantProvider');\n return ctx;\n}\n\nexport function createTenantState(available: TenantRef[]): TenantState & { _listeners: Set<TenantChangeListener> } {\n const listeners = new Set<TenantChangeListener>();\n const state = {\n current: available[0] ?? null,\n available,\n _listeners: listeners,\n switchTenant(orgId: string, team?: string) {\n const next = available.find((t) => t.orgId === orgId && (team === undefined || t.team === team));\n if (!next) throw new Error(`unknown tenant: ${orgId}${team ? `/${team}` : ''}`);\n const previous = state.current;\n state.current = next;\n listeners.forEach((l) => l({ previous, current: next }));\n },\n onTenantChange(listener: TenantChangeListener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return state;\n}\n","export interface Cluster {\n id: string;\n name: string;\n tenantId: string;\n state: 'Pending' | 'Active' | 'Degraded' | 'Cordoned' | 'Decommissioned';\n kubernetesVersion?: string;\n labels?: Record<string, string>;\n}\n\nexport interface CatalogItem {\n id: string;\n name: string;\n source: 'discovered' | 'curated' | 'platform';\n version: string;\n description?: string;\n schema?: Record<string, unknown>;\n uiHints?: Record<string, unknown>;\n}\n\nexport interface ResourceInstance {\n id: string;\n catalogItemId: string;\n clusterId: string;\n cloudAccountId?: string;\n name: string;\n namespace?: string;\n health?: string;\n status?: Record<string, unknown>;\n ownerTeam?: string;\n}\n\nexport interface ApprovalRequest {\n id: string;\n action: string;\n requester: string;\n state: 'pending' | 'approved' | 'rejected';\n}\n\nexport interface ApiClientOptions {\n baseUrl: string;\n getToken: () => Promise<string | undefined> | string | undefined;\n fetchImpl?: typeof fetch;\n}\n\nexport class ApiError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport class ApiClient {\n private readonly baseUrl: string;\n private readonly getToken: ApiClientOptions['getToken'];\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: ApiClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '');\n this.getToken = options.getToken;\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const token = await this.getToken();\n const res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers: {\n 'content-type': 'application/json',\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n if (!res.ok) {\n throw new ApiError(res.status, `${method} ${path} failed: ${res.status}`);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n\n listClusters(): Promise<Cluster[]> {\n return this.request('GET', '/api/v1/clusters');\n }\n\n getCluster(id: string): Promise<Cluster> {\n return this.request('GET', `/api/v1/clusters/${encodeURIComponent(id)}`);\n }\n\n listCatalogItems(clusterId?: string): Promise<CatalogItem[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/catalog/items${q}`);\n }\n\n getCatalogItem(id: string): Promise<CatalogItem> {\n return this.request('GET', `/api/v1/catalog/items/${encodeURIComponent(id)}`);\n }\n\n listResourceInstances(clusterId?: string): Promise<ResourceInstance[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/resources${q}`);\n }\n\n getResourceInstance(id: string): Promise<ResourceInstance> {\n return this.request('GET', `/api/v1/resources/${encodeURIComponent(id)}`);\n }\n\n listApprovals(): Promise<ApprovalRequest[]> {\n return this.request('GET', '/api/v1/approvals');\n }\n\n approveApproval(id: string): Promise<ApprovalRequest> {\n return this.request('POST', `/api/v1/approvals/${encodeURIComponent(id)}/approve`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAElB,IAAM,aAAa,aAChB,OAAO,EACP,IAAI,CAAC,EACL,MAAM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SAAS,SAAY,SAAY,KAAK,UAAU,IAAI;AAAA,IAC5D,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,SAAS,IAAI,QAAQ,GAAG,MAAM,IAAI,IAAI,YAAY,IAAI,MAAM,EAAE;AAAA,IAC1E;AACA,QAAI,IAAI,WAAW,IAAK,QAAO;AAC/B,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB;AAAA,EAEA,eAAmC;AACjC,WAAO,KAAK,QAAQ,OAAO,kBAAkB;AAAA,EAC/C;AAAA,EAEA,WAAW,IAA8B;AACvC,WAAO,KAAK,QAAQ,OAAO,oBAAoB,mBAAmB,EAAE,CAAC,EAAE;AAAA,EACzE;AAAA,EAEA,iBAAiB,WAA4C;AAC3D,UAAM,IAAI,YAAY,cAAc,mBAAmB,SAAS,CAAC,KAAK;AACtE,WAAO,KAAK,QAAQ,OAAO,wBAAwB,CAAC,EAAE;AAAA,EACxD;AAAA,EAEA,eAAe,IAAkC;AAC/C,WAAO,KAAK,QAAQ,OAAO,yBAAyB,mBAAmB,EAAE,CAAC,EAAE;AAAA,EAC9E;AAAA,EAEA,sBAAsB,WAAiD;AACrE,UAAM,IAAI,YAAY,cAAc,mBAAmB,SAAS,CAAC,KAAK;AACtE,WAAO,KAAK,QAAQ,OAAO,oBAAoB,CAAC,EAAE;AAAA,EACpD;AAAA,EAEA,oBAAoB,IAAuC;AACzD,WAAO,KAAK,QAAQ,OAAO,qBAAqB,mBAAmB,EAAE,CAAC,EAAE;AAAA,EAC1E;AAAA,EAEA,gBAA4C;AAC1C,WAAO,KAAK,QAAQ,OAAO,mBAAmB;AAAA,EAChD;AAAA,EAEA,gBAAgB,IAAsC;AACpD,WAAO,KAAK,QAAQ,QAAQ,qBAAqB,mBAAmB,EAAE,CAAC,UAAU;AAAA,EACnF;AACF;","names":["import_react"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/manifest.ts","../src/extension.ts","../src/blueprints/types.ts","../src/blueprints/nav-item.ts","../src/blueprints/catalog-card.ts","../src/blueprints/cluster-tab.ts","../src/blueprints/instance-action.ts","../src/blueprints/form-widget.ts","../src/blueprints/page.ts","../src/host/auth.ts","../src/host/tenant.ts","../src/host/api.ts"],"sourcesContent":["export * from './manifest';\nexport * from './extension';\nexport * from './blueprints';\nexport * from './host';\n","import { z } from 'zod';\n\nconst nameSchema = z\n .string()\n .min(1)\n .regex(/^[a-z0-9][a-z0-9-]*$/, 'name must be kebab-case');\n\nconst slotContributionSchema = z.object({\n kind: z.enum([\n 'nav-item',\n 'catalog-card',\n 'cluster-tab',\n 'instance-action',\n 'form-widget',\n 'page',\n ]),\n name: nameSchema,\n});\n\nexport const extensionManifestSchema = z.object({\n name: nameSchema,\n version: z.string().min(1),\n kind: z.literal('ui'),\n title: z.string().optional(),\n description: z.string().optional(),\n slots: z.array(slotContributionSchema).min(1),\n});\n\nexport type ExtensionManifestInput = z.input<typeof extensionManifestSchema>;\nexport type ParsedExtensionManifest = z.output<typeof extensionManifestSchema>;\n\nexport function parseExtensionManifest(input: unknown): ParsedExtensionManifest {\n return extensionManifestSchema.parse(input);\n}\n","import type { ExtensionManifestInput } from './manifest';\nimport { parseExtensionManifest } from './manifest';\nimport type { AnySlotContribution, InariExtension } from './blueprints/types';\n\nexport interface CreateExtensionParams {\n manifest: Omit<ExtensionManifestInput, 'slots'>;\n slots: AnySlotContribution[];\n}\n\nexport function createExtension(params: CreateExtensionParams): InariExtension {\n const slotDescriptors = params.slots.map((s) => ({ kind: s.kind, name: s.name }));\n const manifest = parseExtensionManifest({ ...params.manifest, slots: slotDescriptors });\n return { manifest, slots: params.slots };\n}\n","import type { ComponentType } from 'react';\n\nexport const SLOT_KINDS = [\n 'nav-item',\n 'catalog-card',\n 'cluster-tab',\n 'instance-action',\n 'form-widget',\n 'page',\n] as const;\n\nexport type SlotKind = (typeof SLOT_KINDS)[number];\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport interface SlotContribution<K extends SlotKind = SlotKind, P = unknown, O = unknown> {\n readonly kind: K;\n readonly name: string;\n readonly props: P;\n readonly options?: O;\n readonly component?: ComponentType<any>;\n}\n\nexport type AnySlotContribution = SlotContribution<SlotKind, any, any>;\n\nexport interface InariExtension {\n readonly manifest: import('../manifest.js').ParsedExtensionManifest;\n readonly slots: readonly AnySlotContribution[];\n}\n\nexport interface SlotContext {\n auth: import('../host/auth.js').AuthState;\n tenant: import('../host/tenant.js').TenantState;\n}\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\n\nexport interface NavItemProps {\n title: string;\n path: string;\n icon?: ComponentType;\n}\n\nexport const NavItemBlueprint = (params: { name: string } & NavItemProps): SlotContribution<'nav-item', NavItemProps> => ({\n kind: 'nav-item',\n name: params.name,\n props: { title: params.title, path: params.path, icon: params.icon },\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\nimport type { CatalogItem } from '../host/api';\n\nexport interface CatalogCardSlotProps {\n catalogItem: CatalogItem;\n}\n\nexport const CatalogCardBlueprint = (params: {\n name: string;\n component: ComponentType<CatalogCardSlotProps>;\n}): SlotContribution<'catalog-card', CatalogCardSlotProps> => ({\n kind: 'catalog-card',\n name: params.name,\n props: {} as CatalogCardSlotProps,\n component: params.component,\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\nimport type { Cluster } from '../host/api';\n\nexport interface ClusterTabSlotProps {\n cluster: Cluster;\n}\n\nexport interface ClusterTabOptions {\n title: string;\n}\n\nexport const ClusterTabBlueprint = (params: {\n name: string;\n title: string;\n component: ComponentType<ClusterTabSlotProps>;\n}): SlotContribution<'cluster-tab', ClusterTabSlotProps, ClusterTabOptions> => ({\n kind: 'cluster-tab',\n name: params.name,\n props: {} as ClusterTabSlotProps,\n options: { title: params.title },\n component: params.component,\n});\n","import type { SlotContribution } from './types';\nimport type { ResourceInstance } from '../host/api';\n\nexport interface InstanceActionSlotProps {\n instance: ResourceInstance;\n}\n\nexport interface InstanceActionProps {\n label: string;\n run: (instance: ResourceInstance) => Promise<void> | void;\n}\n\nexport const InstanceActionBlueprint = (params: {\n name: string;\n label: string;\n run: (instance: ResourceInstance) => Promise<void> | void;\n}): SlotContribution<'instance-action', InstanceActionProps> => ({\n kind: 'instance-action',\n name: params.name,\n props: { label: params.label, run: params.run },\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\n\nexport interface FormWidgetSlotProps<T = unknown> {\n value: T | undefined;\n onChange: (value: T) => void;\n schema: Record<string, unknown>;\n disabled?: boolean;\n}\n\nexport const FormWidgetBlueprint = <T = unknown>(params: {\n name: string;\n component: ComponentType<FormWidgetSlotProps<T>>;\n schemaType?: string;\n}): SlotContribution<'form-widget', FormWidgetSlotProps<T>> => ({\n kind: 'form-widget',\n name: params.name,\n props: {} as FormWidgetSlotProps<T>,\n component: params.component as ComponentType<FormWidgetSlotProps<T>>,\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution, SlotContext } from './types';\n\nexport interface PageSlotProps {\n context: SlotContext;\n}\n\nexport interface PageOptions {\n path: string;\n title?: string;\n}\n\nexport const PageBlueprint = (params: {\n name: string;\n path: string;\n title?: string;\n component: ComponentType<PageSlotProps>;\n}): SlotContribution<'page', PageSlotProps, PageOptions> => ({\n kind: 'page',\n name: params.name,\n props: {} as PageSlotProps,\n options: { path: params.path, title: params.title },\n component: params.component,\n});\n","import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface Principal {\n subject: string;\n displayName: string;\n groups: string[];\n}\n\nexport interface AuthState {\n principal: Principal | null;\n getToken: () => Promise<string | undefined> | string | undefined;\n}\n\nexport const AuthContext = createContext<AuthState | null>(null);\n\n// Module-level mirror of the active AuthState: remotes are host-provided\n// singleton consumers, and their non-component code paths (e.g. instance\n// action runners invoked from host menus) cannot call hooks.\nlet currentAuth: AuthState | null = null;\n\nexport function AuthProvider(props: { value: AuthState; children: ReactNode }) {\n currentAuth = props.value;\n return createElement(AuthContext.Provider, { value: props.value }, props.children);\n}\n\n/** getAuthState returns the active AuthState outside React (null before the\n * provider mounts). Prefer useAuth() inside components. */\nexport function getAuthState(): AuthState | null {\n return currentAuth;\n}\n\nexport function useAuth(): AuthState {\n const ctx = useContext(AuthContext);\n if (!ctx) throw new Error('useAuth must be used within an AuthProvider');\n return ctx;\n}\n\nexport function usePrincipal(): Principal | null {\n return useAuth().principal;\n}\n","import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface TenantRef {\n orgId: string;\n orgName: string;\n team?: string;\n}\n\nexport interface TenantChangeEvent {\n previous: TenantRef | null;\n current: TenantRef;\n}\n\nexport type TenantChangeListener = (event: TenantChangeEvent) => void;\n\nexport interface TenantState {\n current: TenantRef | null;\n available: TenantRef[];\n switchTenant: (orgId: string, team?: string) => void;\n onTenantChange: (listener: TenantChangeListener) => () => void;\n}\n\nexport const TenantContext = createContext<TenantState | null>(null);\n\nexport function TenantProvider(props: { value: TenantState; children: ReactNode }) {\n return createElement(TenantContext.Provider, { value: props.value }, props.children);\n}\n\nexport function useTenant(): TenantState {\n const ctx = useContext(TenantContext);\n if (!ctx) throw new Error('useTenant must be used within a TenantProvider');\n return ctx;\n}\n\nexport function createTenantState(available: TenantRef[]): TenantState & { _listeners: Set<TenantChangeListener> } {\n const listeners = new Set<TenantChangeListener>();\n const state = {\n current: available[0] ?? null,\n available,\n _listeners: listeners,\n switchTenant(orgId: string, team?: string) {\n const next = available.find((t) => t.orgId === orgId && (team === undefined || t.team === team));\n if (!next) throw new Error(`unknown tenant: ${orgId}${team ? `/${team}` : ''}`);\n const previous = state.current;\n state.current = next;\n listeners.forEach((l) => l({ previous, current: next }));\n },\n onTenantChange(listener: TenantChangeListener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return state;\n}\n","export interface Cluster {\n id: string;\n name: string;\n tenantId: string;\n state: 'Pending' | 'Active' | 'Degraded' | 'Cordoned' | 'Decommissioned';\n kubernetesVersion?: string;\n labels?: Record<string, string>;\n}\n\nexport interface CatalogItem {\n id: string;\n name: string;\n source: 'discovered' | 'curated' | 'platform' | 'template';\n version: string;\n description?: string;\n schema?: Record<string, unknown>;\n uiHints?: Record<string, unknown>;\n}\n\nexport interface ResourceInstance {\n id: string;\n catalogItemId: string;\n clusterId: string;\n cloudAccountId?: string;\n name: string;\n namespace?: string;\n health?: string;\n status?: Record<string, unknown>;\n ownerTeam?: string;\n}\n\nexport interface ApprovalRequest {\n id: string;\n action: string;\n requester: string;\n state: 'pending' | 'approved' | 'rejected';\n}\n\nexport interface ApiClientOptions {\n baseUrl: string;\n getToken: () => Promise<string | undefined> | string | undefined;\n fetchImpl?: typeof fetch;\n}\n\nexport class ApiError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport class ApiClient {\n private readonly baseUrl: string;\n private readonly getToken: ApiClientOptions['getToken'];\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: ApiClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '');\n this.getToken = options.getToken;\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const token = await this.getToken();\n const res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers: {\n 'content-type': 'application/json',\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n if (!res.ok) {\n throw new ApiError(res.status, `${method} ${path} failed: ${res.status}`);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n\n listClusters(): Promise<Cluster[]> {\n return this.request('GET', '/api/v1/clusters');\n }\n\n getCluster(id: string): Promise<Cluster> {\n return this.request('GET', `/api/v1/clusters/${encodeURIComponent(id)}`);\n }\n\n listCatalogItems(clusterId?: string): Promise<CatalogItem[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/catalog/items${q}`);\n }\n\n getCatalogItem(id: string): Promise<CatalogItem> {\n return this.request('GET', `/api/v1/catalog/items/${encodeURIComponent(id)}`);\n }\n\n listResourceInstances(clusterId?: string): Promise<ResourceInstance[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/resources${q}`);\n }\n\n getResourceInstance(id: string): Promise<ResourceInstance> {\n return this.request('GET', `/api/v1/resources/${encodeURIComponent(id)}`);\n }\n\n listApprovals(): Promise<ApprovalRequest[]> {\n return this.request('GET', '/api/v1/approvals');\n }\n\n approveApproval(id: string): Promise<ApprovalRequest> {\n return this.request('POST', `/api/v1/approvals/${encodeURIComponent(id)}/approve`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAElB,IAAM,aAAa,aAChB,OAAO,EACP,IAAI,CAAC,EACL,MAAM,wBAAwB,yBAAyB;AAE1D,IAAM,yBAAyB,aAAE,OAAO;AAAA,EACtC,MAAM,aAAE,KAAK;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAAA,EACD,MAAM;AACR,CAAC;AAEM,IAAM,0BAA0B,aAAE,OAAO;AAAA,EAC9C,MAAM;AAAA,EACN,SAAS,aAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACzB,MAAM,aAAE,QAAQ,IAAI;AAAA,EACpB,OAAO,aAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,EACjC,OAAO,aAAE,MAAM,sBAAsB,EAAE,IAAI,CAAC;AAC9C,CAAC;AAKM,SAAS,uBAAuB,OAAyC;AAC9E,SAAO,wBAAwB,MAAM,KAAK;AAC5C;;;ACxBO,SAAS,gBAAgB,QAA+C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,SAAS,CAAC,KAAK;AACtE,WAAO,KAAK,QAAQ,OAAO,wBAAwB,CAAC,EAAE;AAAA,EACxD;AAAA,EAEA,eAAe,IAAkC;AAC/C,WAAO,KAAK,QAAQ,OAAO,yBAAyB,mBAAmB,EAAE,CAAC,EAAE;AAAA,EAC9E;AAAA,EAEA,sBAAsB,WAAiD;AACrE,UAAM,IAAI,YAAY,cAAc,mBAAmB,SAAS,CAAC,KAAK;AACtE,WAAO,KAAK,QAAQ,OAAO,oBAAoB,CAAC,EAAE;AAAA,EACpD;AAAA,EAEA,oBAAoB,IAAuC;AACzD,WAAO,KAAK,QAAQ,OAAO,qBAAqB,mBAAmB,EAAE,CAAC,EAAE;AAAA,EAC1E;AAAA,EAEA,gBAA4C;AAC1C,WAAO,KAAK,QAAQ,OAAO,mBAAmB;AAAA,EAChD;AAAA,EAEA,gBAAgB,IAAsC;AACpD,WAAO,KAAK,QAAQ,QAAQ,qBAAqB,mBAAmB,EAAE,CAAC,UAAU;AAAA,EACnF;AACF;","names":["import_react"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as ExtensionManifestInput, A as AnySlotContribution, I as InariExtension, S as SlotContribution, C as CatalogItem, a as Cluster, R as ResourceInstance, b as SlotContext } from './api-CJrl4sLH.cjs';
2
- export { c as ApiClient, d as ApiClientOptions, e as ApiError, f as ApprovalRequest, g as AuthContext, h as AuthProvider, i as AuthState, P as ParsedExtensionManifest, j as Principal, k as SLOT_KINDS, l as SlotKind, T as TenantChangeEvent, m as TenantChangeListener, n as TenantContext, o as TenantProvider, p as TenantRef, q as TenantState, r as createTenantState, s as extensionManifestSchema, t as parseExtensionManifest, u as useAuth, v as usePrincipal, w as useTenant } from './api-CJrl4sLH.cjs';
1
+ import { E as ExtensionManifestInput, A as AnySlotContribution, I as InariExtension, S as SlotContribution, C as CatalogItem, a as Cluster, R as ResourceInstance, b as SlotContext } from './api-Br2Mnkqb.cjs';
2
+ export { c as ApiClient, d as ApiClientOptions, e as ApiError, f as ApprovalRequest, g as AuthContext, h as AuthProvider, i as AuthState, P as ParsedExtensionManifest, j as Principal, k as SLOT_KINDS, l as SlotKind, T as TenantChangeEvent, m as TenantChangeListener, n as TenantContext, o as TenantProvider, p as TenantRef, q as TenantState, r as createTenantState, s as extensionManifestSchema, t as getAuthState, u as parseExtensionManifest, v as useAuth, w as usePrincipal, x as useTenant } from './api-Br2Mnkqb.cjs';
3
3
  import { ComponentType } from 'react';
4
4
  import 'zod';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as ExtensionManifestInput, A as AnySlotContribution, I as InariExtension, S as SlotContribution, C as CatalogItem, a as Cluster, R as ResourceInstance, b as SlotContext } from './api-CJrl4sLH.js';
2
- export { c as ApiClient, d as ApiClientOptions, e as ApiError, f as ApprovalRequest, g as AuthContext, h as AuthProvider, i as AuthState, P as ParsedExtensionManifest, j as Principal, k as SLOT_KINDS, l as SlotKind, T as TenantChangeEvent, m as TenantChangeListener, n as TenantContext, o as TenantProvider, p as TenantRef, q as TenantState, r as createTenantState, s as extensionManifestSchema, t as parseExtensionManifest, u as useAuth, v as usePrincipal, w as useTenant } from './api-CJrl4sLH.js';
1
+ import { E as ExtensionManifestInput, A as AnySlotContribution, I as InariExtension, S as SlotContribution, C as CatalogItem, a as Cluster, R as ResourceInstance, b as SlotContext } from './api-Br2Mnkqb.js';
2
+ export { c as ApiClient, d as ApiClientOptions, e as ApiError, f as ApprovalRequest, g as AuthContext, h as AuthProvider, i as AuthState, P as ParsedExtensionManifest, j as Principal, k as SLOT_KINDS, l as SlotKind, T as TenantChangeEvent, m as TenantChangeListener, n as TenantContext, o as TenantProvider, p as TenantRef, q as TenantState, r as createTenantState, s as extensionManifestSchema, t as getAuthState, u as parseExtensionManifest, v as useAuth, w as usePrincipal, x as useTenant } from './api-Br2Mnkqb.js';
3
3
  import { ComponentType } from 'react';
4
4
  import 'zod';
5
5
 
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  TenantProvider,
6
6
  createTenantState,
7
7
  useTenant
8
- } from "./chunk-OCKSMPCZ.js";
8
+ } from "./chunk-E5P565T6.js";
9
9
 
10
10
  // src/manifest.ts
11
11
  import { z } from "zod";
@@ -101,9 +101,14 @@ var PageBlueprint = (params) => ({
101
101
  // src/host/auth.ts
102
102
  import { createContext, createElement, useContext } from "react";
103
103
  var AuthContext = createContext(null);
104
+ var currentAuth = null;
104
105
  function AuthProvider(props) {
106
+ currentAuth = props.value;
105
107
  return createElement(AuthContext.Provider, { value: props.value }, props.children);
106
108
  }
109
+ function getAuthState() {
110
+ return currentAuth;
111
+ }
107
112
  function useAuth() {
108
113
  const ctx = useContext(AuthContext);
109
114
  if (!ctx) throw new Error("useAuth must be used within an AuthProvider");
@@ -129,6 +134,7 @@ export {
129
134
  createExtension,
130
135
  createTenantState,
131
136
  extensionManifestSchema,
137
+ getAuthState,
132
138
  parseExtensionManifest,
133
139
  useAuth,
134
140
  usePrincipal,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/manifest.ts","../src/extension.ts","../src/blueprints/types.ts","../src/blueprints/nav-item.ts","../src/blueprints/catalog-card.ts","../src/blueprints/cluster-tab.ts","../src/blueprints/instance-action.ts","../src/blueprints/form-widget.ts","../src/blueprints/page.ts","../src/host/auth.ts"],"sourcesContent":["import { z } from 'zod';\n\nconst nameSchema = z\n .string()\n .min(1)\n .regex(/^[a-z0-9][a-z0-9-]*$/, 'name must be kebab-case');\n\nconst slotContributionSchema = z.object({\n kind: z.enum([\n 'nav-item',\n 'catalog-card',\n 'cluster-tab',\n 'instance-action',\n 'form-widget',\n 'page',\n ]),\n name: nameSchema,\n});\n\nexport const extensionManifestSchema = z.object({\n name: nameSchema,\n version: z.string().min(1),\n kind: z.literal('ui'),\n title: z.string().optional(),\n description: z.string().optional(),\n slots: z.array(slotContributionSchema).min(1),\n});\n\nexport type ExtensionManifestInput = z.input<typeof extensionManifestSchema>;\nexport type ParsedExtensionManifest = z.output<typeof extensionManifestSchema>;\n\nexport function parseExtensionManifest(input: unknown): ParsedExtensionManifest {\n return extensionManifestSchema.parse(input);\n}\n","import type { ExtensionManifestInput } from './manifest';\nimport { parseExtensionManifest } from './manifest';\nimport type { AnySlotContribution, InariExtension } from './blueprints/types';\n\nexport interface CreateExtensionParams {\n manifest: Omit<ExtensionManifestInput, 'slots'>;\n slots: AnySlotContribution[];\n}\n\nexport function createExtension(params: CreateExtensionParams): InariExtension {\n const slotDescriptors = params.slots.map((s) => ({ kind: s.kind, name: s.name }));\n const manifest = parseExtensionManifest({ ...params.manifest, slots: slotDescriptors });\n return { manifest, slots: params.slots };\n}\n","import type { ComponentType } from 'react';\n\nexport const SLOT_KINDS = [\n 'nav-item',\n 'catalog-card',\n 'cluster-tab',\n 'instance-action',\n 'form-widget',\n 'page',\n] as const;\n\nexport type SlotKind = (typeof SLOT_KINDS)[number];\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport interface SlotContribution<K extends SlotKind = SlotKind, P = unknown, O = unknown> {\n readonly kind: K;\n readonly name: string;\n readonly props: P;\n readonly options?: O;\n readonly component?: ComponentType<any>;\n}\n\nexport type AnySlotContribution = SlotContribution<SlotKind, any, any>;\n\nexport interface InariExtension {\n readonly manifest: import('../manifest.js').ParsedExtensionManifest;\n readonly slots: readonly AnySlotContribution[];\n}\n\nexport interface SlotContext {\n auth: import('../host/auth.js').AuthState;\n tenant: import('../host/tenant.js').TenantState;\n}\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\n\nexport interface NavItemProps {\n title: string;\n path: string;\n icon?: ComponentType;\n}\n\nexport const NavItemBlueprint = (params: { name: string } & NavItemProps): SlotContribution<'nav-item', NavItemProps> => ({\n kind: 'nav-item',\n name: params.name,\n props: { title: params.title, path: params.path, icon: params.icon },\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\nimport type { CatalogItem } from '../host/api';\n\nexport interface CatalogCardSlotProps {\n catalogItem: CatalogItem;\n}\n\nexport const CatalogCardBlueprint = (params: {\n name: string;\n component: ComponentType<CatalogCardSlotProps>;\n}): SlotContribution<'catalog-card', CatalogCardSlotProps> => ({\n kind: 'catalog-card',\n name: params.name,\n props: {} as CatalogCardSlotProps,\n component: params.component,\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\nimport type { Cluster } from '../host/api';\n\nexport interface ClusterTabSlotProps {\n cluster: Cluster;\n}\n\nexport interface ClusterTabOptions {\n title: string;\n}\n\nexport const ClusterTabBlueprint = (params: {\n name: string;\n title: string;\n component: ComponentType<ClusterTabSlotProps>;\n}): SlotContribution<'cluster-tab', ClusterTabSlotProps, ClusterTabOptions> => ({\n kind: 'cluster-tab',\n name: params.name,\n props: {} as ClusterTabSlotProps,\n options: { title: params.title },\n component: params.component,\n});\n","import type { SlotContribution } from './types';\nimport type { ResourceInstance } from '../host/api';\n\nexport interface InstanceActionSlotProps {\n instance: ResourceInstance;\n}\n\nexport interface InstanceActionProps {\n label: string;\n run: (instance: ResourceInstance) => Promise<void> | void;\n}\n\nexport const InstanceActionBlueprint = (params: {\n name: string;\n label: string;\n run: (instance: ResourceInstance) => Promise<void> | void;\n}): SlotContribution<'instance-action', InstanceActionProps> => ({\n kind: 'instance-action',\n name: params.name,\n props: { label: params.label, run: params.run },\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\n\nexport interface FormWidgetSlotProps<T = unknown> {\n value: T | undefined;\n onChange: (value: T) => void;\n schema: Record<string, unknown>;\n disabled?: boolean;\n}\n\nexport const FormWidgetBlueprint = <T = unknown>(params: {\n name: string;\n component: ComponentType<FormWidgetSlotProps<T>>;\n schemaType?: string;\n}): SlotContribution<'form-widget', FormWidgetSlotProps<T>> => ({\n kind: 'form-widget',\n name: params.name,\n props: {} as FormWidgetSlotProps<T>,\n component: params.component as ComponentType<FormWidgetSlotProps<T>>,\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution, SlotContext } from './types';\n\nexport interface PageSlotProps {\n context: SlotContext;\n}\n\nexport interface PageOptions {\n path: string;\n title?: string;\n}\n\nexport const PageBlueprint = (params: {\n name: string;\n path: string;\n title?: string;\n component: ComponentType<PageSlotProps>;\n}): SlotContribution<'page', PageSlotProps, PageOptions> => ({\n kind: 'page',\n name: params.name,\n props: {} as PageSlotProps,\n options: { path: params.path, title: params.title },\n component: params.component,\n});\n","import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface Principal {\n subject: string;\n displayName: string;\n groups: string[];\n}\n\nexport interface AuthState {\n principal: Principal | null;\n getToken: () => Promise<string | undefined> | string | undefined;\n}\n\nexport const AuthContext = createContext<AuthState | null>(null);\n\nexport function AuthProvider(props: { value: AuthState; children: ReactNode }) {\n return createElement(AuthContext.Provider, { value: props.value }, props.children);\n}\n\nexport function useAuth(): AuthState {\n const ctx = useContext(AuthContext);\n if (!ctx) throw new Error('useAuth must be used within an AuthProvider');\n return ctx;\n}\n\nexport function usePrincipal(): Principal | null {\n return useAuth().principal;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,SAAS;AAElB,IAAM,aAAa,EAChB,OAAO,EACP,IAAI,CAAC,EACL,MAAM,wBAAwB,yBAAyB;AAE1D,IAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,MAAM,EAAE,KAAK;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAAA,EACD,MAAM;AACR,CAAC;AAEM,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,MAAM;AAAA,EACN,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACzB,MAAM,EAAE,QAAQ,IAAI;AAAA,EACpB,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,OAAO,EAAE,MAAM,sBAAsB,EAAE,IAAI,CAAC;AAC9C,CAAC;AAKM,SAAS,uBAAuB,OAAyC;A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S,EAAE,MAAM,OAAO,MAAM,OAAO,OAAO,MAAM;AAAA,EAClD,WAAW,OAAO;AACpB;;;ACvBA,SAAS,eAAe,eAAe,kBAAkC;AAalE,IAAM,cAAc,cAAgC,IAAI;AAExD,SAAS,aAAa,OAAkD;AAC7E,SAAO,cAAc,YAAY,UAAU,EAAE,OAAO,MAAM,MAAM,GAAG,MAAM,QAAQ;AACnF;AAEO,SAAS,UAAqB;AACnC,QAAM,MAAM,WAAW,WAAW;AAClC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,6CAA6C;AACvE,SAAO;AACT;AAEO,SAAS,eAAiC;AAC/C,SAAO,QAAQ,EAAE;AACnB;","names":[]}
1
+ {"version":3,"sources":["../src/manifest.ts","../src/extension.ts","../src/blueprints/types.ts","../src/blueprints/nav-item.ts","../src/blueprints/catalog-card.ts","../src/blueprints/cluster-tab.ts","../src/blueprints/instance-action.ts","../src/blueprints/form-widget.ts","../src/blueprints/page.ts","../src/host/auth.ts"],"sourcesContent":["import { z } from 'zod';\n\nconst nameSchema = z\n .string()\n .min(1)\n .regex(/^[a-z0-9][a-z0-9-]*$/, 'name must be kebab-case');\n\nconst slotContributionSchema = z.object({\n kind: z.enum([\n 'nav-item',\n 'catalog-card',\n 'cluster-tab',\n 'instance-action',\n 'form-widget',\n 'page',\n ]),\n name: nameSchema,\n});\n\nexport const extensionManifestSchema = z.object({\n name: nameSchema,\n version: z.string().min(1),\n kind: z.literal('ui'),\n title: z.string().optional(),\n description: z.string().optional(),\n slots: z.array(slotContributionSchema).min(1),\n});\n\nexport type ExtensionManifestInput = z.input<typeof extensionManifestSchema>;\nexport type ParsedExtensionManifest = z.output<typeof extensionManifestSchema>;\n\nexport function parseExtensionManifest(input: unknown): ParsedExtensionManifest {\n return extensionManifestSchema.parse(input);\n}\n","import type { ExtensionManifestInput } from './manifest';\nimport { parseExtensionManifest } from './manifest';\nimport type { AnySlotContribution, InariExtension } from './blueprints/types';\n\nexport interface CreateExtensionParams {\n manifest: Omit<ExtensionManifestInput, 'slots'>;\n slots: AnySlotContribution[];\n}\n\nexport function createExtension(params: CreateExtensionParams): InariExtension {\n const slotDescriptors = params.slots.map((s) => ({ kind: s.kind, name: s.name }));\n const manifest = parseExtensionManifest({ ...params.manifest, slots: slotDescriptors });\n return { manifest, slots: params.slots };\n}\n","import type { ComponentType } from 'react';\n\nexport const SLOT_KINDS = [\n 'nav-item',\n 'catalog-card',\n 'cluster-tab',\n 'instance-action',\n 'form-widget',\n 'page',\n] as const;\n\nexport type SlotKind = (typeof SLOT_KINDS)[number];\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport interface SlotContribution<K extends SlotKind = SlotKind, P = unknown, O = unknown> {\n readonly kind: K;\n readonly name: string;\n readonly props: P;\n readonly options?: O;\n readonly component?: ComponentType<any>;\n}\n\nexport type AnySlotContribution = SlotContribution<SlotKind, any, any>;\n\nexport interface InariExtension {\n readonly manifest: import('../manifest.js').ParsedExtensionManifest;\n readonly slots: readonly AnySlotContribution[];\n}\n\nexport interface SlotContext {\n auth: import('../host/auth.js').AuthState;\n tenant: import('../host/tenant.js').TenantState;\n}\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\n\nexport interface NavItemProps {\n title: string;\n path: string;\n icon?: ComponentType;\n}\n\nexport const NavItemBlueprint = (params: { name: string } & NavItemProps): SlotContribution<'nav-item', NavItemProps> => ({\n kind: 'nav-item',\n name: params.name,\n props: { title: params.title, path: params.path, icon: params.icon },\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\nimport type { CatalogItem } from '../host/api';\n\nexport interface CatalogCardSlotProps {\n catalogItem: CatalogItem;\n}\n\nexport const CatalogCardBlueprint = (params: {\n name: string;\n component: ComponentType<CatalogCardSlotProps>;\n}): SlotContribution<'catalog-card', CatalogCardSlotProps> => ({\n kind: 'catalog-card',\n name: params.name,\n props: {} as CatalogCardSlotProps,\n component: params.component,\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\nimport type { Cluster } from '../host/api';\n\nexport interface ClusterTabSlotProps {\n cluster: Cluster;\n}\n\nexport interface ClusterTabOptions {\n title: string;\n}\n\nexport const ClusterTabBlueprint = (params: {\n name: string;\n title: string;\n component: ComponentType<ClusterTabSlotProps>;\n}): SlotContribution<'cluster-tab', ClusterTabSlotProps, ClusterTabOptions> => ({\n kind: 'cluster-tab',\n name: params.name,\n props: {} as ClusterTabSlotProps,\n options: { title: params.title },\n component: params.component,\n});\n","import type { SlotContribution } from './types';\nimport type { ResourceInstance } from '../host/api';\n\nexport interface InstanceActionSlotProps {\n instance: ResourceInstance;\n}\n\nexport interface InstanceActionProps {\n label: string;\n run: (instance: ResourceInstance) => Promise<void> | void;\n}\n\nexport const InstanceActionBlueprint = (params: {\n name: string;\n label: string;\n run: (instance: ResourceInstance) => Promise<void> | void;\n}): SlotContribution<'instance-action', InstanceActionProps> => ({\n kind: 'instance-action',\n name: params.name,\n props: { label: params.label, run: params.run },\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution } from './types';\n\nexport interface FormWidgetSlotProps<T = unknown> {\n value: T | undefined;\n onChange: (value: T) => void;\n schema: Record<string, unknown>;\n disabled?: boolean;\n}\n\nexport const FormWidgetBlueprint = <T = unknown>(params: {\n name: string;\n component: ComponentType<FormWidgetSlotProps<T>>;\n schemaType?: string;\n}): SlotContribution<'form-widget', FormWidgetSlotProps<T>> => ({\n kind: 'form-widget',\n name: params.name,\n props: {} as FormWidgetSlotProps<T>,\n component: params.component as ComponentType<FormWidgetSlotProps<T>>,\n});\n","import type { ComponentType } from 'react';\nimport type { SlotContribution, SlotContext } from './types';\n\nexport interface PageSlotProps {\n context: SlotContext;\n}\n\nexport interface PageOptions {\n path: string;\n title?: string;\n}\n\nexport const PageBlueprint = (params: {\n name: string;\n path: string;\n title?: string;\n component: ComponentType<PageSlotProps>;\n}): SlotContribution<'page', PageSlotProps, PageOptions> => ({\n kind: 'page',\n name: params.name,\n props: {} as PageSlotProps,\n options: { path: params.path, title: params.title },\n component: params.component,\n});\n","import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface Principal {\n subject: string;\n displayName: string;\n groups: string[];\n}\n\nexport interface AuthState {\n principal: Principal | null;\n getToken: () => Promise<string | undefined> | string | undefined;\n}\n\nexport const AuthContext = createContext<AuthState | null>(null);\n\n// Module-level mirror of the active AuthState: remotes are host-provided\n// singleton consumers, and their non-component code paths (e.g. instance\n// action runners invoked from host menus) cannot call hooks.\nlet currentAuth: AuthState | null = null;\n\nexport function AuthProvider(props: { value: AuthState; children: ReactNode }) {\n currentAuth = props.value;\n return createElement(AuthContext.Provider, { value: props.value }, props.children);\n}\n\n/** getAuthState returns the active AuthState outside React (null before the\n * provider mounts). Prefer useAuth() inside components. */\nexport function getAuthState(): AuthState | null {\n return currentAuth;\n}\n\nexport function useAuth(): AuthState {\n const ctx = useContext(AuthContext);\n if (!ctx) throw new Error('useAuth must be used within an AuthProvider');\n return ctx;\n}\n\nexport function usePrincipal(): Principal | null {\n return useAuth().principal;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,SAAS;AAElB,IAAM,aAAa,EAChB,OAAO,EACP,IAAI,CAAC,EACL,MAAM,wBAAwB,yBAAyB;AAE1D,IAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,MAAM,EAAE,KAAK;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAAA,EACD,MAAM;AACR,CAAC;AAEM,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,MAAM;AAAA,EACN,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACzB,MAAM,EAAE,QAAQ,IAAI;AAAA,EACpB,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,OAAO,EAAE,MAAM,sBAAsB,EAAE,IAAI,CAAC;AAC9C,CAAC;AAKM,SAAS,uBAAuB,O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ACR,SAAS,EAAE,MAAM,OAAO,MAAM,OAAO,OAAO,MAAM;AAAA,EAClD,WAAW,OAAO;AACpB;;;ACvBA,SAAS,eAAe,eAAe,kBAAkC;AAalE,IAAM,cAAc,cAAgC,IAAI;AAK/D,IAAI,cAAgC;AAE7B,SAAS,aAAa,OAAkD;AAC7E,gBAAc,MAAM;AACpB,SAAO,cAAc,YAAY,UAAU,EAAE,OAAO,MAAM,MAAM,GAAG,MAAM,QAAQ;AACnF;AAIO,SAAS,eAAiC;AAC/C,SAAO;AACT;AAEO,SAAS,UAAqB;AACnC,QAAM,MAAM,WAAW,WAAW;AAClC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,6CAA6C;AACvE,SAAO;AACT;AAEO,SAAS,eAAiC;AAC/C,SAAO,QAAQ,EAAE;AACnB;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/testing/index.ts","../../src/host/tenant.ts","../../src/host/api.ts"],"sourcesContent":["import type { AuthState, Principal } from '../host/auth';\nimport { createTenantState, type TenantRef, type TenantState } from '../host/tenant';\nimport { ApiClient, type ApiClientOptions } from '../host/api';\nimport type { SlotContext } from '../blueprints/types';\n\nexport function mockPrincipal(overrides: Partial<Principal> = {}): Principal {\n return {\n subject: 'user:dev',\n displayName: 'Dev User',\n groups: ['tenant-acme/platform-team'],\n ...overrides,\n };\n}\n\nexport function mockAuthState(overrides: Partial<AuthState> = {}): AuthState {\n return {\n principal: mockPrincipal(),\n getToken: () => 'mock-token',\n ...overrides,\n };\n}\n\nexport function mockTenantState(tenants?: TenantRef[]): TenantState {\n return createTenantState(\n tenants ?? [\n { orgId: 'org:acme', orgName: 'Acme', team: 'platform-team' },\n { orgId: 'org:globex', orgName: 'Globex' },\n ],\n );\n}\n\nexport function mockApiClient(overrides: Partial<ApiClientOptions> = {}): ApiClient {\n return new ApiClient({\n baseUrl: 'http://mock-control-plane',\n getToken: () => 'mock-token',\n fetchImpl: async () => new Response('[]', { status: 200 }),\n ...overrides,\n });\n}\n\nexport function mockSlotContext(overrides: Partial<SlotContext> = {}): SlotContext {\n return {\n auth: mockAuthState(),\n tenant: mockTenantState(),\n ...overrides,\n };\n}\n","import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface TenantRef {\n orgId: string;\n orgName: string;\n team?: string;\n}\n\nexport interface TenantChangeEvent {\n previous: TenantRef | null;\n current: TenantRef;\n}\n\nexport type TenantChangeListener = (event: TenantChangeEvent) => void;\n\nexport interface TenantState {\n current: TenantRef | null;\n available: TenantRef[];\n switchTenant: (orgId: string, team?: string) => void;\n onTenantChange: (listener: TenantChangeListener) => () => void;\n}\n\nexport const TenantContext = createContext<TenantState | null>(null);\n\nexport function TenantProvider(props: { value: TenantState; children: ReactNode }) {\n return createElement(TenantContext.Provider, { value: props.value }, props.children);\n}\n\nexport function useTenant(): TenantState {\n const ctx = useContext(TenantContext);\n if (!ctx) throw new Error('useTenant must be used within a TenantProvider');\n return ctx;\n}\n\nexport function createTenantState(available: TenantRef[]): TenantState & { _listeners: Set<TenantChangeListener> } {\n const listeners = new Set<TenantChangeListener>();\n const state = {\n current: available[0] ?? null,\n available,\n _listeners: listeners,\n switchTenant(orgId: string, team?: string) {\n const next = available.find((t) => t.orgId === orgId && (team === undefined || t.team === team));\n if (!next) throw new Error(`unknown tenant: ${orgId}${team ? `/${team}` : ''}`);\n const previous = state.current;\n state.current = next;\n listeners.forEach((l) => l({ previous, current: next }));\n },\n onTenantChange(listener: TenantChangeListener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return state;\n}\n","export interface Cluster {\n id: string;\n name: string;\n tenantId: string;\n state: 'Pending' | 'Active' | 'Degraded' | 'Cordoned' | 'Decommissioned';\n kubernetesVersion?: string;\n labels?: Record<string, string>;\n}\n\nexport interface CatalogItem {\n id: string;\n name: string;\n source: 'discovered' | 'curated' | 'platform';\n version: string;\n description?: string;\n schema?: Record<string, unknown>;\n uiHints?: Record<string, unknown>;\n}\n\nexport interface ResourceInstance {\n id: string;\n catalogItemId: string;\n clusterId: string;\n cloudAccountId?: string;\n name: string;\n namespace?: string;\n health?: string;\n status?: Record<string, unknown>;\n ownerTeam?: string;\n}\n\nexport interface ApprovalRequest {\n id: string;\n action: string;\n requester: string;\n state: 'pending' | 'approved' | 'rejected';\n}\n\nexport interface ApiClientOptions {\n baseUrl: string;\n getToken: () => Promise<string | undefined> | string | undefined;\n fetchImpl?: typeof fetch;\n}\n\nexport class ApiError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport class ApiClient {\n private readonly baseUrl: string;\n private readonly getToken: ApiClientOptions['getToken'];\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: ApiClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '');\n this.getToken = options.getToken;\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const token = await this.getToken();\n const res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers: {\n 'content-type': 'application/json',\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n if (!res.ok) {\n throw new ApiError(res.status, `${method} ${path} failed: ${res.status}`);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n\n listClusters(): Promise<Cluster[]> {\n return this.request('GET', '/api/v1/clusters');\n }\n\n getCluster(id: string): Promise<Cluster> {\n return this.request('GET', `/api/v1/clusters/${encodeURIComponent(id)}`);\n }\n\n listCatalogItems(clusterId?: string): Promise<CatalogItem[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/catalog/items${q}`);\n }\n\n getCatalogItem(id: string): Promise<CatalogItem> {\n return this.request('GET', `/api/v1/catalog/items/${encodeURIComponent(id)}`);\n }\n\n listResourceInstances(clusterId?: string): Promise<ResourceInstance[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/resources${q}`);\n }\n\n getResourceInstance(id: string): Promise<ResourceInstance> {\n return this.request('GET', `/api/v1/resources/${encodeURIComponent(id)}`);\n }\n\n listApprovals(): Promise<ApprovalRequest[]> {\n return this.request('GET', '/api/v1/approvals');\n }\n\n approveApproval(id: string): Promise<ApprovalRequest> {\n return this.request('POST', `/api/v1/approvals/${encodeURIComponent(id)}/approve`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyE;AAsBlE,IAAM,oBAAgB,4BAAkC,IAAI;AAY5D,SAAS,kBAAkB,WAAiF;AACjH,QAAM,YAAY,oBAAI,IAA0B;AAChD,QAAM,QAAQ;AAAA,IACZ,SAAS,UAAU,CAAC,KAAK;AAAA,IACzB;AAAA,IACA,YAAY;AAAA,IACZ,aAAa,OAAe,MAAe;AACzC,YAAM,OAAO,UAAU,KAAK,CAAC,MAAM,EAAE,UAAU,UAAU,SAAS,UAAa,EAAE,SAAS,KAAK;AAC/F,UAAI,CAAC,KAAM,OAAM,IAAI,MAAM,mBAAmB,KAAK,GAAG,OAAO,IAAI,IAAI,KAAK,EAAE,EAAE;AAC9E,YAAM,WAAW,MAAM;AACvB,YAAM,UAAU;AAChB,gBAAU,QAAQ,CAAC,MAAM,EAAE,EAAE,UAAU,SAAS,KAAK,CAAC,CAAC;AAAA,IACzD;AAAA,IACA,eAAe,UAAgC;AAC7C,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM,UAAU,OAAO,QAAQ;AAAA,IACxC;AAAA,EACF;AACA,SAAO;AACT;;;ACTO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACkB,QAChB,SACA;AACA,UAAM,OAAO;AAHG;AAIhB,SAAK,OAAO;AAAA,EACd;AAAA,EALkB;AAMpB;AAEO,IAAM,YAAN,MAAgB;AAAA,EACJ;AAAA,EACA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../src/host/api.ts"],"sourcesContent":["import type { AuthState, Principal } from '../host/auth';\nimport { createTenantState, type TenantRef, type TenantState } from '../host/tenant';\nimport { ApiClient, type ApiClientOptions } from '../host/api';\nimport type { SlotContext } from '../blueprints/types';\n\nexport function mockPrincipal(overrides: Partial<Principal> = {}): Principal {\n return {\n subject: 'user:dev',\n displayName: 'Dev User',\n groups: ['tenant-acme/platform-team'],\n ...overrides,\n };\n}\n\nexport function mockAuthState(overrides: Partial<AuthState> = {}): AuthState {\n return {\n principal: mockPrincipal(),\n getToken: () => 'mock-token',\n ...overrides,\n };\n}\n\nexport function mockTenantState(tenants?: TenantRef[]): TenantState {\n return createTenantState(\n tenants ?? [\n { orgId: 'org:acme', orgName: 'Acme', team: 'platform-team' },\n { orgId: 'org:globex', orgName: 'Globex' },\n ],\n );\n}\n\nexport function mockApiClient(overrides: Partial<ApiClientOptions> = {}): ApiClient {\n return new ApiClient({\n baseUrl: 'http://mock-control-plane',\n getToken: () => 'mock-token',\n fetchImpl: async () => new Response('[]', { status: 200 }),\n ...overrides,\n });\n}\n\nexport function mockSlotContext(overrides: Partial<SlotContext> = {}): SlotContext {\n return {\n auth: mockAuthState(),\n tenant: mockTenantState(),\n ...overrides,\n };\n}\n","import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface TenantRef {\n orgId: string;\n orgName: string;\n team?: string;\n}\n\nexport interface TenantChangeEvent {\n previous: TenantRef | null;\n current: TenantRef;\n}\n\nexport type TenantChangeListener = (event: TenantChangeEvent) => void;\n\nexport interface TenantState {\n current: TenantRef | null;\n available: TenantRef[];\n switchTenant: (orgId: string, team?: string) => void;\n onTenantChange: (listener: TenantChangeListener) => () => void;\n}\n\nexport const TenantContext = createContext<TenantState | null>(null);\n\nexport function TenantProvider(props: { value: TenantState; children: ReactNode }) {\n return createElement(TenantContext.Provider, { value: props.value }, props.children);\n}\n\nexport function useTenant(): TenantState {\n const ctx = useContext(TenantContext);\n if (!ctx) throw new Error('useTenant must be used within a TenantProvider');\n return ctx;\n}\n\nexport function createTenantState(available: TenantRef[]): TenantState & { _listeners: Set<TenantChangeListener> } {\n const listeners = new Set<TenantChangeListener>();\n const state = {\n current: available[0] ?? null,\n available,\n _listeners: listeners,\n switchTenant(orgId: string, team?: string) {\n const next = available.find((t) => t.orgId === orgId && (team === undefined || t.team === team));\n if (!next) throw new Error(`unknown tenant: ${orgId}${team ? `/${team}` : ''}`);\n const previous = state.current;\n state.current = next;\n listeners.forEach((l) => l({ previous, current: next }));\n },\n onTenantChange(listener: TenantChangeListener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return state;\n}\n","export interface Cluster {\n id: string;\n name: string;\n tenantId: string;\n state: 'Pending' | 'Active' | 'Degraded' | 'Cordoned' | 'Decommissioned';\n kubernetesVersion?: string;\n labels?: Record<string, string>;\n}\n\nexport interface CatalogItem {\n id: string;\n name: string;\n source: 'discovered' | 'curated' | 'platform' | 'template';\n version: string;\n description?: string;\n schema?: Record<string, unknown>;\n uiHints?: Record<string, unknown>;\n}\n\nexport interface ResourceInstance {\n id: string;\n catalogItemId: string;\n clusterId: string;\n cloudAccountId?: string;\n name: string;\n namespace?: string;\n health?: string;\n status?: Record<string, unknown>;\n ownerTeam?: string;\n}\n\nexport interface ApprovalRequest {\n id: string;\n action: string;\n requester: string;\n state: 'pending' | 'approved' | 'rejected';\n}\n\nexport interface ApiClientOptions {\n baseUrl: string;\n getToken: () => Promise<string | undefined> | string | undefined;\n fetchImpl?: typeof fetch;\n}\n\nexport class ApiError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport class ApiClient {\n private readonly baseUrl: string;\n private readonly getToken: ApiClientOptions['getToken'];\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: ApiClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '');\n this.getToken = options.getToken;\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const token = await this.getToken();\n const res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers: {\n 'content-type': 'application/json',\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n if (!res.ok) {\n throw new ApiError(res.status, `${method} ${path} failed: ${res.status}`);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n\n listClusters(): Promise<Cluster[]> {\n return this.request('GET', '/api/v1/clusters');\n }\n\n getCluster(id: string): Promise<Cluster> {\n return this.request('GET', `/api/v1/clusters/${encodeURIComponent(id)}`);\n }\n\n listCatalogItems(clusterId?: string): Promise<CatalogItem[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/catalog/items${q}`);\n }\n\n getCatalogItem(id: string): Promise<CatalogItem> {\n return this.request('GET', `/api/v1/catalog/items/${encodeURIComponent(id)}`);\n }\n\n listResourceInstances(clusterId?: string): Promise<ResourceInstance[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/resources${q}`);\n }\n\n getResourceInstance(id: string): Promise<ResourceInstance> {\n return this.request('GET', `/api/v1/resources/${encodeURIComponent(id)}`);\n }\n\n listApprovals(): Promise<ApprovalRequest[]> {\n return this.request('GET', '/api/v1/approvals');\n }\n\n approveApproval(id: string): Promise<ApprovalRequest> {\n return this.request('POST', `/api/v1/approvals/${encodeURIComponent(id)}/approve`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyE;AAsBlE,IAAM,oBAAgB,4BAAkC,IAAI;AAY5D,SAAS,kBAAkB,WAAiF;AACjH,QAAM,YAAY,oBAAI,IAA0B;AAChD,QAAM,QAAQ;AAAA,IACZ,SAAS,UAAU,CAAC,KAAK;AAAA,IACzB;AAAA,IACA,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,IACL,WAAW,cAAc;AAAA,IACzB,UAAU,MAAM;AAAA,IAChB,GAAG;AAAA,EACL;AACF;AAEO,SAAS,gBAAgB,SAAoC;AAClE,SAAO;AAAA,IACL,WAAW;AAAA,MACT,EAAE,OAAO,YAAY,SAAS,QAAQ,MAAM,gBAAgB;AAAA,MAC5D,EAAE,OAAO,cAAc,SAAS,SAAS;AAAA,IAC3C;AAAA,EACF;AACF;AAEO,SAAS,cAAc,YAAuC,CAAC,GAAc;AAClF,SAAO,IAAI,UAAU;AAAA,IACnB,SAAS;AAAA,IACT,UAAU,MAAM;AAAA,IAChB,WAAW,YAAY,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AAAA,IACzD,GAAG;AAAA,EACL,CAAC;AACH;AAEO,SAAS,gBAAgB,YAAkC,CAAC,GAAgB;AACjF,SAAO;AAAA,IACL,MAAM,cAAc;AAAA,IACpB,QAAQ,gBAAgB;AAAA,IACxB,GAAG;AAAA,EACL;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import { d as ApiClientOptions, c as ApiClient, i as AuthState, j as Principal, b as SlotContext, p as TenantRef, q as TenantState } from '../api-CJrl4sLH.cjs';
1
+ import { d as ApiClientOptions, c as ApiClient, i as AuthState, j as Principal, b as SlotContext, p as TenantRef, q as TenantState } from '../api-Br2Mnkqb.cjs';
2
2
  import 'react';
3
3
  import 'zod';
4
4
 
@@ -1,4 +1,4 @@
1
- import { d as ApiClientOptions, c as ApiClient, i as AuthState, j as Principal, b as SlotContext, p as TenantRef, q as TenantState } from '../api-CJrl4sLH.js';
1
+ import { d as ApiClientOptions, c as ApiClient, i as AuthState, j as Principal, b as SlotContext, p as TenantRef, q as TenantState } from '../api-Br2Mnkqb.js';
2
2
  import 'react';
3
3
  import 'zod';
4
4
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ApiClient,
3
3
  createTenantState
4
- } from "../chunk-OCKSMPCZ.js";
4
+ } from "../chunk-E5P565T6.js";
5
5
 
6
6
  // src/testing/index.ts
7
7
  function mockPrincipal(overrides = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7k-inari/ui-plugin-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.6",
4
4
  "description": "TypeScript SDK for Inari UI extensions: extension-point blueprints, host APIs, dev harness",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -76,5 +76,9 @@
76
76
  "vite": "^5.4.21",
77
77
  "vitest": "^2.1.3",
78
78
  "zod": "^3.23.8"
79
+ },
80
+ "repository": {
81
+ "type": "git",
82
+ "url": "https://github.com/7K-Inari/inari-ui-plugin-sdk"
79
83
  }
80
84
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/host/tenant.ts","../src/host/api.ts"],"sourcesContent":["import { createContext, createElement, useContext, type ReactNode } from 'react';\n\nexport interface TenantRef {\n orgId: string;\n orgName: string;\n team?: string;\n}\n\nexport interface TenantChangeEvent {\n previous: TenantRef | null;\n current: TenantRef;\n}\n\nexport type TenantChangeListener = (event: TenantChangeEvent) => void;\n\nexport interface TenantState {\n current: TenantRef | null;\n available: TenantRef[];\n switchTenant: (orgId: string, team?: string) => void;\n onTenantChange: (listener: TenantChangeListener) => () => void;\n}\n\nexport const TenantContext = createContext<TenantState | null>(null);\n\nexport function TenantProvider(props: { value: TenantState; children: ReactNode }) {\n return createElement(TenantContext.Provider, { value: props.value }, props.children);\n}\n\nexport function useTenant(): TenantState {\n const ctx = useContext(TenantContext);\n if (!ctx) throw new Error('useTenant must be used within a TenantProvider');\n return ctx;\n}\n\nexport function createTenantState(available: TenantRef[]): TenantState & { _listeners: Set<TenantChangeListener> } {\n const listeners = new Set<TenantChangeListener>();\n const state = {\n current: available[0] ?? null,\n available,\n _listeners: listeners,\n switchTenant(orgId: string, team?: string) {\n const next = available.find((t) => t.orgId === orgId && (team === undefined || t.team === team));\n if (!next) throw new Error(`unknown tenant: ${orgId}${team ? `/${team}` : ''}`);\n const previous = state.current;\n state.current = next;\n listeners.forEach((l) => l({ previous, current: next }));\n },\n onTenantChange(listener: TenantChangeListener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return state;\n}\n","export interface Cluster {\n id: string;\n name: string;\n tenantId: string;\n state: 'Pending' | 'Active' | 'Degraded' | 'Cordoned' | 'Decommissioned';\n kubernetesVersion?: string;\n labels?: Record<string, string>;\n}\n\nexport interface CatalogItem {\n id: string;\n name: string;\n source: 'discovered' | 'curated' | 'platform';\n version: string;\n description?: string;\n schema?: Record<string, unknown>;\n uiHints?: Record<string, unknown>;\n}\n\nexport interface ResourceInstance {\n id: string;\n catalogItemId: string;\n clusterId: string;\n cloudAccountId?: string;\n name: string;\n namespace?: string;\n health?: string;\n status?: Record<string, unknown>;\n ownerTeam?: string;\n}\n\nexport interface ApprovalRequest {\n id: string;\n action: string;\n requester: string;\n state: 'pending' | 'approved' | 'rejected';\n}\n\nexport interface ApiClientOptions {\n baseUrl: string;\n getToken: () => Promise<string | undefined> | string | undefined;\n fetchImpl?: typeof fetch;\n}\n\nexport class ApiError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport class ApiClient {\n private readonly baseUrl: string;\n private readonly getToken: ApiClientOptions['getToken'];\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: ApiClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '');\n this.getToken = options.getToken;\n this.fetchImpl = options.fetchImpl ?? fetch;\n }\n\n private async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const token = await this.getToken();\n const res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers: {\n 'content-type': 'application/json',\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n });\n if (!res.ok) {\n throw new ApiError(res.status, `${method} ${path} failed: ${res.status}`);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n\n listClusters(): Promise<Cluster[]> {\n return this.request('GET', '/api/v1/clusters');\n }\n\n getCluster(id: string): Promise<Cluster> {\n return this.request('GET', `/api/v1/clusters/${encodeURIComponent(id)}`);\n }\n\n listCatalogItems(clusterId?: string): Promise<CatalogItem[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/catalog/items${q}`);\n }\n\n getCatalogItem(id: string): Promise<CatalogItem> {\n return this.request('GET', `/api/v1/catalog/items/${encodeURIComponent(id)}`);\n }\n\n listResourceInstances(clusterId?: string): Promise<ResourceInstance[]> {\n const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : '';\n return this.request('GET', `/api/v1/resources${q}`);\n }\n\n getResourceInstance(id: string): Promise<ResourceInstance> {\n return this.request('GET', `/api/v1/resources/${encodeURIComponent(id)}`);\n }\n\n listApprovals(): Promise<ApprovalRequest[]> {\n return this.request('GET', '/api/v1/approvals');\n }\n\n approveApproval(id: string): Promise<ApprovalRequest> {\n return this.request('POST', `/api/v1/approvals/${encodeURIComponent(id)}/approve`);\n }\n}\n"],"mappings":";AAAA,SAAS,eAAe,eAAe,kBAAkC;AAsBlE,IAAM,gBAAgB,cAAkC,IAAI;AAE5D,SAAS,eAAe,OAAoD;AACjF,SAAO,cAAc,cAAc,UAAU,EAAE,OAAO,MAAM,MAAM,GAAG,MAAM,QAAQ;AACrF;AAEO,SAAS,YAAyB;AACvC,QAAM,MAAM,WAAW,aAAa;AACpC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,gDAAgD;AAC1E,SAAO;AACT;AAEO,SAAS,kBAAkB,WAAiF;AACjH,QAAM,YAAY,oBAAI,IAA0B;AAChD,QAAM,QAAQ;AAAA,IACZ,SAAS,UAAU,CAAC,KAAK;AAAA,IACzB;AAAA,IACA,YAAY;AAAA,IACZ,aAAa,OAAe,MAAe;AACzC,YAAM,OAAO,UAAU,KAAK,CAAC,MAAM,EAAE,UAAU,UAAU,SAAS,UAAa,EAAE,SAAS,K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