@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { isTfExpr } from "../../engine/tf/index.js";
|
|
2
|
+
import { ROLE_RESOURCE_TYPE, roleModule } from "../org/role.js";
|
|
3
|
+
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "./resource-type.js";
|
|
4
|
+
function sideOf(block, attr, name) {
|
|
5
|
+
const list = block.attrs[attr];
|
|
6
|
+
if (!Array.isArray(list) || block.label === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
const members = new Set();
|
|
9
|
+
let hasRawId = false;
|
|
10
|
+
for (const item of list) {
|
|
11
|
+
if (isTfExpr(item) && item.$expr === "resource-attr")
|
|
12
|
+
members.add(`${item.type}.${item.label}`);
|
|
13
|
+
else if (typeof item === "string")
|
|
14
|
+
hasRawId = true;
|
|
15
|
+
}
|
|
16
|
+
return { address: `${block.type}.${block.label}`, name, members, hasRawId };
|
|
17
|
+
}
|
|
18
|
+
function accountName(block) {
|
|
19
|
+
const first = block.attrs["first_name"];
|
|
20
|
+
const last = block.attrs["last_name"];
|
|
21
|
+
return typeof first === "string" && typeof last === "string" ? `${first} ${last}`.trim() : block.label ?? "?";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A role's `service_account_ids` and a service account's `role_ids` write the
|
|
25
|
+
* same membership. When both lists are set and disagree about one role and
|
|
26
|
+
* one account, each apply undoes the other forever (edk#2159), so the build
|
|
27
|
+
* stops and names both. Agreement is left alone: on one app both sides naming
|
|
28
|
+
* each other is a dependency cycle that tofu already reports.
|
|
29
|
+
*
|
|
30
|
+
* A role list never holds a raw id (build resolves every account it names), but
|
|
31
|
+
* an account's `role_ids` can (pull keeps another app's role as
|
|
32
|
+
* `unsafePlatformId`), and this check can't tell which role a raw id is. So a
|
|
33
|
+
* role that lists the account is not reported against an account list holding
|
|
34
|
+
* raw ids, and an account list made only of raw ids never names a role here:
|
|
35
|
+
* it is not compared, including when the role's list leaves that account out.
|
|
36
|
+
*
|
|
37
|
+
* The fix-it text says which property to leave off, chosen by which side
|
|
38
|
+
* claims the membership. Leaving a list off is not the same as `[]` (#2124),
|
|
39
|
+
* and naming the membership on both sides is a dependency cycle on one app.
|
|
40
|
+
*/
|
|
41
|
+
export function roleServiceAccountMembershipErrors(roots) {
|
|
42
|
+
const blocks = roots.flatMap((root) => root.blocks);
|
|
43
|
+
const roles = blocks
|
|
44
|
+
.filter((block) => block.kind === "resource" && block.type === ROLE_RESOURCE_TYPE)
|
|
45
|
+
.map((block) => sideOf(block, "service_account_ids", typeof block.attrs["name"] === "string" ? block.attrs["name"] : block.label ?? "?"))
|
|
46
|
+
.filter((side) => side !== undefined);
|
|
47
|
+
if (roles.length === 0)
|
|
48
|
+
return [];
|
|
49
|
+
const accounts = blocks
|
|
50
|
+
.filter((block) => block.kind === "resource" && block.type === SERVICE_ACCOUNT_RESOURCE_TYPE)
|
|
51
|
+
.map((block) => sideOf(block, "role_ids", accountName(block)))
|
|
52
|
+
.filter((side) => side !== undefined);
|
|
53
|
+
const errors = [];
|
|
54
|
+
for (const role of roles) {
|
|
55
|
+
for (const account of accounts) {
|
|
56
|
+
const roleSays = role.members.has(account.address);
|
|
57
|
+
const accountSays = account.members.has(role.address);
|
|
58
|
+
if (roleSays === accountSays)
|
|
59
|
+
continue;
|
|
60
|
+
if (roleSays && account.hasRawId)
|
|
61
|
+
continue;
|
|
62
|
+
const disagreement = roleSays
|
|
63
|
+
? `the role's serviceAccounts list names the account, but the account's roles list leaves the role out`
|
|
64
|
+
: `the account's roles list names the role, but the role's serviceAccounts list leaves the account out`;
|
|
65
|
+
const fix = roleSays
|
|
66
|
+
? `If the account should hold the role, leave the roles property off the account (not roles: []) so the role's serviceAccounts decides. ` +
|
|
67
|
+
`If it shouldn't, take the account out of the role's serviceAccounts.`
|
|
68
|
+
: `If the account should hold the role, leave the serviceAccounts property off the role (not serviceAccounts: []) so the account's roles decide. ` +
|
|
69
|
+
`If it shouldn't, take the role out of the account's roles.`;
|
|
70
|
+
errors.push({
|
|
71
|
+
address: role.address,
|
|
72
|
+
name: role.name,
|
|
73
|
+
ownerKind: roleModule.kind,
|
|
74
|
+
message: `role "${role.name}" (${role.address}) and service account "${account.name}" (${account.address}) both set whether the account holds the role, and they disagree: ${disagreement}. ` +
|
|
75
|
+
`Each apply would undo the other. ${fix}`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return errors;
|
|
80
|
+
}
|
|
@@ -5,6 +5,21 @@ import type { FromTfContext } from "../../engine/pull/context.js";
|
|
|
5
5
|
* recursive pull's namespace -> refName and display-name -> refName maps.
|
|
6
6
|
*/
|
|
7
7
|
export declare function dataAspectDisplayName(ctx: FromTfContext, kind: "app" | "element" | "task", label: string): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Workspace catalog key for an app or element the export named by its
|
|
10
|
+
* namespace. Prefer the workspace namespace map (case-insensitive via
|
|
11
|
+
* {@link lookupNamespaceMap}). A known namespace that is not on disk must
|
|
12
|
+
* not fall through to the display-name map — that map is not unique and
|
|
13
|
+
* can silently bind another app (#2667 B1). Without a namespace, a unique
|
|
14
|
+
* display-name or sanitized terraform-label match is still allowed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function catalogRefForAspectOwner(input: {
|
|
17
|
+
readonly namespace?: string;
|
|
18
|
+
readonly name?: string;
|
|
19
|
+
readonly tfLabel?: string;
|
|
20
|
+
readonly refNamesByNamespace?: ReadonlyMap<string, string>;
|
|
21
|
+
readonly refNamesByName?: ReadonlyMap<string, string>;
|
|
22
|
+
}): string | undefined;
|
|
8
23
|
/** Resolve the stable pulled catalog key for the same foreign lookup. */
|
|
9
24
|
export declare function dataAspectRefName(ctx: FromTfContext, kind: "app" | "element" | "task", label: string, displayName?: string): string | undefined;
|
|
10
25
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lookupNamespaceMap } from "../../engine/pull/authored-root.js";
|
|
1
2
|
import { sanitizeName, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* Resolve a foreign app/element data lookup to its display name. Ref-only
|
|
@@ -25,6 +26,41 @@ export function dataAspectDisplayName(ctx, kind, label) {
|
|
|
25
26
|
const names = kind === "app" ? ctx.foreignAppRefNames : kind === "element" ? ctx.foreignElementRefNames : undefined;
|
|
26
27
|
return [...(names?.entries() ?? [])].find(([, candidateRefName]) => candidateRefName === refName)?.[0];
|
|
27
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Workspace catalog key for an app or element the export named by its
|
|
31
|
+
* namespace. Prefer the workspace namespace map (case-insensitive via
|
|
32
|
+
* {@link lookupNamespaceMap}). A known namespace that is not on disk must
|
|
33
|
+
* not fall through to the display-name map — that map is not unique and
|
|
34
|
+
* can silently bind another app (#2667 B1). Without a namespace, a unique
|
|
35
|
+
* display-name or sanitized terraform-label match is still allowed.
|
|
36
|
+
*/
|
|
37
|
+
export function catalogRefForAspectOwner(input) {
|
|
38
|
+
const namespace = input.namespace !== undefined && input.namespace !== "" ? input.namespace : undefined;
|
|
39
|
+
if (namespace !== undefined) {
|
|
40
|
+
if (input.refNamesByNamespace !== undefined) {
|
|
41
|
+
const byNamespace = lookupNamespaceMap(input.refNamesByNamespace, namespace);
|
|
42
|
+
if (byNamespace !== undefined)
|
|
43
|
+
return byNamespace;
|
|
44
|
+
throw new Error(`table source namespace ${JSON.stringify(namespace)} is not in this workspace; ` +
|
|
45
|
+
"pull that app or element first so the table can use its refName " +
|
|
46
|
+
"(refusing a display-name guess that could bind a different app)");
|
|
47
|
+
}
|
|
48
|
+
return tfLabelToTsLabel(sanitizeName(namespace));
|
|
49
|
+
}
|
|
50
|
+
if (input.name !== undefined && input.name !== "") {
|
|
51
|
+
const byName = input.refNamesByName?.get(input.name);
|
|
52
|
+
if (byName !== undefined)
|
|
53
|
+
return byName;
|
|
54
|
+
}
|
|
55
|
+
if (input.tfLabel !== undefined && input.refNamesByNamespace !== undefined) {
|
|
56
|
+
const refs = [...new Set([...input.refNamesByNamespace.entries()]
|
|
57
|
+
.filter(([candidate]) => sanitizeName(candidate) === input.tfLabel)
|
|
58
|
+
.map(([, refName]) => refName))];
|
|
59
|
+
if (refs.length === 1)
|
|
60
|
+
return refs[0];
|
|
61
|
+
}
|
|
62
|
+
return input.tfLabel === undefined ? undefined : tfLabelToTsLabel(input.tfLabel);
|
|
63
|
+
}
|
|
28
64
|
/** Resolve the stable pulled catalog key for the same foreign lookup. */
|
|
29
65
|
export function dataAspectRefName(ctx, kind, label, displayName) {
|
|
30
66
|
if (kind === "task")
|
|
@@ -122,6 +122,8 @@ export interface GroupRefAst {
|
|
|
122
122
|
readonly groupKey: string;
|
|
123
123
|
/** The group's display name — the lookup value. */
|
|
124
124
|
readonly name: string;
|
|
125
|
+
/** False when org.ts doesn't carry the group: printed as `groupRef({ name })`, not `org.groups.<key>` (edk#2241). */
|
|
126
|
+
readonly inOrgCatalog?: false;
|
|
125
127
|
}
|
|
126
128
|
/** Reference to a sub-automation via the app's `automations` bag. */
|
|
127
129
|
export interface AutomationRefAst {
|
|
@@ -251,6 +253,8 @@ export type RefExpr =
|
|
|
251
253
|
| {
|
|
252
254
|
kind: "triggerRef";
|
|
253
255
|
path: readonly string[];
|
|
256
|
+
/** Pulled record trigger ref name the trigger output type doesn't declare (#2643). */
|
|
257
|
+
undeclaredHead?: true;
|
|
254
258
|
}
|
|
255
259
|
/** Reference to a forEach loop variable: `ctx.actions.<forEachTask>.<path...>`. */
|
|
256
260
|
| {
|
|
@@ -7,6 +7,13 @@ import type { WorkflowFieldType } from "../types/field-types.js";
|
|
|
7
7
|
import type { AndFilter, BetweenFilter, ConsecutiveRangeFilter, ContainsFilter, CurrentRangeFilter, DateTimeUnit, EqualsFilter, FalseFilter, Filter, FilterReference, FilterValue, GreaterThanEqualsFilter, GreaterThanFilter, InFilter, IsNullFilter, LessThanEqualsFilter, LessThanFilter, LikeFilter, LikeMode, OrFilter, OverlapsFilter, TrueFilter, ValueType } from "./types.js";
|
|
8
8
|
export type { AndFilter, BetweenFilter, ConsecutiveRangeFilter, ContainsFilter, CurrentRangeFilter, DateTimeUnit, EqualsFilter, FalseFilter, FieldFilterOptions, Filter, FilterReference, FilterValue, GreaterThanEqualsFilter, GreaterThanFilter, InFilter, IsNullFilter, LessThanEqualsFilter, LessThanFilter, LikeFilter, LikeMode, OrFilter, OverlapsFilter, TrueFilter, ValueType, } from "./types.js";
|
|
9
9
|
export type FilterField = AppOrElementRef | FieldRef | UserFieldRef | UserGroupFieldRef | TableColumnRef | TableRef | AppField<FieldScope> | UnsafePlatformId | string;
|
|
10
|
+
/**
|
|
11
|
+
* A filter field named by a field token or `unsafePlatformId()`, never by a bare
|
|
12
|
+
* string. Views and access policies take only these, because their build can't
|
|
13
|
+
* resolve a field name (#1873); a filter whose left side is a bare string keeps
|
|
14
|
+
* the wider `FilterField` type, so the editor flags it there instead of build.
|
|
15
|
+
*/
|
|
16
|
+
export type FilterFieldToken = Exclude<FilterField, string>;
|
|
10
17
|
export type FilterReferenceValue = FilterReference | {
|
|
11
18
|
readonly __rawFilterReference: string;
|
|
12
19
|
};
|
|
@@ -47,29 +54,46 @@ export declare function uuid(ref: Ref<unknown> | string, options?: {
|
|
|
47
54
|
}): FilterReferenceInput;
|
|
48
55
|
export declare function isFilterReferenceInput(value: unknown): value is FilterReferenceInput;
|
|
49
56
|
/**
|
|
50
|
-
* A picklist, status, or stage option selected by its LABEL
|
|
51
|
-
* the
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
57
|
+
* A picklist, status, or stage option selected by its LABEL. Build resolves
|
|
58
|
+
* the label to that option's id, which is what the platform stores.
|
|
59
|
+
* This is the one spelling for an option (#1733):
|
|
60
|
+
*
|
|
61
|
+
* - In a filter, a plain string is literal text, sent as written. Use this to
|
|
62
|
+
* compare against an option. A `"UUID"` comparison value type also resolves
|
|
63
|
+
* its label, behind the platform's UUID wrapper; this keeps the TEXT one.
|
|
64
|
+
* - In an automation field assignment to a Dropdown or Multi-Select with
|
|
65
|
+
* static options, this is required. A plain string there is a build error.
|
|
66
|
+
*
|
|
67
|
+
* Build fails when the label names no option of the compared field, or more
|
|
68
|
+
* than one. Pull prints a stored option id this way.
|
|
56
69
|
*/
|
|
57
|
-
export declare function textOption(label: string):
|
|
70
|
+
export declare function textOption(label: string): TextOptionValue;
|
|
71
|
+
/** An option selected by label: what {@link textOption} returns. */
|
|
72
|
+
export type TextOptionValue = Extract<FilterValue<FilterField, FilterReferenceValue>, {
|
|
58
73
|
type: "TEXT";
|
|
59
|
-
}
|
|
74
|
+
}> & {
|
|
75
|
+
readonly option: true;
|
|
76
|
+
};
|
|
77
|
+
export declare function isTextOptionValue(value: unknown): value is TextOptionValue;
|
|
60
78
|
export interface CurrentUserFilterValue {
|
|
61
79
|
readonly __kind: "currentUser";
|
|
62
80
|
readonly valueType: "ID" | "EMAIL" | "DOMAIN";
|
|
63
81
|
}
|
|
64
82
|
export declare function currentUser(valueType?: "ID" | "EMAIL" | "DOMAIN"): CurrentUserFilterValue;
|
|
65
|
-
|
|
66
|
-
|
|
83
|
+
declare const FIELD_VALUE_SOURCE: unique symbol;
|
|
84
|
+
/**
|
|
85
|
+
* A field used as an explicit comparison operand, preserving its identity.
|
|
86
|
+
* `Source` is the field it was made from, so a bare string keeps a filter off
|
|
87
|
+
* views and access policies, as a bare-string left side does (#1873).
|
|
88
|
+
*/
|
|
89
|
+
export interface FieldLeftValue<Source extends FilterField = FilterField> {
|
|
67
90
|
readonly type: "FIELD";
|
|
68
91
|
readonly value: FilterField;
|
|
69
92
|
readonly aspect?: never;
|
|
70
93
|
readonly treatNullAsEquals?: true;
|
|
94
|
+
readonly [FIELD_VALUE_SOURCE]?: Source;
|
|
71
95
|
}
|
|
72
|
-
export declare function fieldValue(value:
|
|
96
|
+
export declare function fieldValue<Source extends FilterField>(value: Source): FieldLeftValue<Source>;
|
|
73
97
|
export declare function fieldValue(value: FilterField, options?: {
|
|
74
98
|
readonly aspect?: string;
|
|
75
99
|
readonly treatNullAsEquals?: boolean;
|
|
@@ -94,34 +118,67 @@ export declare function recordField(field: FilterField, options?: {
|
|
|
94
118
|
type AuthoredFilterValue = FilterValue<FilterField, FilterReferenceValue>;
|
|
95
119
|
export type FilterInput = string | number | boolean | null | Ref<unknown> | FilterReferenceInput | FilterField | CurrentUserFilterValue | AuthoredFilterValue;
|
|
96
120
|
export type LeftRef = FilterField | Ref<unknown> | FilterReferenceInput | FieldLeftValue;
|
|
121
|
+
type TokenLeftRef = FilterFieldToken | Ref<unknown> | FilterReferenceInput | FieldLeftValue<FilterFieldToken>;
|
|
97
122
|
export declare const UNRESOLVED_REFERENCE_MARKER = "__edkUnresolvedReference::";
|
|
98
123
|
export declare function refDataToFilterReference(data: import("../ref.js").RefData): FilterReference;
|
|
99
124
|
export declare function toFilterValue(input: FilterInput, valueType?: ValueType): FilterValue<FilterField, FilterReferenceValue>;
|
|
125
|
+
export declare function eq(left: TokenLeftRef, input: FilterInput, explicit?: ValueType): EqualsFilter<FilterFieldToken, FilterReferenceValue>;
|
|
100
126
|
export declare function eq(left: LeftRef, input: FilterInput, explicit?: ValueType): EqualsFilter<FilterField, FilterReferenceValue>;
|
|
127
|
+
export declare function neq(left: TokenLeftRef, input: FilterInput, explicit?: ValueType): EqualsFilter<FilterFieldToken, FilterReferenceValue>;
|
|
101
128
|
export declare function neq(left: LeftRef, input: FilterInput, explicit?: ValueType): EqualsFilter<FilterField, FilterReferenceValue>;
|
|
129
|
+
export declare function gt(left: TokenLeftRef, input: FilterInput, explicit?: ValueType): GreaterThanFilter<FilterFieldToken, FilterReferenceValue>;
|
|
102
130
|
export declare function gt(left: LeftRef, input: FilterInput, explicit?: ValueType): GreaterThanFilter<FilterField, FilterReferenceValue>;
|
|
131
|
+
export declare function gte(left: TokenLeftRef, input: FilterInput, explicit?: ValueType): GreaterThanEqualsFilter<FilterFieldToken, FilterReferenceValue>;
|
|
103
132
|
export declare function gte(left: LeftRef, input: FilterInput, explicit?: ValueType): GreaterThanEqualsFilter<FilterField, FilterReferenceValue>;
|
|
133
|
+
export declare function lt(left: TokenLeftRef, input: FilterInput, explicit?: ValueType): LessThanFilter<FilterFieldToken, FilterReferenceValue>;
|
|
104
134
|
export declare function lt(left: LeftRef, input: FilterInput, explicit?: ValueType): LessThanFilter<FilterField, FilterReferenceValue>;
|
|
135
|
+
export declare function lte(left: TokenLeftRef, input: FilterInput, explicit?: ValueType): LessThanEqualsFilter<FilterFieldToken, FilterReferenceValue>;
|
|
105
136
|
export declare function lte(left: LeftRef, input: FilterInput, explicit?: ValueType): LessThanEqualsFilter<FilterField, FilterReferenceValue>;
|
|
137
|
+
export declare function like(left: TokenLeftRef, input: FilterInput, options?: {
|
|
138
|
+
readonly not?: boolean;
|
|
139
|
+
readonly caseInsensitive?: boolean;
|
|
140
|
+
readonly mode?: Lowercase<LikeMode>;
|
|
141
|
+
}, explicit?: ValueType): LikeFilter<FilterFieldToken, FilterReferenceValue>;
|
|
106
142
|
export declare function like(left: LeftRef, input: FilterInput, options?: {
|
|
107
143
|
readonly not?: boolean;
|
|
108
144
|
readonly caseInsensitive?: boolean;
|
|
109
145
|
readonly mode?: Lowercase<LikeMode>;
|
|
110
146
|
}, explicit?: ValueType): LikeFilter<FilterField, FilterReferenceValue>;
|
|
147
|
+
export declare function isNull(left: TokenLeftRef, options?: {
|
|
148
|
+
readonly not?: boolean;
|
|
149
|
+
}, explicit?: ValueType): IsNullFilter<FilterFieldToken, FilterReferenceValue>;
|
|
111
150
|
export declare function isNull(left: LeftRef, options?: {
|
|
112
151
|
readonly not?: boolean;
|
|
113
152
|
}, explicit?: ValueType): IsNullFilter<FilterField, FilterReferenceValue>;
|
|
153
|
+
export declare function isNotNull(left: TokenLeftRef, explicit?: ValueType): IsNullFilter<FilterFieldToken, FilterReferenceValue>;
|
|
114
154
|
export declare function isNotNull(left: LeftRef, explicit?: ValueType): IsNullFilter<FilterField, FilterReferenceValue>;
|
|
155
|
+
export declare function isIn(left: TokenLeftRef, input: readonly FilterInput[], explicit?: ValueType): InFilter<FilterFieldToken, FilterReferenceValue>;
|
|
115
156
|
export declare function isIn(left: LeftRef, input: readonly FilterInput[], explicit?: ValueType): InFilter<FilterField, FilterReferenceValue>;
|
|
157
|
+
export declare function isNotIn(left: TokenLeftRef, input: readonly FilterInput[], explicit?: ValueType): InFilter<FilterFieldToken, FilterReferenceValue>;
|
|
116
158
|
export declare function isNotIn(left: LeftRef, input: readonly FilterInput[], explicit?: ValueType): InFilter<FilterField, FilterReferenceValue>;
|
|
159
|
+
export declare function between(left: TokenLeftRef, min: FilterInput, max: FilterInput, options?: {
|
|
160
|
+
readonly not?: boolean;
|
|
161
|
+
}, explicit?: ValueType): BetweenFilter<FilterFieldToken, FilterReferenceValue>;
|
|
117
162
|
export declare function between(left: LeftRef, min: FilterInput, max: FilterInput, options?: {
|
|
118
163
|
readonly not?: boolean;
|
|
119
164
|
}, explicit?: ValueType): BetweenFilter<FilterField, FilterReferenceValue>;
|
|
165
|
+
export declare function currentRange(left: TokenLeftRef, options: {
|
|
166
|
+
readonly unit: DateTimeUnit;
|
|
167
|
+
readonly semantic?: boolean;
|
|
168
|
+
readonly isoWeek?: boolean;
|
|
169
|
+
}, explicit?: ValueType): CurrentRangeFilter<FilterFieldToken, FilterReferenceValue>;
|
|
120
170
|
export declare function currentRange(left: LeftRef, options: {
|
|
121
171
|
readonly unit: DateTimeUnit;
|
|
122
172
|
readonly semantic?: boolean;
|
|
123
173
|
readonly isoWeek?: boolean;
|
|
124
174
|
}, explicit?: ValueType): CurrentRangeFilter<FilterField, FilterReferenceValue>;
|
|
175
|
+
export declare function consecutiveRange(left: TokenLeftRef, options: {
|
|
176
|
+
readonly unit: DateTimeUnit;
|
|
177
|
+
readonly count: number;
|
|
178
|
+
readonly offset: number;
|
|
179
|
+
readonly semantic?: boolean;
|
|
180
|
+
readonly isoWeek?: boolean;
|
|
181
|
+
}, explicit?: ValueType): ConsecutiveRangeFilter<FilterFieldToken, FilterReferenceValue>;
|
|
125
182
|
export declare function consecutiveRange(left: LeftRef, options: {
|
|
126
183
|
readonly unit: DateTimeUnit;
|
|
127
184
|
readonly count: number;
|
|
@@ -129,17 +186,31 @@ export declare function consecutiveRange(left: LeftRef, options: {
|
|
|
129
186
|
readonly semantic?: boolean;
|
|
130
187
|
readonly isoWeek?: boolean;
|
|
131
188
|
}, explicit?: ValueType): ConsecutiveRangeFilter<FilterField, FilterReferenceValue>;
|
|
189
|
+
export declare function contains(left: TokenLeftRef, input: FilterInput | readonly FilterInput[], options?: {
|
|
190
|
+
readonly not?: boolean;
|
|
191
|
+
}, explicit?: ValueType): ContainsFilter<FilterFieldToken, FilterReferenceValue>;
|
|
132
192
|
export declare function contains(left: LeftRef, input: FilterInput | readonly FilterInput[], options?: {
|
|
133
193
|
readonly not?: boolean;
|
|
134
194
|
}, explicit?: ValueType): ContainsFilter<FilterField, FilterReferenceValue>;
|
|
195
|
+
export declare function overlaps(left: TokenLeftRef, input: FilterInput | readonly FilterInput[], options?: {
|
|
196
|
+
readonly not?: boolean;
|
|
197
|
+
}, explicit?: ValueType): OverlapsFilter<FilterFieldToken, FilterReferenceValue>;
|
|
135
198
|
export declare function overlaps(left: LeftRef, input: FilterInput | readonly FilterInput[], options?: {
|
|
136
199
|
readonly not?: boolean;
|
|
137
200
|
}, explicit?: ValueType): OverlapsFilter<FilterField, FilterReferenceValue>;
|
|
138
|
-
export declare function and(...children: readonly Filter<
|
|
139
|
-
export declare function or(...children: readonly Filter<
|
|
201
|
+
export declare function and<F extends FilterField = FilterField>(...children: readonly Filter<F, FilterReferenceValue>[]): AndFilter<F, FilterReferenceValue>;
|
|
202
|
+
export declare function or<F extends FilterField = FilterField>(...children: readonly Filter<F, FilterReferenceValue>[]): OrFilter<F, FilterReferenceValue>;
|
|
140
203
|
export declare function whereTrue(): TrueFilter;
|
|
141
204
|
export declare function whereFalse(): FalseFilter;
|
|
205
|
+
/**
|
|
206
|
+
* A token filter keeps its type only with a token `aspect`; a bare-string
|
|
207
|
+
* `aspect` widens it, so views and access policies reject it (#1873).
|
|
208
|
+
*/
|
|
209
|
+
export declare function withOptions<T extends Filter<FilterFieldToken, FilterReferenceValue>>(value: T, options: {
|
|
210
|
+
readonly aspect?: FilterFieldToken;
|
|
211
|
+
readonly semantic?: boolean;
|
|
212
|
+
}): T;
|
|
142
213
|
export declare function withOptions<T extends Filter<FilterField, FilterReferenceValue>>(value: T, options: {
|
|
143
214
|
readonly aspect?: FilterField;
|
|
144
215
|
readonly semantic?: boolean;
|
|
145
|
-
}): T;
|
|
216
|
+
}): T extends Filter<FilterFieldToken, FilterReferenceValue> ? Filter<FilterField, FilterReferenceValue> : T;
|
|
@@ -76,16 +76,28 @@ export function isFilterReferenceInput(value) {
|
|
|
76
76
|
return typeof value === "object" && value !== null && FILTER_REFERENCE_BRAND in value;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* A picklist, status, or stage option selected by its LABEL
|
|
80
|
-
* the
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
79
|
+
* A picklist, status, or stage option selected by its LABEL. Build resolves
|
|
80
|
+
* the label to that option's id, which is what the platform stores.
|
|
81
|
+
* This is the one spelling for an option (#1733):
|
|
82
|
+
*
|
|
83
|
+
* - In a filter, a plain string is literal text, sent as written. Use this to
|
|
84
|
+
* compare against an option. A `"UUID"` comparison value type also resolves
|
|
85
|
+
* its label, behind the platform's UUID wrapper; this keeps the TEXT one.
|
|
86
|
+
* - In an automation field assignment to a Dropdown or Multi-Select with
|
|
87
|
+
* static options, this is required. A plain string there is a build error.
|
|
88
|
+
*
|
|
89
|
+
* Build fails when the label names no option of the compared field, or more
|
|
90
|
+
* than one. Pull prints a stored option id this way.
|
|
85
91
|
*/
|
|
86
92
|
export function textOption(label) {
|
|
87
93
|
return { type: "TEXT", value: label, option: true };
|
|
88
94
|
}
|
|
95
|
+
export function isTextOptionValue(value) {
|
|
96
|
+
return typeof value === "object" && value !== null &&
|
|
97
|
+
value.type === "TEXT" &&
|
|
98
|
+
value.option === true &&
|
|
99
|
+
typeof value.value === "string";
|
|
100
|
+
}
|
|
89
101
|
export function currentUser(valueType = "ID") {
|
|
90
102
|
return { __kind: "currentUser", valueType };
|
|
91
103
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dropdown option selections in chart, table and lookup-field filters
|
|
3
|
+
* (#2582), the same rule #1733 gave automation, view and access-policy
|
|
4
|
+
* filters. `filter.textOption(label)` is the preferred spelling: it must name
|
|
5
|
+
* exactly one option of the field and builds to that option's id through the
|
|
6
|
+
* field's `<label>_options_by_label` local (an app's Status and Stage use the
|
|
7
|
+
* app's `<ns>_status_options_by_label` / `<ns>_stage_options_by_label`, as
|
|
8
|
+
* access policies, automations and dynamic layouts do). A plain string or a
|
|
9
|
+
* raw option id still builds as written and warns, naming
|
|
10
|
+
* `filter.textOption(...)`. Pull reads the export's options-by-label lookup,
|
|
11
|
+
* and an app's `status_option_ids_by_label`, back as `filter.textOption(label)`.
|
|
12
|
+
*/
|
|
13
|
+
import type { OptionIdIndex } from "../../../engine/pull/field-refs-registry.js";
|
|
14
|
+
import { type ChildResourceScope, type TfValue } from "../../../engine/tf/index.js";
|
|
15
|
+
interface OptionFieldToken {
|
|
16
|
+
readonly __kind?: string;
|
|
17
|
+
readonly refName?: string;
|
|
18
|
+
readonly name?: string;
|
|
19
|
+
readonly options?: readonly string[];
|
|
20
|
+
readonly tags?: readonly string[];
|
|
21
|
+
/** Natural bag key when pull re-keyed off a reserved system key (#1871). */
|
|
22
|
+
readonly resourceKey?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface OptionSelectionOwner {
|
|
25
|
+
/** Where the filter sits, e.g. `chart "Votes".subscriptions[0].filter`. */
|
|
26
|
+
readonly where: string;
|
|
27
|
+
/** The resource address and name that warnings name. */
|
|
28
|
+
readonly address: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly ownerKind: "chart" | "table" | "field";
|
|
31
|
+
readonly optionIds?: OptionIdIndex;
|
|
32
|
+
/**
|
|
33
|
+
* The field's options-by-label local, when the field's owner is built in
|
|
34
|
+
* this workspace. Without it `filter.textOption(label)` has no option id
|
|
35
|
+
* to build and fails.
|
|
36
|
+
*/
|
|
37
|
+
readonly optionsLocal: (field: OptionFieldToken) => string | undefined;
|
|
38
|
+
}
|
|
39
|
+
/** The options-by-label local of a field owned by an app or element in this build. */
|
|
40
|
+
export declare function optionsLocalName(ownerTfLabel: string, scope: ChildResourceScope, field: OptionFieldToken): string | undefined;
|
|
41
|
+
/** The filter codec's `literal` hook for an owner that compares stored option ids. */
|
|
42
|
+
export declare function optionSelectionLiteral(owner: OptionSelectionOwner): (value: TfValue, field: unknown, valueType: string, isOptionLabel: boolean) => TfValue;
|
|
43
|
+
/**
|
|
44
|
+
* Pull: the export writes a stored option id as
|
|
45
|
+
* `local.<field>_options_by_label["<label>"]`, a stage id as
|
|
46
|
+
* `local.<ns>_stage_options_by_label["<label>"]` and a status id as
|
|
47
|
+
* `elementum_app.<ns>.status_option_ids_by_label["<label>"]`. Read each back
|
|
48
|
+
* as the label; build writes the same option's id back through the field,
|
|
49
|
+
* stage or status local (#2582 S1).
|
|
50
|
+
*/
|
|
51
|
+
export declare function optionLookupLabel(value: TfValue | undefined): string | undefined;
|
|
52
|
+
/** The decode hooks that print a stored option lookup as `filter.textOption(label)`. */
|
|
53
|
+
export declare const optionLookupDecode: {
|
|
54
|
+
readonly literal: (value: TfValue) => TfValue;
|
|
55
|
+
readonly optionLookupsAreIdentities: (stored: TfValue) => boolean;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dropdown option selections in chart, table and lookup-field filters
|
|
3
|
+
* (#2582), the same rule #1733 gave automation, view and access-policy
|
|
4
|
+
* filters. `filter.textOption(label)` is the preferred spelling: it must name
|
|
5
|
+
* exactly one option of the field and builds to that option's id through the
|
|
6
|
+
* field's `<label>_options_by_label` local (an app's Status and Stage use the
|
|
7
|
+
* app's `<ns>_status_options_by_label` / `<ns>_stage_options_by_label`, as
|
|
8
|
+
* access policies, automations and dynamic layouts do). A plain string or a
|
|
9
|
+
* raw option id still builds as written and warns, naming
|
|
10
|
+
* `filter.textOption(...)`. Pull reads the export's options-by-label lookup,
|
|
11
|
+
* and an app's `status_option_ids_by_label`, back as `filter.textOption(label)`.
|
|
12
|
+
*/
|
|
13
|
+
import { EntityTfError } from "../../../engine/entity.js";
|
|
14
|
+
import { recordValidations } from "../../../engine/validation.js";
|
|
15
|
+
import { expr, isTfExpr, isUuid, scopedResourceLabel, tsLabelToTfLabel } from "../../../engine/tf/index.js";
|
|
16
|
+
import { plainOptionStringWarning, rawOptionIdWarning } from "../raw-option-id.js";
|
|
17
|
+
function optionField(field) {
|
|
18
|
+
if (typeof field !== "object" || field === null)
|
|
19
|
+
return undefined;
|
|
20
|
+
const token = field;
|
|
21
|
+
// A Stage token carries its stage names as `options`; it resolves through the stage local below.
|
|
22
|
+
if (token.__kind !== "field" || token.options === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
return token;
|
|
25
|
+
}
|
|
26
|
+
/** The options-by-label local of a field owned by an app or element in this build. */
|
|
27
|
+
export function optionsLocalName(ownerTfLabel, scope, field) {
|
|
28
|
+
// #2582 S1: an app's Status and Stage ids live on the app's own locals
|
|
29
|
+
// (app/locals.ts), not a field local. Hand-built refs carry no tags, so
|
|
30
|
+
// match the system key too, as access policies do. Elements have neither.
|
|
31
|
+
if (scope === "app" && (field.tags?.includes("STATUS") === true || field.refName === "status"))
|
|
32
|
+
return `${ownerTfLabel}_status_options_by_label`;
|
|
33
|
+
if (scope === "app" && (field.tags?.includes("STAGE") === true || field.refName === "stage"))
|
|
34
|
+
return `${ownerTfLabel}_stage_options_by_label`;
|
|
35
|
+
if (field.refName === undefined || field.refName === "")
|
|
36
|
+
return undefined;
|
|
37
|
+
// Same child part fieldToTf uses: resourceKey when pull re-keyed (#1871).
|
|
38
|
+
const childPart = tsLabelToTfLabel(field.resourceKey ?? field.refName);
|
|
39
|
+
return `${scopedResourceLabel(ownerTfLabel, childPart, scope)}_options_by_label`;
|
|
40
|
+
}
|
|
41
|
+
/** The filter codec's `literal` hook for an owner that compares stored option ids. */
|
|
42
|
+
export function optionSelectionLiteral(owner) {
|
|
43
|
+
return (value, field, valueType, isOptionLabel) => {
|
|
44
|
+
if (typeof value !== "string" || value === "")
|
|
45
|
+
return value;
|
|
46
|
+
const token = optionField(field);
|
|
47
|
+
if (token === undefined)
|
|
48
|
+
return value;
|
|
49
|
+
const options = token.options ?? [];
|
|
50
|
+
const fieldName = token.name ?? token.refName ?? "unknown";
|
|
51
|
+
const warn = (message) => recordValidations([{ severity: "warning", address: owner.address, name: owner.name, ownerKind: owner.ownerKind, message }]);
|
|
52
|
+
if (isOptionLabel && valueType !== "text") {
|
|
53
|
+
// #2582 N1: the codec also sets isOptionLabel for a UUID wrapper. A
|
|
54
|
+
// label it names builds to the option's lookup; a raw id or any other
|
|
55
|
+
// string falls through to the warnings below.
|
|
56
|
+
const local = options.filter((option) => option === value).length === 1 ? owner.optionsLocal(token) : undefined;
|
|
57
|
+
if (local !== undefined)
|
|
58
|
+
return expr.local(local, [{ index: value }]);
|
|
59
|
+
}
|
|
60
|
+
else if (isOptionLabel) {
|
|
61
|
+
const matches = options.filter((option) => option === value).length;
|
|
62
|
+
if (matches !== 1) {
|
|
63
|
+
throw new EntityTfError(matches === 0
|
|
64
|
+
? `${owner.where}: filter.textOption(${JSON.stringify(value)}) names no option of field "${fieldName}"; expected one of: ${options.map((option) => JSON.stringify(option)).join(", ")}`
|
|
65
|
+
: `${owner.where}: filter.textOption(${JSON.stringify(value)}) matches ${matches} options of field "${fieldName}", so it names no single option`);
|
|
66
|
+
}
|
|
67
|
+
const local = owner.optionsLocal(token);
|
|
68
|
+
if (local === undefined) {
|
|
69
|
+
throw new EntityTfError(`${owner.where}: filter.textOption(${JSON.stringify(value)}) on field "${fieldName}" needs that field's app or element in this workspace to build its option id`);
|
|
70
|
+
}
|
|
71
|
+
return expr.local(local, [{ index: value }]);
|
|
72
|
+
}
|
|
73
|
+
const slot = owner.where;
|
|
74
|
+
if (isUuid(value) && !options.includes(value)) {
|
|
75
|
+
warn(rawOptionIdWarning({ slot, fieldName, id: value, options, localName: owner.optionsLocal(token), index: owner.optionIds }));
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
warn(plainOptionStringWarning(slot, fieldName, value, options, false));
|
|
79
|
+
return value;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function indexLabel(segment) {
|
|
83
|
+
return typeof segment === "object" && segment !== null && "index" in segment && typeof segment.index === "string" ? segment.index : undefined;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Pull: the export writes a stored option id as
|
|
87
|
+
* `local.<field>_options_by_label["<label>"]`, a stage id as
|
|
88
|
+
* `local.<ns>_stage_options_by_label["<label>"]` and a status id as
|
|
89
|
+
* `elementum_app.<ns>.status_option_ids_by_label["<label>"]`. Read each back
|
|
90
|
+
* as the label; build writes the same option's id back through the field,
|
|
91
|
+
* stage or status local (#2582 S1).
|
|
92
|
+
*/
|
|
93
|
+
export function optionLookupLabel(value) {
|
|
94
|
+
if (value === undefined || !isTfExpr(value))
|
|
95
|
+
return undefined;
|
|
96
|
+
if (value.$expr === "local") {
|
|
97
|
+
return value.name.endsWith("_options_by_label") && value.path.length === 1 ? indexLabel(value.path[0]) : undefined;
|
|
98
|
+
}
|
|
99
|
+
if (value.$expr === "resource-attr" && value.type === "elementum_app" && value.path.length === 2 && value.path[0] === "status_option_ids_by_label") {
|
|
100
|
+
return indexLabel(value.path[1]);
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
/** The decode hooks that print a stored option lookup as `filter.textOption(label)`. */
|
|
105
|
+
export const optionLookupDecode = {
|
|
106
|
+
literal: (value) => optionLookupLabel(value) ?? value,
|
|
107
|
+
optionLookupsAreIdentities: (stored) => optionLookupLabel(stored) !== undefined,
|
|
108
|
+
};
|
|
@@ -14,11 +14,15 @@ export function printFilter(filter, codec) {
|
|
|
14
14
|
const uuidValues = literals.length > 0 && literals.every((literal) => literal.type === "UUID");
|
|
15
15
|
const explicitType = uuidValues ? `, ${quote("UUID")}` : "";
|
|
16
16
|
const impliedLiteralType = stringLiteralTypeImpliedBy(filter, uuidValues);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
// An option selection prints as `filter.textOption(label)` whatever the
|
|
18
|
+
// left side implies: a bare or wrapped TEXT literal builds as a raw word (#1733).
|
|
19
|
+
const value = (input) => input.type === "TEXT" && input.option === true
|
|
20
|
+
? printFilterValue(input, codec, call, quote)
|
|
21
|
+
: input.type === "UUID"
|
|
22
|
+
? uuidValues ? quote(input.value) : `{ type: "UUID", value: ${quote(input.value)} }`
|
|
23
|
+
: (input.type === "TEXT" || input.type === "DATE" || input.type === "DATETIME") && impliedLiteralType !== undefined && input.type !== impliedLiteralType
|
|
24
|
+
? `{ type: ${quote(input.type)}, value: ${quote(input.value)} }`
|
|
25
|
+
: printFilterValue(input, codec, call, quote);
|
|
22
26
|
if ("leftValue" in filter && filter.leftValue?.type === "FIELD") {
|
|
23
27
|
const operand = filter.leftValue;
|
|
24
28
|
if ((operand.aspect != null && operand.aspect !== "") || (operand.treatNullAsEquals != null && operand.treatNullAsEquals !== true)) {
|
|
@@ -96,6 +96,11 @@ export interface FilterToTfCodec {
|
|
|
96
96
|
* lookup, whichever wrapper that is.
|
|
97
97
|
*/
|
|
98
98
|
readonly literal?: (value: TfValue, field: unknown | undefined, valueType: string, isOptionLabel: boolean) => TfValue;
|
|
99
|
+
/**
|
|
100
|
+
* The owner keeps an option label its field no longer lists as written
|
|
101
|
+
* (a pulled automation, #1733), and its `literal` hook already warned.
|
|
102
|
+
*/
|
|
103
|
+
readonly keepUnresolvedOptions?: boolean;
|
|
99
104
|
/** A RECORD_FIELD value's source-record field; without it only raw platform ids encode. */
|
|
100
105
|
readonly recordField?: (value: unknown) => TfValue;
|
|
101
106
|
/** The owning app or element an `includeOwner` RECORD_FIELD value stores; without it such a value cannot encode. */
|
|
@@ -129,14 +134,14 @@ export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
|
|
|
129
134
|
/** Whether a RECORD_FIELD `object` reference names the owning app or element; without it only raw platform ids decode. */
|
|
130
135
|
readonly recordFieldOwner?: (value: TfValue) => boolean;
|
|
131
136
|
/**
|
|
132
|
-
* A TEXT-wrapped literal `literal` resolved from an option-id lookup
|
|
133
|
-
* option LABEL, not a stored word. Set this when the
|
|
134
|
-
* bare
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
137
|
+
* A TEXT-wrapped literal that `literal` resolved from an option-id lookup or
|
|
138
|
+
* a raw option id is an option LABEL, not a stored word. Set this when the
|
|
139
|
+
* owner keeps a bare string as raw text, as list views and automations do
|
|
140
|
+
* (#1733), so the label prints as `filter.textOption(...)`. An owner whose
|
|
141
|
+
* hook also rewrites non-option values (an access policy's stage keys)
|
|
142
|
+
* passes a predicate naming which stored values are option lookups.
|
|
138
143
|
*/
|
|
139
|
-
readonly optionLookupsAreIdentities?: boolean;
|
|
144
|
+
readonly optionLookupsAreIdentities?: boolean | ((stored: TfValue) => boolean);
|
|
140
145
|
}
|
|
141
146
|
export type WireFilterValue = Readonly<{
|
|
142
147
|
type: string;
|
|
@@ -280,7 +280,7 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
|
280
280
|
const resolved = codec.literal?.(raw.value, field, type, isOptionLabel) ?? raw.value;
|
|
281
281
|
// Writing an option label where the platform stored an id is a silent data
|
|
282
282
|
// change on a live view. Only a resolved lookup is an expression.
|
|
283
|
-
if (raw.option === true && !isTfExpr(resolved)) {
|
|
283
|
+
if (raw.option === true && !isTfExpr(resolved) && codec.keepUnresolvedOptions !== true) {
|
|
284
284
|
throw new EntityTfError(`option selection ${JSON.stringify(raw.value)} has no declared option identity`);
|
|
285
285
|
}
|
|
286
286
|
if (isTfExpr(resolved))
|
|
@@ -641,10 +641,14 @@ function filterValueFromTf(value, codec, fieldScope, field) {
|
|
|
641
641
|
case "number": return { type: "NUMBER", value: typeof literal === "number" ? literal : Number(literal) };
|
|
642
642
|
case "boolean": return { type: "BOOLEAN", value: typeof literal === "boolean" ? literal : String(literal).toLowerCase() === "true" };
|
|
643
643
|
case "text": {
|
|
644
|
-
// `type` stays the stored wrapper.
|
|
645
|
-
//
|
|
646
|
-
// the second, independent fact, which a TEXT
|
|
647
|
-
|
|
644
|
+
// `type` stays the stored wrapper. A value the literal hook rewrote, an
|
|
645
|
+
// id lookup expression or a raw option id, was an option, so this
|
|
646
|
+
// literal is its LABEL: the second, independent fact, which a TEXT
|
|
647
|
+
// wrapper cannot express. Any other stored text stays plain (#1733).
|
|
648
|
+
const identities = codec.optionLookupsAreIdentities;
|
|
649
|
+
const option = typeof identities === "function"
|
|
650
|
+
? identities(value.value)
|
|
651
|
+
: identities === true && (isTfExpr(value.value) || literal !== value.value);
|
|
648
652
|
return { type: "TEXT", value: String(literal), ...(option && { option: true }) };
|
|
649
653
|
}
|
|
650
654
|
case "uuid":
|