@widgetic/workflows 0.0.0-stage → 0.2.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.
Files changed (149) hide show
  1. package/LICENSE +122 -0
  2. package/README.md +304 -2
  3. package/dist/api/apiContext.d.ts +4 -0
  4. package/dist/api/apiContext.js +17 -0
  5. package/dist/api/types.d.ts +168 -0
  6. package/dist/api/types.js +3 -0
  7. package/dist/api/workflowsApi.d.ts +109 -0
  8. package/dist/api/workflowsApi.js +657 -0
  9. package/dist/components/Workflows.svelte +131 -0
  10. package/dist/components/Workflows.svelte.d.ts +4 -0
  11. package/dist/components/WorkflowsEmptyState.svelte +32 -0
  12. package/dist/components/WorkflowsEmptyState.svelte.d.ts +7 -0
  13. package/dist/components/WorkflowsHeader.svelte +14 -0
  14. package/dist/components/WorkflowsHeader.svelte.d.ts +18 -0
  15. package/dist/components/WorkflowsWorkspace.svelte +87 -0
  16. package/dist/components/WorkflowsWorkspace.svelte.d.ts +14 -0
  17. package/dist/components/canvas/AddBlockMenu.svelte +101 -0
  18. package/dist/components/canvas/AddBlockMenu.svelte.d.ts +5 -0
  19. package/dist/components/canvas/CanvasToolbar.svelte +95 -0
  20. package/dist/components/canvas/CanvasToolbar.svelte.d.ts +9 -0
  21. package/dist/components/canvas/CompositionNodeView.svelte +125 -0
  22. package/dist/components/canvas/CompositionNodeView.svelte.d.ts +5 -0
  23. package/dist/components/canvas/ConditionNodeView.svelte +95 -0
  24. package/dist/components/canvas/ConditionNodeView.svelte.d.ts +5 -0
  25. package/dist/components/canvas/HandlePoint.svelte +32 -0
  26. package/dist/components/canvas/HandlePoint.svelte.d.ts +14 -0
  27. package/dist/components/canvas/TriggerNodeView.svelte +75 -0
  28. package/dist/components/canvas/TriggerNodeView.svelte.d.ts +5 -0
  29. package/dist/components/canvas/WorkflowCanvas.svelte +380 -0
  30. package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +25 -0
  31. package/dist/components/canvas/WorkflowEdgeView.svelte +58 -0
  32. package/dist/components/canvas/WorkflowEdgeView.svelte.d.ts +4 -0
  33. package/dist/components/editor/EditorBanners.svelte +143 -0
  34. package/dist/components/editor/EditorBanners.svelte.d.ts +7 -0
  35. package/dist/components/editor/EditorCanvasArea.svelte +85 -0
  36. package/dist/components/editor/EditorCanvasArea.svelte.d.ts +3 -0
  37. package/dist/components/editor/EditorTabs.svelte +81 -0
  38. package/dist/components/editor/EditorTabs.svelte.d.ts +7 -0
  39. package/dist/components/editor/EditorTopBar.svelte +132 -0
  40. package/dist/components/editor/EditorTopBar.svelte.d.ts +9 -0
  41. package/dist/components/editor/RunsTab.svelte +256 -0
  42. package/dist/components/editor/RunsTab.svelte.d.ts +3 -0
  43. package/dist/components/editor/SettingsTab.svelte +180 -0
  44. package/dist/components/editor/SettingsTab.svelte.d.ts +7 -0
  45. package/dist/components/editor/WorkflowEditor.svelte +185 -0
  46. package/dist/components/editor/WorkflowEditor.svelte.d.ts +15 -0
  47. package/dist/components/index.d.ts +1 -0
  48. package/dist/components/index.js +1 -0
  49. package/dist/components/list/CreateWorkflowDialog.svelte +89 -0
  50. package/dist/components/list/CreateWorkflowDialog.svelte.d.ts +9 -0
  51. package/dist/components/list/WorkflowList.svelte +204 -0
  52. package/dist/components/list/WorkflowList.svelte.d.ts +12 -0
  53. package/dist/components/list/WorkflowRow.svelte +191 -0
  54. package/dist/components/list/WorkflowRow.svelte.d.ts +10 -0
  55. package/dist/components/panel/BlockProblems.svelte +47 -0
  56. package/dist/components/panel/BlockProblems.svelte.d.ts +6 -0
  57. package/dist/components/panel/CompositionForm.svelte +127 -0
  58. package/dist/components/panel/CompositionForm.svelte.d.ts +7 -0
  59. package/dist/components/panel/CompositionPicker.svelte +179 -0
  60. package/dist/components/panel/CompositionPicker.svelte.d.ts +14 -0
  61. package/dist/components/panel/ConditionForm.svelte +105 -0
  62. package/dist/components/panel/ConditionForm.svelte.d.ts +7 -0
  63. package/dist/components/panel/EventValueRow.svelte +85 -0
  64. package/dist/components/panel/EventValueRow.svelte.d.ts +12 -0
  65. package/dist/components/panel/NextStepSelect.svelte +70 -0
  66. package/dist/components/panel/NextStepSelect.svelte.d.ts +12 -0
  67. package/dist/components/panel/ProblemsList.svelte +101 -0
  68. package/dist/components/panel/ProblemsList.svelte.d.ts +3 -0
  69. package/dist/components/panel/RuleCard.svelte +191 -0
  70. package/dist/components/panel/RuleCard.svelte.d.ts +13 -0
  71. package/dist/components/panel/SidePanel.svelte +82 -0
  72. package/dist/components/panel/SidePanel.svelte.d.ts +3 -0
  73. package/dist/components/panel/TestRow.svelte +150 -0
  74. package/dist/components/panel/TestRow.svelte.d.ts +15 -0
  75. package/dist/components/panel/TestRunPanel.svelte +85 -0
  76. package/dist/components/panel/TestRunPanel.svelte.d.ts +3 -0
  77. package/dist/components/panel/TestTriggerCard.svelte +121 -0
  78. package/dist/components/panel/TestTriggerCard.svelte.d.ts +7 -0
  79. package/dist/components/panel/TriggerForm.svelte +385 -0
  80. package/dist/components/panel/TriggerForm.svelte.d.ts +7 -0
  81. package/dist/components/panel/VersionHistory.svelte +123 -0
  82. package/dist/components/panel/VersionHistory.svelte.d.ts +3 -0
  83. package/dist/components/ui/ActionButton.svelte +85 -0
  84. package/dist/components/ui/ActionButton.svelte.d.ts +27 -0
  85. package/dist/components/ui/ConfirmDialog.svelte +52 -0
  86. package/dist/components/ui/ConfirmDialog.svelte.d.ts +16 -0
  87. package/dist/components/ui/Icon.svelte +32 -0
  88. package/dist/components/ui/Icon.svelte.d.ts +9 -0
  89. package/dist/components/ui/Menu.svelte +211 -0
  90. package/dist/components/ui/Menu.svelte.d.ts +21 -0
  91. package/dist/components/ui/Modal.svelte +129 -0
  92. package/dist/components/ui/Modal.svelte.d.ts +13 -0
  93. package/dist/components/ui/Notice.svelte +36 -0
  94. package/dist/components/ui/Notice.svelte.d.ts +11 -0
  95. package/dist/components/ui/SelectField.svelte +74 -0
  96. package/dist/components/ui/SelectField.svelte.d.ts +16 -0
  97. package/dist/components/ui/StatusBadge.svelte +41 -0
  98. package/dist/components/ui/StatusBadge.svelte.d.ts +9 -0
  99. package/dist/components/ui/TextField.svelte +97 -0
  100. package/dist/components/ui/TextField.svelte.d.ts +29 -0
  101. package/dist/components/ui/icons.d.ts +34 -0
  102. package/dist/components/ui/icons.js +54 -0
  103. package/dist/components/ui/types.d.ts +26 -0
  104. package/dist/components/ui/types.js +1 -0
  105. package/dist/editor/apiErrorText.d.ts +10 -0
  106. package/dist/editor/apiErrorText.js +53 -0
  107. package/dist/editor/autosave.d.ts +47 -0
  108. package/dist/editor/autosave.js +119 -0
  109. package/dist/editor/blockLabels.d.ts +91 -0
  110. package/dist/editor/blockLabels.js +196 -0
  111. package/dist/editor/canvasContext.d.ts +52 -0
  112. package/dist/editor/canvasContext.js +37 -0
  113. package/dist/editor/canvasWords.d.ts +24 -0
  114. package/dist/editor/canvasWords.js +40 -0
  115. package/dist/editor/capabilityModel.d.ts +46 -0
  116. package/dist/editor/capabilityModel.js +113 -0
  117. package/dist/editor/editorState.svelte.d.ts +220 -0
  118. package/dist/editor/editorState.svelte.js +713 -0
  119. package/dist/editor/flowAdapter.d.ts +59 -0
  120. package/dist/editor/flowAdapter.js +166 -0
  121. package/dist/editor/formatCount.d.ts +5 -0
  122. package/dist/editor/formatCount.js +15 -0
  123. package/dist/editor/graphDiff.d.ts +27 -0
  124. package/dist/editor/graphDiff.js +64 -0
  125. package/dist/editor/graphModel.d.ts +154 -0
  126. package/dist/editor/graphModel.js +457 -0
  127. package/dist/editor/issueText.d.ts +64 -0
  128. package/dist/editor/issueText.js +101 -0
  129. package/dist/editor/listState.svelte.d.ts +82 -0
  130. package/dist/editor/listState.svelte.js +250 -0
  131. package/dist/editor/statsRange.d.ts +26 -0
  132. package/dist/editor/statsRange.js +41 -0
  133. package/dist/editor/testRun.d.ts +36 -0
  134. package/dist/editor/testRun.js +74 -0
  135. package/dist/editor/zonedTime.d.ts +20 -0
  136. package/dist/editor/zonedTime.js +134 -0
  137. package/dist/i18n/index.d.ts +2 -0
  138. package/dist/i18n/index.js +2 -0
  139. package/dist/i18n/language.d.ts +22 -0
  140. package/dist/i18n/language.js +34 -0
  141. package/dist/i18n/messages.d.ts +423 -0
  142. package/dist/i18n/messages.js +446 -0
  143. package/dist/index.d.ts +4 -0
  144. package/dist/index.js +5 -0
  145. package/dist/types/index.d.ts +66 -0
  146. package/dist/types/index.js +1 -0
  147. package/dist/utils/logger.d.ts +4 -0
  148. package/dist/utils/logger.js +35 -0
  149. package/package.json +103 -5
