@rippling/rippling-sdk 0.2.0-alpha.104 → 0.2.0-alpha.106
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/client.d.mts +12 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +12 -0
- package/client.d.ts.map +1 -1
- package/client.js +12 -0
- package/client.js.map +1 -1
- package/client.mjs +12 -0
- package/client.mjs.map +1 -1
- package/lib/charts/builders.d.mts +43 -0
- package/lib/charts/builders.d.mts.map +1 -0
- package/lib/charts/builders.d.ts +43 -0
- package/lib/charts/builders.d.ts.map +1 -0
- package/lib/charts/builders.js +77 -0
- package/lib/charts/builders.js.map +1 -0
- package/lib/charts/builders.mjs +70 -0
- package/lib/charts/builders.mjs.map +1 -0
- package/lib/charts/describe.d.mts +12 -0
- package/lib/charts/describe.d.mts.map +1 -0
- package/lib/charts/describe.d.ts +12 -0
- package/lib/charts/describe.d.ts.map +1 -0
- package/lib/charts/describe.js +64 -0
- package/lib/charts/describe.js.map +1 -0
- package/lib/charts/describe.mjs +61 -0
- package/lib/charts/describe.mjs.map +1 -0
- package/lib/charts/errors.d.mts +35 -0
- package/lib/charts/errors.d.mts.map +1 -0
- package/lib/charts/errors.d.ts +35 -0
- package/lib/charts/errors.d.ts.map +1 -0
- package/lib/charts/errors.js +55 -0
- package/lib/charts/errors.js.map +1 -0
- package/lib/charts/errors.mjs +47 -0
- package/lib/charts/errors.mjs.map +1 -0
- package/lib/charts/evaluate.d.mts +16 -0
- package/lib/charts/evaluate.d.mts.map +1 -0
- package/lib/charts/evaluate.d.ts +16 -0
- package/lib/charts/evaluate.d.ts.map +1 -0
- package/lib/charts/evaluate.js +99 -0
- package/lib/charts/evaluate.js.map +1 -0
- package/lib/charts/evaluate.mjs +96 -0
- package/lib/charts/evaluate.mjs.map +1 -0
- package/lib/charts/guards.d.mts +15 -0
- package/lib/charts/guards.d.mts.map +1 -0
- package/lib/charts/guards.d.ts +15 -0
- package/lib/charts/guards.d.ts.map +1 -0
- package/lib/charts/guards.js +38 -0
- package/lib/charts/guards.js.map +1 -0
- package/lib/charts/guards.mjs +34 -0
- package/lib/charts/guards.mjs.map +1 -0
- package/lib/charts/schema.d.mts +101 -0
- package/lib/charts/schema.d.mts.map +1 -0
- package/lib/charts/schema.d.ts +101 -0
- package/lib/charts/schema.d.ts.map +1 -0
- package/lib/charts/schema.js +74 -0
- package/lib/charts/schema.js.map +1 -0
- package/lib/charts/schema.mjs +71 -0
- package/lib/charts/schema.mjs.map +1 -0
- package/lib/charts/types.d.mts +79 -0
- package/lib/charts/types.d.mts.map +1 -0
- package/lib/charts/types.d.ts +79 -0
- package/lib/charts/types.d.ts.map +1 -0
- package/lib/charts/types.js +25 -0
- package/lib/charts/types.js.map +1 -0
- package/lib/charts/types.mjs +22 -0
- package/lib/charts/types.mjs.map +1 -0
- package/lib/charts.d.mts +7 -0
- package/lib/charts.d.mts.map +1 -0
- package/lib/charts.d.ts +7 -0
- package/lib/charts.d.ts.map +1 -0
- package/lib/charts.js +32 -0
- package/lib/charts.js.map +1 -0
- package/lib/charts.mjs +7 -0
- package/lib/charts.mjs.map +1 -0
- package/lib/manifest/_existing-component-fields.d.mts.map +1 -1
- package/lib/manifest/_existing-component-fields.d.ts.map +1 -1
- package/lib/manifest/_existing-component-fields.js +2 -0
- package/lib/manifest/_existing-component-fields.js.map +1 -1
- package/lib/manifest/_existing-component-fields.mjs +2 -0
- package/lib/manifest/_existing-component-fields.mjs.map +1 -1
- package/lib/manifest/existing-manifest-context.d.mts +3 -0
- package/lib/manifest/existing-manifest-context.d.mts.map +1 -1
- package/lib/manifest/existing-manifest-context.d.ts +3 -0
- package/lib/manifest/existing-manifest-context.d.ts.map +1 -1
- package/lib/manifest/existing-manifest-context.js +14 -0
- package/lib/manifest/existing-manifest-context.js.map +1 -1
- package/lib/manifest/existing-manifest-context.mjs +14 -0
- package/lib/manifest/existing-manifest-context.mjs.map +1 -1
- package/lib/manifest/workflow/index.d.mts +4 -0
- package/lib/manifest/workflow/index.d.mts.map +1 -1
- package/lib/manifest/workflow/index.d.ts +4 -0
- package/lib/manifest/workflow/index.d.ts.map +1 -1
- package/lib/manifest/workflow/index.js +49 -0
- package/lib/manifest/workflow/index.js.map +1 -1
- package/lib/manifest/workflow/index.mjs +49 -0
- package/lib/manifest/workflow/index.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/activity-log.d.mts +517 -0
- package/resources/activity-log.d.mts.map +1 -0
- package/resources/activity-log.d.ts +517 -0
- package/resources/activity-log.d.ts.map +1 -0
- package/resources/activity-log.js +171 -0
- package/resources/activity-log.js.map +1 -0
- package/resources/activity-log.mjs +167 -0
- package/resources/activity-log.mjs.map +1 -0
- package/resources/compensations.d.mts +1 -1
- package/resources/compensations.d.ts +1 -1
- package/resources/compensations.js +1 -1
- package/resources/compensations.mjs +1 -1
- package/resources/developer-program-application.d.mts +1 -1
- package/resources/developer-program-application.d.ts +1 -1
- package/resources/developer-program-application.js +1 -1
- package/resources/developer-program-application.mjs +1 -1
- package/resources/developer-users.d.mts +2 -1
- package/resources/developer-users.d.mts.map +1 -1
- package/resources/developer-users.d.ts +2 -1
- package/resources/developer-users.d.ts.map +1 -1
- package/resources/developer-users.js +2 -1
- package/resources/developer-users.js.map +1 -1
- package/resources/developer-users.mjs +2 -1
- package/resources/developer-users.mjs.map +1 -1
- package/resources/hire-requirements.d.mts +8 -74
- package/resources/hire-requirements.d.mts.map +1 -1
- package/resources/hire-requirements.d.ts +8 -74
- package/resources/hire-requirements.d.ts.map +1 -1
- package/resources/hire-requirements.js +3 -19
- package/resources/hire-requirements.js.map +1 -1
- package/resources/hire-requirements.mjs +3 -19
- package/resources/hire-requirements.mjs.map +1 -1
- package/resources/hires.d.mts +677 -142
- package/resources/hires.d.mts.map +1 -1
- package/resources/hires.d.ts +677 -142
- package/resources/hires.d.ts.map +1 -1
- package/resources/hires.js +3 -4
- package/resources/hires.js.map +1 -1
- package/resources/hires.mjs +3 -4
- package/resources/hires.mjs.map +1 -1
- package/resources/index.d.mts +2 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +7 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -0
- package/resources/index.mjs.map +1 -1
- package/resources/listing-submissions.d.mts +1 -1
- package/resources/listing-submissions.d.ts +1 -1
- package/resources/listing-submissions.js +1 -1
- package/resources/listing-submissions.mjs +1 -1
- package/resources/listing-transitions.d.mts +1 -1
- package/resources/listing-transitions.d.ts +1 -1
- package/resources/listing-transitions.js +1 -1
- package/resources/listing-transitions.mjs +1 -1
- package/resources/listing.d.mts +1 -1
- package/resources/listing.d.ts +1 -1
- package/resources/listing.js +1 -1
- package/resources/listing.mjs +1 -1
- package/resources/payroll-payment-mode-changes.d.mts +102 -0
- package/resources/payroll-payment-mode-changes.d.mts.map +1 -0
- package/resources/payroll-payment-mode-changes.d.ts +102 -0
- package/resources/payroll-payment-mode-changes.d.ts.map +1 -0
- package/resources/payroll-payment-mode-changes.js +54 -0
- package/resources/payroll-payment-mode-changes.js.map +1 -0
- package/resources/payroll-payment-mode-changes.mjs +50 -0
- package/resources/payroll-payment-mode-changes.mjs.map +1 -0
- package/resources/payroll-runs/index.d.mts +1 -0
- package/resources/payroll-runs/index.d.mts.map +1 -1
- package/resources/payroll-runs/index.d.ts +1 -0
- package/resources/payroll-runs/index.d.ts.map +1 -1
- package/resources/payroll-runs/index.js +3 -1
- package/resources/payroll-runs/index.js.map +1 -1
- package/resources/payroll-runs/index.mjs +1 -0
- package/resources/payroll-runs/index.mjs.map +1 -1
- package/resources/payroll-runs/off-cycle.d.mts +322 -0
- package/resources/payroll-runs/off-cycle.d.mts.map +1 -0
- package/resources/payroll-runs/off-cycle.d.ts +322 -0
- package/resources/payroll-runs/off-cycle.d.ts.map +1 -0
- package/resources/payroll-runs/off-cycle.js +112 -0
- package/resources/payroll-runs/off-cycle.js.map +1 -0
- package/resources/payroll-runs/off-cycle.mjs +108 -0
- package/resources/payroll-runs/off-cycle.mjs.map +1 -0
- package/resources/payroll-runs/payroll-runs.d.mts +4 -0
- package/resources/payroll-runs/payroll-runs.d.mts.map +1 -1
- package/resources/payroll-runs/payroll-runs.d.ts +4 -0
- package/resources/payroll-runs/payroll-runs.d.ts.map +1 -1
- package/resources/payroll-runs/payroll-runs.js +4 -0
- package/resources/payroll-runs/payroll-runs.js.map +1 -1
- package/resources/payroll-runs/payroll-runs.mjs +4 -0
- package/resources/payroll-runs/payroll-runs.mjs.map +1 -1
- package/resources/sandboxes.d.mts +17 -11
- package/resources/sandboxes.d.mts.map +1 -1
- package/resources/sandboxes.d.ts +17 -11
- package/resources/sandboxes.d.ts.map +1 -1
- package/resources/sandboxes.js +1 -3
- package/resources/sandboxes.js.map +1 -1
- package/resources/sandboxes.mjs +1 -3
- package/resources/sandboxes.mjs.map +1 -1
- package/resources/variable-compensation-payout-labels.d.mts +3 -2
- package/resources/variable-compensation-payout-labels.d.mts.map +1 -1
- package/resources/variable-compensation-payout-labels.d.ts +3 -2
- package/resources/variable-compensation-payout-labels.d.ts.map +1 -1
- package/resources/variable-compensation-payout-labels.js +3 -2
- package/resources/variable-compensation-payout-labels.js.map +1 -1
- package/resources/variable-compensation-payout-labels.mjs +3 -2
- package/resources/variable-compensation-payout-labels.mjs.map +1 -1
- package/resources/variable-compensation-payout-types.d.mts +2 -2
- package/resources/variable-compensation-payout-types.d.ts +2 -2
- package/resources/variable-compensation-payout-types.js +2 -2
- package/resources/variable-compensation-payout-types.mjs +2 -2
- package/resources/variable-compensation-payouts.d.mts +5 -2
- package/resources/variable-compensation-payouts.d.mts.map +1 -1
- package/resources/variable-compensation-payouts.d.ts +5 -2
- package/resources/variable-compensation-payouts.d.ts.map +1 -1
- package/resources/variable-compensation-payouts.js +5 -2
- package/resources/variable-compensation-payouts.js.map +1 -1
- package/resources/variable-compensation-payouts.mjs +5 -2
- package/resources/variable-compensation-payouts.mjs.map +1 -1
- package/src/client.ts +38 -0
- package/src/lib/charts/README.md +114 -0
- package/src/lib/charts/builders.ts +90 -0
- package/src/lib/charts/describe.ts +67 -0
- package/src/lib/charts/errors.ts +48 -0
- package/src/lib/charts/evaluate.ts +114 -0
- package/src/lib/charts/guards.ts +42 -0
- package/src/lib/charts/schema.ts +72 -0
- package/src/lib/charts/types.ts +113 -0
- package/src/lib/charts.ts +43 -0
- package/src/lib/manifest/_existing-component-fields.ts +2 -0
- package/src/lib/manifest/existing-manifest-context.ts +22 -0
- package/src/lib/manifest/workflow/index.ts +64 -0
- package/src/resources/activity-log.ts +645 -0
- package/src/resources/compensations.ts +1 -1
- package/src/resources/developer-program-application.ts +1 -1
- package/src/resources/developer-users.ts +2 -1
- package/src/resources/hire-requirements.ts +8 -85
- package/src/resources/hires.ts +866 -213
- package/src/resources/index.ts +13 -0
- package/src/resources/listing-submissions.ts +1 -1
- package/src/resources/listing-transitions.ts +1 -1
- package/src/resources/listing.ts +1 -1
- package/src/resources/payroll-payment-mode-changes.ts +121 -0
- package/src/resources/payroll-runs/index.ts +1 -0
- package/src/resources/payroll-runs/off-cycle.ts +372 -0
- package/src/resources/payroll-runs/payroll-runs.ts +10 -0
- package/src/resources/sandboxes.ts +17 -11
- package/src/resources/variable-compensation-payout-labels.ts +3 -2
- package/src/resources/variable-compensation-payout-types.ts +2 -2
- package/src/resources/variable-compensation-payouts.ts +5 -2
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chart rule vocabulary — shared types.
|
|
3
|
+
*
|
|
4
|
+
* A rule is a small, serializable tree of nodes discriminated by `kind`. The
|
|
5
|
+
* agent builds it with the helpers in `builders.ts`, which emit it wrapped in a
|
|
6
|
+
* `{$rule}` placeholder — the same idea as the `{$fn}` placeholders a chart
|
|
7
|
+
* already emits. The renderer resolves it with `evaluate`; the settings panel
|
|
8
|
+
* reads it with `describe`. All three agree because a node can only ever be one
|
|
9
|
+
* of the kinds defined here — the closed set the `chartRuleSchema` describes.
|
|
10
|
+
*
|
|
11
|
+
* v1 is scoped to conditional formatting: compare this datum's `value` against a
|
|
12
|
+
* constant, and (optionally) pick between two values. Richer pieces — aggregates,
|
|
13
|
+
* logic, more refs — are the documented roadmap in the README.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const CHART_RULE_CONTRACT_VERSION = 'chart_rule.v1' as const;
|
|
17
|
+
export type ChartRuleContractVersion = typeof CHART_RULE_CONTRACT_VERSION;
|
|
18
|
+
|
|
19
|
+
/** A leaf value a rule can carry or resolve to. */
|
|
20
|
+
export type Scalar = number | string | boolean | null;
|
|
21
|
+
|
|
22
|
+
/* -------------------------------------------------------------------------- */
|
|
23
|
+
/* Nodes — the closed set, discriminated by `kind`. Each appears in every face. */
|
|
24
|
+
/* -------------------------------------------------------------------------- */
|
|
25
|
+
|
|
26
|
+
/** Reads a value out of the evaluation context — this datum's plotted value. */
|
|
27
|
+
export type RefNode = { kind: 'value' };
|
|
28
|
+
|
|
29
|
+
export interface LiteralNode {
|
|
30
|
+
kind: 'literal';
|
|
31
|
+
value: Scalar;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ComparisonKind =
|
|
35
|
+
| 'equals'
|
|
36
|
+
| 'isNot'
|
|
37
|
+
| 'lessThan'
|
|
38
|
+
| 'greaterThan'
|
|
39
|
+
| 'lessOrEqual'
|
|
40
|
+
| 'greaterOrEqual';
|
|
41
|
+
export interface ComparisonNode {
|
|
42
|
+
kind: ComparisonKind;
|
|
43
|
+
left: RuleNode;
|
|
44
|
+
right: RuleNode;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The conditional-value form produced by `when(cond, then, else)`. */
|
|
48
|
+
export interface IfElseNode {
|
|
49
|
+
kind: 'ifElse';
|
|
50
|
+
cond: RuleNode;
|
|
51
|
+
then: RuleNode;
|
|
52
|
+
else: RuleNode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Any node of a rule tree. */
|
|
56
|
+
export type RuleNode = RefNode | LiteralNode | ComparisonNode | IfElseNode;
|
|
57
|
+
|
|
58
|
+
/* -------------------------------------------------------------------------- */
|
|
59
|
+
/* The placeholder — how a rule is embedded in a chart option (like {$fn}). */
|
|
60
|
+
/* -------------------------------------------------------------------------- */
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The chart channel a rule drives. v1 supports colour only — a rule decides the
|
|
64
|
+
* colour of a series/datum. Other channels (opacity, label visibility, …) are
|
|
65
|
+
* the documented roadmap and would be added here.
|
|
66
|
+
*/
|
|
67
|
+
export type RuleChannel = 'color';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* What a builder returns: a rule tree, marked so the renderer can find it, and
|
|
71
|
+
* tagged with the channel it targets. `channel: 'color'` says this resolves to a
|
|
72
|
+
* colour — so a reader sees the target without inferring it from where it sits.
|
|
73
|
+
*/
|
|
74
|
+
export interface RulePlaceholder {
|
|
75
|
+
$rule: RuleNode;
|
|
76
|
+
channel: RuleChannel;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A placeholder, or the bare tree — what `evaluate` and `describe` accept. */
|
|
80
|
+
export type Rule = RulePlaceholder | RuleNode;
|
|
81
|
+
|
|
82
|
+
/* -------------------------------------------------------------------------- */
|
|
83
|
+
/* Evaluation */
|
|
84
|
+
/* -------------------------------------------------------------------------- */
|
|
85
|
+
|
|
86
|
+
/** What a rule is evaluated against: the current datum's value. */
|
|
87
|
+
export interface RuleContext {
|
|
88
|
+
value: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The result of evaluating a node. */
|
|
92
|
+
export type RuleValue = Scalar;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The deepest a rule may nest before `evaluate`/`describe` refuse it. Real rules
|
|
96
|
+
* are a handful of levels; this only stops a pathological deserialized tree from
|
|
97
|
+
* overflowing the stack. Far below the JS call-stack limit.
|
|
98
|
+
*/
|
|
99
|
+
export const MAX_RULE_DEPTH = 256;
|
|
100
|
+
|
|
101
|
+
/* -------------------------------------------------------------------------- */
|
|
102
|
+
/* Description — what the settings panel renders */
|
|
103
|
+
/* -------------------------------------------------------------------------- */
|
|
104
|
+
|
|
105
|
+
export type ControlRole = 'rule' | 'comparison' | 'ref' | 'literal';
|
|
106
|
+
|
|
107
|
+
/** A node as the panel should show it: a label, its editable value, its parts. */
|
|
108
|
+
export interface Control {
|
|
109
|
+
role: ControlRole;
|
|
110
|
+
label: string;
|
|
111
|
+
value?: Scalar;
|
|
112
|
+
parts?: Control[];
|
|
113
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export {
|
|
2
|
+
color,
|
|
3
|
+
equals,
|
|
4
|
+
greaterOrEqual,
|
|
5
|
+
greaterThan,
|
|
6
|
+
isNot,
|
|
7
|
+
isRulePlaceholder,
|
|
8
|
+
lessOrEqual,
|
|
9
|
+
lessThan,
|
|
10
|
+
literal,
|
|
11
|
+
value,
|
|
12
|
+
when,
|
|
13
|
+
type Operand,
|
|
14
|
+
} from './charts/builders';
|
|
15
|
+
export { evaluate } from './charts/evaluate';
|
|
16
|
+
export { describe } from './charts/describe';
|
|
17
|
+
export { chartRuleSchema, CHART_RULE_SCHEMA_ID } from './charts/schema';
|
|
18
|
+
export {
|
|
19
|
+
ChartRuleError,
|
|
20
|
+
MalformedRuleError,
|
|
21
|
+
RuleDepthError,
|
|
22
|
+
RuleTypeError,
|
|
23
|
+
UnknownNodeError,
|
|
24
|
+
} from './charts/errors';
|
|
25
|
+
export {
|
|
26
|
+
CHART_RULE_CONTRACT_VERSION,
|
|
27
|
+
MAX_RULE_DEPTH,
|
|
28
|
+
type ChartRuleContractVersion,
|
|
29
|
+
type ComparisonKind,
|
|
30
|
+
type ComparisonNode,
|
|
31
|
+
type Control,
|
|
32
|
+
type ControlRole,
|
|
33
|
+
type IfElseNode,
|
|
34
|
+
type LiteralNode,
|
|
35
|
+
type RefNode,
|
|
36
|
+
type Rule,
|
|
37
|
+
type RuleChannel,
|
|
38
|
+
type RuleContext,
|
|
39
|
+
type RuleNode,
|
|
40
|
+
type RulePlaceholder,
|
|
41
|
+
type RuleValue,
|
|
42
|
+
type Scalar,
|
|
43
|
+
} from './charts/types';
|
|
@@ -13,6 +13,8 @@ function labelComponent(componentType: string, component: Record<string, any>):
|
|
|
13
13
|
component['source_agent_id'] ??
|
|
14
14
|
component['field_api_name'] ??
|
|
15
15
|
component['section_id'] ??
|
|
16
|
+
component['definition_id'] ??
|
|
17
|
+
component['obj_id'] ??
|
|
16
18
|
'unknown';
|
|
17
19
|
return `${componentType}:${String(id)}`;
|
|
18
20
|
}
|
|
@@ -16,6 +16,7 @@ import { ManifestFunction } from './manifest-function';
|
|
|
16
16
|
import { Rule } from './rule';
|
|
17
17
|
import { SduiPage } from './sdui-page';
|
|
18
18
|
import { Validation } from './validation';
|
|
19
|
+
import { Workflow } from './workflow';
|
|
19
20
|
import {
|
|
20
21
|
optionalStringComponentField,
|
|
21
22
|
requireObjectComponentField,
|
|
@@ -92,6 +93,8 @@ function componentLabel(component: Record<string, any>): string {
|
|
|
92
93
|
component['source_skill_id'] ??
|
|
93
94
|
component['field_api_name'] ??
|
|
94
95
|
component['section_id'] ??
|
|
96
|
+
component['definition_id'] ??
|
|
97
|
+
component['obj_id'] ??
|
|
95
98
|
'unknown';
|
|
96
99
|
return `${type}:${id}`;
|
|
97
100
|
}
|
|
@@ -355,6 +358,15 @@ export class ExistingManifestContext {
|
|
|
355
358
|
return this.loadACPAgentComponent(component);
|
|
356
359
|
}
|
|
357
360
|
|
|
361
|
+
loadWorkflow(definitionId: string): Workflow {
|
|
362
|
+
const component = this.findUnique(
|
|
363
|
+
'WORKFLOW_DEFINITION',
|
|
364
|
+
(candidate) => candidate['definition_id'] === definitionId,
|
|
365
|
+
`WORKFLOW_DEFINITION ${definitionId}`,
|
|
366
|
+
);
|
|
367
|
+
return this.loadWorkflowComponent(component);
|
|
368
|
+
}
|
|
369
|
+
|
|
358
370
|
private loadComponent(component: Record<string, any>): unknown {
|
|
359
371
|
switch (component['type']) {
|
|
360
372
|
case 'AGENT':
|
|
@@ -391,6 +403,8 @@ export class ExistingManifestContext {
|
|
|
391
403
|
return this.loadSduiPageComponent(component);
|
|
392
404
|
case 'CUSTOM_APP':
|
|
393
405
|
return this.loadAppComponent(component);
|
|
406
|
+
case 'WORKFLOW_DEFINITION':
|
|
407
|
+
return this.loadWorkflowComponent(component);
|
|
394
408
|
default:
|
|
395
409
|
return this.loadRawComponent(component);
|
|
396
410
|
}
|
|
@@ -626,6 +640,14 @@ export class ExistingManifestContext {
|
|
|
626
640
|
);
|
|
627
641
|
}
|
|
628
642
|
|
|
643
|
+
private loadWorkflowComponent(component: Record<string, any>): Workflow {
|
|
644
|
+
const definitionId = requireStringComponentField(component, 'definition_id', Workflow.componentType);
|
|
645
|
+
const cacheKey = this.cacheKey('WORKFLOW_DEFINITION', definitionId);
|
|
646
|
+
return this.getOrLoad(cacheKey, () =>
|
|
647
|
+
Workflow._fromExistingComponent(this.getManifestBuilder(), component),
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
|
|
629
651
|
private loadRawComponent(component: Record<string, any>): ExistingRawComponent {
|
|
630
652
|
const index = this.componentIndexes.get(component) ?? -1;
|
|
631
653
|
const cacheKey = this.cacheKey('RAW', `${index}:${componentLabel(component)}`);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { generateId } from '../_helpers';
|
|
2
2
|
import type { BusinessEventKey } from '../business-event';
|
|
3
|
+
import { requireObjectComponentField, requireStringComponentField } from '../_existing-component-fields';
|
|
4
|
+
import {
|
|
5
|
+
getExistingManifestContext,
|
|
6
|
+
type ExistingManifestContextOptions,
|
|
7
|
+
} from '../existing-manifest-context';
|
|
3
8
|
import type { ManifestFunction } from '../manifest-function';
|
|
4
9
|
import type { ManifestComponentDeletion, ManifestScope } from '../manifest-builder';
|
|
5
10
|
import type { WorkflowActionPayloads } from './actions';
|
|
@@ -473,6 +478,11 @@ export interface WorkflowProps {
|
|
|
473
478
|
categories?: WorkflowCategory[];
|
|
474
479
|
}
|
|
475
480
|
|
|
481
|
+
function cloneJson<T>(value: T): T {
|
|
482
|
+
if (value == null) return value;
|
|
483
|
+
return JSON.parse(JSON.stringify(value)) as T;
|
|
484
|
+
}
|
|
485
|
+
|
|
476
486
|
function assertNonEmptyString(value: unknown, path: string): void {
|
|
477
487
|
if (typeof value !== 'string' || !value.trim()) throw new Error(`${path} is required.`);
|
|
478
488
|
}
|
|
@@ -882,6 +892,60 @@ export class Workflow {
|
|
|
882
892
|
scope._register(this);
|
|
883
893
|
}
|
|
884
894
|
|
|
895
|
+
static loadFromExisting(definitionId: string, options: ExistingManifestContextOptions = {}): Workflow {
|
|
896
|
+
return getExistingManifestContext(options).loadWorkflow(definitionId);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/** @internal Hydrates a workflow from existing manifest wire JSON. */
|
|
900
|
+
static _fromExistingComponent(scope: ManifestScope, component: Record<string, any>): Workflow {
|
|
901
|
+
const workflowMeta = requireObjectComponentField(component, 'workflow_meta', Workflow.componentType);
|
|
902
|
+
const definitionId = requireStringComponentField(component, 'definition_id', Workflow.componentType);
|
|
903
|
+
const props: WorkflowProps = {
|
|
904
|
+
definitionId,
|
|
905
|
+
title: requireStringComponentField(
|
|
906
|
+
{ definition_id: definitionId, name: workflowMeta['name'] },
|
|
907
|
+
'name',
|
|
908
|
+
Workflow.componentType,
|
|
909
|
+
),
|
|
910
|
+
trigger: cloneJson(
|
|
911
|
+
requireObjectComponentField(component, 'trigger', Workflow.componentType),
|
|
912
|
+
) as WorkflowTrigger,
|
|
913
|
+
};
|
|
914
|
+
if (typeof workflowMeta['description'] === 'string') props.description = workflowMeta['description'];
|
|
915
|
+
if (typeof workflowMeta['recipe_id'] === 'string') props.recipeId = workflowMeta['recipe_id'];
|
|
916
|
+
if (typeof component['function_api_name'] === 'string') {
|
|
917
|
+
props.function = component['function_api_name'];
|
|
918
|
+
}
|
|
919
|
+
if (typeof component['version_status'] === 'string') {
|
|
920
|
+
props.versionStatus = component['version_status'] as WorkflowVersionStatus;
|
|
921
|
+
}
|
|
922
|
+
if (typeof component['trigger_status'] === 'string') {
|
|
923
|
+
props.triggerStatus = component['trigger_status'] as WorkflowTriggerStatus;
|
|
924
|
+
}
|
|
925
|
+
if (component['graph'] != null) {
|
|
926
|
+
props.graph = cloneJson(component['graph']) as WorkflowGraph;
|
|
927
|
+
}
|
|
928
|
+
if (component['functions_inferred_graph'] != null) {
|
|
929
|
+
props.functionsInferredGraph = cloneJson(component['functions_inferred_graph']) as WorkflowGraph;
|
|
930
|
+
}
|
|
931
|
+
if (component['custom_variables'] != null) {
|
|
932
|
+
props.customVariables = cloneJson(component['custom_variables']) as Record<
|
|
933
|
+
string,
|
|
934
|
+
WorkflowCustomVariable
|
|
935
|
+
>;
|
|
936
|
+
}
|
|
937
|
+
if (component['function_api_names_by_old_id'] != null) {
|
|
938
|
+
props.functionApiNamesByOldId = cloneJson(component['function_api_names_by_old_id']) as Record<
|
|
939
|
+
string,
|
|
940
|
+
string
|
|
941
|
+
>;
|
|
942
|
+
}
|
|
943
|
+
if (component['categories'] != null) {
|
|
944
|
+
props.categories = cloneJson(component['categories']) as WorkflowCategory[];
|
|
945
|
+
}
|
|
946
|
+
return new Workflow(scope, props);
|
|
947
|
+
}
|
|
948
|
+
|
|
885
949
|
private _validate(): void {
|
|
886
950
|
assertNonEmptyString(this._title, 'Workflow.workflow_meta.name');
|
|
887
951
|
if (this._props.function !== undefined)
|