@ebay-dt/bonfire-next 0.1.0-alpha.0 → 0.1.0-alpha.2

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.
Files changed (45) hide show
  1. package/README.md +254 -31
  2. package/dist/client/index.d.ts.map +1 -1
  3. package/dist/client/index.js.map +1 -1
  4. package/dist/client/lifecycle-provider.d.ts +2 -1
  5. package/dist/client/lifecycle-provider.d.ts.map +1 -1
  6. package/dist/client/lifecycle-provider.js +5 -7
  7. package/dist/client/lifecycle-provider.js.map +1 -1
  8. package/dist/server/agent-actions.d.ts +13 -0
  9. package/dist/server/agent-actions.d.ts.map +1 -0
  10. package/dist/server/agent-actions.js +80 -0
  11. package/dist/server/agent-actions.js.map +1 -0
  12. package/dist/server/auth-boundary.d.ts +1 -0
  13. package/dist/server/auth-boundary.d.ts.map +1 -1
  14. package/dist/server/auth-boundary.js +10 -3
  15. package/dist/server/auth-boundary.js.map +1 -1
  16. package/dist/server/auth-routes.d.ts.map +1 -1
  17. package/dist/server/auth-routes.js.map +1 -1
  18. package/dist/server/create-bonfire-next.d.ts +12 -1
  19. package/dist/server/create-bonfire-next.d.ts.map +1 -1
  20. package/dist/server/create-bonfire-next.js +41 -1
  21. package/dist/server/create-bonfire-next.js.map +1 -1
  22. package/dist/server/index.d.ts +4 -1
  23. package/dist/server/index.d.ts.map +1 -1
  24. package/dist/server/index.js +1 -0
  25. package/dist/server/index.js.map +1 -1
  26. package/dist/server/login-page-model.d.ts.map +1 -1
  27. package/dist/server/login-page-model.js.map +1 -1
  28. package/dist/server/prototype-actions.d.ts +7 -3
  29. package/dist/server/prototype-actions.d.ts.map +1 -1
  30. package/dist/server/prototype-actions.js +84 -5
  31. package/dist/server/prototype-actions.js.map +1 -1
  32. package/dist/server/prototype-dashboard.d.ts +2 -1
  33. package/dist/server/prototype-dashboard.d.ts.map +1 -1
  34. package/dist/server/prototype-dashboard.js +3 -0
  35. package/dist/server/prototype-dashboard.js.map +1 -1
  36. package/dist/server/prototype-environment.d.ts +18 -0
  37. package/dist/server/prototype-environment.d.ts.map +1 -0
  38. package/dist/server/prototype-environment.js +67 -0
  39. package/dist/server/prototype-environment.js.map +1 -0
  40. package/dist/server/prototype-routes.d.ts.map +1 -1
  41. package/dist/server/prototype-routes.js +9 -4
  42. package/dist/server/prototype-routes.js.map +1 -1
  43. package/dist/server/session.d.ts.map +1 -1
  44. package/dist/server/session.js.map +1 -1
  45. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"auth-boundary.js","sourceRoot":"","sources":["../../src/server/auth-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,SAAS,UAAU,CAAC,QAAgB;IAClC,OAAO,CACL,QAAQ,KAAK,QAAQ;QACrB,QAAQ,KAAK,OAAO;QACpB,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAyB;IACvD,MAAM,UAAU,GAAG,oBAAoB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEvD,OAAO,KAAK,UAAU,SAAS,CAAC,OAAoB;QAClD,IAAI,OAAO,CAAC,UAAU;YAAE,OAAO,YAAY,CAAC,IAAI,EAAE,CAAC;QACnD,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,YAAY,CAAC,IAAI,EAAE,CAAC;QAErE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;QACrD,MAAM,QAAQ,GACZ,KAAK,IAAI,OAAO,CAAC,aAAa;YAC5B,CAAC,CAAC,MAAM,aAAa,CAAC,KAAK,EAAE,OAA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OAAO,IAAI,EAAE,CAAC;QACtC,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,IAAI,EAAE,CAAC;QAExD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;QACrD,MAAM,QAAQ,GACZ,KAAK,IAAI,OAAO,CAAC,aAAa;YAC5B,CAAC,CAAC,MAAM,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC;YACnD,CAAC,CAAC,IAAI,CAAC;QACX,IAAI,QAAQ;YAAE,OAAO,IAAI,EAAE,CAAC;QAE5B,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { getSessionCookieName } from \"@ebay-dt/bonfire-core\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\nimport { verifySession } from \"./session.js\";\n\nexport type AuthProxyOptions = {\n appId: string;\n sessionSecret: string | undefined;\n production: boolean;\n};\n\nfunction isAuthPath(pathname: string): boolean {\n return (\n pathname === \"/login\" ||\n pathname === \"/auth\" ||\n pathname.startsWith(\"/auth/\")\n );\n}\n\nexport const BONFIRE_PATHNAME_HEADER = \"x-bonfire-pathname\";\n\nexport function createAuthProxy(options: AuthProxyOptions) {\n const cookieName = getSessionCookieName(options.appId);\n\n return async function authProxy(request: NextRequest) {\n // Forwarded so the shared prototype route-group layout can resolve the\n // active prototype's theme policy server-side without duplicating catalog\n // lookup in the host.\n const forwardedHeaders = new Headers(request.headers);\n forwardedHeaders.set(BONFIRE_PATHNAME_HEADER, request.nextUrl.pathname);\n const next = () =>\n NextResponse.next({ request: { headers: forwardedHeaders } });\n\n if (options.production) return next();\n if (isAuthPath(request.nextUrl.pathname)) return next();\n\n const token = request.cookies.get(cookieName)?.value;\n const identity =\n token && options.sessionSecret\n ? await verifySession(token, options.sessionSecret)\n : null;\n if (identity) return next();\n\n return NextResponse.redirect(new URL(\"/login\", request.url));\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"auth-routes.d.ts","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,aAAa,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE,CAChB,QAAQ,EAAE,eAAe,KACtB,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAC;CACvD,CAAC;AAqCF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB;qBAC1B,WAAW;;sBAqEV,WAAW;EAM3C"}
1
+ {"version":3,"file":"auth-routes.d.ts","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,aAAa,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE,CAChB,QAAQ,EAAE,eAAe,KACtB,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAC;CACvD,CAAC;AAqCF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB;qBAC1B,WAAW;;sBAqEV,WAAW;EAM3C","sourcesContent":["import {\n lifecycleFailure,\n lifecycleSuccess,\n type BranchPreparationValue,\n type LifecycleResult,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliError,\n type GitHubCliClientLike,\n} from \"@ebay-dt/bonfire-node\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\n\nexport type AuthRouteOptions = {\n production: boolean;\n githubCli: GitHubCliClientLike;\n createSession: (identity: BonfireIdentity) => Promise<void>;\n clearSession: () => Promise<void>;\n prepareIdentity?: (\n identity: BonfireIdentity,\n ) => Promise<LifecycleResult<BranchPreparationValue>>;\n};\n\nfunction notFound() {\n return new NextResponse(null, { status: 404 });\n}\n\nfunction redirect(request: NextRequest, path: string, status = 307) {\n return NextResponse.redirect(new URL(path, request.url), status);\n}\n\nfunction logLoginFailure(message: string) {\n console.error(`Bonfire GitHub CLI login failed: ${message}`);\n}\n\nfunction logBranchPreparationFailure() {\n console.error(\"Bonfire branch preparation failed.\");\n}\n\nasync function prepareIdentity(\n options: AuthRouteOptions,\n identity: BonfireIdentity,\n) {\n try {\n return (\n (await options.prepareIdentity?.(identity)) ??\n lifecycleSuccess({ status: \"disabled\" } satisfies BranchPreparationValue)\n );\n } catch {\n return lifecycleFailure(\"unexpected-failure\");\n }\n}\n\nfunction branchPreparationFailed(request: NextRequest): NextResponse {\n logBranchPreparationFailure();\n return redirect(request, \"/login?error=branch_prepare_failed\");\n}\n\nexport function createAuthRoutes(options: AuthRouteOptions) {\n async function login(request: NextRequest) {\n if (options.production) return notFound();\n\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n error.reason === \"unauthenticated\"\n ) {\n try {\n const webLogin = await options.githubCli.startWebLogin();\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"auth\", \"started\");\n if (webLogin.code) loginUrl.searchParams.set(\"code\", webLogin.code);\n return NextResponse.redirect(loginUrl);\n } catch {\n logLoginFailure(\"device login could not be started\");\n }\n }\n\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) return branchPreparationFailed(request);\n\n try {\n await options.createSession(user);\n return redirect(request, \"/\");\n } catch {\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n }\n\n async function status() {\n const response = options.production\n ? notFound()\n : await (async () => {\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) {\n logBranchPreparationFailure();\n return NextResponse.json({\n authenticated: false,\n error: \"branch_prepare_failed\" as const,\n });\n }\n\n try {\n await options.createSession(user);\n return NextResponse.json({ authenticated: true });\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n })();\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n\n async function logout(request: NextRequest) {\n await options.clearSession();\n return redirect(request, options.production ? \"/\" : \"/login\", 303);\n }\n\n return { login, status, logout };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"auth-routes.js","sour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gBACpD,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;QACT,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAClD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,UAAU,MAAM,CAAC,OAAoB;QACxC,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC;QAC7B,OAAO,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import {\n lifecycleFailure,\n lifecycleSuccess,\n type BranchPreparationValue,\n type LifecycleResult,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliError,\n type GitHubCliClientLike,\n} from \"@ebay-dt/bonfire-node\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\n\nexport type AuthRouteOptions = {\n production: boolean;\n githubCli: GitHubCliClientLike;\n createSession: (identity: BonfireIdentity) => Promise<void>;\n clearSession: () => Promise<void>;\n prepareIdentity?: (\n identity: BonfireIdentity,\n ) => Promise<LifecycleResult<BranchPreparationValue>>;\n};\n\nfunction notFound() {\n return new NextResponse(null, { status: 404 });\n}\n\nfunction redirect(request: NextRequest, path: string, status = 307) {\n return NextResponse.redirect(new URL(path, request.url), status);\n}\n\nfunction logLoginFailure(message: string) {\n console.error(`Bonfire GitHub CLI login failed: ${message}`);\n}\n\nfunction logBranchPreparationFailure() {\n console.error(\"Bonfire branch preparation failed.\");\n}\n\nasync function prepareIdentity(\n options: AuthRouteOptions,\n identity: BonfireIdentity,\n) {\n try {\n return (\n (await options.prepareIdentity?.(identity)) ??\n lifecycleSuccess({ status: \"disabled\" } satisfies BranchPreparationValue)\n );\n } catch {\n return lifecycleFailure(\"unexpected-failure\");\n }\n}\n\nfunction branchPreparationFailed(request: NextRequest): NextResponse {\n logBranchPreparationFailure();\n return redirect(request, \"/login?error=branch_prepare_failed\");\n}\n\nexport function createAuthRoutes(options: AuthRouteOptions) {\n async function login(request: NextRequest) {\n if (options.production) return notFound();\n\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n error.reason === \"unauthenticated\"\n ) {\n try {\n const webLogin = await options.githubCli.startWebLogin();\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"auth\", \"started\");\n if (webLogin.code) loginUrl.searchParams.set(\"code\", webLogin.code);\n return NextResponse.redirect(loginUrl);\n } catch {\n logLoginFailure(\"device login could not be started\");\n }\n }\n\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) return branchPreparationFailed(request);\n\n try {\n await options.createSession(user);\n return redirect(request, \"/\");\n } catch {\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n }\n\n async function status() {\n const response = options.production\n ? notFound()\n : await (async () => {\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) {\n logBranchPreparationFailure();\n return NextResponse.json({\n authenticated: false,\n error: \"branch_prepare_failed\" as const,\n });\n }\n\n try {\n await options.createSession(user);\n return NextResponse.json({ authenticated: true });\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n })();\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n\n async function logout(request: NextRequest) {\n await options.clearSession();\n return redirect(request, options.production ? \"/\" : \"/login\", 303);\n }\n\n return { login, status, logout };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type BonfireConfigInput, type BonfireIdentity } from "@ebay-dt/bonfire-core";
2
- import { type GitHubCliClientLike, type PreparePrototypeFiles, type PrototypeCatalogLike, type PrototypeLifecycle } from "@ebay-dt/bonfire-node";
2
+ import { type DeploymentProvider, type GitHubCliClientLike, type PreparePrototypeFiles, type PrototypeAgentServiceLike, type PrototypeCatalogLike, type PrototypeLifecycle } from "@ebay-dt/bonfire-node";
3
3
  import type { PrototypeWatcher } from "@ebay-dt/bonfire-node/watcher";
4
4
  import { type CSSProperties } from "react";
5
5
  import { type LoginSearchParams } from "./login-page-model.js";
@@ -11,11 +11,16 @@ export type CreateBonfireNextOptions = {
11
11
  sessionSecret?: string;
12
12
  githubCli?: GitHubCliClientLike;
13
13
  prototypeCatalog?: PrototypeCatalogLike;
14
+ prototypeAgents?: PrototypeAgentServiceLike;
14
15
  prototypeLifecycle?: PrototypeLifecycle;
16
+ deploymentProvider?: DeploymentProvider;
15
17
  prototypeWatcher?: PrototypeWatcher;
16
18
  preparePrototypeFiles?: PreparePrototypeFiles;
17
19
  disableAutoBranchSwitch?: string;
18
20
  };
21
+ export type PrototypeCapabilities = {
22
+ deployment: boolean;
23
+ };
19
24
  type AppLayoutModel = {
20
25
  htmlProps: {
21
26
  style: CSSProperties;
@@ -28,9 +33,15 @@ type AppLayoutModel = {
28
33
  export declare function createBonfireNext(options: CreateBonfireNextOptions): {
29
34
  prototypes: {
30
35
  getDashboardModel: (searchParams?: Promise<import("./prototype-dashboard.js").PrototypeDashboardSearchParams> | import("./prototype-dashboard.js").PrototypeDashboardSearchParams | undefined) => Promise<import("@ebay-dt/bonfire-core").PrototypeDashboardModel>;
36
+ getRouteModel: (input: import("@ebay-dt/bonfire-core").PrototypeRef) => Promise<import("./prototype-environment.js").PrototypeRouteModel | null>;
37
+ getCurrentRouteModel: () => Promise<import("./prototype-environment.js").PrototypeRouteModel | null>;
31
38
  getSummary: (ref: import("@ebay-dt/bonfire-core").PrototypeRef) => Promise<import("@ebay-dt/bonfire-core").PrototypeSummary | null>;
39
+ capabilities: {
40
+ deployment: boolean;
41
+ };
32
42
  lifecycle: PrototypeLifecycle | null;
33
43
  actions: import("./prototype-actions.js").PrototypeActions;
44
+ agents: import("./agent-actions.js").PrototypeAgentActions;
34
45
  routes: import("./prototype-routes.js").PrototypeRoutes;
35
46
  };
36
47
  auth: {
@@ -1 +1 @@
1
- {"version":3,"file":"create-bonfire-next.d.ts","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAS,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAM/B,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,KAAK,c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C;IACxC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,SAAS,EAAE;QACT,KAAK,EAAE,aAAa,CAAC;KACtB,CAAC;IACF,WAAW,EAAE;QACX,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;KAC9B,CAAC;CACH,CAAC;AAQF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;iCAoHvB,OAAO,CAAC,cAAc,CAAC;2CAgBhD,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;EA8ChE","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n lifecycleSuccess,\n parseAutomaticBranchSwitchSetting,\n type BranchPreparationValue,\n type BonfireConfigInput,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\n\nexport type CreateBonfireNextOptions = {\n config: BonfireConfigInput;\n repositoryRoot: string;\n prototypeRoot?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"2.5rem\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const config = defineConfig(options.config);\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch: options.primaryBranch,\n automaticBranchSwitch,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prepareIdentity = production\n ? undefined\n : automaticBranchSwitch === \"enabled\" && lifecycle\n ? lifecycle.prepareBranch.bind(lifecycle)\n : async () =>\n lifecycleSuccess({\n status: \"disabled\",\n } satisfies BranchPreparationValue);\n const prototypeActions = createPrototypeActions({\n production,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n prepareIdentity,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n agents: prototypeAgentActions,\n routes: prototypeRoutes,\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
@@ -1,19 +1,24 @@
1
1
  import { join, resolve } from "node:path";
2
2
  import { defineConfig, lifecycleSuccess, parseAutomaticBranchSwitchSetting, } from "@ebay-dt/bonfire-core";
3
- import { GitHubCliClient, LocalPrototypeLifecycle, PrototypeCatalog, } from "@ebay-dt/bonfire-node";
3
+ import { GitHubCliClient, LocalPrototypeLifecycle, PrototypeAgentService, PrototypeCatalog, resolvePrototypeCatalogPaths, } from "@ebay-dt/bonfire-node";
4
4
  import { cache } from "react";
5
5
  import { createAuthProxy } from "./auth-boundary.js";
6
6
  import { createAuthRoutes } from "./auth-routes.js";
7
7
  import { createLoginPageModel, getLoginPageSearchParams, } from "./login-page-model.js";
8
8
  import { createSessionAdapter } from "./session.js";
9
9
  import { createPrototypeActions } from "./prototype-actions.js";
10
+ import { createPrototypeAgentActions } from "./agent-actions.js";
10
11
  import { createPrototypeDashboardModelLoader } from "./prototype-dashboard.js";
12
+ import { createPrototypeEnvironmentModelLoader } from "./prototype-environment.js";
11
13
  import { createPrototypeRoutes } from "./prototype-routes.js";
12
14
  const APP_HEADER_BLOCK_SIZE_PROPERTY = "--app-header-block-size";
13
15
  const APP_HEADER_PRESENT_BLOCK_SIZE = "2.5rem";
14
16
  export function createBonfireNext(options) {
15
17
  const config = defineConfig(options.config);
16
18
  const production = process.env.NODE_ENV === "production";
19
+ if (options.prototypeLifecycle && options.deploymentProvider) {
20
+ throw new Error("prototypeLifecycle and deploymentProvider cannot be supplied together");
21
+ }
17
22
  if (options.prototypeLifecycle && options.preparePrototypeFiles) {
18
23
  throw new Error("prototypeLifecycle and preparePrototypeFiles cannot be supplied together");
19
24
  }
@@ -30,6 +35,7 @@ export function createBonfireNext(options) {
30
35
  new PrototypeCatalog({
31
36
  repositoryRoot: options.repositoryRoot,
32
37
  prototypeRoot: options.prototypeRoot,
38
+ themeRegistry: config.themes,
33
39
  });
34
40
  const lifecycle = options.prototypeLifecycle ??
35
41
  (production
@@ -39,9 +45,15 @@ export function createBonfireNext(options) {
39
45
  prototypeRoot: options.prototypeRoot,
40
46
  primaryBranch: options.primaryBranch,
41
47
  automaticBranchSwitch,
48
+ applicationId: config.appId,
42
49
  catalog: prototypeCatalog,
50
+ deploymentProvider: options.deploymentProvider,
43
51
  preparePrototypeFiles: options.preparePrototypeFiles,
52
+ themeRegistry: config.themes,
44
53
  }));
54
+ const deploymentAvailable = !production &&
55
+ (options.deploymentProvider !== undefined ||
56
+ options.prototypeLifecycle?.deploy !== undefined);
45
57
  const getCurrentUser = cache(() => getSession());
46
58
  const prepareIdentity = production
47
59
  ? undefined
@@ -54,6 +66,22 @@ export function createBonfireNext(options) {
54
66
  production,
55
67
  getCurrentUser: getSession,
56
68
  lifecycle,
69
+ themeRegistry: config.themes,
70
+ });
71
+ const prototypeAgents = production
72
+ ? null
73
+ : (options.prototypeAgents ??
74
+ new PrototypeAgentService({
75
+ runtime: resolvePrototypeCatalogPaths({
76
+ repositoryRoot: options.repositoryRoot,
77
+ prototypeRoot: options.prototypeRoot,
78
+ }),
79
+ catalog: prototypeCatalog,
80
+ }));
81
+ const prototypeAgentActions = createPrototypeAgentActions({
82
+ production,
83
+ getCurrentUser: getSession,
84
+ agents: prototypeAgents,
57
85
  });
58
86
  let prototypeWatcher = options.prototypeWatcher;
59
87
  const getWatcher = async () => {
@@ -79,7 +107,13 @@ export function createBonfireNext(options) {
79
107
  production,
80
108
  catalog: prototypeCatalog,
81
109
  getCurrentUser,
110
+ themeRegistry: config.themes,
111
+ });
112
+ const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } = createPrototypeEnvironmentModelLoader({
113
+ catalog: prototypeCatalog,
114
+ themeRegistry: config.themes,
82
115
  });
116
+ const getCurrentRouteModel = cache(getCurrentRouteModelUncached);
83
117
  const getAppLayoutModel = cache(async () => {
84
118
  const user = production ? null : await getCurrentUser();
85
119
  const style = {
@@ -119,9 +153,15 @@ export function createBonfireNext(options) {
119
153
  return {
120
154
  prototypes: {
121
155
  getDashboardModel,
156
+ getRouteModel,
157
+ getCurrentRouteModel,
122
158
  getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),
159
+ capabilities: {
160
+ deployment: deploymentAvailable,
161
+ },
123
162
  lifecycle,
124
163
  actions: prototypeActions,
164
+ agents: prototypeAgentActions,
125
165
  routes: prototypeRoutes,
126
166
  },
127
167
  auth: {
@@ -1 +1 @@
1
- {"version":3,"file":"create-bonfire-next.js","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,iCAAiC,GAIlC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,gBAAgB,GAKjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AA6B9D,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;AACjE,MAAM,6BAA6B,GAAG,QAAQ,CAAC;AAE/C,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IACjE,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IACzD,IAAI,OAAO,CAAC,kBAAkB,IAAI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Config,\n lifecycleSuccess,\n parseAutomaticBranchSwitchSetting,\n type BranchPreparationValue,\n type BonfireConfigInput,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\n\nexport type CreateBonfireNextOptions = {\n config: BonfireConfigInput;\n repositoryRoot: string;\n prototypeRoot?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"2.5rem\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const config = defineConfig(options.config);\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch: options.primaryBranch,\n automaticBranchSwitch,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prepareIdentity = production\n ? undefined\n : automaticBranchSwitch === \"enabled\" && lifecycle\n ? lifecycle.prepareBranch.bind(lifecycle)\n : async () =>\n lifecycleSuccess({\n status: \"disabled\",\n } satisfies BranchPreparationValue);\n const prototypeActions = createPrototypeActions({\n production,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n prepareIdentity,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n agents: prototypeAgentActions,\n routes: prototypeRoutes,\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
@@ -1,4 +1,7 @@
1
- export { createBonfireNext, type CreateBonfireNextOptions, } from "./create-bonfire-next.js";
1
+ export { createBonfireNext, type CreateBonfireNextOptions, type PrototypeCapabilities, } from "./create-bonfire-next.js";
2
+ export { createDeploymentProvider, DeploymentProviderError, type CreateDeploymentProviderOptions, type DeploymentProvider, type DeploymentProviderErrorKind, type DeploymentProviderResult, } from "@ebay-dt/bonfire-node";
2
3
  export type { PrototypeActions } from "./prototype-actions.js";
4
+ export type { PrototypeAgentActions } from "./agent-actions.js";
3
5
  export type { PrototypeRoutes } from "./prototype-routes.js";
6
+ export type { PrototypeRouteModel } from "./prototype-environment.js";
4
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["export {\n createBonfireNext,\n type CreateBonfireNextOptions,\n type PrototypeCapabilities,\n} from \"./create-bonfire-next.js\";\nexport {\n createDeploymentProvider,\n DeploymentProviderError,\n type CreateDeploymentProviderOptions,\n type DeploymentProvider,\n type DeploymentProviderErrorKind,\n type DeploymentProviderResult,\n} from \"@ebay-dt/bonfire-node\";\nexport type { PrototypeActions } from \"./prototype-actions.js\";\nexport type { PrototypeAgentActions } from \"./agent-actions.js\";\nexport type { PrototypeRoutes } from \"./prototype-routes.js\";\nexport type { PrototypeRouteModel } from \"./prototype-environment.js\";\n"]}
@@ -1,2 +1,3 @@
1
1
  export { createBonfireNext, } from "./create-bonfire-next.js";
2
+ export { createDeploymentProvider, DeploymentProviderError, } from "@ebay-dt/bonfire-node";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAElB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GAKxB,MAAM,uBAAuB,CAAC","sourcesContent":["export {\n createBonfireNext,\n type CreateBonfireNextOptions,\n type PrototypeCapabilities,\n} from \"./create-bonfire-next.js\";\nexport {\n createDeploymentProvider,\n DeploymentProviderError,\n type CreateDeploymentProviderOptions,\n type DeploymentProvider,\n type DeploymentProviderErrorKind,\n type DeploymentProviderResult,\n} from \"@ebay-dt/bonfire-node\";\nexport type { PrototypeActions } from \"./prototype-actions.js\";\nexport type { PrototypeAgentActions } from \"./agent-actions.js\";\nexport type { PrototypeRoutes } from \"./prototype-routes.js\";\nexport type { PrototypeRouteModel } from \"./prototype-environment.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"login-page-model.d.ts","sourceRoot":"","sources":["../../src/server/login-page-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAQ9E,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,YAAY,CAAC,EAAE,iBAAiB;;;;;;;;;;;EAuBjC;AAED,wBAAsB,wBAAwB,CAC5C,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,8BAG9D"}
1
+ {"version":3,"file":"login-page-model.d.ts","sourceRoot":"","sources":["../../src/server/login-page-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAQ9E,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,YAAY,CAAC,EAAE,iBAAiB;;;;;;;;;;;EAuBjC;AAED,wBAAsB,wBAAwB,CAC5C,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,8BAG9D","sourcesContent":["import type {\n GitHubCliLoginPageModel,\n BonfireConfig,\n} from \"@ebay-dt/bonfire-core\";\n\nexport type LoginSearchParams = Record<string, string | string[] | undefined>;\n\nconst DEVICE_CODE_PATTERN = /^[A-Za-z0-9-]{1,64}$/;\n\nfunction singleValue(value: string | string[] | undefined) {\n return typeof value === \"string\" ? value : null;\n}\n\nexport function createLoginPageModel(\n config: BonfireConfig,\n searchParams?: LoginSearchParams,\n) {\n const auth = singleValue(searchParams?.auth);\n const error = singleValue(searchParams?.error);\n const code = singleValue(searchParams?.code);\n const pollingActive = auth === \"started\";\n\n return {\n applicationName: config.name,\n githubHostname: config.auth.github.hostname,\n loginUrl: \"/auth/login\",\n statusUrl: \"/auth/status\",\n returnUrl: \"/\",\n deviceUrl: `https://${config.auth.github.hostname}/login/device`,\n fallbackCommand: `gh auth login --hostname ${config.auth.github.hostname}`,\n deviceCode:\n pollingActive && code && DEVICE_CODE_PATTERN.test(code) ? code : null,\n pollingActive,\n error:\n error === \"gh_cli_failed\" || error === \"branch_prepare_failed\"\n ? error\n : null,\n } satisfies GitHubCliLoginPageModel;\n}\n\nexport async function getLoginPageSearchParams(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n) {\n return (await searchParams) ?? {};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"login-page-model.js","sourceRoot":"","sources":["../../src/server/login-page-model.ts"],"names":[],"mappings":"AAOA,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAEnD,SAAS,WAAW,CAAC,KAAoC;IACvD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAqB,E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AClD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAqB,EACrB,YAAgC;IAEhC,MAAM,IAAI,GAAG,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC7C,MAAM,aAAa,GAAG,IAAI,KAAK,SAAS,CAAC;IAEzC,OAAO;QACL,eAAe,EAAE,MAAM,CAAC,IAAI;QAC5B,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ;QAC3C,QAAQ,EAAE,aAAa;QACvB,SAAS,EAAE,cAAc;QACzB,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,WAAW,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,eAAe;QAChE,eAAe,EAAE,4BAA4B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QAC1E,UAAU,EACR,aAAa,IAAI,IAAI,IAAI,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;QACvE,aAAa;QACb,KAAK,EACH,KAAK,KAAK,eAAe,IAAI,KAAK,KAAK,uBAAuB;YAC5D,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI;KACuB,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,YAA6D;IAE7D,OAAO,CAAC,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import type {\n GitHubCliLoginPageModel,\n BonfireConfig,\n} from \"@ebay-dt/bonfire-core\";\n\nexport type LoginSearchParams = Record<string, string | string[] | undefined>;\n\nconst DEVICE_CODE_PATTERN = /^[A-Za-z0-9-]{1,64}$/;\n\nfunction singleValue(value: string | string[] | undefined) {\n return typeof value === \"string\" ? value : null;\n}\n\nexport function createLoginPageModel(\n config: BonfireConfig,\n searchParams?: LoginSearchParams,\n) {\n const auth = singleValue(searchParams?.auth);\n const error = singleValue(searchParams?.error);\n const code = singleValue(searchParams?.code);\n const pollingActive = auth === \"started\";\n\n return {\n applicationName: config.name,\n githubHostname: config.auth.github.hostname,\n loginUrl: \"/auth/login\",\n statusUrl: \"/auth/status\",\n returnUrl: \"/\",\n deviceUrl: `https://${config.auth.github.hostname}/login/device`,\n fallbackCommand: `gh auth login --hostname ${config.auth.github.hostname}`,\n deviceCode:\n pollingActive && code && DEVICE_CODE_PATTERN.test(code) ? code : null,\n pollingActive,\n error:\n error === \"gh_cli_failed\" || error === \"branch_prepare_failed\"\n ? error\n : null,\n } satisfies GitHubCliLoginPageModel;\n}\n\nexport async function getLoginPageSearchParams(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n) {\n return (await searchParams) ?? {};\n}\n"]}
@@ -1,15 +1,19 @@
1
- import { type CreatePrototypeInput, type CreatePrototypeValue, type DiscardPrototypeInput, type DiscardPrototypeValue, type DuplicatePrototypeInput, type DuplicatePrototypeValue, type LifecycleResult, type SavePrototypeInput, type SavePrototypeValue, type BonfireIdentity } from "@ebay-dt/bonfire-core";
1
+ import { type CreatePrototypeInput, type CreatePrototypeValue, type DeletePrototypeValue, type DeploymentValue, type DiscardPrototypeValue, type DuplicatePrototypeInput, type DuplicatePrototypeValue, type EditPrototypeInput, type EditPrototypeValue, type LifecycleResult, type PrototypeCommandInput, type SavePrototypeValue, type BonfireIdentity, type ThemeRegistry } from "@ebay-dt/bonfire-core";
2
2
  import type { PrototypeLifecycle } from "@ebay-dt/bonfire-node";
3
3
  export type PrototypeActions = {
4
4
  create(input: CreatePrototypeInput): Promise<LifecycleResult<CreatePrototypeValue>>;
5
5
  duplicate(input: DuplicatePrototypeInput): Promise<LifecycleResult<DuplicatePrototypeValue>>;
6
- save(input: SavePrototypeInput): Promise<LifecycleResult<SavePrototypeValue>>;
7
- discard(input: DiscardPrototypeInput): Promise<LifecycleResult<DiscardPrototypeValue>>;
6
+ edit(input: EditPrototypeInput): Promise<LifecycleResult<EditPrototypeValue>>;
7
+ delete(input: PrototypeCommandInput): Promise<LifecycleResult<DeletePrototypeValue>>;
8
+ save(input: PrototypeCommandInput): Promise<LifecycleResult<SavePrototypeValue>>;
9
+ discard(input: PrototypeCommandInput): Promise<LifecycleResult<DiscardPrototypeValue>>;
10
+ deploy(input: PrototypeCommandInput): Promise<LifecycleResult<DeploymentValue>>;
8
11
  };
9
12
  export type PrototypeActionsOptions = {
10
13
  production: boolean;
11
14
  getCurrentUser: () => Promise<BonfireIdentity | null>;
12
15
  lifecycle: PrototypeLifecycle | null;
16
+ themeRegistry?: ThemeRegistry;
13
17
  };
14
18
  export declare function createPrototypeActions(options: PrototypeActionsOptions): PrototypeActions;
15
19
  //# sourceMappingURL=prototype-actions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prototype-actions.d.ts","sourceRoot":"","sources":["../../src/server/prototype-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CACJ,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAClD,SAAS,CACP,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,kBAAkB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K,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAClD,IAAI,CACF,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAChD,OAAO,CACL,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAAC;IACnD,MAAM,CACJ,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACtD,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACrC,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AASF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CAwLlB","sourcesContent":["import {\n lifecycleFailure,\n parseCreatePrototypeInput,\n parseDuplicatePrototypeInput,\n parseEditPrototypeInput,\n parsePrototypeCommandInput,\n LifecycleInputError,\n type CreatePrototypeInput,\n type CreatePrototypeValue,\n type DeletePrototypeValue,\n type DeploymentValue,\n type DiscardPrototypeValue,\n type DuplicatePrototypeInput,\n type DuplicatePrototypeValue,\n type EditPrototypeInput,\n type EditPrototypeValue,\n type LifecycleResult,\n type PrototypeCommandInput,\n type SavePrototypeValue,\n type BonfireIdentity,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycle } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeActions = {\n create(\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>>;\n duplicate(\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>>;\n edit(input: EditPrototypeInput): Promise<LifecycleResult<EditPrototypeValue>>;\n delete(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>>;\n save(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>>;\n discard(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>>;\n deploy(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>>;\n};\n\nexport type PrototypeActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n lifecycle: PrototypeLifecycle | null;\n themeRegistry?: ThemeRegistry;\n};\n\nfunction logUnexpectedFailure(\n operation:\n \"create\" | \"duplicate\" | \"edit\" | \"delete\" | \"save\" | \"discard\" | \"deploy\",\n) {\n console.error(`Bonfire prototype ${operation} failed unexpectedly.`);\n}\n\nexport function createPrototypeActions(\n options: PrototypeActionsOptions,\n): PrototypeActions {\n async function create(\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.create(\n identity,\n parseCreatePrototypeInput(input, options.themeRegistry),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"create\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function duplicate(\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.duplicate(\n identity,\n parseDuplicatePrototypeInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"duplicate\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function edit(\n input: EditPrototypeInput,\n ): Promise<LifecycleResult<EditPrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.edit(\n identity,\n parseEditPrototypeInput(input, options.themeRegistry),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"edit\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function deletePrototype(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.delete(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"delete\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function save(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.save(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"save\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function discard(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.discard(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"discard\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function deploy(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>> {\n if (options.production) return lifecycleFailure(\"forbidden\");\n\n let parsedInput: PrototypeCommandInput;\n try {\n parsedInput = parsePrototypeCommandInput(input);\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"deployment-failure\");\n }\n if (options.lifecycle === null) {\n return lifecycleFailure(\"deployment-unavailable\");\n }\n\n let identity: BonfireIdentity | null;\n try {\n identity = await options.getCurrentUser();\n } catch {\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n\n try {\n return await options.lifecycle.deploy(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"deployment-failure\");\n }\n }\n\n return {\n create,\n duplicate,\n edit,\n delete: deletePrototype,\n save,\n discard,\n deploy,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { lifecycleFailure, parseCreatePrototypeInput, parseDiscardPrototypeInput, parseDuplicatePrototypeInput, parseSavePrototypeInput, LifecycleInputError, } from "@ebay-dt/bonfire-core";
1
+ import { lifecycleFailure, parseCreatePrototypeInput, parseDuplicatePrototypeInput, parseEditPrototypeInput, parsePrototypeCommandInput, LifecycleInputError, } from "@ebay-dt/bonfire-core";
2
2
  function logUnexpectedFailure(operation) {
3
3
  console.error(`Bonfire prototype ${operation} failed unexpectedly.`);
4
4
  }
@@ -11,7 +11,7 @@ export function createPrototypeActions(options) {
11
11
  const identity = await options.getCurrentUser();
12
12
  if (identity === null)
13
13
  return lifecycleFailure("unauthenticated");
14
- return await options.lifecycle.create(identity, parseCreatePrototypeInput(input));
14
+ return await options.lifecycle.create(identity, parseCreatePrototypeInput(input, options.themeRegistry));
15
15
  }
16
16
  catch (error) {
17
17
  if (error instanceof LifecycleInputError) {
@@ -39,6 +39,42 @@ export function createPrototypeActions(options) {
39
39
  return lifecycleFailure("unexpected-failure");
40
40
  }
41
41
  }
42
+ async function edit(input) {
43
+ if (options.production || options.lifecycle === null) {
44
+ return lifecycleFailure("forbidden");
45
+ }
46
+ try {
47
+ const identity = await options.getCurrentUser();
48
+ if (identity === null)
49
+ return lifecycleFailure("unauthenticated");
50
+ return await options.lifecycle.edit(identity, parseEditPrototypeInput(input, options.themeRegistry));
51
+ }
52
+ catch (error) {
53
+ if (error instanceof LifecycleInputError) {
54
+ return lifecycleFailure("invalid-input");
55
+ }
56
+ logUnexpectedFailure("edit");
57
+ return lifecycleFailure("unexpected-failure");
58
+ }
59
+ }
60
+ async function deletePrototype(input) {
61
+ if (options.production || options.lifecycle === null) {
62
+ return lifecycleFailure("forbidden");
63
+ }
64
+ try {
65
+ const identity = await options.getCurrentUser();
66
+ if (identity === null)
67
+ return lifecycleFailure("unauthenticated");
68
+ return await options.lifecycle.delete(identity, parsePrototypeCommandInput(input));
69
+ }
70
+ catch (error) {
71
+ if (error instanceof LifecycleInputError) {
72
+ return lifecycleFailure("invalid-input");
73
+ }
74
+ logUnexpectedFailure("delete");
75
+ return lifecycleFailure("unexpected-failure");
76
+ }
77
+ }
42
78
  async function save(input) {
43
79
  if (options.production || options.lifecycle === null) {
44
80
  return lifecycleFailure("forbidden");
@@ -47,7 +83,7 @@ export function createPrototypeActions(options) {
47
83
  const identity = await options.getCurrentUser();
48
84
  if (identity === null)
49
85
  return lifecycleFailure("unauthenticated");
50
- return await options.lifecycle.save(identity, parseSavePrototypeInput(input));
86
+ return await options.lifecycle.save(identity, parsePrototypeCommandInput(input));
51
87
  }
52
88
  catch (error) {
53
89
  if (error instanceof LifecycleInputError) {
@@ -65,7 +101,7 @@ export function createPrototypeActions(options) {
65
101
  const identity = await options.getCurrentUser();
66
102
  if (identity === null)
67
103
  return lifecycleFailure("unauthenticated");
68
- return await options.lifecycle.discard(identity, parseDiscardPrototypeInput(input));
104
+ return await options.lifecycle.discard(identity, parsePrototypeCommandInput(input));
69
105
  }
70
106
  catch (error) {
71
107
  if (error instanceof LifecycleInputError) {
@@ -75,6 +111,49 @@ export function createPrototypeActions(options) {
75
111
  return lifecycleFailure("unexpected-failure");
76
112
  }
77
113
  }
78
- return { create, duplicate, save, discard };
114
+ async function deploy(input) {
115
+ if (options.production)
116
+ return lifecycleFailure("forbidden");
117
+ let parsedInput;
118
+ try {
119
+ parsedInput = parsePrototypeCommandInput(input);
120
+ }
121
+ catch (error) {
122
+ if (error instanceof LifecycleInputError) {
123
+ return lifecycleFailure("invalid-input");
124
+ }
125
+ logUnexpectedFailure("deploy");
126
+ return lifecycleFailure("deployment-failure");
127
+ }
128
+ if (options.lifecycle === null) {
129
+ return lifecycleFailure("deployment-unavailable");
130
+ }
131
+ let identity;
132
+ try {
133
+ identity = await options.getCurrentUser();
134
+ }
135
+ catch {
136
+ logUnexpectedFailure("deploy");
137
+ return lifecycleFailure("unexpected-failure");
138
+ }
139
+ if (identity === null)
140
+ return lifecycleFailure("unauthenticated");
141
+ try {
142
+ return await options.lifecycle.deploy(identity, parsedInput);
143
+ }
144
+ catch {
145
+ logUnexpectedFailure("deploy");
146
+ return lifecycleFailure("deployment-failure");
147
+ }
148
+ }
149
+ return {
150
+ create,
151
+ duplicate,
152
+ edit,
153
+ delete: deletePrototype,
154
+ save,
155
+ discard,
156
+ deploy,
157
+ };
79
158
  }
80
159
  //# sourceMappingURL=prototype-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prototype-actions.js","sourceRoot":"","sources":["../../src/server/prototype-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,yBAAy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,CAAC,CAAC;YAC/B,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,SAAS;QACT,IAAI;QACJ,MAAM,EAAE,eAAe;QACvB,IAAI;QACJ,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n lifecycleFailure,\n parseCreatePrototypeInput,\n parseDuplicatePrototypeInput,\n parseEditPrototypeInput,\n parsePrototypeCommandInput,\n LifecycleInputError,\n type CreatePrototypeInput,\n type CreatePrototypeValue,\n type DeletePrototypeValue,\n type DeploymentValue,\n type DiscardPrototypeValue,\n type DuplicatePrototypeInput,\n type DuplicatePrototypeValue,\n type EditPrototypeInput,\n type EditPrototypeValue,\n type LifecycleResult,\n type PrototypeCommandInput,\n type SavePrototypeValue,\n type BonfireIdentity,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycle } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeActions = {\n create(\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>>;\n duplicate(\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>>;\n edit(input: EditPrototypeInput): Promise<LifecycleResult<EditPrototypeValue>>;\n delete(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>>;\n save(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>>;\n discard(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>>;\n deploy(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>>;\n};\n\nexport type PrototypeActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n lifecycle: PrototypeLifecycle | null;\n themeRegistry?: ThemeRegistry;\n};\n\nfunction logUnexpectedFailure(\n operation:\n \"create\" | \"duplicate\" | \"edit\" | \"delete\" | \"save\" | \"discard\" | \"deploy\",\n) {\n console.error(`Bonfire prototype ${operation} failed unexpectedly.`);\n}\n\nexport function createPrototypeActions(\n options: PrototypeActionsOptions,\n): PrototypeActions {\n async function create(\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.create(\n identity,\n parseCreatePrototypeInput(input, options.themeRegistry),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"create\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function duplicate(\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.duplicate(\n identity,\n parseDuplicatePrototypeInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"duplicate\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function edit(\n input: EditPrototypeInput,\n ): Promise<LifecycleResult<EditPrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.edit(\n identity,\n parseEditPrototypeInput(input, options.themeRegistry),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"edit\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function deletePrototype(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.delete(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"delete\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function save(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.save(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"save\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function discard(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>> {\n if (options.production || options.lifecycle === null) {\n return lifecycleFailure(\"forbidden\");\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n return await options.lifecycle.discard(\n identity,\n parsePrototypeCommandInput(input),\n );\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"discard\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n }\n\n async function deploy(\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>> {\n if (options.production) return lifecycleFailure(\"forbidden\");\n\n let parsedInput: PrototypeCommandInput;\n try {\n parsedInput = parsePrototypeCommandInput(input);\n } catch (error) {\n if (error instanceof LifecycleInputError) {\n return lifecycleFailure(\"invalid-input\");\n }\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"deployment-failure\");\n }\n if (options.lifecycle === null) {\n return lifecycleFailure(\"deployment-unavailable\");\n }\n\n let identity: BonfireIdentity | null;\n try {\n identity = await options.getCurrentUser();\n } catch {\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"unexpected-failure\");\n }\n if (identity === null) return lifecycleFailure(\"unauthenticated\");\n\n try {\n return await options.lifecycle.deploy(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"deploy\");\n return lifecycleFailure(\"deployment-failure\");\n }\n }\n\n return {\n create,\n duplicate,\n edit,\n delete: deletePrototype,\n save,\n discard,\n deploy,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type PrototypeDashboardModel, type BonfireIdentity } from "@ebay-dt/bonfire-core";
1
+ import { type PrototypeDashboardModel, type BonfireIdentity, type ThemeRegistry } from "@ebay-dt/bonfire-core";
2
2
  import type { PrototypeCatalogLike } from "@ebay-dt/bonfire-node";
3
3
  export type PrototypeDashboardSearchParams = Record<string, string | string[] | undefined>;
4
4
  type DashboardSearchParamsInput = PrototypeDashboardSearchParams | Promise<PrototypeDashboardSearchParams> | undefined;
@@ -7,6 +7,7 @@ type PrototypeDashboardLoaderOptions = {
7
7
  production: boolean;
8
8
  catalog: PrototypeCatalogLike;
9
9
  getCurrentUser: () => Promise<BonfireIdentity | null>;
10
+ themeRegistry?: ThemeRegistry;
10
11
  };
11
12
  export declare function createPrototypeDashboardModelLoader(options: PrototypeDashboardLoaderOptions): (searchParams?: DashboardSearchParamsInput) => Promise<PrototypeDashboardModel>;
12
13
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"prototype-dashboard.d.ts","sourceRoot":"","sources":["../../src/server/prototype-dashboard.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,MAAM,8BAA8B,GA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B,CAAC,CAuBpC","sourcesContent":["import { connection } from \"next/server.js\";\nimport {\n definePrototypeRef,\n filterPrototypes,\n getPrototypeAuthorOptions,\n sortPrototypes,\n type PrototypeCatalogQuery,\n type PrototypeDashboardModel,\n type BonfireIdentity,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeCatalogLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeDashboardSearchParams = Record<\n string,\n string | string[] | undefined\n>;\n\ntype DashboardSearchParamsInput =\n | PrototypeDashboardSearchParams\n | Promise<PrototypeDashboardSearchParams>\n | undefined;\n\ntype PrototypeDashboardLoaderOptions = {\n applicationName: string;\n production: boolean;\n catalog: PrototypeCatalogLike;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n themeRegistry?: ThemeRegistry;\n};\n\nconst MAX_QUERY_VALUE_LENGTH = 128;\nconst VALID_SORTS = new Set<PrototypeCatalogQuery[\"sort\"]>([\n \"recent\",\n \"alphabetical\",\n \"deployed\",\n]);\n\nfunction singleQueryValue(value: unknown) {\n if (typeof value !== \"string\") return null;\n if (value.length > MAX_QUERY_VALUE_LENGTH) return null;\n return value;\n}\n\nfunction normalizeSort(value: unknown): PrototypeCatalogQuery[\"sort\"] {\n const scalar = singleQueryValue(value);\n return scalar !== null &&\n VALID_SORTS.has(scalar as PrototypeCatalogQuery[\"sort\"])\n ? (scalar as PrototypeCatalogQuery[\"sort\"])\n : \"recent\";\n}\n\nfunction normalizeAuthor(\n value: unknown,\n currentLogin: string | null,\n): PrototypeCatalogQuery[\"author\"] {\n const scalar = singleQueryValue(value);\n if (scalar === \"all\") return \"all\";\n if (scalar === \"mine\") return currentLogin === null ? \"all\" : \"mine\";\n if (scalar === null) return \"all\";\n\n try {\n return definePrototypeRef({ login: scalar, slug: \"prototype\" }).login;\n } catch {\n return \"all\";\n }\n}\n\nasync function normalizeSearchParams(\n searchParams: DashboardSearchParamsInput,\n currentLogin: string | null,\n): Promise<PrototypeCatalogQuery> {\n const params = (await searchParams) ?? {};\n return {\n author: normalizeAuthor(params.author, currentLogin),\n sort: normalizeSort(params.sort),\n };\n}\n\nexport function createPrototypeDashboardModelLoader(\n options: PrototypeDashboardLoaderOptions,\n) {\n return async function getDashboardModel(\n searchParams?: DashboardSearchParamsInput,\n ): Promise<PrototypeDashboardModel> {\n await connection();\n\n const [summaries, currentUser] = await Promise.all([\n options.catalog.scan(),\n options.production ? Promise.resolve(null) : options.getCurrentUser(),\n ]);\n const currentLogin = currentUser?.login ?? null;\n const query = await normalizeSearchParams(searchParams, currentLogin);\n const filtered = filterPrototypes(summaries, query.author, currentLogin);\n const visibleSummaries = sortPrototypes(filtered, query.sort);\n\n return {\n applicationName: options.applicationName,\n query,\n authorOptions: getPrototypeAuthorOptions(summaries, currentLogin),\n showMine: currentUser !== null,\n summaries: visibleSummaries,\n ...(options.themeRegistry === undefined\n ? {}\n : { themeRegistry: options.themeRegistry }),\n };\n };\n}\n"]}
@@ -59,6 +59,9 @@ export function createPrototypeDashboardModelLoader(options) {
59
59
  authorOptions: getPrototypeAuthorOptions(summaries, currentLogin),
60
60
  showMine: currentUser !== null,
61
61
  summaries: visibleSummaries,
62
+ ...(options.themeRegistry === undefined
63
+ ? {}
64
+ : { themeRegistry: options.themeRegistry }),
62
65
  };
63
66
  };
64
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prototype-dashboard.js","sourceRoot":"","sources":["../../src/server/prototype-dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,GAIf,MAAM,uBAAuB,CAAC;AAoB/B,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAgC;IACzD,QAAQ;IACR,cAAc;IACd,UAAU;CACX,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI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D,OAAwC;IAExC,OAAO,KAAK,UAAU,iBAAiB,CACrC,YAAyC;QAEzC,MAAM,UAAU,EAAE,CAAC;QAEnB,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACjD,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE;YACtB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE;SACtE,CAAC,CAAC;QACH,MAAM,YAAY,GAAG,WAAW,EAAE,KAAK,IAAI,IAAI,CAAC;QAChD,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QACtE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACzE,MAAM,gBAAgB,GAAG,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAE9D,OAAO;YACL,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,KAAK;YACL,aAAa,EAAE,yBAAyB,CAAC,SAAS,EAAE,YAAY,CAAC;YACjE,QAAQ,EAAE,WAAW,KAAK,IAAI;YAC9B,SAAS,EAAE,gBAAgB;YAC3B,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS;gBACrC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;SAC9C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { connection } from \"next/server.js\";\nimport {\n definePrototypeRef,\n filterPrototypes,\n getPrototypeAuthorOptions,\n sortPrototypes,\n type PrototypeCatalogQuery,\n type PrototypeDashboardModel,\n type BonfireIdentity,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeCatalogLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeDashboardSearchParams = Record<\n string,\n string | string[] | undefined\n>;\n\ntype DashboardSearchParamsInput =\n | PrototypeDashboardSearchParams\n | Promise<PrototypeDashboardSearchParams>\n | undefined;\n\ntype PrototypeDashboardLoaderOptions = {\n applicationName: string;\n production: boolean;\n catalog: PrototypeCatalogLike;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n themeRegistry?: ThemeRegistry;\n};\n\nconst MAX_QUERY_VALUE_LENGTH = 128;\nconst VALID_SORTS = new Set<PrototypeCatalogQuery[\"sort\"]>([\n \"recent\",\n \"alphabetical\",\n \"deployed\",\n]);\n\nfunction singleQueryValue(value: unknown) {\n if (typeof value !== \"string\") return null;\n if (value.length > MAX_QUERY_VALUE_LENGTH) return null;\n return value;\n}\n\nfunction normalizeSort(value: unknown): PrototypeCatalogQuery[\"sort\"] {\n const scalar = singleQueryValue(value);\n return scalar !== null &&\n VALID_SORTS.has(scalar as PrototypeCatalogQuery[\"sort\"])\n ? (scalar as PrototypeCatalogQuery[\"sort\"])\n : \"recent\";\n}\n\nfunction normalizeAuthor(\n value: unknown,\n currentLogin: string | null,\n): PrototypeCatalogQuery[\"author\"] {\n const scalar = singleQueryValue(value);\n if (scalar === \"all\") return \"all\";\n if (scalar === \"mine\") return currentLogin === null ? \"all\" : \"mine\";\n if (scalar === null) return \"all\";\n\n try {\n return definePrototypeRef({ login: scalar, slug: \"prototype\" }).login;\n } catch {\n return \"all\";\n }\n}\n\nasync function normalizeSearchParams(\n searchParams: DashboardSearchParamsInput,\n currentLogin: string | null,\n): Promise<PrototypeCatalogQuery> {\n const params = (await searchParams) ?? {};\n return {\n author: normalizeAuthor(params.author, currentLogin),\n sort: normalizeSort(params.sort),\n };\n}\n\nexport function createPrototypeDashboardModelLoader(\n options: PrototypeDashboardLoaderOptions,\n) {\n return async function getDashboardModel(\n searchParams?: DashboardSearchParamsInput,\n ): Promise<PrototypeDashboardModel> {\n await connection();\n\n const [summaries, currentUser] = await Promise.all([\n options.catalog.scan(),\n options.production ? Promise.resolve(null) : options.getCurrentUser(),\n ]);\n const currentLogin = currentUser?.login ?? null;\n const query = await normalizeSearchParams(searchParams, currentLogin);\n const filtered = filterPrototypes(summaries, query.author, currentLogin);\n const visibleSummaries = sortPrototypes(filtered, query.sort);\n\n return {\n applicationName: options.applicationName,\n query,\n authorOptions: getPrototypeAuthorOptions(summaries, currentLogin),\n showMine: currentUser !== null,\n summaries: visibleSummaries,\n ...(options.themeRegistry === undefined\n ? {}\n : { themeRegistry: options.themeRegistry }),\n };\n };\n}\n"]}