@juo/orion-core 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ExtensionRoot-BuoY5H2A.js → ExtensionRoot-BFk-vt2J.js} +44 -16
- package/dist/block.d.ts +15 -3
- package/dist/bridge-fHXg0b-e.js +421 -0
- package/dist/core.js +270 -9
- package/dist/editor/bridge.d.ts +17 -0
- package/dist/editor/bridge.test.d.ts +1 -0
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/handler.d.ts +2 -3
- package/dist/editor/main.d.ts +7 -4
- package/dist/editor/messages.d.ts +86 -6
- package/dist/editor.js +299 -59
- package/dist/flows/MockWorkflowApiAdapter.d.ts +12 -0
- package/dist/flows/WorkflowService.d.ts +156 -0
- package/dist/flows/__tests__/WorkflowService.test.d.ts +1 -0
- package/dist/flows/__tests__/defaults.test.d.ts +1 -0
- package/dist/flows/__tests__/juo-workflow.test.d.ts +1 -0
- package/dist/flows/__tests__/overlay-behavior.test.d.ts +1 -0
- package/dist/flows/__tests__/theme-state-surfaces.test.d.ts +1 -0
- package/dist/flows/defaults.d.ts +14 -0
- package/dist/flows/index.d.ts +3 -0
- package/dist/flows/juo-workflow.d.ts +47 -0
- package/dist/juo-workflow-CoWvwYTn.js +545 -0
- package/dist/main.d.ts +5 -3
- package/dist/preact.js +1 -1
- package/dist/react.js +1 -1
- package/dist/{block-CFJIpH_9.js → theme-state-TW-9hD7e.js} +209 -7
- package/dist/theme-state.d.ts +84 -0
- package/dist/theme-state.locales.test.d.ts +1 -0
- package/dist/translation.d.ts +13 -0
- package/dist/translation.test.d.ts +1 -0
- package/dist/vue/context.d.ts +2 -0
- package/dist/vue.js +8 -1
- package/dist/web-components/ExtensionRoot.d.ts +12 -1
- package/dist/web-components/editor/InlineText.d.ts +4 -0
- package/dist/web-components/runtime/InlineText.d.ts +2 -1
- package/dist/web-components-editor.js +70 -21
- package/dist/web-components-runtime.js +39 -3
- package/package.json +1 -1
- package/dist/bridge-BPfBHSPI.js +0 -245
- package/dist/page-DFFhF7j8.js +0 -12
- package/dist/page.d.ts +0 -9
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ReadonlySignal } from '@preact/signals-core';
|
|
2
|
+
import { ThemeState } from '../theme-state';
|
|
3
|
+
export declare const WorkflowServiceContext: {
|
|
4
|
+
__context__: {
|
|
5
|
+
state: ReadonlySignal<WorkflowState>;
|
|
6
|
+
/** True when the portal is running inside the Orion editor (editorMode dep
|
|
7
|
+
* or ?trigger=... URL param). Consumers use this to suppress auto-start. */
|
|
8
|
+
isPreviewMode: boolean;
|
|
9
|
+
isActive: ReadonlySignal<boolean>;
|
|
10
|
+
isLoading: ReadonlySignal<boolean>;
|
|
11
|
+
isCompleted: ReadonlySignal<boolean>;
|
|
12
|
+
hasError: ReadonlySignal<boolean>;
|
|
13
|
+
currentInteraction: ReadonlySignal<PendingInteraction | null>;
|
|
14
|
+
currentStepInfo: ReadonlySignal<WorkflowStepInfo | null>;
|
|
15
|
+
startFlow(flowType: string, context: Record<string, unknown>, workflowId?: string): Promise<void>;
|
|
16
|
+
respond(responseType: string, responseData?: Record<string, unknown>): Promise<void>;
|
|
17
|
+
cancel(): Promise<void>;
|
|
18
|
+
reset(): void;
|
|
19
|
+
refresh(): Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Mirrors `PendingInteraction` from `@juo/workflows-core`.
|
|
24
|
+
* Inlined here to avoid a cross-package dependency from orion-core -> workflow-core.
|
|
25
|
+
*/
|
|
26
|
+
export interface PendingInteraction {
|
|
27
|
+
/** Unique per interaction instance (idempotency/stale-response protection) */
|
|
28
|
+
interactionId: string;
|
|
29
|
+
stepId: string;
|
|
30
|
+
actionType: string;
|
|
31
|
+
actionBehavior: "input";
|
|
32
|
+
actionConfig: Record<string, unknown>;
|
|
33
|
+
availableResponses: Array<{
|
|
34
|
+
type: string;
|
|
35
|
+
label: string;
|
|
36
|
+
}>;
|
|
37
|
+
presentedAt: Date;
|
|
38
|
+
/** Optional relative timeout duration (milliseconds) */
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface WorkflowOutcome {
|
|
42
|
+
type: string;
|
|
43
|
+
message: string;
|
|
44
|
+
}
|
|
45
|
+
export type WorkflowStatus = "idle" | "loading" | "active" | "completed" | "error";
|
|
46
|
+
export interface WorkflowState {
|
|
47
|
+
status: WorkflowStatus;
|
|
48
|
+
flowType: string | null;
|
|
49
|
+
workflowId: string | null;
|
|
50
|
+
workflowVersion: number | null;
|
|
51
|
+
runId: string | null;
|
|
52
|
+
runVersion: number | null;
|
|
53
|
+
currentStepId: string | null;
|
|
54
|
+
currentInteraction: PendingInteraction | null;
|
|
55
|
+
error: string | null;
|
|
56
|
+
result: Record<string, unknown> | null;
|
|
57
|
+
/** Parameters passed to startFlow (e.g. { layout: 'modal' | 'sidebar' }) */
|
|
58
|
+
flowParams: Record<string, unknown> | null;
|
|
59
|
+
/** Accumulated resources invalidated by actions across all responses in this flow. */
|
|
60
|
+
invalidatedResources: string[];
|
|
61
|
+
/** Describes the primary action taken when the workflow completes.
|
|
62
|
+
* Used to show a confirmation toast (e.g. "Your subscription has been cancelled"). */
|
|
63
|
+
outcome: WorkflowOutcome | null;
|
|
64
|
+
}
|
|
65
|
+
/** Available steps metadata (for rendering and editor) */
|
|
66
|
+
export interface WorkflowStepInfo {
|
|
67
|
+
interactionId: string;
|
|
68
|
+
stepId: string;
|
|
69
|
+
actionType: string;
|
|
70
|
+
actionConfig: Record<string, unknown>;
|
|
71
|
+
availableResponses: Array<{
|
|
72
|
+
type: string;
|
|
73
|
+
label: string;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Lightweight step definition (no per-instance interactionId).
|
|
78
|
+
* Used by `interactiveSteps` to describe the full set of input steps
|
|
79
|
+
* in a workflow so the root block can pre-populate all slots and presets.
|
|
80
|
+
*/
|
|
81
|
+
export interface WorkflowStepDefinition {
|
|
82
|
+
stepId: string;
|
|
83
|
+
actionType: string;
|
|
84
|
+
actionConfig: Record<string, unknown>;
|
|
85
|
+
availableResponses: Array<{
|
|
86
|
+
type: string;
|
|
87
|
+
label: string;
|
|
88
|
+
}>;
|
|
89
|
+
}
|
|
90
|
+
export type WorkflowStartResponse = {
|
|
91
|
+
status: "no_workflow";
|
|
92
|
+
} | {
|
|
93
|
+
status: "completed_silently";
|
|
94
|
+
invalidatedResources?: string[];
|
|
95
|
+
outcome?: WorkflowOutcome;
|
|
96
|
+
} | WorkflowRunState;
|
|
97
|
+
export interface WorkflowRunState {
|
|
98
|
+
workflowId: string;
|
|
99
|
+
workflowVersion: number;
|
|
100
|
+
runId: string;
|
|
101
|
+
runVersion: number;
|
|
102
|
+
status: "running" | "waiting_interaction" | "completed" | "failed" | "cancelled";
|
|
103
|
+
pendingInteraction?: PendingInteraction;
|
|
104
|
+
/** All interactive (input) steps in this workflow, in order.
|
|
105
|
+
* Provided on start() so the client can pre-populate all root block slots and editor presets. */
|
|
106
|
+
interactiveSteps?: WorkflowStepDefinition[];
|
|
107
|
+
result?: Record<string, unknown>;
|
|
108
|
+
error?: {
|
|
109
|
+
message: string;
|
|
110
|
+
code?: string;
|
|
111
|
+
};
|
|
112
|
+
/** Resources invalidated by actions executed during this response (e.g. ["subscription"]). */
|
|
113
|
+
invalidatedResources?: string[];
|
|
114
|
+
outcome?: WorkflowOutcome;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* API adapter interface for WorkflowService.
|
|
118
|
+
* Allows different implementations (real API, mocked, etc.)
|
|
119
|
+
*/
|
|
120
|
+
export interface WorkflowApiAdapter {
|
|
121
|
+
start(flowType: string, context: Record<string, unknown>, workflowId?: string, dryRun?: boolean): Promise<WorkflowStartResponse>;
|
|
122
|
+
respond(runId: string, interactionId: string, responseType: string, responseData?: Record<string, unknown>, expectedRunVersion?: number, eventId?: string): Promise<WorkflowRunState>;
|
|
123
|
+
getState(runId: string): Promise<WorkflowRunState>;
|
|
124
|
+
cancel(runId: string): Promise<WorkflowRunState>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Create a real API adapter for the Customer API.
|
|
128
|
+
*/
|
|
129
|
+
export declare function createWorkflowApiAdapter(sdk: {
|
|
130
|
+
get: any;
|
|
131
|
+
post: any;
|
|
132
|
+
}): WorkflowApiAdapter;
|
|
133
|
+
export interface WorkflowServiceDependencies {
|
|
134
|
+
/** API adapter for communicating with backend */
|
|
135
|
+
api: WorkflowApiAdapter;
|
|
136
|
+
/** ThemeState context for resolving the started workflow */
|
|
137
|
+
themeState: ThemeState;
|
|
138
|
+
}
|
|
139
|
+
export declare function createWorkflowService(deps: WorkflowServiceDependencies): {
|
|
140
|
+
state: ReadonlySignal<WorkflowState>;
|
|
141
|
+
/** True when the portal is running inside the Orion editor (editorMode dep
|
|
142
|
+
* or ?trigger=... URL param). Consumers use this to suppress auto-start. */
|
|
143
|
+
isPreviewMode: boolean;
|
|
144
|
+
isActive: ReadonlySignal<boolean>;
|
|
145
|
+
isLoading: ReadonlySignal<boolean>;
|
|
146
|
+
isCompleted: ReadonlySignal<boolean>;
|
|
147
|
+
hasError: ReadonlySignal<boolean>;
|
|
148
|
+
currentInteraction: ReadonlySignal<PendingInteraction | null>;
|
|
149
|
+
currentStepInfo: ReadonlySignal<WorkflowStepInfo | null>;
|
|
150
|
+
startFlow(flowType: string, context: Record<string, unknown>, workflowId?: string): Promise<void>;
|
|
151
|
+
respond(responseType: string, responseData?: Record<string, unknown>): Promise<void>;
|
|
152
|
+
cancel(): Promise<void>;
|
|
153
|
+
reset(): void;
|
|
154
|
+
refresh(): Promise<void>;
|
|
155
|
+
};
|
|
156
|
+
export type WorkflowService = ReturnType<typeof createWorkflowService>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Block } from '../block';
|
|
2
|
+
/**
|
|
3
|
+
* Get default block for a flow step based on action type.
|
|
4
|
+
* Looks for a registered block with name `action:<actionType>`.
|
|
5
|
+
*
|
|
6
|
+
* Used by:
|
|
7
|
+
* - <juo-workflow> for rendering current step
|
|
8
|
+
* - OrionWorkflowInitializer when no custom block is defined for a step
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDefaultBlockForAction(actionType: string, actionConfig: Record<string, unknown>, blockId?: string): Block;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a default block exists for an action type.
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasDefaultBlockForAction(actionType: string): boolean;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createWorkflowService, createWorkflowApiAdapter, WorkflowServiceContext, type PendingInteraction, type WorkflowService, type WorkflowApiAdapter, type WorkflowServiceDependencies, type WorkflowState, type WorkflowStatus, type WorkflowStepInfo, type WorkflowStepDefinition, type WorkflowStartResponse, type WorkflowRunState, type WorkflowOutcome, } from './WorkflowService';
|
|
2
|
+
export { getDefaultBlockForAction, hasDefaultBlockForAction, } from './defaults';
|
|
3
|
+
export { createMockWorkflowApiAdapter } from './MockWorkflowApiAdapter';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <juo-workflow> web component
|
|
3
|
+
*
|
|
4
|
+
* Renders the current workflow step by:
|
|
5
|
+
* 1. Subscribing to WorkflowServiceContext
|
|
6
|
+
* 2. Watching state (status + currentStepInfo) changes
|
|
7
|
+
* 3. For active/loading state with a step: renders <juo-extension-root surface="overlay" name="<stepId>">
|
|
8
|
+
* - The step is kept mounted during `loading` so button processing state is preserved
|
|
9
|
+
* while the respond API call is in flight.
|
|
10
|
+
* - The DOM is only replaced when the step ID actually changes.
|
|
11
|
+
* 4. For all other states: clears content
|
|
12
|
+
* - `completed`: unloads content; the portal handles teardown
|
|
13
|
+
* - `error`: dispatches a `juo-workflow-error` CustomEvent for the portal to handle
|
|
14
|
+
*
|
|
15
|
+
* The `name` attribute on juo-extension-root corresponds to the current step ID.
|
|
16
|
+
* The `surface="overlay"` attribute selects ThemeStateContext.overlay blocks.
|
|
17
|
+
* Block resolution (default vs custom) is handled by OrionWorkflowInitializer
|
|
18
|
+
* which updates ThemeStateContext.overlay with the appropriate blocks.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* <juo-workflow></juo-workflow>
|
|
22
|
+
*
|
|
23
|
+
* Must be placed inside an element where WorkflowServiceContext is provided.
|
|
24
|
+
*
|
|
25
|
+
* The `blockWrapper` property accepts an optional function:
|
|
26
|
+
* (rendered: HTMLElement) => HTMLElement
|
|
27
|
+
* When provided, it is called to wrap each rendered block element.
|
|
28
|
+
* This allows the parent (e.g. WorkflowOverlay) to inject a sidebar/modal container
|
|
29
|
+
* inside the Orion block wrapper, producing:
|
|
30
|
+
* juo-editor-block-wrapper -> [blockWrapper result] -> actual block
|
|
31
|
+
*/
|
|
32
|
+
export declare class JuoWorkflowElement extends HTMLElement {
|
|
33
|
+
private workflowService;
|
|
34
|
+
private unsubscribeContext;
|
|
35
|
+
private unsubscribeEffect;
|
|
36
|
+
/** Tracks which step is currently mounted to avoid unnecessary DOM teardown. */
|
|
37
|
+
private renderedStepId;
|
|
38
|
+
/**
|
|
39
|
+
* Optional function to wrap rendered content (step blocks).
|
|
40
|
+
* Must be set before workflow becomes active for correct behavior.
|
|
41
|
+
*/
|
|
42
|
+
blockWrapper: ((rendered: HTMLElement) => HTMLElement) | null;
|
|
43
|
+
connectedCallback(): void;
|
|
44
|
+
disconnectedCallback(): void;
|
|
45
|
+
private setupSubscription;
|
|
46
|
+
private render;
|
|
47
|
+
}
|