@7k-inari/ui-plugin-sdk 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/bin/create-inari-ui-extension.mjs +10 -0
- package/bin/inari-ui-ext.mjs +38 -0
- package/dist/api-CJrl4sLH.d.cts +167 -0
- package/dist/api-CJrl4sLH.d.ts +167 -0
- package/dist/chunk-OCKSMPCZ.js +103 -0
- package/dist/chunk-OCKSMPCZ.js.map +1 -0
- package/dist/harness/index.cjs +197 -0
- package/dist/harness/index.cjs.map +1 -0
- package/dist/harness/index.d.cts +32 -0
- package/dist/harness/index.d.ts +32 -0
- package/dist/harness/index.js +169 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/index.cjs +268 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +80 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.js +137 -0
- package/dist/index.js.map +1 -0
- package/dist/testing/index.cjs +164 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +11 -0
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.js +52 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tokens/index.cjs +60 -0
- package/dist/tokens/index.cjs.map +1 -0
- package/dist/tokens/index.d.cts +41 -0
- package/dist/tokens/index.d.ts +41 -0
- package/dist/tokens/index.js +35 -0
- package/dist/tokens/index.js.map +1 -0
- package/harness/shell/index.html +12 -0
- package/harness/shell/main.tsx +222 -0
- package/harness/shell/vite.config.ts +6 -0
- package/package.json +80 -0
- package/src/tokens/tokens.css +26 -0
- package/templates/extension/package.json +21 -0
- package/templates/extension/src/index.tsx +29 -0
- package/templates/extension/tsconfig.json +12 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/testing/index.ts
|
|
21
|
+
var testing_exports = {};
|
|
22
|
+
__export(testing_exports, {
|
|
23
|
+
mockApiClient: () => mockApiClient,
|
|
24
|
+
mockAuthState: () => mockAuthState,
|
|
25
|
+
mockPrincipal: () => mockPrincipal,
|
|
26
|
+
mockSlotContext: () => mockSlotContext,
|
|
27
|
+
mockTenantState: () => mockTenantState
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(testing_exports);
|
|
30
|
+
|
|
31
|
+
// src/host/tenant.ts
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var TenantContext = (0, import_react.createContext)(null);
|
|
34
|
+
function createTenantState(available) {
|
|
35
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
36
|
+
const state = {
|
|
37
|
+
current: available[0] ?? null,
|
|
38
|
+
available,
|
|
39
|
+
_listeners: listeners,
|
|
40
|
+
switchTenant(orgId, team) {
|
|
41
|
+
const next = available.find((t) => t.orgId === orgId && (team === void 0 || t.team === team));
|
|
42
|
+
if (!next) throw new Error(`unknown tenant: ${orgId}${team ? `/${team}` : ""}`);
|
|
43
|
+
const previous = state.current;
|
|
44
|
+
state.current = next;
|
|
45
|
+
listeners.forEach((l) => l({ previous, current: next }));
|
|
46
|
+
},
|
|
47
|
+
onTenantChange(listener) {
|
|
48
|
+
listeners.add(listener);
|
|
49
|
+
return () => listeners.delete(listener);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return state;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/host/api.ts
|
|
56
|
+
var ApiError = class extends Error {
|
|
57
|
+
constructor(status, message) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.status = status;
|
|
60
|
+
this.name = "ApiError";
|
|
61
|
+
}
|
|
62
|
+
status;
|
|
63
|
+
};
|
|
64
|
+
var ApiClient = class {
|
|
65
|
+
baseUrl;
|
|
66
|
+
getToken;
|
|
67
|
+
fetchImpl;
|
|
68
|
+
constructor(options) {
|
|
69
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
70
|
+
this.getToken = options.getToken;
|
|
71
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
72
|
+
}
|
|
73
|
+
async request(method, path, body) {
|
|
74
|
+
const token = await this.getToken();
|
|
75
|
+
const res = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
76
|
+
method,
|
|
77
|
+
headers: {
|
|
78
|
+
"content-type": "application/json",
|
|
79
|
+
...token ? { authorization: `Bearer ${token}` } : {}
|
|
80
|
+
},
|
|
81
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
82
|
+
});
|
|
83
|
+
if (!res.ok) {
|
|
84
|
+
throw new ApiError(res.status, `${method} ${path} failed: ${res.status}`);
|
|
85
|
+
}
|
|
86
|
+
if (res.status === 204) return void 0;
|
|
87
|
+
return await res.json();
|
|
88
|
+
}
|
|
89
|
+
listClusters() {
|
|
90
|
+
return this.request("GET", "/api/v1/clusters");
|
|
91
|
+
}
|
|
92
|
+
getCluster(id) {
|
|
93
|
+
return this.request("GET", `/api/v1/clusters/${encodeURIComponent(id)}`);
|
|
94
|
+
}
|
|
95
|
+
listCatalogItems(clusterId) {
|
|
96
|
+
const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : "";
|
|
97
|
+
return this.request("GET", `/api/v1/catalog/items${q}`);
|
|
98
|
+
}
|
|
99
|
+
getCatalogItem(id) {
|
|
100
|
+
return this.request("GET", `/api/v1/catalog/items/${encodeURIComponent(id)}`);
|
|
101
|
+
}
|
|
102
|
+
listResourceInstances(clusterId) {
|
|
103
|
+
const q = clusterId ? `?clusterId=${encodeURIComponent(clusterId)}` : "";
|
|
104
|
+
return this.request("GET", `/api/v1/resources${q}`);
|
|
105
|
+
}
|
|
106
|
+
getResourceInstance(id) {
|
|
107
|
+
return this.request("GET", `/api/v1/resources/${encodeURIComponent(id)}`);
|
|
108
|
+
}
|
|
109
|
+
listApprovals() {
|
|
110
|
+
return this.request("GET", "/api/v1/approvals");
|
|
111
|
+
}
|
|
112
|
+
approveApproval(id) {
|
|
113
|
+
return this.request("POST", `/api/v1/approvals/${encodeURIComponent(id)}/approve`);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/testing/index.ts
|
|
118
|
+
function mockPrincipal(overrides = {}) {
|
|
119
|
+
return {
|
|
120
|
+
subject: "user:dev",
|
|
121
|
+
displayName: "Dev User",
|
|
122
|
+
groups: ["tenant-acme/platform-team"],
|
|
123
|
+
...overrides
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function mockAuthState(overrides = {}) {
|
|
127
|
+
return {
|
|
128
|
+
principal: mockPrincipal(),
|
|
129
|
+
getToken: () => "mock-token",
|
|
130
|
+
...overrides
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function mockTenantState(tenants) {
|
|
134
|
+
return createTenantState(
|
|
135
|
+
tenants ?? [
|
|
136
|
+
{ orgId: "org:acme", orgName: "Acme", team: "platform-team" },
|
|
137
|
+
{ orgId: "org:globex", orgName: "Globex" }
|
|
138
|
+
]
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
function mockApiClient(overrides = {}) {
|
|
142
|
+
return new ApiClient({
|
|
143
|
+
baseUrl: "http://mock-control-plane",
|
|
144
|
+
getToken: () => "mock-token",
|
|
145
|
+
fetchImpl: async () => new Response("[]", { status: 200 }),
|
|
146
|
+
...overrides
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function mockSlotContext(overrides = {}) {
|
|
150
|
+
return {
|
|
151
|
+
auth: mockAuthState(),
|
|
152
|
+
tenant: mockTenantState(),
|
|
153
|
+
...overrides
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
157
|
+
0 && (module.exports = {
|
|
158
|
+
mockApiClient,
|
|
159
|
+
mockAuthState,
|
|
160
|
+
mockPrincipal,
|
|
161
|
+
mockSlotContext,
|
|
162
|
+
mockTenantState
|
|
163
|
+
});
|
|
164
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +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;AAA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AAAA,EACL;AACF;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
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';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
declare function mockPrincipal(overrides?: Partial<Principal>): Principal;
|
|
6
|
+
declare function mockAuthState(overrides?: Partial<AuthState>): AuthState;
|
|
7
|
+
declare function mockTenantState(tenants?: TenantRef[]): TenantState;
|
|
8
|
+
declare function mockApiClient(overrides?: Partial<ApiClientOptions>): ApiClient;
|
|
9
|
+
declare function mockSlotContext(overrides?: Partial<SlotContext>): SlotContext;
|
|
10
|
+
|
|
11
|
+
export { mockApiClient, mockAuthState, mockPrincipal, mockSlotContext, mockTenantState };
|
|
@@ -0,0 +1,11 @@
|
|
|
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';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
declare function mockPrincipal(overrides?: Partial<Principal>): Principal;
|
|
6
|
+
declare function mockAuthState(overrides?: Partial<AuthState>): AuthState;
|
|
7
|
+
declare function mockTenantState(tenants?: TenantRef[]): TenantState;
|
|
8
|
+
declare function mockApiClient(overrides?: Partial<ApiClientOptions>): ApiClient;
|
|
9
|
+
declare function mockSlotContext(overrides?: Partial<SlotContext>): SlotContext;
|
|
10
|
+
|
|
11
|
+
export { mockApiClient, mockAuthState, mockPrincipal, mockSlotContext, mockTenantState };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiClient,
|
|
3
|
+
createTenantState
|
|
4
|
+
} from "../chunk-OCKSMPCZ.js";
|
|
5
|
+
|
|
6
|
+
// src/testing/index.ts
|
|
7
|
+
function mockPrincipal(overrides = {}) {
|
|
8
|
+
return {
|
|
9
|
+
subject: "user:dev",
|
|
10
|
+
displayName: "Dev User",
|
|
11
|
+
groups: ["tenant-acme/platform-team"],
|
|
12
|
+
...overrides
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function mockAuthState(overrides = {}) {
|
|
16
|
+
return {
|
|
17
|
+
principal: mockPrincipal(),
|
|
18
|
+
getToken: () => "mock-token",
|
|
19
|
+
...overrides
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function mockTenantState(tenants) {
|
|
23
|
+
return createTenantState(
|
|
24
|
+
tenants ?? [
|
|
25
|
+
{ orgId: "org:acme", orgName: "Acme", team: "platform-team" },
|
|
26
|
+
{ orgId: "org:globex", orgName: "Globex" }
|
|
27
|
+
]
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function mockApiClient(overrides = {}) {
|
|
31
|
+
return new ApiClient({
|
|
32
|
+
baseUrl: "http://mock-control-plane",
|
|
33
|
+
getToken: () => "mock-token",
|
|
34
|
+
fetchImpl: async () => new Response("[]", { status: 200 }),
|
|
35
|
+
...overrides
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function mockSlotContext(overrides = {}) {
|
|
39
|
+
return {
|
|
40
|
+
auth: mockAuthState(),
|
|
41
|
+
tenant: mockTenantState(),
|
|
42
|
+
...overrides
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
mockApiClient,
|
|
47
|
+
mockAuthState,
|
|
48
|
+
mockPrincipal,
|
|
49
|
+
mockSlotContext,
|
|
50
|
+
mockTenantState
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/testing/index.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"],"mappings":";;;;;;AAKO,SAAS,cAAc,YAAgC,CAAC,GAAc;AAC3E,SAAO;AAAA,IACL,SAAS;AAAA,IACT,aAAa;AAAA,IACb,QAAQ,CAAC,2BAA2B;AAAA,IACpC,GAAG;AAAA,EACL;AACF;AAEO,SAAS,cAAc,YAAgC,CAAC,GAAc;AAC3E,SAAO;AAAA,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":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/tokens/index.ts
|
|
21
|
+
var tokens_exports = {};
|
|
22
|
+
__export(tokens_exports, {
|
|
23
|
+
default: () => tokens_default,
|
|
24
|
+
tokens: () => tokens
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(tokens_exports);
|
|
27
|
+
var tokens = {
|
|
28
|
+
color: {
|
|
29
|
+
background: "#faf9f7",
|
|
30
|
+
foreground: "#1c1917",
|
|
31
|
+
primary: "#c2410c",
|
|
32
|
+
primaryForeground: "#fff7ed",
|
|
33
|
+
muted: "#e7e5e4",
|
|
34
|
+
mutedForeground: "#57534e",
|
|
35
|
+
border: "#d6d3d1",
|
|
36
|
+
destructive: "#b91c1c",
|
|
37
|
+
dark: {
|
|
38
|
+
background: "#1c1917",
|
|
39
|
+
foreground: "#fafaf9",
|
|
40
|
+
primary: "#ea580c",
|
|
41
|
+
primaryForeground: "#fff7ed",
|
|
42
|
+
muted: "#292524",
|
|
43
|
+
mutedForeground: "#a8a29e",
|
|
44
|
+
border: "#44403c",
|
|
45
|
+
destructive: "#ef4444"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
spacing: { xs: "0.25rem", sm: "0.5rem", md: "1rem", lg: "1.5rem", xl: "2rem" },
|
|
49
|
+
radius: { sm: "0.25rem", md: "0.5rem", lg: "0.75rem" },
|
|
50
|
+
font: {
|
|
51
|
+
family: "ui-sans-serif, system-ui, sans-serif",
|
|
52
|
+
mono: "ui-monospace, SFMono-Regular, monospace"
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var tokens_default = tokens;
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
tokens
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/tokens/index.ts"],"sourcesContent":["export const tokens = {\n color: {\n background: '#faf9f7',\n foreground: '#1c1917',\n primary: '#c2410c',\n primaryForeground: '#fff7ed',\n muted: '#e7e5e4',\n mutedForeground: '#57534e',\n border: '#d6d3d1',\n destructive: '#b91c1c',\n dark: {\n background: '#1c1917',\n foreground: '#fafaf9',\n primary: '#ea580c',\n primaryForeground: '#fff7ed',\n muted: '#292524',\n mutedForeground: '#a8a29e',\n border: '#44403c',\n destructive: '#ef4444',\n },\n },\n spacing: { xs: '0.25rem', sm: '0.5rem', md: '1rem', lg: '1.5rem', xl: '2rem' },\n radius: { sm: '0.25rem', md: '0.5rem', lg: '0.75rem' },\n font: {\n family: 'ui-sans-serif, system-ui, sans-serif',\n mono: 'ui-monospace, SFMono-Regular, monospace',\n },\n} as const;\n\nexport type Tokens = typeof tokens;\nexport default tokens;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,SAAS;AAAA,EACpB,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,mBAAmB;AAAA,IACnB,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,MAAM;AAAA,MACJ,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,mBAAmB;AAAA,MACnB,OAAO;AAAA,MACP,iBAAiB;AAAA,MACjB,QAAQ;AAAA,MACR,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,SAAS,EAAE,IAAI,WAAW,IAAI,UAAU,IAAI,QAAQ,IAAI,UAAU,IAAI,OAAO;AAAA,EAC7E,QAAQ,EAAE,IAAI,WAAW,IAAI,UAAU,IAAI,UAAU;AAAA,EACrD,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AACF;AAGA,IAAO,iBAAQ;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const tokens: {
|
|
2
|
+
readonly color: {
|
|
3
|
+
readonly background: "#faf9f7";
|
|
4
|
+
readonly foreground: "#1c1917";
|
|
5
|
+
readonly primary: "#c2410c";
|
|
6
|
+
readonly primaryForeground: "#fff7ed";
|
|
7
|
+
readonly muted: "#e7e5e4";
|
|
8
|
+
readonly mutedForeground: "#57534e";
|
|
9
|
+
readonly border: "#d6d3d1";
|
|
10
|
+
readonly destructive: "#b91c1c";
|
|
11
|
+
readonly dark: {
|
|
12
|
+
readonly background: "#1c1917";
|
|
13
|
+
readonly foreground: "#fafaf9";
|
|
14
|
+
readonly primary: "#ea580c";
|
|
15
|
+
readonly primaryForeground: "#fff7ed";
|
|
16
|
+
readonly muted: "#292524";
|
|
17
|
+
readonly mutedForeground: "#a8a29e";
|
|
18
|
+
readonly border: "#44403c";
|
|
19
|
+
readonly destructive: "#ef4444";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
readonly spacing: {
|
|
23
|
+
readonly xs: "0.25rem";
|
|
24
|
+
readonly sm: "0.5rem";
|
|
25
|
+
readonly md: "1rem";
|
|
26
|
+
readonly lg: "1.5rem";
|
|
27
|
+
readonly xl: "2rem";
|
|
28
|
+
};
|
|
29
|
+
readonly radius: {
|
|
30
|
+
readonly sm: "0.25rem";
|
|
31
|
+
readonly md: "0.5rem";
|
|
32
|
+
readonly lg: "0.75rem";
|
|
33
|
+
};
|
|
34
|
+
readonly font: {
|
|
35
|
+
readonly family: "ui-sans-serif, system-ui, sans-serif";
|
|
36
|
+
readonly mono: "ui-monospace, SFMono-Regular, monospace";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type Tokens = typeof tokens;
|
|
40
|
+
|
|
41
|
+
export { type Tokens, tokens as default, tokens };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const tokens: {
|
|
2
|
+
readonly color: {
|
|
3
|
+
readonly background: "#faf9f7";
|
|
4
|
+
readonly foreground: "#1c1917";
|
|
5
|
+
readonly primary: "#c2410c";
|
|
6
|
+
readonly primaryForeground: "#fff7ed";
|
|
7
|
+
readonly muted: "#e7e5e4";
|
|
8
|
+
readonly mutedForeground: "#57534e";
|
|
9
|
+
readonly border: "#d6d3d1";
|
|
10
|
+
readonly destructive: "#b91c1c";
|
|
11
|
+
readonly dark: {
|
|
12
|
+
readonly background: "#1c1917";
|
|
13
|
+
readonly foreground: "#fafaf9";
|
|
14
|
+
readonly primary: "#ea580c";
|
|
15
|
+
readonly primaryForeground: "#fff7ed";
|
|
16
|
+
readonly muted: "#292524";
|
|
17
|
+
readonly mutedForeground: "#a8a29e";
|
|
18
|
+
readonly border: "#44403c";
|
|
19
|
+
readonly destructive: "#ef4444";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
readonly spacing: {
|
|
23
|
+
readonly xs: "0.25rem";
|
|
24
|
+
readonly sm: "0.5rem";
|
|
25
|
+
readonly md: "1rem";
|
|
26
|
+
readonly lg: "1.5rem";
|
|
27
|
+
readonly xl: "2rem";
|
|
28
|
+
};
|
|
29
|
+
readonly radius: {
|
|
30
|
+
readonly sm: "0.25rem";
|
|
31
|
+
readonly md: "0.5rem";
|
|
32
|
+
readonly lg: "0.75rem";
|
|
33
|
+
};
|
|
34
|
+
readonly font: {
|
|
35
|
+
readonly family: "ui-sans-serif, system-ui, sans-serif";
|
|
36
|
+
readonly mono: "ui-monospace, SFMono-Regular, monospace";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type Tokens = typeof tokens;
|
|
40
|
+
|
|
41
|
+
export { type Tokens, tokens as default, tokens };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/tokens/index.ts
|
|
2
|
+
var tokens = {
|
|
3
|
+
color: {
|
|
4
|
+
background: "#faf9f7",
|
|
5
|
+
foreground: "#1c1917",
|
|
6
|
+
primary: "#c2410c",
|
|
7
|
+
primaryForeground: "#fff7ed",
|
|
8
|
+
muted: "#e7e5e4",
|
|
9
|
+
mutedForeground: "#57534e",
|
|
10
|
+
border: "#d6d3d1",
|
|
11
|
+
destructive: "#b91c1c",
|
|
12
|
+
dark: {
|
|
13
|
+
background: "#1c1917",
|
|
14
|
+
foreground: "#fafaf9",
|
|
15
|
+
primary: "#ea580c",
|
|
16
|
+
primaryForeground: "#fff7ed",
|
|
17
|
+
muted: "#292524",
|
|
18
|
+
mutedForeground: "#a8a29e",
|
|
19
|
+
border: "#44403c",
|
|
20
|
+
destructive: "#ef4444"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
spacing: { xs: "0.25rem", sm: "0.5rem", md: "1rem", lg: "1.5rem", xl: "2rem" },
|
|
24
|
+
radius: { sm: "0.25rem", md: "0.5rem", lg: "0.75rem" },
|
|
25
|
+
font: {
|
|
26
|
+
family: "ui-sans-serif, system-ui, sans-serif",
|
|
27
|
+
mono: "ui-monospace, SFMono-Regular, monospace"
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var tokens_default = tokens;
|
|
31
|
+
export {
|
|
32
|
+
tokens_default as default,
|
|
33
|
+
tokens
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/tokens/index.ts"],"sourcesContent":["export const tokens = {\n color: {\n background: '#faf9f7',\n foreground: '#1c1917',\n primary: '#c2410c',\n primaryForeground: '#fff7ed',\n muted: '#e7e5e4',\n mutedForeground: '#57534e',\n border: '#d6d3d1',\n destructive: '#b91c1c',\n dark: {\n background: '#1c1917',\n foreground: '#fafaf9',\n primary: '#ea580c',\n primaryForeground: '#fff7ed',\n muted: '#292524',\n mutedForeground: '#a8a29e',\n border: '#44403c',\n destructive: '#ef4444',\n },\n },\n spacing: { xs: '0.25rem', sm: '0.5rem', md: '1rem', lg: '1.5rem', xl: '2rem' },\n radius: { sm: '0.25rem', md: '0.5rem', lg: '0.75rem' },\n font: {\n family: 'ui-sans-serif, system-ui, sans-serif',\n mono: 'ui-monospace, SFMono-Regular, monospace',\n },\n} as const;\n\nexport type Tokens = typeof tokens;\nexport default tokens;\n"],"mappings":";AAAO,IAAM,SAAS;AAAA,EACpB,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,mBAAmB;AAAA,IACnB,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,MAAM;AAAA,MACJ,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,mBAAmB;AAAA,MACnB,OAAO;AAAA,MACP,iBAAiB;AAAA,MACjB,QAAQ;AAAA,MACR,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,SAAS,EAAE,IAAI,WAAW,IAAI,UAAU,IAAI,QAAQ,IAAI,UAAU,IAAI,OAAO;AAAA,EAC7E,QAAQ,EAAE,IAAI,WAAW,IAAI,UAAU,IAAI,UAAU;AAAA,EACrD,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AACF;AAGA,IAAO,iBAAQ;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Inari Extension Dev Harness</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|