@salsita-ai/sdk 0.50.0-develop.91d65bd507 → 0.50.0-develop.9239ced550
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 +1 -1
- package/dist/application/index.d.ts +1 -0
- package/dist/application/index.js +1 -1
- package/dist/application/mount-application.d.ts +1 -1
- package/dist/application/mount-application.js +1 -1
- package/dist/application/mount-configurator.d.ts +19 -0
- package/dist/application/mount-configurator.js +1 -0
- package/dist/application/mounted-application-runtime.d.ts +4 -0
- package/dist/application/mounted-application-runtime.js +1 -0
- package/dist/application/register-web-component.d.ts +2 -0
- package/dist/application/register-web-component.js +1 -0
- package/dist/application-spec/core/enhanced-json-value.d.ts +2 -31
- package/dist/application-spec/core/enhanced-json-value.js +1 -1
- package/dist/application-spec/core/index.d.ts +1 -3
- package/dist/application-spec/core/index.js +1 -1
- package/dist/application-spec/core/markers/index.d.ts +1 -1
- package/dist/application-spec/core/markers/index.js +1 -1
- package/dist/application-spec/core/markers/msg-marker.d.ts +2 -28
- package/dist/application-spec/core/markers/msg-marker.js +1 -1
- package/dist/application-spec/core/markers/raw-eval-write-marker.d.ts +1 -1
- package/dist/application-spec/core/markers/raw-eval-write-marker.js +1 -1
- package/dist/application-spec/core/markers/raw-read-write-marker.js +1 -1
- package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
- package/dist/application-spec/generate-application/code/templates/index.d.ts +2 -6
- package/dist/application-spec/generate-application/code/templates/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill-bundle.d.ts +10 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill-bundle.js +7 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
- package/dist/application-spec/generate-application/implementations/phx-application-types.d.ts +25 -0
- package/dist/application-spec/generate-application/implementations/phx-application-types.js +1 -0
- package/dist/application-spec/generate-application/implementations/phx-domain.d.ts +36 -0
- package/dist/application-spec/generate-application/implementations/phx-domain.js +1 -0
- package/dist/application-spec/generate-application/implementations/phx-model.d.ts +24 -0
- package/dist/application-spec/generate-application/implementations/phx-model.js +1 -0
- package/dist/application-spec/generate-application/implementations/phx.d.ts +22 -0
- package/dist/application-spec/generate-application/implementations/phx.js +1 -0
- package/dist/application-spec/generate-application/index.d.ts +2 -0
- package/dist/application-spec/generate-application/index.js +1 -1
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-model-runtime.d.ts +3 -3
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.d.ts +4 -2
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-spec-runtime.d.ts +16 -0
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-spec-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/application-runtime.d.ts +5 -0
- package/dist/application-spec/generate-application/runtime/application-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/application-spec-slice.d.ts +71 -0
- package/dist/application-spec/generate-application/runtime/application-spec-slice.js +1 -0
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-model-runtime.d.ts +3 -3
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +4 -2
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-spec-runtime.d.ts +16 -0
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-spec-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/create-application.d.ts +57 -0
- package/dist/application-spec/generate-application/runtime/create-application.js +1 -0
- package/dist/application-spec/generate-application/runtime/factory-data/recipe-defaults.js +1 -1
- package/dist/application-spec/generate-application/runtime/factory-data/static-violations.d.ts +1 -1
- package/dist/application-spec/generate-application/runtime/factory-data/static-violations.js +1 -1
- package/dist/application-spec/generate-application/runtime/generate-runtime-instance.d.ts +1 -1
- package/dist/application-spec/generate-application/runtime/generate-runtime-instance.js +1 -1
- package/dist/application-spec/generate-application/runtime/index.d.ts +8 -0
- package/dist/application-spec/generate-application/runtime/index.js +1 -0
- package/dist/application-spec/generate-application/runtime/sections/build-sdk-optic.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/expression-runtime.d.ts +1 -1
- package/dist/application-spec/generate-application/runtime/sections/expression-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/generate-memo-eval-plan-runtime.d.ts +1 -1
- package/dist/application-spec/generate-application/runtime/sections/generate-memo-eval-plan-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/spec-code/resolve-spec-code.d.ts +1 -1
- package/dist/application-spec/generate-application/runtime/spec-runtime.d.ts +21 -0
- package/dist/application-spec/generate-application/runtime/spec-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime-spec/encoded-runtime-spec.d.ts +3 -2
- package/dist/application-spec/generate-application/runtime-spec/runtime-spec.d.ts +44 -9
- package/dist/application-spec/generate-application/runtime-spec/runtime-spec.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-expressions.d.ts +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-expressions.js +1 -1
- package/dist/client/authorized-client.d.ts +3 -1
- package/dist/client/authorized-client.js +1 -1
- package/dist/client/contract.d.ts +17 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/local-authorized-client.d.ts +3 -1
- package/dist/client/local-authorized-client.js +1 -1
- package/dist/client/memory-authorized-client.d.ts +4 -1
- package/dist/client/memory-authorized-client.js +1 -1
- package/dist/client/phoenix-api.d.ts +228 -0
- package/dist/configurator/ConfiguratorApp.js +1 -1
- package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +13 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +15 -9
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.d.ts +1 -1
- package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.js +1 -1
- package/dist/configurator/ui/assistant/screenshots/tool-screenshots.d.ts +12 -4
- package/dist/configurator/ui/assistant/screenshots/tool-screenshots.js +1 -1
- package/dist/configurator/ui/assistant/screenshots/use-screenshot-src.d.ts +8 -0
- package/dist/configurator/ui/assistant/screenshots/use-screenshot-src.js +1 -0
- package/dist/docs/index.json +1 -1
- package/dist/docs/layouts/gallery/nightjar-guitar.mdx +31 -16
- package/dist/docs/layouts/gallery/tidepool-aquascape.mdx +205 -33
- package/dist/docs/phoenix/domain-model.mdx +4 -1
- package/dist/docs/phoenix/phoenix-cli.mdx +14 -6
- package/dist/docs/phoenix/project-structure.mdx +21 -17
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +6 -4
- package/dist/domain/application/assistant/build-assistant-manifest.js +1 -1
- package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
- package/dist/domain/application/configurator-builder.d.ts +7 -1
- package/dist/domain/application/configurator-builder.js +1 -1
- package/dist/domain/application/index.d.ts +1 -1
- package/dist/domain/application/index.js +1 -1
- package/dist/domain/application/standard-properties.js +1 -1
- package/dist/domain/domain-runtime/application.d.ts +39 -0
- package/dist/domain/domain-runtime/application.js +1 -0
- package/dist/domain/domain-runtime/domain-runtime.d.ts +36 -4
- package/dist/domain/domain-runtime/domain-runtime.js +1 -1
- package/dist/domain/domain-runtime/environment/initialize.d.ts +1 -1
- package/dist/domain/domain-runtime/index.d.ts +1 -0
- package/dist/domain/domain-runtime/index.js +1 -1
- package/dist/domain/domain-runtime/web-component/actions.d.ts +3 -0
- package/dist/domain/domain-runtime/web-component/actions.js +1 -1
- package/dist/domain/domain-runtime/web-component/initialize.d.ts +1 -0
- package/dist/domain/domain-runtime/web-component/initialize.js +1 -1
- package/dist/domain/domain-runtime/web-component/selectors.d.ts +2 -0
- package/dist/domain/domain-runtime/web-component/selectors.js +1 -1
- package/dist/domain/domain-runtime/web-component/types.d.ts +6 -3
- package/dist/domain/index.d.ts +1 -0
- package/dist/domain/index.js +1 -1
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +5 -0
- package/dist/domain/spec/application/index.d.ts +1 -0
- package/dist/domain/spec/application/index.js +1 -0
- package/dist/{application-spec/core → domain/spec}/components/component-filter.d.ts +3 -2
- package/dist/domain/spec/enhanced-json-value.d.ts +30 -0
- package/dist/domain/spec/enhanced-json-value.js +1 -0
- package/dist/domain/spec/index.d.ts +5 -0
- package/dist/domain/spec/index.js +1 -0
- package/dist/domain/spec/markers/index.d.ts +2 -0
- package/dist/domain/spec/markers/index.js +1 -0
- package/dist/domain/spec/markers/msg-marker.d.ts +28 -0
- package/dist/domain/spec/markers/msg-marker.js +1 -0
- package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
- package/dist/editor/domain-editors/apply-spec-update.d.ts +2 -1
- package/dist/editor/domain-editors/apply-spec-update.js +1 -1
- package/dist/editor/domain-editors/use-implementation-files.d.ts +0 -3
- package/dist/editor/domain-editors/use-implementation-files.js +1 -1
- package/dist/phoenix/application-spec/generate-application-spec-project.js +2 -2
- package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +11 -0
- package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
- package/dist/phoenix/bin.js +1 -1
- package/dist/phoenix/cli.js +1 -1
- package/dist/phoenix/commands/deploy.js +1 -1
- package/dist/phoenix/commands/dev.js +5 -5
- package/dist/phoenix/commands/generated-env-markers.d.ts +1 -0
- package/dist/phoenix/commands/generated-env-markers.js +1 -1
- package/dist/phoenix/commands/index.d.ts +1 -1
- package/dist/phoenix/commands/index.js +1 -1
- package/dist/phoenix/lingui/index.d.ts +1 -0
- package/dist/phoenix/lingui/index.js +1 -0
- package/dist/phoenix/{services → lingui}/lingui.d.ts +5 -2
- package/dist/phoenix/lingui/lingui.js +1 -0
- package/dist/phoenix/services/application-spec-project-watcher.d.ts +3 -1
- package/dist/phoenix/services/application-spec-project-watcher.js +2 -2
- package/dist/phoenix/services/index.d.ts +1 -0
- package/dist/phoenix/services/index.js +1 -1
- package/dist/phoenix/services/lingui-watcher.js +1 -1
- package/dist/phoenix/services/prepare-development-environment.js +1 -1
- package/dist/phoenix/services/vite-config.js +1 -1
- package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +1 -1
- package/dist/react-sdk/application-runtime/common-services/initialize.d.ts +2 -2
- package/dist/react-sdk/application-runtime/hooks/use-access-service.js +1 -1
- package/dist/react-sdk/application-runtime/hooks/use-web-component-readonly-sync.d.ts +4 -11
- package/dist/react-sdk/application-runtime/hooks/use-web-component-readonly-sync.js +1 -1
- package/dist/react-sdk/application-runtime/hooks/use-web-component.d.ts +5 -0
- package/dist/react-sdk/application-runtime/hooks/use-web-component.js +1 -1
- package/dist/react-sdk/application-runtime/host-properties/actions.d.ts +15 -0
- package/dist/react-sdk/application-runtime/host-properties/actions.js +1 -0
- package/dist/react-sdk/application-runtime/host-properties/connect-host-properties.d.ts +30 -0
- package/dist/react-sdk/application-runtime/host-properties/connect-host-properties.js +1 -0
- package/dist/react-sdk/application-runtime/host-properties/domain-host-properties.d.ts +7 -0
- package/dist/react-sdk/application-runtime/host-properties/domain-host-properties.js +1 -0
- package/dist/react-sdk/application-runtime/host-properties/host-property-descriptors.d.ts +21 -0
- package/dist/react-sdk/application-runtime/host-properties/host-property-descriptors.js +1 -0
- package/dist/react-sdk/application-runtime/host-properties/host-property-scopes.d.ts +42 -0
- package/dist/react-sdk/application-runtime/host-properties/host-property-scopes.js +1 -0
- package/dist/react-sdk/application-runtime/host-properties/index.d.ts +8 -0
- package/dist/react-sdk/application-runtime/host-properties/index.js +1 -0
- package/dist/react-sdk/application-runtime/host-properties/initialize.d.ts +7 -0
- package/dist/react-sdk/application-runtime/host-properties/initialize.js +1 -0
- package/dist/react-sdk/application-runtime/host-properties/selectors.d.ts +54 -0
- package/dist/react-sdk/application-runtime/host-properties/selectors.js +1 -0
- package/dist/react-sdk/application-runtime/host-properties/types.d.ts +18 -0
- package/dist/react-sdk/application-runtime/host-properties/types.js +1 -0
- package/dist/react-sdk/application-runtime/index.d.ts +1 -0
- package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +151 -9
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.js +1 -1
- package/package.json +3 -3
- package/dist/phoenix/services/lingui.js +0 -1
- /package/dist/{application-spec/core → domain/spec/application}/application-instance.d.ts +0 -0
- /package/dist/{application-spec/core → domain/spec/application}/application-instance.js +0 -0
- /package/dist/{application-spec/core → domain/spec}/components/component-filter.js +0 -0
- /package/dist/{application-spec/core → domain/spec}/components/index.d.ts +0 -0
- /package/dist/{application-spec/core → domain/spec}/components/index.js +0 -0
- /package/dist/{application-spec/core → domain/spec}/components/sdk-code-ref.d.ts +0 -0
- /package/dist/{application-spec/core → domain/spec}/components/sdk-code-ref.js +0 -0
- /package/dist/{application-spec/core → domain/spec}/expressions/index.d.ts +0 -0
- /package/dist/{application-spec/core → domain/spec}/expressions/index.js +0 -0
- /package/dist/{application-spec/core → domain/spec}/expressions/relation-expression-params.d.ts +0 -0
- /package/dist/{application-spec/core → domain/spec}/expressions/relation-expression-params.js +0 -0
- /package/dist/{application-spec/core → domain/spec}/expressions/sdk-expression-implementation.d.ts +0 -0
- /package/dist/{application-spec/core → domain/spec}/expressions/sdk-expression-implementation.js +0 -0
- /package/dist/{application-spec/core → domain/spec}/markers/eval-marker.d.ts +0 -0
- /package/dist/{application-spec/core → domain/spec}/markers/eval-marker.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EvalMarker, MsgMarker } from './markers/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* A JSON-serialisable value augmented with Phoenix structural markers:
|
|
4
|
+
* `$msg` (i18n) and `$eval` (self-scoped code).
|
|
5
|
+
*
|
|
6
|
+
* Single shared shape across components, expressions, and defaults — lowered
|
|
7
|
+
* either to TypeScript source via `stringifyEnhancedJsonValue` or to a
|
|
8
|
+
* runtime value via `resolveEnhancedJsonValue`, both of `application-spec`.
|
|
9
|
+
*
|
|
10
|
+
* Which markers are allowed at a given slot is controlled by
|
|
11
|
+
* `EnhancedJsonValueCaps` of `application-spec`, not by the type — all markers parse
|
|
12
|
+
* identically, capability checks kick in at lowering time.
|
|
13
|
+
*/
|
|
14
|
+
export type EnhancedJsonValue = string | number | boolean | null | MsgMarker | EvalMarker | EnhancedJsonArray | EnhancedJsonObject;
|
|
15
|
+
/** Array form of {@link EnhancedJsonValue} — extracted as a named interface so `z.lazy` can close the recursion. */
|
|
16
|
+
export interface EnhancedJsonArray extends ReadonlyArray<EnhancedJsonValue> {
|
|
17
|
+
}
|
|
18
|
+
/** Object form of {@link EnhancedJsonValue} — extracted for the same reason as {@link EnhancedJsonArray}. */
|
|
19
|
+
export interface EnhancedJsonObject {
|
|
20
|
+
readonly [key: string]: EnhancedJsonValue;
|
|
21
|
+
}
|
|
22
|
+
/** Runtime `self` accessor — shape-agnostic entity state. */
|
|
23
|
+
export type SelfAccessor = object;
|
|
24
|
+
/**
|
|
25
|
+
* Deterministic string key for a value — sorted object keys, JSON-encoded.
|
|
26
|
+
* Used by the expression runtime's reference store to preserve an evaluator when the
|
|
27
|
+
* underlying value is structurally unchanged (mirrors the content-hash pattern
|
|
28
|
+
* used for components).
|
|
29
|
+
*/
|
|
30
|
+
export declare const canonicalEnhancedJsonValueKey: (value: EnhancedJsonValue) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const canonicalEnhancedJsonValueKey=r=>{let e=r=>{if(null===r||"object"!=typeof r)return r;if(Array.isArray(r))return r.map(e);let t={};for(let n of Object.keys(r).sort())t[n]=e(r[n]);return t};return JSON.stringify(e(r))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./application/index.js";export*from"./components/index.js";export*from"./enhanced-json-value.js";export*from"./expressions/index.js";export*from"./markers/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./eval-marker.js";export*from"./msg-marker.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MessageDescriptor } from '@lingui/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/** Key literal for the `$msg` marker in raw YAML. */
|
|
4
|
+
export declare const MSG_MARKER_KEY: '$msg';
|
|
5
|
+
/** Key literal for the optional `$msgId` qualifier on `$msg`. */
|
|
6
|
+
export declare const MSG_ID_MARKER_KEY: '$msgId';
|
|
7
|
+
/**
|
|
8
|
+
* YAML marker produced by `$msg: 'text'` / `$msg: 'text', $msgId: 'id'` entries.
|
|
9
|
+
* `$msgId` is a qualifier on `$msg`, not a standalone marker.
|
|
10
|
+
*/
|
|
11
|
+
export interface MsgMarker {
|
|
12
|
+
readonly $msg: string;
|
|
13
|
+
readonly $msgId?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Zod decoder for {@link MsgMarker}. Strict — rejects extra keys. */
|
|
16
|
+
export declare const msgMarkerSchema: z.ZodObject<{
|
|
17
|
+
$msg: z.ZodString;
|
|
18
|
+
$msgId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, "strict", z.ZodTypeAny, {
|
|
20
|
+
$msg: string;
|
|
21
|
+
$msgId?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
$msg: string;
|
|
24
|
+
$msgId?: string | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
/** Structural type guard for {@link MsgMarker}. */
|
|
27
|
+
export declare const isMsgMarker: (value: unknown) => value is MsgMarker;
|
|
28
|
+
export declare const createMessageDescriptor: (marker: MsgMarker) => MessageDescriptor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{generateMessageId as s}from"@lingui/message-utils/generateMessageId";import{z as e}from"zod";export const MSG_MARKER_KEY="$msg";export const MSG_ID_MARKER_KEY="$msgId";export const msgMarkerSchema=e.object({$msg:e.string(),$msgId:e.string().optional()}).strict();export const isMsgMarker=s=>msgMarkerSchema.safeParse(s).success;export const createMessageDescriptor=e=>({id:e.$msgId??s(e.$msg),message:e.$msg});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import r from"lodash-es/debounce.js";import t from"promise-queue";import{createContext as o,useCallback as n,useContext as i,useEffect as s,useMemo as a,useRef as c,useState as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import r from"lodash-es/debounce.js";import t from"promise-queue";import{createContext as o,useCallback as n,useContext as i,useEffect as s,useMemo as a,useRef as c,useState as l}from"react";import{match as m}from"ts-pattern";import{ApplicationRuntime as u,BinaryFile as p,RawProjectFiles as d,RuntimeReferenceStore as g,TextFile as f,buildPhoenixDefinitions as v,isConfiguratorModelSchemaCompatible as S,isTextFile as h,parseApplicationFiles as y}from"#package/application-spec";import{createImplementationErrorCollector as E,findActionImplementationConflicts as x,getAllPhxDefinitions as A}from"#package/domain";import{useApplicationRuntime as C,useMountGuard as D}from"#package/react-sdk";import{useEditorConnection as w}from"../services/EditorConnectionContext.js";import{trpc as N}from"../services/trpc.js";import{applyRuntimeReset as P,applySpecUpdate as R,prepareRuntimeRefresh as _,prepareRuntimeReset as j}from"./apply-spec-update.js";import{useDiagnostics as I}from"./use-diagnostics.js";import{useImplementationFiles as L}from"./use-implementation-files.js";import{getWasmSwcParsers as k}from"./wasm-swc-parsers.js";let b=o(null),M={debug:e=>console.debug(e)},O=e=>e instanceof Error?e.message:String(e);export const DomainSpecProvider=o=>{let{children:i,domainSpec:T,initialRawProjectFiles:$}=o,[F,z]=l(a(()=>T?[{fileName:"domain.yaml",content:T}]:$?$.files.filter(h).map(e=>({fileName:e.name,content:e.content})):[],[T,$])),[H,q]=l(null),U=a(()=>new g,[]),G=a(()=>v(A()),[]),Q=c(null),B=C(),{getImplementationFiles:V}=L(),{diagnostics:Y,unreadDiagnosticCount:Z,setDiagnostics:J,pushDiagnostic:K,clearDiagnostics:W,markDiagnosticsRead:X}=I(),ee=a(()=>new t(1,1/0),[]),er=c(0),et=c(null),{mutateAsync:eo}=N.requestSpecFiles.useMutation(),{mutateAsync:en}=N.save.useMutation(),ei=D(),{localMode:es,connectionStatus:ea}=w(),{data:ec}=N.getEditorConfig.useQuery(void 0,{enabled:!es&&"connected"===ea}),el=es||ec?.specSync===!0,em=F.length>0?F:void 0,eu=a(()=>F.map(e=>e.fileName),[F]),ep=a(()=>r(async e=>{if(!es&&"connected"===ea&&0!==e.length)try{await en(e.map(e=>({fileName:e.fileName,content:e.content})))}catch(e){console.error("[DomainSpecContext] Failed to save files to disk:",e)}},1e3),[es,ea,en]);s(()=>()=>{ep.cancel()},[ep]);let ed=n(()=>{q(null)},[]),eg=n(async(e,r)=>{z(t=>{let o=t.find(r=>r.fileName===e)?t.map(t=>t.fileName===e?{...t,content:r}:t):[...t,{fileName:e,content:r}];return ep(o),o})},[ep]),ef=n(async(e,r)=>{let t,o,n=()=>ei()&&er.current===r;if(!n())return;let i=d(e.rawProjectFiles.files.map(e=>m(e).with({kind:"text"},e=>f(e.name,e.content)).with({kind:"binary"},e=>p(e.name)).exhaustive()));z(i.files.filter(h).map(e=>({fileName:e.name,content:e.content})));try{t=await k()}catch(e){if(!n())return;J([{code:"MODULE_ANALYZER_UNAVAILABLE",message:`The editor's module analyzer failed to load: ${e instanceof Error?e.message:String(e)}`,severity:"error",source:"spec",path:[]}]);return}if(!n())return;let s=y({rawProjectFiles:i,phxDefinitions:G},{analyzer:t.analyzer,evalExpressionParser:t.evalExpressionParser,referenceStore:U,logger:M});if(console.info(`[DomainSpecContext] Spec parsed: ${s.ok?"ok":"error"}, ${s.diagnostics.length} diagnostics`),!s.ok)return void J([...s.errors,...s.diagnostics].map(e=>({...e,source:"spec"})));W();let{applicationSpec:a}=s.value,c=await V({application:s.value,projectRoot:e.projectRoot});if(!n())return;if(c.errors.length>0)return void J(c.errors.map(e=>({code:e.code,message:e.message,severity:"error",source:"reload",path:[]})));let l=x([...a.configurator.actions.values()].map(e=>String(e.name)),c.actionImplementations??B.getState().spec.configurator.actionImplementations);if(l.extra.length>0&&console.error(`[DomainSpecContext] Action implementations without a declaration: ${l.extra.join(", ")}`),l.missing.length>0){let e=`Missing action implementations: ${l.missing.join(", ")}. Add each to a default export of phx.domain.implementActions({ ... }) in src/actions/.`;console.error(`[DomainSpecContext] ${e}`),K({code:"MISSING_ACTION_IMPLEMENTATIONS",message:e,severity:"error",source:"runtime"});return}let g=E(),v=u(a,U,c.expressionModules,c.importedTransformers,c.invariantImplementations,c.adminExpressionModules,void 0,void 0,void 0,g);for(let e of g.recorded())console.error(`[DomainSpecContext] ${e.message}`),K({code:e.code,message:e.message,severity:"error",source:"runtime"});if(!v.ok)return void U.clear();let{runtime:A}=v,C=null===Q.current||S(Q.current.configurator,a.configurator),D=B.selectors.environment.getPersistenceConfig();if(!C){let e;if("server"===D.type)return void K({code:"HOT_RELOAD_MODEL_CHANGE_REQUIRES_RESTART",message:"Domain model changes require an application restart and were not applied.",severity:"error",source:"runtime"});if(!B.selectors.domainContext.configurator.getInitializationState().isCurrent)return void B.selectors.domainServices.getLogger().debug("[DomainSpecContext] Skipping the model reset because no configurator session is initialized; the change applies once a session loads under the new spec.");try{e=j({runtime:A,implementationFiles:c,previousSpec:B.getState().spec})}catch(e){K({code:"HOT_RELOAD_PREPARE_FAILED",message:O(e),severity:"error",source:"runtime"});return}for(let r of(B.selectors.domainServices.getLogger().debug("[DomainSpecContext] Reseeding the reset session directly from the spec preset; onPresetLoadedHandler and ProductSelected analytics are intentionally skipped."),P(B,e,B.selectors.domainApplicationContext.configurator.getConfigurationPersistSystem().revisionId$.value),Q.current=a,e.implementationErrors))K({code:r.code,message:r.message,severity:"error",source:"runtime"});return}try{o=_({runtime:A,implementationFiles:c,previousSpec:B.getState().spec})}catch(e){K({code:"HOT_RELOAD_PREPARE_FAILED",message:O(e),severity:"error",source:"runtime"});return}if(n())for(let e of(R(B,o),Q.current=a,o.implementationErrors))K({code:e.code,message:e.message,severity:"error",source:"runtime"})},[B,V,ei,G,K,U,J,W]),ev=c(null),eS=n(e=>{let r=er.current+1;er.current=r,et.current={data:e,generation:r},ee.add(async()=>{let e=et.current;e&&e.data!==ev.current&&(et.current=null,ev.current=e.data,await ef(e.data,e.generation))})},[ef,ee]);N.onSpecChange.useSubscription(void 0,{enabled:!es&&el,onData:eS}),s(()=>{!es&&el&&eo().catch(()=>{console.warn("[DomainSpecContext] Failed to request spec files")})},[eo,es,el]);let eh=a(()=>({files:em,fileNames:eu,updateFile:eg,parsing:!1,parseError:H,clearParseError:ed,diagnostics:Y,clearDiagnostics:W,unreadDiagnosticCount:Z,markDiagnosticsRead:X}),[em,eu,eg,H,ed,Y,W,Z,X]);return e(b.Provider,{value:eh,children:i})};export const useDomainSpecContext=()=>{let e=i(b);if(null===e)throw Error("useDomainSpecContext must be used within DomainSpecProvider");return e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ApplicationRuntime as GeneratedApplicationRuntime } from '#package/application-spec';
|
|
2
2
|
import { type ImplementationError, type ApplicationSpec as RuntimeApplicationSpec } from '#package/domain';
|
|
3
3
|
import type { ApplicationRuntime } from '#package/react-sdk';
|
|
4
4
|
import type { ImplementationFiles } from './use-implementation-files.js';
|
|
@@ -23,6 +23,7 @@ export interface PrepareRuntimeRefreshInput {
|
|
|
23
23
|
readonly implementationFiles: ImplementationFiles;
|
|
24
24
|
readonly previousSpec: RuntimeApplicationSpec;
|
|
25
25
|
}
|
|
26
|
+
/** Refreshes the configurator sections of the live spec while the model's schema stays. */
|
|
26
27
|
export declare const prepareRuntimeRefresh: (input: PrepareRuntimeRefreshInput) => PreparedRuntimeRefresh;
|
|
27
28
|
/** Rebuilds every model-owned configurator field for an incompatible schema replacement. */
|
|
28
29
|
export declare const prepareRuntimeReset: (input: PrepareRuntimeRefreshInput) => PreparedRuntimeReset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{applicationSpecSlice as e}from"#package/application-spec";import{findAssistantFormElementErrors as t}from"#package/domain";import{getPhoenixThemes as o}from"#package/ui-sdk";let n=e=>({handlers:e.handlers,elements:e.elements,customComponentOptics:e.customComponentOptics,actionImplementations:e.actionImplementations}),r=({configurator:e})=>t(e.assistant?.formElements??[],e.elements);export const prepareRuntimeRefresh=t=>{let i=e({runtime:t.runtime,modules:n(t.implementationFiles),themePresets:o(),previous:t.previousSpec,model:"keep"});return{nextSpec:i,implementationErrors:r(i)}};export const prepareRuntimeReset=t=>{let i=e({runtime:t.runtime,modules:n(t.implementationFiles),themePresets:o(),previous:t.previousSpec,model:"rebuild"}),s=i.configurator.presets[0];if(void 0===s)throw Error("Cannot reset the configurator after a model change because the application spec has no presets.");return{firstPreset:s,nextSpec:i,implementationErrors:r(i)}};let i=(e,t)=>{e.actions.spec.updateSpec(t)};export const applyRuntimeRefresh=(e,t)=>i(e,t.nextSpec);export const applyRuntimeReset=(e,t,o)=>{i(e,t.nextSpec),e.actions.loadedData.completeConfiguratorLoad({initialRevisionId:o,initialEntities:t.firstPreset.initialDomainEntities,modelVersion:t.nextSpec.configurator.modelVersion,rootEntityType:t.firstPreset.rootEntityType,schemaIdentity:t.nextSpec.configurator.factory})};export const applySpecUpdate=(e,t)=>i(e,t.nextSpec);
|
|
@@ -44,9 +44,6 @@ export interface GetImplementationFilesProps {
|
|
|
44
44
|
readonly projectRoot: string;
|
|
45
45
|
}
|
|
46
46
|
export declare const mergeComponentOptics: <ComponentOptic>(generatedComponentOptics: readonly ComponentOptic[], customComponentOptics: readonly ComponentOptic[]) => readonly ComponentOptic[];
|
|
47
|
-
export declare const getCustomComponentOptics: <ComponentOptic extends {
|
|
48
|
-
readonly generated?: boolean;
|
|
49
|
-
}>(componentOptics: readonly ComponentOptic[]) => readonly ComponentOptic[];
|
|
50
47
|
/**
|
|
51
48
|
* Owns the should-reload gating and cross-update caching for project implementation files
|
|
52
49
|
* (expressions, actions, invariants, components, transformers, handlers, elements). Returns `getImplementationFiles`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as e,useRef as n}from"react";import{resolveActionModules as t,resolveComponentOpticModules as a,resolveElementModule as r,resolveHandlerModule as o,resolveInvariantModules as i,resolveTransformerModule as s}from"#package/domain";import{importImplementationFile as l}from"./import-implementation-file.js";let m=e=>e instanceof Error?e.message:String(e),c=async(e,n)=>{let t=Date.now();return Promise.all(e.map(async e=>({origin:e,exports:await l(`/@fs/${n}/${e}?t=${t}`)})))},p=async(e,n)=>t(await c(e,n));export const mergeComponentOptics=(e,n)=>e.concat(n);
|
|
1
|
+
import{useCallback as e,useRef as n}from"react";import{resolveActionModules as t,resolveComponentOpticModules as a,resolveElementModule as r,resolveHandlerModule as o,resolveInvariantModules as i,resolveTransformerModule as s}from"#package/domain";import{importImplementationFile as l}from"./import-implementation-file.js";let m=e=>e instanceof Error?e.message:String(e),c=async(e,n)=>{let t=Date.now();return Promise.all(e.map(async e=>({origin:e,exports:await l(`/@fs/${n}/${e}?t=${t}`)})))},p=async(e,n)=>t(await c(e,n));export const mergeComponentOptics=(e,n)=>e.concat(n);let u=async(e,n)=>a(await c(e,n)),d=async(e,n)=>i(await c(e,n)),f=async(e,n)=>(await c(e,n)).map(s),h=async(e,n)=>(await c(e,n)).map(e=>({filePath:e.origin,registrations:o(e)})),g=async(e,n)=>(await c(e,n)).map(e=>({filePath:e.origin,registrations:r(e)}));export const useImplementationFiles=()=>{let t=n([]),a=n(null),r=n([]),o=n(0),i=n(null),s=n({}),l=n(null),E=n(null),F=n(null),w=n([]),I=n(null),y=n(null),A=n(new Map),R=n(new Map);return{getImplementationFiles:e(async e=>{let{application:n,projectRoot:O}=e,D=++o.current,{applicationSpec:L,categorizedFiles:S}=n,C=[],_=t.current,$=r.current,v=s.current,x=F.current,N=w.current,M=S.expressionsChanged,P=S.actionsChanged,b=S.componentsChanged,H=S.transformersChanged,T=S.handlersChanged,k=S.elementsChanged,j=Object.fromEntries(S.invariants.map(e=>[e.file.name,e.depHash])),J=l.current,X=JSON.stringify(L.configurator.invariants.entries),V=null===J||E.current!==X||Object.keys(J).length!==S.invariants.length||S.invariants.some(e=>J[e.file.name]!==e.depHash);if(console.info(`[useImplementationFiles] Changed: spec=${S.specChanged}, expressions=${S.expressionsChanged}, actions=${S.actionsChanged}, adminExpressions=${S.adminExpressionsChanged}, transformers=${S.transformersChanged}, handlers=${S.handlersChanged}, elements=${S.elementsChanged}`),M){console.info("[useImplementationFiles] Reloading expression implementations");try{t.current=_=await c(S.expressions.map(e=>e.file.name),O)}catch(e){console.warn("[useImplementationFiles] Failed to reload expressions:",e),C.push({code:"RELOAD_EXPRESSIONS_FAILED",message:m(e)})}}let q=a.current;if(P){console.info("[useImplementationFiles] Reloading action implementations");try{a.current=q=await p(S.actions.map(e=>e.file.name),O)}catch(e){console.warn("[useImplementationFiles] Failed to reload actions:",e),C.push({code:"RELOAD_ACTIONS_FAILED",message:m(e)})}}let z=JSON.stringify({projectRoot:O,files:S.adminExpressions.map(e=>[e.file.name,e.depHash])});if(D===o.current&&i.current!==z)try{$=await c(S.adminExpressions.map(e=>e.file.name),O),D===o.current&&(r.current=$,i.current=z)}catch(e){C.push({code:"RELOAD_ADMIN_EXPRESSIONS_FAILED",message:m(e)})}if(b){console.info("[useImplementationFiles] Reloading component optics");try{F.current=x=await u(S.components.map(e=>e.file.name),O)}catch(e){console.warn("[useImplementationFiles] Failed to reload components:",e),C.push({code:"RELOAD_COMPONENTS_FAILED",message:m(e)})}}if(V){console.info("[useImplementationFiles] Reloading invariant implementations");try{s.current=v=await d(S.invariants.map(e=>e.file.name),O),l.current=j,E.current=X}catch(e){console.warn("[useImplementationFiles] Failed to reload invariants:",e),C.push({code:"RELOAD_INVARIANTS_FAILED",message:m(e)})}}if(H){console.info("[useImplementationFiles] Reloading transformer implementations");try{w.current=N=await f(S.transformers.map(e=>e.file.name),O)}catch(e){console.warn("[useImplementationFiles] Failed to reload transformers:",e),C.push({code:"RELOAD_TRANSFORMERS_FAILED",message:m(e)})}}let B=null;if(T){console.info("[useImplementationFiles] Reloading handler implementations");try{let e=Object.fromEntries(S.handlers.map(e=>[e.file.name,e.depHash])),n=I.current,t=t=>null===n||n[t]!==e[t],a=R.current,r=S.handlers.map(e=>e.file.name),o=r.filter(e=>t(e)||!a.has(e)),i=await h(o,O),s=new Map(i.map(e=>[e.filePath,e])),l=r.map(e=>{let n=s.get(e)??a.get(e);if(!n)throw Error(`Handler file "${e}" was neither re-imported nor cached from a previous round. This is a hot-reload bookkeeping bug — reload the editor page to recover.`);return n}),m=l.flatMap(e=>e.registrations),c={};for(let{filePath:n,registrations:a}of l){let r=t(n)?e[n]:void 0;if(r)for(let e of a)c[e.name]=r}console.info(`[useImplementationFiles] Staged handlers for registry (${m.length} total)`),B={handlers:m,nameHashes:c},R.current=new Map(l.map(e=>[e.filePath,e])),I.current=e}catch(e){console.warn("[useImplementationFiles] Failed to reload handlers:",e),C.push({code:"RELOAD_HANDLERS_FAILED",message:m(e)})}}let G=null;if(k){console.info("[useImplementationFiles] Reloading element implementations");try{let e=Object.fromEntries(S.elements.map(e=>[e.file.name,e.depHash])),n=y.current,t=t=>null===n||n[t]!==e[t],a=A.current,r=S.elements.map(e=>e.file.name),o=r.filter(e=>t(e)||!a.has(e)),i=await g(o,O),s=new Map(i.map(e=>[e.filePath,e])),l=r.map(e=>{let n=s.get(e)??a.get(e);if(!n)throw Error(`Element file "${e}" was neither re-imported nor cached from a previous round. This is a hot-reload bookkeeping bug — reload the editor page to recover.`);return n}),m=l.flatMap(e=>e.registrations),c={},p=0;for(let{filePath:n,registrations:a}of l){let r=t(n)?e[n]:void 0;for(let e of a)if("assistantFormElement"!==e.type){if("entity"===e.type||"layout"===e.type){r&&(c[e.name]=r);continue}r&&(c[`icon:${p}`]=r),p+=1}}console.info(`[useImplementationFiles] Staged elements for registry (${m.length} total)`),G={elements:m,nameHashes:c},A.current=new Map(l.map(e=>[e.filePath,e])),y.current=e}catch(e){console.warn("[useImplementationFiles] Failed to reload elements:",e),C.push({code:"RELOAD_ELEMENTS_FAILED",message:m(e)})}}return{expressionModules:_,actionImplementations:q,adminExpressionModules:$,invariantImplementations:v,importedTransformers:N,customComponentOptics:x,handlers:B,elements:G,errors:C}},[])}};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{symlink as e}from"fs/promises";import{ParseContext as i}from"#package/application-spec";import{extractAndCompileLingui as
|
|
2
|
-
${
|
|
1
|
+
import{symlink as e}from"fs/promises";import{ParseContext as i}from"#package/application-spec";import{bootstrapLinguiCatalogs as t,extractAndCompileLingui as p}from"../lingui/index.js";import{compileWithSwc as a}from"../services/swc.js";import{exists as o}from"../utils/index.js";import{ApplicationSpecBuilder as r}from"./application-spec-builder.js";import{formatMetrics as c}from"./metrics/index.js";import{syncTemplateFiles as s}from"./template-files.js";let n=".phoenix",l=async(e,i)=>{let t=i.startSpan("swcCompile(src)","sync","generate-application-spec-project.ts");await a({sourceDir:"src",outDir:`./${n}/.swc/src`},{logger:e}),t();let p=i.startSpan("swcCompile(.phoenix)","sync","generate-application-spec-project.ts");await a({sourceDir:n,outDir:`./${n}/.swc/${n}`},{logger:e}),p()};export const generateApplicationSpecProject=async a=>{let{withLingui:n=!0,force:m=!1,analyze:u=!1}=a,g=a.logger;g.info("Using application-spec pipeline");let j=new i,w=j.startSpan("sync","generateApplicationSpecProject","generate-application-spec-project.ts"),f=j.startSpan("build","sync","application-spec-builder.ts"),S=new r({logger:g,sdkVersion:a.sdkVersion,projectSlug:a.projectSlug,environmentSlug:a.environmentSlug,cliUseWorkspace:a.cliUseWorkspace,enableEditor:a.enableEditor??!0,inlineTemplates:a.inlineTemplates??!1}),d=await S.build({force:m,parsingContext:j,compile:!1});if(f(),!d.ok)throw Error(`Failed to build the project files:
|
|
2
|
+
${d.errors.map(e=>` [${e.code}] ${e.message}`).join("\n")}`);let b=j.startSpan("symlink","sync","generate-application-spec-project.ts");await o("./.phoenix/public")||await e("../public","./.phoenix/public");let x=await s();if(b(),n){let e=j.startSpan("lingui","sync","generate-application-spec-project.ts");await p({logger:g}),e()}else await t(d.application.applicationSpec.configurator.ui.availableLocales,{logger:g});return await l(g,j),w(),u&&c(j.metrics,j.counts,g),{templateFiles:x,applicationSpec:d.application.applicationSpec}};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DeploymentAssistant } from '@salsita-ai/contracts/assistant';
|
|
2
|
+
import { type ApplicationSpec } from '#package/application-spec';
|
|
2
3
|
import type { Logger } from '../utils/index.js';
|
|
3
4
|
interface ResolveOptions {
|
|
4
5
|
readonly skipUpload: boolean;
|
|
@@ -22,6 +23,8 @@ interface DeploymentData {
|
|
|
22
23
|
readonly assistant: boolean;
|
|
23
24
|
/** Generated locally for prepare-command diagnostics; never sent to the server. */
|
|
24
25
|
readonly assistantSetup: DeploymentAssistant | undefined;
|
|
26
|
+
/** {@link getDeploymentFingerprint} of the spec the data was resolved from; never sent to the server. */
|
|
27
|
+
readonly fingerprint: string;
|
|
25
28
|
readonly assets: {
|
|
26
29
|
readonly privateFilePaths: readonly string[];
|
|
27
30
|
readonly publicFilePaths: readonly string[];
|
|
@@ -29,6 +32,14 @@ interface DeploymentData {
|
|
|
29
32
|
readonly publicFilesFullPaths: readonly string[];
|
|
30
33
|
};
|
|
31
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Fingerprint of what the server applies to the requests of a deployment prepared from the spec: the configurator and
|
|
37
|
+
* admin configuration schemas with their versions, the published data schema, the auth hook, the roles that may
|
|
38
|
+
* create configurations and the assistant. Preparing a development deployment records it in the generated env file,
|
|
39
|
+
* and `phoenix dev` prepares again when the spec's fingerprint differs from the recorded one, such as after a domain
|
|
40
|
+
* model change.
|
|
41
|
+
*/
|
|
42
|
+
export declare const getDeploymentFingerprint: (applicationSpec: ApplicationSpec) => string;
|
|
32
43
|
/** Resolves deployment data using the new application-spec pipeline (parse only, no codegen/write). */
|
|
33
44
|
export declare const resolveApplicationSpecDeploymentData: (options: ResolveOptions) => Promise<DeploymentData>;
|
|
34
45
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{RuntimeReferenceStore as
|
|
2
|
-
${u.errors.map(e=>` [${e.code}] ${e.message}`).join("\n")}`);let{
|
|
1
|
+
import{createHash as e}from"node:crypto";import{RuntimeReferenceStore as a,buildPhoenixDefinitions as s,parseApplicationFiles as t}from"#package/application-spec";import{generateAssistantPrompt as i,getAllPhxDefinitions as n}from"#package/domain";import{readApplicationFiles as o}from"./application-spec-file-reader.js";import{readProjectAssets as r}from"./read-project-assets.js";import{swcEvalExpressionParser as c,swcModuleAnalyzer as l}from"./swc-module-analyzer.js";let p=e=>null!==e.assistant&&null!==e.assistantServerSettings;export const getDeploymentFingerprint=a=>{let{configurator:s,admin:t,appMetadata:i,infra:n}=a,o={configurationSchema:[s.configurationSchema.version,s.configurationSchema.hash],adminConfigurationSchema:[t.configurationSchema.version,t.configurationSchema.hash],publishedDataHash:s.dataSchemas.publishedDataHash,useAuthHook:i.useAuthHook,aclCanCreate:n.acl.canCreate,assistant:p(s)};return e("sha256").update(JSON.stringify(o)).digest("hex")};export const resolveApplicationSpecDeploymentData=async e=>{let{skipUpload:h,logger:m}=e,u=t({rawProjectFiles:await o({envs:{}}),phxDefinitions:s(n())},{analyzer:l,evalExpressionParser:c,referenceStore:new a,logger:m});if(!u.ok)throw Error(`Failed to parse application spec:
|
|
2
|
+
${u.errors.map(e=>` [${e.code}] ${e.message}`).join("\n")}`);let{applicationSpec:d}=u.value,{configurator:g,admin:f}=d,{configurationSchema:S}=g,v=f.configurationSchema,F=await r(),b=[],A=[],D=[],y=[];h||(b=F.privateAssetFiles,A=F.publicAssetFiles,D=F.privateAssetFilesFullPaths,y=F.publicAssetFilesFullPaths,m.debug(`Scanned assets: ${b.length} private files, ${A.length} public files`));let{appMetadata:H,infra:k}=d,{assistant:C,assistantServerSettings:j}=g;return{schema:{...S.schema},schemaVersion:S.version,adminSchema:{...v.schema},adminSchemaVersion:v.version,applicationVersion:H.applicationVersion,publishedDataHash:g.dataSchemas.publishedDataHash,useAuthHook:H.useAuthHook,aclCanCreate:k.acl.canCreate,embeddings:void 0,chat:void 0,assistant:p(g),assistantSetup:C&&j?{sdl:C.sdl,prompt:i(C),instructions:j.instructions??void 0,ai:j.ai}:void 0,fingerprint:getDeploymentFingerprint(d),assets:{privateFilePaths:b,publicFilePaths:A,privateFilesFullPaths:D,publicFilesFullPaths:y}}};
|
package/dist/phoenix/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{assertSupportedNodeVersion as
|
|
2
|
+
import{assertSupportedNodeVersion as e}from"./utils/node-version/index.js";e(),await import("./cli.js").catch(e=>{throw console.error("If this error comes from loading a dependency, check peerDependencies in the installed @salsita-ai/sdk package.json, align your project's dependencies, reinstall, and retry."),e});
|
package/dist/phoenix/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bool as e,str as o}from"envalid";import{readFileSync as t}from"fs";import{readFile as i}from"fs/promises";import{arch as r,platform as n}from"os";import{dirname as a,join as s,resolve as l}from"path";import{P as p,match as d}from"ts-pattern";import{fileURLToPath as c}from"url";import u from"yargs";import{hideBin as E}from"yargs/helpers";import{z as v}from"zod";import{createEnvReader as f}from"@salsita-ai/common/env";import{DEFAULT_PROJECT_ALIAS as g,FeedbackType as m}from"@salsita-ai/contracts/domain";import{phoenixCli as h}from"#package/legacy";import{readSpecProject as y}from"./application-spec/read-spec-project.js";import{prepareDevelopmentEnvironment as S,prepareLocalEnvironment as R,runActivateDeploymentCommand as _,runBuildCommand as O,runChangelogCommand as U,runCheckCommand as P,runCleanCommand as b,runCleanupEnvironmentCommand as L,runCreateEnvironmentCommand as I,runDataCommand as N,runDeployCommand as T,runDeploymentBuildEnvsCommand as w,runDepsCommand as k,runDevCommand as D,runDocsCommand as j,runExtractSourcesCommand as G,runFeedbackCommand as C,runFinishDeploymentCommand as A,runFixCommand as K,runInitCommand as V,runInspectAssetsCommand as M,runLinkCommand as J,runListEnvironmentsCommand as B,runLoginCommand as F,runLogoutCommand as x,runPrepareCiCommand as Y,runPrepareDeploymentCommand as q,runRegisterDeploymentCommand as H,runSceneCommand as W,runScreenshotCommand as $,runStateCommand as X,runStoryCommand as z,runSyncCommand as Q,runUnlinkCommand as Z,runVariantsCommand as ee}from"./commands/index.js";import{DEFAULT_PHOENIX_REGION as eo,PHOENIX_REGIONS as et,PUBLIC_PHOENIX_REGIONS as ei,VariantFileSession as er,getRegionServerUrl as en,getRegionStudioUrl as ea,resolveSignedInDevelopmentEnvironment as es}from"./services/index.js";import{getIsEditorEnabled as el}from"./utils/get-is-editor-enabled.js";import{createLogger as ep}from"./utils/index.js";let ed=(e,o,t)=>{e?.info(`Using ${o?"application-spec":"domain-spec"} flow (${t})`)},ec=(e,o,t)=>{let i=t?.logger??ep();if(void 0!==e)return i.detail(`Application spec: ${e} (from CLI flag)`),ed(t?.logger,e,"from CLI flag"),e;let r=process.env.USE_APPLICATION_SPEC;if(void 0!==r){let e="true"===r||"1"===r;return i.detail(`Application spec: ${e} (from environment variable)`),ed(t?.logger,e,"from environment variable"),e}return void 0!==o?(i.detail(`Application spec: ${o} (from package.json phoenix.applicationFlow)`),ed(t?.logger,o,"from package.json phoenix.applicationFlow"),o):(i.detail("Application spec: false (default)"),ed(t?.logger,!1,"default"),!1)},eu=t(s(a(c(import.meta.url)),"../../package.json"),"utf-8");if(!eu)throw Error("Project package.json is required, please provide it in the package.json file");let eE=v.object({version:v.string({required_error:"Project version is required, please provide it in the package.json file"}),name:v.string({required_error:"Project name is required, please provide it in the package.json file"}),dependencies:v.object({eslint:v.string(),prettier:v.string()})}).parse(JSON.parse(eu)),ev=async()=>{try{let e=await i("./package.json","utf-8"),o=JSON.parse(e);return{name:o.name,applicationFlow:o.phoenix?.applicationFlow}}catch{return{name:void 0,applicationFlow:void 0}}},ef=e=>{if(!(e instanceof Error))return String(e);let o=(e=>{if(!(e instanceof Error))return;if(e.message.length>0)return e.message;let o=(e instanceof AggregateError?e.errors:[]).find(e=>e instanceof Error&&e.message.length>0);return o instanceof Error?o.message:"code"in e&&"string"==typeof e.code?e.code:void 0})(e.cause);return void 0===o?e.message:`${e.message}: ${o}`};await u(E(process.argv)).scriptName("phoenix").usage("$0 <command> [options]").command(["build","b"],"Build the project",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("onlyFrontend",{alias:"F",type:"boolean",description:"Build only frontend bundle"}).option("onlyWebhook",{alias:"W",type:"boolean",description:"Build only webhooks"}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("banner",{type:"string",requiresArg:!0,description:"Text for the comment at the top of every frontend .js file, public in the bundle (default: application version from the spec and the git commit when available)",coerce:e=>"string"==typeof e?e:e.join("\n")}),async t=>{let i,r=f({PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1}),BUILD_TARGET:o({choices:["frontend","webhook","both"],default:"both"}),FORCE_REBUILD:e({default:!1})})(),n=ep({debug:t.debug??r.DEBUG}),a=el(t.editor,r.ENABLE_EDITOR),s=t.force??r.FORCE_REBUILD,l=await ev(),p=ec(t.applicationSpec,l.applicationFlow,{logger:n}),d=t.projectSlug??r.PROJECT_SLUG??l.name,c=t.environmentSlug??r.ENVIRONMENT_SLUG??l.name;if(!d)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!c)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");let u=t.onlyFrontend,E=t.onlyWebhook;if(u&&E)throw Error("Cannot use --onlyFrontend and --onlyWebhook flags together, they are mutually exclusive");i=u?"frontend":E?"webhook":r.BUILD_TARGET;let v={sdkVersion:eE.version,projectSlug:d,environmentSlug:c,cliUseWorkspace:t.workspace,enableEditor:a,buildTarget:i,force:s};await (p?O({...v,banner:t.banner},{logger:n}):h.runBuildCommand(v,{logger:n}))}).command(["clean","cl"],"Remove .phoenix and regenerate the project files; installs nothing (the legacy pipeline also removes node_modules and reinstalls)",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1})})(),r=ep({debug:t.debug??i.DEBUG}),n=el(t.editor,i.ENABLE_EDITOR),a=await ev(),s=ec(t.applicationSpec,a.applicationFlow,{logger:r}),l=t.projectSlug??i.PROJECT_SLUG??a.name,p=t.environmentSlug??i.ENVIRONMENT_SLUG??a.name;if(!l)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!p)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");await (s?b:h.runCleanCommand)({sdkVersion:eE.version,projectSlug:l,environmentSlug:p,cliUseWorkspace:t.workspace,enableEditor:n},{logger:r})}).command(["dev","d"],"Start development mode (Vite, spec watching, and the webhook tunnel)",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("editorWsPort",{alias:"ep",type:"string",description:"Port for the editor WebSocket server (defaults to EDITOR_WS_PORT env or 3020)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG; required in server mode unless --local; offline modes default to the package name)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG; required in server mode unless --local; offline modes default to the package name)"}).option("withLingui",{alias:"wl",type:"boolean",description:"Enable or disable i18n messages extraction and compilation (defaults to WITH_LINGUI env or false)"}).option("persistence",{alias:"P",type:"string",description:"Persistence mode for the configurator (defaults to PERSISTENCE_MODE env or server)",choices:["memory","local-storage","server"]}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("tui",{alias:"T",type:"boolean",description:"Render logs in a terminal UI with per-stream pages and split view; requires an interactive terminal (env: PHOENIX_TUI, default: false)"}).option("local",{type:"boolean",description:"Use local-mode development environment defaults (env: PHOENIX_LOCAL, default: false)"}).option("region",{choices:ei,description:`Phoenix region of the workspace you are signed in to, used when .env has no SERVER_URL (default: ${eo})`}).option("serverUrl",{type:"string",description:"URL of the Phoenix server, instead of SERVER_URL or the region default"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket when the development deployment is prepared (env: SKIP_UPLOAD, default: false)"}),async t=>{let i=f({ENABLE_EDITOR:e({default:!0}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),EDITOR_WS_PORT:o({default:"3020"}),DEBUG:e({default:!1}),WITH_LINGUI:e({default:!1}),PERSISTENCE_MODE:o({default:void 0}),FORCE_REBUILD:e({default:!1}),PHOENIX_TUI:e({default:!1}),SERVER_URL:o({default:void 0}),DEVELOPMENT_KEY:o({default:void 0}),PHOENIX_LOCAL:e({default:!1}),PHOENIX_REGION:o({choices:et,default:void 0}),SKIP_UPLOAD:e({default:!1})})(),r=t.debug??i.DEBUG,n=ep({debug:r}),a=el(t.editor,i.ENABLE_EDITOR),s=t.editorWsPort??i.EDITOR_WS_PORT,l=t.force??i.FORCE_REBUILD,c=t.withLingui??i.WITH_LINGUI,u=t.persistence??i.PERSISTENCE_MODE,E=!u||"server"===u,v=t.tui??i.PHOENIX_TUI,m=await ev(),S=ec(t.applicationSpec,m.applicationFlow,{logger:n}),R=t.local??i.PHOENIX_LOCAL,_=t.projectSlug??i.PROJECT_SLUG;S&&await er.recover(process.cwd(),n);let O=E&&S&&!R&&!_?.length?await y(process.cwd()):void 0,{serverUrl:U,developmentKey:P,apiToken:b,projectSlug:L,environmentSlug:I}=await d({useServer:E,local:R,serverUrl:t.serverUrl??i.SERVER_URL,developmentKey:i.DEVELOPMENT_KEY,projectSlug:_?.length?_:O,environmentSlug:t.environmentSlug??i.ENVIRONMENT_SLUG}).with({useServer:!1},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e,developmentKey:o,apiToken:void 0,projectSlug:t??m.name,environmentSlug:i??m.name})).with({local:!0},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e?.length?e:"http://localhost:3000",developmentKey:o?.length?o:"dev_local-dev-key-12345",apiToken:void 0,projectSlug:t?.length?t:"local",environmentSlug:i?.length?i:"dev-local"})).with({developmentKey:p.string.minLength(1)},()=>O===g,()=>{throw Error(`phoenix dev has a DEVELOPMENT_KEY, but the spec says \`project: ${g}\`, which only a signed-in workspace can resolve. Set PROJECT_SLUG in .env by pasting the .env block of your Studio development environment, or name the project's slug in the spec.`)}).with({serverUrl:p.string.minLength(1),developmentKey:p.string.minLength(1),projectSlug:p.string.minLength(1),environmentSlug:p.string.minLength(1)},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e,developmentKey:o,apiToken:void 0,projectSlug:t,environmentSlug:i})).with({developmentKey:p.union(void 0,""),projectSlug:p.string.minLength(1)},()=>S,async({serverUrl:e,projectSlug:o})=>{let r=e?.length?e:en(t.region??i.PHOENIX_REGION??eo),a=await es({serverUrl:r,project:o});return n.info(`Developing in ${a.projectSlug}/${a.environmentSlug} of workspace "${a.workspaceName}" on ${r}`),{serverUrl:r,developmentKey:void 0,apiToken:a.apiToken,projectSlug:a.projectSlug,environmentSlug:a.environmentSlug}}).with({developmentKey:p.union(void 0,""),projectSlug:p.union(void 0,"")},()=>S,()=>{throw Error(`phoenix dev does not know which project to develop in. Add \`project: ${g}\` to spec/application.yaml to use the default project of the workspace you are signed in to, or paste the .env block of a Studio development environment into .env. Pass --local to use the local-mode server.`)}).otherwise(()=>{throw Error("phoenix dev needs SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, and DEVELOPMENT_KEY in .env. Create a development environment for your project in Studio and paste its .env block, or pass --local to use the local-mode server.")});if(!L)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!I)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");let N={sdkVersion:eE.version,projectSlug:L,environmentSlug:I,cliUseWorkspace:t.workspace,enableEditor:a,editorWsPort:s,debug:r,withLingui:c,persistenceMode:u,force:l,tui:v,serverUrl:U,skipUpload:t.skipUpload??i.SKIP_UPLOAD};if(S){let e=P?{developmentKey:P}:b?{apiToken:b}:void 0;await D({...N,credential:e},{logger:n})}else await h.runDevCommand({...N,developmentKey:P},{logger:n})}).command(["link","l"],"Internal tool, pnpm only: link a local SDK checkout for development through pnpm overrides; installs nothing, run the pnpm install it prints next",e=>e.option("sdk-path",{type:"string",description:"Path to the SDK repository",default:"../configurator-phoenix"}),async e=>{let o=ep();try{await J({sdkPath:e.sdkPath},{logger:o})}catch{process.exit(1)}}).command(["unlink","ul"],"Internal tool, pnpm only: remove the local SDK link that phoenix link added; installs nothing, run the pnpm install it prints next",()=>{},async()=>{let e=ep();try{await Z({logger:e})}catch{process.exit(1)}}).command(["sync","s"],"Sync project files and compile specs without building vite/webhooks",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("analyze",{alias:"a",type:"boolean",description:"Print pipeline metrics flamegraph after build (requires --applicationSpec)"}),async t=>{let i=f({ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),FORCE_REBUILD:e({default:!1})})(),r=ep({debug:t.debug??i.DEBUG}),n=el(t.editor,i.ENABLE_EDITOR),a=t.force??i.FORCE_REBUILD,s=await ev(),l=ec(t.applicationSpec,s.applicationFlow,{logger:r}),p=t.projectSlug??i.PROJECT_SLUG??s.name,d=t.environmentSlug??i.ENVIRONMENT_SLUG??s.name;if(!p)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!d)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");await (l?Q:h.runSyncCommand)({sdkVersion:eE.version,projectSlug:p,environmentSlug:d,cliUseWorkspace:t.workspace,enableEditor:n,force:a,analyze:t.analyze},{logger:r})}).command(["deps"],"Bring package.json in line with the SDK's peer dependencies: add the missing ones and move out-of-range versions into the SDK's range. Installs nothing; install the dependencies with your package manager next",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async e=>{let o=ep({debug:e.debug??!1}),t=await ev();if(!ec(e.applicationSpec,t.applicationFlow,{logger:o}))return void o.info("phoenix deps changes nothing in a legacy project: phoenix sync manages its dependencies. Switch the project to the application-spec pipeline (phoenix.applicationFlow in package.json) to manage them with phoenix deps.");try{await k({projectRoot:process.cwd()},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command("init [folder]","Start a Phoenix project: write package.json with the SDK, its peers, ESLint and Prettier (an existing one gains only what it lacks) and a starter spec. Install the dependencies with your package manager, then continue with phoenix sync, phoenix login and phoenix dev",e=>e.positional("folder",{type:"string",description:"Folder to create the project in (default: the working directory)"}).option("scaffold",{type:"boolean",hidden:!0,description:"Accepted for compatibility and ignored: init always only writes the starter project"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging"}),async e=>{let o=ep({debug:e.debug??!1});try{await V({sdkVersion:eE.version,editorToolVersions:eE.dependencies,projectRoot:void 0===e.folder?void 0:l(e.folder)},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command(["story","st"],"Storybook example utilities",e=>z(e),()=>{}).command(["check","c"],"Run checks (TypeScript, ESLint, Prettier). Runs all by default, or only selected when any of --types/--lint/--format is passed.",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("types",{type:"boolean",description:"Run TypeScript check"}).option("lint",{type:"boolean",description:"Run ESLint check"}).option("format",{type:"boolean",description:"Run Prettier check"}),async o=>{let t=f({DEBUG:e({default:!1})})(),i=ep({debug:o.debug??t.DEBUG});await P({types:o.types,lint:o.lint,format:o.format},{logger:i})}).command(["fix","f"],"Fix linting and formatting issues. Runs all by default, or only selected when any of --lint/--format is passed.",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("lint",{type:"boolean",description:"Run ESLint fix"}).option("format",{type:"boolean",description:"Run Prettier fix"}),async o=>{let t=f({DEBUG:e({default:!1})})(),i=ep({debug:o.debug??t.DEBUG});await K({lint:o.lint,format:o.format},{logger:i})}).command(["changelog","clog"],"Display SDK changelog",e=>e.option("ver",{type:"string",description:"Show specific version (e.g., 0.36.0)"}).option("all",{alias:"a",type:"boolean",description:"Show all versions (warning: large output)"}).option("page",{alias:"p",type:"number",description:"Page number (3 versions per page)"}).option("list",{alias:"l",type:"boolean",description:"List version numbers only"}),async e=>{let o=ep();await U({version:e.ver,all:e.all,page:e.page,list:e.list},{logger:o})}).command(["inspect:assets","ia"],"Inspect 3D assets (glTF/GLB) — nodes, transforms, bounds, origin, materials, morph targets, animations",e=>e.option("file",{alias:"f",type:"string",description:"Path to specific glTF/GLB file"}).option("objects",{alias:"O",type:"boolean",description:"Show only object/node names"}).option("materials",{alias:"m",type:"boolean",description:"Show only material names"}).option("morphs",{alias:"M",type:"boolean",description:"Show only morph target names"}).option("animations",{alias:"a",type:"boolean",description:"Show only animation names"}).option("json",{alias:"j",type:"boolean",description:"Output as JSON"}),async e=>{let o=ep();await M({file:e.file,objects:e.objects,materials:e.materials,morphs:e.morphs,animations:e.animations,json:e.json},{logger:o})}).command(["screenshot","ss"],"Capture a screenshot of the configurator canvas",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (defaults to SCREENSHOT_OUTPUT env or ./screenshot.png)"}).option("width",{alias:"w",type:"number",description:"Width in pixels (default: 1920)"}).option("height",{alias:"H",type:"number",description:"Height in pixels (default: 1080)"}).option("format",{alias:"f",type:"string",description:"Image format: PNG or JPEG (default: PNG)"}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"}),SCREENSHOT_OUTPUT:o({default:"./screenshot.png"})})(),i=ep();await $({port:e.port??t.EDITOR_WS_PORT,output:e.output??t.SCREENSHOT_OUTPUT,width:e.width,height:e.height,format:e.format},{logger:i})}).command("variants [directory]","Show the options of a .phoenix/variants/<name>/ folder over the configurator and wait for the answer",e=>e.positional("directory",{type:"string",description:"Folder below .phoenix/variants/ holding one .variant.js script per option"}).option("title",{alias:"t",type:"string",description:"Question shown above the options"}).option("description",{alias:"d",type:"string",description:"A line under the question saying what differs between the options"}).option("timeout",{type:"number",description:'Seconds to wait for the answer before exiting with status "waiting" (default: 540)'}).option("keep",{type:"boolean",description:"Keep the folder after the answer instead of removing it"}).option("close",{type:"boolean",description:"Close the open preview without waiting for an answer; the folder is kept"}).option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await ee({directory:e.directory,title:e.title,description:e.description,timeout:e.timeout,keep:e.keep,close:e.close,port:e.port??t.EDITOR_WS_PORT},{logger:i})}).command(["inspect:state","is"],"Get the current editor state as JSON (entities, navigation, validation)",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("sections",{alias:"s",type:"string",description:"Comma-separated sections: entities,navigation,validation (default: all)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await X({port:e.port??t.EDITOR_WS_PORT,output:e.output,sections:e.sections,pretty:e.pretty},{logger:i})}).command(["inspect:data","id"],"Get the current editor context data as JSON (published, frontend, backend, session, access, web component)",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await N({port:e.port??t.EDITOR_WS_PORT,output:e.output,pretty:e.pretty},{logger:i})}).command(["inspect:scene","isc"],"Get the current Three.js scene graph as JSON",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await W({port:e.port??t.EDITOR_WS_PORT,output:e.output,pretty:e.pretty},{logger:i})}).command(["docs","doc"],"Browse SDK documentation",e=>e.option("read",{alias:"r",type:"string",description:"Read a specific doc file (e.g., docs/phoenix/admin.mdx)"}).option("category",{alias:"c",type:"string",description:"Show all docs in a category"}).option("list",{alias:"l",type:"boolean",description:"List all docs with paths and titles"}).option("search",{alias:"s",type:"string",description:"Search doc content for a term (case-insensitive)"}).option("dir",{type:"boolean",description:"Print the absolute path of the docs directory"}),async e=>{let o=ep();await j({read:e.read,category:e.category,list:e.list,search:e.search,dir:e.dir},{logger:o})}).command(["prepare:ci","pci","ci"],"Prepare CI environment by copying .env.ci to .env",()=>{},async()=>{let e=ep();await Y({logger:e})}).command({command:"environment:create",aliases:["env:create"],describe:"Create a new deployment environment",deprecated:"Switch to a new workflow and use deployment:prepare instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("name",{alias:"n",type:"string",description:"Name of the environment to be created"}).option("slug",{type:"string",description:"Slug of the customer to be created"}).option("uuid",{alias:"u",type:"string",description:"UUID of the environment to be created"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment UUID to",default:".env.generated"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await I({server:o.server,apiKey:o.apiKey,name:o.name,slug:o.slug,uuid:o.uuid,outFile:o.outFile,debug:i},{logger:r})}}).command({command:"environment:list",aliases:["env:list"],describe:"List all deployment environments",deprecated:"Switch to a new workflow and use the prepare environment flow instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await B({server:o.server,apiKey:o.apiKey,debug:i},{logger:r})}}).command(["environment:cleanup","env:cleanup","ec"],"Cleanup a transient deployment environment",e=>e.option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Project slug (env: PROJECT_SLUG, required)"}).option("environmentSlug",{alias:"e",type:"string",description:"Environment slug (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write cleanup result env variables to (env: OUT_FILE, default: .env.generated)",default:".env.generated"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),SERVER_URL:o({default:void 0}),OUT_FILE:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.apiKey??i.ENVIRONMENT_API_KEY,a=t.projectKey??i.PROJECT_KEY,s=t.projectSlug??i.PROJECT_SLUG,l=await ev(),p=t.environmentSlug??i.ENVIRONMENT_SLUG??l.name,d=t.serverUrl??i.SERVER_URL,c=t.outFile??i.OUT_FILE??".env.generated";if(!n)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");if(!a)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");if(!s)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");if(!p)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");if(!d)throw Error("Server URL is required, provide via --serverUrl or -su, or set SERVER_URL environment variable");let u=ep({debug:r});await L({server:d,apiKey:n,projectKey:a,projectSlug:s,environmentSlug:p,debug:r,outFile:c},{logger:u})}).command(["login <customer>"],"Sign the CLI in to an SDK-builder workspace; you approve it in Studio",e=>e.positional("customer",{type:"string",demandOption:!0,description:"Slug of the SDK-builder workspace (customer)"}).option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}).option("studioUrl",{type:"string",description:"URL of Studio for the workspace, instead of the region default"}).option("open",{type:"boolean",default:!0,description:"Open the approval page in the default browser (--no-open to only print the link)"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await F({customer:e.customer,serverUrl:e.serverUrl??en(i),studioUrl:e.studioUrl??ea(i,e.customer),open:e.open},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["deploy"],"Upload this SDK-builder project and follow its build until it is live",e=>e.option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}).option("wait",{type:"boolean",default:!0,description:"Follow the build until it finishes (--no-wait to return once it starts)"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await T({serverUrl:e.serverUrl??en(i),sdkVersion:eE.version,wait:e.wait,projectDir:process.cwd(),pollIntervalMs:3e3},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["logout"],"Revoke the API token of an SDK-builder workspace and forget it on this computer",e=>e.option("region",{choices:ei,description:`Phoenix region to sign out of (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await x({serverUrl:e.serverUrl??en(i)},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["feedback [message]"],"Send feedback about the SDK, CLI, docs or Studio to the Phoenix team",e=>e.positional("message",{type:"string",description:"What you want to tell the Phoenix team; leave it out when you pass --file"}).option("file",{type:"string",description:"Path of a text file that holds the message, for a long report instead of the argument"}).option("type",{choices:[m.Bug,m.Idea,m.Other],default:m.Other,description:"What the feedback is about"}).option("contact",{type:"string",description:"How to reach you, when you want a reply"}).option("agent",{type:"string",description:"Name of the coding agent that writes the feedback"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the workspace project the feedback is about (env: PROJECT_SLUG, defaults to `project` of the application spec)"}).option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0}),PROJECT_SLUG:o({default:void 0})})(),i=ep(),a=e.region??t.PHOENIX_REGION??eo,s=e.projectSlug??t.PROJECT_SLUG,l=s?.length?s:await y(process.cwd()).catch(()=>{i.warn("The feedback is sent without a project, because `project` could not be read from the application spec. Pass --projectSlug to name the project.")});try{await C({serverUrl:e.serverUrl??en(a),message:e.message,file:e.file,type:e.type,contact:e.contact,agent:e.agent,project:l,sdkVersion:eE.version,clientInfo:`${n()} ${r()}, Node.js ${process.versions.node}`},{logger:i})}catch(e){i.error(ef(e)),process.exit(1)}}).command({command:"deployment:register",aliases:["dep:register","dr"],describe:"Register deployment configuration",deprecated:"Switch to a new workflow and use deployment:prepare and deployment:finish instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the deployment ID to",default:".env.generated"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip uploading assets",default:!1}).option("activate",{alias:"a",type:"boolean",description:"Activate deployment after registration",default:!0}).option("overrideSchema",{alias:"os",type:"boolean",description:"Override existing schema",default:!1}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await H({server:o.server,apiKey:o.apiKey,outFile:o.outFile,skipUpload:o.skipUpload,activate:o.activate,overrideSchema:o.overrideSchema,debug:i},{logger:r})}}).command({command:"deployment:activate",aliases:["dep:activate","da"],describe:"Activate a deployment",deprecated:"Switch to a new workflow and use deployment:prepare and deployment:finish instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("uuid",{alias:"u",type:"string",description:"UUID of the deployment to activate"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await _({server:o.server,apiKey:o.apiKey,uuid:o.uuid,debug:i},{logger:r})}}).command(["deployment:prepare","dep:prepare","dp"],"Prepare environment and register deployment (env: ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, PROJECT_REF, PROJECT_SHA, ENVIRONMENT_SLUG, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA, SERVER_URL)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (will be created if it does not exist) (env: ENVIRONMENT_SLUG, required)"}).option("projectRef",{type:"string",description:"Source branch, tag, or ref recorded as deployment provenance (env: PROJECT_REF)"}).option("projectSha",{type:"string",description:"Full commit SHA of the checked-out project revision (env: PROJECT_SHA)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows to override deployment schemas (env: OVERRIDE_SCHEMA, default: false)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("uploadLinksFile",{alias:"ulf",type:"string",description:"File to write upload links to (used by finish command) (default: .upload-links.json)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),PROJECT_REF:o({default:void 0}),PROJECT_SHA:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!1}),SERVER_URL:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.apiKey??i.ENVIRONMENT_API_KEY;if(!n)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let a=t.projectKey??i.PROJECT_KEY;if(!a)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let s=t.projectSlug??i.PROJECT_SLUG;if(!s)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let l=t.environmentSlug??i.ENVIRONMENT_SLUG;if(!l)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");let p=t.serverUrl??i.SERVER_URL;if(!p)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let d=await ev(),c=ep({debug:r}),u=ec(t.applicationSpec,d.applicationFlow,{logger:c});await (u?q:h.runPrepareDeploymentCommand)({apiKey:n,projectKey:a,projectSlug:s,projectRef:t.projectRef??i.PROJECT_REF,projectSha:t.projectSha??i.PROJECT_SHA,environmentSlug:l,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,uploadLinksFile:t.uploadLinksFile??".upload-links.json",serverUrl:p,debug:r,projectVersion:eE.version},{logger:c})}).command(["deployment:prepare-dev","dep:prepare-dev","dpd"],"Prepare a development deployment (env: SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, DEVELOPMENT_KEY, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required unless --local)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the development environment (env: ENVIRONMENT_SLUG, required unless --local)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows overriding deployment schemas (env: OVERRIDE_SCHEMA, default: true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("local",{type:"boolean",description:"Use local-mode development environment defaults (env: PHOENIX_LOCAL, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),SERVER_URL:o({default:void 0}),DEVELOPMENT_KEY:o({default:void 0}),PHOENIX_LOCAL:e({default:!1}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!0})})(),r=t.debug??i.DEBUG,n=ep({debug:r}),a=t.local??i.PHOENIX_LOCAL,s=i.SERVER_URL,l=t.projectSlug??i.PROJECT_SLUG,p=t.environmentSlug??i.ENVIRONMENT_SLUG,d=i.DEVELOPMENT_KEY;if(a&&(s=s?.length?s:"http://localhost:3000",l=l?.length?l:"local",p=p?.length?p:"dev-local",d=d?.length?d:"dev_local-dev-key-12345"),!s||!l||!p||!d)throw Error("phoenix deployment:prepare-dev needs SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, and DEVELOPMENT_KEY in .env. Create a development environment for your project in Studio and paste its .env block, or pass --local to use the local-mode server.");let c=await ev(),u=ec(t.applicationSpec,c.applicationFlow,{logger:n}),E={serverUrl:s,projectSlug:l,environmentSlug:p,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,debug:r,projectVersion:eE.version};try{u?await S({...E,credential:{developmentKey:d}},{logger:n}):await h.prepareDevelopmentEnvironment({...E,developmentKey:d},{logger:n})}catch(e){n.error(`Development environment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}}).command(["deployment:prepare-local","dep:prepare-local","dpl"],"Prepare local environment for development (env: PROJECT_KEY, PROJECT_SLUG, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA, SERVER_URL, LAMBDA_URL)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, default: local)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, default: project name in package.json)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows to override deployment schemas (env: OVERRIDE_SCHEMA, default: true)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, default: http://localhost:3000)"}).option("lambdaUrl",{alias:"l",type:"string",description:"Webhook URL (env: LAMBDA_URL, default: http://localhost:8080)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_SLUG:o({default:void 0}),PROJECT_KEY:o({default:"project_local-dev-key-12345"}),PROJECT_SLUG:o({default:"local"}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!0}),SERVER_URL:o({default:"http://localhost:3000"}),LAMBDA_URL:o({default:"http://localhost:8080"}),ENVIRONMENT_API_KEY:o({default:"local-dev-key-12345"})})(),r=t.debug??i.DEBUG,n=t.projectKey??i.PROJECT_KEY;if(!n)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let a=await ev(),s=t.environmentSlug??i.ENVIRONMENT_SLUG??a.name;if(!s)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");let l=t.apiKey??i.ENVIRONMENT_API_KEY;if(!l)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let p=ep({debug:r}),d=ec(t.applicationSpec,a.applicationFlow,{logger:p});try{await (d?R:h.prepareLocalEnvironment)({apiKey:l,projectKey:n,projectSlug:t.projectSlug??i.PROJECT_SLUG,environmentSlug:s,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,serverUrl:t.serverUrl??i.SERVER_URL,lambdaUrl:t.lambdaUrl??i.LAMBDA_URL,debug:r,projectVersion:eE.version},{logger:p})}catch(e){p.error(`Local environment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}}).command(["deployment:extract-sources <archive> <folder>"],"Validate the source archive of a phoenix deploy and extract its project files into a new folder. Links, special files, unsafe paths and oversized content are refused; entries that are not project files are left out",e=>e.positional("archive",{type:"string",demandOption:!0,description:"The source archive (.tgz)"}).positional("folder",{type:"string",demandOption:!0,description:"New or empty folder to extract the project files into"}),async e=>{let o=ep();try{await G({archivePath:e.archive,targetDir:e.folder},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command(["deployment:build-envs","dep:build-envs","dbe"],"Write the environment variables for the build step of a prepared deployment that builds apart from its deploy (env: DEPLOYMENT_ID, ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, OUT_FILE, SERVER_URL)",e=>e.option("uuid",{alias:"u",type:"string",description:"Id of the prepared deployment (env: DEPLOYMENT_ID, required)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),DEPLOYMENT_ID:o({default:void 0}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),OUT_FILE:o({default:".env.generated"}),SERVER_URL:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.uuid??i.DEPLOYMENT_ID;if(!n)throw Error("Deployment ID is required, provide via --uuid or -u, or set DEPLOYMENT_ID environment variable");let a=t.apiKey??i.ENVIRONMENT_API_KEY;if(!a)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let s=t.projectKey??i.PROJECT_KEY;if(!s)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let l=t.projectSlug??i.PROJECT_SLUG;if(!l)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let p=t.serverUrl??i.SERVER_URL;if(!p)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let d=ep({debug:r});await w({uuid:n,apiKey:a,projectKey:s,projectSlug:l,outFile:t.outFile??i.OUT_FILE,serverUrl:p,debug:r},{logger:d})}).command(["deployment:finish","dep:finish","df"],"Upload files to S3 and activate deployment (env: DEPLOYMENT_ID, ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, LAMBDA_URL, SERVER_URL, SKIP_UPLOAD)",e=>e.option("uuid",{alias:"u",type:"string",description:"Id of the deployment to be activated (env: DEPLOYMENT_ID, required)"}).option("uploadLinksFile",{alias:"ulf",type:"string",description:"File containing upload links (generated by prepare command) (default: .upload-links.json)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("lambdaUrl",{alias:"l",type:"string",description:"Lambda webhook URL for the deployment (env: LAMBDA_URL, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),DEPLOYMENT_ID:o({default:void 0}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),LAMBDA_URL:o({default:void 0}),SERVER_URL:o({default:void 0}),SKIP_UPLOAD:e({default:!1})})(),r=t.debug??i.DEBUG,n=t.uuid??i.DEPLOYMENT_ID;if(!n)throw Error("Deployment ID is required, provide via --uuid or -u, or set DEPLOYMENT_ID environment variable");let a=t.apiKey??i.ENVIRONMENT_API_KEY;if(!a)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let s=t.projectKey??i.PROJECT_KEY;if(!s)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let l=t.projectSlug??i.PROJECT_SLUG;if(!l)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let p=t.lambdaUrl??i.LAMBDA_URL;if(!p)throw Error("Lambda URL is required, provide via --lambdaUrl or -l, or set LAMBDA_URL environment variable");let d=t.serverUrl??i.SERVER_URL;if(!d)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let c=ep({debug:r});await A({uuid:n,uploadLinksFile:t.uploadLinksFile??".upload-links.json",apiKey:a,projectKey:s,projectSlug:l,lambdaUrl:p,serverUrl:d,skipUpload:t.skipUpload??i.SKIP_UPLOAD,debug:r},{logger:c})}).demandCommand(1,"Please specify a command").help().alias("help","h").version(eE.version).alias("version","v").strict().parse();
|
|
1
|
+
import{bool as e,str as o}from"envalid";import{readFileSync as t}from"fs";import{readFile as i}from"fs/promises";import{arch as r,platform as n}from"os";import{dirname as a,join as s,resolve as l}from"path";import{P as p,match as d}from"ts-pattern";import{fileURLToPath as c}from"url";import u from"yargs";import{hideBin as E}from"yargs/helpers";import{z as v}from"zod";import{createEnvReader as f}from"@salsita-ai/common/env";import{DEFAULT_PROJECT_ALIAS as g,FeedbackType as m}from"@salsita-ai/contracts/domain";import{phoenixCli as h}from"#package/legacy";import{readSpecProject as y}from"./application-spec/read-spec-project.js";import{prepareDevelopmentEnvironment as S,prepareLocalEnvironment as R,runActivateDeploymentCommand as _,runBuildCommand as O,runChangelogCommand as U,runCheckCommand as P,runCleanCommand as b,runCleanupEnvironmentCommand as L,runCreateEnvironmentCommand as I,runDataCommand as N,runDeployCommand as T,runDeploymentBuildEnvsCommand as w,runDepsCommand as k,runDevCommand as D,runDocsCommand as j,runExtractSourcesCommand as G,runFeedbackCommand as C,runFinishDeploymentCommand as A,runFixCommand as K,runInitCommand as V,runInspectAssetsCommand as M,runLinkCommand as J,runListEnvironmentsCommand as B,runLoginCommand as F,runLogoutCommand as x,runPrepareCiCommand as Y,runPrepareDeploymentCommand as q,runRegisterDeploymentCommand as H,runSceneCommand as W,runScreenshotCommand as $,runStateCommand as X,runStoryCommand as z,runSyncCommand as Q,runUnlinkCommand as Z,runVariantsCommand as ee}from"./commands/index.js";import{DEFAULT_PHOENIX_REGION as eo,PHOENIX_REGIONS as et,PUBLIC_PHOENIX_REGIONS as ei,VariantFileSession as er,getRegionServerUrl as en,getRegionStudioUrl as ea,resolveSignedInDevelopmentEnvironment as es}from"./services/index.js";import{getIsEditorEnabled as el}from"./utils/get-is-editor-enabled.js";import{createLogger as ep}from"./utils/index.js";let ed=(e,o,t)=>{e?.info(`Using ${o?"application-spec":"domain-spec"} flow (${t})`)},ec=(e,o,t)=>{let i=t?.logger??ep();if(void 0!==e)return i.detail(`Application spec: ${e} (from CLI flag)`),ed(t?.logger,e,"from CLI flag"),e;let r=process.env.USE_APPLICATION_SPEC;if(void 0!==r){let e="true"===r||"1"===r;return i.detail(`Application spec: ${e} (from environment variable)`),ed(t?.logger,e,"from environment variable"),e}return void 0!==o?(i.detail(`Application spec: ${o} (from package.json phoenix.applicationFlow)`),ed(t?.logger,o,"from package.json phoenix.applicationFlow"),o):(i.detail("Application spec: false (default)"),ed(t?.logger,!1,"default"),!1)},eu=t(s(a(c(import.meta.url)),"../../package.json"),"utf-8");if(!eu)throw Error("Project package.json is required, please provide it in the package.json file");let eE=v.object({version:v.string({required_error:"Project version is required, please provide it in the package.json file"}),name:v.string({required_error:"Project name is required, please provide it in the package.json file"}),dependencies:v.object({eslint:v.string(),prettier:v.string()})}).parse(JSON.parse(eu)),ev=async()=>{try{let e=await i("./package.json","utf-8"),o=JSON.parse(e);return{name:o.name,applicationFlow:o.phoenix?.applicationFlow}}catch{return{name:void 0,applicationFlow:void 0}}},ef=e=>{if(!(e instanceof Error))return String(e);let o=(e=>{if(!(e instanceof Error))return;if(e.message.length>0)return e.message;let o=(e instanceof AggregateError?e.errors:[]).find(e=>e instanceof Error&&e.message.length>0);return o instanceof Error?o.message:"code"in e&&"string"==typeof e.code?e.code:void 0})(e.cause);return void 0===o?e.message:`${e.message}: ${o}`};await u(E(process.argv)).scriptName("phoenix").usage("$0 <command> [options]").command(["build","b"],"Build the project",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("onlyFrontend",{alias:"F",type:"boolean",description:"Build only frontend bundle"}).option("onlyWebhook",{alias:"W",type:"boolean",description:"Build only webhooks"}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("banner",{type:"string",requiresArg:!0,description:"Text for the comment at the top of every frontend .js file, public in the bundle (default: application version from the spec and the git commit when available)",coerce:e=>"string"==typeof e?e:e.join("\n")}),async t=>{let i,r=f({PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1}),BUILD_TARGET:o({choices:["frontend","webhook","both"],default:"both"}),FORCE_REBUILD:e({default:!1})})(),n=ep({debug:t.debug??r.DEBUG}),a=el(t.editor,r.ENABLE_EDITOR),s=t.force??r.FORCE_REBUILD,l=await ev(),p=ec(t.applicationSpec,l.applicationFlow,{logger:n}),d=t.projectSlug??r.PROJECT_SLUG??l.name,c=t.environmentSlug??r.ENVIRONMENT_SLUG??l.name;if(!d)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!c)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");let u=t.onlyFrontend,E=t.onlyWebhook;if(u&&E)throw Error("Cannot use --onlyFrontend and --onlyWebhook flags together, they are mutually exclusive");i=u?"frontend":E?"webhook":r.BUILD_TARGET;let v={sdkVersion:eE.version,projectSlug:d,environmentSlug:c,cliUseWorkspace:t.workspace,enableEditor:a,buildTarget:i,force:s};await (p?O({...v,banner:t.banner},{logger:n}):h.runBuildCommand(v,{logger:n}))}).command(["clean","cl"],"Remove .phoenix and regenerate the project files; installs nothing (the legacy pipeline also removes node_modules and reinstalls)",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1})})(),r=ep({debug:t.debug??i.DEBUG}),n=el(t.editor,i.ENABLE_EDITOR),a=await ev(),s=ec(t.applicationSpec,a.applicationFlow,{logger:r}),l=t.projectSlug??i.PROJECT_SLUG??a.name,p=t.environmentSlug??i.ENVIRONMENT_SLUG??a.name;if(!l)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!p)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");await (s?b:h.runCleanCommand)({sdkVersion:eE.version,projectSlug:l,environmentSlug:p,cliUseWorkspace:t.workspace,enableEditor:n},{logger:r})}).command(["dev","d"],"Start development mode (Vite, spec watching, and the webhook tunnel)",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("editorWsPort",{alias:"ep",type:"string",description:"Port for the editor WebSocket server (defaults to EDITOR_WS_PORT env or 3020)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG; required in server mode unless --local; offline modes default to the package name)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG; required in server mode unless --local; offline modes default to the package name)"}).option("withLingui",{alias:"wl",type:"boolean",description:"Enable or disable i18n messages extraction and compilation (defaults to WITH_LINGUI env or false)"}).option("persistence",{alias:"P",type:"string",description:"Persistence mode for the configurator (defaults to PERSISTENCE_MODE env or server)",choices:["memory","local-storage","server"]}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache, and prepare the development deployment again (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("tui",{alias:"T",type:"boolean",description:"Render logs in a terminal UI with per-stream pages and split view; requires an interactive terminal (env: PHOENIX_TUI, default: false)"}).option("local",{type:"boolean",description:"Use local-mode development environment defaults (env: PHOENIX_LOCAL, default: false)"}).option("region",{choices:ei,description:`Phoenix region of the workspace you are signed in to, used when .env has no SERVER_URL (default: ${eo})`}).option("serverUrl",{type:"string",description:"URL of the Phoenix server, instead of SERVER_URL or the region default"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket when the development deployment is prepared (env: SKIP_UPLOAD, default: false)"}),async t=>{let i=f({ENABLE_EDITOR:e({default:!0}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),EDITOR_WS_PORT:o({default:"3020"}),DEBUG:e({default:!1}),WITH_LINGUI:e({default:!1}),PERSISTENCE_MODE:o({default:void 0}),FORCE_REBUILD:e({default:!1}),PHOENIX_TUI:e({default:!1}),SERVER_URL:o({default:void 0}),DEVELOPMENT_KEY:o({default:void 0}),PHOENIX_LOCAL:e({default:!1}),PHOENIX_REGION:o({choices:et,default:void 0}),SKIP_UPLOAD:e({default:!1})})(),r=t.debug??i.DEBUG,n=ep({debug:r}),a=el(t.editor,i.ENABLE_EDITOR),s=t.editorWsPort??i.EDITOR_WS_PORT,l=t.force??i.FORCE_REBUILD,c=t.withLingui??i.WITH_LINGUI,u=t.persistence??i.PERSISTENCE_MODE,E=!u||"server"===u,v=t.tui??i.PHOENIX_TUI,m=await ev(),S=ec(t.applicationSpec,m.applicationFlow,{logger:n}),R=t.local??i.PHOENIX_LOCAL,_=t.projectSlug??i.PROJECT_SLUG;S&&await er.recover(process.cwd(),n);let O=E&&S&&!R&&!_?.length?await y(process.cwd()):void 0,{serverUrl:U,developmentKey:P,apiToken:b,projectSlug:L,environmentSlug:I}=await d({useServer:E,local:R,serverUrl:t.serverUrl??i.SERVER_URL,developmentKey:i.DEVELOPMENT_KEY,projectSlug:_?.length?_:O,environmentSlug:t.environmentSlug??i.ENVIRONMENT_SLUG}).with({useServer:!1},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e,developmentKey:o,apiToken:void 0,projectSlug:t??m.name,environmentSlug:i??m.name})).with({local:!0},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e?.length?e:"http://localhost:3000",developmentKey:o?.length?o:"dev_local-dev-key-12345",apiToken:void 0,projectSlug:t?.length?t:"local",environmentSlug:i?.length?i:"dev-local"})).with({developmentKey:p.string.minLength(1)},()=>O===g,()=>{throw Error(`phoenix dev has a DEVELOPMENT_KEY, but the spec says \`project: ${g}\`, which only a signed-in workspace can resolve. Set PROJECT_SLUG in .env by pasting the .env block of your Studio development environment, or name the project's slug in the spec.`)}).with({serverUrl:p.string.minLength(1),developmentKey:p.string.minLength(1),projectSlug:p.string.minLength(1),environmentSlug:p.string.minLength(1)},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e,developmentKey:o,apiToken:void 0,projectSlug:t,environmentSlug:i})).with({developmentKey:p.union(void 0,""),projectSlug:p.string.minLength(1)},()=>S,async({serverUrl:e,projectSlug:o})=>{let r=e?.length?e:en(t.region??i.PHOENIX_REGION??eo),a=await es({serverUrl:r,project:o});return n.info(`Developing in ${a.projectSlug}/${a.environmentSlug} of workspace "${a.workspaceName}" on ${r}`),{serverUrl:r,developmentKey:void 0,apiToken:a.apiToken,projectSlug:a.projectSlug,environmentSlug:a.environmentSlug}}).with({developmentKey:p.union(void 0,""),projectSlug:p.union(void 0,"")},()=>S,()=>{throw Error(`phoenix dev does not know which project to develop in. Add \`project: ${g}\` to spec/application.yaml to use the default project of the workspace you are signed in to, or paste the .env block of a Studio development environment into .env. Pass --local to use the local-mode server.`)}).otherwise(()=>{throw Error("phoenix dev needs SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, and DEVELOPMENT_KEY in .env. Create a development environment for your project in Studio and paste its .env block, or pass --local to use the local-mode server.")});if(!L)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!I)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");let N={sdkVersion:eE.version,projectSlug:L,environmentSlug:I,cliUseWorkspace:t.workspace,enableEditor:a,editorWsPort:s,debug:r,withLingui:c,persistenceMode:u,force:l,tui:v,serverUrl:U,skipUpload:t.skipUpload??i.SKIP_UPLOAD};if(S){let e=P?{developmentKey:P}:b?{apiToken:b}:void 0;await D({...N,credential:e},{logger:n})}else await h.runDevCommand({...N,developmentKey:P},{logger:n})}).command(["link","l"],"Internal tool, pnpm only: link a local SDK checkout for development through pnpm overrides; installs nothing, run the pnpm install it prints next",e=>e.option("sdk-path",{type:"string",description:"Path to the SDK repository",default:"../configurator-phoenix"}),async e=>{let o=ep();try{await J({sdkPath:e.sdkPath},{logger:o})}catch{process.exit(1)}}).command(["unlink","ul"],"Internal tool, pnpm only: remove the local SDK link that phoenix link added; installs nothing, run the pnpm install it prints next",()=>{},async()=>{let e=ep();try{await Z({logger:e})}catch{process.exit(1)}}).command(["sync","s"],"Sync project files and compile specs without building vite/webhooks",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("analyze",{alias:"a",type:"boolean",description:"Print pipeline metrics flamegraph after build (requires --applicationSpec)"}),async t=>{let i=f({ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),FORCE_REBUILD:e({default:!1})})(),r=ep({debug:t.debug??i.DEBUG}),n=el(t.editor,i.ENABLE_EDITOR),a=t.force??i.FORCE_REBUILD,s=await ev(),l=ec(t.applicationSpec,s.applicationFlow,{logger:r}),p=t.projectSlug??i.PROJECT_SLUG??s.name,d=t.environmentSlug??i.ENVIRONMENT_SLUG??s.name;if(!p)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!d)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");await (l?Q:h.runSyncCommand)({sdkVersion:eE.version,projectSlug:p,environmentSlug:d,cliUseWorkspace:t.workspace,enableEditor:n,force:a,analyze:t.analyze},{logger:r})}).command(["deps"],"Bring package.json in line with the SDK's peer dependencies: add the missing ones and move out-of-range versions into the SDK's range. Installs nothing; install the dependencies with your package manager next",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async e=>{let o=ep({debug:e.debug??!1}),t=await ev();if(!ec(e.applicationSpec,t.applicationFlow,{logger:o}))return void o.info("phoenix deps changes nothing in a legacy project: phoenix sync manages its dependencies. Switch the project to the application-spec pipeline (phoenix.applicationFlow in package.json) to manage them with phoenix deps.");try{await k({projectRoot:process.cwd()},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command("init [folder]","Start a Phoenix project: write package.json with the SDK, its peers, ESLint and Prettier (an existing one gains only what it lacks) and a starter spec. Install the dependencies with your package manager, then continue with phoenix sync, phoenix login and phoenix dev",e=>e.positional("folder",{type:"string",description:"Folder to create the project in (default: the working directory)"}).option("scaffold",{type:"boolean",hidden:!0,description:"Accepted for compatibility and ignored: init always only writes the starter project"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging"}),async e=>{let o=ep({debug:e.debug??!1});try{await V({sdkVersion:eE.version,editorToolVersions:eE.dependencies,projectRoot:void 0===e.folder?void 0:l(e.folder)},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command(["story","st"],"Storybook example utilities",e=>z(e),()=>{}).command(["check","c"],"Run checks (TypeScript, ESLint, Prettier). Runs all by default, or only selected when any of --types/--lint/--format is passed.",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("types",{type:"boolean",description:"Run TypeScript check"}).option("lint",{type:"boolean",description:"Run ESLint check"}).option("format",{type:"boolean",description:"Run Prettier check"}),async o=>{let t=f({DEBUG:e({default:!1})})(),i=ep({debug:o.debug??t.DEBUG});await P({types:o.types,lint:o.lint,format:o.format},{logger:i})}).command(["fix","f"],"Fix linting and formatting issues. Runs all by default, or only selected when any of --lint/--format is passed.",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("lint",{type:"boolean",description:"Run ESLint fix"}).option("format",{type:"boolean",description:"Run Prettier fix"}),async o=>{let t=f({DEBUG:e({default:!1})})(),i=ep({debug:o.debug??t.DEBUG});await K({lint:o.lint,format:o.format},{logger:i})}).command(["changelog","clog"],"Display SDK changelog",e=>e.option("ver",{type:"string",description:"Show specific version (e.g., 0.36.0)"}).option("all",{alias:"a",type:"boolean",description:"Show all versions (warning: large output)"}).option("page",{alias:"p",type:"number",description:"Page number (3 versions per page)"}).option("list",{alias:"l",type:"boolean",description:"List version numbers only"}),async e=>{let o=ep();await U({version:e.ver,all:e.all,page:e.page,list:e.list},{logger:o})}).command(["inspect:assets","ia"],"Inspect 3D assets (glTF/GLB) — nodes, transforms, bounds, origin, materials, morph targets, animations",e=>e.option("file",{alias:"f",type:"string",description:"Path to specific glTF/GLB file"}).option("objects",{alias:"O",type:"boolean",description:"Show only object/node names"}).option("materials",{alias:"m",type:"boolean",description:"Show only material names"}).option("morphs",{alias:"M",type:"boolean",description:"Show only morph target names"}).option("animations",{alias:"a",type:"boolean",description:"Show only animation names"}).option("json",{alias:"j",type:"boolean",description:"Output as JSON"}),async e=>{let o=ep();await M({file:e.file,objects:e.objects,materials:e.materials,morphs:e.morphs,animations:e.animations,json:e.json},{logger:o})}).command(["screenshot","ss"],"Capture a screenshot of the configurator canvas",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (defaults to SCREENSHOT_OUTPUT env or ./screenshot.png)"}).option("width",{alias:"w",type:"number",description:"Width in pixels (default: 1920)"}).option("height",{alias:"H",type:"number",description:"Height in pixels (default: 1080)"}).option("format",{alias:"f",type:"string",description:"Image format: PNG or JPEG (default: PNG)"}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"}),SCREENSHOT_OUTPUT:o({default:"./screenshot.png"})})(),i=ep();await $({port:e.port??t.EDITOR_WS_PORT,output:e.output??t.SCREENSHOT_OUTPUT,width:e.width,height:e.height,format:e.format},{logger:i})}).command("variants [directory]","Show the options of a .phoenix/variants/<name>/ folder over the configurator and wait for the answer",e=>e.positional("directory",{type:"string",description:"Folder below .phoenix/variants/ holding one .variant.js script per option"}).option("title",{alias:"t",type:"string",description:"Question shown above the options"}).option("description",{alias:"d",type:"string",description:"A line under the question saying what differs between the options"}).option("timeout",{type:"number",description:'Seconds to wait for the answer before exiting with status "waiting" (default: 540)'}).option("keep",{type:"boolean",description:"Keep the folder after the answer instead of removing it"}).option("close",{type:"boolean",description:"Close the open preview without waiting for an answer; the folder is kept"}).option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await ee({directory:e.directory,title:e.title,description:e.description,timeout:e.timeout,keep:e.keep,close:e.close,port:e.port??t.EDITOR_WS_PORT},{logger:i})}).command(["inspect:state","is"],"Get the current editor state as JSON (entities, navigation, validation)",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("sections",{alias:"s",type:"string",description:"Comma-separated sections: entities,navigation,validation (default: all)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await X({port:e.port??t.EDITOR_WS_PORT,output:e.output,sections:e.sections,pretty:e.pretty},{logger:i})}).command(["inspect:data","id"],"Get the current editor context data as JSON (published, frontend, backend, session, access, web component)",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await N({port:e.port??t.EDITOR_WS_PORT,output:e.output,pretty:e.pretty},{logger:i})}).command(["inspect:scene","isc"],"Get the current Three.js scene graph as JSON",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await W({port:e.port??t.EDITOR_WS_PORT,output:e.output,pretty:e.pretty},{logger:i})}).command(["docs","doc"],"Browse SDK documentation",e=>e.option("read",{alias:"r",type:"string",description:"Read a specific doc file (e.g., docs/phoenix/admin.mdx)"}).option("category",{alias:"c",type:"string",description:"Show all docs in a category"}).option("list",{alias:"l",type:"boolean",description:"List all docs with paths and titles"}).option("search",{alias:"s",type:"string",description:"Search doc content for a term (case-insensitive)"}).option("dir",{type:"boolean",description:"Print the absolute path of the docs directory"}),async e=>{let o=ep();await j({read:e.read,category:e.category,list:e.list,search:e.search,dir:e.dir},{logger:o})}).command(["prepare:ci","pci","ci"],"Prepare CI environment by copying .env.ci to .env",()=>{},async()=>{let e=ep();await Y({logger:e})}).command({command:"environment:create",aliases:["env:create"],describe:"Create a new deployment environment",deprecated:"Switch to a new workflow and use deployment:prepare instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("name",{alias:"n",type:"string",description:"Name of the environment to be created"}).option("slug",{type:"string",description:"Slug of the customer to be created"}).option("uuid",{alias:"u",type:"string",description:"UUID of the environment to be created"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment UUID to",default:".env.generated"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await I({server:o.server,apiKey:o.apiKey,name:o.name,slug:o.slug,uuid:o.uuid,outFile:o.outFile,debug:i},{logger:r})}}).command({command:"environment:list",aliases:["env:list"],describe:"List all deployment environments",deprecated:"Switch to a new workflow and use the prepare environment flow instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await B({server:o.server,apiKey:o.apiKey,debug:i},{logger:r})}}).command(["environment:cleanup","env:cleanup","ec"],"Cleanup a transient deployment environment",e=>e.option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Project slug (env: PROJECT_SLUG, required)"}).option("environmentSlug",{alias:"e",type:"string",description:"Environment slug (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write cleanup result env variables to (env: OUT_FILE, default: .env.generated)",default:".env.generated"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),SERVER_URL:o({default:void 0}),OUT_FILE:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.apiKey??i.ENVIRONMENT_API_KEY,a=t.projectKey??i.PROJECT_KEY,s=t.projectSlug??i.PROJECT_SLUG,l=await ev(),p=t.environmentSlug??i.ENVIRONMENT_SLUG??l.name,d=t.serverUrl??i.SERVER_URL,c=t.outFile??i.OUT_FILE??".env.generated";if(!n)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");if(!a)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");if(!s)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");if(!p)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");if(!d)throw Error("Server URL is required, provide via --serverUrl or -su, or set SERVER_URL environment variable");let u=ep({debug:r});await L({server:d,apiKey:n,projectKey:a,projectSlug:s,environmentSlug:p,debug:r,outFile:c},{logger:u})}).command(["login <customer>"],"Sign the CLI in to an SDK-builder workspace; you approve it in Studio",e=>e.positional("customer",{type:"string",demandOption:!0,description:"Slug of the SDK-builder workspace (customer)"}).option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}).option("studioUrl",{type:"string",description:"URL of Studio for the workspace, instead of the region default"}).option("open",{type:"boolean",default:!0,description:"Open the approval page in the default browser (--no-open to only print the link)"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await F({customer:e.customer,serverUrl:e.serverUrl??en(i),studioUrl:e.studioUrl??ea(i,e.customer),open:e.open},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["deploy"],"Upload this SDK-builder project and follow its build until it is live",e=>e.option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}).option("wait",{type:"boolean",default:!0,description:"Follow the build until it finishes (--no-wait to return once it starts)"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await T({serverUrl:e.serverUrl??en(i),sdkVersion:eE.version,wait:e.wait,projectDir:process.cwd(),pollIntervalMs:3e3},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["logout"],"Revoke the API token of an SDK-builder workspace and forget it on this computer",e=>e.option("region",{choices:ei,description:`Phoenix region to sign out of (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await x({serverUrl:e.serverUrl??en(i)},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["feedback [message]"],"Send feedback about the SDK, CLI, docs or Studio to the Phoenix team",e=>e.positional("message",{type:"string",description:"What you want to tell the Phoenix team; leave it out when you pass --file"}).option("file",{type:"string",description:"Path of a text file that holds the message, for a long report instead of the argument"}).option("type",{choices:[m.Bug,m.Idea,m.Other],default:m.Other,description:"What the feedback is about"}).option("contact",{type:"string",description:"How to reach you, when you want a reply"}).option("agent",{type:"string",description:"Name of the coding agent that writes the feedback"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the workspace project the feedback is about (env: PROJECT_SLUG, defaults to `project` of the application spec)"}).option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0}),PROJECT_SLUG:o({default:void 0})})(),i=ep(),a=e.region??t.PHOENIX_REGION??eo,s=e.projectSlug??t.PROJECT_SLUG,l=s?.length?s:await y(process.cwd()).catch(()=>{i.warn("The feedback is sent without a project, because `project` could not be read from the application spec. Pass --projectSlug to name the project.")});try{await C({serverUrl:e.serverUrl??en(a),message:e.message,file:e.file,type:e.type,contact:e.contact,agent:e.agent,project:l,sdkVersion:eE.version,clientInfo:`${n()} ${r()}, Node.js ${process.versions.node}`},{logger:i})}catch(e){i.error(ef(e)),process.exit(1)}}).command({command:"deployment:register",aliases:["dep:register","dr"],describe:"Register deployment configuration",deprecated:"Switch to a new workflow and use deployment:prepare and deployment:finish instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the deployment ID to",default:".env.generated"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip uploading assets",default:!1}).option("activate",{alias:"a",type:"boolean",description:"Activate deployment after registration",default:!0}).option("overrideSchema",{alias:"os",type:"boolean",description:"Override existing schema",default:!1}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await H({server:o.server,apiKey:o.apiKey,outFile:o.outFile,skipUpload:o.skipUpload,activate:o.activate,overrideSchema:o.overrideSchema,debug:i},{logger:r})}}).command({command:"deployment:activate",aliases:["dep:activate","da"],describe:"Activate a deployment",deprecated:"Switch to a new workflow and use deployment:prepare and deployment:finish instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("uuid",{alias:"u",type:"string",description:"UUID of the deployment to activate"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await _({server:o.server,apiKey:o.apiKey,uuid:o.uuid,debug:i},{logger:r})}}).command(["deployment:prepare","dep:prepare","dp"],"Prepare environment and register deployment (env: ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, PROJECT_REF, PROJECT_SHA, ENVIRONMENT_SLUG, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA, SERVER_URL)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (will be created if it does not exist) (env: ENVIRONMENT_SLUG, required)"}).option("projectRef",{type:"string",description:"Source branch, tag, or ref recorded as deployment provenance (env: PROJECT_REF)"}).option("projectSha",{type:"string",description:"Full commit SHA of the checked-out project revision (env: PROJECT_SHA)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows to override deployment schemas (env: OVERRIDE_SCHEMA, default: false)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("uploadLinksFile",{alias:"ulf",type:"string",description:"File to write upload links to (used by finish command) (default: .upload-links.json)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),PROJECT_REF:o({default:void 0}),PROJECT_SHA:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!1}),SERVER_URL:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.apiKey??i.ENVIRONMENT_API_KEY;if(!n)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let a=t.projectKey??i.PROJECT_KEY;if(!a)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let s=t.projectSlug??i.PROJECT_SLUG;if(!s)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let l=t.environmentSlug??i.ENVIRONMENT_SLUG;if(!l)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");let p=t.serverUrl??i.SERVER_URL;if(!p)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let d=await ev(),c=ep({debug:r}),u=ec(t.applicationSpec,d.applicationFlow,{logger:c});await (u?q:h.runPrepareDeploymentCommand)({apiKey:n,projectKey:a,projectSlug:s,projectRef:t.projectRef??i.PROJECT_REF,projectSha:t.projectSha??i.PROJECT_SHA,environmentSlug:l,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,uploadLinksFile:t.uploadLinksFile??".upload-links.json",serverUrl:p,debug:r,projectVersion:eE.version},{logger:c})}).command(["deployment:prepare-dev","dep:prepare-dev","dpd"],"Prepare a development deployment (env: SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, DEVELOPMENT_KEY, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required unless --local)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the development environment (env: ENVIRONMENT_SLUG, required unless --local)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows overriding deployment schemas (env: OVERRIDE_SCHEMA, default: true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("local",{type:"boolean",description:"Use local-mode development environment defaults (env: PHOENIX_LOCAL, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),SERVER_URL:o({default:void 0}),DEVELOPMENT_KEY:o({default:void 0}),PHOENIX_LOCAL:e({default:!1}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!0})})(),r=t.debug??i.DEBUG,n=ep({debug:r}),a=t.local??i.PHOENIX_LOCAL,s=i.SERVER_URL,l=t.projectSlug??i.PROJECT_SLUG,p=t.environmentSlug??i.ENVIRONMENT_SLUG,d=i.DEVELOPMENT_KEY;if(a&&(s=s?.length?s:"http://localhost:3000",l=l?.length?l:"local",p=p?.length?p:"dev-local",d=d?.length?d:"dev_local-dev-key-12345"),!s||!l||!p||!d)throw Error("phoenix deployment:prepare-dev needs SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, and DEVELOPMENT_KEY in .env. Create a development environment for your project in Studio and paste its .env block, or pass --local to use the local-mode server.");let c=await ev(),u=ec(t.applicationSpec,c.applicationFlow,{logger:n}),E={serverUrl:s,projectSlug:l,environmentSlug:p,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,debug:r,projectVersion:eE.version};try{u?await S({...E,credential:{developmentKey:d}},{logger:n}):await h.prepareDevelopmentEnvironment({...E,developmentKey:d},{logger:n})}catch(e){n.error(`Development environment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}}).command(["deployment:prepare-local","dep:prepare-local","dpl"],"Prepare local environment for development (env: PROJECT_KEY, PROJECT_SLUG, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA, SERVER_URL, LAMBDA_URL)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, default: local)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, default: project name in package.json)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows to override deployment schemas (env: OVERRIDE_SCHEMA, default: true)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, default: http://localhost:3000)"}).option("lambdaUrl",{alias:"l",type:"string",description:"Webhook URL (env: LAMBDA_URL, default: http://localhost:8080)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_SLUG:o({default:void 0}),PROJECT_KEY:o({default:"project_local-dev-key-12345"}),PROJECT_SLUG:o({default:"local"}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!0}),SERVER_URL:o({default:"http://localhost:3000"}),LAMBDA_URL:o({default:"http://localhost:8080"}),ENVIRONMENT_API_KEY:o({default:"local-dev-key-12345"})})(),r=t.debug??i.DEBUG,n=t.projectKey??i.PROJECT_KEY;if(!n)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let a=await ev(),s=t.environmentSlug??i.ENVIRONMENT_SLUG??a.name;if(!s)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");let l=t.apiKey??i.ENVIRONMENT_API_KEY;if(!l)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let p=ep({debug:r}),d=ec(t.applicationSpec,a.applicationFlow,{logger:p});try{await (d?R:h.prepareLocalEnvironment)({apiKey:l,projectKey:n,projectSlug:t.projectSlug??i.PROJECT_SLUG,environmentSlug:s,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,serverUrl:t.serverUrl??i.SERVER_URL,lambdaUrl:t.lambdaUrl??i.LAMBDA_URL,debug:r,projectVersion:eE.version},{logger:p})}catch(e){p.error(`Local environment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}}).command(["deployment:extract-sources <archive> <folder>"],"Validate the source archive of a phoenix deploy and extract its project files into a new folder. Links, special files, unsafe paths and oversized content are refused; entries that are not project files are left out",e=>e.positional("archive",{type:"string",demandOption:!0,description:"The source archive (.tgz)"}).positional("folder",{type:"string",demandOption:!0,description:"New or empty folder to extract the project files into"}),async e=>{let o=ep();try{await G({archivePath:e.archive,targetDir:e.folder},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command(["deployment:build-envs","dep:build-envs","dbe"],"Write the environment variables for the build step of a prepared deployment that builds apart from its deploy (env: DEPLOYMENT_ID, ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, OUT_FILE, SERVER_URL)",e=>e.option("uuid",{alias:"u",type:"string",description:"Id of the prepared deployment (env: DEPLOYMENT_ID, required)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),DEPLOYMENT_ID:o({default:void 0}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),OUT_FILE:o({default:".env.generated"}),SERVER_URL:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.uuid??i.DEPLOYMENT_ID;if(!n)throw Error("Deployment ID is required, provide via --uuid or -u, or set DEPLOYMENT_ID environment variable");let a=t.apiKey??i.ENVIRONMENT_API_KEY;if(!a)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let s=t.projectKey??i.PROJECT_KEY;if(!s)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let l=t.projectSlug??i.PROJECT_SLUG;if(!l)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let p=t.serverUrl??i.SERVER_URL;if(!p)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let d=ep({debug:r});await w({uuid:n,apiKey:a,projectKey:s,projectSlug:l,outFile:t.outFile??i.OUT_FILE,serverUrl:p,debug:r},{logger:d})}).command(["deployment:finish","dep:finish","df"],"Upload files to S3 and activate deployment (env: DEPLOYMENT_ID, ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, LAMBDA_URL, SERVER_URL, SKIP_UPLOAD)",e=>e.option("uuid",{alias:"u",type:"string",description:"Id of the deployment to be activated (env: DEPLOYMENT_ID, required)"}).option("uploadLinksFile",{alias:"ulf",type:"string",description:"File containing upload links (generated by prepare command) (default: .upload-links.json)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("lambdaUrl",{alias:"l",type:"string",description:"Lambda webhook URL for the deployment (env: LAMBDA_URL, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),DEPLOYMENT_ID:o({default:void 0}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),LAMBDA_URL:o({default:void 0}),SERVER_URL:o({default:void 0}),SKIP_UPLOAD:e({default:!1})})(),r=t.debug??i.DEBUG,n=t.uuid??i.DEPLOYMENT_ID;if(!n)throw Error("Deployment ID is required, provide via --uuid or -u, or set DEPLOYMENT_ID environment variable");let a=t.apiKey??i.ENVIRONMENT_API_KEY;if(!a)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let s=t.projectKey??i.PROJECT_KEY;if(!s)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let l=t.projectSlug??i.PROJECT_SLUG;if(!l)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let p=t.lambdaUrl??i.LAMBDA_URL;if(!p)throw Error("Lambda URL is required, provide via --lambdaUrl or -l, or set LAMBDA_URL environment variable");let d=t.serverUrl??i.SERVER_URL;if(!d)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let c=ep({debug:r});await A({uuid:n,uploadLinksFile:t.uploadLinksFile??".upload-links.json",apiKey:a,projectKey:s,projectSlug:l,lambdaUrl:p,serverUrl:d,skipUpload:t.skipUpload??i.SKIP_UPLOAD,debug:r},{logger:c})}).demandCommand(1,"Please specify a command").help().alias("help","h").version(eE.version).alias("version","v").strict().parse();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{openAsBlob as e}from"node:fs";import{createApiBaseClient as t}from"#package/client";import{resolveApplicationSpecDeploymentData as i}from"../application-spec/index.js";import{createSourceArchive as o,getServerCredentials as a}from"../services/index.js";let r={queued:"Waiting for a build runner",preparing:"Preparing the deployment",building:"Building the project",deploying:"Deploying the frontend, webhooks and assets",live:"Live",failed:"Failed",cancelled:"Cancelled"},s=e=>new Promise(t=>setTimeout(t,e)),n=async(t,i)=>{let o=new FormData;for(let[e,i]of Object.entries(t.fields))o.append(e,i);o.append("file",await e(i,{type:"application/gzip"}),"sources.tgz");let a=await fetch(t.url,{method:"POST",body:o});if(!a.ok)throw Error(`Uploading the sources failed with HTTP ${a.status}: ${await a.text()}`)};export const runDeployCommand=async(e,{logger:l})=>{let d=await a(e.serverUrl),{pollIntervalMs:u}=e;if(!d)throw Error(`You are not signed in to ${e.serverUrl}. Run \`phoenix login <workspace>\` first.`);let c=t(e.serverUrl),p={authorization:`Bearer ${d.token}`};l.step("Validating the application spec");let h=await i({skipUpload:!0,logger:l});l.success(`The spec is valid (application version ${h.applicationVersion})`),l.step(`Packing the project for ${d.customerName}`);let m=await o(e.projectDir);try{let t;m.hasConversationLog?l.info("Including conversation.log in the private sources archive. It is not published with the application."):l.warn("No conversation.log found in the project root. Deploying without a conversation transcript."),l.info(` ${m.fileCount} files, ${(t=m.size)<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}`);let i=await c.POST("/deployments/builds",{body:{sdkVersion:e.sdkVersion,sizeBytes:m.size,configurationSchema:{version:h.schemaVersion,schema:h.schema},adminConfigurationSchema:h.adminSchema?{version:h.adminSchemaVersion,schema:h.adminSchema}:void 0},headers:p});if(i.error||!i.data)throw Error(`The server did not create a build: ${i.error?.message??"no response"}`);let{buildId:o,upload:a}=i.data;l.step("Uploading the sources"),await n(a,m.path);let f=await c.POST("/deployments/builds/{buildId}/start",{params:{path:{buildId:o}},headers:{...p,"content-type":null}});if(f.error)throw Error(`The server did not start the build: ${f.error.message}`);if(f.data?.status==="failed")throw Error(`Build ${o} could not be started: ${f.data.error??"the server gave no reason"}`);if(l.success(`Build ${o} started`),d.studioUrl){let e=new URL(`/builder/deployments/${o}`,d.studioUrl);e.searchParams.set("customer",d.customerSlug),l.info(`Follow the build in Studio: ${e.toString()}`)}if(!e.wait)return;let g=null,w=0;for(;;){let{data:e,error:t}=await c.GET("/deployments/builds/{buildId}",{params:{path:{buildId:o}},headers:p}).catch(e=>({data:void 0,error:{message:String(e)}}));if(t||!e){if((w+=1)>=5)throw Error(`Following build ${o} failed: ${t?.message??"no response"}. The build may still finish; check Deployments in Studio.`);await s(u);continue}if(w=0,e.status!==g&&(g=e.status,l.step(r[e.status])),"live"===e.status){l.success(`Your configurator is live at ${e.configuratorUrl}`),l.info("Coding agents: when the user has nothing more to build,
|
|
1
|
+
import{openAsBlob as e}from"node:fs";import{createApiBaseClient as t}from"#package/client";import{resolveApplicationSpecDeploymentData as i}from"../application-spec/index.js";import{createSourceArchive as o,getServerCredentials as a}from"../services/index.js";let r={queued:"Waiting for a build runner",preparing:"Preparing the deployment",building:"Building the project",deploying:"Deploying the frontend, webhooks and assets",live:"Live",failed:"Failed",cancelled:"Cancelled"},s=e=>new Promise(t=>setTimeout(t,e)),n=async(t,i)=>{let o=new FormData;for(let[e,i]of Object.entries(t.fields))o.append(e,i);o.append("file",await e(i,{type:"application/gzip"}),"sources.tgz");let a=await fetch(t.url,{method:"POST",body:o});if(!a.ok)throw Error(`Uploading the sources failed with HTTP ${a.status}: ${await a.text()}`)};export const runDeployCommand=async(e,{logger:l})=>{let d=await a(e.serverUrl),{pollIntervalMs:u}=e;if(!d)throw Error(`You are not signed in to ${e.serverUrl}. Run \`phoenix login <workspace>\` first.`);let c=t(e.serverUrl),p={authorization:`Bearer ${d.token}`};l.step("Validating the application spec");let h=await i({skipUpload:!0,logger:l});l.success(`The spec is valid (application version ${h.applicationVersion})`),l.step(`Packing the project for ${d.customerName}`);let m=await o(e.projectDir);try{let t;m.hasConversationLog?l.info("Including conversation.log in the private sources archive. It is not published with the application."):l.warn("No conversation.log found in the project root. Deploying without a conversation transcript."),l.info(` ${m.fileCount} files, ${(t=m.size)<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}`);let i=await c.POST("/deployments/builds",{body:{sdkVersion:e.sdkVersion,sizeBytes:m.size,configurationSchema:{version:h.schemaVersion,schema:h.schema},adminConfigurationSchema:h.adminSchema?{version:h.adminSchemaVersion,schema:h.adminSchema}:void 0},headers:p});if(i.error||!i.data)throw Error(`The server did not create a build: ${i.error?.message??"no response"}`);let{buildId:o,upload:a}=i.data;l.step("Uploading the sources"),await n(a,m.path);let f=await c.POST("/deployments/builds/{buildId}/start",{params:{path:{buildId:o}},headers:{...p,"content-type":null}});if(f.error)throw Error(`The server did not start the build: ${f.error.message}`);if(f.data?.status==="failed")throw Error(`Build ${o} could not be started: ${f.data.error??"the server gave no reason"}`);if(l.success(`Build ${o} started`),d.studioUrl){let e=new URL(`/builder/deployments/${o}`,d.studioUrl);e.searchParams.set("customer",d.customerSlug),l.info(`Follow the build in Studio: ${e.toString()}`)}if(!e.wait)return;let g=null,w=0;for(;;){let{data:e,error:t}=await c.GET("/deployments/builds/{buildId}",{params:{path:{buildId:o}},headers:p}).catch(e=>({data:void 0,error:{message:String(e)}}));if(t||!e){if((w+=1)>=5)throw Error(`Following build ${o} failed: ${t?.message??"no response"}. The build may still finish; check Deployments in Studio.`);await s(u);continue}if(w=0,e.status!==g&&(g=e.status,l.step(r[e.status])),"live"===e.status){l.success(`Your configurator is live at ${e.configuratorUrl}`),l.info("Coding agents: when the user has nothing more to build, load the phoenix skill and follow its Feedback guide for the run evaluation, once per conversation.");return}if("failed"===e.status||"cancelled"===e.status||e.timedOut){let t=await c.GET("/deployments/builds/{buildId}/log",{params:{path:{buildId:o}},headers:p}).catch(()=>({data:void 0})),i=(t.data?.log??"").trim().split("\n").slice(-40).join("\n");i&&l.info(`
|
|
2
2
|
Last lines of the build log:
|
|
3
3
|
${i}
|
|
4
4
|
`);let a=e.timedOut?"it took too long":e.error??"see the build log";throw Error(`Build ${o} did not go live: ${a}`)}await s(u)}}finally{await m.cleanup()}};
|