@opens/service-workflow-ui 0.0.0-stage → 1.1.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/README.md CHANGED
@@ -1,3 +1,130 @@
1
- # Temporary Holding Version
1
+ # @opens/service-workflow-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Service workflow editor
4
+
5
+ Import the package stylesheet once in the consuming application, then bind the service flow with
6
+ `v-model`. Existing rules are always displayed; `allowed-node-types` controls which types can be
7
+ created by the editor.
8
+
9
+ ```ts
10
+ import { createPinia } from 'pinia';
11
+ import ServiceWorkflowUi, {
12
+ AppServiceWorkflowAddForm,
13
+ AppServiceWorkflowEditNodeForm,
14
+ AppServiceWorkflowEditor,
15
+ } from '@opens/service-workflow-ui';
16
+ import '@opens/service-workflow-ui/dist/yunique_ui.css';
17
+
18
+ app.use(createPinia());
19
+ app.use(ServiceWorkflowUi);
20
+ ```
21
+
22
+ ```vue
23
+ <app-service-workflow-editor
24
+ workflow-id="main-flow"
25
+ v-model="flow"
26
+ :allowed-node-types="['screen', 'identification', 'service']"
27
+ @change="handleChange"
28
+ @node="handleNode"
29
+ @invalid-change="handleInvalidChange"
30
+ @invalid-model="handleInvalidModel"
31
+ ></app-service-workflow-editor>
32
+
33
+ <app-service-workflow-add-form workflow-id="main-flow"></app-service-workflow-add-form>
34
+ <app-service-workflow-edit-node-form
35
+ workflow-id="main-flow"
36
+ @close="handleEditClose"
37
+ ></app-service-workflow-edit-node-form>
38
+ ```
39
+
40
+ `workflow-id` connects one editor to external add and edit forms through Pinia. The consumer owns
41
+ the Pinia instance; the library never installs or replaces it. Both forms can be positioned
42
+ anywhere in the application. Selecting an editable `screen`, `service`, or `identification` node
43
+ opens the matching form; saving emits the updated workflow through the editor's `v-model` and
44
+ `change` event. The edit form emits `close` whenever an active form closes.
45
+
46
+ A non-empty flow must contain exactly one rule with `isRoot: true`. Disconnected rules, multiple
47
+ parents, and cycles are supported. Invalid models remain visible in read-only mode.
48
+
49
+ Node-type descriptors may define a maximum number of outgoing children. Every rule with remaining
50
+ capacity displays one rolling purple add placeholder, regardless of how many slots remain.
51
+ `maxChildren: 0` disables child creation for that type.
52
+
53
+ ```ts
54
+ const allowedNodeTypes = [
55
+ { type: 'screen', maxChildren: 2 },
56
+ { type: 'identification', maxChildren: 1 },
57
+ { type: 'service', maxChildren: 0 },
58
+ ];
59
+ ```
60
+
61
+ The editor rejects add, connect, or cross-source reconnect operations that exceed a finite limit
62
+ through `invalid-change`. Existing over-capacity payloads remain visible and editable so their
63
+ connections can be removed or corrected.
64
+
65
+ This template should help get you started developing with Vue 3 in Vite.
66
+
67
+ ## Recommended IDE Setup
68
+
69
+ [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
70
+
71
+ ## Type Support for `.vue` Imports in TS
72
+
73
+ TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
74
+
75
+ If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
76
+
77
+ 1. Disable the built-in TypeScript Extension
78
+ 1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
79
+ 2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
80
+ 2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
81
+
82
+ ## Customize configuration
83
+
84
+ See [Vite Configuration Reference](https://vitejs.dev/config/).
85
+
86
+ ## Project Setup
87
+
88
+ ```sh
89
+ npm install
90
+ ```
91
+
92
+ ### Compile and Hot-Reload for Development
93
+
94
+ ```sh
95
+ npm run dev
96
+ ```
97
+
98
+ ### Type-Check, Compile and Minify for Production
99
+
100
+ ```sh
101
+ npm run build
102
+ ```
103
+
104
+ ### Run Unit Tests with [Vitest](https://vitest.dev/)
105
+
106
+ ```sh
107
+ npm run test:unit
108
+ ```
109
+
110
+ ### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
111
+
112
+ ```sh
113
+ npm run test:e2e:dev
114
+ ```
115
+
116
+ This runs the end-to-end tests against the Vite development server.
117
+ It is much faster than the production build.
118
+
119
+ But it's still recommended to test the production build with `test:e2e` before deploying (e.g. in CI environments):
120
+
121
+ ```sh
122
+ npm run build
123
+ npm run test:e2e
124
+ ```
125
+
126
+ ---
127
+
128
+ ### Novas versões
129
+
130
+ Para fechar novas versões deve-se atualizar o parâmetro `version` no package.json com o valor da nova versão. Após isso, o pipeline já irá fazer o build e atualizar no npm.
Binary file
package/dist/main.d.ts ADDED
@@ -0,0 +1,127 @@
1
+ import { App } from 'vue';
2
+ import { ComponentOptionsMixin } from 'vue';
3
+ import { ComponentProvideOptions } from 'vue';
4
+ import { ComputedRef } from 'vue';
5
+ import { CreateIdentificationRuleDTO } from '@opens/gateways/chat-config';
6
+ import { CreateScreenRuleDTO } from '@opens/gateways/chat-config';
7
+ import { CreateServiceRuleDTO } from '@opens/gateways/chat-config';
8
+ import { DefineComponent } from 'vue';
9
+ import { PublicProps } from 'vue';
10
+ import { Rule } from '@opens/gateways/chat-config';
11
+
12
+ declare type __VLS_Props = {
13
+ workflowId: string;
14
+ };
15
+
16
+ declare type __VLS_Props_2 = {
17
+ workflowId: string;
18
+ };
19
+
20
+ declare type __VLS_Props_3 = {
21
+ workflowId: string;
22
+ modelValue: any;
23
+ allowedNodeTypes?: any[];
24
+ };
25
+
26
+ export declare const AppServiceWorkflowAddForm: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
27
+
28
+ export declare const AppServiceWorkflowEditNodeForm: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
29
+ close: () => any;
30
+ }, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{
31
+ onClose?: (() => any) | undefined;
32
+ }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
33
+
34
+ export declare const AppServiceWorkflowEditor: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
35
+ "update:modelValue": (flow: any) => any;
36
+ change: (flow: any, mutation: WorkflowMutation) => any;
37
+ node: (rule: any) => any;
38
+ "invalid-change": (invalid: InvalidChange) => any;
39
+ "invalid-model": (invalid: InvalidModel) => any;
40
+ }, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{
41
+ "onUpdate:modelValue"?: ((flow: any) => any) | undefined;
42
+ onChange?: ((flow: any, mutation: WorkflowMutation) => any) | undefined;
43
+ onNode?: ((rule: any) => any) | undefined;
44
+ "onInvalid-change"?: ((invalid: InvalidChange) => any) | undefined;
45
+ "onInvalid-model"?: ((invalid: InvalidModel) => any) | undefined;
46
+ }>, {
47
+ allowedNodeTypes: any[];
48
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
49
+
50
+ declare const _default: {
51
+ install(app: App): void;
52
+ };
53
+ export default _default;
54
+
55
+ export declare interface InvalidChange {
56
+ mutation: Record<string, any>;
57
+ reason: string;
58
+ }
59
+
60
+ export declare interface InvalidModel {
61
+ reasons: string[];
62
+ }
63
+
64
+ export declare interface NormalizedNodeType {
65
+ type: string;
66
+ label: string;
67
+ color: string;
68
+ icon: string;
69
+ defaultName: string;
70
+ maxChildren?: number;
71
+ }
72
+
73
+ export declare type ServiceWorkflowEditorChannel = ReturnType<typeof useServiceWorkflowEditorChannel>;
74
+
75
+ export declare const useServiceWorkflowEditorChannel: (workflowId: string) => {
76
+ request: ComputedRef<WorkflowAddRequest | undefined>;
77
+ editRequest: ComputedRef< {
78
+ workflowId: string;
79
+ rule: Rule & {
80
+ action: (CreateScreenRuleDTO | CreateServiceRuleDTO | CreateIdentificationRuleDTO)["action"];
81
+ };
82
+ } | undefined>;
83
+ nodeTypes: ComputedRef<NormalizedNodeType[]>;
84
+ requestAdd: (parentRule?: any) => boolean;
85
+ requestEdit: (rule: Parameters<(id: string, rule: Rule) => boolean>[1]) => boolean;
86
+ cancelAdd: () => void;
87
+ cancelEdit: () => void;
88
+ confirmAdd: (nodeType: Parameters<(id: string, nodeType: NormalizedNodeType) => boolean>[1]) => boolean;
89
+ confirmEdit: (payload: Parameters<(id: string, payload: CreateScreenRuleDTO | CreateServiceRuleDTO | CreateIdentificationRuleDTO) => boolean>[1]) => boolean;
90
+ };
91
+
92
+ export declare interface WorkflowAddRequest {
93
+ workflowId: string;
94
+ parentId?: string;
95
+ parentName?: string;
96
+ }
97
+
98
+ export declare type WorkflowMutation = {
99
+ type: 'add-node';
100
+ nodeId: string;
101
+ parentId?: string;
102
+ } | {
103
+ type: 'edit-node';
104
+ nodeId: string;
105
+ } | {
106
+ type: 'delete-node';
107
+ nodeId: string;
108
+ } | {
109
+ type: 'connect';
110
+ edgeId: string;
111
+ source: string;
112
+ target: string;
113
+ } | {
114
+ type: 'disconnect';
115
+ edgeId: string;
116
+ source: string;
117
+ target: string;
118
+ } | {
119
+ type: 'reconnect';
120
+ edgeId: string;
121
+ source: string;
122
+ target: string;
123
+ previousSource: string;
124
+ previousTarget: string;
125
+ };
126
+
127
+ export { }