@elementumai/edk 0.11.0 → 0.13.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 +40 -6
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +2 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
- package/dist-sdk/src/core/triggers/on-demand.js +3 -0
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +5 -0
- package/dist-sdk/src/engine/coverage-gaps.js +9 -0
- package/dist-sdk/src/engine/ei/run.d.ts +20 -1
- package/dist-sdk/src/engine/ei/run.js +102 -14
- package/dist-sdk/src/engine/pull/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +10 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +22 -0
- package/dist-sdk/src/engine/pull/ref-only.js +59 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +148 -0
- package/dist-sdk/src/engine/pull/stream-root.js +563 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +9 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +25 -4
- package/dist-sdk/src/entities/access-policy/module.js +5 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -0
- package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
- package/dist-sdk/src/entities/agent/from-tf.js +262 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
- package/dist-sdk/src/entities/agent/to-tf.js +158 -14
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +34 -14
- package/dist-sdk/src/entities/app/build.js +93 -16
- package/dist-sdk/src/entities/app/from-tf.js +25 -11
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +20 -5
- package/dist-sdk/src/entities/app/stage-keys.js +43 -9
- package/dist-sdk/src/entities/app/to-tf.js +2 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.d.ts +50 -24
- package/dist-sdk/src/entities/automation/build.js +86 -33
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +52 -8
- package/dist-sdk/src/entities/automation/from-tf.d.ts +38 -6
- package/dist-sdk/src/entities/automation/from-tf.js +855 -157
- package/dist-sdk/src/entities/automation/index.d.ts +2 -1
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +33 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/run-target.d.ts +2 -0
- package/dist-sdk/src/entities/automation/run-target.js +5 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +2 -1
- package/dist-sdk/src/entities/automation/script-code.js +82 -1
- package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
- package/dist-sdk/src/entities/automation/script-lint.js +418 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +12 -1
- package/dist-sdk/src/entities/automation/task-output-labels.js +32 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +76 -18
- package/dist-sdk/src/entities/automation/tasks.js +52 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/automation/to-tf.js +585 -97
- package/dist-sdk/src/entities/automation/triggers.d.ts +48 -23
- package/dist-sdk/src/entities/automation/triggers.js +27 -12
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +18 -2
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +28 -1
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/printer.js +5 -2
- package/dist-sdk/src/entities/chart/to-tf.js +38 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +45 -6
- package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.js +15 -2
- package/dist-sdk/src/entities/element/module.js +3 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +2 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +29 -1
- package/dist-sdk/src/entities/field/from-tf.js +99 -6
- package/dist-sdk/src/entities/field/module.js +12 -2
- package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
- package/dist-sdk/src/entities/field/to-tf.js +90 -46
- package/dist-sdk/src/entities/org/category.js +1 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/role.js +5 -0
- package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +7 -2
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +9 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
- package/dist-sdk/src/entities/shared/filters/index.js +18 -6
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.js +9 -5
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
- package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +2 -1
- package/dist-sdk/src/entities/task/to-tf.js +1 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +8 -4
- package/dist-sdk/src/entities/view/from-tf.js +10 -9
- package/dist-sdk/src/entities/view/module.js +5 -0
- package/dist-sdk/src/entities/widget/from-tf.js +15 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +51 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +20 -2
- package/dist-sdk/src/graph/index.js +19 -0
- package/dist-sdk/src/graph/modules.js +11 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +116 -6
- package/package.json +6 -3
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { type ApprovalProcessRef, type CatalogRef, type FieldRef } from "../../catalog/index.js";
|
|
2
2
|
import { type UnsafePlatformId } from "../../core/platform-id.js";
|
|
3
3
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
4
|
+
import { type ApprovalStep } from "./steps.js";
|
|
4
5
|
type AppOwner = CatalogRef<"app">;
|
|
5
|
-
type
|
|
6
|
+
type ElementOwner = CatalogRef<"element">;
|
|
7
|
+
/** The app or element that owns an approval process (edk#373). */
|
|
8
|
+
type ApprovalOwner = AppOwner | ElementOwner;
|
|
9
|
+
type OwnedField<Owner extends ApprovalOwner> = Owner extends {
|
|
6
10
|
readonly fields: infer Fields;
|
|
7
|
-
} ? Fields extends Readonly<Record<string, FieldRef>> ? Fields[keyof Fields] : FieldRef<
|
|
11
|
+
} ? Fields extends Readonly<Record<string, FieldRef>> ? Fields[keyof Fields] : FieldRef<Owner["refName"]> : FieldRef<Owner["refName"]>;
|
|
8
12
|
export interface UnsafeApprovalStageId {
|
|
9
13
|
readonly __unsafe: "approvalStageId";
|
|
10
14
|
readonly value: string;
|
|
11
15
|
}
|
|
12
16
|
/** Explicit escape hatch used only when pull cannot recover a portable stage key. */
|
|
13
17
|
export declare function unsafeApprovalStageId(value: string): UnsafeApprovalStageId;
|
|
14
|
-
interface DefineApprovalProcessBase<
|
|
15
|
-
/** The app that owns this approval process. */
|
|
16
|
-
readonly app: App;
|
|
18
|
+
interface DefineApprovalProcessBase<Owner extends ApprovalOwner> extends EntityDeployOptions {
|
|
17
19
|
readonly name: string;
|
|
18
20
|
readonly numberOfDynamicApprovers: number;
|
|
19
21
|
readonly managedByAutomation?: boolean;
|
|
@@ -28,19 +30,52 @@ interface DefineApprovalProcessBase<App extends AppOwner> extends EntityDeployOp
|
|
|
28
30
|
* Pull uses `unsafePlatformId(...)` only when the platform export contains a
|
|
29
31
|
* system-field UUID that cannot be reconstructed as a portable catalog ref.
|
|
30
32
|
*/
|
|
31
|
-
readonly lockedFields?: readonly (OwnedField<
|
|
33
|
+
readonly lockedFields?: readonly (OwnedField<Owner> | UnsafePlatformId)[];
|
|
34
|
+
/**
|
|
35
|
+
* Whether the process is a dynamic chain (edk#373). Only a dynamic chain
|
|
36
|
+
* takes `priorityGroup` steps. Chosen at create: changing it replaces the
|
|
37
|
+
* approval process. Omit to keep the live value.
|
|
38
|
+
*/
|
|
39
|
+
readonly dynamicChain?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The approver steps, in order (edk#373): `userStep`, `groupStep`,
|
|
42
|
+
* `dynamicEmployeeStep`, `resolvedQueryStep` and `priorityGroup`. Omit to
|
|
43
|
+
* leave the live steps unmanaged; `[]` removes every step.
|
|
44
|
+
*/
|
|
45
|
+
readonly steps?: readonly ApprovalStep[];
|
|
46
|
+
/**
|
|
47
|
+
* App fields that approval preconditions may filter on (edk#2657; the web
|
|
48
|
+
* app's Table filter columns). Omit to leave the live columns unmanaged;
|
|
49
|
+
* `[]` clears them. When both `steps` and `tableFilterColumns` are set,
|
|
50
|
+
* every `when` filter field must appear in the list.
|
|
51
|
+
*/
|
|
52
|
+
readonly tableFilterColumns?: readonly (OwnedField<Owner> | UnsafePlatformId)[];
|
|
32
53
|
}
|
|
33
|
-
|
|
54
|
+
/** An app owns the approval process; it may sit on one of the app's stages. */
|
|
55
|
+
type AppOwned<Owner extends ApprovalOwner> = {
|
|
56
|
+
/** The app that owns this approval process. */
|
|
57
|
+
readonly app: Owner;
|
|
58
|
+
readonly element?: never;
|
|
59
|
+
} & ({
|
|
34
60
|
readonly stage?: string;
|
|
35
61
|
readonly unsafeStageId?: never;
|
|
36
62
|
} | {
|
|
37
63
|
readonly stage?: never;
|
|
38
64
|
readonly unsafeStageId: UnsafeApprovalStageId;
|
|
39
65
|
});
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
/** An element owns the approval process. Elements have no stages. */
|
|
67
|
+
interface ElementOwned<Owner extends ApprovalOwner> {
|
|
68
|
+
/** The element that owns this approval process; each element record gets its own approvals. */
|
|
69
|
+
readonly element: Owner;
|
|
70
|
+
readonly app?: never;
|
|
71
|
+
readonly stage?: never;
|
|
72
|
+
readonly unsafeStageId?: never;
|
|
73
|
+
}
|
|
74
|
+
export type DefineApprovalProcessOptions<Owner extends ApprovalOwner = ApprovalOwner> = DefineApprovalProcessBase<Owner> & (Owner extends ElementOwner ? ElementOwned<Owner> : AppOwned<Owner>);
|
|
75
|
+
export interface ApprovalProcessConfigured<Owner extends ApprovalOwner = ApprovalOwner> {
|
|
76
|
+
ref<const RefName extends string>(refName: RefName): ApprovalProcessRef<Owner["refName"], RefName>;
|
|
42
77
|
def(refName: string): DeployableEntity;
|
|
43
78
|
}
|
|
44
|
-
/** Define an
|
|
45
|
-
export declare function approvalProcess<
|
|
79
|
+
/** Define an approval process owned by an app or an element, using the provider's dynamic-approver contract. */
|
|
80
|
+
export declare function approvalProcess<Owner extends ApprovalOwner>(opts: DefineApprovalProcessOptions<Owner>): ApprovalProcessConfigured<Owner>;
|
|
46
81
|
export {};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
|
|
2
2
|
import { slimTokens, } from "../../catalog/index.js";
|
|
3
3
|
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
4
|
+
import { validateApprovalSteps } from "./steps.js";
|
|
4
5
|
/** Explicit escape hatch used only when pull cannot recover a portable stage key. */
|
|
5
6
|
export function unsafeApprovalStageId(value) {
|
|
6
7
|
if (value.trim() === "")
|
|
7
8
|
throw new EdkValidationError("unsafeApprovalStageId requires a non-empty platform id.");
|
|
8
9
|
return { __unsafe: "approvalStageId", value };
|
|
9
10
|
}
|
|
10
|
-
/** Define an
|
|
11
|
+
/** Define an approval process owned by an app or an element, using the provider's dynamic-approver contract. */
|
|
11
12
|
export function approvalProcess(opts) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const owner = approvalOwner(opts);
|
|
14
|
+
if (opts.steps !== undefined)
|
|
15
|
+
validateApprovalSteps(opts.steps, opts.dynamicChain === true);
|
|
15
16
|
if (opts.name.trim() === "")
|
|
16
17
|
throw new EdkValidationError("approvalProcess requires a non-empty name.");
|
|
17
18
|
if (!Number.isInteger(opts.numberOfDynamicApprovers) || opts.numberOfDynamicApprovers < 0) {
|
|
@@ -20,9 +21,24 @@ export function approvalProcess(opts) {
|
|
|
20
21
|
for (const field of opts.lockedFields ?? []) {
|
|
21
22
|
if (isUnsafePlatformId(field))
|
|
22
23
|
continue;
|
|
23
|
-
if (field.parent !==
|
|
24
|
-
throw new EdkValidationError(`approvalProcess locked field ${JSON.stringify(field.refName)} belongs to ${JSON.stringify(field.parent)}, not
|
|
24
|
+
if (field.parent !== owner.refName) {
|
|
25
|
+
throw new EdkValidationError(`approvalProcess locked field ${JSON.stringify(field.refName)} belongs to ${JSON.stringify(field.parent)}, not ${owner.__kind} ${JSON.stringify(owner.refName)}.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const tableFilterKeys = new Set();
|
|
29
|
+
for (const field of opts.tableFilterColumns ?? []) {
|
|
30
|
+
if (isUnsafePlatformId(field)) {
|
|
31
|
+
tableFilterKeys.add(`id:${field.value}`);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (field.parent !== owner.refName) {
|
|
35
|
+
throw new EdkValidationError(`approvalProcess tableFilterColumns field ${JSON.stringify(field.refName)} belongs to ${JSON.stringify(field.parent)}, not ${owner.__kind} ${JSON.stringify(owner.refName)}.`);
|
|
25
36
|
}
|
|
37
|
+
// Parent + bag key so another app's same-named field cannot satisfy the when check (edk#2841 S1).
|
|
38
|
+
tableFilterKeys.add(`key:${field.parent}:${field.refName}`);
|
|
39
|
+
}
|
|
40
|
+
if (opts.tableFilterColumns !== undefined && opts.steps !== undefined) {
|
|
41
|
+
validateWhenFieldsInTableFilters(opts.steps, tableFilterKeys);
|
|
26
42
|
}
|
|
27
43
|
const payload = slimTokens({
|
|
28
44
|
name: opts.name,
|
|
@@ -36,20 +52,25 @@ export function approvalProcess(opts) {
|
|
|
36
52
|
approveButton: opts.approveButton ?? "Approve",
|
|
37
53
|
...(opts.exceptionButton !== undefined ? { exceptionButton: opts.exceptionButton } : {}),
|
|
38
54
|
...(opts.lockedFields !== undefined ? { lockedFieldIds: opts.lockedFields } : {}),
|
|
55
|
+
...(opts.dynamicChain !== undefined ? { dynamicChain: opts.dynamicChain } : {}),
|
|
56
|
+
...(opts.tableFilterColumns !== undefined ? { tableFilterFieldIds: opts.tableFilterColumns } : {}),
|
|
39
57
|
});
|
|
58
|
+
// Filters stay unslimmed, as on SLA targets: the filter codec reads full field tokens.
|
|
59
|
+
if (opts.steps !== undefined)
|
|
60
|
+
payload["steps"] = opts.steps.map(wireStep);
|
|
40
61
|
return {
|
|
41
62
|
ref(refName) {
|
|
42
63
|
return {
|
|
43
64
|
__kind: "approvalChain",
|
|
44
65
|
refName,
|
|
45
66
|
name: opts.name,
|
|
46
|
-
parent:
|
|
67
|
+
parent: owner.refName,
|
|
47
68
|
};
|
|
48
69
|
},
|
|
49
70
|
def(refName) {
|
|
50
71
|
return {
|
|
51
72
|
kind: "approvalChain",
|
|
52
|
-
parent:
|
|
73
|
+
parent: owner.refName,
|
|
53
74
|
refName,
|
|
54
75
|
payload,
|
|
55
76
|
...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}),
|
|
@@ -57,3 +78,94 @@ export function approvalProcess(opts) {
|
|
|
57
78
|
},
|
|
58
79
|
};
|
|
59
80
|
}
|
|
81
|
+
/** A step as payload wire: group tokens slimmed to their catalog identity. */
|
|
82
|
+
function wireStep(step) {
|
|
83
|
+
if (step.kind !== "priorityGroup")
|
|
84
|
+
return wireApprover(step);
|
|
85
|
+
return { ...step, conditionals: step.conditionals.map((c) => ({ ...c, approver: wireApprover(c.approver) })) };
|
|
86
|
+
}
|
|
87
|
+
function wireApprover(approver) {
|
|
88
|
+
if (approver.kind === "group")
|
|
89
|
+
return { ...approver, group: { __kind: "group", refName: approver.group.refName, name: approver.group.name } };
|
|
90
|
+
return approver;
|
|
91
|
+
}
|
|
92
|
+
/** The owner the options name: exactly one app or element, and no stage on an element. */
|
|
93
|
+
function approvalOwner(opts) {
|
|
94
|
+
if (opts.app !== undefined && opts.element !== undefined) {
|
|
95
|
+
throw new EdkValidationError("approvalProcess takes exactly one owner: app or element, not both.");
|
|
96
|
+
}
|
|
97
|
+
if (opts.element !== undefined) {
|
|
98
|
+
if (opts.element.__kind !== "element")
|
|
99
|
+
throw new EdkValidationError("approvalProcess element must be an element catalog reference.");
|
|
100
|
+
if (opts.stage !== undefined || opts.unsafeStageId !== undefined) {
|
|
101
|
+
throw new EdkValidationError("approvalProcess on an element takes no stage; elements have no stages.");
|
|
102
|
+
}
|
|
103
|
+
return opts.element;
|
|
104
|
+
}
|
|
105
|
+
if (opts.app === undefined || opts.app.__kind !== "app") {
|
|
106
|
+
throw new EdkValidationError("approvalProcess requires an owner: an app or an element catalog reference.");
|
|
107
|
+
}
|
|
108
|
+
return opts.app;
|
|
109
|
+
}
|
|
110
|
+
/** Every priority-group `when` field must be listed in tableFilterColumns (edk#2657 / #2841 S1). */
|
|
111
|
+
function validateWhenFieldsInTableFilters(steps, allowed) {
|
|
112
|
+
steps.forEach((step, index) => {
|
|
113
|
+
if (step.kind !== "priorityGroup")
|
|
114
|
+
return;
|
|
115
|
+
step.conditionals.forEach((conditional, conditionalIndex) => {
|
|
116
|
+
if (conditional.when === undefined)
|
|
117
|
+
return;
|
|
118
|
+
for (const field of filterFieldTokens(conditional.when)) {
|
|
119
|
+
const key = whenFieldKey(field, index, conditionalIndex);
|
|
120
|
+
if (!allowed.has(key)) {
|
|
121
|
+
// AppField / unsafe ids are lowered to plain id strings before this
|
|
122
|
+
// check (edk#2841 N-B); tell authors to use catalog field tokens so
|
|
123
|
+
// the key can match tableFilterColumns' parent+refName keys.
|
|
124
|
+
if (key.startsWith("id:")) {
|
|
125
|
+
throw new EdkValidationError(`approvalProcess steps[${index}] conditionals[${conditionalIndex}].when references a platform field id (${JSON.stringify(key.slice(3))}) that cannot be matched to tableFilterColumns; author the when with a catalog field token (catalog.<app>.fields.<key>).`);
|
|
126
|
+
}
|
|
127
|
+
const label = key.startsWith("key:") ? key.slice(4) : key;
|
|
128
|
+
throw new EdkValidationError(`approvalProcess steps[${index}] conditionals[${conditionalIndex}].when references field ${JSON.stringify(label)} which is not in tableFilterColumns.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Key a `when` left-hand field the same way tableFilterColumns is keyed: owned
|
|
136
|
+
* fields by parent+refName, string / unsafePlatformId by id. Public eq/filter
|
|
137
|
+
* helpers wire unsafePlatformId and app fields to plain id strings first.
|
|
138
|
+
*/
|
|
139
|
+
function whenFieldKey(field, stepIndex, conditionalIndex) {
|
|
140
|
+
if (isUnsafePlatformId(field))
|
|
141
|
+
return `id:${field.value}`;
|
|
142
|
+
if (typeof field === "string" && field.trim() !== "")
|
|
143
|
+
return `id:${field}`;
|
|
144
|
+
if (typeof field === "object" && field !== null) {
|
|
145
|
+
const record = field;
|
|
146
|
+
if (typeof record.parent === "string" && typeof record.refName === "string") {
|
|
147
|
+
return `key:${record.parent}:${record.refName}`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
throw new EdkValidationError(`approvalProcess steps[${stepIndex}] conditionals[${conditionalIndex}].when names a field that cannot be matched to tableFilterColumns.`);
|
|
151
|
+
}
|
|
152
|
+
/** Collect field tokens named by a filter's `field`, FIELD `leftValue`, and nested children. */
|
|
153
|
+
function filterFieldTokens(node) {
|
|
154
|
+
if (node === null || typeof node !== "object")
|
|
155
|
+
return [];
|
|
156
|
+
const record = node;
|
|
157
|
+
const out = [];
|
|
158
|
+
if (record["field"] !== undefined)
|
|
159
|
+
out.push(record["field"]);
|
|
160
|
+
const left = record["leftValue"];
|
|
161
|
+
if (left !== null && typeof left === "object") {
|
|
162
|
+
const leftRecord = left;
|
|
163
|
+
if (leftRecord["type"] === "FIELD" && leftRecord["value"] !== undefined)
|
|
164
|
+
out.push(leftRecord["value"]);
|
|
165
|
+
}
|
|
166
|
+
if (Array.isArray(record["children"])) {
|
|
167
|
+
for (const child of record["children"])
|
|
168
|
+
out.push(...filterFieldTokens(child));
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
-
import { type TfBlock } from "../../engine/tf/index.js";
|
|
2
|
+
import { type ChildResourceScope, type TfBlock } from "../../engine/tf/index.js";
|
|
3
3
|
import { type StageHandleIndex } from "../app/stage-keys.js";
|
|
4
|
+
import { type PulledApprovalStep } from "./steps-tf.js";
|
|
4
5
|
export interface NormalizedApprovalChain {
|
|
5
6
|
readonly refName: string;
|
|
6
7
|
readonly name: string;
|
|
@@ -15,7 +16,28 @@ export interface NormalizedApprovalChain {
|
|
|
15
16
|
readonly summary?: string;
|
|
16
17
|
readonly lockedFields: readonly string[];
|
|
17
18
|
readonly unsafeLockedFieldIds?: readonly string[];
|
|
19
|
+
/** Only true is kept; a false or absent dynamic_chain is the default. */
|
|
20
|
+
readonly dynamicChain?: true;
|
|
21
|
+
/** The approver steps (edk#373); absent when the export left them out or they cannot be authored. */
|
|
22
|
+
readonly steps?: readonly PulledApprovalStep[];
|
|
23
|
+
/**
|
|
24
|
+
* App fields preconditions may filter on (edk#2657). Each entry is a
|
|
25
|
+
* portable field key or an unresolved platform id (ARCH-H5 / #2787).
|
|
26
|
+
* Absent when the export left them out or a column could not be authored
|
|
27
|
+
* (all-or-nothing). Kept as one list so mixed refs and `unsafePlatformId`
|
|
28
|
+
* stay interleaved (edk#2841 S-A); column *order* is non-authoritative
|
|
29
|
+
* (edk#2841 S2) — the platform may reorder on write.
|
|
30
|
+
*/
|
|
31
|
+
readonly tableFilterColumns?: readonly TableFilterColumnEntry[];
|
|
18
32
|
}
|
|
33
|
+
/** One table-filter column: portable key or unresolved id (order non-authoritative). */
|
|
34
|
+
export type TableFilterColumnEntry = {
|
|
35
|
+
readonly key: string;
|
|
36
|
+
readonly unsafeId?: never;
|
|
37
|
+
} | {
|
|
38
|
+
readonly unsafeId: string;
|
|
39
|
+
readonly key?: never;
|
|
40
|
+
};
|
|
19
41
|
/**
|
|
20
42
|
* The lost-stage warning when an approval process sits on a stage with no
|
|
21
43
|
* handle of its own (see `pulledStageHandle`, #1136), else undefined. Such a
|
|
@@ -23,4 +45,4 @@ export interface NormalizedApprovalChain {
|
|
|
23
45
|
* approval task or trigger) cannot be authored either.
|
|
24
46
|
*/
|
|
25
47
|
export declare function approvalChainLostStage(block: Pick<TfBlock, "type" | "label" | "attrs">, appTfLabel: string, stageHandles: StageHandleIndex | undefined): string | undefined;
|
|
26
|
-
export declare function approvalChainFromTf(block: TfBlock, appTfLabel: string, ctx: FromTfContext, stageHandles?: StageHandleIndex): NormalizedApprovalChain;
|
|
48
|
+
export declare function approvalChainFromTf(block: TfBlock, appTfLabel: string, ctx: FromTfContext, stageHandles?: StageHandleIndex, scope?: ChildResourceScope): NormalizedApprovalChain;
|
|
@@ -4,7 +4,8 @@ import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf
|
|
|
4
4
|
import { fieldKeyFromTfRef } from "../field/from-tf.js";
|
|
5
5
|
import { LostStageHandleError, lostStageMessage, pulledStageHandle } from "../app/stage-keys.js";
|
|
6
6
|
import { APPROVAL_PROCESS_RESOURCE_TYPE } from "./module.js";
|
|
7
|
-
|
|
7
|
+
import { approvalStepsFromTf } from "./steps-tf.js";
|
|
8
|
+
const KNOWN = new Set(["id", "app_id", "element_id", "name", "stage_id", "number_of_dynamic_approvers", "locked_field_ids", "managed_by_automation", "approve_button_text", "deny_button_text", "exception_button_text", "default_reason", "approval_summary", "dynamic_chain", "approvers", "table_filter_field_ids"]);
|
|
8
9
|
function stringAttr(attrs, key) { return typeof attrs[key] === "string" ? attrs[key] : undefined; }
|
|
9
10
|
/**
|
|
10
11
|
* The lost-stage warning when an approval process sits on a stage with no
|
|
@@ -22,14 +23,22 @@ export function approvalChainLostStage(block, appTfLabel, stageHandles) {
|
|
|
22
23
|
const pulled = pulledStageHandle(index.index, stageHandles);
|
|
23
24
|
return pulled.kind === "lost" ? lostStageMessage(`${block.type}.${block.label}`, index.index, pulled, "the approval chain is left unmanaged") : undefined;
|
|
24
25
|
}
|
|
25
|
-
export function approvalChainFromTf(block, appTfLabel, ctx, stageHandles) {
|
|
26
|
+
export function approvalChainFromTf(block, appTfLabel, ctx, stageHandles, scope = "app") {
|
|
26
27
|
if (block.type !== APPROVAL_PROCESS_RESOURCE_TYPE || block.label === undefined)
|
|
27
28
|
throw new EntityTfError(`expected ${APPROVAL_PROCESS_RESOURCE_TYPE}`);
|
|
28
29
|
for (const key of Object.keys(block.attrs))
|
|
29
30
|
if (!KNOWN.has(key))
|
|
30
31
|
throw new EntityTfError(`${block.type}.${block.label}: unknown attribute ${key}`);
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
// The owner (edk#373): app_id for an app stream, element_id for an element stream, never both.
|
|
33
|
+
const ownerAttr = scope === "element" ? "element_id" : "app_id";
|
|
34
|
+
const otherAttr = scope === "element" ? "app_id" : "element_id";
|
|
35
|
+
const ownerType = scope === "element" ? "elementum_element" : "elementum_app";
|
|
36
|
+
if (block.attrs[otherAttr] !== undefined)
|
|
37
|
+
throw new EntityTfError(`${block.type}.${block.label}: ${otherAttr} on a ${scope}-owned approval process`);
|
|
38
|
+
if (resourceRefLabel(block.attrs[ownerAttr], ownerType) !== appTfLabel)
|
|
39
|
+
throw new EntityTfError(`${block.type}.${block.label}: wrong ${ownerAttr}`);
|
|
40
|
+
if (scope === "element" && block.attrs["stage_id"] !== undefined)
|
|
41
|
+
throw new EntityTfError(`${block.type}.${block.label}: an element-owned approval process takes no stage_id`);
|
|
33
42
|
const name = stringAttr(block.attrs, "name");
|
|
34
43
|
const count = block.attrs["number_of_dynamic_approvers"];
|
|
35
44
|
const managed = block.attrs["managed_by_automation"];
|
|
@@ -74,7 +83,7 @@ export function approvalChainFromTf(block, appTfLabel, ctx, stageHandles) {
|
|
|
74
83
|
// Keep literal IDs literal even when state can identify the corresponding
|
|
75
84
|
// system field. Export deliberately avoids the owning app's computed
|
|
76
85
|
// `*_field_id` locals because they can be null during fresh import.
|
|
77
|
-
const key = fieldKeyFromTfRef(value, appTfLabel,
|
|
86
|
+
const key = fieldKeyFromTfRef(value, appTfLabel, scope);
|
|
78
87
|
if (key !== undefined) {
|
|
79
88
|
lockedFields.push(key);
|
|
80
89
|
continue;
|
|
@@ -86,8 +95,99 @@ export function approvalChainFromTf(block, appTfLabel, ctx, stageHandles) {
|
|
|
86
95
|
}
|
|
87
96
|
throw new EntityTfError(`${block.type}.${block.label}: locked field is not a local field reference or platform id`);
|
|
88
97
|
}
|
|
98
|
+
const dynamicChain = block.attrs["dynamic_chain"];
|
|
99
|
+
if (dynamicChain !== undefined && typeof dynamicChain !== "boolean")
|
|
100
|
+
throw new EntityTfError(`${block.type}.${block.label}: dynamic_chain must be a literal boolean`);
|
|
101
|
+
// Steps are all or nothing: authoring some of them would make the provider
|
|
102
|
+
// delete the rest, so any step that cannot be authored leaves every step
|
|
103
|
+
// unmanaged with a diagnostic (edk#373).
|
|
104
|
+
let steps;
|
|
105
|
+
if (block.attrs["approvers"] !== undefined) {
|
|
106
|
+
try {
|
|
107
|
+
steps = approvalStepsFromTf(block.attrs["approvers"], `${block.type}.${block.label}.approvers`, { appTfLabel, scope }, ctx);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
ctx.diagnostics.push(`${error instanceof Error ? error.message : String(error)}; the approver steps are left out and stay unmanaged`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Table filter columns are all or nothing (edk#2657): a single unresolvable
|
|
114
|
+
// field leaves the whole list unmanaged so apply does not clear the rest.
|
|
115
|
+
// Kept as one list (edk#2841 S-A) so mixed refs and unsafe ids stay
|
|
116
|
+
// interleaved; order itself is non-authoritative (edk#2841 S2).
|
|
117
|
+
let tableFilterColumns;
|
|
118
|
+
if (block.attrs["table_filter_field_ids"] !== undefined) {
|
|
119
|
+
const rawFilters = block.attrs["table_filter_field_ids"];
|
|
120
|
+
if (!Array.isArray(rawFilters))
|
|
121
|
+
throw new EntityTfError(`${block.type}.${block.label}: table_filter_field_ids must be a list`);
|
|
122
|
+
const entries = [];
|
|
123
|
+
let dropColumns = false;
|
|
124
|
+
// Classify every entry first (edk#2841 S2): only emit "preserved with
|
|
125
|
+
// unsafePlatformId" when the list is kept; otherwise the all-or-nothing
|
|
126
|
+
// unmanaged warning alone is accurate.
|
|
127
|
+
for (const value of rawFilters) {
|
|
128
|
+
const key = fieldKeyFromTfRef(value, appTfLabel, scope);
|
|
129
|
+
if (key !== undefined) {
|
|
130
|
+
entries.push({ key });
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
134
|
+
entries.push({ unsafeId: value });
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
dropColumns = true;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (dropColumns) {
|
|
141
|
+
ctx.diagnostics.push(`${block.type}.${block.label}: a table filter column could not be authored; tableFilterColumns are left out and stay unmanaged`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
for (const entry of entries) {
|
|
145
|
+
if (entry.unsafeId !== undefined) {
|
|
146
|
+
ctx.diagnostics.push(`${block.type}.${block.label}: table filter column ${entry.unsafeId} could not be resolved to a portable field reference; preserved with unsafePlatformId`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
tableFilterColumns = entries;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// S1 / r4519125639: when a pulled priority-group `when` is outside the
|
|
153
|
+
// columns, leave `steps` unset (same all-or-nothing as an unauthorable
|
|
154
|
+
// step) so pull never writes source `approvalProcess()` rejects; keep the
|
|
155
|
+
// warning. Match by owner+fieldKey or by id, not bag key alone.
|
|
156
|
+
if (tableFilterColumns !== undefined && steps !== undefined) {
|
|
157
|
+
const ownerRefName = tfLabelToTsLabel(appTfLabel);
|
|
158
|
+
const allowed = new Set();
|
|
159
|
+
for (const entry of tableFilterColumns) {
|
|
160
|
+
if (entry.key !== undefined)
|
|
161
|
+
allowed.add(`key:${ownerRefName}:${entry.key}`);
|
|
162
|
+
else if (entry.unsafeId !== undefined)
|
|
163
|
+
allowed.add(`id:${entry.unsafeId}`);
|
|
164
|
+
}
|
|
165
|
+
let dropSteps = false;
|
|
166
|
+
for (const [stepIndex, step] of steps.entries()) {
|
|
167
|
+
if (step.kind !== "priorityGroup")
|
|
168
|
+
continue;
|
|
169
|
+
for (const [conditionalIndex, conditional] of step.conditionals.entries()) {
|
|
170
|
+
if (conditional.when === undefined)
|
|
171
|
+
continue;
|
|
172
|
+
for (const field of pullWhenFieldTokens(conditional.when)) {
|
|
173
|
+
if (pullWhenFieldMatches(field, allowed))
|
|
174
|
+
continue;
|
|
175
|
+
const label = pullWhenFieldLabel(field);
|
|
176
|
+
if (label === undefined)
|
|
177
|
+
continue;
|
|
178
|
+
ctx.diagnostics.push(`${block.type}.${block.label}: steps[${stepIndex}] conditionals[${conditionalIndex}].when references field ${JSON.stringify(label)} which is not in tableFilterColumns; the approver steps are left out and stay unmanaged`);
|
|
179
|
+
dropSteps = true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (dropSteps)
|
|
184
|
+
steps = undefined;
|
|
185
|
+
}
|
|
89
186
|
return {
|
|
90
|
-
refName: scopedLabelToBagKey(appTfLabel, block.label,
|
|
187
|
+
refName: scopedLabelToBagKey(appTfLabel, block.label, scope), name,
|
|
188
|
+
...(dynamicChain === true && { dynamicChain: true }),
|
|
189
|
+
...(steps !== undefined && { steps }),
|
|
190
|
+
...(tableFilterColumns !== undefined && { tableFilterColumns }),
|
|
91
191
|
...(stage !== undefined && { stage }), ...(stageId !== undefined && { stageId }),
|
|
92
192
|
numberOfDynamicApprovers: count, managedByAutomation: managed, denyButton: deny, approveButton: approve,
|
|
93
193
|
lockedFields, unsafeLockedFieldIds,
|
|
@@ -96,3 +196,45 @@ export function approvalChainFromTf(block, appTfLabel, ctx, stageHandles) {
|
|
|
96
196
|
...(stringAttr(block.attrs, "approval_summary") !== undefined && { summary: stringAttr(block.attrs, "approval_summary") }),
|
|
97
197
|
};
|
|
98
198
|
}
|
|
199
|
+
/** Field tokens named by a pulled priority-group `when` filter (edk#2841 N-A). */
|
|
200
|
+
function pullWhenFieldTokens(node) {
|
|
201
|
+
if (node === null || typeof node !== "object")
|
|
202
|
+
return [];
|
|
203
|
+
const record = node;
|
|
204
|
+
const out = [];
|
|
205
|
+
if (record["field"] !== undefined)
|
|
206
|
+
out.push(record["field"]);
|
|
207
|
+
const left = record["leftValue"];
|
|
208
|
+
if (left !== null && typeof left === "object") {
|
|
209
|
+
const leftRecord = left;
|
|
210
|
+
if (leftRecord["type"] === "FIELD" && leftRecord["value"] !== undefined)
|
|
211
|
+
out.push(leftRecord["value"]);
|
|
212
|
+
}
|
|
213
|
+
if (Array.isArray(record["children"])) {
|
|
214
|
+
for (const child of record["children"])
|
|
215
|
+
out.push(...pullWhenFieldTokens(child));
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
function pullWhenFieldMatches(field, allowed) {
|
|
220
|
+
if (typeof field === "string" && field.trim() !== "")
|
|
221
|
+
return allowed.has(`id:${field}`);
|
|
222
|
+
if (typeof field === "object" && field !== null) {
|
|
223
|
+
const record = field;
|
|
224
|
+
if (record.kind === "field" && typeof record.fieldKey === "string" && typeof record.appHandle === "string") {
|
|
225
|
+
return allowed.has(`key:${record.appHandle}:${record.fieldKey}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return true; // unrecognized shapes: do not warn (build will surface them)
|
|
229
|
+
}
|
|
230
|
+
function pullWhenFieldLabel(field) {
|
|
231
|
+
if (typeof field === "string" && field.trim() !== "")
|
|
232
|
+
return field;
|
|
233
|
+
if (typeof field === "object" && field !== null) {
|
|
234
|
+
const record = field;
|
|
235
|
+
if (record.kind === "field" && typeof record.fieldKey === "string") {
|
|
236
|
+
return typeof record.appHandle === "string" ? `${record.appHandle}.${record.fieldKey}` : record.fieldKey;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Approval-process authoring.
|
|
2
|
+
* Approval-process authoring. Owned by an app or an element; the ordered
|
|
3
|
+
* approver steps (edk#373) are built with the step factories below.
|
|
3
4
|
* Standalone from v1's `src/approvalChains`.
|
|
4
5
|
*/
|
|
5
6
|
export { approvalProcess, unsafeApprovalStageId, type ApprovalProcessConfigured, type DefineApprovalProcessOptions, type UnsafeApprovalStageId, } from "./build.js";
|
|
7
|
+
export { dynamicEmployeeStep, groupStep, priorityGroup, resolvedQueryStep, runtimeGroup, runtimeUser, userStep, type ApprovalConditional, type ApprovalConditionalApprover, type ApprovalCounts, type ApprovalDynamicEmployeeStep, type ApprovalGroupStep, type ApprovalPriorityGroup, type ApprovalResolvedQueryStep, type ApprovalRuntimeGroup, type ApprovalRuntimeUser, type ApprovalStep, type ApprovalUserStep, } from "./steps.js";
|
|
8
|
+
export { userRef, type RoleUserRef as ApprovalUserRef } from "../role/build.js";
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Approval-process authoring.
|
|
2
|
+
* Approval-process authoring. Owned by an app or an element; the ordered
|
|
3
|
+
* approver steps (edk#373) are built with the step factories below.
|
|
3
4
|
* Standalone from v1's `src/approvalChains`.
|
|
4
5
|
*/
|
|
5
6
|
export { approvalProcess, unsafeApprovalStageId, } from "./build.js";
|
|
7
|
+
export { dynamicEmployeeStep, groupStep, priorityGroup, resolvedQueryStep, runtimeGroup, runtimeUser, userStep, } from "./steps.js";
|
|
8
|
+
export { userRef } from "../role/build.js";
|
|
@@ -28,10 +28,14 @@ function extract(blocks, _stream, ctx) {
|
|
|
28
28
|
const skipped = [];
|
|
29
29
|
const releaseIfManaged = [];
|
|
30
30
|
const diagnostics = [];
|
|
31
|
-
|
|
31
|
+
if (ctx.parentScope === "table")
|
|
32
|
+
return { items, skipped: blocks.map((block) => `${block.type}.${block.label ?? "?"}`), diagnostics: ["approval processes cannot belong to tables"] };
|
|
33
|
+
const scope = ctx.parentScope;
|
|
34
|
+
// Elements carry no stages (edk#373); an app's stage handles keep chains on their own stage (#1136).
|
|
35
|
+
const stageHandles = scope === "app" ? stageHandleIndexFromTfStages(ctx.resourceByAddress?.(`elementum_app.${ctx.appTfLabel}`)?.attrs["stages"]) : undefined;
|
|
32
36
|
for (const block of blocks) {
|
|
33
37
|
try {
|
|
34
|
-
items.push(approvalChainFromTf(block, ctx.appTfLabel, ctx, stageHandles));
|
|
38
|
+
items.push(approvalChainFromTf(block, ctx.appTfLabel, ctx, stageHandles, scope));
|
|
35
39
|
}
|
|
36
40
|
catch (error) {
|
|
37
41
|
const address = `${block.type}.${block.label ?? ""}`;
|
|
@@ -47,12 +51,26 @@ function extract(blocks, _stream, ctx) {
|
|
|
47
51
|
}
|
|
48
52
|
export const approvalChainModule = {
|
|
49
53
|
kind: "approval-chain", stream: { role: "streamMember" }, authoring: { unit: "ownFile", bag: "approval-chains" },
|
|
50
|
-
parents: [{ parent: "app", child: "approval-chain" }],
|
|
54
|
+
parents: [{ parent: "app", child: "approval-chain" }, { parent: "element", child: "approval-chain" }],
|
|
51
55
|
resource: { shape: "single", resourceType: APPROVAL_PROCESS_RESOURCE_TYPE, adoptable: true }, data: NO_DATA,
|
|
52
56
|
lifecycle: {
|
|
53
57
|
participates: true, extractOwnFile: extract,
|
|
54
|
-
printOwnFile: (item, opts) => {
|
|
55
|
-
|
|
58
|
+
printOwnFile: (item, opts) => {
|
|
59
|
+
if (opts.parentScope === "table")
|
|
60
|
+
throw new Error("approval processes cannot belong to tables");
|
|
61
|
+
const chain = item;
|
|
62
|
+
return { refName: chain.refName, source: printApprovalChain(chain, opts.appRefName, opts.parentScope, opts.orgImportPath) };
|
|
63
|
+
},
|
|
64
|
+
toTf: (entity, ctx) => {
|
|
65
|
+
if (ctx.parentScope === "table")
|
|
66
|
+
throw new Error("approval processes cannot belong to tables");
|
|
67
|
+
return approvalChainToTf(entity, {
|
|
68
|
+
appRefName: ctx.appRefName, appTfLabel: ctx.appTfLabel, parentScope: ctx.parentScope,
|
|
69
|
+
orgRefs: ctx.orgRefs, diagnostics: ctx.diagnostics,
|
|
70
|
+
...(ctx.fieldAddresses !== undefined && { fieldAddresses: ctx.fieldAddresses }),
|
|
71
|
+
...(ctx.parentScope !== "element" && { stageKeyByTfLabel: appStageKeyByHandle(ctx.streamRootEntity?.payload) }),
|
|
72
|
+
});
|
|
73
|
+
},
|
|
56
74
|
},
|
|
57
75
|
canvas: { participates: true, label: "Approval processes", glyph: "✓", component: "generic" },
|
|
58
76
|
catalog: { participates: true, refKind: "approvalChain", catalogBag: "approvalChains", renderOrder: 26, catalogRoot: "app", renderEntry: rootParentFactoryEntry("approvalChainRef"), stubRef: stub, refFromAuthoring },
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { NormalizedApprovalChain } from "./from-tf.js";
|
|
2
|
-
export declare function printApprovalChain(chain: NormalizedApprovalChain, appRefName: string): string;
|
|
2
|
+
export declare function printApprovalChain(chain: NormalizedApprovalChain, appRefName: string, parentScope?: "app" | "element", orgImportPath?: string): string;
|