@ebay-dt/bonfire-next 0.2.0-alpha.0 → 0.2.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/client/lifecycle-provider.d.ts.map +1 -1
- package/dist/client/lifecycle-provider.js +1 -1
- package/dist/client/lifecycle-provider.js.map +1 -1
- package/dist/server/create-bonfire-next.d.ts +7 -0
- package/dist/server/create-bonfire-next.d.ts.map +1 -1
- package/dist/server/create-bonfire-next.js +14 -28
- package/dist/server/create-bonfire-next.js.map +1 -1
- package/dist/server/entry-coordinator.d.ts +15 -4
- package/dist/server/entry-coordinator.d.ts.map +1 -1
- package/dist/server/entry-coordinator.js +13 -7
- package/dist/server/entry-coordinator.js.map +1 -1
- package/dist/server/prototype-actions.d.ts +4 -1
- package/dist/server/prototype-actions.d.ts.map +1 -1
- package/dist/server/prototype-actions.js +83 -2
- package/dist/server/prototype-actions.js.map +1 -1
- package/dist/server/prototype-source-link.d.ts +11 -0
- package/dist/server/prototype-source-link.d.ts.map +1 -0
- package/dist/server/prototype-source-link.js +59 -0
- package/dist/server/prototype-source-link.js.map +1 -0
- package/dist/server/repository-actions.d.ts +6 -4
- package/dist/server/repository-actions.d.ts.map +1 -1
- package/dist/server/repository-actions.js +71 -3
- package/dist/server/repository-actions.js.map +1 -1
- package/dist/server/repository-routes.d.ts +1 -0
- package/dist/server/repository-routes.d.ts.map +1 -1
- package/dist/server/repository-routes.js +7 -0
- package/dist/server/repository-routes.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -109,8 +109,12 @@ Run `bonfire prepare` before development so the secret exists in
|
|
|
109
109
|
The explicit repository root enables request-time discovery under
|
|
110
110
|
`src/app/(prototypes)` without relying on package-internal `process.cwd()`.
|
|
111
111
|
`BF_PROTOTYPE_BASE_BRANCH` can override the default `main` branch used as the
|
|
112
|
-
base for identity branches.
|
|
113
|
-
|
|
112
|
+
base for identity branches. A missing base branch reports repository attention
|
|
113
|
+
without silently using the current branch. Set `BF_GIT_MODE=manual` to disable
|
|
114
|
+
all Bonfire Git mutations while retaining filesystem lifecycle actions and
|
|
115
|
+
read-only local Git observation; `managed` is the default. This is distinct
|
|
116
|
+
from `BF_DISABLE_AUTO_BRANCH_SWITCH=true`, which skips automatic branch
|
|
117
|
+
selection but does not disable managed commits and pushes.
|
|
114
118
|
|
|
115
119
|
A development instance can also receive a trusted server-only
|
|
116
120
|
`preparePrototypeFiles` callback. It runs after Bonfire scaffolds or
|
|
@@ -146,7 +150,9 @@ export default async function RootLayout({ children }: LayoutProps<"/">) {
|
|
|
146
150
|
`getAppLayoutModel()` returns a paired set of opaque document props and
|
|
147
151
|
serializable header props. Spread `htmlProps` on `<html>` and `headerProps` on
|
|
148
152
|
`<AppHeader>`; do not omit the document props when rendering the header. Both
|
|
149
|
-
values come from the same `getAppLayoutModel()` result.
|
|
153
|
+
values come from the same `getAppLayoutModel()` result. With repository actions
|
|
154
|
+
configured, the header checks for updates when opened in development and offers
|
|
155
|
+
Get updates/preparation without applying updates on open. Render `AppHeader` in
|
|
150
156
|
the route layout that owns it. Keep the dashboard header in a system layout and
|
|
151
157
|
the prototype header inside the prototype environment, so the header can
|
|
152
158
|
consume the environment context:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-provider.d.ts","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,uBAAuB,EAG5B,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,4BAA4B,IAAI,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxG,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,uBAAuB,CAAC;IACjC,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,OAAc,EACd,IAAW,EACX,aAAa,EACb,mBAAmB,GACpB,EAAE,0BAA0B,+TAa5B","sourcesContent":["\"use client\";\n\nimport {\n createDirtyObservationAdapter,\n createLifecycleController,\n LifecycleProvider,\n RepositoryActionsProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n type RepositoryActionBindings,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport { useOptionalRepositoryActions as useRepositoryActions } from \"@ebay-dt/bonfire-react/lifecycle\";\nexport type { RepositoryActionBindings } from \"@ebay-dt/bonfire-react/lifecycle\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n repositoryActions?: RepositoryActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n repositoryActions={repositoryActions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n \"actions\"
|
|
1
|
+
{"version":3,"file":"lifecycle-provider.d.ts","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,uBAAuB,EAG5B,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,4BAA4B,IAAI,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxG,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,uBAAuB,CAAC;IACjC,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,OAAc,EACd,IAAW,EACX,aAAa,EACb,mBAAmB,GACpB,EAAE,0BAA0B,+TAa5B","sourcesContent":["\"use client\";\n\nimport {\n createDirtyObservationAdapter,\n createLifecycleController,\n LifecycleProvider,\n RepositoryActionsProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n type RepositoryActionBindings,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport { useOptionalRepositoryActions as useRepositoryActions } from \"@ebay-dt/bonfire-react/lifecycle\";\nexport type { RepositoryActionBindings } from \"@ebay-dt/bonfire-react/lifecycle\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n repositoryActions?: RepositoryActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n repositoryActions={repositoryActions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n | \"actions\"\n | \"repositoryActions\"\n | \"children\"\n | \"user\"\n | \"dirtyEndpoint\"\n | \"deploymentAvailable\"\n>) {\n const pathname = usePathname() ?? \"/\";\n const router = useRouter();\n const [route] = useState(() => {\n let currentPathname = pathname;\n const listeners = new Set<() => void>();\n const adapter: LifecycleRouteAdapter = {\n getPathname: () => currentPathname,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return {\n adapter,\n setPathname(nextPathname: string) {\n if (nextPathname === currentPathname) return;\n currentPathname = nextPathname;\n for (const listener of listeners) listener();\n },\n };\n });\n const [navigation] = useState<LifecycleNavigationAdapter>(() => ({\n pathname,\n push: (href) => router.push(href),\n replace: (href) => router.replace(href),\n back: () => router.back(),\n refresh: () => router.refresh(),\n }));\n const [dirtyObservation] = useState(() =>\n createDirtyObservationAdapter({ endpoint: dirtyEndpoint }),\n );\n const [controller] = useState(() =>\n createLifecycleController({\n actions,\n navigation,\n route: route.adapter,\n user,\n dirtyObservation,\n deploymentAvailable,\n }),\n );\n\n useEffect(() => {\n route.setPathname(pathname);\n }, [pathname, route]);\n\n return (\n <RepositoryActionsProvider actions={repositoryActions}>\n <LifecycleProvider\n controller={controller}\n getPendingRecovery={actions.getPendingRecovery}\n >\n {children}\n </LifecycleProvider>\n </RepositoryActionsProvider>\n );\n}\n"]}
|
|
@@ -52,6 +52,6 @@ function EnabledNextLifecycleProvider({ actions, repositoryActions, children, us
|
|
|
52
52
|
useEffect(() => {
|
|
53
53
|
route.setPathname(pathname);
|
|
54
54
|
}, [pathname, route]);
|
|
55
|
-
return (_jsx(RepositoryActionsProvider, { actions: repositoryActions, children: _jsx(LifecycleProvider, { controller: controller, children: children }) }));
|
|
55
|
+
return (_jsx(RepositoryActionsProvider, { actions: repositoryActions, children: _jsx(LifecycleProvider, { controller: controller, getPendingRecovery: actions.getPendingRecovery, children: children }) }));
|
|
56
56
|
}
|
|
57
57
|
//# sourceMappingURL=lifecycle-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-provider.js","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,GAK1B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,4BAA4B,IAAI,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAaxG,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,iBAAiB,EACj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C,OAAO,EAAE;KAChC,CAAC,CAAC,CAAC;IACJ,MAAM,CAAC,gBAAgB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACvC,6BAA6B,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAC3D,CAAC;IACF,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACjC,yBAAyB,CAAC;QACxB,OAAO;QACP,UAAU;QACV,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,IAAI;QACJ,gBAAgB;QAChB,mBAAmB;KACpB,CAAC,CACH,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAEtB,OAAO,CACL,KAAC,yBAAyB,IAAC,OAAO,EAAE,iBAAiB,YACnD,KAAC,iBAAiB,IAChB,UAAU,EAAE,UAAU,EACtB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,YAE7C,QAAQ,GACS,GACM,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport {\n createDirtyObservationAdapter,\n createLifecycleController,\n LifecycleProvider,\n RepositoryActionsProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n type RepositoryActionBindings,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport { useOptionalRepositoryActions as useRepositoryActions } from \"@ebay-dt/bonfire-react/lifecycle\";\nexport type { RepositoryActionBindings } from \"@ebay-dt/bonfire-react/lifecycle\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n repositoryActions?: RepositoryActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n repositoryActions={repositoryActions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n | \"actions\"\n | \"repositoryActions\"\n | \"children\"\n | \"user\"\n | \"dirtyEndpoint\"\n | \"deploymentAvailable\"\n>) {\n const pathname = usePathname() ?? \"/\";\n const router = useRouter();\n const [route] = useState(() => {\n let currentPathname = pathname;\n const listeners = new Set<() => void>();\n const adapter: LifecycleRouteAdapter = {\n getPathname: () => currentPathname,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return {\n adapter,\n setPathname(nextPathname: string) {\n if (nextPathname === currentPathname) return;\n currentPathname = nextPathname;\n for (const listener of listeners) listener();\n },\n };\n });\n const [navigation] = useState<LifecycleNavigationAdapter>(() => ({\n pathname,\n push: (href) => router.push(href),\n replace: (href) => router.replace(href),\n back: () => router.back(),\n refresh: () => router.refresh(),\n }));\n const [dirtyObservation] = useState(() =>\n createDirtyObservationAdapter({ endpoint: dirtyEndpoint }),\n );\n const [controller] = useState(() =>\n createLifecycleController({\n actions,\n navigation,\n route: route.adapter,\n user,\n dirtyObservation,\n deploymentAvailable,\n }),\n );\n\n useEffect(() => {\n route.setPathname(pathname);\n }, [pathname, route]);\n\n return (\n <RepositoryActionsProvider actions={repositoryActions}>\n <LifecycleProvider\n controller={controller}\n getPendingRecovery={actions.getPendingRecovery}\n >\n {children}\n </LifecycleProvider>\n </RepositoryActionsProvider>\n );\n}\n"]}
|
|
@@ -5,7 +5,9 @@ import { type CSSProperties } from "react";
|
|
|
5
5
|
import { type LoginSearchParams } from "./login-page-model.js";
|
|
6
6
|
export type CreateBonfireNextOptions = BonfireConfigInput & {
|
|
7
7
|
repositoryRoot: string;
|
|
8
|
+
/** Shared with CLI startup through BF_* environment settings. */
|
|
8
9
|
prototypeRoot?: string;
|
|
10
|
+
remote?: string;
|
|
9
11
|
primaryBranch?: string;
|
|
10
12
|
sessionSecret?: string;
|
|
11
13
|
githubCli?: GitHubCliClientLike;
|
|
@@ -17,6 +19,7 @@ export type CreateBonfireNextOptions = BonfireConfigInput & {
|
|
|
17
19
|
preparePrototypeFiles?: PreparePrototypeFiles;
|
|
18
20
|
disableAutoBranchSwitch?: string;
|
|
19
21
|
gitMode?: GitMode;
|
|
22
|
+
installDependencies?: (root: string) => Promise<void>;
|
|
20
23
|
};
|
|
21
24
|
export type PrototypeCapabilities = {
|
|
22
25
|
deployment: boolean;
|
|
@@ -29,6 +32,10 @@ type AppLayoutModel = {
|
|
|
29
32
|
headerProps: {
|
|
30
33
|
applicationName: string;
|
|
31
34
|
user: BonfireIdentity | null;
|
|
35
|
+
sourceRepository?: {
|
|
36
|
+
url: string;
|
|
37
|
+
prototypeDirectory: string;
|
|
38
|
+
};
|
|
32
39
|
};
|
|
33
40
|
};
|
|
34
41
|
export declare function createBonfireNext(options: CreateBonfireNextOptions): {
|
|
@@ -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,EACpB,KAAK,yBAAyB,EAC9B,KAAK,OAAO,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,oB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,GAAG,OAAO,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;EA2DhE","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\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\";\nimport { createEntrySynchronizationCoordinator } from \"./entry-coordinator.js\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\n\nexport type CreateBonfireNextOptions = 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 gitMode?: GitMode;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\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({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\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 gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined && injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\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 gitMode,\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 gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const entrySynchronization = createEntrySynchronizationCoordinator({\n lifecycle,\n onStatus: production\n ? undefined\n : ({ identity, status, result }) => {\n if (status === \"started\") {\n console.info(\n `[bonfire] Preparing repository branch for ${identity.login}…`,\n );\n } else if (status === \"deferred\") {\n console.warn(\n `[bonfire] Branch preparation for ${identity.login} is taking longer than 10s; continuing page rendering while it finishes.`,\n );\n } else if (result?.status === \"ready\") {\n console.info(\n `[bonfire] Branch preparation completed for ${identity.login}.`,\n );\n } else if (result?.status === \"disabled\") {\n console.info(\n `[bonfire] Branch preparation skipped for ${identity.login}.`,\n );\n } else {\n console.warn(\n `[bonfire] Branch preparation completed with repository attention for ${identity.login}.`,\n );\n }\n },\n });\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n entrySynchronizationInFlight: entrySynchronization.isInFlight,\n waitForEntrySynchronization: entrySynchronization.waitForCompletion,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\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 if (user !== null) await entrySynchronization.synchronize(user);\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 });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
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,EACpB,KAAK,yBAAyB,EAC9B,KAAK,OAAO,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,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;AAW/B,MAAM,MAAM,wBAAwB,GAAG,kB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B,CAAC;;;;;;;;;;;;;;;;;;;EA2DhE","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\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\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\nimport { getPrototypeSourceRepository } from \"./prototype-source-link.js\";\n\nexport type CreateBonfireNextOptions = BonfireConfigInput & {\n repositoryRoot: string;\n /** Shared with CLI startup through BF_* environment settings. */\n prototypeRoot?: string;\n remote?: 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 gitMode?: GitMode;\n installDependencies?: (root: string) => Promise<void>;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n sourceRepository?: { url: string; prototypeDirectory: string };\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({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\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 gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined &&\n injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\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 remote: options.remote,\n automaticBranchSwitch,\n gitMode,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n installDependencies: options.installDependencies,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n automaticBranchSwitch,\n getCurrentUser: getSession,\n lifecycle,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\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 sourceRepository =\n user === null\n ? undefined\n : await getPrototypeSourceRepository({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n hostname: config.auth.github.hostname,\n });\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 ...(sourceRepository === undefined ? {} : { sourceRepository }),\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 });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
@@ -11,9 +11,9 @@ import { createPrototypeAgentActions } from "./agent-actions.js";
|
|
|
11
11
|
import { createPrototypeDashboardModelLoader } from "./prototype-dashboard.js";
|
|
12
12
|
import { createPrototypeEnvironmentModelLoader } from "./prototype-environment.js";
|
|
13
13
|
import { createPrototypeRoutes } from "./prototype-routes.js";
|
|
14
|
-
import { createEntrySynchronizationCoordinator } from "./entry-coordinator.js";
|
|
15
14
|
import { createRepositoryActions } from "./repository-actions.js";
|
|
16
15
|
import { createRepositoryRoutes } from "./repository-routes.js";
|
|
16
|
+
import { getPrototypeSourceRepository } from "./prototype-source-link.js";
|
|
17
17
|
const APP_HEADER_BLOCK_SIZE_PROPERTY = "--app-header-block-size";
|
|
18
18
|
const APP_HEADER_PRESENT_BLOCK_SIZE = "2.5rem";
|
|
19
19
|
export function createBonfireNext(options) {
|
|
@@ -35,7 +35,8 @@ export function createBonfireNext(options) {
|
|
|
35
35
|
const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;
|
|
36
36
|
if (options.prototypeLifecycle !== undefined &&
|
|
37
37
|
((gitMode === "manual" && injectedLifecycleMode !== "manual") ||
|
|
38
|
-
(injectedLifecycleMode !== undefined &&
|
|
38
|
+
(injectedLifecycleMode !== undefined &&
|
|
39
|
+
injectedLifecycleMode !== gitMode))) {
|
|
39
40
|
throw new TypeError(gitMode === "manual"
|
|
40
41
|
? "prototypeLifecycle must declare manual mode when gitMode is manual"
|
|
41
42
|
: "prototypeLifecycle gitMode does not match configured gitMode");
|
|
@@ -61,40 +62,20 @@ export function createBonfireNext(options) {
|
|
|
61
62
|
repositoryRoot: options.repositoryRoot,
|
|
62
63
|
prototypeRoot: options.prototypeRoot,
|
|
63
64
|
primaryBranch: options.primaryBranch,
|
|
65
|
+
remote: options.remote,
|
|
64
66
|
automaticBranchSwitch,
|
|
65
67
|
gitMode,
|
|
66
68
|
applicationId: config.appId,
|
|
67
69
|
catalog: prototypeCatalog,
|
|
68
70
|
deploymentProvider: options.deploymentProvider,
|
|
69
71
|
preparePrototypeFiles: options.preparePrototypeFiles,
|
|
72
|
+
installDependencies: options.installDependencies,
|
|
70
73
|
themeRegistry: config.themes,
|
|
71
74
|
}));
|
|
72
75
|
const deploymentAvailable = !production &&
|
|
73
76
|
gitMode === "managed" &&
|
|
74
77
|
(options.deploymentProvider !== undefined ||
|
|
75
78
|
options.prototypeLifecycle?.deploy !== undefined);
|
|
76
|
-
const entrySynchronization = createEntrySynchronizationCoordinator({
|
|
77
|
-
lifecycle,
|
|
78
|
-
onStatus: production
|
|
79
|
-
? undefined
|
|
80
|
-
: ({ identity, status, result }) => {
|
|
81
|
-
if (status === "started") {
|
|
82
|
-
console.info(`[bonfire] Preparing repository branch for ${identity.login}…`);
|
|
83
|
-
}
|
|
84
|
-
else if (status === "deferred") {
|
|
85
|
-
console.warn(`[bonfire] Branch preparation for ${identity.login} is taking longer than 10s; continuing page rendering while it finishes.`);
|
|
86
|
-
}
|
|
87
|
-
else if (result?.status === "ready") {
|
|
88
|
-
console.info(`[bonfire] Branch preparation completed for ${identity.login}.`);
|
|
89
|
-
}
|
|
90
|
-
else if (result?.status === "disabled") {
|
|
91
|
-
console.info(`[bonfire] Branch preparation skipped for ${identity.login}.`);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
console.warn(`[bonfire] Branch preparation completed with repository attention for ${identity.login}.`);
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
79
|
const getCurrentUser = cache(() => getSession());
|
|
99
80
|
const prototypeActions = createPrototypeActions({
|
|
100
81
|
production,
|
|
@@ -106,10 +87,9 @@ export function createBonfireNext(options) {
|
|
|
106
87
|
const repositoryActions = createRepositoryActions({
|
|
107
88
|
production,
|
|
108
89
|
gitMode,
|
|
90
|
+
automaticBranchSwitch,
|
|
109
91
|
getCurrentUser: getSession,
|
|
110
92
|
lifecycle,
|
|
111
|
-
entrySynchronizationInFlight: entrySynchronization.isInFlight,
|
|
112
|
-
waitForEntrySynchronization: entrySynchronization.waitForCompletion,
|
|
113
93
|
});
|
|
114
94
|
const repositoryRoutes = createRepositoryRoutes({
|
|
115
95
|
production,
|
|
@@ -163,8 +143,13 @@ export function createBonfireNext(options) {
|
|
|
163
143
|
const getCurrentRouteModel = cache(getCurrentRouteModelUncached);
|
|
164
144
|
const getAppLayoutModel = cache(async () => {
|
|
165
145
|
const user = production ? null : await getCurrentUser();
|
|
166
|
-
|
|
167
|
-
|
|
146
|
+
const sourceRepository = user === null
|
|
147
|
+
? undefined
|
|
148
|
+
: await getPrototypeSourceRepository({
|
|
149
|
+
repositoryRoot: options.repositoryRoot,
|
|
150
|
+
prototypeRoot: options.prototypeRoot,
|
|
151
|
+
hostname: config.auth.github.hostname,
|
|
152
|
+
});
|
|
168
153
|
const style = {
|
|
169
154
|
[APP_HEADER_BLOCK_SIZE_PROPERTY]: user === null ? "0px" : APP_HEADER_PRESENT_BLOCK_SIZE,
|
|
170
155
|
};
|
|
@@ -173,6 +158,7 @@ export function createBonfireNext(options) {
|
|
|
173
158
|
headerProps: {
|
|
174
159
|
applicationName: config.name,
|
|
175
160
|
user,
|
|
161
|
+
...(sourceRepository === undefined ? {} : { sourceRepository }),
|
|
176
162
|
},
|
|
177
163
|
};
|
|
178
164
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-bonfire-next.js","sourceRoot":"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,EAAE,OAAO,CAAC,aAAa;QACpC,UAAU;KACX,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,gBAAgB,CAAC;QAC9B,UAAU;QACV,SAAS;QACT,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,YAAY,EAAE,OAAO,CAAC,YAAY;KACnC,CAAC,CAAC;IACH,OAAO;QACL,UAAU,EAAE;YACV,iBAAiB;YACjB,aAAa;YACb,oBAAoB;YACpB,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC9D,YAAY,EAAE;gBACZ,UAAU,EAAE,mBAAmB;gBAC/B,GAAG,EAAE;oBACH,GAAG,4BAA4B,CAAC,OAAO,CAAC;oBACxC,GAAG,CAAC,UAAU;wBACZ,CAAC,CAAC;4BACE,mBAAmB,EAAE,KAAK;4BAC1B,cAAc,EAAE,KAAK;4BACrB,IAAI,EAAE,KAAK;4BACX,OAAO,EAAE,KAAK;4BACd,UAAU,EAAE,KAAK;4BACjB,MAAM,EAAE,KAAK;yBACd;wBACH,CAAC,CAAC,EAAE,CAAC;iBACR;aAC8B;YACjC,SAAS;YACT,OAAO,EAAE,gBAAgB;YACzB,UAAU,EAAE,iBAAiB;YAC7B,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE,EAAE,GAAG,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE;SAC7D;QACD,IAAI,EAAE;YACJ,UAAU;YACV,cAAc;YACd,iBAAiB;YACjB,iBAAiB;YACjB,KAAK;YACL,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\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\";\nimport { createEntrySynchronizationCoordinator } from \"./entry-coordinator.js\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\n\nexport type CreateBonfireNextOptions = 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 gitMode?: GitMode;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\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({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\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 gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined && injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\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 gitMode,\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 gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const entrySynchronization = createEntrySynchronizationCoordinator({\n lifecycle,\n onStatus: production\n ? undefined\n : ({ identity, status, result }) => {\n if (status === \"started\") {\n console.info(\n `[bonfire] Preparing repository branch for ${identity.login}…`,\n );\n } else if (status === \"deferred\") {\n console.warn(\n `[bonfire] Branch preparation for ${identity.login} is taking longer than 10s; continuing page rendering while it finishes.`,\n );\n } else if (result?.status === \"ready\") {\n console.info(\n `[bonfire] Branch preparation completed for ${identity.login}.`,\n );\n } else if (result?.status === \"disabled\") {\n console.info(\n `[bonfire] Branch preparation skipped for ${identity.login}.`,\n );\n } else {\n console.warn(\n `[bonfire] Branch preparation completed with repository attention for ${identity.login}.`,\n );\n }\n },\n });\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n entrySynchronizationInFlight: entrySynchronization.isInFlight,\n waitForEntrySynchronization: entrySynchronization.waitForCompletion,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\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 if (user !== null) await entrySynchronization.synchronize(user);\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 });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
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,4BAA4B,EAC5B,iCAAiC,EACjC,mBAAmB,GAKpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,4BAA4B,GAO7B,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,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9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C,CAAC;IACH,OAAO;QACL,UAAU,EAAE;YACV,iBAAiB;YACjB,aAAa;YACb,oBAAoB;YACpB,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC9D,YAAY,EAAE;gBACZ,UAAU,EAAE,mBAAmB;gBAC/B,GAAG,EAAE;oBACH,GAAG,4BAA4B,CAAC,OAAO,CAAC;oBACxC,GAAG,CAAC,UAAU;wBACZ,CAAC,CAAC;4BACE,mBAAmB,EAAE,KAAK;4BAC1B,cAAc,EAAE,KAAK;4BACrB,IAAI,EAAE,KAAK;4BACX,OAAO,EAAE,KAAK;4BACd,UAAU,EAAE,KAAK;4BACjB,MAAM,EAAE,KAAK;yBACd;wBACH,CAAC,CAAC,EAAE,CAAC;iBACR;aAC8B;YACjC,SAAS;YACT,OAAO,EAAE,gBAAgB;YACzB,UAAU,EAAE,iBAAiB;YAC7B,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE,EAAE,GAAG,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE;SAC7D;QACD,IAAI,EAAE;YACJ,UAAU;YACV,cAAc;YACd,iBAAiB;YACjB,iBAAiB;YACjB,KAAK;YACL,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\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\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\nimport { getPrototypeSourceRepository } from \"./prototype-source-link.js\";\n\nexport type CreateBonfireNextOptions = BonfireConfigInput & {\n repositoryRoot: string;\n /** Shared with CLI startup through BF_* environment settings. */\n prototypeRoot?: string;\n remote?: 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 gitMode?: GitMode;\n installDependencies?: (root: string) => Promise<void>;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n sourceRepository?: { url: string; prototypeDirectory: string };\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({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\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 gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined &&\n injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\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 remote: options.remote,\n automaticBranchSwitch,\n gitMode,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n installDependencies: options.installDependencies,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n automaticBranchSwitch,\n getCurrentUser: getSession,\n lifecycle,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\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 sourceRepository =\n user === null\n ? undefined\n : await getPrototypeSourceRepository({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n hostname: config.auth.github.hostname,\n });\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 ...(sourceRepository === undefined ? {} : { sourceRepository }),\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 });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import type { BonfireIdentity, BranchPreparationValue } from "@ebay-dt/bonfire-core";
|
|
1
|
+
import type { BonfireIdentity, BranchPreparationValue, LifecycleErrorCode } from "@ebay-dt/bonfire-core";
|
|
2
2
|
import type { PrototypeLifecycle } from "@ebay-dt/bonfire-node";
|
|
3
3
|
type EntryLifecycle = Pick<PrototypeLifecycle, "prepareBranch">;
|
|
4
|
+
export type EntrySynchronizationCompletion = {
|
|
5
|
+
status: "completed";
|
|
6
|
+
preparation: BranchPreparationValue;
|
|
7
|
+
} | {
|
|
8
|
+
status: "failed";
|
|
9
|
+
error: LifecycleErrorCode;
|
|
10
|
+
};
|
|
11
|
+
export type EntrySynchronizationResult = EntrySynchronizationCompletion | {
|
|
12
|
+
status: "in-flight";
|
|
13
|
+
};
|
|
4
14
|
export type EntrySynchronizationStatus = "started" | "deferred" | "completed";
|
|
5
15
|
export type EntrySynchronizationCoordinator = {
|
|
6
|
-
synchronize(identity: BonfireIdentity): Promise<
|
|
16
|
+
synchronize(identity: BonfireIdentity): Promise<EntrySynchronizationResult | null>;
|
|
7
17
|
waitForCompletion(identity: BonfireIdentity): Promise<void>;
|
|
8
18
|
isInFlight(identity: BonfireIdentity): boolean;
|
|
9
19
|
};
|
|
@@ -13,8 +23,8 @@ export type EntrySynchronizationCoordinator = {
|
|
|
13
23
|
* not repeated until the process is restarted.
|
|
14
24
|
*
|
|
15
25
|
* The wait budget is intentionally shorter than the Git operation timeout. A
|
|
16
|
-
* timed-out request continues the operation in-process while allowing the
|
|
17
|
-
*
|
|
26
|
+
* timed-out request continues the operation in-process while allowing the page
|
|
27
|
+
* render to proceed with an explicitly in-flight result.
|
|
18
28
|
*/
|
|
19
29
|
export declare function createEntrySynchronizationCoordinator(options: {
|
|
20
30
|
lifecycle: EntryLifecycle | null;
|
|
@@ -23,6 +33,7 @@ export declare function createEntrySynchronizationCoordinator(options: {
|
|
|
23
33
|
identity: BonfireIdentity;
|
|
24
34
|
status: EntrySynchronizationStatus;
|
|
25
35
|
result?: BranchPreparationValue;
|
|
36
|
+
error?: LifecycleErrorCode;
|
|
26
37
|
}): void;
|
|
27
38
|
}): EntrySynchronizationCoordinator;
|
|
28
39
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-coordinator.d.ts","sourceRoot":"","sources":["../../src/server/entry-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,
|
|
1
|
+
{"version":3,"file":"entry-coordinator.d.ts","sourceRoot":"","sources":["../../src/server/entry-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,KAAK,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;AAEhE,MAAM,MAAM,8BAA8B,GACtC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,sBAAsB,CAAA;CAAE,GAC5D;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEpD,MAAM,MAAM,0BAA0B,GACpC,8BAA8B,GAAG;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC;AAO3D,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;AAE9E,MAAM,MAAM,+BAA+B,GAAG;IAC5C,WAAW,CACT,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;IAC9C,iBAAiB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,UAAU,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC;CAChD,CAAC;AAIF;;;;;;;;GAQG;AACH,wBAAgB,qCAAqC,CAAC,OAAO,EAAE;IAC7D,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE;QACf,QAAQ,EAAE,eAAe,CAAC;QAC1B,MAAM,EAAE,0BAA0B,CAAC;QACnC,MAAM,CAAC,EAAE,sBAAsB,CAAC;QAChC,KAAK,CAAC,EAAE,kBAAkB,CAAC;KAC5B,GAAG,IAAI,CAAC;CACV,GAAG,+BAA+B,CAgGlC","sourcesContent":["import type {\n BonfireIdentity,\n BranchPreparationValue,\n LifecycleErrorCode,\n LifecycleResult,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycle } from \"@ebay-dt/bonfire-node\";\n\ntype EntryLifecycle = Pick<PrototypeLifecycle, \"prepareBranch\">;\n\nexport type EntrySynchronizationCompletion =\n | { status: \"completed\"; preparation: BranchPreparationValue }\n | { status: \"failed\"; error: LifecycleErrorCode };\n\nexport type EntrySynchronizationResult =\n EntrySynchronizationCompletion | { status: \"in-flight\" };\n\ntype InFlightAttempt = {\n completion: Promise<EntrySynchronizationCompletion>;\n renderWait: Promise<EntrySynchronizationResult>;\n};\n\nexport type EntrySynchronizationStatus = \"started\" | \"deferred\" | \"completed\";\n\nexport type EntrySynchronizationCoordinator = {\n synchronize(\n identity: BonfireIdentity,\n ): Promise<EntrySynchronizationResult | null>;\n waitForCompletion(identity: BonfireIdentity): Promise<void>;\n isInFlight(identity: BonfireIdentity): boolean;\n};\n\nconst DEFAULT_ENTRY_WAIT_MS = 10_000;\n\n/**\n * Coordinates the first authenticated repository attempt for each identity in\n * this process. Concurrent tabs share one promise, and a completed attempt is\n * not repeated until the process is restarted.\n *\n * The wait budget is intentionally shorter than the Git operation timeout. A\n * timed-out request continues the operation in-process while allowing the page\n * render to proceed with an explicitly in-flight result.\n */\nexport function createEntrySynchronizationCoordinator(options: {\n lifecycle: EntryLifecycle | null;\n waitMs?: number;\n onStatus?(event: {\n identity: BonfireIdentity;\n status: EntrySynchronizationStatus;\n result?: BranchPreparationValue;\n error?: LifecycleErrorCode;\n }): void;\n}): EntrySynchronizationCoordinator {\n const waitMs = options.waitMs ?? DEFAULT_ENTRY_WAIT_MS;\n const inFlight = new Map<string, InFlightAttempt>();\n const completed = new Map<string, EntrySynchronizationCompletion>();\n const deferredReported = new Set<string>();\n\n function report(event: {\n identity: BonfireIdentity;\n status: EntrySynchronizationStatus;\n result?: BranchPreparationValue;\n error?: LifecycleErrorCode;\n }) {\n try {\n options.onStatus?.(event);\n } catch {\n // Observability must never affect authentication or page rendering.\n }\n }\n\n function createRenderWait(\n identity: BonfireIdentity,\n completion: Promise<EntrySynchronizationCompletion>,\n ): Promise<EntrySynchronizationResult> {\n if (waitMs <= 0) return completion;\n\n let timeout: ReturnType<typeof setTimeout> | undefined;\n const deferred = new Promise<EntrySynchronizationResult>((resolve) => {\n timeout = setTimeout(() => {\n if (!deferredReported.has(identity.login)) {\n deferredReported.add(identity.login);\n report({ identity, status: \"deferred\" });\n }\n resolve({ status: \"in-flight\" });\n }, waitMs);\n });\n\n return Promise.race([completion, deferred]).finally(() => {\n if (timeout !== undefined) clearTimeout(timeout);\n });\n }\n\n async function synchronize(identity: BonfireIdentity) {\n if (options.lifecycle === null) return null;\n\n const previous = completed.get(identity.login);\n if (previous !== undefined) return previous;\n\n const active = inFlight.get(identity.login);\n if (active !== undefined) return active.renderWait;\n\n report({ identity, status: \"started\" });\n const attempt = options.lifecycle\n .prepareBranch(identity)\n .then((result: LifecycleResult<BranchPreparationValue>) =>\n result.ok\n ? ({ status: \"completed\", preparation: result.value } as const)\n : ({ status: \"failed\", error: result.error.code } as const),\n )\n .catch(\n () => ({ status: \"failed\", error: \"unexpected-failure\" }) as const,\n );\n\n let completion!: Promise<EntrySynchronizationCompletion>;\n completion = attempt\n .then((result) => {\n completed.set(identity.login, result);\n report({\n identity,\n status: \"completed\",\n ...(result.status === \"completed\"\n ? { result: result.preparation }\n : { error: result.error }),\n });\n return result;\n })\n .finally(() => {\n deferredReported.delete(identity.login);\n if (inFlight.get(identity.login)?.completion === completion) {\n inFlight.delete(identity.login);\n }\n });\n const renderWait = createRenderWait(identity, completion);\n inFlight.set(identity.login, { completion, renderWait });\n\n return renderWait;\n }\n\n async function waitForCompletion(identity: BonfireIdentity) {\n await inFlight.get(identity.login)?.completion;\n }\n\n return {\n synchronize,\n waitForCompletion,\n isInFlight: (identity) => inFlight.has(identity.login),\n };\n}\n"]}
|
|
@@ -5,8 +5,8 @@ const DEFAULT_ENTRY_WAIT_MS = 10_000;
|
|
|
5
5
|
* not repeated until the process is restarted.
|
|
6
6
|
*
|
|
7
7
|
* The wait budget is intentionally shorter than the Git operation timeout. A
|
|
8
|
-
* timed-out request continues the operation in-process while allowing the
|
|
9
|
-
*
|
|
8
|
+
* timed-out request continues the operation in-process while allowing the page
|
|
9
|
+
* render to proceed with an explicitly in-flight result.
|
|
10
10
|
*/
|
|
11
11
|
export function createEntrySynchronizationCoordinator(options) {
|
|
12
12
|
const waitMs = options.waitMs ?? DEFAULT_ENTRY_WAIT_MS;
|
|
@@ -31,7 +31,7 @@ export function createEntrySynchronizationCoordinator(options) {
|
|
|
31
31
|
deferredReported.add(identity.login);
|
|
32
32
|
report({ identity, status: "deferred" });
|
|
33
33
|
}
|
|
34
|
-
resolve({ status: "
|
|
34
|
+
resolve({ status: "in-flight" });
|
|
35
35
|
}, waitMs);
|
|
36
36
|
});
|
|
37
37
|
return Promise.race([completion, deferred]).finally(() => {
|
|
@@ -52,14 +52,20 @@ export function createEntrySynchronizationCoordinator(options) {
|
|
|
52
52
|
const attempt = options.lifecycle
|
|
53
53
|
.prepareBranch(identity)
|
|
54
54
|
.then((result) => result.ok
|
|
55
|
-
? result.value
|
|
56
|
-
: { status: "
|
|
57
|
-
.catch(() => ({ status: "
|
|
55
|
+
? { status: "completed", preparation: result.value }
|
|
56
|
+
: { status: "failed", error: result.error.code })
|
|
57
|
+
.catch(() => ({ status: "failed", error: "unexpected-failure" }));
|
|
58
58
|
let completion;
|
|
59
59
|
completion = attempt
|
|
60
60
|
.then((result) => {
|
|
61
61
|
completed.set(identity.login, result);
|
|
62
|
-
report({
|
|
62
|
+
report({
|
|
63
|
+
identity,
|
|
64
|
+
status: "completed",
|
|
65
|
+
...(result.status === "completed"
|
|
66
|
+
? { result: result.preparation }
|
|
67
|
+
: { error: result.error }),
|
|
68
|
+
});
|
|
63
69
|
return result;
|
|
64
70
|
})
|
|
65
71
|
.finally(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-coordinator.js","sourceRoot":"","sources":["../../src/server/entry-coordinator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry-coordinator.js","sourceRoot":"","sources":["../../src/server/entry-coordinator.ts"],"names":[],"mappings":"AAgCA,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,UAAU,qCAAqC,CAAC,OASrD;IACC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,qBAAqB,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;IACpD,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0C,CAAC;IACpE,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE3C,SAAS,MAAM,CAAC,KAKf;QACC,IAAI,CAAC;YACH,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,oEAAoE;QACtE,CAAC;IACH,CAAC;IAED,SAAS,gBAAgB,CACvB,QAAyB,EACzB,UAAmD;QAEnD,IAAI,MAAM,IAAI,CAAC;YAAE,OAAO,UAAU,CAAC;QAEnC,IAAI,OAAkD,CAAC;QACvD,MAAM,QAAQ,GAAG,IAAI,OAAO,CAA6B,CAAC,OAAO,EAAE,EAAE;YACnE,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBACxB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,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AAE,UAAU,CAAC;IACjD,CAAC;IAED,OAAO;QACL,WAAW;QACX,iBAAiB;QACjB,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;KACvD,CAAC;AACJ,CAAC","sourcesContent":["import type {\n BonfireIdentity,\n BranchPreparationValue,\n LifecycleErrorCode,\n LifecycleResult,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycle } from \"@ebay-dt/bonfire-node\";\n\ntype EntryLifecycle = Pick<PrototypeLifecycle, \"prepareBranch\">;\n\nexport type EntrySynchronizationCompletion =\n | { status: \"completed\"; preparation: BranchPreparationValue }\n | { status: \"failed\"; error: LifecycleErrorCode };\n\nexport type EntrySynchronizationResult =\n EntrySynchronizationCompletion | { status: \"in-flight\" };\n\ntype InFlightAttempt = {\n completion: Promise<EntrySynchronizationCompletion>;\n renderWait: Promise<EntrySynchronizationResult>;\n};\n\nexport type EntrySynchronizationStatus = \"started\" | \"deferred\" | \"completed\";\n\nexport type EntrySynchronizationCoordinator = {\n synchronize(\n identity: BonfireIdentity,\n ): Promise<EntrySynchronizationResult | null>;\n waitForCompletion(identity: BonfireIdentity): Promise<void>;\n isInFlight(identity: BonfireIdentity): boolean;\n};\n\nconst DEFAULT_ENTRY_WAIT_MS = 10_000;\n\n/**\n * Coordinates the first authenticated repository attempt for each identity in\n * this process. Concurrent tabs share one promise, and a completed attempt is\n * not repeated until the process is restarted.\n *\n * The wait budget is intentionally shorter than the Git operation timeout. A\n * timed-out request continues the operation in-process while allowing the page\n * render to proceed with an explicitly in-flight result.\n */\nexport function createEntrySynchronizationCoordinator(options: {\n lifecycle: EntryLifecycle | null;\n waitMs?: number;\n onStatus?(event: {\n identity: BonfireIdentity;\n status: EntrySynchronizationStatus;\n result?: BranchPreparationValue;\n error?: LifecycleErrorCode;\n }): void;\n}): EntrySynchronizationCoordinator {\n const waitMs = options.waitMs ?? DEFAULT_ENTRY_WAIT_MS;\n const inFlight = new Map<string, InFlightAttempt>();\n const completed = new Map<string, EntrySynchronizationCompletion>();\n const deferredReported = new Set<string>();\n\n function report(event: {\n identity: BonfireIdentity;\n status: EntrySynchronizationStatus;\n result?: BranchPreparationValue;\n error?: LifecycleErrorCode;\n }) {\n try {\n options.onStatus?.(event);\n } catch {\n // Observability must never affect authentication or page rendering.\n }\n }\n\n function createRenderWait(\n identity: BonfireIdentity,\n completion: Promise<EntrySynchronizationCompletion>,\n ): Promise<EntrySynchronizationResult> {\n if (waitMs <= 0) return completion;\n\n let timeout: ReturnType<typeof setTimeout> | undefined;\n const deferred = new Promise<EntrySynchronizationResult>((resolve) => {\n timeout = setTimeout(() => {\n if (!deferredReported.has(identity.login)) {\n deferredReported.add(identity.login);\n report({ identity, status: \"deferred\" });\n }\n resolve({ status: \"in-flight\" });\n }, waitMs);\n });\n\n return Promise.race([completion, deferred]).finally(() => {\n if (timeout !== undefined) clearTimeout(timeout);\n });\n }\n\n async function synchronize(identity: BonfireIdentity) {\n if (options.lifecycle === null) return null;\n\n const previous = completed.get(identity.login);\n if (previous !== undefined) return previous;\n\n const active = inFlight.get(identity.login);\n if (active !== undefined) return active.renderWait;\n\n report({ identity, status: \"started\" });\n const attempt = options.lifecycle\n .prepareBranch(identity)\n .then((result: LifecycleResult<BranchPreparationValue>) =>\n result.ok\n ? ({ status: \"completed\", preparation: result.value } as const)\n : ({ status: \"failed\", error: result.error.code } as const),\n )\n .catch(\n () => ({ status: \"failed\", error: \"unexpected-failure\" }) as const,\n );\n\n let completion!: Promise<EntrySynchronizationCompletion>;\n completion = attempt\n .then((result) => {\n completed.set(identity.login, result);\n report({\n identity,\n status: \"completed\",\n ...(result.status === \"completed\"\n ? { result: result.preparation }\n : { error: result.error }),\n });\n return result;\n })\n .finally(() => {\n deferredReported.delete(identity.login);\n if (inFlight.get(identity.login)?.completion === completion) {\n inFlight.delete(identity.login);\n }\n });\n const renderWait = createRenderWait(identity, completion);\n inFlight.set(identity.login, { completion, renderWait });\n\n return renderWait;\n }\n\n async function waitForCompletion(identity: BonfireIdentity) {\n await inFlight.get(identity.login)?.completion;\n }\n\n return {\n synchronize,\n waitForCompletion,\n isInFlight: (identity) => inFlight.has(identity.login),\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CreatePrototypeInput, type CreatePrototypeValue, type DeletePrototypeValue, type DeploymentValue, type DiscardPrototypeValue, type DuplicatePrototypeInput, type DuplicatePrototypeValue, type EditPrototypeInput, type EditPrototypeValue, type GitMode, type LifecycleResult, type PrototypeCommandInput, type SavePrototypeValue, type BonfireIdentity, type ThemeRegistry } 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 GitMode, type LifecycleResult, type LifecycleRecoveryValue, 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>>;
|
|
@@ -8,6 +8,9 @@ export type PrototypeActions = {
|
|
|
8
8
|
save(input: PrototypeCommandInput): Promise<LifecycleResult<SavePrototypeValue>>;
|
|
9
9
|
discard(input: PrototypeCommandInput): Promise<LifecycleResult<DiscardPrototypeValue>>;
|
|
10
10
|
deploy(input: PrototypeCommandInput): Promise<LifecycleResult<DeploymentValue>>;
|
|
11
|
+
retryPublish?(input: PrototypeCommandInput): Promise<LifecycleResult<DeploymentValue>>;
|
|
12
|
+
getPendingRecovery(): Promise<LifecycleResult<LifecycleRecoveryValue | null>>;
|
|
13
|
+
retryPendingPublication(recoveryId: string): Promise<LifecycleResult<LifecycleRecoveryValue>>;
|
|
11
14
|
};
|
|
12
15
|
export type PrototypeActionsOptions = {
|
|
13
16
|
production: boolean;
|