@elementumai/edk 0.12.0 → 0.13.1
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 +8 -2
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +10 -2
- 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 +12 -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/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 +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +4 -0
- package/dist-sdk/src/engine/ei/run.d.ts +8 -0
- package/dist-sdk/src/engine/ei/run.js +46 -7
- 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 +34 -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 +4 -0
- package/dist-sdk/src/engine/pull/ref-only.js +7 -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 +159 -0
- package/dist-sdk/src/engine/pull/stream-root.js +579 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
- 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 +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +17 -5
- 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 +70 -1
- package/dist-sdk/src/entities/agent/from-tf.d.ts +36 -1
- package/dist-sdk/src/entities/agent/from-tf.js +289 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +11 -11
- package/dist-sdk/src/entities/agent/to-tf.js +179 -17
- 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 +33 -13
- package/dist-sdk/src/entities/app/build.js +14 -12
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +7 -9
- 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 +3 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
- package/dist-sdk/src/entities/app/stage-keys.js +3 -3
- package/dist-sdk/src/entities/app/to-tf.js +1 -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 +10 -1
- package/dist-sdk/src/entities/automation/build.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +21 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +665 -112
- 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 +45 -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/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/system-ref-name.d.ts +23 -3
- package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
- package/dist-sdk/src/entities/automation/tasks.js +34 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/automation/to-tf.js +563 -103
- package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
- package/dist-sdk/src/entities/automation/triggers.js +26 -11
- 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 +9 -1
- package/dist-sdk/src/entities/chart/from-tf.js +3 -0
- package/dist-sdk/src/entities/chart/to-tf.js +19 -2
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
- package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
- package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
- 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.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -7
- package/dist-sdk/src/entities/element/module.js +5 -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 +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +52 -1
- package/dist-sdk/src/entities/field/from-tf.js +212 -14
- package/dist-sdk/src/entities/field/module.js +4 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/field/to-tf.js +33 -12
- 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/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 +9 -4
- 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/build.d.ts +3 -4
- 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/search-table/build.d.ts +9 -3
- package/dist-sdk/src/entities/search-table/build.js +4 -4
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +4 -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-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/context.d.ts +14 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +97 -15
- package/dist-sdk/src/entities/shared/filters/index.js +30 -7
- 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.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/print.js +19 -6
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +16 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +25 -5
- package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
- 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.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +3 -2
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- 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 +3 -2
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +6 -4
- package/dist-sdk/src/entities/view/custom-view-validate.js +36 -18
- package/dist-sdk/src/entities/view/from-tf.js +16 -4
- package/dist-sdk/src/entities/view/to-tf.js +66 -47
- package/dist-sdk/src/entities/visual-flow/module.js +52 -1
- package/dist-sdk/src/entities/widget/from-tf.js +19 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +9 -0
- package/dist-sdk/src/graph/index.js +8 -0
- package/dist-sdk/src/graph/modules.js +13 -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 +113 -6
- package/package.json +7 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A raw option id where an option is selected (#1733). Dax, 2026-11-03: "both
|
|
3
|
+
* should be supported. Anything that references ids should warn and mention
|
|
4
|
+
* the preferred method". A raw id builds as written, and build warns with the
|
|
5
|
+
* `filter.textOption(label)` spelling, naming the label when it is known.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The warning for a plain string compared with a Dropdown or Multi-Select
|
|
9
|
+
* with static options (#1733). Dax, 2026-11-03: "1733: warn on plain-string
|
|
10
|
+
* dropdown filters and point to textOption". `resolvesLabels` says what the
|
|
11
|
+
* filter's owner does with a string that matches an option label: access
|
|
12
|
+
* policies, dashboards, relationships and dynamic layouts resolve it to the
|
|
13
|
+
* option id, while automations and views send the word as written. A raw
|
|
14
|
+
* option id gets {@link rawOptionIdWarning} instead.
|
|
15
|
+
*/
|
|
16
|
+
export function plainOptionStringWarning(slot, fieldName, value, options, resolvesLabels) {
|
|
17
|
+
const isLabel = options.includes(value);
|
|
18
|
+
const outcome = isLabel && resolvesLabels
|
|
19
|
+
? "Build resolves it to that option's id"
|
|
20
|
+
: `It is sent as the literal text ${JSON.stringify(value)}, not an option id`;
|
|
21
|
+
return `${slot} compares field "${fieldName}" with the plain string ${JSON.stringify(value)}. ` +
|
|
22
|
+
`${outcome}; the preferred form for an option is filter.textOption(${JSON.stringify(isLabel ? value : "<label>")})`;
|
|
23
|
+
}
|
|
24
|
+
/** The warning for a raw option id: its option's label, a deleted option, or an unknown label. */
|
|
25
|
+
export function rawOptionIdWarning(input) {
|
|
26
|
+
const { slot, fieldName, id, options, localName, index } = input;
|
|
27
|
+
const fieldIds = localName === undefined ? undefined : index?.idsByLocal.get(localName);
|
|
28
|
+
const label = fieldIds !== undefined
|
|
29
|
+
? [...fieldIds].find(([, optionId]) => optionId === id)?.[0]
|
|
30
|
+
: index?.labelById.get(id);
|
|
31
|
+
if (label !== undefined && options.includes(label)) {
|
|
32
|
+
return `${slot} uses raw option id ${JSON.stringify(id)}, the option ${JSON.stringify(label)} of field "${fieldName}". ` +
|
|
33
|
+
`Raw ids still build; the preferred form is filter.textOption(${JSON.stringify(label)})`;
|
|
34
|
+
}
|
|
35
|
+
if (fieldIds !== undefined || label !== undefined) {
|
|
36
|
+
return `${slot} uses raw option id ${JSON.stringify(id)}, which is no longer an option of field "${fieldName}", so the option no longer exists. ` +
|
|
37
|
+
`It builds as written; select a current option with filter.textOption("<label>")`;
|
|
38
|
+
}
|
|
39
|
+
return `${slot} uses raw option id ${JSON.stringify(id)} on field "${fieldName}", whose label is not known locally. ` +
|
|
40
|
+
`Raw ids still build; the preferred form is filter.textOption("<label>")`;
|
|
41
|
+
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { FromTfContext } from "../../engine/pull/context.js";
|
|
18
18
|
import { type ChildResourceScope, type TfValue } from "../../engine/tf/index.js";
|
|
19
|
-
export declare function resolveToolFieldKey(fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope | "task", ctx?: Pick<FromTfContext, "dataAttrs" | "foreignFieldRefsByDataAddress">): string | undefined;
|
|
19
|
+
export declare function resolveToolFieldKey(fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope | "task", ctx?: Pick<FromTfContext, "dataAttrs" | "foreignFieldRefsByDataAddress" | "resourcesOfType">): string | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* When `fieldRef` is a field resource whose scoped label names a different
|
|
22
22
|
* owner than the tool's resolved target, return that owner as
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isTfExpr, ownerFromScopedChildLabel,
|
|
1
|
+
import { isTfExpr, ownerFromScopedChildLabel, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
2
|
+
import { pulledFieldBagKey } from "../field/from-tf.js";
|
|
2
3
|
import { SUB_TYPE_BY_RESOURCE as FIELD_SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
3
4
|
export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx) {
|
|
4
5
|
if (fieldRef === undefined)
|
|
@@ -8,7 +9,7 @@ export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx)
|
|
|
8
9
|
// into a key on this tool's target (edk#1403 review S1).
|
|
9
10
|
if (toolFieldRefOtherOwner(fieldRef, scopeTfLabel, scope) !== undefined)
|
|
10
11
|
return undefined;
|
|
11
|
-
return
|
|
12
|
+
return pulledFieldBagKey(scopeTfLabel, fieldRef.label, scope, ctx);
|
|
12
13
|
}
|
|
13
14
|
if (isTfExpr(fieldRef) && fieldRef.$expr === "data-attr" && fieldRef.type === "elementum_field") {
|
|
14
15
|
const fieldAttrs = ctx?.dataAttrs?.("elementum_field", fieldRef.label);
|
|
@@ -104,10 +104,13 @@ export function formatSkillLookupNotes(lookups) {
|
|
|
104
104
|
return lines.join("\n");
|
|
105
105
|
}
|
|
106
106
|
export function deriveSkillInstructions(baseProse, inputs, lookups) {
|
|
107
|
-
|
|
107
|
+
// With nothing to generate, send the text exactly as written: pull keeps the
|
|
108
|
+
// platform's instructions byte for byte, so trimming here planned a diff for
|
|
109
|
+
// every skill whose instructions end in a newline (edk#2512).
|
|
108
110
|
if (inputs === undefined && lookups === undefined) {
|
|
109
|
-
return
|
|
111
|
+
return baseProse ?? "";
|
|
110
112
|
}
|
|
113
|
+
const raw = baseProse?.trim() ?? "";
|
|
111
114
|
const decomposed = decomposeSkillInstructions(raw);
|
|
112
115
|
const effectiveInputs = inputs !== undefined
|
|
113
116
|
? inputs
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
2
|
+
import type { CatalogRef } from "../../catalog/index.js";
|
|
3
|
+
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
4
|
+
declare const slaTimeUnitBrand: unique symbol;
|
|
5
|
+
/** The unit of an SLA target's allowed time. Use {@link slaTimeUnit}. */
|
|
6
|
+
export type SlaTimeUnit = string & {
|
|
7
|
+
readonly [slaTimeUnitBrand]: "SlaTimeUnit";
|
|
8
|
+
};
|
|
9
|
+
export declare const slaTimeUnit: {
|
|
10
|
+
readonly seconds: SlaTimeUnit;
|
|
11
|
+
readonly minutes: SlaTimeUnit;
|
|
12
|
+
readonly hours: SlaTimeUnit;
|
|
13
|
+
readonly days: SlaTimeUnit;
|
|
14
|
+
readonly weeks: SlaTimeUnit;
|
|
15
|
+
readonly months: SlaTimeUnit;
|
|
16
|
+
readonly years: SlaTimeUnit;
|
|
17
|
+
};
|
|
18
|
+
declare const slaWeekDayBrand: unique symbol;
|
|
19
|
+
/** A working day of an SLA target. Use {@link slaWeekDay}. */
|
|
20
|
+
export type SlaWeekDay = string & {
|
|
21
|
+
readonly [slaWeekDayBrand]: "SlaWeekDay";
|
|
22
|
+
};
|
|
23
|
+
export declare const slaWeekDay: {
|
|
24
|
+
readonly monday: SlaWeekDay;
|
|
25
|
+
readonly tuesday: SlaWeekDay;
|
|
26
|
+
readonly wednesday: SlaWeekDay;
|
|
27
|
+
readonly thursday: SlaWeekDay;
|
|
28
|
+
readonly friday: SlaWeekDay;
|
|
29
|
+
readonly saturday: SlaWeekDay;
|
|
30
|
+
readonly sunday: SlaWeekDay;
|
|
31
|
+
};
|
|
32
|
+
/** A 24-hour `HH:MM` or `HH:MM:SS` time. */
|
|
33
|
+
export declare const SLA_LOCAL_TIME: RegExp;
|
|
34
|
+
/** One record target: the time allowed and the working hours that count toward it. */
|
|
35
|
+
export interface SlaTarget {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** Time allowed, counted only during working hours. */
|
|
38
|
+
readonly time: {
|
|
39
|
+
readonly amount: number;
|
|
40
|
+
readonly unit: SlaTimeUnit;
|
|
41
|
+
};
|
|
42
|
+
readonly workingHours: {
|
|
43
|
+
readonly days: readonly SlaWeekDay[];
|
|
44
|
+
/** 24-hour start time, `HH:MM` or `HH:MM:SS`, such as `"08:00:00"`. */
|
|
45
|
+
readonly start: string;
|
|
46
|
+
/** 24-hour end time, `HH:MM` or `HH:MM:SS`, such as `"17:00:00"`. */
|
|
47
|
+
readonly end: string;
|
|
48
|
+
/** IANA time zone, such as `"America/Denver"`. Omit to let the platform choose. */
|
|
49
|
+
readonly timezone?: string;
|
|
50
|
+
};
|
|
51
|
+
/** Optional record filter; same typed DSL as views and tables. Omit to keep a live filter. App-owned SLAs only. */
|
|
52
|
+
readonly filter?: Filter;
|
|
53
|
+
/**
|
|
54
|
+
* Approval entity this target sits on (edk#373). Approval-process-owned SLAs
|
|
55
|
+
* only; omit to target the whole process. Forbidden on app-owned SLAs.
|
|
56
|
+
*/
|
|
57
|
+
readonly approval?: {
|
|
58
|
+
readonly entityId?: string;
|
|
59
|
+
readonly entityType?: "APPROVAL_CHAIN_TEMPLATE" | "APPROVAL_TEMPLATE_PRIORITY_GROUP" | "APPROVAL_TEMPLATE_CONDITIONAL";
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export interface SlaAppOptions<AppRefName extends string = string> extends EntityDeployOptions {
|
|
63
|
+
/** The app that owns the SLA. */
|
|
64
|
+
readonly app: CatalogRef<"app", AppRefName>;
|
|
65
|
+
readonly approvalProcess?: never;
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly description?: string;
|
|
68
|
+
/** Whether the clock runs. Defaults to `true`. */
|
|
69
|
+
readonly active?: boolean;
|
|
70
|
+
/** Keys of the app stages the clock runs in, as authored on the app's `stages`. */
|
|
71
|
+
readonly stages: readonly string[];
|
|
72
|
+
readonly targets: readonly SlaTarget[];
|
|
73
|
+
}
|
|
74
|
+
export interface SlaApprovalOptions<AppRefName extends string = string> extends EntityDeployOptions {
|
|
75
|
+
/** The approval process that owns the SLA (edk#373). */
|
|
76
|
+
readonly approvalProcess: CatalogRef<"approvalChain"> & {
|
|
77
|
+
readonly parent: AppRefName;
|
|
78
|
+
};
|
|
79
|
+
readonly app?: never;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly description?: string;
|
|
82
|
+
readonly active?: boolean;
|
|
83
|
+
readonly stages?: never;
|
|
84
|
+
readonly targets: readonly SlaTarget[];
|
|
85
|
+
}
|
|
86
|
+
export type SlaOptions<AppRefName extends string = string> = SlaAppOptions<AppRefName> | SlaApprovalOptions<AppRefName>;
|
|
87
|
+
export interface SlaConfigured {
|
|
88
|
+
def(refName: string): DeployableEntity;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Define an app SLA clock: a timer that runs while a record is in one of
|
|
92
|
+
* `stages`, with ordered record targets. Place it at
|
|
93
|
+
* `apps/<appRef>/slas/<slaRef>.ts`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function sla<const AppRefName extends string>(opts: SlaOptions<AppRefName>): SlaConfigured;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
|
|
2
|
+
export const slaTimeUnit = {
|
|
3
|
+
seconds: "SECOND",
|
|
4
|
+
minutes: "MINUTE",
|
|
5
|
+
hours: "HOUR",
|
|
6
|
+
days: "DAY",
|
|
7
|
+
weeks: "WEEK",
|
|
8
|
+
months: "MONTH",
|
|
9
|
+
years: "YEAR",
|
|
10
|
+
};
|
|
11
|
+
export const slaWeekDay = {
|
|
12
|
+
monday: "MONDAY",
|
|
13
|
+
tuesday: "TUESDAY",
|
|
14
|
+
wednesday: "WEDNESDAY",
|
|
15
|
+
thursday: "THURSDAY",
|
|
16
|
+
friday: "FRIDAY",
|
|
17
|
+
saturday: "SATURDAY",
|
|
18
|
+
sunday: "SUNDAY",
|
|
19
|
+
};
|
|
20
|
+
const TIME_UNITS = new Set(Object.values(slaTimeUnit));
|
|
21
|
+
const WEEK_DAYS = new Set(Object.values(slaWeekDay));
|
|
22
|
+
/** A 24-hour `HH:MM` or `HH:MM:SS` time. */
|
|
23
|
+
export const SLA_LOCAL_TIME = /^([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/;
|
|
24
|
+
function validateSla(refName, opts) {
|
|
25
|
+
const fail = (message) => {
|
|
26
|
+
throw new EdkValidationError(`sla "${refName}": ${message}`);
|
|
27
|
+
};
|
|
28
|
+
const approvalOwned = opts.approvalProcess !== undefined;
|
|
29
|
+
if (approvalOwned) {
|
|
30
|
+
if (opts.approvalProcess.__kind !== "approvalChain")
|
|
31
|
+
fail("approvalProcess must be an approval-chain catalog ref");
|
|
32
|
+
}
|
|
33
|
+
else if (opts.app.__kind !== "app") {
|
|
34
|
+
fail("app must be an app catalog ref");
|
|
35
|
+
}
|
|
36
|
+
if (opts.name.trim() === "")
|
|
37
|
+
fail("name must not be empty");
|
|
38
|
+
if (opts.description !== undefined && opts.description.trim() === "")
|
|
39
|
+
fail("description must not be empty when set");
|
|
40
|
+
if (!approvalOwned) {
|
|
41
|
+
const stages = new Set();
|
|
42
|
+
for (const stage of opts.stages) {
|
|
43
|
+
if (stage.trim() === "")
|
|
44
|
+
fail("stage keys must not be empty");
|
|
45
|
+
if (stages.has(stage))
|
|
46
|
+
fail(`stage "${stage}" is listed twice`);
|
|
47
|
+
stages.add(stage);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (opts.targets.length === 0)
|
|
51
|
+
fail("targets must list at least one target");
|
|
52
|
+
opts.targets.forEach((target, index) => {
|
|
53
|
+
const where = `target ${index} ("${target.name}")`;
|
|
54
|
+
if (target.name.trim() === "")
|
|
55
|
+
fail(`target ${index}: name must not be empty`);
|
|
56
|
+
if (!Number.isInteger(target.time.amount) || target.time.amount < 1)
|
|
57
|
+
fail(`${where}: time.amount must be a whole number of at least 1`);
|
|
58
|
+
if (!TIME_UNITS.has(target.time.unit))
|
|
59
|
+
fail(`${where}: time.unit must be a slaTimeUnit constant`);
|
|
60
|
+
const hours = target.workingHours;
|
|
61
|
+
if (!SLA_LOCAL_TIME.test(hours.start))
|
|
62
|
+
fail(`${where}: workingHours.start must be a 24-hour HH:MM or HH:MM:SS time`);
|
|
63
|
+
if (!SLA_LOCAL_TIME.test(hours.end))
|
|
64
|
+
fail(`${where}: workingHours.end must be a 24-hour HH:MM or HH:MM:SS time`);
|
|
65
|
+
if (hours.timezone !== undefined && hours.timezone.trim() === "")
|
|
66
|
+
fail(`${where}: workingHours.timezone must not be empty when set`);
|
|
67
|
+
if (hours.days.length === 0)
|
|
68
|
+
fail(`${where}: workingHours.days must list at least one day`);
|
|
69
|
+
const days = new Set();
|
|
70
|
+
for (const day of hours.days) {
|
|
71
|
+
if (!WEEK_DAYS.has(day))
|
|
72
|
+
fail(`${where}: workingHours.days must use slaWeekDay constants`);
|
|
73
|
+
if (days.has(day))
|
|
74
|
+
fail(`${where}: day ${day} is listed twice`);
|
|
75
|
+
days.add(day);
|
|
76
|
+
}
|
|
77
|
+
if (approvalOwned && target.filter !== undefined)
|
|
78
|
+
fail(`${where}: filter is only for app-owned SLAs`);
|
|
79
|
+
if (!approvalOwned && target.approval !== undefined)
|
|
80
|
+
fail(`${where}: approval is only for approval-process-owned SLAs`);
|
|
81
|
+
if (target.approval?.entityId !== undefined) {
|
|
82
|
+
fail(`${where}: approval.entityId is a raw platform id; omit it or use a typed approver/conditional ref (entityType alone / empty approval remains allowed)`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Define an app SLA clock: a timer that runs while a record is in one of
|
|
88
|
+
* `stages`, with ordered record targets. Place it at
|
|
89
|
+
* `apps/<appRef>/slas/<slaRef>.ts`.
|
|
90
|
+
*/
|
|
91
|
+
export function sla(opts) {
|
|
92
|
+
return {
|
|
93
|
+
def(refName) {
|
|
94
|
+
validateSla(refName, opts);
|
|
95
|
+
const approvalOwned = opts.approvalProcess !== undefined;
|
|
96
|
+
const parent = approvalOwned ? opts.approvalProcess.parent : opts.app.refName;
|
|
97
|
+
return {
|
|
98
|
+
kind: "sla",
|
|
99
|
+
parent,
|
|
100
|
+
refName,
|
|
101
|
+
payload: {
|
|
102
|
+
...(approvalOwned
|
|
103
|
+
? { approvalProcess: { refName: opts.approvalProcess.refName, parent: opts.approvalProcess.parent } }
|
|
104
|
+
: { app: { refName: opts.app.refName }, stages: [...opts.stages] }),
|
|
105
|
+
name: opts.name,
|
|
106
|
+
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
107
|
+
active: opts.active ?? true,
|
|
108
|
+
targets: opts.targets.map((target) => ({
|
|
109
|
+
name: target.name,
|
|
110
|
+
timePeriod: target.time.amount,
|
|
111
|
+
timeUnit: target.time.unit,
|
|
112
|
+
workingStartTime: target.workingHours.start,
|
|
113
|
+
workingEndTime: target.workingHours.end,
|
|
114
|
+
...(target.workingHours.timezone !== undefined ? { workingTimezone: target.workingHours.timezone } : {}),
|
|
115
|
+
workingWeekDays: [...target.workingHours.days],
|
|
116
|
+
...(target.filter !== undefined ? { filter: target.filter } : {}),
|
|
117
|
+
...(target.approval !== undefined ? { approval: target.approval } : {}),
|
|
118
|
+
})),
|
|
119
|
+
},
|
|
120
|
+
...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}),
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
import type { FromTfContext } from "../../engine/pull/context.js";
|
|
3
|
+
import type { RefExpr } from "../shared/filters/ast.js";
|
|
4
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
5
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
6
|
+
import { type StageHandleIndex } from "../app/stage-keys.js";
|
|
7
|
+
/**
|
|
8
|
+
* An SLA the public API cannot express, such as one with no record targets.
|
|
9
|
+
* Like a lost stage handle, it is reported, released and its file archived.
|
|
10
|
+
*/
|
|
11
|
+
export declare class UnmanagedSlaError extends EntityTfError {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
export interface NormalizedSlaTarget {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly timePeriod: number;
|
|
17
|
+
readonly timeUnit: string;
|
|
18
|
+
readonly workingStartTime: string;
|
|
19
|
+
readonly workingEndTime: string;
|
|
20
|
+
readonly workingTimezone?: string;
|
|
21
|
+
readonly workingWeekDays: readonly string[];
|
|
22
|
+
readonly filter?: Filter<RefExpr, RefExpr>;
|
|
23
|
+
readonly approval?: NormalizedSlaApproval;
|
|
24
|
+
}
|
|
25
|
+
export interface NormalizedSlaApproval {
|
|
26
|
+
readonly entityId?: string;
|
|
27
|
+
readonly entityType?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface NormalizedSla {
|
|
30
|
+
readonly refName: string;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly description?: string;
|
|
33
|
+
readonly active: boolean;
|
|
34
|
+
/** Stage handles for app-owned SLAs; empty for approval-owned. */
|
|
35
|
+
readonly stages: readonly string[];
|
|
36
|
+
/** Approval process TF label when approval-owned (edk#373). */
|
|
37
|
+
readonly approvalProcessTfLabel?: string;
|
|
38
|
+
readonly targets: readonly NormalizedSlaTarget[];
|
|
39
|
+
}
|
|
40
|
+
export declare function slaFromTf(block: TfBlock, appTfLabel: string, stageHandles: StageHandleIndex | undefined, ctx?: FromTfContext): NormalizedSla;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
3
|
+
import { resourceRefLabel } from "../../engine/pull/context.js";
|
|
4
|
+
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
5
|
+
import { LostStageHandleError, lostStageMessage, pulledStageHandle } from "../app/stage-keys.js";
|
|
6
|
+
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
7
|
+
import { APPROVAL_PROCESS_RESOURCE_TYPE } from "../approval-chain/module.js";
|
|
8
|
+
import { SLA_RESOURCE_TYPE } from "./module.js";
|
|
9
|
+
const KNOWN = new Set(["id", "app_id", "approval_process_id", "owner_aspect_id", "name", "description", "active", "stage_ids", "targets"]);
|
|
10
|
+
const TARGET_KNOWN = new Set([
|
|
11
|
+
"name", "time_period", "time_unit", "working_start_time", "working_end_time", "working_timezone", "working_week_days", "filter", "approval",
|
|
12
|
+
]);
|
|
13
|
+
/**
|
|
14
|
+
* An SLA the public API cannot express, such as one with no record targets.
|
|
15
|
+
* Like a lost stage handle, it is reported, released and its file archived.
|
|
16
|
+
*/
|
|
17
|
+
export class UnmanagedSlaError extends EntityTfError {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "UnmanagedSlaError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function isRecord(value) {
|
|
24
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !isTfExpr(value);
|
|
25
|
+
}
|
|
26
|
+
export function slaFromTf(block, appTfLabel, stageHandles, ctx) {
|
|
27
|
+
const where = `${block.type}.${block.label ?? ""}`;
|
|
28
|
+
if (block.type !== SLA_RESOURCE_TYPE || block.label === undefined)
|
|
29
|
+
throw new EntityTfError(`expected ${SLA_RESOURCE_TYPE}`);
|
|
30
|
+
for (const key of Object.keys(block.attrs)) {
|
|
31
|
+
if (!KNOWN.has(key))
|
|
32
|
+
throw new EntityTfError(`${where}: unknown attribute ${key} — extend slaFromTf deliberately`);
|
|
33
|
+
}
|
|
34
|
+
const approvalProcessTfLabel = resourceRefLabel(block.attrs["approval_process_id"], APPROVAL_PROCESS_RESOURCE_TYPE);
|
|
35
|
+
const appOwned = block.attrs["app_id"] !== undefined;
|
|
36
|
+
if (appOwned && approvalProcessTfLabel !== undefined) {
|
|
37
|
+
throw new EntityTfError(`${where}: set exactly one of app_id or approval_process_id`);
|
|
38
|
+
}
|
|
39
|
+
if (appOwned) {
|
|
40
|
+
if (resourceRefLabel(block.attrs["app_id"], APP_RESOURCE_TYPE) !== appTfLabel) {
|
|
41
|
+
throw new EntityTfError(`${where}: app_id does not reference ${APP_RESOURCE_TYPE}.${appTfLabel}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (approvalProcessTfLabel === undefined) {
|
|
45
|
+
throw new EntityTfError(`${where}: expected app_id or approval_process_id`);
|
|
46
|
+
}
|
|
47
|
+
const name = block.attrs["name"];
|
|
48
|
+
if (typeof name !== "string" || name === "")
|
|
49
|
+
throw new EntityTfError(`${where}: name must be a literal string`);
|
|
50
|
+
const description = block.attrs["description"];
|
|
51
|
+
if (description !== undefined && typeof description !== "string")
|
|
52
|
+
throw new EntityTfError(`${where}: description must be a literal string`);
|
|
53
|
+
const active = block.attrs["active"] ?? true;
|
|
54
|
+
if (typeof active !== "boolean")
|
|
55
|
+
throw new EntityTfError(`${where}: active must be a literal boolean`);
|
|
56
|
+
const stages = [];
|
|
57
|
+
if (appOwned) {
|
|
58
|
+
const rawStages = block.attrs["stage_ids"];
|
|
59
|
+
if (!Array.isArray(rawStages))
|
|
60
|
+
throw new EntityTfError(`${where}: stage_ids must be a list`);
|
|
61
|
+
for (const value of rawStages) {
|
|
62
|
+
if (!isTfExpr(value) || value.$expr !== "local" || value.name !== `${appTfLabel}_stage_ids_by_key`) {
|
|
63
|
+
throw new LostStageHandleError(`${where}: stage ${typeof value === "string" ? JSON.stringify(value) : "reference"} is not one of the app's authored stages; the SLA is left unmanaged`);
|
|
64
|
+
}
|
|
65
|
+
const index = value.path[0];
|
|
66
|
+
if (typeof index !== "object" || typeof index.index !== "string")
|
|
67
|
+
throw new EntityTfError(`${where}: unsupported stage_ids expression`);
|
|
68
|
+
const pulled = pulledStageHandle(index.index, stageHandles);
|
|
69
|
+
if (pulled.kind === "lost")
|
|
70
|
+
throw new LostStageHandleError(lostStageMessage(where, index.index, pulled, "the SLA is left unmanaged"));
|
|
71
|
+
if (pulled.kind !== "handle")
|
|
72
|
+
throw new EntityTfError(`${where}: stage key ${JSON.stringify(index.index)} has no terraform label handle`);
|
|
73
|
+
stages.push(tfLabelToTsLabel(pulled.handle));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (block.attrs["stage_ids"] !== undefined) {
|
|
77
|
+
throw new EntityTfError(`${where}: stage_ids is not allowed on an approval-process-owned SLA`);
|
|
78
|
+
}
|
|
79
|
+
const rawTargets = block.attrs["targets"] ?? [];
|
|
80
|
+
if (!Array.isArray(rawTargets))
|
|
81
|
+
throw new EntityTfError(`${where}: targets must be a list`);
|
|
82
|
+
if (rawTargets.length === 0) {
|
|
83
|
+
throw new UnmanagedSlaError(`${where}: the SLA has no record targets, which source cannot express (an SLA needs at least one); the SLA is left unmanaged`);
|
|
84
|
+
}
|
|
85
|
+
const targets = rawTargets.map((value, index) => {
|
|
86
|
+
const at = `${where}: target ${index}`;
|
|
87
|
+
if (!isRecord(value))
|
|
88
|
+
throw new EntityTfError(`${at} must be an object`);
|
|
89
|
+
const raw = value;
|
|
90
|
+
for (const key of Object.keys(raw)) {
|
|
91
|
+
if (!TARGET_KNOWN.has(key))
|
|
92
|
+
throw new EntityTfError(`${at}: unknown attribute ${key} — extend slaFromTf deliberately`);
|
|
93
|
+
}
|
|
94
|
+
const str = (key) => {
|
|
95
|
+
const value = raw[key];
|
|
96
|
+
if (typeof value !== "string")
|
|
97
|
+
throw new EntityTfError(`${at}: ${key} must be a literal string`);
|
|
98
|
+
return value;
|
|
99
|
+
};
|
|
100
|
+
const period = raw["time_period"];
|
|
101
|
+
if (typeof period !== "number")
|
|
102
|
+
throw new EntityTfError(`${at}: time_period must be a literal number`);
|
|
103
|
+
const days = raw["working_week_days"];
|
|
104
|
+
if (!Array.isArray(days) || !days.every((day) => typeof day === "string")) {
|
|
105
|
+
throw new EntityTfError(`${at}: working_week_days must be a list of literal strings`);
|
|
106
|
+
}
|
|
107
|
+
const timezone = raw["working_timezone"];
|
|
108
|
+
if (timezone !== undefined && typeof timezone !== "string")
|
|
109
|
+
throw new EntityTfError(`${at}: working_timezone must be a literal string`);
|
|
110
|
+
let filter;
|
|
111
|
+
if (raw["filter"] !== undefined) {
|
|
112
|
+
if (!appOwned)
|
|
113
|
+
throw new EntityTfError(`${at}: filter is only for app-owned SLAs`);
|
|
114
|
+
filter = filterFromTf(raw["filter"], {
|
|
115
|
+
type: "elementum_app",
|
|
116
|
+
label: appTfLabel,
|
|
117
|
+
ownerRefName: tfLabelToTsLabel(appTfLabel),
|
|
118
|
+
ownerTfLabel: appTfLabel,
|
|
119
|
+
scope: "app",
|
|
120
|
+
foreignFieldRefsById: ctx?.foreignFieldRefsById,
|
|
121
|
+
}, `${at}.filter`, ctx, { optionLookupsAsTextOption: true });
|
|
122
|
+
}
|
|
123
|
+
let approval;
|
|
124
|
+
if (raw["approval"] !== undefined) {
|
|
125
|
+
if (appOwned)
|
|
126
|
+
throw new EntityTfError(`${at}: approval is only for approval-process-owned SLAs`);
|
|
127
|
+
if (!isRecord(raw["approval"]))
|
|
128
|
+
throw new EntityTfError(`${at}.approval must be an object`);
|
|
129
|
+
const ap = raw["approval"];
|
|
130
|
+
const entityId = ap["entity_id"];
|
|
131
|
+
const entityType = ap["entity_type"];
|
|
132
|
+
// Fail-closed: a raw platform id in authored source is not a typed
|
|
133
|
+
// approver/conditional ref (edk#373 follow-up). Leave the SLA unmanaged.
|
|
134
|
+
if (entityId !== undefined) {
|
|
135
|
+
throw new UnmanagedSlaError(`${at}.approval.entity_id is a raw platform id; export cannot yet name a non-process approval entity as a typed approver or conditional ref, so the SLA is left unmanaged`);
|
|
136
|
+
}
|
|
137
|
+
if (entityType !== undefined && typeof entityType !== "string")
|
|
138
|
+
throw new EntityTfError(`${at}.approval.entity_type must be a literal string`);
|
|
139
|
+
approval = {
|
|
140
|
+
...(entityType !== undefined && entityType !== "" ? { entityType } : {}),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
name: str("name"),
|
|
145
|
+
timePeriod: period,
|
|
146
|
+
timeUnit: str("time_unit"),
|
|
147
|
+
workingStartTime: str("working_start_time"),
|
|
148
|
+
workingEndTime: str("working_end_time"),
|
|
149
|
+
...(timezone !== undefined && timezone !== "" ? { workingTimezone: timezone } : {}),
|
|
150
|
+
workingWeekDays: days,
|
|
151
|
+
...(filter !== undefined ? { filter } : {}),
|
|
152
|
+
...(approval !== undefined ? { approval } : {}),
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
refName: scopedLabelToBagKey(appTfLabel, block.label, "app"),
|
|
157
|
+
name,
|
|
158
|
+
...(description !== undefined && description !== "" ? { description } : {}),
|
|
159
|
+
active,
|
|
160
|
+
stages,
|
|
161
|
+
...(approvalProcessTfLabel !== undefined ? { approvalProcessTfLabel } : {}),
|
|
162
|
+
targets,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sla, slaTimeUnit, slaWeekDay, type SlaAppOptions, type SlaApprovalOptions, type SlaConfigured, type SlaOptions, type SlaTarget, type SlaTimeUnit, type SlaWeekDay, } from "./build.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sla, slaTimeUnit, slaWeekDay, } from "./build.js";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
2
|
+
import { NO_CANVAS, NO_CATALOG, NO_DATA } from "../../graph/types.js";
|
|
3
|
+
import { appStageKeyByHandle, LostStageHandleError, stageHandleIndexFromTfStages } from "../app/stage-keys.js";
|
|
4
|
+
import { slaFromTf, UnmanagedSlaError } from "./from-tf.js";
|
|
5
|
+
import { printSla } from "./printer.js";
|
|
6
|
+
import { slaToTf } from "./to-tf.js";
|
|
7
|
+
export const SLA_RESOURCE_TYPE = "elementum_sla";
|
|
8
|
+
function extract(blocks, _stream, ctx) {
|
|
9
|
+
const items = [];
|
|
10
|
+
const skipped = [];
|
|
11
|
+
const releaseIfManaged = [];
|
|
12
|
+
const quarantineOwnFiles = [];
|
|
13
|
+
const diagnostics = [];
|
|
14
|
+
const stageHandles = stageHandleIndexFromTfStages(ctx.resourceByAddress?.(`elementum_app.${ctx.appTfLabel}`)?.attrs["stages"]);
|
|
15
|
+
for (const block of blocks) {
|
|
16
|
+
try {
|
|
17
|
+
items.push(slaFromTf(block, ctx.appTfLabel, stageHandles, ctx));
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
// Only an SLA on a stage with no authored handle (#1136) or with no
|
|
21
|
+
// targets is a supported, reported gap: it stays platform-managed, its
|
|
22
|
+
// state is released and its authored file archived, so the next plan
|
|
23
|
+
// neither destroys the live clock nor creates a second one (#1858).
|
|
24
|
+
// Any other extract error is malformed structure and fails the pull,
|
|
25
|
+
// since a skipped block left in state would plan a destroy.
|
|
26
|
+
if (!(error instanceof LostStageHandleError) && !(error instanceof UnmanagedSlaError))
|
|
27
|
+
throw error;
|
|
28
|
+
const address = `${block.type}.${block.label ?? ""}`;
|
|
29
|
+
skipped.push(address);
|
|
30
|
+
releaseIfManaged.push(address);
|
|
31
|
+
if (block.label !== undefined) {
|
|
32
|
+
quarantineOwnFiles.push({ kind: "sla", refName: scopedLabelToBagKey(ctx.appTfLabel, block.label, "app") });
|
|
33
|
+
}
|
|
34
|
+
diagnostics.push(`${error.message}; its authored file, if any, is archived so the next plan does not create a duplicate`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
items,
|
|
39
|
+
skipped,
|
|
40
|
+
...(releaseIfManaged.length > 0 && { releaseIfManaged }),
|
|
41
|
+
...(quarantineOwnFiles.length > 0 && { quarantineOwnFiles }),
|
|
42
|
+
diagnostics,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** App SLA clocks (edk#600): `apps/<appRef>/slas/<slaRef>.ts`. */
|
|
46
|
+
export const slaModule = {
|
|
47
|
+
kind: "sla",
|
|
48
|
+
stream: { role: "streamMember" },
|
|
49
|
+
authoring: { unit: "ownFile", bag: "slas" },
|
|
50
|
+
parents: [{ parent: "app", child: "sla" }],
|
|
51
|
+
resource: { shape: "single", resourceType: SLA_RESOURCE_TYPE, adoptable: true },
|
|
52
|
+
data: NO_DATA,
|
|
53
|
+
lifecycle: {
|
|
54
|
+
participates: true,
|
|
55
|
+
extractOwnFile: extract,
|
|
56
|
+
printOwnFile: (item, opts) => {
|
|
57
|
+
const sla = item;
|
|
58
|
+
return { refName: sla.refName, source: printSla(sla, opts.appRefName) };
|
|
59
|
+
},
|
|
60
|
+
toTf: (entity, ctx) => slaToTf(entity, {
|
|
61
|
+
appRefName: ctx.appRefName,
|
|
62
|
+
appTfLabel: ctx.appTfLabel,
|
|
63
|
+
diagnostics: ctx.diagnostics,
|
|
64
|
+
...(ctx.fieldAddresses !== undefined ? { fieldAddresses: ctx.fieldAddresses } : {}),
|
|
65
|
+
...(() => {
|
|
66
|
+
const stageKeyByTfLabel = appStageKeyByHandle(ctx.streamRootEntity?.payload);
|
|
67
|
+
return stageKeyByTfLabel !== undefined ? { stageKeyByTfLabel } : {};
|
|
68
|
+
})(),
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
canvas: NO_CANVAS,
|
|
72
|
+
catalog: NO_CATALOG,
|
|
73
|
+
};
|