@salsita-ai/sdk 0.50.0-develop.9241bcf09e → 0.50.0-develop.927e2414eb
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 +3 -3
- package/dist/admin/common/admin-interface.d.ts +11 -1
- package/dist/admin/common/admin-interface.js +1 -1
- package/dist/admin/ui/layout/UserProfile.d.ts +1 -1
- package/dist/admin/ui/layout/UserProfile.js +1 -1
- package/dist/admin/ui/maintenance/ImportPresets.js +1 -1
- package/dist/application/mount-application.js +1 -1
- package/dist/application/mount-configurator.js +1 -1
- package/dist/application/studio-embedding.d.ts +6 -0
- package/dist/application/studio-embedding.js +1 -0
- package/dist/application-spec/core/enhanced-json-schema.d.ts +5 -6
- package/dist/application-spec/core/enhanced-json-schema.js +1 -1
- package/dist/application-spec/core/markers/index.d.ts +1 -0
- package/dist/application-spec/core/markers/index.js +1 -1
- package/dist/application-spec/core/markers/set-in-studio-marker.d.ts +15 -0
- package/dist/application-spec/core/markers/set-in-studio-marker.js +1 -0
- package/dist/application-spec/errors/diagnostic-codes.d.ts +16 -0
- package/dist/application-spec/errors/diagnostic-codes.js +1 -1
- package/dist/application-spec/errors/diagnostic-messages.d.ts +16 -0
- package/dist/application-spec/errors/diagnostic-messages.js +1 -1
- package/dist/application-spec/generate-application/code/domain-runtime-files.d.ts +3 -3
- package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
- package/dist/application-spec/generate-application/code/standalone-app-files.d.ts +0 -12
- package/dist/application-spec/generate-application/code/standalone-app-files.js +1 -1
- package/dist/application-spec/generate-application/code/templates/admin-config.d.ts +5 -1
- package/dist/application-spec/generate-application/code/templates/admin-config.js +4 -4
- package/dist/application-spec/generate-application/code/templates/application-types.js +5 -5
- package/dist/application-spec/generate-application/code/templates/configurator-config.js +6 -6
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +19 -0
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +12 -12
- package/dist/application-spec/generate-application/code/templates/frontend-config.js +7 -3
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +3 -3
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +3 -3
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-assistant-form-element-types.d.ts +10 -6
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-assistant-form-element-types.js +7 -7
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-phx-types.js +12 -12
- package/dist/application-spec/generate-application/code/templates/globals.js +21 -12
- package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/sign-in-page-options.d.ts +5 -0
- package/dist/application-spec/generate-application/code/templates/sign-in-page-options.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/core/cli.d.ts +2 -1
- package/dist/application-spec/generate-application/code/templates/skills/core/cli.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/core/sdk.js +2 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/application-states/presets.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/application-states/views-and-tools.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/assistant/index.d.ts +3 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/assistant/index.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/{custom-layout/assistant.d.ts → assistant/panel.d.ts} +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/assistant/panel.js +42 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/assistant/reading-and-changing.d.ts +3 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/assistant/reading-and-changing.js +55 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/{webhooks/assistant-setup.d.ts → assistant/session-setup.d.ts} +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/assistant/session-setup.js +16 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/custom-layout.js +2 -2
- package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/sign-in.d.ts +3 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/sign-in.js +19 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/domain-model/actions.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/embedding.d.ts +2 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/embedding.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/features.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/authentication.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/authentication.js +32 -26
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/entry-and-environment.js +1 -3
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/publishing.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/session-fields.d.ts +3 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/session-fields.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/webhooks.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/guide.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill-bundle.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill-bundle.js +3 -3
- package/dist/application-spec/generate-application/code/templates/skills/processes/asset-conversion.js +3 -3
- package/dist/application-spec/generate-application/code/templates/skills/processes/assistant-configuration.d.ts +3 -0
- package/dist/application-spec/generate-application/code/templates/skills/processes/assistant-configuration.js +3 -0
- package/dist/application-spec/generate-application/code/templates/skills/processes/feedback/report.js +2 -2
- package/dist/application-spec/generate-application/code/templates/skills/processes/first-draft/handoff.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/processes/index.d.ts +2 -1
- package/dist/application-spec/generate-application/code/templates/skills/processes/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/processes/model-migration.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/processes/review/appearance.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/processes/review/code.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/processes/scene-realism.d.ts +2 -0
- package/dist/application-spec/generate-application/code/templates/skills/processes/scene-realism.js +29 -0
- package/dist/application-spec/generate-application/code/templates/skills/sdk-channel.d.ts +17 -0
- package/dist/application-spec/generate-application/code/templates/skills/sdk-channel.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/sdk-subpath-imports.js +1 -1
- package/dist/application-spec/generate-application/code/templates/webhook-builders.js +3 -2
- package/dist/application-spec/generate-application/code/templates/webhook-index.d.ts +1 -2
- package/dist/application-spec/generate-application/code/templates/webhook-index.js +3 -7
- package/dist/application-spec/generate-application/code/webhook-safe-files.d.ts +3 -1
- package/dist/application-spec/generate-application/code/webhook-safe-files.js +1 -1
- package/dist/application-spec/parse-application-files/access/access-handler-kinds.d.ts +18 -0
- package/dist/application-spec/parse-application-files/access/access-handler-kinds.js +1 -0
- package/dist/application-spec/parse-application-files/access/analyzed-file.d.ts +7 -0
- package/dist/application-spec/parse-application-files/access/analyzed-file.js +1 -0
- package/dist/application-spec/parse-application-files/access/check-access-handler-files.d.ts +20 -0
- package/dist/application-spec/parse-application-files/access/check-access-handler-files.js +1 -0
- package/dist/application-spec/parse-application-files/access/check-auth-hook-files.d.ts +17 -0
- package/dist/application-spec/parse-application-files/access/check-auth-hook-files.js +1 -0
- package/dist/application-spec/parse-application-files/access/index.d.ts +5 -0
- package/dist/application-spec/parse-application-files/access/index.js +1 -0
- package/dist/application-spec/parse-application-files/access/sign-in-control.d.ts +7 -0
- package/dist/application-spec/parse-application-files/access/sign-in-control.js +1 -0
- package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +2 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/module-analysis.d.ts +30 -4
- package/dist/application-spec/parse-application-files/categorize/module-analysis.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/webhook-safety.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-app-metadata.d.ts +16 -1
- package/dist/application-spec/parse-application-files/merge/merged-app-metadata.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-assistant.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +7 -1
- package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
- package/dist/application-spec/parse-application-files/parse-application-files.js +1 -1
- package/dist/application-spec/parse-application-files/parse-common-admin-spec.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.d.ts +3 -2
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +29 -6
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-components.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +11 -3
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
- package/dist/application-spec/parse-application-files/resolve/resolve-import-modules.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +6 -0
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/index.d.ts +2 -1
- package/dist/application-spec/parse-application-files/spec/model/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/session-data-schema.d.ts +5 -2
- package/dist/application-spec/parse-application-files/spec/model/session-data-schema.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/session-fields/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/model/session-fields/index.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/session-fields/session-fields.d.ts +15 -0
- package/dist/application-spec/parse-application-files/spec/model/session-fields/session-fields.js +1 -0
- package/dist/application-spec/parse-application-files/spec/relations/relations.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/actions.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/app-metadata.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-form-elements.d.ts +14 -2
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-form-elements.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +6 -9
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/index.d.ts +0 -1
- package/dist/client/authenticated-client.d.ts +5 -1
- package/dist/client/authenticated-client.js +1 -1
- package/dist/client/authorized-client.d.ts +3 -1
- package/dist/client/authorized-client.js +1 -1
- package/dist/client/base-client.d.ts +15 -1
- package/dist/client/base-client.js +1 -1
- package/dist/client/cli-client/cli-api-client.d.ts +17 -0
- package/dist/client/cli-client/cli-api-client.js +1 -0
- package/dist/client/cli-client/index.d.ts +2 -0
- package/dist/client/cli-client/index.js +1 -0
- package/dist/client/cli-client/unsupported-api-version-error.d.ts +11 -0
- package/dist/client/cli-client/unsupported-api-version-error.js +1 -0
- package/dist/client/contract.d.ts +39 -4
- package/dist/client/contract.js +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.js +1 -1
- package/dist/client/phoenix-api.d.ts +7834 -2378
- package/dist/client/unauthenticated-client.d.ts +2 -1
- package/dist/client/unauthenticated-client.js +1 -1
- package/dist/client/version.d.ts +11 -0
- package/dist/client/version.js +1 -1
- package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/action-system/action.d.ts +16 -4
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +25 -10
- 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 +15 -5
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/index.d.ts +1 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/index.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/register-webmcp-tools.d.ts +7 -3
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/register-webmcp-tools.js +6 -2
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/share-link.d.ts +14 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/webmcp/share-link.js +2 -0
- package/dist/configurator/application-runtime/extensions/systems/camera-control-system/camera-control-system.d.ts +41 -35
- package/dist/configurator/application-runtime/extensions/systems/camera-control-system/camera-control-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/export-system/export-system.d.ts +4 -2
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +9 -3
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/read-offered-navigation.d.ts +6 -3
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/read-offered-navigation.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/export-image-capture.d.ts +15 -4
- package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/export-image-capture.js +3 -3
- package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/image-rendering-system.d.ts +15 -7
- package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/image-rendering-system.js +1 -1
- package/dist/configurator/common/configurator-interface.d.ts +13 -1
- package/dist/configurator/common/configurator-interface.js +1 -1
- package/dist/configurator/scene/animations/Animations.js +1 -1
- package/dist/configurator/scene/cameras/CameraPadding.d.ts +5 -0
- package/dist/configurator/scene/cameras/CameraPadding.js +1 -1
- package/dist/configurator/scene/resources/use-phx-gltf.js +1 -1
- package/dist/configurator/scene/scene-entity/materials/LocalCreatedMaterial.js +1 -1
- package/dist/configurator/scene/scene-entity/materials/RemoteReplacedMaterial.d.ts +5 -0
- package/dist/configurator/scene/scene-entity/materials/RemoteReplacedMaterial.js +1 -1
- package/dist/configurator/scene/scene-entity/materials/use-dispose-replaced.d.ts +27 -0
- package/dist/configurator/scene/scene-entity/materials/use-dispose-replaced.js +1 -0
- package/dist/configurator/toolbar-actions/use-toolbar-actions.js +1 -1
- package/dist/configurator/ui/assistant/AssistantComposer.js +1 -1
- package/dist/configurator/ui/assistant/AssistantPanel.js +1 -1
- package/dist/configurator/ui/assistant/annotation/editor/AnnotationComment.d.ts +6 -5
- package/dist/configurator/ui/assistant/annotation/editor/AnnotationComment.js +1 -1
- package/dist/configurator/ui/assistant/annotation/editor/AnnotationEditor.d.ts +4 -3
- package/dist/configurator/ui/assistant/annotation/editor/AnnotationEditor.js +1 -1
- package/dist/configurator/ui/assistant/annotation/editor/annotation-pins.d.ts +5 -0
- package/dist/configurator/ui/assistant/annotation/editor/annotation-pins.js +1 -1
- package/dist/configurator/ui/assistant/disclaimer/AssistantDisclaimerDialog.d.ts +10 -0
- package/dist/configurator/ui/assistant/disclaimer/AssistantDisclaimerDialog.js +1 -0
- package/dist/configurator/ui/assistant/disclaimer/AssistantDisclaimerLine.d.ts +10 -0
- package/dist/configurator/ui/assistant/disclaimer/AssistantDisclaimerLine.js +1 -0
- package/dist/configurator/ui/assistant/disclaimer/index.d.ts +2 -0
- package/dist/configurator/ui/assistant/disclaimer/index.js +1 -0
- package/dist/configurator/ui/assistant/drawing/AssistantDrawing.d.ts +2 -3
- package/dist/configurator/ui/assistant/drawing/AssistantDrawing.js +1 -1
- package/dist/configurator/ui/assistant/drawing/index.d.ts +1 -1
- package/dist/configurator/ui/assistant/drawing/index.js +1 -1
- package/dist/configurator/ui/assistant/drawing/use-drawing-url.d.ts +6 -12
- package/dist/configurator/ui/assistant/drawing/use-drawing-url.js +1 -1
- package/dist/configurator/ui/assistant/form/registry/create-assistant-form-element.d.ts +11 -7
- package/dist/configurator/ui/assistant/form-elements/FormTile.js +1 -1
- package/dist/configurator/ui/assistant/image-view/ImageView.js +1 -1
- package/dist/configurator/ui/assistant/panel/AssistantPanelHeader.js +1 -1
- package/dist/configurator/ui/assistant/use-assistant-composer.d.ts +5 -0
- package/dist/configurator/ui/assistant/use-assistant-composer.js +2 -2
- package/dist/configurator/ui/configurator-layout/index.d.ts +1 -1
- package/dist/configurator/ui/configurator-layout/index.js +1 -1
- package/dist/configurator/ui/configurator-layout/slots/desktop-sidebar/DesktopSidebar.js +4 -4
- package/dist/configurator/ui/configurator-layout/slots/index.d.ts +2 -0
- package/dist/configurator/ui/configurator-layout/slots/index.js +1 -1
- package/dist/configurator/ui/configurator-layout/slots/view-controls/DesktopViewControls.js +1 -1
- package/dist/configurator/ui/configurator-layout/slots/view-controls/MobileViewControls.js +1 -1
- package/dist/configurator/ui/configurator-layout/slots/view-controls/NestedViewControls.d.ts +7 -0
- package/dist/configurator/ui/configurator-layout/slots/view-controls/NestedViewControls.js +1 -0
- package/dist/configurator/ui/configurator-layout/slots/view-controls/use-view-control-items.d.ts +6 -0
- package/dist/configurator/ui/configurator-layout/slots/view-controls/use-view-control-items.js +1 -0
- package/dist/configurator/ui/configurator-layout/universal/DesktopPreview.js +1 -1
- package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +3 -3
- package/dist/configurator/ui/configurator-layout/universal/MobilePreview.js +1 -1
- package/dist/configurator/ui/configurator-layout/universal/use-preview-description.d.ts +1 -0
- package/dist/configurator/ui/configurator-layout/universal/use-preview-description.js +1 -0
- package/dist/configurator/ui/index.d.ts +1 -1
- package/dist/configurator/ui/legacy/layout/common/ViewControls.js +1 -1
- package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -1
- package/dist/docs/index.json +117 -2
- package/dist/docs/layouts/nested-view-controls.mdx +223 -0
- package/dist/docs/layouts/preview/always.mdx +22 -0
- package/dist/docs/layouts/view-controls.mdx +2 -0
- package/dist/docs/other-features/domain-actions.mdx +53 -56
- package/dist/docs/phoenix/admin.mdx +5 -40
- package/dist/docs/phoenix/application-states.mdx +1 -1
- package/dist/docs/phoenix/assistant/actions.mdx +183 -0
- package/dist/docs/phoenix/assistant/changing-the-configuration.mdx +333 -0
- package/dist/docs/phoenix/assistant/instructions-and-ai-settings.mdx +221 -0
- package/dist/docs/phoenix/assistant/overview.mdx +137 -0
- package/dist/docs/phoenix/assistant/per-session-setup.mdx +166 -0
- package/dist/docs/phoenix/assistant/reading-the-configuration.mdx +349 -0
- package/dist/docs/phoenix/assistant/screenshots.mdx +135 -0
- package/dist/docs/phoenix/assistant/security-and-limits.mdx +151 -0
- package/dist/docs/phoenix/assistant/the-panel.mdx +298 -0
- package/dist/docs/phoenix/clerk-sign-in.mdx +9 -5
- package/dist/docs/phoenix/configurator-interface.mdx +18 -33
- package/dist/docs/phoenix/csp.mdx +3 -1
- package/dist/docs/phoenix/data-sources.mdx +26 -30
- package/dist/docs/phoenix/deployments.mdx +3 -3
- package/dist/docs/phoenix/finalization.mdx +0 -1
- package/dist/docs/phoenix/integration/authentication-external.mdx +17 -15
- package/dist/docs/phoenix/integration/authentication-internal.mdx +1 -1
- package/dist/docs/phoenix/integration/finalization-internal.mdx +1 -4
- package/dist/docs/phoenix/integration/integration-modes-external.mdx +2 -2
- package/dist/docs/phoenix/integration/integration-modes-internal.mdx +9 -0
- package/dist/docs/phoenix/layout-slots.mdx +1 -1
- package/dist/docs/phoenix/migrations.mdx +1 -1
- package/dist/docs/phoenix/phoenix-cli.mdx +90 -57
- package/dist/docs/phoenix/project-structure.mdx +30 -15
- package/dist/docs/phoenix/publishing.mdx +21 -28
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +51 -34
- package/dist/docs/phoenix/sessions-and-access.mdx +171 -164
- package/dist/docs/phoenix/webhook-membership.mdx +4 -1
- package/dist/docs/phoenix/webhooks.mdx +93 -116
- package/dist/docs/ux-guidelines/interaction-modes.mdx +2 -2
- package/dist/domain/application/access/access-handlers.d.ts +19 -0
- package/dist/domain/application/access/access-handlers.js +1 -0
- package/dist/domain/application/access/anonymous-handler.d.ts +16 -0
- package/dist/domain/application/access/anonymous-handler.js +1 -0
- package/dist/domain/application/access/chunk-scopes-handler.d.ts +27 -0
- package/dist/domain/application/access/chunk-scopes-handler.js +1 -0
- package/dist/domain/application/access/code-handler.d.ts +16 -0
- package/dist/domain/application/access/code-handler.js +1 -0
- package/dist/domain/application/access/index.d.ts +7 -0
- package/dist/domain/application/access/index.js +1 -0
- package/dist/domain/application/access/refresh-handler.d.ts +16 -0
- package/dist/domain/application/access/refresh-handler.js +1 -0
- package/dist/domain/application/access/signed-in-handler.d.ts +44 -0
- package/dist/domain/application/access/signed-in-handler.js +1 -0
- package/dist/domain/application/access/visitor-handler.d.ts +23 -0
- package/dist/domain/application/access/visitor-handler.js +1 -0
- package/dist/domain/application/application-config.d.ts +36 -1
- package/dist/domain/application/assistant/assistant-exposure.d.ts +22 -0
- package/dist/domain/application/assistant/assistant-exposure.js +1 -0
- package/dist/domain/application/assistant/build-assistant-lenses.js +3 -3
- package/dist/domain/application/assistant/build-assistant-manifest.js +1 -1
- package/dist/domain/application/assistant/generate-assistant-prompt.d.ts +6 -2
- package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
- package/dist/domain/application/assistant/index.d.ts +1 -0
- package/dist/domain/application/assistant/index.js +1 -1
- package/dist/domain/application/assistant/session-setup/apply-assistant-setup.js +1 -1
- package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.d.ts +14 -2
- package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.js +1 -1
- package/dist/domain/application/assistant/session-setup/assistant-takes-images.d.ts +7 -0
- package/dist/domain/application/assistant/session-setup/assistant-takes-images.js +1 -0
- package/dist/domain/application/assistant/session-setup/index.d.ts +1 -0
- package/dist/domain/application/assistant/session-setup/index.js +1 -1
- package/dist/domain/application/assistant-mutations.js +1 -1
- package/dist/domain/application/assistant-recipe-groups.d.ts +4 -3
- package/dist/domain/application/assistant-recipe-groups.js +1 -1
- package/dist/domain/application/configurator-builder.d.ts +2 -0
- package/dist/domain/application/configurator-builder.js +1 -1
- package/dist/domain/application/index.d.ts +2 -1
- package/dist/domain/application/index.js +1 -1
- package/dist/domain/application/standard-properties.d.ts +1 -1
- package/dist/domain/application/standard-properties.js +1 -1
- package/dist/domain/available-system-components/available-system-components.js +1 -1
- package/dist/domain/core/component/system-component-filter.d.ts +1 -0
- package/dist/domain/core/component/system-component-filter.js +1 -1
- package/dist/domain/core/component/view-state-component.d.ts +4 -3
- package/dist/domain/core/component/view-state-component.js +1 -1
- package/dist/domain/core/domain-factory.d.ts +6 -0
- package/dist/domain/core/domain-factory.js +1 -1
- package/dist/domain/core/fit-session-data.d.ts +16 -0
- package/dist/domain/core/fit-session-data.js +1 -0
- package/dist/domain/domain-context/navigation-system/navigation-system.d.ts +2 -2
- package/dist/domain/domain-context/navigation-system/navigation-system.js +1 -1
- package/dist/domain/domain-context/transformers/when-builder.js +1 -1
- package/dist/domain/domain-runtime/domain-context/actions.d.ts +4 -0
- package/dist/domain/domain-runtime/domain-context/actions.js +1 -1
- package/dist/domain/domain-runtime/domain-context/domain-context.d.ts +8 -0
- package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
- package/dist/domain/domain-runtime/domain-context/selectors.d.ts +1 -0
- package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
- package/dist/domain/domain-runtime/domain-context/types.d.ts +8 -4
- package/dist/domain/domain-runtime/domain-runtime.d.ts +8 -0
- package/dist/domain/extensions/export-images/agent-screenshot.d.ts +5 -4
- package/dist/domain/extensions/export-images/agent-screenshot.js +1 -1
- package/dist/domain/extensions/index.d.ts +0 -1
- package/dist/domain/extensions/index.js +1 -1
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +4 -0
- package/dist/domain/spec/sections/actions.d.ts +3 -2
- package/dist/domain/spec/sections/app-metadata.d.ts +12 -0
- package/dist/domain/spec/sections/assistant/assistant-features.d.ts +13 -0
- package/dist/domain/spec/sections/assistant/assistant-features.js +1 -0
- package/dist/domain/spec/sections/assistant/assistant-manifest.d.ts +17 -6
- package/dist/domain/spec/sections/assistant/assistant-resolved-manifest.d.ts +28 -5
- package/dist/domain/spec/sections/assistant/index.d.ts +1 -0
- package/dist/domain/system-components/index.d.ts +1 -0
- package/dist/domain/system-components/index.js +1 -1
- package/dist/domain/system-components/navigation/index.d.ts +1 -0
- package/dist/domain/system-components/navigation/index.js +1 -0
- package/dist/domain/system-components/navigation/view-controls.d.ts +24 -0
- package/dist/domain/system-components/navigation/view-controls.js +1 -0
- package/dist/editor/domain-editors/use-implementation-files.js +1 -1
- package/dist/extras/clerk/index.d.ts +6 -0
- package/dist/extras/cognito/AccountAvatar.d.ts +7 -0
- package/dist/extras/cognito/AccountAvatar.js +1 -0
- package/dist/extras/cognito/AccountControl.d.ts +14 -0
- package/dist/extras/cognito/AccountControl.js +1 -0
- package/dist/extras/cognito/AdminSignInPage.d.ts +26 -0
- package/dist/extras/cognito/AdminSignInPage.js +1 -0
- package/dist/extras/cognito/CognitoSignInPage.d.ts +8 -2
- package/dist/extras/cognito/CognitoSignInPage.js +1 -1
- package/dist/extras/cognito/ConfiguratorSignInPage.d.ts +19 -0
- package/dist/extras/cognito/ConfiguratorSignInPage.js +1 -0
- package/dist/extras/cognito/SignInFailurePage.d.ts +11 -0
- package/dist/extras/cognito/SignInFailurePage.js +1 -0
- package/dist/extras/cognito/SignInGateLayout.d.ts +25 -0
- package/dist/extras/cognito/SignInGateLayout.js +1 -0
- package/dist/extras/cognito/SignInNotice.d.ts +9 -0
- package/dist/extras/cognito/SignInNotice.js +1 -0
- package/dist/extras/cognito/index.d.ts +4 -0
- package/dist/extras/cognito/index.js +1 -1
- package/dist/globals/index.d.ts +5 -0
- package/dist/i18n/locales/cs/messages.js +1 -1
- package/dist/i18n/locales/da/messages.js +1 -1
- package/dist/i18n/locales/de/messages.js +1 -1
- package/dist/i18n/locales/de-AT/messages.js +1 -1
- package/dist/i18n/locales/en/messages.js +1 -1
- package/dist/i18n/locales/en-AU/messages.js +1 -1
- package/dist/i18n/locales/en-GB/messages.js +1 -1
- package/dist/i18n/locales/es/messages.js +1 -1
- package/dist/i18n/locales/fr/messages.js +1 -1
- package/dist/i18n/locales/hu/messages.js +1 -1
- package/dist/i18n/locales/it/messages.js +1 -1
- package/dist/i18n/locales/nl/messages.js +1 -1
- package/dist/i18n/locales/pl/messages.js +1 -1
- package/dist/i18n/locales/pt/messages.js +1 -1
- package/dist/i18n/locales/ro/messages.js +1 -1
- package/dist/i18n/locales/sk/messages.js +1 -1
- package/dist/i18n/locales/tr/messages.js +1 -1
- package/dist/legacy/deployment-cli/commands/create-environment.js +1 -1
- package/dist/legacy/deployment-cli/commands/list-environments.js +1 -1
- package/dist/legacy/deployment-cli/commands/register-deployment.js +1 -1
- package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +12 -3
- package/dist/legacy/phoenix-cli/commands/prepare-deployment-command.js +1 -1
- package/dist/legacy/phoenix-cli/commands/prepare-local-environment-command.js +1 -1
- package/dist/legacy/phoenix-cli/services/prepare-development-environment.js +1 -1
- package/dist/legacy/phoenix-cli/services/webhook-service/transport.js +1 -1
- package/dist/phoenix/application-spec/index.d.ts +1 -1
- package/dist/phoenix/application-spec/index.js +1 -1
- package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +10 -3
- package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
- package/dist/phoenix/cli.js +1 -1
- package/dist/phoenix/commands/account/whoami.d.ts +8 -2
- package/dist/phoenix/commands/account/whoami.js +4 -3
- package/dist/phoenix/commands/cleanup-environment.js +1 -1
- package/dist/phoenix/commands/deploy.d.ts +7 -2
- package/dist/phoenix/commands/deploy.js +9 -3
- package/dist/phoenix/commands/deployment-build-envs-command.js +1 -1
- package/dist/phoenix/commands/deps/deps.js +2 -2
- package/dist/phoenix/commands/feedback.d.ts +2 -2
- package/dist/phoenix/commands/feedback.js +1 -1
- package/dist/phoenix/commands/finish-deployment-command.js +1 -1
- package/dist/phoenix/commands/init-starter-spec.js +3 -4
- package/dist/phoenix/commands/init.d.ts +2 -2
- package/dist/phoenix/commands/init.js +1 -1
- package/dist/phoenix/commands/login.d.ts +1 -1
- package/dist/phoenix/commands/login.js +2 -2
- package/dist/phoenix/commands/logout.js +1 -1
- package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
- package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
- package/dist/phoenix/services/cli-credentials.d.ts +13 -2
- package/dist/phoenix/services/cli-credentials.js +2 -2
- package/dist/phoenix/services/cli-server/describe-saved-logins.d.ts +5 -0
- package/dist/phoenix/services/cli-server/describe-saved-logins.js +1 -0
- package/dist/phoenix/services/cli-server/index.d.ts +2 -0
- package/dist/phoenix/services/cli-server/index.js +1 -0
- package/dist/phoenix/services/cli-server/resolve-cli-server-url.d.ts +25 -0
- package/dist/phoenix/services/cli-server/resolve-cli-server-url.js +1 -0
- package/dist/phoenix/services/development-credential.js +1 -1
- package/dist/phoenix/services/frontend-config.d.ts +2 -0
- package/dist/phoenix/services/index.d.ts +4 -2
- package/dist/phoenix/services/index.js +1 -1
- package/dist/phoenix/services/phoenix-regions.d.ts +15 -5
- package/dist/phoenix/services/phoenix-regions.js +1 -1
- package/dist/phoenix/services/prepare-development-environment.js +2 -2
- package/dist/phoenix/services/session/phoenix-application.js +1 -1
- package/dist/phoenix/services/signed-in-development-environment.d.ts +15 -4
- package/dist/phoenix/services/signed-in-development-environment.js +1 -1
- package/dist/phoenix/services/spec-project/describe-workspace-projects.d.ts +11 -0
- package/dist/phoenix/services/spec-project/describe-workspace-projects.js +1 -0
- package/dist/phoenix/services/spec-project/index.d.ts +3 -0
- package/dist/phoenix/services/spec-project/index.js +1 -0
- package/dist/phoenix/services/spec-project/resolve-deploy-target.d.ts +47 -0
- package/dist/phoenix/services/spec-project/resolve-deploy-target.js +1 -0
- package/dist/phoenix/services/spec-project/resolve-target-project.d.ts +34 -0
- package/dist/phoenix/services/spec-project/resolve-target-project.js +2 -0
- package/dist/phoenix/services/spec-project/write-spec-project.d.ts +7 -0
- package/dist/phoenix/services/spec-project/write-spec-project.js +1 -0
- package/dist/phoenix/services/variant-file-session.js +1 -1
- package/dist/phoenix/services/vite-config.js +1 -1
- package/dist/phoenix/services/webhook-service/transport.js +1 -1
- package/dist/react-sdk/application-runtime/common-services/selectors.js +1 -1
- package/dist/react-sdk/application-runtime/domain-application-context/configuration-persist-system.d.ts +6 -0
- package/dist/react-sdk/application-runtime/domain-application-context/configuration-persist-system.js +1 -1
- package/dist/react-sdk/application-runtime/host-properties/selectors.d.ts +2 -2
- package/dist/react-sdk/application-runtime/integration/integration-mode.d.ts +30 -0
- package/dist/react-sdk/application-runtime/integration/integration-mode.js +1 -1
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +20 -6
- package/dist/react-sdk/application-runtime/session/actions.d.ts +2 -1
- package/dist/react-sdk/application-runtime/session/actions.js +1 -1
- package/dist/react-sdk/application-runtime/session/initialize.js +1 -1
- package/dist/react-sdk/application-runtime/session/selectors.d.ts +2 -0
- package/dist/react-sdk/application-runtime/session/selectors.js +1 -1
- package/dist/react-sdk/application-runtime/session/session-service.d.ts +64 -2
- package/dist/react-sdk/application-runtime/session/session-service.js +1 -1
- package/dist/react-sdk/application-runtime/session/session-token.d.ts +8 -0
- package/dist/react-sdk/application-runtime/session/session-token.js +1 -1
- package/dist/react-sdk/application-runtime/session/types.d.ts +6 -1
- package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +1 -0
- package/dist/react-sdk/domain-context/index.d.ts +3 -2
- package/dist/react-sdk/domain-context/index.js +1 -1
- package/dist/react-sdk/domain-context/system-hooks/generate-share-link-hooks.d.ts +1 -5
- package/dist/react-sdk/domain-context/system-hooks/generate-share-link-hooks.js +1 -1
- package/dist/react-sdk/domain-context/system-hooks/generate-share-link.d.ts +25 -0
- package/dist/react-sdk/domain-context/system-hooks/generate-share-link.js +1 -0
- package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.d.ts +5 -3
- package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.js +1 -1
- package/dist/react-sdk/preset-selection/PresetSelectionProvider.js +1 -1
- package/dist/react-sdk/session/AccessDeniedAdminPage.d.ts +13 -0
- package/dist/react-sdk/session/AccessDeniedAdminPage.js +1 -0
- package/dist/react-sdk/session/AccessDeniedPage.d.ts +20 -0
- package/dist/react-sdk/session/AccessDeniedPage.js +1 -0
- package/dist/react-sdk/session/ConfiguratorUnavailablePage.d.ts +5 -0
- package/dist/react-sdk/session/ConfiguratorUnavailablePage.js +1 -0
- package/dist/react-sdk/session/SessionServiceProvider.d.ts +5 -0
- package/dist/react-sdk/session/SessionServiceProvider.js +1 -1
- package/dist/react-sdk/session/index.d.ts +3 -0
- package/dist/react-sdk/session/index.js +1 -1
- package/dist/react-sdk/session/server-sign-in-support.d.ts +16 -0
- package/dist/react-sdk/session/server-sign-in-support.js +1 -0
- package/dist/react-sdk/session/sign-in-address.d.ts +18 -0
- package/dist/react-sdk/session/sign-in-address.js +1 -0
- package/dist/react-sdk/session/studio-frame.d.ts +14 -0
- package/dist/react-sdk/session/studio-frame.js +1 -0
- package/dist/react-sdk/session/use-sign-in.d.ts +51 -0
- package/dist/react-sdk/session/use-sign-in.js +1 -0
- package/dist/ui-sdk/components/preview/Preview.d.ts +12 -4
- package/dist/ui-sdk/components/preview/Preview.js +2 -2
- package/dist/ui-sdk/components/snackbar/Snackbar.d.ts +3 -2
- package/dist/ui-sdk/components/snackbar/Snackbar.js +1 -1
- package/dist/ui-sdk/components/toolbar/desktop-toolbar/ToolbarPopper.d.ts +2 -0
- package/dist/ui-sdk/components/toolbar/desktop-toolbar/ToolbarPopper.js +1 -1
- package/dist/ui-sdk/components/view-controls/ViewControlsContext.d.ts +3 -1
- package/dist/ui-sdk/components/view-controls/ViewControlsItem.js +1 -1
- package/dist/ui-sdk/components/view-controls/ViewControlsRoot.d.ts +6 -1
- package/dist/ui-sdk/components/view-controls/ViewControlsRoot.js +1 -1
- package/dist/webhook/builders/auth-handler-builder.d.ts +21 -1
- package/dist/webhook/builders/auth-handler-builder.js +1 -1
- package/dist/webhook/builders/common.d.ts +9 -0
- package/dist/webhook/builders/webhook-builder.d.ts +18 -0
- package/dist/webhook/builders/webhook-builder.js +1 -1
- package/package.json +5 -4
- package/schema/domain-spec.json +224 -65
- package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/assistant.js +0 -43
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/assistant-setup.js +0 -32
- package/dist/application-spec/generate-application/code/templates/skills/processes/beta.d.ts +0 -14
- package/dist/application-spec/generate-application/code/templates/skills/processes/beta.js +0 -4
- package/dist/domain/extensions/view-controls.d.ts +0 -25
- package/dist/domain/extensions/view-controls.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{spawn as e}from"node:child_process";import{createHash as r,randomBytes as t}from"node:crypto";import{createServer as o}from"node:http";import{hostname as n}from"node:os";import{z as s}from"zod";import{
|
|
1
|
+
import{spawn as e}from"node:child_process";import{createHash as r,randomBytes as t}from"node:crypto";import{createServer as o}from"node:http";import{hostname as n}from"node:os";import{z as s}from"zod";import{createCliApiClient as i}from"#package/client";import{getServerCredentials as a,saveServerCredentials as l}from"../services/index.js";let c=s.string().uuid(),d={"&":"&","<":"<",">":">",'"':""","'":"'"},u=(e,r)=>`<!doctype html><html><head><meta charset="utf-8"><title>${e}</title></head><body style="font-family:system-ui,sans-serif;display:grid;place-items:center;height:100vh;margin:0"><main style="text-align:center"><h1>${e}</h1><p>${r.replace(/[&<>"']/g,e=>d[e]??e)}</p></main></body></html>`,h=(e,r,t,o)=>new Promise(n=>{e.destroyed?n():(e.once("close",n),e.writeHead(r,{...t,connection:"close"}).end(o))});export const startLoginCallbackListener=async e=>{let{state:r,studioUrl:t,customer:n}=e,s=(e,r)=>{let o=new URL(e,t);return n&&o.searchParams.set("customer",n),r&&o.searchParams.set("name",r),o.toString()},i=null,a=!1,l=new Promise((e,r)=>{i={resolve:e,reject:r}}),c=o((e,t)=>{let o=new URL(e.url??"/","http://127.0.0.1"),n=o.searchParams.get("code"),l="access_denied"===o.searchParams.get("error");if("/callback"!==o.pathname)return void t.writeHead(404).end();if(o.searchParams.get("state")!==r||a||!n&&!l){h(t,400,{"content-type":"text/html"},u("Sign-in failed","This response does not belong to the waiting CLI. Run phoenix login again.")),a||i?.reject(Error("The sign-in response did not match this CLI session. Run `phoenix login` again."));return}if(a=!0,l||!n)return void h(t,302,{location:s("/builder/cli-login/denied",null)}).then(()=>{i?.reject(Error("The sign-in was denied in Studio. Run `phoenix login` again to sign in."))});let c=o.searchParams.get("name");i?.resolve({code:n,tokenName:c,finish:e=>e.signedIn?h(t,302,{location:s("/builder/cli-login/done",c)}):h(t,200,{"content-type":"text/html"},u("Sign-in failed",e.message))})}),d=await new Promise((e,r)=>{c.once("error",r),c.listen(0,"127.0.0.1",()=>{let t=c.address();null===t||"string"==typeof t?r(Error("The login callback listener did not get a port. Run `phoenix login` again.")):e(t.port)})}),g=setTimeout(()=>{i?.reject(Error("Nobody approved the sign-in within 5 minutes. Run `phoenix login` again."))},3e5);return{port:d,callback:l,close:()=>{clearTimeout(g),c.close()}}};let g=async(e,r)=>{try{let{error:t,response:o}=await i(e).DELETE("/auth/token",{headers:{authorization:`Bearer ${r}`,"content-type":null}});return t&&401!==o.status?t.message:null}catch(e){return e instanceof Error?e.message:String(e)}},m=async(e,r)=>{let{data:t,error:o}=await i(e.serverUrl).POST("/auth/token",{body:r});if(o||!t)throw Error(`The server did not accept the sign-in: ${o?.message??"no response"}`);let n=t.customer?.slug??void 0;if(n!==e.customer){var s;throw await g(e.serverUrl,t.token),Error((s=e.customer,void 0===s?`The sign-in was approved for workspace "${n}" only, but \`phoenix login\` signs in to your whole Phoenix account. Check --region or --studioUrl and run \`phoenix login\` again.`:void 0===n?`The sign-in was approved for your whole Phoenix account, not for workspace "${s}". Check --region or --studioUrl and run \`phoenix login ${s}\` again.`:`The sign-in was approved in workspace "${n}", not "${s}". Check --region or --studioUrl and run \`phoenix login ${s}\` again.`))}let d=await a(e.serverUrl),u=c.safeParse(t.customer?.id),h=await l(e.serverUrl,{token:t.token,userId:t.userId,...u.success?{customerId:u.data}:{},...t.customer?{customerSlug:t.customer.slug,customerName:t.customer.name}:{},studioUrl:e.studioUrl,createdAt:new Date().toISOString()}),m=d?await g(e.serverUrl,d.token):null;return{customerName:t.customer?.name??"your Phoenix account",path:h,revokeError:m,replaced:d,telemetryAssociation:u.success?{userId:t.userId,workspaceId:u.data}:null===t.customer?{userId:t.userId,workspaceId:null}:void 0}};export const runLoginCommand=async(o,{logger:s})=>{let{data:a,error:l}=await i(o.serverUrl).GET("/auth/config");if(l||!a?.studioOrigin||!((e,{studioUrl:r,customer:t})=>{let o=new URL(e),n=new URL(r);return t?o.protocol===n.protocol&&o.port===n.port&&(n.hostname===o.hostname||n.hostname.endsWith(`.${o.hostname}`)):o.origin===n.origin})(a.studioOrigin,o))throw Error(`The server ${o.serverUrl} and the Studio ${o.studioUrl} do not share a sign-in region, so a sign-in approved there would not work here. Check --region, --serverUrl and --studioUrl, then run phoenix login again.`);let c=t(32).toString("base64url"),d=r("sha256").update(c).digest("base64url"),u=t(16).toString("base64url"),h=n(),g=`phoenix CLI on ${h}`,p=await startLoginCallbackListener({state:u,studioUrl:o.studioUrl,customer:o.customer});try{let r=new URL("/builder/cli-login",o.studioUrl);o.customer&&r.searchParams.set("customer",o.customer),r.searchParams.set("port",String(p.port)),r.searchParams.set("state",u),r.searchParams.set("challenge",d),r.searchParams.set("name",g),r.searchParams.set("host",h),r.searchParams.set("started",String(Date.now())),s.step(`Signing in to ${o.customer?`workspace "${o.customer}"`:"your Phoenix account"} on ${o.serverUrl}`),s.info(`Approve the CLI in your browser:
|
|
2
2
|
|
|
3
3
|
${r.toString()}
|
|
4
|
-
`),o.open&&(r=>{let[t,o]="darwin"===process.platform?["open",[r]]:"win32"===process.platform?["rundll32",["url.dll,FileProtocolHandler",r]]:["xdg-open",[r]];e(t,o,{stdio:"ignore",detached:!0}).on("error",()=>void 0).unref()})(r.toString());let t=await
|
|
4
|
+
`),o.open&&(r=>{let[t,o]="darwin"===process.platform?["open",[r]]:"win32"===process.platform?["rundll32",["url.dll,FileProtocolHandler",r]]:["xdg-open",[r]];e(t,o,{stdio:"ignore",detached:!0}).on("error",()=>void 0).unref()})(r.toString());let t=await p.callback;try{let e=await m(o,{code:t.code,codeVerifier:c,port:p.port,name:g});if(e.revokeError){let r=new URL("/builder/tokens",e.replaced?.studioUrl??o.studioUrl);e.replaced?.customerSlug&&r.searchParams.set("customer",e.replaced.customerSlug),s.warn(`The server did not revoke the token this sign-in replaces (${e.revokeError}). It stays valid on the server. Revoke it on the Tokens page of Studio: ${r.toString()}`)}return await t.finish({signedIn:!0}),s.success(`Signed in to ${e.customerName}. The token is stored in ${e.path}; revoke it with phoenix logout.`),e.telemetryAssociation}catch(e){throw await t.finish({signedIn:!1,message:e instanceof Error?e.message:String(e)}),e}}finally{p.close()}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createCliApiClient as e}from"#package/client";import{describeSavedLogins as t,getServerCredentials as r,removeServerCredentials as o}from"../services/index.js";let n=async(t,r)=>{try{let{error:o,response:n}=await e(t).DELETE("/auth/token",{headers:{authorization:`Bearer ${r}`,"content-type":null}});return o&&401!==n.status?o.message:null}catch(e){return e instanceof Error?e.message:String(e)}};export const runLogoutCommand=async(e,{logger:s})=>{let a=await r(e.serverUrl);if(!a){let r=await t();s.info(`Not signed in to ${e.serverUrl}.${r?` ${r}`:""}`);return}void 0!==process.env.PHOENIX_API_TOKEN&&s.info(`phoenix logout ignores PHOENIX_API_TOKEN: it signs out the saved login on ${e.serverUrl} and leaves that token valid.`);let i=await n(e.serverUrl,a.token);if(await o(e.serverUrl),i){let e=a.studioUrl?new URL("/builder/tokens",a.studioUrl):null;e&&a.customerSlug&&e.searchParams.set("customer",a.customerSlug),s.warn(`Signed out locally, but the server did not revoke the token (${i}). It is removed from this computer but stays valid on the server. Revoke it on the Tokens page of Studio${e?`: ${e.toString()}`:"."}`);return}s.success(`Signed out of ${a.customerName??"your Phoenix account"} on ${e.serverUrl}.`)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{writeFile as e}from"fs/promises";import{
|
|
2
|
-
${e}`),l.info(`Assistant prompt of this deployment (generated prompt, schema and instructions): ${r} characters`)}l.info("Preparing deployment on server...");let{data:w,error:
|
|
1
|
+
import{writeFile as e}from"fs/promises";import{createCliApiClient as a}from"#package/client";import{resolveApplicationSpecDeploymentData as t}from"../application-spec/index.js";import{exitCli as r}from"../services/index.js";import{formatEnvContent as i,formatEnvLine as s}from"../utils/index.js";export const runPrepareDeploymentCommand=async(o,n)=>{let{logger:l}=n;try{l.step("Preparing deployment");let{apiKey:r,projectKey:n,projectSlug:p,projectRef:c,projectSha:d,environmentSlug:m,outFile:h,skipUpload:u,overrideSchema:f,uploadLinksFile:g,serverUrl:v}=o;l.info(`Preparing deployment for project "${p}", environment "${m}"`);let b=a(v);l.debug(`Using server URL: ${v}`);let y=await t({skipUpload:u,logger:l});if(y.assistantSetup){let{sdl:e,prompt:a,instructions:t}=y.assistantSetup,r=a.length+e.length+(t?.length??0);l.info(`Assistant GraphQL schema:
|
|
2
|
+
${e}`),l.info(`Assistant prompt of this deployment (generated prompt, schema and instructions): ${r} characters`)}l.info("Preparing deployment on server...");let{data:w,error:F}=await b.POST("/environments/prepare",{body:{projectSlug:p,environmentSlug:m,applicationVersion:y.applicationVersion,projectRef:c,projectSha:d,publishedDataHash:y.publishedDataHash,useAuthHook:y.useAuthHook,useCognito:y.useCognito,accessMode:y.accessMode,sessionFields:y.sessionFields,overrideSchema:f,configurationSchema:{version:y.schemaVersion,schema:y.schema},adminConfigurationSchema:y.adminSchema?{schema:y.adminSchema,version:y.adminSchemaVersion}:void 0,chat:y.chat,embeddings:y.embeddings,...y.assistant?{assistant:!0}:{},acl:{canCreate:y.aclCanCreate},privateFiles:[...y.assets.privateFilePaths],publicFiles:[...y.assets.publicFilePaths]},headers:{"x-api-key":r,"x-project-key":n,"x-project-slug":p}});if(F)throw Error(`Failed to prepare deployment with server: ${F.message}`);if(!w)throw Error("No data returned from server");for(let e of w.warnings??[])l.warn(e);l.debug("Deployment prepared on server");let{baseDomain:S,isCustomDomain:P}=w,U=w.environmentVariables,k=w.privateUploadUrls,$=w.publicUploadUrls;if(!U||!k||!$)throw Error("Incomplete data returned from server");try{let a=[i(U),s("BASE_DOMAIN",String(S)),s("IS_CUSTOM_DOMAIN",String(P))].join("\n");await e(h,a+"\n"),l.debug(`Environment variables written to ${h}`)}catch(e){throw Error("Failed to write environment variables to file")}try{if(u)await e(g,JSON.stringify({privateFiles:[],publicFiles:[]},null,2)),l.debug("Upload links file cleared (upload was skipped)");else{let a={privateFiles:[...y.assets.privateFilesFullPaths].map(e=>({localPath:e,uploadUrl:k[e.replace(/^assets\/private\//,"")]})),publicFiles:[...y.assets.publicFilesFullPaths].map(e=>({localPath:e,uploadUrl:$[e.replace(/^assets\/public\//,"")]}))};await e(g,JSON.stringify(a,null,2)),l.debug(`Upload links written to ${g}`),l.info('Run "finish" command to upload files and activate the deployment')}}catch(e){throw Error("Failed to write upload links to file")}l.success("Deployment prepared successfully!")}catch(e){l.error(`Deployment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),await r(1)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFile as e}from"fs/promises";import{
|
|
1
|
+
import{writeFile as e}from"fs/promises";import{createCliApiClient as r}from"#package/client";import{resolveApplicationSpecDeploymentData as i}from"../application-spec/index.js";import{formatEnvContent as t,uploadFilesWithPresignedUrls as a}from"../utils/index.js";export const prepareLocalEnvironment=async(o,s)=>{let{logger:n}=s;n.step("Preparing local environment");let{projectKey:l,projectSlug:p,outFile:c,skipUpload:d,overrideSchema:m,serverUrl:h,lambdaUrl:f,environmentSlug:v,apiKey:u}=o;n.info(`Preparing local environment for project "${p}", environment "${v}"`);let g=r(h);n.debug(`Using server URL: ${h}`);let y=await i({skipUpload:d,logger:n});n.info("Preparing a local environment and deployment on the server...");let{data:b,error:w}=await g.POST("/environments/prepare",{body:{projectSlug:p,environmentSlug:v,applicationVersion:y.applicationVersion,publishedDataHash:y.publishedDataHash,useAuthHook:y.useAuthHook,useCognito:y.useCognito,accessMode:y.accessMode,sessionFields:y.sessionFields,overrideSchema:m,configurationSchema:{version:y.schemaVersion,schema:y.schema},adminConfigurationSchema:y.adminSchema?{schema:y.adminSchema,version:y.adminSchemaVersion}:void 0,chat:y.chat,embeddings:y.embeddings,...y.assistant?{assistant:!0}:{},acl:{canCreate:y.aclCanCreate},privateFiles:[...y.assets.privateFilePaths],publicFiles:[...y.assets.publicFilePaths]},headers:{"x-api-key":u,"x-project-key":l,"x-project-slug":p}});if(w)throw Error(`Failed to prepare deployment with server: ${w.message}`);if(!b)throw Error("No data returned from server");for(let e of b.warnings??[])n.warn(e);n.debug("Deployment prepared on server");let F=b.environmentVariables,E=b.privateUploadUrls,P=b.publicUploadUrls,$=F?.DEPLOYMENT_ID;if(!F||!E||!P)throw Error("Incomplete data returned from server");if(!$)throw Error("No deployment ID returned from server");try{await e(c,t(F)+"\n"),n.debug(`Environment variables written to ${c}`)}catch(e){throw Error(`Failed to write environment variables to file at ${c}, please verify you have write permissions to this location.`)}if(d)n.debug("Skipping file upload");else{n.info("Uploading files to S3...");let e={privateFiles:[...y.assets.privateFilesFullPaths].map(e=>{let r=e.replace("assets/private/",""),i=E[r];if(!i)throw Error(`No upload URL provided for private file ${r}, the server did not return a presigned URL for this file, please verify the file exists in the assets/private directory.`);return{localPath:e,uploadUrl:i}}),publicFiles:[...y.assets.publicFilesFullPaths].map(e=>{let r=e.replace("assets/public/",""),i=P[r];if(!i)throw Error(`No upload URL provided for public file ${r}, the server did not return a presigned URL for this file, please verify the file exists in the assets/public directory.`);return{localPath:e,uploadUrl:i}})};await a(e,{logger:n})}n.info("Activating deployment...");let{error:U}=await g.POST("/deployments/{deploymentId}/activate",{params:{path:{deploymentId:$}},headers:{"x-project-key":l,"x-project-slug":p,"x-api-key":u},body:{lambdaUrl:f}});if(U)throw Error(`Failed to activate deployment with server: ${U.message}`);n.info(`Project: ${p}`),n.info(`Environment: ${v}`),n.info(`Deployment ID: ${$}`),n.info(`Lambda URL: ${f}`),n.success("Local environment prepared successfully!")};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
|
-
* What `phoenix login` stores for one Phoenix server: the SDK builder's API token and the workspace it
|
|
3
|
+
* What `phoenix login` stores for one Phoenix server: the SDK builder's API token, and the workspace it is bound to
|
|
4
|
+
* when the sign-in named one.
|
|
4
5
|
*/
|
|
5
6
|
declare const ServerCredentials: z.ZodObject<{
|
|
6
7
|
token: z.ZodString;
|
|
@@ -32,15 +33,25 @@ export type ServerCredentials = z.infer<typeof ServerCredentials>;
|
|
|
32
33
|
* Where the CLI keeps credentials: `~/.phoenix/credentials.json`, or the file in `PHOENIX_CREDENTIALS_FILE`.
|
|
33
34
|
*/
|
|
34
35
|
export declare const getCredentialsPath: () => string;
|
|
36
|
+
/** Server of the current saved login: the most recent `phoenix login` that was not signed out since. */
|
|
37
|
+
export declare const getCurrentServerUrl: () => Promise<string | null>;
|
|
38
|
+
/** Servers that hold a saved login, for a message that tells the user where they are signed in. */
|
|
39
|
+
export declare const listSavedServerUrls: () => Promise<readonly string[]>;
|
|
35
40
|
export declare const getServerCredentials: (serverUrl: string) => Promise<ServerCredentials | null>;
|
|
36
41
|
/** Credentials used by deploy and whoami; CI tokens never enter the login file. */
|
|
37
|
-
interface CliApiCredentials {
|
|
42
|
+
export interface CliApiCredentials {
|
|
38
43
|
readonly token: string;
|
|
44
|
+
/** Whether `PHOENIX_API_TOKEN` supplied the token, so signing in again cannot replace it. */
|
|
45
|
+
readonly fromEnvironment: boolean;
|
|
39
46
|
readonly customerSlug?: string;
|
|
40
47
|
readonly customerName?: string;
|
|
41
48
|
readonly studioUrl?: string;
|
|
42
49
|
}
|
|
43
50
|
export declare const getCliApiCredentials: (serverUrl: string) => Promise<CliApiCredentials | null>;
|
|
51
|
+
/** Where the credential of deploy or whoami comes from, so the user sees which identity a command acts as. */
|
|
52
|
+
export declare const describeCliApiCredentialSource: (credentials: CliApiCredentials) => string;
|
|
53
|
+
/** What to do when the server refuses the credential of deploy or whoami. */
|
|
54
|
+
export declare const getCliApiCredentialsHint: (credentials: CliApiCredentials) => string;
|
|
44
55
|
export declare const saveServerCredentials: (serverUrl: string, entry: ServerCredentials) => Promise<string>;
|
|
45
56
|
export declare const removeServerCredentials: (serverUrl: string) => Promise<void>;
|
|
46
57
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{chmod as e,mkdir as r,readFile as t,writeFile as
|
|
2
|
-
`,{mode:384}),await e(
|
|
1
|
+
import{chmod as e,mkdir as r,readFile as t,writeFile as n}from"node:fs/promises";import{homedir as o}from"node:os";import{dirname as i,join as s}from"node:path";import{z as a}from"zod";let l=a.object({token:a.string().min(1),userId:a.string(),customerId:a.string().uuid().optional(),customerSlug:a.string().optional(),customerName:a.string().optional(),studioUrl:a.string().optional(),createdAt:a.string()}),c=a.object({version:a.literal(1),servers:a.record(a.string(),l),current:a.string().optional()}),d={version:1,servers:{}};export const getCredentialsPath=()=>process.env.PHOENIX_CREDENTIALS_FILE??s(o(),".phoenix","credentials.json");let u=e=>new URL(e).origin,v=async()=>{let e;try{e=await t(getCredentialsPath(),"utf8")}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return d;throw e}let r=c.safeParse((e=>{try{return JSON.parse(e)}catch{return null}})(e));if(!r.success)throw Error(`The credentials file ${getCredentialsPath()} is not valid. Delete it and run \`phoenix login\` again.`);return r.data},p=async t=>{let o=getCredentialsPath();return await r(i(o),{recursive:!0,mode:448}),await n(o,`${JSON.stringify(t,null,2)}
|
|
2
|
+
`,{mode:384}),await e(o,384),o},g=e=>{if(void 0!==e.current&&e.servers[e.current])return e.current;let[r]=Object.entries(e.servers).sort(([,e],[,r])=>r.createdAt.localeCompare(e.createdAt));return r?.[0]??null};export const getCurrentServerUrl=async()=>g(await v());export const listSavedServerUrls=async()=>Object.keys((await v()).servers);export const getServerCredentials=async e=>(await v()).servers[u(e)]??null;export const getCliApiCredentials=async e=>{let r=process.env.PHOENIX_API_TOKEN;if(void 0===r){let r=await getServerCredentials(e);return r?{...r,fromEnvironment:!1}:null}if(!/^phx[a]?_[A-Za-z0-9_-]{43}$/.test(r))throw Error("PHOENIX_API_TOKEN is not a valid Phoenix token. Replace the process variable or unset it to use your saved login.");return{token:r,fromEnvironment:!0}};export const describeCliApiCredentialSource=e=>e.fromEnvironment?"PHOENIX_API_TOKEN":`saved login in ${getCredentialsPath()}`;export const getCliApiCredentialsHint=e=>e.fromEnvironment?"The token comes from PHOENIX_API_TOKEN, so signing in again does not replace it. Set the variable to a valid token, or unset it to use your saved login.":"Run `phoenix login` again.";export const saveServerCredentials=async(e,r)=>{let t=await v(),n=u(e);return p({...t,servers:{...t.servers,[n]:r},current:n})};export const removeServerCredentials=async e=>{let r=await v(),{[u(e)]:t,...n}=r.servers,{current:o,...i}=r,s=g({...r,servers:n});await p({...i,servers:n,...null===s?{}:{current:s}})};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Says where the user is signed in when the server a command resolved holds no login, and how to select one of
|
|
3
|
+
* those servers. Null when there is no saved login at all, so the caller advises to sign in instead.
|
|
4
|
+
*/
|
|
5
|
+
export declare const describeSavedLogins: () => Promise<string | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{listSavedServerUrls as e}from"../cli-credentials.js";import{PUBLIC_PHOENIX_REGIONS as n,getRegionServerUrl as i}from"../phoenix-regions.js";export const describeSavedLogins=async()=>{let r=await e();if(0===r.length)return null;let o=r.map(e=>{let r;return`${e} (${(r=n.find(n=>new URL(i(n)).origin===e))?`--region ${r}`:`--serverUrl ${e}`})`}).join(", ");return`You have a saved login on ${o}: pass its flag to use it, or run \`phoenix login\` to sign in here.`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{describeSavedLogins}from"./describe-saved-logins.js";export{resolveCliServerUrl,warnOfInternalServer}from"./resolve-cli-server-url.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type PhoenixRegion } from '../phoenix-regions.js';
|
|
2
|
+
interface ResolveCliServerUrlProps {
|
|
3
|
+
/** Server named with `--serverUrl`. */
|
|
4
|
+
readonly serverUrl: string | undefined;
|
|
5
|
+
/** Region named with `--region`. */
|
|
6
|
+
readonly region: PhoenixRegion | undefined;
|
|
7
|
+
/** What the process environment and the project's `.env` say about the server. */
|
|
8
|
+
readonly env: {
|
|
9
|
+
readonly SERVER_URL: string | undefined;
|
|
10
|
+
readonly PHOENIX_REGION: PhoenixRegion | undefined;
|
|
11
|
+
};
|
|
12
|
+
/** Warns when the server is an internal installation, so nobody works on develop or staging unawares. */
|
|
13
|
+
readonly logger: {
|
|
14
|
+
readonly warn: (message: string) => void;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Warns when a server is an internal installation (develop or staging), so nobody works there unawares. */
|
|
18
|
+
export declare const warnOfInternalServer: (serverUrl: string, logger: ResolveCliServerUrlProps['logger']) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Decides which Phoenix server a sign-in command talks to, by one rule for `login`, `dev`, `deploy`, `whoami`,
|
|
21
|
+
* `logout` and `feedback`, so they cannot point at different servers unnoticed: a flag wins, then the environment,
|
|
22
|
+
* then the server of the current saved login, then the default region.
|
|
23
|
+
*/
|
|
24
|
+
export declare const resolveCliServerUrl: ({ logger, ...props }: ResolveCliServerUrlProps) => Promise<string>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getCurrentServerUrl as r}from"../cli-credentials.js";import{DEFAULT_PHOENIX_REGION as e,getInternalRegionOfServer as n,getRegionServerUrl as t}from"../phoenix-regions.js";export const warnOfInternalServer=(r,e)=>{let t=n(r);void 0!==t&&e.warn(`Using the internal ${t} installation (${r}), not production.`)};let o=async({serverUrl:n,region:o,env:i})=>n?.length?n:void 0!==o?t(o):i.SERVER_URL?.length?i.SERVER_URL:void 0!==i.PHOENIX_REGION?t(i.PHOENIX_REGION):await r()??t(e);export const resolveCliServerUrl=async({logger:r,...e})=>{let n=await o(e);return warnOfInternalServer(n,r),n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const getDevelopmentCredentialHint=(e,n)=>"developmentKey"in e?`Create a development environment for project "${n}" in Studio and paste its .env block into .env.`:"Run `phoenix login
|
|
1
|
+
export const getDevelopmentCredentialHint=(e,n)=>"developmentKey"in e?`Create a development environment for project "${n}" in Studio and paste its .env block into .env.`:"Run `phoenix login` again if the sign-in was revoked, then restart phoenix dev.";export const getDevelopmentHeaders=(e,n)=>({..."developmentKey"in e?{"x-development-key":e.developmentKey}:{authorization:`Bearer ${e.apiToken}`},"x-project-slug":n.projectSlug,"x-environment-slug":n.environmentSlug});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
interface FrontendBuildConfig {
|
|
2
2
|
readonly jsonSchemaValidator: 'ajv' | 'csp-compatible';
|
|
3
3
|
readonly gltfDecoder: 'js' | 'wasm';
|
|
4
|
+
readonly gltfDecoderWorkerLimit: number;
|
|
5
|
+
readonly exportPixelRatio: number | undefined;
|
|
4
6
|
}
|
|
5
7
|
export interface FrontendConfigModule {
|
|
6
8
|
readonly readRuntimeConfig: () => Record<string, unknown>;
|
|
@@ -19,10 +19,12 @@ export { compileWithSwc, watchWithSwc } from './swc.js';
|
|
|
19
19
|
export { STORY_DEV_MARKER_PATH, readActiveStoryDevMarker, type StoryDevMarker } from './story-dev-marker.js';
|
|
20
20
|
export { composeDefaultBanner } from './phx-banner-plugin.js';
|
|
21
21
|
export { getViteBuildConfigs, getViteDevConfig, setViteLogSink, type ViteLogSink, type ViteLogSinkOptions, } from './vite-config.js';
|
|
22
|
-
export { getCliApiCredentials, getServerCredentials, removeServerCredentials, saveServerCredentials, } from './cli-credentials.js';
|
|
22
|
+
export { describeCliApiCredentialSource, getCliApiCredentials, getCliApiCredentialsHint, getServerCredentials, removeServerCredentials, saveServerCredentials, } from './cli-credentials.js';
|
|
23
23
|
export { exitCli, setBeforeCliExit } from './cli-exit.js';
|
|
24
24
|
export { createSourceArchive, extractSourceArchive } from './source-archive.js';
|
|
25
25
|
export { resolveSignedInDevelopmentEnvironment } from './signed-in-development-environment.js';
|
|
26
|
+
export { describeWorkspaceProjects, resolveDeployTarget, resolveTargetProject } from './spec-project/index.js';
|
|
26
27
|
export { createTelemetryClient, resolveTelemetryCommand, type CommandTelemetryAttempt, type TelemetryAssociation, type TelemetryClient, type TelemetryCommand, } from './telemetry/index.js';
|
|
27
|
-
export { DEFAULT_PHOENIX_REGION, PHOENIX_REGIONS, PUBLIC_PHOENIX_REGIONS, getRegionServerUrl, getRegionStudioUrl, } from './phoenix-regions.js';
|
|
28
|
+
export { DEFAULT_PHOENIX_REGION, PHOENIX_REGIONS, PUBLIC_PHOENIX_REGIONS, getRegionServerUrl, getRegionStudioUrl, getServerStudioUrl, parsePhoenixRegion, } from './phoenix-regions.js';
|
|
29
|
+
export { describeSavedLogins, resolveCliServerUrl, warnOfInternalServer } from './cli-server/index.js';
|
|
28
30
|
export { type CredentialRoute, type DevExperience, readExplicitEditorSetting, resolveDevExperience, resolveRegeneratedPageExperience, } from './dev-experience/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{PhoenixPubSub}from"./phoenix-pubsub.js";export{PhoenixStore}from"./phoenix-store.js";export{DeploymentPreparationService,readGeneratedEnvMarkers}from"./deployment/index.js";export{PhoenixApplication}from"./session/index.js";export{VariantFileSession}from"./variant-file-session.js";export{VariantPreviewService}from"./variant-preview-service.js";export{MockTemplateWatcher}from"./mock-template-watcher.js";export{ApplicationSpecProjectWatcher}from"./application-spec-project-watcher.js";export{ApplicationSpecStoryWatcher}from"./application-spec-story-watcher.js";export{LinguiWatcher}from"./lingui-watcher.js";export{bootstrapLinguiCatalogs,extractAndCompileLingui}from"../lingui/index.js";export{loadMockTemplates,parseMockTemplateYaml}from"./spec-files.js";export{LOG_STREAMS,LogBus}from"./log-bus.js";export{createBusLogger}from"./bus-logger.js";export{patchConsole}from"./console-capture.js";export{WebhookTunnelMonitor}from"./webhook-tunnel-monitor.js";export{compileWithSwc,watchWithSwc}from"./swc.js";export{STORY_DEV_MARKER_PATH,readActiveStoryDevMarker}from"./story-dev-marker.js";export{composeDefaultBanner}from"./phx-banner-plugin.js";export{getViteBuildConfigs,getViteDevConfig,setViteLogSink}from"./vite-config.js";export{getCliApiCredentials,getServerCredentials,removeServerCredentials,saveServerCredentials}from"./cli-credentials.js";export{exitCli,setBeforeCliExit}from"./cli-exit.js";export{createSourceArchive,extractSourceArchive}from"./source-archive.js";export{resolveSignedInDevelopmentEnvironment}from"./signed-in-development-environment.js";export{createTelemetryClient,resolveTelemetryCommand}from"./telemetry/index.js";export{DEFAULT_PHOENIX_REGION,PHOENIX_REGIONS,PUBLIC_PHOENIX_REGIONS,getRegionServerUrl,getRegionStudioUrl}from"./phoenix-regions.js";export{readExplicitEditorSetting,resolveDevExperience,resolveRegeneratedPageExperience}from"./dev-experience/index.js";
|
|
1
|
+
export{PhoenixPubSub}from"./phoenix-pubsub.js";export{PhoenixStore}from"./phoenix-store.js";export{DeploymentPreparationService,readGeneratedEnvMarkers}from"./deployment/index.js";export{PhoenixApplication}from"./session/index.js";export{VariantFileSession}from"./variant-file-session.js";export{VariantPreviewService}from"./variant-preview-service.js";export{MockTemplateWatcher}from"./mock-template-watcher.js";export{ApplicationSpecProjectWatcher}from"./application-spec-project-watcher.js";export{ApplicationSpecStoryWatcher}from"./application-spec-story-watcher.js";export{LinguiWatcher}from"./lingui-watcher.js";export{bootstrapLinguiCatalogs,extractAndCompileLingui}from"../lingui/index.js";export{loadMockTemplates,parseMockTemplateYaml}from"./spec-files.js";export{LOG_STREAMS,LogBus}from"./log-bus.js";export{createBusLogger}from"./bus-logger.js";export{patchConsole}from"./console-capture.js";export{WebhookTunnelMonitor}from"./webhook-tunnel-monitor.js";export{compileWithSwc,watchWithSwc}from"./swc.js";export{STORY_DEV_MARKER_PATH,readActiveStoryDevMarker}from"./story-dev-marker.js";export{composeDefaultBanner}from"./phx-banner-plugin.js";export{getViteBuildConfigs,getViteDevConfig,setViteLogSink}from"./vite-config.js";export{describeCliApiCredentialSource,getCliApiCredentials,getCliApiCredentialsHint,getServerCredentials,removeServerCredentials,saveServerCredentials}from"./cli-credentials.js";export{exitCli,setBeforeCliExit}from"./cli-exit.js";export{createSourceArchive,extractSourceArchive}from"./source-archive.js";export{resolveSignedInDevelopmentEnvironment}from"./signed-in-development-environment.js";export{describeWorkspaceProjects,resolveDeployTarget,resolveTargetProject}from"./spec-project/index.js";export{createTelemetryClient,resolveTelemetryCommand}from"./telemetry/index.js";export{DEFAULT_PHOENIX_REGION,PHOENIX_REGIONS,PUBLIC_PHOENIX_REGIONS,getRegionServerUrl,getRegionStudioUrl,getServerStudioUrl,parsePhoenixRegion}from"./phoenix-regions.js";export{describeSavedLogins,resolveCliServerUrl,warnOfInternalServer}from"./cli-server/index.js";export{readExplicitEditorSetting,resolveDevExperience,resolveRegeneratedPageExperience}from"./dev-experience/index.js";
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The hosted Phoenix installations the CLI can sign in to. Each region has its own server and its own Studio domain
|
|
3
|
-
* on
|
|
2
|
+
* The hosted Phoenix installations the CLI can sign in to. Each region has its own server and its own Studio domain.
|
|
3
|
+
* Only on production and staging does every workspace also get a subdomain of that domain; develop has none, so the
|
|
4
|
+
* legacy `phoenix login <customer>` does not reach a develop Studio.
|
|
4
5
|
*/
|
|
5
|
-
export declare const PHOENIX_REGIONS: readonly ['eu', 'us', 'staging'];
|
|
6
|
+
export declare const PHOENIX_REGIONS: readonly ['eu', 'us', 'staging', 'develop'];
|
|
6
7
|
export type PhoenixRegion = (typeof PHOENIX_REGIONS)[number];
|
|
7
8
|
/**
|
|
8
|
-
* The regions offered to users as `--region`. Staging
|
|
9
|
-
*
|
|
9
|
+
* The regions offered to users as `--region`. Staging and develop are internal: `--region` and `PHOENIX_REGION`
|
|
10
|
+
* accept them, but help and the docs do not list them. Only the Studio of that installation shows them.
|
|
10
11
|
*/
|
|
11
12
|
export declare const PUBLIC_PHOENIX_REGIONS: readonly ["eu", "us"];
|
|
12
13
|
export declare const DEFAULT_PHOENIX_REGION: PhoenixRegion;
|
|
14
|
+
/** Reads a `--region` value. It accepts every region, and names only the public ones when it refuses a value. */
|
|
15
|
+
export declare const parsePhoenixRegion: (value: string) => PhoenixRegion;
|
|
16
|
+
/** The internal region a server belongs to (develop or staging), or undefined for a production or unknown server. */
|
|
17
|
+
export declare const getInternalRegionOfServer: (serverUrl: string) => PhoenixRegion | undefined;
|
|
13
18
|
export declare const getRegionServerUrl: (region: PhoenixRegion) => string;
|
|
14
19
|
/**
|
|
15
20
|
* Studio of one workspace in a region. The slug becomes a subdomain, so anything but a plain slug is refused: it
|
|
16
21
|
* could otherwise point the sign-in at another host.
|
|
17
22
|
*/
|
|
18
23
|
export declare const getRegionStudioUrl: (region: PhoenixRegion, workspace: string | undefined) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Studio that pairs with a server, for a sign-in that names the server and no Studio. Only the server of a region
|
|
26
|
+
* has a known Studio; for a local or self-hosted server the user names it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getServerStudioUrl: (serverUrl: string, workspace: string | undefined) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PHOENIX_REGIONS=["eu","us","staging"];export const PUBLIC_PHOENIX_REGIONS=["eu","us"];export const DEFAULT_PHOENIX_REGION="eu";let
|
|
1
|
+
export const PHOENIX_REGIONS=["eu","us","staging","develop"];export const PUBLIC_PHOENIX_REGIONS=["eu","us"];export const DEFAULT_PHOENIX_REGION="eu";let e={eu:{serverUrl:"https://production-eu-central-1.salsita.ai",studioDomain:"studio.eu.salsita.ai"},us:{serverUrl:"https://production-us-east-1.salsita.ai",studioDomain:"studio.salsita.ai"},staging:{serverUrl:"https://staging.salsita.app",studioDomain:"studio-staging.salsita.app"},develop:{serverUrl:"https://phoenix-develop.salsita.app",studioDomain:"studio-develop.salsita.app"}};export const parsePhoenixRegion=e=>{let t=PHOENIX_REGIONS.find(t=>t===e);if(void 0===t)throw Error(`"${e}" is not a Phoenix region. Use ${PUBLIC_PHOENIX_REGIONS.join(" or ")}.`);return t};export const getInternalRegionOfServer=t=>{let o=URL.canParse(t)?new URL(t).origin:void 0;return PHOENIX_REGIONS.find(t=>!PUBLIC_PHOENIX_REGIONS.includes(t)&&new URL(e[t].serverUrl).origin===o)};let t=/^[a-z0-9-]+$/;export const getRegionServerUrl=t=>e[t].serverUrl;export const getRegionStudioUrl=(o,r)=>{if(void 0===r)return`https://${e[o].studioDomain}`;if(!t.test(r))throw Error(`"${r}" is not a workspace slug. A slug has only lowercase letters, digits and dashes; use the one from your Studio address.`);return`https://${r}.${e[o].studioDomain}`};export const getServerStudioUrl=(t,o)=>{let r=PHOENIX_REGIONS.find(o=>new URL(e[o].serverUrl).origin===new URL(t).origin);if(void 0===r)throw Error(`The Studio of ${t} is not known, because it is not the server of a Phoenix region. Pass --studioUrl <url> with the address of the Studio that belongs to it.`);return getRegionStudioUrl(r,o)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{writeFile as e}from"node:fs/promises";import{
|
|
2
|
-
`),p.debug(`Environment variables written to ${
|
|
1
|
+
import{writeFile as e}from"node:fs/promises";import{createCliApiClient as i}from"#package/client";import{resolveApplicationSpecDeploymentData as t}from"../application-spec/index.js";import{formatEnvContent as r,uploadFilesWithPresignedUrls as s}from"../utils/index.js";import{getDevelopmentCredentialHint as o,getDevelopmentHeaders as a}from"./development-credential.js";export const prepareDevelopmentEnvironment=async(n,l)=>{let{logger:p}=l,{projectSlug:d,environmentSlug:m,serverUrl:c,credential:h,outFile:f,skipUpload:v,overrideSchema:u,projectVersion:g}=n;p.step("Preparing development environment"),p.info(`Preparing development environment for project "${d}", environment "${m}"`);let E=i(c);p.debug(`Using server URL: ${c}`);let P=await t({skipUpload:v,logger:p});p.info("Preparing and activating the development deployment on the server...");let{data:b,error:$}=await E.POST("/environments/development/prepare",{body:{applicationVersion:P.applicationVersion,publishedDataHash:P.publishedDataHash,useAuthHook:P.useAuthHook,useCognito:P.useCognito,accessMode:P.accessMode,sessionFields:P.sessionFields,overrideSchema:u,configurationSchema:{version:P.schemaVersion,schema:P.schema},adminConfigurationSchema:P.adminSchema?{schema:P.adminSchema,version:P.adminSchemaVersion}:void 0,chat:P.chat,embeddings:P.embeddings,...P.assistant?{assistant:!0}:{},acl:{canCreate:P.aclCanCreate},privateFiles:[...P.assets.privateFilePaths],publicFiles:[...P.assets.publicFilePaths],sdkVersion:g},headers:a(h,{projectSlug:d,environmentSlug:m})});if($)throw Error(`Failed to prepare development deployment for ${d}/${m} on ${c}: ${$.message}. ${o(h,d)}`);if(!b)throw Error("No data returned from server while preparing the development deployment.");for(let e of b.warnings??[])p.warn(e);let{environmentVariables:w,privateUploadUrls:F,publicUploadUrls:y}=b;if(v)p.debug("Skipping file upload");else{p.info("Uploading files to S3...");let e={privateFiles:[...P.assets.privateFilesFullPaths].map(e=>{let i=e.replace("assets/private/",""),t=F[i];if(!t)throw Error(`No upload URL provided for private file ${i}, the server did not return a presigned URL for this file, please verify the file exists in the assets/private directory.`);return{localPath:e,uploadUrl:t}}),publicFiles:[...P.assets.publicFilesFullPaths].map(e=>{let i=e.replace("assets/public/",""),t=y[i];if(!t)throw Error(`No upload URL provided for public file ${i}, the server did not return a presigned URL for this file, please verify the file exists in the assets/public directory.`);return{localPath:e,uploadUrl:t}})};await s(e,{logger:p})}try{await e(f,`${r({...w,PHOENIX_PROJECT_SLUG:d,PHOENIX_ENVIRONMENT_SLUG:m,PHOENIX_SERVER_URL:c,PHOENIX_DEPLOYMENT_FINGERPRINT:P.fingerprint})}
|
|
2
|
+
`),p.debug(`Environment variables written to ${f}`)}catch{throw Error(`Failed to write environment variables to file at ${f}, please verify you have write permissions to this location.`)}p.info(`Project: ${d}`),p.info(`Environment: ${m}`),p.info(`Deployment ID: ${w.DEPLOYMENT_ID}`),p.success("Development environment prepared successfully!")};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Subject as e}from"rxjs";import{createServer as t}from"vite";import{resolveGeneratedEnvFile as r}from"@salsita-ai/common/env";import{generateProjectFiles as o,getDeploymentFingerprint as s}from"../../application-spec/index.js";import{exists as i}from"../../utils/index.js";import{buildWebhooks as n,webhookLogContext as a}from"../../webhooks/index.js";import{ApplicationSpecProjectWatcher as l}from"../application-spec-project-watcher.js";import{ApplicationSpecStoryWatcher as c}from"../application-spec-story-watcher.js";import{DeploymentPreparationService as h,readGeneratedEnvMarkers as p}from"../deployment/index.js";import{getDevelopmentCredentialHint as u}from"../development-credential.js";import{LinguiWatcher as g}from"../lingui-watcher.js";import{LogBus as m}from"../log-bus.js";import{MockTemplateWatcher as d}from"../mock-template-watcher.js";import{PhoenixPubSub as v}from"../phoenix-pubsub.js";import{PhoenixStore as w}from"../phoenix-store.js";import{VariantPreviewService as b}from"../variant-preview-service.js";import{getViteDevConfig as S}from"../vite-config.js";import{createWebhookTunnelTransport as E,readOrCreateTunnelSessionId as x,startWebhookService as f}from"../webhook-service/index.js";import{WebhookTunnelMonitor as P}from"../webhook-tunnel-monitor.js";export class PhoenixApplication{props;context;store=new w;pubsub=new v;failures$=new e;logsValue;tunnelMonitorValue;deploymentPreparationValue;variantPreviewsValue;linguiWatcherValue;projectWatcher;storyWatcher;mockTemplateWatcher;editorServer;webhookTunnel;browserConsoleSubscription;startPromise;closePromise;constructor(e,t){this.props=e,this.context=t;let r="dev"===e.mode?e.development:void 0,o=r&&(!r.persistenceMode||"server"===r.persistenceMode);this.logsValue="dev"===e.mode?new m:void 0,this.tunnelMonitorValue=o&&r.serverUrl?new P(r.serverUrl):void 0,this.deploymentPreparationValue=o&&r.serverUrl&&r.credential?new h({serverUrl:r.serverUrl,credential:r.credential,projectSlug:r.projectSlug,environmentSlug:r.environmentSlug,sdkVersion:r.sdkVersion},{store:this.store,get logger(){return t.logger}}):void 0}get logs(){return this.logsValue}get tunnelMonitor(){return this.tunnelMonitorValue}get deploymentPreparation(){return this.deploymentPreparationValue}get projectRoot(){return this.props.projectRoot}get mode(){return this.props.mode}get variantPreviews(){return this.variantPreviewsValue}get linguiWatcher(){return this.linguiWatcherValue}start(){return this.startPromise??=this.startSession(),this.startPromise}close(){return this.closePromise??=this.closeResources(this.context.logger),this.closePromise}async startSession(){try{if(this.assertStarting(),"story"===this.mode)return void await this.startEditor();let e=this.logs;if(!e)throw Error("Cannot start development: the application has no log bus.");return this.browserConsoleSubscription=this.pubsub.browserConsole$.subscribe(t=>this.context.onBrowserConsole(t,e)),await this.startDevelopment()}catch(e){throw this.closePromise||this.context.onStartupFailure(e),await this.close(),e}}async startEditor(){let e=this.props.editorPort;void 0!==e&&("dev"===this.mode&&this.context.logger.step("Starting editor WebSocket server"),this.editorServer=this.context.createEditorServer({port:e,application:this,logger:this.context.logger,debug:this.props.development?.debug??!1}),await this.editorServer.ready,this.assertStarting(),"dev"===this.mode&&this.context.logger.debug(`Editor WebSocket server started on port ${e}`),this.mockTemplateWatcher=new d({projectRoot:this.projectRoot,pubsub:this.pubsub,logger:this.context.logger}),this.mockTemplateWatcher.start(),"story"===this.mode&&(this.storyWatcher=new c({projectRoot:this.projectRoot,pubsub:this.pubsub,logger:this.context.logger}),this.storyWatcher.start()))}async startDevelopment(){let e=this.props.development,c=this.logs;if(!e||!c)throw Error("Cannot start development: session options are missing. Supply development options when constructing the application.");let{sdkVersion:h,projectSlug:m,environmentSlug:d,cliUseWorkspace:v,devExperience:w,debug:P,withLingui:j,persistenceMode:y,force:k,serverUrl:V,credential:W,skipUpload:R}=e,{store:N,pubsub:T,deploymentPreparation:I,tunnelMonitor:_}=this;process.env.NODE_ENV="development",y&&(process.env.PERSISTENCE_MODE=y);let O=!y||"server"===y;if(O&&V&&(process.env.SERVER_URL=V),this.context.logger.step("Starting development mode"),!await i("spec"))throw Object.assign(Error('Spec folder not found. Run "phoenix init" first.'),{code:"SPEC_NOT_FOUND"});if(O&&(!V||!W))throw Error("Server persistence needs a server and a credential. Run `phoenix login
|
|
1
|
+
import{Subject as e}from"rxjs";import{createServer as t}from"vite";import{resolveGeneratedEnvFile as r}from"@salsita-ai/common/env";import{generateProjectFiles as o,getDeploymentFingerprint as s}from"../../application-spec/index.js";import{exists as i}from"../../utils/index.js";import{buildWebhooks as n,webhookLogContext as a}from"../../webhooks/index.js";import{ApplicationSpecProjectWatcher as l}from"../application-spec-project-watcher.js";import{ApplicationSpecStoryWatcher as c}from"../application-spec-story-watcher.js";import{DeploymentPreparationService as h,readGeneratedEnvMarkers as p}from"../deployment/index.js";import{getDevelopmentCredentialHint as u}from"../development-credential.js";import{LinguiWatcher as g}from"../lingui-watcher.js";import{LogBus as m}from"../log-bus.js";import{MockTemplateWatcher as d}from"../mock-template-watcher.js";import{PhoenixPubSub as v}from"../phoenix-pubsub.js";import{PhoenixStore as w}from"../phoenix-store.js";import{VariantPreviewService as b}from"../variant-preview-service.js";import{getViteDevConfig as S}from"../vite-config.js";import{createWebhookTunnelTransport as E,readOrCreateTunnelSessionId as x,startWebhookService as f}from"../webhook-service/index.js";import{WebhookTunnelMonitor as P}from"../webhook-tunnel-monitor.js";export class PhoenixApplication{props;context;store=new w;pubsub=new v;failures$=new e;logsValue;tunnelMonitorValue;deploymentPreparationValue;variantPreviewsValue;linguiWatcherValue;projectWatcher;storyWatcher;mockTemplateWatcher;editorServer;webhookTunnel;browserConsoleSubscription;startPromise;closePromise;constructor(e,t){this.props=e,this.context=t;let r="dev"===e.mode?e.development:void 0,o=r&&(!r.persistenceMode||"server"===r.persistenceMode);this.logsValue="dev"===e.mode?new m:void 0,this.tunnelMonitorValue=o&&r.serverUrl?new P(r.serverUrl):void 0,this.deploymentPreparationValue=o&&r.serverUrl&&r.credential?new h({serverUrl:r.serverUrl,credential:r.credential,projectSlug:r.projectSlug,environmentSlug:r.environmentSlug,sdkVersion:r.sdkVersion},{store:this.store,get logger(){return t.logger}}):void 0}get logs(){return this.logsValue}get tunnelMonitor(){return this.tunnelMonitorValue}get deploymentPreparation(){return this.deploymentPreparationValue}get projectRoot(){return this.props.projectRoot}get mode(){return this.props.mode}get variantPreviews(){return this.variantPreviewsValue}get linguiWatcher(){return this.linguiWatcherValue}start(){return this.startPromise??=this.startSession(),this.startPromise}close(){return this.closePromise??=this.closeResources(this.context.logger),this.closePromise}async startSession(){try{if(this.assertStarting(),"story"===this.mode)return void await this.startEditor();let e=this.logs;if(!e)throw Error("Cannot start development: the application has no log bus.");return this.browserConsoleSubscription=this.pubsub.browserConsole$.subscribe(t=>this.context.onBrowserConsole(t,e)),await this.startDevelopment()}catch(e){throw this.closePromise||this.context.onStartupFailure(e),await this.close(),e}}async startEditor(){let e=this.props.editorPort;void 0!==e&&("dev"===this.mode&&this.context.logger.step("Starting editor WebSocket server"),this.editorServer=this.context.createEditorServer({port:e,application:this,logger:this.context.logger,debug:this.props.development?.debug??!1}),await this.editorServer.ready,this.assertStarting(),"dev"===this.mode&&this.context.logger.debug(`Editor WebSocket server started on port ${e}`),this.mockTemplateWatcher=new d({projectRoot:this.projectRoot,pubsub:this.pubsub,logger:this.context.logger}),this.mockTemplateWatcher.start(),"story"===this.mode&&(this.storyWatcher=new c({projectRoot:this.projectRoot,pubsub:this.pubsub,logger:this.context.logger}),this.storyWatcher.start()))}async startDevelopment(){let e=this.props.development,c=this.logs;if(!e||!c)throw Error("Cannot start development: session options are missing. Supply development options when constructing the application.");let{sdkVersion:h,projectSlug:m,environmentSlug:d,cliUseWorkspace:v,devExperience:w,debug:P,withLingui:j,persistenceMode:y,force:k,serverUrl:V,credential:W,skipUpload:R}=e,{store:N,pubsub:T,deploymentPreparation:I,tunnelMonitor:_}=this;process.env.NODE_ENV="development",y&&(process.env.PERSISTENCE_MODE=y);let O=!y||"server"===y;if(O&&V&&(process.env.SERVER_URL=V),this.context.logger.step("Starting development mode"),!await i("spec"))throw Object.assign(Error('Spec folder not found. Run "phoenix init" first.'),{code:"SPEC_NOT_FOUND"});if(O&&(!V||!W))throw Error("Server persistence needs a server and a credential. Run `phoenix login`, or create a development environment in Studio and paste its .env block into .env.");this.context.logger.step("Building project files");let{templateFiles:D,applicationSpec:$}=await o({sdkVersion:h,projectSlug:m,environmentSlug:d,cliUseWorkspace:v,pageExperience:w,withLingui:j,force:k},{logger:this.context.logger});if(this.assertStarting(),this.context.logger.success("Project files built successfully"),O&&V&&W){let e=r("."),t=await p(e);k||t?.PHOENIX_PROJECT_SLUG!==m||t.PHOENIX_ENVIRONMENT_SLUG!==d||t.PHOENIX_SERVER_URL!==V||t.PHOENIX_DEPLOYMENT_FINGERPRINT!==s($)?(this.context.logger.step("Preparing development deployment"),await I?.prepareAtStartup({skipUpload:R,debug:P})):this.context.logger.debug(`${e} matches the current development environment, skipping prepare`)}if(this.assertStarting(),this.context.onProjectPrepared(c),j?(this.linguiWatcherValue=new g({logger:this.context.logger}),this.linguiWatcherValue.start()):this.context.logger.warn("Continuous Lingui updates are disabled; missing catalogs were bootstrapped at startup. Pass --withLingui or set WITH_LINGUI=true to enable."),O&&(this.context.logger.step("Building webhooks"),await a.run("webhook",async()=>{await n({experimental:!0,skipNodeEnvOverride:!0,webhookEntryPoint:"./.phoenix/.swc/.phoenix/webhook.js"})})),O&&V&&W){let e=r("."),t=await p(e);if(!t?.DEPLOYMENT_ID)throw Error(`Webhook tunnel cannot start because ${e} has no DEPLOYMENT_ID. Rerun phoenix dev to prepare the development deployment.`);this.assertStarting();let o=await x();this.assertStarting();let s=await f({experimental:!0,transport:E({serverUrl:V,credential:W,projectSlug:m,environmentSlug:d}),rejectionHint:u(W,m),environmentSlug:d,deploymentId:t.DEPLOYMENT_ID,sessionId:o,onStatus:(e,r)=>{_?.setStatus(e,{deploymentId:t.DEPLOYMENT_ID,sessionId:o,message:r??null})},onRequest:e=>_?.record(e)});this.closePromise&&(await s.stop(),this.assertStarting()),this.webhookTunnel=s,_?.setStatus("waiting",{deploymentId:t.DEPLOYMENT_ID,sessionId:o}),s.stopped.catch(e=>{this.failures$.next(Error(`Webhook tunnel failed: ${e instanceof Error?e.message:String(e)}`)),this.close()}),this.context.logger.success("Webhook tunnel started")}this.assertStarting();let M=new l({pubsub:T,logger:this.context.logger,sdkVersion:h,projectSlug:m,environmentSlug:d,cliUseWorkspace:v,pageExperience:w,inlineTemplates:!1,useServer:O},{store:N,linguiWatcher:this.linguiWatcherValue,deploymentPreparation:I});this.projectWatcher=M,this.variantPreviewsValue=new b({projectRoot:this.projectRoot},{store:N,logger:this.context.logger,projectWatcher:M}),"plain"!==w&&void 0!==this.props.editorPort&&await this.startEditor();let C=await S({templateFiles:D,agentMode:"agent"===w}),L=await t(C);return this.closePromise&&(await L.close(),this.assertStarting()),this.store.viteServer$.next(L),await L.listen(),this.assertStarting(),this.context.logger.step("Starting Vite dev server"),M.start(L),L}assertStarting(){if(this.closePromise)throw Error("Cannot continue startup: the session has already closed. Start a new Phoenix application.")}async closeResources(e){"dev"===this.mode&&e.debug("Shutting down...");let t="story"===this.mode?[{name:"story source watcher",close:()=>this.storyWatcher?.close()},{name:"mock-template watcher",close:()=>this.mockTemplateWatcher?.close()},{name:"editor server",close:()=>this.editorServer?.close()}]:[{name:"lingui watcher",close:()=>this.linguiWatcherValue?.close()},{name:"project watcher",close:()=>this.projectWatcher?.close()},{name:"mock template watcher",close:()=>this.mockTemplateWatcher?.close()},{name:"editor server",close:()=>this.editorServer?.close()},{name:"variant previews",close:()=>this.variantPreviewsValue?.dispose()},{name:"vite server",close:()=>this.store.viteServer$.value?.close()},{name:"webhook tunnel",close:()=>this.webhookTunnel?.stop()}],r=[];for(let o of t)try{"dev"===this.mode&&e.debug(`Shutting down ${o.name}`),await o.close()}catch(s){let t=s instanceof Error?s.message:String(s);"story"===this.mode?e.warn(`Failed to close the story-dev ${o.name}: ${t}. The process will continue shutting down.`):r.push(`${o.name}: ${t}`)}this.browserConsoleSubscription?.unsubscribe(),this.failures$.complete(),r.length>0&&e.warn(`Cleanup warnings:
|
|
2
2
|
${r.join("\n ")}`),"dev"===this.mode&&e.debug("Shutdown complete")}}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
import type { Logger } from '../utils/index.js';
|
|
1
2
|
interface SignedInDevelopmentEnvironmentProps {
|
|
2
3
|
readonly serverUrl: string;
|
|
3
|
-
readonly
|
|
4
|
+
readonly flagProject: string | undefined;
|
|
5
|
+
readonly specProject: string | undefined;
|
|
6
|
+
readonly specProjectSource: string;
|
|
7
|
+
readonly projectRoot: string;
|
|
8
|
+
readonly interactive: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface SignedInDevelopmentEnvironmentContext {
|
|
11
|
+
readonly logger: Logger;
|
|
12
|
+
readonly ask: (question: string) => Promise<string>;
|
|
4
13
|
}
|
|
5
14
|
/** The development environment `phoenix dev` works in when it authenticates with the stored login. */
|
|
6
15
|
interface SignedInDevelopmentEnvironment {
|
|
7
16
|
readonly apiToken: string;
|
|
8
|
-
|
|
17
|
+
/** Name of the workspace the sign-in is bound to. A personal sign-in has none. */
|
|
18
|
+
readonly workspaceName: string | undefined;
|
|
9
19
|
readonly projectSlug: string;
|
|
10
20
|
readonly environmentSlug: string;
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
13
23
|
* Asks the server for the signed-in user's development environment in a project. The server creates it on the first
|
|
14
|
-
* call, so nothing has to be set up in Studio.
|
|
24
|
+
* call, so nothing has to be set up in Studio. The project is the one --project or the spec names, or one of the
|
|
25
|
+
* projects the sign-in can reach.
|
|
15
26
|
*/
|
|
16
|
-
export declare const resolveSignedInDevelopmentEnvironment: (props: SignedInDevelopmentEnvironmentProps) => Promise<SignedInDevelopmentEnvironment>;
|
|
27
|
+
export declare const resolveSignedInDevelopmentEnvironment: (props: SignedInDevelopmentEnvironmentProps, context: SignedInDevelopmentEnvironmentContext) => Promise<SignedInDevelopmentEnvironment>;
|
|
17
28
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createCliApiClient as e}from"#package/client";import{getServerCredentials as o}from"./cli-credentials.js";import{describeSavedLogins as n}from"./cli-server/index.js";import{resolveTargetProject as r}from"./spec-project/index.js";export const resolveSignedInDevelopmentEnvironment=async(t,i)=>{let{serverUrl:a,projectRoot:c}=t,s=await o(a);if(!s)throw Error(`phoenix dev has no development key and you are not signed in to ${a}. ${await n()??"Run `phoenix login`."} Or paste the .env block of a Studio development environment into .env.`);void 0!==process.env.PHOENIX_API_TOKEN&&i.logger.info(`phoenix dev ignores PHOENIX_API_TOKEN: it develops with the saved login on ${a}${s.customerName?` for workspace ${s.customerName}`:""}.`);let p=await r({serverUrl:a,token:s.token,flagProject:t.flagProject,specProject:t.specProject,specProjectSource:t.specProjectSource,projectRoot:c,interactive:t.interactive,credentialHint:"Run `phoenix login` again."},i),{data:m,error:l}=await e(a).POST("/environments/development/resolve",{body:{project:p},headers:{authorization:`Bearer ${s.token}`}});if(l||!m)throw Error(`The server did not provide a development environment for project "${p}"${s.customerSlug?` in workspace "${s.customerSlug}"`:""} on ${a}: ${l?.message??"no response"}`);return{apiToken:s.token,workspaceName:s.customerName,projectSlug:m.projectSlug,environmentSlug:m.environmentSlug}};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A workspace of the session, as `/auth/me` lists it. */
|
|
2
|
+
interface SessionWorkspace {
|
|
3
|
+
readonly slug: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly projects: readonly {
|
|
6
|
+
readonly slug: string;
|
|
7
|
+
}[];
|
|
8
|
+
}
|
|
9
|
+
/** One workspace with the project slugs the credential can reach in it, as `whoami` and deploy errors list them. */
|
|
10
|
+
export declare const describeWorkspaceProjects: (workspace: SessionWorkspace) => string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const describeWorkspaceProjects=e=>`${e.name} (${e.slug}): ${e.projects.map(e=>e.slug).join(", ")||"no project access"}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{describeWorkspaceProjects}from"./describe-workspace-projects.js";export{resolveDeployTarget}from"./resolve-deploy-target.js";export{resolveTargetProject}from"./resolve-target-project.js";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface ResolveDeployTargetProps {
|
|
2
|
+
readonly serverUrl: string;
|
|
3
|
+
/** API token of the credential the deploy runs with. */
|
|
4
|
+
readonly token: string;
|
|
5
|
+
/** Slug of the project the deploy is about to upload to. */
|
|
6
|
+
readonly project: string;
|
|
7
|
+
/** What to do when the server refuses the token: sign in again, or replace the variable that supplies it. */
|
|
8
|
+
readonly credentialHint: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Where a deploy goes and who it acts as, checked against the server before anything is packed, so a wrong project
|
|
12
|
+
* or account shows before it reaches a live configurator.
|
|
13
|
+
*/
|
|
14
|
+
interface DeployTarget {
|
|
15
|
+
/** Workspace that owns the project. Null when the server is too old to list the workspaces of the session. */
|
|
16
|
+
readonly workspace: {
|
|
17
|
+
readonly slug: string;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
} | null;
|
|
20
|
+
/**
|
|
21
|
+
* Workspaces the named slug is in when it is in several of them; the server then deploys to the one whose project the
|
|
22
|
+
* credential can manage, and `workspace` is null. Empty otherwise.
|
|
23
|
+
*/
|
|
24
|
+
readonly ambiguousWorkspaces: readonly {
|
|
25
|
+
readonly slug: string;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
}[];
|
|
28
|
+
/** How the deploy names the project: its slug, or `<slug>--<workspace slug>`. */
|
|
29
|
+
readonly project: string;
|
|
30
|
+
/** The project's slug within its workspace, which Studio addresses name it by. */
|
|
31
|
+
readonly projectSlug: string;
|
|
32
|
+
/** Email of the account, or its id on a server that sends no email. */
|
|
33
|
+
readonly account: string;
|
|
34
|
+
/** API version the server reported with the session, when it sent one. */
|
|
35
|
+
readonly apiVersion: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* The previews of the project a deploy can build into, which `--env` is checked against. Null when the server does
|
|
38
|
+
* not list them, a server from before previews.
|
|
39
|
+
*/
|
|
40
|
+
readonly previews: readonly string[] | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reads the session of the credential and finds the workspace of the project a deploy targets. A project the
|
|
44
|
+
* credential cannot reach stops the deploy here with the ones it can, instead of after packing and uploading.
|
|
45
|
+
*/
|
|
46
|
+
export declare const resolveDeployTarget: ({ serverUrl, token, project, credentialHint, }: ResolveDeployTargetProps) => Promise<DeployTarget>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCliApiClient as e}from"#package/client";import{describeWorkspaceProjects as r}from"./describe-workspace-projects.js";export const resolveDeployTarget=async({serverUrl:o,token:s,project:a,credentialHint:p})=>{let{data:t,error:c,response:l}=await e(o).GET("/auth/me",{headers:{authorization:`Bearer ${s}`}});if(c||!t){let e=401===l.status?` ${p}`:"";throw Error(`Your sign-in could not be checked: ${(c?.message??"no response").replace(/\.$/,"")}.${e}`)}let i=t.email??t.userId,n=l.headers.get("x-api-version");if(void 0===t.workspaces)return{workspace:null,ambiguousWorkspaces:[],project:a,projectSlug:a,account:i,apiVersion:n,previews:null};let u=t.workspaces.flatMap(e=>e.projects.filter(r=>r.slug===a||`${r.slug}--${e.slug}`===a).map(r=>({workspace:{slug:e.slug,name:e.name},projectSlug:r.slug,previews:r.previews??null}))),[g]=u;if(void 0===g){let e=t.workspaces.map(r).join("; ");throw Error(`Project "${a}" is not one ${i} can reach on ${o}, so nothing was packed or uploaded. ${e?`Reachable projects: ${e}`:"The credential reaches no workspace"}. Pass --project <slug> or set \`project\` in spec/application.yaml to one of them, or ask a workspace administrator for access to "${a}".`)}return u.length>1?{workspace:null,ambiguousWorkspaces:u.map(e=>e.workspace),project:a,projectSlug:g.projectSlug,account:i,apiVersion:n,previews:null}:{workspace:g.workspace,ambiguousWorkspaces:[],project:a,projectSlug:g.projectSlug,account:i,apiVersion:n,previews:g.previews}};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Logger } from '../../utils/index.js';
|
|
2
|
+
interface ResolveTargetProjectProps {
|
|
3
|
+
readonly serverUrl: string;
|
|
4
|
+
/** API token of the sign-in the command runs with. */
|
|
5
|
+
readonly token: string;
|
|
6
|
+
/** Project slug named with `--project`. It wins over the spec. */
|
|
7
|
+
readonly flagProject: string | undefined;
|
|
8
|
+
/** `project` of the application spec, when a spec file sets it, or the project `.env` names in its place. */
|
|
9
|
+
readonly specProject: string | undefined;
|
|
10
|
+
/** Where `specProject` comes from, for messages: the spec, or `PROJECT_SLUG` for `phoenix dev`. */
|
|
11
|
+
readonly specProjectSource: string;
|
|
12
|
+
/** Folder of the project whose spec may get the chosen project written into it. */
|
|
13
|
+
readonly projectRoot: string;
|
|
14
|
+
/** Whether somebody can answer a prompt: false for an agent, CI or piped input. */
|
|
15
|
+
readonly interactive: boolean;
|
|
16
|
+
/** What to do when the server refuses the token: sign in again, or replace the variable that supplies it. */
|
|
17
|
+
readonly credentialHint: string;
|
|
18
|
+
}
|
|
19
|
+
interface ResolveTargetProjectContext {
|
|
20
|
+
readonly logger: Logger;
|
|
21
|
+
/** Prints a question and resolves with the trimmed line typed as the answer. */
|
|
22
|
+
readonly ask: (question: string) => Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Decides which server project `phoenix dev` and `phoenix deploy` work in: the one named with `--project`, else the
|
|
26
|
+
* one the spec names, else one of the projects the sign-in can reach.
|
|
27
|
+
*
|
|
28
|
+
* With no project named, a terminal gets a select of the reachable projects; without a terminal the only reachable
|
|
29
|
+
* project is used and several stop the command with the list, since nobody can choose. A choice the spec does not
|
|
30
|
+
* hold yet is offered for saving. A spec that still says `project: default` names no project: that alias for a
|
|
31
|
+
* workspace's original project no longer exists.
|
|
32
|
+
*/
|
|
33
|
+
export declare const resolveTargetProject: (props: ResolveTargetProjectProps, context: ResolveTargetProjectContext) => Promise<string>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DEFAULT_PROJECT_ALIAS as e}from"@salsita-ai/contracts/domain";import{createCliApiClient as t}from"#package/client";import{describeWorkspaceProjects as r}from"./describe-workspace-projects.js";import{writeSpecProject as o}from"./write-spec-project.js";let a=t=>{let r=t?.trim();return r&&r!==e?r:void 0},n=async({serverUrl:e,token:r,credentialHint:o})=>{let{data:a,error:n,response:s}=await t(e).GET("/auth/me",{headers:{authorization:`Bearer ${r}`}});if(n||!a){let t=401===s.status?` ${o}`:"";throw Error(`Phoenix could not list the projects your sign-in can reach on ${e}: ${(n?.message??"no response").replace(/\.$/,"")}. The list is needed because neither --project nor the spec names a project.${t} Passing --project <slug> skips the list.`)}let i=(a.workspaces??[]).flatMap(e=>e.projects.map(t=>({slug:t.slug,name:t.name,workspaceName:e.name,workspaceSlug:e.slug})));return i.map(e=>({...e,target:i.filter(t=>t.slug===e.slug).length>1?`${e.slug}--${e.workspaceSlug}`:e.slug}))},s=async(e,{logger:t,ask:r})=>{let o=e.map((e,t)=>` ${t+1}. ${e.target} (${e.name}, workspace ${e.workspaceName})`).join("\n");for(t.info(`Neither --project nor the spec names a project. Your sign-in can reach:
|
|
2
|
+
${o}`);;){let o=await r(`Project to use [1-${e.length}]: `),a=e.find((e,t)=>o===String(t+1)||o===e.target);if(a)return a.target;t.warn(`"${o}" is not on the list. Type a number from 1 to ${e.length}, or a project slug.`)}},i=async(t,r,{logger:a,ask:n})=>{let s=`project: ${t}`;if(!r.interactive){let o=r.flagProject?.trim()?"keep passing --project":`pass --project ${t}`;a.info(r.specProject?.trim()===e?`Replace \`${e}\` in ${r.specProjectSource} with \`${t}\`, or ${o}, to target it on later runs.`:`Add \`${s}\` to spec/application.yaml, or ${o}, to target it on later runs.`);return}if(!["","y","yes"].includes((await n(`Write \`${s}\` to the spec so later runs use it? [Y/n] `)).toLowerCase()))return;let i=await o(r.projectRoot,t);a.info(void 0===i?`Phoenix could not write \`${s}\` into the spec, because \`project\` is set there in a form it cannot rewrite or spec/application.yaml is missing. Set it by hand.`:`${i} now says \`${s}\`. Commit the change.`)};export const resolveTargetProject=async(t,o)=>{let{serverUrl:c,interactive:p}=t,{logger:l}=o,g=a(t.specProject);if(t.flagProject?.trim()===e)throw Error(`--project ${e} names no project: \`${e}\` was an alias for a workspace's original project and no longer exists. Pass the project's slug; \`phoenix whoami\` lists the ones you can reach.`);let u=a(t.flagProject);if(void 0!==u)return void 0===g?await i(u,t,o):g!==u&&l.info(`Using project "${u}" from --project instead of "${g}" from ${t.specProjectSource}.`),u;if(void 0!==g)return g;t.specProject?.trim()===e&&l.warn(`The project \`${e}\` from ${t.specProjectSource} no longer names a project. Replace it with a project slug.`);let m=await n(t),[h]=m;if(void 0===h)throw Error(`Your sign-in on ${c} can reach no project, and neither --project nor the spec names one. Create a project in Studio, or ask a workspace administrator for project access, then run the command again.`);if(p){let e=await s(m,o);return await i(e,t,o),e}if(m.length>1)throw Error(`Neither --project nor the spec names a project, and your sign-in can reach ${m.length} (${[...new Set(m.map(e=>e.workspaceSlug))].map(e=>{let t=m.filter(t=>t.workspaceSlug===e);return r({slug:e,name:t[0]?.workspaceName??e,projects:t})}).join("; ")}). Pass --project <slug>, or set \`project\` in spec/application.yaml to the slug of the one to work in.`);return l.info(`Using project "${h.target}", the only project your sign-in can reach.`),await i(h.target,t,o),h.target};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes the project a command targets into the spec, and returns the path of the changed file within the project.
|
|
3
|
+
* A spec file that still says `project: default` gets the slug in place of that value; otherwise the slug is added
|
|
4
|
+
* to `spec/application.yaml`. Returns nothing, and writes nothing, when `project` is set in a form that cannot be
|
|
5
|
+
* rewritten safely (a block scalar, an alias, an empty value) or there is no application spec file to add it to.
|
|
6
|
+
*/
|
|
7
|
+
export declare const writeSpecProject: (projectRoot: string, projectSlug: string) => Promise<string | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{globby as t}from"globby";import{readFile as e,writeFile as r}from"node:fs/promises";import{join as i}from"node:path";import{Scalar as a,isMap as n,isScalar as o,parseDocument as l,stringify as p}from"yaml";import{DEFAULT_PROJECT_ALIAS as s}from"@salsita-ai/contracts/domain";import{SPEC_FILE_PATTERN as m}from"../../application-spec/index.js";let c="spec/application.yaml",f=(t,e)=>{let r=l(t).get("project",!0);if(!o(r)||!r.range||"string"!=typeof r.value||r.type===a.BLOCK_LITERAL||r.type===a.BLOCK_FOLDED||r.value.trim()!==s)return t;let[i,n]=r.range;return`${t.slice(0,i)}${p(e).trimEnd()}${t.slice(n)}`};export const writeSpecProject=async(a,o)=>{let s=(await t(m,{cwd:a})).sort(),u=await Promise.all(s.map(async t=>({filePath:t,text:await e(i(a,t),"utf-8")})));for(let{filePath:t,text:e}of u){let n=f(e,o);if(n!==e)return await r(i(a,t),n),t}let $=u.find(t=>t.filePath===c);if(!$||u.some(t=>l(t.text).has("project")))return;let d=((t,e)=>{let{contents:r}=l(t),i=t.includes("\r\n")?"\r\n":"\n",a=`project: ${p(e).trimEnd()}${i}`;if(null===r)return`${t}${""===t||t.endsWith("\n")?"":i}${a}`;if(!n(r)||!r.range)return t;let[o]=r.range,s=`${t.slice(0,o)}${a}${t.slice(o)}`,m=l(s);return 0===m.errors.length&&m.get("project")===e?s:t})($.text,o);if(d!==$.text)return await r(i(a,c),d),c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdir as e,readFile as t,realpath as i,rename as a,rm as r,writeFile as s}from"node:fs/promises";import{dirname as o,join as n,relative as l,resolve as p,sep as c}from"node:path";import h from"promise-queue";import{z as d}from"zod";import{RawProjectFiles as f,RuntimeReferenceStore as m,TextFile as w,buildPhoenixDefinitions as u,isTextFile as g,parseApplicationFiles as v}from"#package/application-spec";import{generateAssistantPrompt as y,getAllPhxDefinitions as b}from"#package/domain";import{readApplicationFiles as S}from"../application-spec/application-spec-file-reader.js";import{swcEvalExpressionParser as
|
|
1
|
+
import{mkdir as e,readFile as t,realpath as i,rename as a,rm as r,writeFile as s}from"node:fs/promises";import{dirname as o,join as n,relative as l,resolve as p,sep as c}from"node:path";import h from"promise-queue";import{z as d}from"zod";import{RawProjectFiles as f,RuntimeReferenceStore as m,TextFile as w,buildPhoenixDefinitions as u,isTextFile as g,parseApplicationFiles as v}from"#package/application-spec";import{generateAssistantPrompt as y,getAllPhxDefinitions as b}from"#package/domain";import{readApplicationFiles as S}from"../application-spec/application-spec-file-reader.js";import{swcEvalExpressionParser as k,swcModuleAnalyzer as F}from"../application-spec/swc-module-analyzer.js";let N=".phoenix/variant-recovery.json",M=d.array(d.object({fileName:d.string(),original:d.string().nullable(),applied:d.string().nullable(),previous:d.string().nullable().optional()})),j=e=>!e.includes("\\")&&!e.split("/").some(e=>".."===e||"."===e||""===e)&&(/^spec\/(?!admin\/).+\.yaml$/.test(e)||/^src\/(?:components|transformers|handlers|elements|_[^/]+)\/.+\.tsx?$/.test(e)),E=e=>`Left ${e} as it is: it was edited outside the variant comparison, so restoring the baseline would overwrite that edit. Review the file and remove what the option added to it`,$=async e=>{try{return await t(e,"utf8")}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return null;throw e}},C=async(t,i)=>{if(null===i)return void await r(t,{force:!0});await e(o(t),{recursive:!0});let n=`${t}.variant-${crypto.randomUUID()}`;try{await s(n,i),await a(n,t)}finally{await r(n,{force:!0})}},R=(e,t)=>{let i=v({rawProjectFiles:e,phxDefinitions:u(b())},{analyzer:F,evalExpressionParser:k,referenceStore:new m,logger:t});if(!i.ok)throw Error(`Cannot apply variant: ${i.errors.map(e=>`[${e.code}] ${e.message}`).join("\n")}`);let{configurator:a,admin:r,appMetadata:s,infra:o,dataSpec:n}=i.value.applicationSpec,l=i.value.categorizedFiles,p=new Set([...l.webhooks,...l.expressions,...l.actions,...l.invariants,...l.migrations,...l.adminMigrations,...l.adminExpressions,...l.adminInvariants,...l.handlers.filter(e=>"pinned"===e.webhookMembership||"named-handler"===e.webhookMembership||"webhook-only"===e.webhookMembership),...l.components.filter(e=>"pinned"===e.webhookMembership),...l.adminComponents.filter(e=>"pinned"===e.webhookMembership)].flatMap(e=>[e.file.name,...e.deps]));return JSON.stringify({webhookFiles:e.files.filter(g).filter(e=>p.has(e.name)).sort((e,t)=>e.name.localeCompare(t.name)),appMetadata:s,infra:o,dataSpec:n,model:a.latestModel,schema:a.configurationSchema,dataSchemas:a.dataSchemas,adminModel:r.latestModel,adminSchema:r.configurationSchema,assistant:a.assistant?.sdl,assistantInstructions:a.assistant?.instructions,assistantSettings:a.assistantServerSettings,assistantPrompt:a.assistant?y(a.assistant,{surface:"panel",voice:a.assistantServerSettings?.ai.voice===!0}):null},(e,t)=>t instanceof Map?[...t.entries()]:t)};export class VariantFileSession{props;queue=new h(1,1/0);applied=new Map;baseline=new Map;contract;settled=!1;constructor(e){for(let t of(this.props=e,e.rawFiles.files))g(t)&&j(t.name)&&this.baseline.set(t.name,t.content);this.contract=R(e.rawFiles,e.logger)}static async create(e){await VariantFileSession.recover(e.projectRoot,e.logger);let t=await S({projectRoot:e.projectRoot,envs:{}});return new VariantFileSession({...e,rawFiles:t})}static async recover(e,t){let i=await $(n(e,N));if(null!==i){for(let a of M.parse(JSON.parse(i))){let i=await VariantFileSession.resolveFile(e,a.fileName),r=await $(i);if(r!==a.applied&&r!==a.original&&r!==a.previous){t.warn(E(a.fileName));continue}await C(i,a.original)}await r(n(e,N),{force:!0})}}static async resolveFile(e,t){if(!j(t))throw Error(`Cannot override ${t}: variants support frontend spec and TypeScript files only. Keep server code, dependencies, environment files and assets unchanged`);let a=await i(e),r=p(a,t),s=r;for(;;)try{let e=await i(s),r=l(a,e);if(".."===r||r.startsWith(`..${c}`))throw Error(`Cannot override ${t}: its symbolic link leaves the project`);if(e!==s)throw Error(`Cannot override ${t}: it uses a symbolic link. Variant edits require regular files so restoration preserves the original file`);break}catch(e){if(!(e instanceof Error&&"code"in e&&"ENOENT"===e.code))throw e;s=o(s)}return r}getFiles(){return[...this.baseline].map(([e,t])=>({fileName:e,content:t}))}apply(e){return this.queue.add(async()=>{if(this.settled)throw Error("This variant comparison has already ended");let t=new Map;for(let i of e){if(await VariantFileSession.resolveFile(this.props.projectRoot,i.fileName),t.has(i.fileName))throw Error(`Cannot apply variant: ${i.fileName} is specified twice`);t.set(i.fileName,i.content)}if(t.size>0){let e=this.props.rawFiles.files.filter(e=>!t.has(e.name));for(let[i,a]of t)null!==a&&e.push(w(i,a));if(R(f(e),this.props.logger)!==this.contract)throw Error("Cannot apply variant: it changes the model, schemas, data or deployment settings. Variants must need no server preparation")}await this.writeTarget(t,"refuse")})}finish(e){return this.queue.add(async()=>{this.settled||(e||await this.writeTarget(new Map,"keep"),await r(n(this.props.projectRoot,N),{force:!0}),this.settled=!0)})}async writeTarget(t,i){let a=new Set([...this.applied.keys(),...t.keys()]);if(0===a.size)return;let r=new Map;for(let e of a){let t=await VariantFileSession.resolveFile(this.props.projectRoot,e),a=this.applied.has(e)?this.applied.get(e):this.baseline.get(e)??null;if(await $(t)===a){r.set(e,t);continue}if("refuse"===i)throw Error(`Cannot switch variant: ${e} was edited outside the preview, and switching would overwrite that edit. Choose the option that is shown, or close the comparison with \`phoenix variants --close\`, which keeps the edit`);this.props.logger.warn(E(e))}let s=[...r.keys()].map(e=>({fileName:e,original:this.baseline.get(e)??null,previous:this.applied.has(e)?this.applied.get(e)??null:this.baseline.get(e)??null,applied:t.has(e)?t.get(e)??null:this.baseline.get(e)??null}));await e(n(this.props.projectRoot,".phoenix"),{recursive:!0}),await C(n(this.props.projectRoot,N),JSON.stringify(s));let o=new Map(this.applied);try{for(let e of s){let t=r.get(e.fileName);void 0!==t&&await C(t,e.applied)}}catch(e){for(let[e,t]of r)await C(t,o.has(e)?o.get(e)??null:this.baseline.get(e)??null);throw await C(n(this.props.projectRoot,N),JSON.stringify([...o].map(([e,t])=>({fileName:e,original:this.baseline.get(e)??null,applied:t})))),e}for(let[e,i]of(this.applied.clear(),t))this.applied.set(e,i);this.props.onFilesChanged(s.map(e=>({fileName:e.fileName,content:e.applied})))}}
|