@@ -0,0 +1,109 @@
1
+ import type { IssueCode, ValidationIssue, WorkflowGraph } from '@widgetic/workflows-engine';
2
+ import { type AccessTokenFunction, type CompositionOption, type CompositionOptionList, type CompositionOptionsQuery, type WorkflowDetail, type WorkflowList, type WorkflowListItem, type WorkflowListQuery, type WorkflowPublishResult, type WorkflowStateAction, type WorkflowStats, type WorkflowStatsQuery, type WorkflowVersion, type WorkflowVersionDetail } from './types.js';
3
+ /** How long a request may take before it is given up: the reads, and the writes (a publish reads every composition). */
4
+ export declare const READ_TIMEOUT_MS = 15000;
5
+ export declare const WRITE_TIMEOUT_MS = 30000;
6
+ /** What went wrong with a request, as far as the screens care. */
7
+ export declare class WorkflowsApiError extends Error {
8
+ /** The HTTP status; null when no answer came (offline, blocked by the page's policy, too slow, a token that could not be had). */
9
+ readonly status: number | null;
10
+ /**
11
+ * The API's error code (`BUSINESS_STATE_CONFLICT`, `AUTHZ_PLAN_RESTRICTION`...), or the screen's own: `NETWORK_ERROR`,
12
+ * `TIMEOUT`, `TOKEN_UNAVAILABLE`, `INVALID_RESPONSE`, or `HTTP_<status>` when the answer carried no code.
13
+ */
14
+ readonly code: string;
15
+ /** What the API said besides (`reason`, `currentRevision`, `issues`...), as it came; null when it said nothing more. */
16
+ readonly details: Record<string, unknown> | null;
17
+ constructor(message: string, details: {
18
+ status: number | null;
19
+ code: string;
20
+ details?: Record<string, unknown> | null;
21
+ cause?: unknown;
22
+ });
23
+ /** The person's session is over: the API refused the token, and the fresh one too. */
24
+ get sessionEnded(): boolean;
25
+ /** The account's plan does not include workflows. */
26
+ get planRestricted(): boolean;
27
+ /** The workflow, version or composition is not there (any more). */
28
+ get notFound(): boolean;
29
+ /** Somebody saved the draft since this screen read it: the screen reloads, it never overwrites. */
30
+ get revisionChanged(): boolean;
31
+ /** The revision the draft is at now, when the API said (a refused save or publish). */
32
+ get currentRevision(): number | null;
33
+ /** Why a 409 was refused (`revision_changed`, `nothing_to_publish`, `nothing_to_discard`, `workflow_archived`, `wrong_state`). */
34
+ get conflictReason(): string | null;
35
+ /** What stopped a publish (422) or a save of a document the engine cannot read (400): the blocks to fix. */
36
+ get issues(): ValidationIssue[];
37
+ }
38
+ /** Whether an error is a request that was cancelled on purpose (the screen was taken down). */
39
+ export declare function isCancelled(error: unknown): boolean;
40
+ export interface WorkflowsApiOptions {
41
+ /** The Widgetic API origin, without `/v1` (the module's `apiUrl`). */
42
+ apiUrl: string;
43
+ /** `personal`, or an organization id. */
44
+ workspaceId: string;
45
+ getAccessToken: AccessTokenFunction;
46
+ /** For tests. The page's `fetch` by default. */
47
+ fetchImplementation?: typeof fetch;
48
+ /** For tests. */
49
+ readTimeoutMs?: number;
50
+ writeTimeoutMs?: number;
51
+ }
52
+ export interface RequestOptions {
53
+ signal?: AbortSignal;
54
+ }
55
+ /** The writes that must not happen twice when an answer is lost. */
56
+ export interface RetryableRequestOptions extends RequestOptions {
57
+ /**
58
+ * The key that makes a retry of this request safe: the same key replays the answer of a request that was made. Made
59
+ * when left out.
60
+ */
61
+ idempotencyKey?: string;
62
+ }
63
+ export interface WorkflowsApi {
64
+ listWorkflows(query?: WorkflowListQuery, options?: RequestOptions): Promise<WorkflowList>;
65
+ createWorkflow(input: {
66
+ name: string;
67
+ compositionId?: string | null;
68
+ timezone?: string | null;
69
+ }, options?: RetryableRequestOptions): Promise<WorkflowDetail>;
70
+ getWorkflow(workflowId: string, options?: RequestOptions): Promise<WorkflowDetail>;
71
+ /** Saves the draft; answers the workflow's list entry with the new revision. */
72
+ saveDraft(workflowId: string, input: {
73
+ revision: number;
74
+ name?: string;
75
+ timezone?: string;
76
+ graph?: WorkflowGraph;
77
+ }, options?: RequestOptions): Promise<WorkflowListItem>;
78
+ deleteWorkflow(workflowId: string, options?: RequestOptions): Promise<void>;
79
+ duplicateWorkflow(workflowId: string, options?: RetryableRequestOptions): Promise<WorkflowDetail>;
80
+ publishWorkflow(workflowId: string, revision: number, options?: RetryableRequestOptions): Promise<WorkflowPublishResult>;
81
+ discardChanges(workflowId: string, revision: number, options?: RequestOptions): Promise<WorkflowDetail>;
82
+ listVersions(workflowId: string, options?: RequestOptions): Promise<WorkflowVersion[]>;
83
+ getVersion(workflowId: string, versionId: string, options?: RequestOptions): Promise<WorkflowVersionDetail>;
84
+ restoreVersion(workflowId: string, versionId: string, revision: number, options?: RequestOptions): Promise<WorkflowDetail>;
85
+ changeState(workflowId: string, action: WorkflowStateAction, options?: RequestOptions): Promise<WorkflowListItem>;
86
+ getStats(workflowId: string, query?: WorkflowStatsQuery, options?: RequestOptions): Promise<WorkflowStats>;
87
+ listCompositionOptions(query?: CompositionOptionsQuery, options?: RequestOptions): Promise<CompositionOptionList>;
88
+ }
89
+ /** A key the gateway accepts as an `Idempotency-Key` (`^[A-Za-z0-9_-]{8,50}$`). */
90
+ export declare function makeIdempotencyKey(): string;
91
+ /** One workflow of the list (or the same fields of a workflow in full). */
92
+ export declare function readWorkflowListItem(data: unknown): WorkflowListItem;
93
+ export declare function readWorkflowVersion(data: unknown): WorkflowVersion;
94
+ export declare function readWorkflowVersionDetail(data: unknown): WorkflowVersionDetail;
95
+ export declare function readWorkflowDetail(data: unknown): WorkflowDetail;
96
+ /** The address of a thumbnail, when it is one an `<img>` should be given: http or https, nothing else. */
97
+ export declare function usableImageUrl(value: unknown): string | null;
98
+ /**
99
+ * One composition the editor can offer. What a composition cannot do reads as "not enabled" and never as an error: the
100
+ * capability model is the API's, and an answer that left a part out is treated as "this composition cannot do that".
101
+ */
102
+ export declare function readCompositionOption(data: unknown): CompositionOption;
103
+ /** The query string of the list: only what was asked for. */
104
+ export declare function buildListQueryString(query: WorkflowListQuery | undefined): string;
105
+ export declare function buildCompositionOptionsQueryString(query: CompositionOptionsQuery | undefined): string;
106
+ /** Makes the client of one screen: one workspace, one way to get a token. */
107
+ export declare function createWorkflowsApi(options: WorkflowsApiOptions): WorkflowsApi;
108
+ /** The engine's issue codes a screen can say; re-exported so a screen imports one place. */
109
+ export type { IssueCode };