@gadicc/loom 0.0.0-oidc-bootstrap.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +6 -0
- package/README.md +448 -0
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/db/drizzle-config.d.ts +20 -0
- package/db/drizzle-config.js +34 -0
- package/db/fixtures.d.ts +31 -0
- package/db/fixtures.js +52 -0
- package/db/neon.d.ts +3 -0
- package/db/neon.js +20 -0
- package/db/neonFull.d.ts +12 -0
- package/db/neonFull.js +33 -0
- package/db/package.json +3 -0
- package/db/testing.d.ts +26 -0
- package/db/testing.js +76 -0
- package/db/testing.test.ts +28 -0
- package/db/valibot.d.ts +23 -0
- package/db/valibot.js +8 -0
- package/esm/_dnt.polyfills.d.ts +149 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +163 -0
- package/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +57 -0
- package/esm/bin/loom.d.ts +2 -0
- package/esm/bin/loom.d.ts.map +1 -0
- package/esm/bin/loom.js +11 -0
- package/esm/mod.d.ts +9 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +8 -0
- package/esm/package.json +3 -0
- package/esm/src/apiKeys/authorize.d.ts +4 -0
- package/esm/src/apiKeys/authorize.d.ts.map +1 -0
- package/esm/src/apiKeys/authorize.js +184 -0
- package/esm/src/apiKeys/country.d.ts +3 -0
- package/esm/src/apiKeys/country.d.ts.map +1 -0
- package/esm/src/apiKeys/country.js +7 -0
- package/esm/src/apiKeys/credentials.d.ts +4 -0
- package/esm/src/apiKeys/credentials.d.ts.map +1 -0
- package/esm/src/apiKeys/credentials.js +55 -0
- package/esm/src/apiKeys/fingerprint.d.ts +3 -0
- package/esm/src/apiKeys/fingerprint.d.ts.map +1 -0
- package/esm/src/apiKeys/fingerprint.js +5 -0
- package/esm/src/apiKeys/mod.d.ts +9 -0
- package/esm/src/apiKeys/mod.d.ts.map +1 -0
- package/esm/src/apiKeys/mod.js +8 -0
- package/esm/src/apiKeys/policy.d.ts +59 -0
- package/esm/src/apiKeys/policy.d.ts.map +1 -0
- package/esm/src/apiKeys/policy.js +88 -0
- package/esm/src/apiKeys/retention.d.ts +55 -0
- package/esm/src/apiKeys/retention.d.ts.map +1 -0
- package/esm/src/apiKeys/retention.js +65 -0
- package/esm/src/apiKeys/types.d.ts +175 -0
- package/esm/src/apiKeys/types.d.ts.map +1 -0
- package/esm/src/apiKeys/types.js +1 -0
- package/esm/src/cli/externalSkills.d.ts +39 -0
- package/esm/src/cli/externalSkills.d.ts.map +1 -0
- package/esm/src/cli/externalSkills.js +177 -0
- package/esm/src/cli/mod.d.ts +337 -0
- package/esm/src/cli/mod.d.ts.map +1 -0
- package/esm/src/cli/mod.js +9268 -0
- package/esm/src/cli/projectSkills.d.ts +102 -0
- package/esm/src/cli/projectSkills.d.ts.map +1 -0
- package/esm/src/cli/projectSkills.js +592 -0
- package/esm/src/files/client.d.ts +29 -0
- package/esm/src/files/client.d.ts.map +1 -0
- package/esm/src/files/client.js +41 -0
- package/esm/src/files/errors.d.ts +37 -0
- package/esm/src/files/errors.d.ts.map +1 -0
- package/esm/src/files/errors.js +66 -0
- package/esm/src/files/hash.d.ts +15 -0
- package/esm/src/files/hash.d.ts.map +1 -0
- package/esm/src/files/hash.js +82 -0
- package/esm/src/files/memory.d.ts +29 -0
- package/esm/src/files/memory.d.ts.map +1 -0
- package/esm/src/files/memory.js +109 -0
- package/esm/src/files/metadata.d.ts +10 -0
- package/esm/src/files/metadata.d.ts.map +1 -0
- package/esm/src/files/metadata.js +186 -0
- package/esm/src/files/mod.d.ts +10 -0
- package/esm/src/files/mod.d.ts.map +1 -0
- package/esm/src/files/mod.js +9 -0
- package/esm/src/files/s3.d.ts +29 -0
- package/esm/src/files/s3.d.ts.map +1 -0
- package/esm/src/files/s3.js +107 -0
- package/esm/src/files/service.d.ts +27 -0
- package/esm/src/files/service.d.ts.map +1 -0
- package/esm/src/files/service.js +136 -0
- package/esm/src/files/types.d.ts +134 -0
- package/esm/src/files/types.d.ts.map +1 -0
- package/esm/src/files/types.js +1 -0
- package/esm/src/jobs/catalog.d.ts +32 -0
- package/esm/src/jobs/catalog.d.ts.map +1 -0
- package/esm/src/jobs/catalog.js +208 -0
- package/esm/src/jobs/controller.d.ts +28 -0
- package/esm/src/jobs/controller.d.ts.map +1 -0
- package/esm/src/jobs/controller.js +95 -0
- package/esm/src/jobs/direct.d.ts +36 -0
- package/esm/src/jobs/direct.d.ts.map +1 -0
- package/esm/src/jobs/direct.js +122 -0
- package/esm/src/jobs/events.d.ts +15 -0
- package/esm/src/jobs/events.d.ts.map +1 -0
- package/esm/src/jobs/events.js +30 -0
- package/esm/src/jobs/format.d.ts +16 -0
- package/esm/src/jobs/format.d.ts.map +1 -0
- package/esm/src/jobs/format.js +183 -0
- package/esm/src/jobs/http.d.ts +22 -0
- package/esm/src/jobs/http.d.ts.map +1 -0
- package/esm/src/jobs/http.js +44 -0
- package/esm/src/jobs/log.d.ts +2 -0
- package/esm/src/jobs/log.d.ts.map +1 -0
- package/esm/src/jobs/log.js +10 -0
- package/esm/src/jobs/mod.d.ts +10 -0
- package/esm/src/jobs/mod.d.ts.map +1 -0
- package/esm/src/jobs/mod.js +9 -0
- package/esm/src/jobs/run.d.ts +20 -0
- package/esm/src/jobs/run.d.ts.map +1 -0
- package/esm/src/jobs/run.js +57 -0
- package/esm/src/jobs/types.d.ts +31 -0
- package/esm/src/jobs/types.d.ts.map +1 -0
- package/esm/src/jobs/types.js +1 -0
- package/esm/src/mui/apiKeys.d.ts +65 -0
- package/esm/src/mui/apiKeys.d.ts.map +1 -0
- package/esm/src/mui/apiKeys.js +301 -0
- package/esm/src/mui/apiKeysView.d.ts +48 -0
- package/esm/src/mui/apiKeysView.d.ts.map +1 -0
- package/esm/src/mui/apiKeysView.js +34 -0
- package/esm/src/mui/confirm.d.ts +12 -0
- package/esm/src/mui/confirm.d.ts.map +1 -0
- package/esm/src/mui/confirm.js +78 -0
- package/esm/src/mui/mod.d.ts +4 -0
- package/esm/src/mui/mod.d.ts.map +1 -0
- package/esm/src/mui/mod.js +2 -0
- package/esm/src/next/apiKeys/mod.d.ts +64 -0
- package/esm/src/next/apiKeys/mod.d.ts.map +1 -0
- package/esm/src/next/apiKeys/mod.js +217 -0
- package/esm/src/next/auth/config.d.ts +34 -0
- package/esm/src/next/auth/config.d.ts.map +1 -0
- package/esm/src/next/auth/config.js +103 -0
- package/esm/src/next/auth/mod.d.ts +3 -0
- package/esm/src/next/auth/mod.d.ts.map +1 -0
- package/esm/src/next/auth/mod.js +2 -0
- package/esm/src/next/auth/server.d.ts +28 -0
- package/esm/src/next/auth/server.d.ts.map +1 -0
- package/esm/src/next/auth/server.js +24 -0
- package/esm/src/next/files/mod.d.ts +3 -0
- package/esm/src/next/files/mod.d.ts.map +1 -0
- package/esm/src/next/files/mod.js +2 -0
- package/esm/src/next/files/route.d.ts +99 -0
- package/esm/src/next/files/route.d.ts.map +1 -0
- package/esm/src/next/files/route.js +349 -0
- package/esm/src/next/jobs/list.d.ts +25 -0
- package/esm/src/next/jobs/list.d.ts.map +1 -0
- package/esm/src/next/jobs/list.js +39 -0
- package/esm/src/next/jobs/mod.d.ts +6 -0
- package/esm/src/next/jobs/mod.d.ts.map +1 -0
- package/esm/src/next/jobs/mod.js +5 -0
- package/esm/src/next/jobs/paths.d.ts +14 -0
- package/esm/src/next/jobs/paths.d.ts.map +1 -0
- package/esm/src/next/jobs/paths.js +40 -0
- package/esm/src/next/jobs/route.d.ts +48 -0
- package/esm/src/next/jobs/route.d.ts.map +1 -0
- package/esm/src/next/jobs/route.js +101 -0
- package/esm/src/next/jobs/run.d.ts +51 -0
- package/esm/src/next/jobs/run.d.ts.map +1 -0
- package/esm/src/next/jobs/run.js +563 -0
- package/esm/src/next/jobs/stream.d.ts +3 -0
- package/esm/src/next/jobs/stream.d.ts.map +1 -0
- package/esm/src/next/jobs/stream.js +25 -0
- package/esm/src/next/pwa/mod.d.ts +104 -0
- package/esm/src/next/pwa/mod.d.ts.map +1 -0
- package/esm/src/next/pwa/mod.js +169 -0
- package/esm/src/next/pwa/worker.d.ts +27 -0
- package/esm/src/next/pwa/worker.d.ts.map +1 -0
- package/esm/src/next/pwa/worker.js +27 -0
- package/package.json +293 -0
- package/script/_dnt.polyfills.d.ts +149 -0
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.polyfills.js +166 -0
- package/script/_dnt.shims.d.ts +2 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +60 -0
- package/script/bin/loom.d.ts +2 -0
- package/script/bin/loom.d.ts.map +1 -0
- package/script/bin/loom.js +17 -0
- package/script/mod.d.ts +9 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +24 -0
- package/script/package.json +3 -0
- package/script/src/apiKeys/authorize.d.ts +4 -0
- package/script/src/apiKeys/authorize.d.ts.map +1 -0
- package/script/src/apiKeys/authorize.js +187 -0
- package/script/src/apiKeys/country.d.ts +3 -0
- package/script/src/apiKeys/country.d.ts.map +1 -0
- package/script/src/apiKeys/country.js +10 -0
- package/script/src/apiKeys/credentials.d.ts +4 -0
- package/script/src/apiKeys/credentials.d.ts.map +1 -0
- package/script/src/apiKeys/credentials.js +58 -0
- package/script/src/apiKeys/fingerprint.d.ts +3 -0
- package/script/src/apiKeys/fingerprint.d.ts.map +1 -0
- package/script/src/apiKeys/fingerprint.js +8 -0
- package/script/src/apiKeys/mod.d.ts +9 -0
- package/script/src/apiKeys/mod.d.ts.map +1 -0
- package/script/src/apiKeys/mod.js +24 -0
- package/script/src/apiKeys/policy.d.ts +59 -0
- package/script/src/apiKeys/policy.d.ts.map +1 -0
- package/script/src/apiKeys/policy.js +92 -0
- package/script/src/apiKeys/retention.d.ts +55 -0
- package/script/src/apiKeys/retention.d.ts.map +1 -0
- package/script/src/apiKeys/retention.js +70 -0
- package/script/src/apiKeys/types.d.ts +175 -0
- package/script/src/apiKeys/types.d.ts.map +1 -0
- package/script/src/apiKeys/types.js +2 -0
- package/script/src/cli/externalSkills.d.ts +39 -0
- package/script/src/cli/externalSkills.d.ts.map +1 -0
- package/script/src/cli/externalSkills.js +181 -0
- package/script/src/cli/mod.d.ts +337 -0
- package/script/src/cli/mod.d.ts.map +1 -0
- package/script/src/cli/mod.js +9337 -0
- package/script/src/cli/projectSkills.d.ts +102 -0
- package/script/src/cli/projectSkills.d.ts.map +1 -0
- package/script/src/cli/projectSkills.js +606 -0
- package/script/src/files/client.d.ts +29 -0
- package/script/src/files/client.d.ts.map +1 -0
- package/script/src/files/client.js +45 -0
- package/script/src/files/errors.d.ts +37 -0
- package/script/src/files/errors.d.ts.map +1 -0
- package/script/src/files/errors.js +76 -0
- package/script/src/files/hash.d.ts +15 -0
- package/script/src/files/hash.d.ts.map +1 -0
- package/script/src/files/hash.js +89 -0
- package/script/src/files/memory.d.ts +29 -0
- package/script/src/files/memory.d.ts.map +1 -0
- package/script/src/files/memory.js +113 -0
- package/script/src/files/metadata.d.ts +10 -0
- package/script/src/files/metadata.d.ts.map +1 -0
- package/script/src/files/metadata.js +189 -0
- package/script/src/files/mod.d.ts +10 -0
- package/script/src/files/mod.d.ts.map +1 -0
- package/script/src/files/mod.js +25 -0
- package/script/src/files/s3.d.ts +29 -0
- package/script/src/files/s3.d.ts.map +1 -0
- package/script/src/files/s3.js +110 -0
- package/script/src/files/service.d.ts +27 -0
- package/script/src/files/service.d.ts.map +1 -0
- package/script/src/files/service.js +139 -0
- package/script/src/files/types.d.ts +134 -0
- package/script/src/files/types.d.ts.map +1 -0
- package/script/src/files/types.js +2 -0
- package/script/src/jobs/catalog.d.ts +32 -0
- package/script/src/jobs/catalog.d.ts.map +1 -0
- package/script/src/jobs/catalog.js +223 -0
- package/script/src/jobs/controller.d.ts +28 -0
- package/script/src/jobs/controller.d.ts.map +1 -0
- package/script/src/jobs/controller.js +100 -0
- package/script/src/jobs/direct.d.ts +36 -0
- package/script/src/jobs/direct.d.ts.map +1 -0
- package/script/src/jobs/direct.js +128 -0
- package/script/src/jobs/events.d.ts +15 -0
- package/script/src/jobs/events.d.ts.map +1 -0
- package/script/src/jobs/events.js +37 -0
- package/script/src/jobs/format.d.ts +16 -0
- package/script/src/jobs/format.d.ts.map +1 -0
- package/script/src/jobs/format.js +193 -0
- package/script/src/jobs/http.d.ts +22 -0
- package/script/src/jobs/http.d.ts.map +1 -0
- package/script/src/jobs/http.js +50 -0
- package/script/src/jobs/log.d.ts +2 -0
- package/script/src/jobs/log.d.ts.map +1 -0
- package/script/src/jobs/log.js +13 -0
- package/script/src/jobs/mod.d.ts +10 -0
- package/script/src/jobs/mod.d.ts.map +1 -0
- package/script/src/jobs/mod.js +25 -0
- package/script/src/jobs/run.d.ts +20 -0
- package/script/src/jobs/run.d.ts.map +1 -0
- package/script/src/jobs/run.js +61 -0
- package/script/src/jobs/types.d.ts +31 -0
- package/script/src/jobs/types.d.ts.map +1 -0
- package/script/src/jobs/types.js +2 -0
- package/script/src/mui/apiKeys.d.ts +65 -0
- package/script/src/mui/apiKeys.d.ts.map +1 -0
- package/script/src/mui/apiKeys.js +327 -0
- package/script/src/mui/apiKeysView.d.ts +48 -0
- package/script/src/mui/apiKeysView.d.ts.map +1 -0
- package/script/src/mui/apiKeysView.js +40 -0
- package/script/src/mui/confirm.d.ts +12 -0
- package/script/src/mui/confirm.d.ts.map +1 -0
- package/script/src/mui/confirm.js +85 -0
- package/script/src/mui/mod.d.ts +4 -0
- package/script/src/mui/mod.d.ts.map +1 -0
- package/script/src/mui/mod.js +19 -0
- package/script/src/next/apiKeys/mod.d.ts +64 -0
- package/script/src/next/apiKeys/mod.d.ts.map +1 -0
- package/script/src/next/apiKeys/mod.js +224 -0
- package/script/src/next/auth/config.d.ts +34 -0
- package/script/src/next/auth/config.d.ts.map +1 -0
- package/script/src/next/auth/config.js +142 -0
- package/script/src/next/auth/mod.d.ts +3 -0
- package/script/src/next/auth/mod.d.ts.map +1 -0
- package/script/src/next/auth/mod.js +18 -0
- package/script/src/next/auth/server.d.ts +28 -0
- package/script/src/next/auth/server.d.ts.map +1 -0
- package/script/src/next/auth/server.js +27 -0
- package/script/src/next/files/mod.d.ts +3 -0
- package/script/src/next/files/mod.d.ts.map +1 -0
- package/script/src/next/files/mod.js +18 -0
- package/script/src/next/files/route.d.ts +99 -0
- package/script/src/next/files/route.d.ts.map +1 -0
- package/script/src/next/files/route.js +353 -0
- package/script/src/next/jobs/list.d.ts +25 -0
- package/script/src/next/jobs/list.d.ts.map +1 -0
- package/script/src/next/jobs/list.js +48 -0
- package/script/src/next/jobs/mod.d.ts +6 -0
- package/script/src/next/jobs/mod.d.ts.map +1 -0
- package/script/src/next/jobs/mod.js +21 -0
- package/script/src/next/jobs/paths.d.ts +14 -0
- package/script/src/next/jobs/paths.d.ts.map +1 -0
- package/script/src/next/jobs/paths.js +47 -0
- package/script/src/next/jobs/route.d.ts +48 -0
- package/script/src/next/jobs/route.d.ts.map +1 -0
- package/script/src/next/jobs/route.js +105 -0
- package/script/src/next/jobs/run.d.ts +51 -0
- package/script/src/next/jobs/run.d.ts.map +1 -0
- package/script/src/next/jobs/run.js +570 -0
- package/script/src/next/jobs/stream.d.ts +3 -0
- package/script/src/next/jobs/stream.d.ts.map +1 -0
- package/script/src/next/jobs/stream.js +28 -0
- package/script/src/next/pwa/mod.d.ts +104 -0
- package/script/src/next/pwa/mod.d.ts.map +1 -0
- package/script/src/next/pwa/mod.js +192 -0
- package/script/src/next/pwa/worker.d.ts +27 -0
- package/script/src/next/pwa/worker.d.ts.map +1 -0
- package/script/src/next/pwa/worker.js +33 -0
- package/skills/loom/SKILL.md +200 -0
- package/skills/loom-api-keys/SKILL.md +123 -0
- package/skills/loom-auth/SKILL.md +70 -0
- package/skills/loom-db/SKILL.md +94 -0
- package/skills/loom-db/references/db-stack.md +39 -0
- package/skills/loom-files/SKILL.md +97 -0
- package/skills/loom-jobs/SKILL.md +148 -0
- package/skills/upgrade-deps/SKILL.md +165 -0
- package/skills/upgrade-deps/agents/openai.yaml +4 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JobController } from "./controller.js";
|
|
2
|
+
import type { JobDefinition, JobParams } from "./types.js";
|
|
3
|
+
export interface JobRunResult<TJob extends JobDefinition = JobDefinition> {
|
|
4
|
+
controller: JobController;
|
|
5
|
+
error: unknown | null;
|
|
6
|
+
job: TJob;
|
|
7
|
+
params: JobParams;
|
|
8
|
+
}
|
|
9
|
+
export interface JobExecution<TJob extends JobDefinition = JobDefinition> {
|
|
10
|
+
stream: ReadableStream<string>;
|
|
11
|
+
result: Promise<JobRunResult<TJob>>;
|
|
12
|
+
getController: () => JobController | null;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateJobExecutionOptions {
|
|
15
|
+
maxLogLevel?: number;
|
|
16
|
+
runDeferredTasks?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function formatJobError(error: unknown): string;
|
|
19
|
+
export declare function createJobExecution<TJob extends JobDefinition>(job: TJob, params?: JobParams, options?: CreateJobExecutionOptions): JobExecution<TJob>;
|
|
20
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/src/jobs/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,WAAW,YAAY,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa;IACtE,UAAU,EAAE,aAAa,CAAC;IAC1B,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB,GAAG,EAAE,IAAI,CAAC;IACV,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,YAAY,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa;IACtE,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,aAAa,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,yBAAyB;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUrD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,aAAa,EAC3D,GAAG,EAAE,IAAI,EACT,MAAM,GAAE,SAAc,EACtB,OAAO,GAAE,yBAA8B,GACtC,YAAY,CAAC,IAAI,CAAC,CAiDpB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { JobController } from "./controller.js";
|
|
2
|
+
import { serializeJobEvent } from "./events.js";
|
|
3
|
+
export function formatJobError(error) {
|
|
4
|
+
if (error instanceof Error) {
|
|
5
|
+
return error.stack ?? error.toString();
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
return JSON.stringify(error);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return String(error);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function createJobExecution(job, params = {}, options = {}) {
|
|
15
|
+
let jobController = null;
|
|
16
|
+
let resolveResult;
|
|
17
|
+
const result = new Promise((resolve) => {
|
|
18
|
+
resolveResult = resolve;
|
|
19
|
+
});
|
|
20
|
+
const stream = new ReadableStream({
|
|
21
|
+
async start(controller) {
|
|
22
|
+
controller.enqueue(serializeJobEvent({ _job: "start" }));
|
|
23
|
+
jobController = new JobController(controller, options.maxLogLevel);
|
|
24
|
+
let error = null;
|
|
25
|
+
try {
|
|
26
|
+
await job.handler(jobController, params);
|
|
27
|
+
if (options.runDeferredTasks) {
|
|
28
|
+
await jobController.runDeferredTasks();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (caught) {
|
|
32
|
+
error = caught;
|
|
33
|
+
jobController.fatal(formatJobError(caught));
|
|
34
|
+
}
|
|
35
|
+
controller.enqueue(serializeJobEvent({ _job: "end" }));
|
|
36
|
+
controller.close();
|
|
37
|
+
resolveResult({
|
|
38
|
+
controller: jobController,
|
|
39
|
+
error,
|
|
40
|
+
job,
|
|
41
|
+
params,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
cancel() {
|
|
45
|
+
if (!jobController) {
|
|
46
|
+
throw new Error("Job cancelled but job controller not set.");
|
|
47
|
+
}
|
|
48
|
+
jobController.log("Job cancelled");
|
|
49
|
+
jobController._cancelled = true;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
stream,
|
|
54
|
+
result,
|
|
55
|
+
getController: () => jobController,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { JobController } from "./controller.js";
|
|
2
|
+
export interface JobParamDefinition {
|
|
3
|
+
type: "string" | "number" | "boolean";
|
|
4
|
+
desc: string;
|
|
5
|
+
default?: string | number | boolean;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type JobParamsDefinition = Record<string, JobParamDefinition>;
|
|
9
|
+
export interface JobMeta {
|
|
10
|
+
id: string;
|
|
11
|
+
desc: string;
|
|
12
|
+
params?: JobParamsDefinition;
|
|
13
|
+
}
|
|
14
|
+
export type JobParamsValue = string | number | boolean;
|
|
15
|
+
export type JobParams = Record<string, JobParamsValue>;
|
|
16
|
+
export interface JobDefinition<TParams extends Record<string, any> = Record<string, any>> {
|
|
17
|
+
meta: JobMeta;
|
|
18
|
+
handler: (controller: JobController, params: TParams) => Promise<void> | void;
|
|
19
|
+
}
|
|
20
|
+
export type Job = JobDefinition;
|
|
21
|
+
export interface JobCatalog<TJob extends JobDefinition = JobDefinition> {
|
|
22
|
+
readonly jobs: Readonly<Record<string, TJob>>;
|
|
23
|
+
readonly metas: readonly JobMeta[];
|
|
24
|
+
readonly ids: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export type JobOutputFormat = "nd-json" | "text" | "html";
|
|
27
|
+
export interface DeferredTask {
|
|
28
|
+
label?: string;
|
|
29
|
+
task: () => Promise<void> | void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/jobs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAErE,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACvD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEvD,MAAM,WAAW,aAAa,CAC5B,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAEzD,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,CACP,UAAU,EAAE,aAAa,EACzB,MAAM,EAAE,OAAO,KACZ,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,MAAM,GAAG,GAAG,aAAa,CAAC;AAEhC,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa;IACpE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import "../../_dnt.polyfills.js";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import { type ApiKeyAuditRow, type ApiKeyRow, type ApiKeyScopeDefinition } from "./apiKeysView.js";
|
|
4
|
+
export * from "./apiKeysView.js";
|
|
5
|
+
export interface ApiKeyCreateInput {
|
|
6
|
+
expiresAt: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
scopeIds: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface ApiKeyCreateResult {
|
|
11
|
+
key: string;
|
|
12
|
+
keyStart?: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ApiKeyTableColumn {
|
|
16
|
+
header: ReactNode;
|
|
17
|
+
id: string;
|
|
18
|
+
render: (row: ApiKeyRow) => ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface ApiKeyCreateDialogProps {
|
|
21
|
+
error?: string | null;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
onCreate: (input: ApiKeyCreateInput) => Promise<ApiKeyCreateResult>;
|
|
24
|
+
onCreated: (result: ApiKeyCreateResult) => void;
|
|
25
|
+
open: boolean;
|
|
26
|
+
scopes: ApiKeyScopeDefinition[];
|
|
27
|
+
}
|
|
28
|
+
export declare function ApiKeyCreateDialog(props: ApiKeyCreateDialogProps): any;
|
|
29
|
+
export interface ApiKeySecretDialogProps {
|
|
30
|
+
open: boolean;
|
|
31
|
+
onClose: () => void;
|
|
32
|
+
queryCredentialsEnabled?: boolean;
|
|
33
|
+
result: ApiKeyCreateResult | null;
|
|
34
|
+
}
|
|
35
|
+
export declare function ApiKeySecretDialog(props: ApiKeySecretDialogProps): any;
|
|
36
|
+
export interface ApiKeysTableProps {
|
|
37
|
+
admin?: boolean;
|
|
38
|
+
extraColumns?: ApiKeyTableColumn[];
|
|
39
|
+
loading?: boolean;
|
|
40
|
+
onRename?: (id: string, name: string) => Promise<void>;
|
|
41
|
+
onRevoke?: (id: string) => Promise<void>;
|
|
42
|
+
rows: ApiKeyRow[];
|
|
43
|
+
scopes?: ApiKeyScopeDefinition[];
|
|
44
|
+
}
|
|
45
|
+
export declare function ApiKeysTable(props: ApiKeysTableProps): any;
|
|
46
|
+
export declare function AdminApiKeysTable(props: Omit<ApiKeysTableProps, "admin">): any;
|
|
47
|
+
export interface ApiKeyAuditTableProps {
|
|
48
|
+
count: number;
|
|
49
|
+
loading?: boolean;
|
|
50
|
+
onPageChange: (page: number) => void;
|
|
51
|
+
page: number;
|
|
52
|
+
rows: ApiKeyAuditRow[];
|
|
53
|
+
rowsPerPage: number;
|
|
54
|
+
}
|
|
55
|
+
export declare function ApiKeyAuditTable(props: ApiKeyAuditTableProps): any;
|
|
56
|
+
export interface ApiKeysManagerProps extends Omit<ApiKeysTableProps, "onRevoke" | "onRename"> {
|
|
57
|
+
error?: string | null;
|
|
58
|
+
onCreate?: (input: ApiKeyCreateInput) => Promise<ApiKeyCreateResult>;
|
|
59
|
+
onRename?: (id: string, name: string) => Promise<void>;
|
|
60
|
+
onRevoke?: (id: string) => Promise<void>;
|
|
61
|
+
queryCredentialsEnabled?: boolean;
|
|
62
|
+
scopes: ApiKeyScopeDefinition[];
|
|
63
|
+
}
|
|
64
|
+
export declare function ApiKeysManager(props: ApiKeysManagerProps): any;
|
|
65
|
+
//# sourceMappingURL=apiKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiKeys.d.ts","sourceRoot":"","sources":["../../../src/src/mui/apiKeys.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import Alert from "@mui/material/Alert";
|
|
3
|
+
import Box from "@mui/material/Box";
|
|
4
|
+
import Button from "@mui/material/Button";
|
|
5
|
+
import Checkbox from "@mui/material/Checkbox";
|
|
6
|
+
import Chip from "@mui/material/Chip";
|
|
7
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
|
8
|
+
import Dialog from "@mui/material/Dialog";
|
|
9
|
+
import DialogActions from "@mui/material/DialogActions";
|
|
10
|
+
import DialogContent from "@mui/material/DialogContent";
|
|
11
|
+
import DialogContentText from "@mui/material/DialogContentText";
|
|
12
|
+
import DialogTitle from "@mui/material/DialogTitle";
|
|
13
|
+
import FormControlLabel from "@mui/material/FormControlLabel";
|
|
14
|
+
import Paper from "@mui/material/Paper";
|
|
15
|
+
import Stack from "@mui/material/Stack";
|
|
16
|
+
import Table from "@mui/material/Table";
|
|
17
|
+
import TableBody from "@mui/material/TableBody";
|
|
18
|
+
import TableCell from "@mui/material/TableCell";
|
|
19
|
+
import TableContainer from "@mui/material/TableContainer";
|
|
20
|
+
import TableHead from "@mui/material/TableHead";
|
|
21
|
+
import TablePagination from "@mui/material/TablePagination";
|
|
22
|
+
import TableRow from "@mui/material/TableRow";
|
|
23
|
+
import TextField from "@mui/material/TextField";
|
|
24
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
25
|
+
import Typography from "@mui/material/Typography";
|
|
26
|
+
import React from "react";
|
|
27
|
+
import { countryCodeToFlagEmoji, formatApiKeyDate, getApiKeyStatus, } from "./apiKeysView.js";
|
|
28
|
+
export * from "./apiKeysView.js";
|
|
29
|
+
function IpCountry(props) {
|
|
30
|
+
const flag = countryCodeToFlagEmoji(props.countryCode);
|
|
31
|
+
if (!flag && !props.ipAddress)
|
|
32
|
+
return React.createElement(React.Fragment, null, "\u2014");
|
|
33
|
+
return (React.createElement(React.Fragment, null,
|
|
34
|
+
flag
|
|
35
|
+
? (React.createElement(Box, { component: "span", role: "img", "aria-label": props.countryCode?.toUpperCase(), sx: { mr: props.ipAddress ? 0.75 : 0 } }, flag))
|
|
36
|
+
: null,
|
|
37
|
+
props.ipAddress));
|
|
38
|
+
}
|
|
39
|
+
export function ApiKeyCreateDialog(props) {
|
|
40
|
+
const [name, setName] = React.useState("");
|
|
41
|
+
const [scopeIds, setScopeIds] = React.useState([]);
|
|
42
|
+
const [expiry, setExpiry] = React.useState("never");
|
|
43
|
+
const [customExpiry, setCustomExpiry] = React.useState("");
|
|
44
|
+
const [localError, setLocalError] = React.useState(null);
|
|
45
|
+
const [pending, startTransition] = React.useTransition();
|
|
46
|
+
const close = () => {
|
|
47
|
+
if (!pending)
|
|
48
|
+
props.onClose();
|
|
49
|
+
};
|
|
50
|
+
const submit = () => {
|
|
51
|
+
const trimmedName = name.trim();
|
|
52
|
+
if (!trimmedName) {
|
|
53
|
+
setLocalError("Enter a name for this key.");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!scopeIds.length) {
|
|
57
|
+
setLocalError("Choose at least one scope.");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let expiresAt = null;
|
|
61
|
+
if (expiry === "custom") {
|
|
62
|
+
const parsed = new Date(customExpiry);
|
|
63
|
+
if (!customExpiry || Number.isNaN(parsed.valueOf()) || parsed <= new Date()) {
|
|
64
|
+
setLocalError("Choose a future expiry date.");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
expiresAt = parsed.toISOString();
|
|
68
|
+
}
|
|
69
|
+
else if (expiry !== "never") {
|
|
70
|
+
expiresAt = new Date(Date.now() + Number(expiry) * 86_400_000)
|
|
71
|
+
.toISOString();
|
|
72
|
+
}
|
|
73
|
+
setLocalError(null);
|
|
74
|
+
startTransition(async () => {
|
|
75
|
+
try {
|
|
76
|
+
const result = await props.onCreate({
|
|
77
|
+
expiresAt,
|
|
78
|
+
name: trimmedName,
|
|
79
|
+
scopeIds,
|
|
80
|
+
});
|
|
81
|
+
props.onCreated(result);
|
|
82
|
+
setName("");
|
|
83
|
+
setScopeIds([]);
|
|
84
|
+
setExpiry("never");
|
|
85
|
+
props.onClose();
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
setLocalError(error instanceof Error
|
|
89
|
+
? error.message
|
|
90
|
+
: "The key could not be created.");
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return (React.createElement(Dialog, { open: props.open, onClose: close, fullWidth: true, maxWidth: "sm", "aria-labelledby": "loom-api-key-create-title" },
|
|
95
|
+
React.createElement(DialogTitle, { id: "loom-api-key-create-title" }, "Create API key"),
|
|
96
|
+
React.createElement(DialogContent, null,
|
|
97
|
+
React.createElement(Stack, { spacing: 2, sx: { pt: 1 } },
|
|
98
|
+
React.createElement(TextField, { label: "Key name", value: name, required: true, autoFocus: true, onChange: (event) => setName(event.target.value), disabled: pending }),
|
|
99
|
+
React.createElement(Box, { component: "fieldset", sx: { border: 0, m: 0, p: 0 } },
|
|
100
|
+
React.createElement(Typography, { component: "legend", variant: "subtitle2" }, "Scopes"),
|
|
101
|
+
props.scopes.map((scope) => (React.createElement(Tooltip, { key: scope.id, title: scope.description ?? "", placement: "right" },
|
|
102
|
+
React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { checked: scopeIds.includes(scope.id), onChange: (_, checked) => setScopeIds((current) => checked
|
|
103
|
+
? [...current, scope.id]
|
|
104
|
+
: current.filter((id) => id !== scope.id)) }), disabled: pending || scope.disabled, label: scope.label }))))),
|
|
105
|
+
React.createElement(TextField, { select: true, label: "Expiry", value: expiry, onChange: (event) => setExpiry(event.target.value), disabled: pending, slotProps: { select: { native: true } } },
|
|
106
|
+
React.createElement("option", { value: "never" }, "Never"),
|
|
107
|
+
React.createElement("option", { value: "7" }, "7 days"),
|
|
108
|
+
React.createElement("option", { value: "30" }, "30 days"),
|
|
109
|
+
React.createElement("option", { value: "custom" }, "Custom date")),
|
|
110
|
+
expiry === "custom"
|
|
111
|
+
? (React.createElement(TextField, { type: "datetime-local", label: "Expires at", value: customExpiry, onChange: (event) => setCustomExpiry(event.target.value), slotProps: { inputLabel: { shrink: true } }, disabled: pending }))
|
|
112
|
+
: null,
|
|
113
|
+
localError || props.error
|
|
114
|
+
? React.createElement(Alert, { severity: "error" }, localError ?? props.error)
|
|
115
|
+
: null)),
|
|
116
|
+
React.createElement(DialogActions, null,
|
|
117
|
+
React.createElement(Button, { onClick: close, disabled: pending }, "Cancel"),
|
|
118
|
+
React.createElement(Button, { onClick: submit, variant: "contained", disabled: pending }, pending ? "Creating…" : "Create key"))));
|
|
119
|
+
}
|
|
120
|
+
export function ApiKeySecretDialog(props) {
|
|
121
|
+
const [copied, setCopied] = React.useState(false);
|
|
122
|
+
React.useEffect(() => setCopied(false), [props.result]);
|
|
123
|
+
const copy = async () => {
|
|
124
|
+
if (!props.result)
|
|
125
|
+
return;
|
|
126
|
+
const clipboard = globalThis.navigator.clipboard;
|
|
127
|
+
if (!clipboard)
|
|
128
|
+
throw new Error("Clipboard access is unavailable.");
|
|
129
|
+
await clipboard.writeText(props.result.key);
|
|
130
|
+
setCopied(true);
|
|
131
|
+
};
|
|
132
|
+
return (React.createElement(Dialog, { open: props.open, onClose: props.onClose, fullWidth: true, maxWidth: "sm", "aria-labelledby": "loom-api-key-secret-title" },
|
|
133
|
+
React.createElement(DialogTitle, { id: "loom-api-key-secret-title" }, "Copy your API key now"),
|
|
134
|
+
React.createElement(DialogContent, null,
|
|
135
|
+
React.createElement(DialogContentText, null, "This secret is shown once and cannot be recovered after you close this dialog."),
|
|
136
|
+
React.createElement(TextField, { value: props.result?.key ?? "", fullWidth: true, margin: "normal", label: "API key", slotProps: {
|
|
137
|
+
htmlInput: { readOnly: true, "aria-label": "New API key" },
|
|
138
|
+
} }),
|
|
139
|
+
props.queryCredentialsEnabled
|
|
140
|
+
? (React.createElement(Alert, { severity: "warning" }, "Query-parameter keys can appear in browser history, access logs, copied links, and referrers. Prefer an authorization header."))
|
|
141
|
+
: null,
|
|
142
|
+
copied
|
|
143
|
+
? React.createElement(Alert, { severity: "success", sx: { mt: 2 } }, "Copied.")
|
|
144
|
+
: null),
|
|
145
|
+
React.createElement(DialogActions, null,
|
|
146
|
+
React.createElement(Button, { onClick: copy, disabled: !props.result }, "Copy key"),
|
|
147
|
+
React.createElement(Button, { onClick: props.onClose, variant: "contained" }, "I saved it"))));
|
|
148
|
+
}
|
|
149
|
+
function ScopeChips({ scopes }) {
|
|
150
|
+
return (React.createElement(Stack, { direction: "row", gap: 0.5, flexWrap: "wrap" }, scopes.map((scope) => React.createElement(Chip, { key: scope, size: "small", label: scope }))));
|
|
151
|
+
}
|
|
152
|
+
export function ApiKeysTable(props) {
|
|
153
|
+
const [pendingId, setPendingId] = React.useState(null);
|
|
154
|
+
const revoke = async (row) => {
|
|
155
|
+
if (!props.onRevoke ||
|
|
156
|
+
!globalThis.confirm(`Revoke “${row.name}”? This cannot be undone.`))
|
|
157
|
+
return;
|
|
158
|
+
setPendingId(row.id);
|
|
159
|
+
try {
|
|
160
|
+
await props.onRevoke(row.id);
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
setPendingId(null);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const rename = async (row) => {
|
|
167
|
+
if (!props.onRename)
|
|
168
|
+
return;
|
|
169
|
+
const name = globalThis.prompt("New key name", row.name)?.trim();
|
|
170
|
+
if (!name || name === row.name)
|
|
171
|
+
return;
|
|
172
|
+
setPendingId(row.id);
|
|
173
|
+
try {
|
|
174
|
+
await props.onRename(row.id, name);
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
setPendingId(null);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
if (props.loading) {
|
|
181
|
+
return (React.createElement(Box, { sx: { py: 6, textAlign: "center" } },
|
|
182
|
+
React.createElement(CircularProgress, { "aria-label": "Loading API keys" })));
|
|
183
|
+
}
|
|
184
|
+
if (!props.rows.length) {
|
|
185
|
+
return (React.createElement(Alert, { severity: "info" }, "No API keys yet. Create one when you are ready to connect an external tool."));
|
|
186
|
+
}
|
|
187
|
+
const actions = (row) => (React.createElement(Stack, { direction: "row", spacing: 1 },
|
|
188
|
+
React.createElement(Button, { size: "small", onClick: () => rename(row), disabled: !props.onRename || pendingId === row.id }, "Rename"),
|
|
189
|
+
React.createElement(Button, { size: "small", color: "error", onClick: () => revoke(row), disabled: !props.onRevoke || !row.enabled || pendingId === row.id }, "Revoke")));
|
|
190
|
+
return (React.createElement(React.Fragment, null,
|
|
191
|
+
React.createElement(TableContainer, { component: Paper, variant: "outlined", sx: { display: { xs: "none", md: "block" } } },
|
|
192
|
+
React.createElement(Table, { size: "small", "aria-label": props.admin ? "All user API keys" : "Your API keys" },
|
|
193
|
+
React.createElement(TableHead, null,
|
|
194
|
+
React.createElement(TableRow, null,
|
|
195
|
+
props.admin ? React.createElement(TableCell, null, "Owner") : null,
|
|
196
|
+
React.createElement(TableCell, null, "Name / start"),
|
|
197
|
+
React.createElement(TableCell, null, "Status"),
|
|
198
|
+
React.createElement(TableCell, null, "Scopes"),
|
|
199
|
+
React.createElement(TableCell, null, "Created"),
|
|
200
|
+
React.createElement(TableCell, null, "Expires"),
|
|
201
|
+
React.createElement(TableCell, null, "Last successful use"),
|
|
202
|
+
props.extraColumns?.map((column) => (React.createElement(TableCell, { key: column.id }, column.header))),
|
|
203
|
+
React.createElement(TableCell, { align: "right" }, "Actions"))),
|
|
204
|
+
React.createElement(TableBody, null, props.rows.map((row) => (React.createElement(TableRow, { key: row.id, hover: true },
|
|
205
|
+
props.admin
|
|
206
|
+
? (React.createElement(TableCell, null,
|
|
207
|
+
React.createElement(Typography, { variant: "body2" }, row.ownerName ?? row.ownerId ?? "Unknown"),
|
|
208
|
+
React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.ownerEmail)))
|
|
209
|
+
: null,
|
|
210
|
+
React.createElement(TableCell, null,
|
|
211
|
+
React.createElement(Typography, { variant: "body2", fontWeight: 600 }, row.name),
|
|
212
|
+
React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.start ?? "No visible prefix")),
|
|
213
|
+
React.createElement(TableCell, null,
|
|
214
|
+
React.createElement(Chip, { size: "small", color: getApiKeyStatus(row) === "Active"
|
|
215
|
+
? "success"
|
|
216
|
+
: "default", label: getApiKeyStatus(row) })),
|
|
217
|
+
React.createElement(TableCell, null,
|
|
218
|
+
React.createElement(ScopeChips, { scopes: row.scopes })),
|
|
219
|
+
React.createElement(TableCell, null, formatApiKeyDate(row.createdAt)),
|
|
220
|
+
React.createElement(TableCell, null, formatApiKeyDate(row.expiresAt)),
|
|
221
|
+
React.createElement(TableCell, null,
|
|
222
|
+
formatApiKeyDate(row.lastUsedAt),
|
|
223
|
+
row.lastUsedScope
|
|
224
|
+
? (React.createElement(Typography, { display: "block", variant: "caption" }, row.lastUsedScope))
|
|
225
|
+
: null,
|
|
226
|
+
row.lastUsedCountryCode || row.lastUsedIpAddress
|
|
227
|
+
? (React.createElement(Typography, { display: "block", variant: "caption" },
|
|
228
|
+
React.createElement(IpCountry, { countryCode: row.lastUsedCountryCode, ipAddress: row.lastUsedIpAddress })))
|
|
229
|
+
: null),
|
|
230
|
+
props.extraColumns?.map((column) => (React.createElement(TableCell, { key: column.id }, column.render(row)))),
|
|
231
|
+
React.createElement(TableCell, { align: "right" }, actions(row)))))))),
|
|
232
|
+
React.createElement(Stack, { spacing: 1.5, sx: { display: { xs: "flex", md: "none" } } }, props.rows.map((row) => (React.createElement(Paper, { key: row.id, variant: "outlined", sx: { p: 2 } },
|
|
233
|
+
React.createElement(Stack, { spacing: 1 },
|
|
234
|
+
React.createElement(Stack, { direction: "row", justifyContent: "space-between" },
|
|
235
|
+
React.createElement(Box, null,
|
|
236
|
+
React.createElement(Typography, { fontWeight: 600 }, row.name),
|
|
237
|
+
React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.start)),
|
|
238
|
+
React.createElement(Chip, { size: "small", label: getApiKeyStatus(row) })),
|
|
239
|
+
props.admin
|
|
240
|
+
? (React.createElement(Typography, { variant: "body2" }, row.ownerName ?? row.ownerEmail ?? row.ownerId))
|
|
241
|
+
: null,
|
|
242
|
+
React.createElement(ScopeChips, { scopes: row.scopes }),
|
|
243
|
+
React.createElement(Typography, { variant: "caption" },
|
|
244
|
+
"Last successful use: ",
|
|
245
|
+
formatApiKeyDate(row.lastUsedAt),
|
|
246
|
+
row.lastUsedScope ? ` · ${row.lastUsedScope}` : "",
|
|
247
|
+
row.lastUsedCountryCode || row.lastUsedIpAddress
|
|
248
|
+
? (React.createElement(React.Fragment, null,
|
|
249
|
+
" · ",
|
|
250
|
+
React.createElement(IpCountry, { countryCode: row.lastUsedCountryCode, ipAddress: row.lastUsedIpAddress })))
|
|
251
|
+
: null),
|
|
252
|
+
actions(row))))))));
|
|
253
|
+
}
|
|
254
|
+
export function AdminApiKeysTable(props) {
|
|
255
|
+
return React.createElement(ApiKeysTable, { ...props, admin: true });
|
|
256
|
+
}
|
|
257
|
+
export function ApiKeyAuditTable(props) {
|
|
258
|
+
return (React.createElement(Paper, { variant: "outlined" },
|
|
259
|
+
React.createElement(TableContainer, null,
|
|
260
|
+
React.createElement(Table, { size: "small", "aria-label": "API-key audit history" },
|
|
261
|
+
React.createElement(TableHead, null,
|
|
262
|
+
React.createElement(TableRow, null,
|
|
263
|
+
React.createElement(TableCell, null, "Time"),
|
|
264
|
+
React.createElement(TableCell, null, "Scope"),
|
|
265
|
+
React.createElement(TableCell, null, "Operation"),
|
|
266
|
+
React.createElement(TableCell, null, "Transport"),
|
|
267
|
+
React.createElement(TableCell, null, "Client"),
|
|
268
|
+
React.createElement(TableCell, null, "Outcome"),
|
|
269
|
+
React.createElement(TableCell, null, "Context"))),
|
|
270
|
+
React.createElement(TableBody, null, props.loading
|
|
271
|
+
? (React.createElement(TableRow, null,
|
|
272
|
+
React.createElement(TableCell, { colSpan: 7, align: "center" },
|
|
273
|
+
React.createElement(CircularProgress, { size: 24, "aria-label": "Loading audit history" }))))
|
|
274
|
+
: props.rows.map((row) => (React.createElement(TableRow, { key: row.id },
|
|
275
|
+
React.createElement(TableCell, null, formatApiKeyDate(row.occurredAt)),
|
|
276
|
+
React.createElement(TableCell, null, row.scope),
|
|
277
|
+
React.createElement(TableCell, null, row.operation),
|
|
278
|
+
React.createElement(TableCell, null, row.transport ?? "—"),
|
|
279
|
+
React.createElement(TableCell, null,
|
|
280
|
+
React.createElement(Typography, { variant: "body2" },
|
|
281
|
+
React.createElement(IpCountry, { countryCode: row.countryCode, ipAddress: row.ipAddress })),
|
|
282
|
+
React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.userAgent ?? "")),
|
|
283
|
+
React.createElement(TableCell, null, [row.authorizationOutcome, row.operationOutcome].filter(Boolean).join(" / ")),
|
|
284
|
+
React.createElement(TableCell, null, [row.pageName, row.functionName, row.actionName].filter(Boolean).join(" · ") || "—"))))))),
|
|
285
|
+
React.createElement(TablePagination, { component: "div", count: props.count, page: props.page, rowsPerPage: props.rowsPerPage, rowsPerPageOptions: [props.rowsPerPage], onPageChange: (_event, page) => props.onPageChange(page) })));
|
|
286
|
+
}
|
|
287
|
+
export function ApiKeysManager(props) {
|
|
288
|
+
const [createOpen, setCreateOpen] = React.useState(false);
|
|
289
|
+
const [secret, setSecret] = React.useState(null);
|
|
290
|
+
return (React.createElement(Stack, { spacing: 2 },
|
|
291
|
+
React.createElement(Stack, { direction: { xs: "column", sm: "row" }, justifyContent: "space-between", alignItems: { sm: "center" }, gap: 1 },
|
|
292
|
+
React.createElement(Box, null,
|
|
293
|
+
React.createElement(Typography, { variant: "h5", component: "h1" }, "API keys"),
|
|
294
|
+
React.createElement(Typography, { color: "text.secondary" }, "Create scoped credentials for tools you trust.")),
|
|
295
|
+
React.createElement(Button, { variant: "contained", onClick: () => setCreateOpen(true), disabled: !props.onCreate }, "Create API key")),
|
|
296
|
+
props.error ? React.createElement(Alert, { severity: "error" }, props.error) : null,
|
|
297
|
+
React.createElement(ApiKeysTable, { rows: props.rows, loading: props.loading, scopes: props.scopes, extraColumns: props.extraColumns, onRename: props.onRename, onRevoke: props.onRevoke }),
|
|
298
|
+
React.createElement(ApiKeyCreateDialog, { open: createOpen, onClose: () => setCreateOpen(false), scopes: props.scopes, error: props.error, onCreate: props.onCreate ??
|
|
299
|
+
(() => Promise.reject(new Error("Key creation is unavailable."))), onCreated: setSecret }),
|
|
300
|
+
React.createElement(ApiKeySecretDialog, { open: secret !== null, result: secret, queryCredentialsEnabled: props.queryCredentialsEnabled, onClose: () => setSecret(null) })));
|
|
301
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface ApiKeyScopeDefinition {
|
|
2
|
+
description?: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
permission: {
|
|
7
|
+
action: string;
|
|
8
|
+
resource: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface ApiKeyRow {
|
|
12
|
+
createdAt: string;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
expiresAt?: string | null;
|
|
15
|
+
id: string;
|
|
16
|
+
lastUsedAt?: string | null;
|
|
17
|
+
lastUsedCountryCode?: string | null;
|
|
18
|
+
lastUsedIpAddress?: string | null;
|
|
19
|
+
lastUsedScope?: string | null;
|
|
20
|
+
name: string;
|
|
21
|
+
ownerEmail?: string;
|
|
22
|
+
ownerId?: string;
|
|
23
|
+
ownerName?: string;
|
|
24
|
+
scopes: string[];
|
|
25
|
+
start?: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface ApiKeyAuditRow {
|
|
28
|
+
actionName?: string | null;
|
|
29
|
+
authorizationOutcome?: string | null;
|
|
30
|
+
countryCode?: string | null;
|
|
31
|
+
functionName?: string | null;
|
|
32
|
+
id: string;
|
|
33
|
+
ipAddress?: string | null;
|
|
34
|
+
occurredAt: string;
|
|
35
|
+
operation: string;
|
|
36
|
+
operationOutcome?: string | null;
|
|
37
|
+
pageName?: string | null;
|
|
38
|
+
scope: string;
|
|
39
|
+
transport?: string | null;
|
|
40
|
+
userAgent?: string | null;
|
|
41
|
+
}
|
|
42
|
+
/** Converts an ISO alpha-2 country code to its Unicode regional flag. */
|
|
43
|
+
export declare function countryCodeToFlagEmoji(countryCode?: string | null): string | null;
|
|
44
|
+
/** Formats ISO date values consistently while preserving an empty state. */
|
|
45
|
+
export declare function formatApiKeyDate(value?: string | null): string;
|
|
46
|
+
export declare function getApiKeyStatus(row: ApiKeyRow, now?: number): "Revoked" | "Expired" | "Active";
|
|
47
|
+
export declare function getApiKeyVisibleColumnIds(admin?: boolean): string[];
|
|
48
|
+
//# sourceMappingURL=apiKeysView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiKeysView.d.ts","sourceRoot":"","sources":["../../../src/src/mui/apiKeysView.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,yEAAyE;AACzE,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,iBASjE;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,UAIrD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,SAAa,oCAM/D;AAED,wBAAgB,yBAAyB,CAAC,KAAK,UAAQ,YAWtD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Converts an ISO alpha-2 country code to its Unicode regional flag. */
|
|
2
|
+
export function countryCodeToFlagEmoji(countryCode) {
|
|
3
|
+
const normalized = countryCode?.trim().toUpperCase();
|
|
4
|
+
if (!normalized || !/^[A-Z]{2}$/.test(normalized))
|
|
5
|
+
return null;
|
|
6
|
+
return String.fromCodePoint(...Array.from(normalized, (character) => 0x1f1e6 + character.charCodeAt(0) - 65));
|
|
7
|
+
}
|
|
8
|
+
/** Formats ISO date values consistently while preserving an empty state. */
|
|
9
|
+
export function formatApiKeyDate(value) {
|
|
10
|
+
if (!value)
|
|
11
|
+
return "Never";
|
|
12
|
+
const date = new Date(value);
|
|
13
|
+
return Number.isNaN(date.valueOf()) ? value : date.toLocaleString();
|
|
14
|
+
}
|
|
15
|
+
export function getApiKeyStatus(row, now = Date.now()) {
|
|
16
|
+
if (!row.enabled)
|
|
17
|
+
return "Revoked";
|
|
18
|
+
if (row.expiresAt && new Date(row.expiresAt).valueOf() <= now) {
|
|
19
|
+
return "Expired";
|
|
20
|
+
}
|
|
21
|
+
return "Active";
|
|
22
|
+
}
|
|
23
|
+
export function getApiKeyVisibleColumnIds(admin = false) {
|
|
24
|
+
return [
|
|
25
|
+
...(admin ? ["owner"] : []),
|
|
26
|
+
"name",
|
|
27
|
+
"status",
|
|
28
|
+
"scopes",
|
|
29
|
+
"created",
|
|
30
|
+
"expires",
|
|
31
|
+
"lastUsed",
|
|
32
|
+
"actions",
|
|
33
|
+
];
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface ConfirmOptions {
|
|
3
|
+
cancel?: ReactNode;
|
|
4
|
+
ok?: ReactNode;
|
|
5
|
+
text: ReactNode;
|
|
6
|
+
title?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function asyncConfirm(text: string): Promise<boolean>;
|
|
9
|
+
export declare function asyncConfirm(options: ConfirmOptions): Promise<boolean>;
|
|
10
|
+
export declare function ConfirmDialog(): any;
|
|
11
|
+
export default asyncConfirm;
|
|
12
|
+
//# sourceMappingURL=confirm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.d.ts","sourceRoot":"","sources":["../../../src/src/mui/confirm.tsx"],"names":[],"mappings":"AAQA,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AA4DD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC7D,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAaxE,wBAAgB,aAAa,QA+C5B;AAED,eAAe,YAAY,CAAC"}
|