@elementumai/edk 0.9.18 → 0.9.19
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 -3
- package/dist-sdk/src/catalog/factories.d.ts +11 -0
- package/dist-sdk/src/catalog/factories.js +6 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.d.ts +39 -1
- package/dist-sdk/src/catalog/org.js +460 -50
- package/dist-sdk/src/catalog/types.d.ts +10 -0
- package/dist-sdk/src/catalog/types.js +2 -0
- package/dist-sdk/src/engine/pull/ref-only.js +54 -20
- package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
- package/dist-sdk/src/engine/pull/result-output.js +1 -1
- package/dist-sdk/src/engine/tf/expr.js +38 -13
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +2 -0
- package/dist-sdk/src/engine/tf/labels.js +4 -0
- package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
- package/dist-sdk/src/engine/tf/parse.js +105 -6
- package/dist-sdk/src/engine/workspace/loader.js +49 -12
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +11 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -1
- package/dist-sdk/src/entities/app/build.d.ts +10 -0
- package/dist-sdk/src/entities/app/build.js +0 -13
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -3
- 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 +13 -0
- package/dist-sdk/src/entities/app/to-tf.js +2 -0
- package/dist-sdk/src/entities/automation/build.d.ts +2 -1
- package/dist-sdk/src/entities/automation/build.js +27 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +6 -0
- package/dist-sdk/src/entities/automation/from-tf.js +135 -26
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +2 -0
- package/dist-sdk/src/entities/automation/module.js +56 -0
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
- package/dist-sdk/src/entities/automation/system-ref-name.js +44 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +15 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +38 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -2
- package/dist-sdk/src/entities/automation/to-tf.js +158 -84
- package/dist-sdk/src/entities/automation/types.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.js +33 -17
- package/dist-sdk/src/entities/chart/module.js +3 -1
- package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
- package/dist-sdk/src/entities/chart/printer.js +26 -16
- package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
- package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
- package/dist-sdk/src/entities/chart/to-tf.js +12 -10
- package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +51 -2
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
- package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
- package/dist-sdk/src/entities/element/build.d.ts +8 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +6 -2
- package/dist-sdk/src/entities/element/index.d.ts +1 -0
- package/dist-sdk/src/entities/element/index.js +1 -0
- package/dist-sdk/src/entities/element/module.js +2 -0
- package/dist-sdk/src/entities/element/to-tf.js +12 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/field/from-tf.js +11 -0
- package/dist-sdk/src/entities/field/to-tf.js +13 -9
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +19 -10
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +23 -2
- package/dist-sdk/src/entities/shared/filters/index.js +24 -1
- package/dist-sdk/src/entities/shared/filters/print.js +14 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +23 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +46 -14
- package/dist-sdk/src/entities/shared/filters/types.d.ts +13 -4
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
- package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
- package/dist-sdk/src/entities/skill/access-policy.js +101 -0
- package/dist-sdk/src/entities/skill/build.d.ts +3 -0
- package/dist-sdk/src/entities/skill/build.js +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +21 -0
- package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill/from-tf.js +4 -9
- package/dist-sdk/src/entities/skill/index.d.ts +2 -0
- package/dist-sdk/src/entities/skill/index.js +1 -0
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill/to-tf.js +5 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +3 -3
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +224 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +36 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +288 -0
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +121 -0
- package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/view/from-tf.js +42 -7
- package/dist-sdk/src/entities/view/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/view/to-tf.js +30 -1
- package/dist-sdk/src/entities/view/types.js +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +2 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +25 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +43 -0
- package/dist-sdk/src/graph/index.js +9 -0
- package/dist-sdk/src/graph/types.d.ts +78 -0
- package/package.json +2 -1
|
@@ -76,16 +76,7 @@ function relationshipFromTf(block, owner, ctx) {
|
|
|
76
76
|
// Only "app"/"element" targets carry a resolvable field scope here -
|
|
77
77
|
// a table target has no fallback, since table columns never go
|
|
78
78
|
// through this `_field` resource-attr path anyway.
|
|
79
|
-
const targetFilterOwner = target
|
|
80
|
-
? {
|
|
81
|
-
type: target.kind === "element" ? "elementum_element" : "elementum_app",
|
|
82
|
-
label: target.tfLabel ?? target.key,
|
|
83
|
-
ownerRefName: target.key,
|
|
84
|
-
ownerTfLabel: target.tfLabel ?? target.key,
|
|
85
|
-
scope: target.kind,
|
|
86
|
-
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
87
|
-
}
|
|
88
|
-
: undefined;
|
|
79
|
+
const targetFilterOwner = filterOwnerForTarget(target, ctx);
|
|
89
80
|
try {
|
|
90
81
|
if (targetFilterOwner === undefined)
|
|
91
82
|
throw ownerErr;
|
|
@@ -105,6 +96,37 @@ function relationshipFromTf(block, owner, ctx) {
|
|
|
105
96
|
}
|
|
106
97
|
return { key, target, columns, ...(filter !== undefined && { filter }) };
|
|
107
98
|
}
|
|
99
|
+
function filterOwnerForTarget(target, ctx) {
|
|
100
|
+
return target.kind === "app" || target.kind === "element"
|
|
101
|
+
? {
|
|
102
|
+
type: target.kind === "element" ? "elementum_element" : "elementum_app",
|
|
103
|
+
label: target.tfLabel ?? target.key,
|
|
104
|
+
ownerRefName: target.key,
|
|
105
|
+
ownerTfLabel: target.tfLabel ?? target.key,
|
|
106
|
+
scope: target.kind,
|
|
107
|
+
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
108
|
+
dataField: (label) => targetDataFilterField(label, target, ctx),
|
|
109
|
+
}
|
|
110
|
+
: undefined;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Filter-field scope for records of the app or element `aspectId` points at,
|
|
114
|
+
* managed or data-sourced. Other filters over a target's records (dynamic
|
|
115
|
+
* layout related-items blocks) decode their fields the same way.
|
|
116
|
+
*/
|
|
117
|
+
export function filterOwnerForAspect(aspectId, ctx) {
|
|
118
|
+
for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
|
|
119
|
+
const resourceLabel = resourceRefLabel(aspectId, type);
|
|
120
|
+
if (resourceLabel !== undefined) {
|
|
121
|
+
return filterOwnerForTarget({ kind, key: tfLabelToTsLabel(resourceLabel), name: tfLabelToTsLabel(resourceLabel), tfLabel: resourceLabel, managed: true }, ctx);
|
|
122
|
+
}
|
|
123
|
+
const dataLabel = dataRefLabel(aspectId, type);
|
|
124
|
+
if (dataLabel !== undefined) {
|
|
125
|
+
return filterOwnerForTarget({ kind, tfLabel: dataLabel, managed: false, ...resolveDataAspectTarget(ctx, kind, dataLabel) }, ctx);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
108
130
|
function targetRef(value, owner, ctx) {
|
|
109
131
|
if (value === undefined)
|
|
110
132
|
return undefined;
|
|
@@ -132,6 +154,27 @@ function targetRef(value, owner, ctx) {
|
|
|
132
154
|
}
|
|
133
155
|
return undefined;
|
|
134
156
|
}
|
|
157
|
+
/** A relationship filter on the unmanaged target's own field, decoded like a join column's related field. */
|
|
158
|
+
function targetDataFilterField(label, target, ctx) {
|
|
159
|
+
const field = relatedFieldRef({ $expr: "data-attr", type: "elementum_field", label, path: ["id"] }, target, ctx);
|
|
160
|
+
if (field === undefined || field.kind !== "field" || field.parent === undefined)
|
|
161
|
+
return undefined;
|
|
162
|
+
const entityType = field.parentKind ?? (target.kind === "app" || target.kind === "element" ? target.kind : undefined);
|
|
163
|
+
if (entityType === undefined)
|
|
164
|
+
return undefined;
|
|
165
|
+
return {
|
|
166
|
+
kind: "field",
|
|
167
|
+
appHandle: field.parent,
|
|
168
|
+
fieldKey: field.key,
|
|
169
|
+
foreign: {
|
|
170
|
+
entityType,
|
|
171
|
+
name: field.parentName ?? target.name ?? field.parent,
|
|
172
|
+
...(field.parentNamespace !== undefined ? { namespace: field.parentNamespace } : {}),
|
|
173
|
+
fieldName: field.name,
|
|
174
|
+
...(field.fieldType !== undefined ? { fieldType: field.fieldType } : {}),
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
135
178
|
function relatedFieldRef(value, target, ctx) {
|
|
136
179
|
if (value === undefined)
|
|
137
180
|
return undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
2
2
|
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
3
|
+
import { type FilterToTfContext } from "../access-policy/to-tf.js";
|
|
3
4
|
import type { Filter } from "../shared/filters/types.js";
|
|
4
5
|
interface RefWire {
|
|
5
6
|
readonly __kind?: string;
|
|
@@ -29,5 +30,12 @@ export interface RelationshipsToTfOptions {
|
|
|
29
30
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
30
31
|
readonly diagnostics: string[];
|
|
31
32
|
}
|
|
33
|
+
type TargetResolutionOptions = Omit<RelationshipsToTfOptions, "ownerType">;
|
|
32
34
|
export declare function relationshipsToTf(relationships: Readonly<Record<string, RelationshipWire>> | undefined, opts: RelationshipsToTfOptions): TfBlock[];
|
|
35
|
+
/**
|
|
36
|
+
* `filterToTf` hook for a filter over the records of `targetToken`, so the
|
|
37
|
+
* target's own fields (system fields included) resolve against the target
|
|
38
|
+
* instead of the filter's owner.
|
|
39
|
+
*/
|
|
40
|
+
export declare function targetFilterFieldResolver(targetToken: RefWire, where: string, opts: TargetResolutionOptions): NonNullable<FilterToTfContext["foreignField"]> | undefined;
|
|
33
41
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { workspaceAspectKey, } from "../../engine/build/context.js";
|
|
2
|
-
import { expr, isCanonicalTsLabel,
|
|
2
|
+
import { expr, isCanonicalTsLabel, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
3
3
|
import { filterToTf } from "../access-policy/to-tf.js";
|
|
4
|
-
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
4
|
+
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
5
5
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
6
6
|
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
|
|
7
7
|
import { autoRelationColumnError } from "./column-contract.js";
|
|
@@ -49,6 +49,9 @@ export function relationshipsToTf(relationships, opts) {
|
|
|
49
49
|
objectId: opts.objectId,
|
|
50
50
|
orgRefs: opts.orgRefs,
|
|
51
51
|
diagnostics: opts.diagnostics,
|
|
52
|
+
foreignField: (token, fieldWhere) => token.parent === target.refName
|
|
53
|
+
? resolveRelatedField({ __kind: "field", ...token }, target, fieldWhere, opts)
|
|
54
|
+
: undefined,
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
57
|
const tfKey = tsLabelToTfLabel(key);
|
|
@@ -136,6 +139,19 @@ function resolveTarget(value, where, opts) {
|
|
|
136
139
|
managed: false,
|
|
137
140
|
};
|
|
138
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* `filterToTf` hook for a filter over the records of `targetToken`, so the
|
|
144
|
+
* target's own fields (system fields included) resolve against the target
|
|
145
|
+
* instead of the filter's owner.
|
|
146
|
+
*/
|
|
147
|
+
export function targetFilterFieldResolver(targetToken, where, opts) {
|
|
148
|
+
const target = resolveTarget(targetToken, where, opts);
|
|
149
|
+
if (target === undefined)
|
|
150
|
+
return undefined;
|
|
151
|
+
return (token, fieldWhere) => token.parent === target.refName
|
|
152
|
+
? resolveRelatedField({ __kind: "field", ...token }, target, fieldWhere, opts)
|
|
153
|
+
: undefined;
|
|
154
|
+
}
|
|
139
155
|
function resolveRelatedField(value, target, where, opts) {
|
|
140
156
|
if (value?.__kind === "recordIdentity") {
|
|
141
157
|
if (value.target === undefined) {
|
|
@@ -173,14 +189,7 @@ function resolveRelatedField(value, target, where, opts) {
|
|
|
173
189
|
return direct;
|
|
174
190
|
}
|
|
175
191
|
const name = value?.name ?? refName;
|
|
176
|
-
const
|
|
177
|
-
? "elementum_app"
|
|
178
|
-
: target.kind === "element"
|
|
179
|
-
? "elementum_element"
|
|
180
|
-
: target.kind === "task"
|
|
181
|
-
? "elementum_task"
|
|
182
|
-
: "elementum_table";
|
|
183
|
-
const label = sanitizeName(`${targetResourceType}_${target.tfLabel ?? target.refName}_${name}`);
|
|
192
|
+
const label = foreignFieldDataLabel(target.kind, target.tfLabel ?? target.refName, name);
|
|
184
193
|
opts.orgRefs.foreignField("elementum_field", label, target.value, name);
|
|
185
194
|
return expr.dataAttr("elementum_field", label, ["id"]);
|
|
186
195
|
}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* filters, for instance, only produce `literal`, `field`, `app`, and
|
|
34
34
|
* `unresolved`).
|
|
35
35
|
*/
|
|
36
|
-
import type { UserFieldKey } from "../../../catalog/types.js";
|
|
36
|
+
import type { UserFieldKey, UserGroupFieldKey } from "../../../catalog/types.js";
|
|
37
37
|
/** Reference to an app: `<appHandle>`. */
|
|
38
38
|
export interface AppRefAst {
|
|
39
39
|
readonly kind: "app";
|
|
@@ -72,6 +72,11 @@ export interface UserFieldRefAst {
|
|
|
72
72
|
readonly kind: "userField";
|
|
73
73
|
readonly fieldKey: UserFieldKey;
|
|
74
74
|
}
|
|
75
|
+
/** Reference to a fixed platform user-group attribute. */
|
|
76
|
+
export interface UserGroupFieldRefAst {
|
|
77
|
+
readonly kind: "userGroupField";
|
|
78
|
+
readonly fieldKey: UserGroupFieldKey;
|
|
79
|
+
}
|
|
75
80
|
/** Reference to an element's search table: `<handle>.searchTables.<tableKey>`. */
|
|
76
81
|
export interface SearchTableRefAst {
|
|
77
82
|
readonly kind: "searchTable";
|
|
@@ -246,7 +251,7 @@ export type RefExpr =
|
|
|
246
251
|
| {
|
|
247
252
|
kind: "template";
|
|
248
253
|
parts: readonly (string | RefExpr)[];
|
|
249
|
-
} | FieldRefAst | UserFieldRefAst | AppRefAst | AgentRefAst | AutomationRefAst | DocumentModelRefAst | DocumentModelFieldRefAst | ApprovalChainRefAst | DatamineRefAst | TableRefAst | TableColumnRefAst | SearchTableRefAst | ConnectorRefAst | CloudLinkRefAst | ProcedureRefAst | PhoneServiceRefAst | UserRefAst | UnresolvedRefAst
|
|
254
|
+
} | FieldRefAst | UserFieldRefAst | UserGroupFieldRefAst | AppRefAst | AgentRefAst | AutomationRefAst | DocumentModelRefAst | DocumentModelFieldRefAst | ApprovalChainRefAst | DatamineRefAst | TableRefAst | TableColumnRefAst | SearchTableRefAst | ConnectorRefAst | CloudLinkRefAst | ProcedureRefAst | PhoneServiceRefAst | UserRefAst | UnresolvedRefAst
|
|
250
255
|
/** Preserved terraform local expression for round-trip (e.g. status option ids by label). */
|
|
251
256
|
| {
|
|
252
257
|
kind: "localRef";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** Canonical Elementum filter model and authoring helpers. */
|
|
2
|
-
import type { AppOrElementRef, FieldRef, TableColumnRef, TableRef, UserFieldRef } from "../../../catalog/index.js";
|
|
2
|
+
import type { AppOrElementRef, FieldRef, TableColumnRef, TableRef, UserFieldRef, UserGroupFieldRef } from "../../../catalog/index.js";
|
|
3
3
|
import type { UnsafePlatformId } from "../../../core/platform-id.js";
|
|
4
4
|
import { type AppField, type FieldScope } from "../../../core/types/app.js";
|
|
5
5
|
import { type Ref } from "../ref.js";
|
|
6
6
|
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
|
-
export type FilterField = AppOrElementRef | FieldRef | UserFieldRef | TableColumnRef | TableRef | AppField<FieldScope> | UnsafePlatformId | string;
|
|
9
|
+
export type FilterField = AppOrElementRef | FieldRef | UserFieldRef | UserGroupFieldRef | TableColumnRef | TableRef | AppField<FieldScope> | UnsafePlatformId | string;
|
|
10
10
|
export type FilterReferenceValue = FilterReference | {
|
|
11
11
|
readonly __rawFilterReference: string;
|
|
12
12
|
};
|
|
@@ -44,6 +44,17 @@ export declare function uuid(ref: Ref<unknown> | string, options?: {
|
|
|
44
44
|
readonly multiple?: boolean;
|
|
45
45
|
}): FilterReferenceInput;
|
|
46
46
|
export declare function isFilterReferenceInput(value: unknown): value is FilterReferenceInput;
|
|
47
|
+
/**
|
|
48
|
+
* A picklist, status, or stage option selected by its LABEL and stored behind
|
|
49
|
+
* the platform's TEXT value wrapper, which is how many live list-view filters
|
|
50
|
+
* hold their option ids. Build resolves the label to that option's id either
|
|
51
|
+
* way, so the wrapper is the only difference: pass a plain label for a raw text
|
|
52
|
+
* comparison, `"UUID"` as the comparison's value type for the UUID wrapper, and
|
|
53
|
+
* this for the TEXT one.
|
|
54
|
+
*/
|
|
55
|
+
export declare function textOption(label: string): Extract<FilterValue<FilterField, FilterReferenceValue>, {
|
|
56
|
+
type: "TEXT";
|
|
57
|
+
}>;
|
|
47
58
|
export interface CurrentUserFilterValue {
|
|
48
59
|
readonly __kind: "currentUser";
|
|
49
60
|
readonly valueType: "ID" | "EMAIL" | "DOMAIN";
|
|
@@ -63,6 +74,16 @@ export declare function fieldValue(value: FilterField, options?: {
|
|
|
63
74
|
}): Extract<FilterValue<FilterField, FilterReferenceValue>, {
|
|
64
75
|
type: "FIELD";
|
|
65
76
|
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Compare against a field on the record being edited — a dynamic Dropdown
|
|
79
|
+
* filter such as "source Process Area equals this record's Process Area".
|
|
80
|
+
* `field` must belong to the Dropdown's own app or element.
|
|
81
|
+
*/
|
|
82
|
+
export declare function recordField(field: FilterField, options?: {
|
|
83
|
+
readonly required?: boolean;
|
|
84
|
+
}): Extract<FilterValue<FilterField, FilterReferenceValue>, {
|
|
85
|
+
type: "RECORD_FIELD";
|
|
86
|
+
}>;
|
|
66
87
|
type AuthoredFilterValue = FilterValue<FilterField, FilterReferenceValue>;
|
|
67
88
|
export type FilterInput = string | number | boolean | null | Ref<unknown> | FilterReferenceInput | FilterField | CurrentUserFilterValue | AuthoredFilterValue;
|
|
68
89
|
export type LeftRef = FilterField | Ref<unknown> | FilterReferenceInput | FieldLeftValue;
|
|
@@ -75,6 +75,17 @@ export function uuid(ref, options) {
|
|
|
75
75
|
export function isFilterReferenceInput(value) {
|
|
76
76
|
return typeof value === "object" && value !== null && FILTER_REFERENCE_BRAND in value;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* A picklist, status, or stage option selected by its LABEL and stored behind
|
|
80
|
+
* the platform's TEXT value wrapper, which is how many live list-view filters
|
|
81
|
+
* hold their option ids. Build resolves the label to that option's id either
|
|
82
|
+
* way, so the wrapper is the only difference: pass a plain label for a raw text
|
|
83
|
+
* comparison, `"UUID"` as the comparison's value type for the UUID wrapper, and
|
|
84
|
+
* this for the TEXT one.
|
|
85
|
+
*/
|
|
86
|
+
export function textOption(label) {
|
|
87
|
+
return { type: "TEXT", value: label, option: true };
|
|
88
|
+
}
|
|
78
89
|
export function currentUser(valueType = "ID") {
|
|
79
90
|
return { __kind: "currentUser", valueType };
|
|
80
91
|
}
|
|
@@ -90,6 +101,18 @@ export function fieldValue(value, options) {
|
|
|
90
101
|
Object.defineProperty(operand, FIELD_VALUE_SOURCE, { value });
|
|
91
102
|
return operand;
|
|
92
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Compare against a field on the record being edited — a dynamic Dropdown
|
|
106
|
+
* filter such as "source Process Area equals this record's Process Area".
|
|
107
|
+
* `field` must belong to the Dropdown's own app or element.
|
|
108
|
+
*/
|
|
109
|
+
export function recordField(field, options) {
|
|
110
|
+
return {
|
|
111
|
+
type: "RECORD_FIELD",
|
|
112
|
+
field: fieldWireValue(field),
|
|
113
|
+
...(options?.required !== undefined && { required: options.required }),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
93
116
|
export const UNRESOLVED_REFERENCE_MARKER = "__edkUnresolvedReference::";
|
|
94
117
|
export function refDataToFilterReference(data) {
|
|
95
118
|
switch (data.kind) {
|
|
@@ -121,7 +144,7 @@ function isCanonicalFilterValue(value) {
|
|
|
121
144
|
FILTER_VALUE_TYPES.has(value.type);
|
|
122
145
|
}
|
|
123
146
|
function isCatalogField(value) {
|
|
124
|
-
return hasKind(value, "field") || hasKind(value, "userField") || hasKind(value, "tableColumn");
|
|
147
|
+
return hasKind(value, "field") || hasKind(value, "userField") || hasKind(value, "userGroupField") || hasKind(value, "tableColumn");
|
|
125
148
|
}
|
|
126
149
|
function isAppField(value) {
|
|
127
150
|
return typeof value === "object" && value !== null && "id" in value && "type" in value && !isCatalogField(value);
|
|
@@ -88,7 +88,9 @@ function printLikeOptions(filter, quote) {
|
|
|
88
88
|
}
|
|
89
89
|
function printFilterValue(value, codec, call, quote) {
|
|
90
90
|
switch (value.type) {
|
|
91
|
-
|
|
91
|
+
// A TEXT-wrapped option label needs both facts in the printed call: a bare
|
|
92
|
+
// string is a raw word, and `"UUID"` would change the stored wrapper.
|
|
93
|
+
case "TEXT": return value.option === true ? call("textOption", quote(value.value)) : quote(value.value);
|
|
92
94
|
case "UUID":
|
|
93
95
|
case "DATE":
|
|
94
96
|
case "DATETIME": return quote(value.value);
|
|
@@ -139,6 +141,16 @@ function printFilterValue(value, codec, call, quote) {
|
|
|
139
141
|
}
|
|
140
142
|
return call(helper, `${codec.reference(value.value)}${options}`);
|
|
141
143
|
}
|
|
142
|
-
case "RECORD_FIELD":
|
|
144
|
+
case "RECORD_FIELD": {
|
|
145
|
+
if (typeof value.field === "string")
|
|
146
|
+
return `${JSON.stringify(value)} as const`;
|
|
147
|
+
const { type: _type, field, required, ...rest } = value;
|
|
148
|
+
if (Object.keys(rest).length === 0) {
|
|
149
|
+
return call("recordField", `${codec.field(field)}${required !== undefined ? `, { required: ${required} }` : ""}`);
|
|
150
|
+
}
|
|
151
|
+
const extras = Object.entries({ ...rest, ...(required !== undefined && { required }) })
|
|
152
|
+
.map(([key, item]) => `${key}: ${JSON.stringify(item)}`);
|
|
153
|
+
return `{ type: "RECORD_FIELD", field: ${codec.field(field)}, ${extras.join(", ")} } as const`;
|
|
154
|
+
}
|
|
143
155
|
}
|
|
144
156
|
}
|
|
@@ -90,7 +90,14 @@ export interface FilterToTfCodec {
|
|
|
90
90
|
* wire forms for TASK refs in each slot (#490).
|
|
91
91
|
*/
|
|
92
92
|
readonly reference: (value: unknown, role?: "left" | "value", realType?: string, operator?: TfFilterType) => TfValue;
|
|
93
|
-
|
|
93
|
+
/**
|
|
94
|
+
* `valueType` is the wrapper to store. `isOptionLabel` is the independent
|
|
95
|
+
* fact that `value` is an option LABEL to resolve back to its option-id
|
|
96
|
+
* lookup, whichever wrapper that is.
|
|
97
|
+
*/
|
|
98
|
+
readonly literal?: (value: TfValue, field: unknown | undefined, valueType: string, isOptionLabel: boolean) => TfValue;
|
|
99
|
+
/** A RECORD_FIELD value's source-record field; without it only raw platform ids encode. */
|
|
100
|
+
readonly recordField?: (value: unknown) => TfValue;
|
|
94
101
|
readonly fieldFromLeftValue?: (value: unknown) => unknown | undefined;
|
|
95
102
|
/**
|
|
96
103
|
* Override the REFERENCE `real_type` that would otherwise default to TEXT.
|
|
@@ -100,8 +107,10 @@ export interface FilterToTfCodec {
|
|
|
100
107
|
*/
|
|
101
108
|
readonly referenceRealType?: (reference: unknown, role: "left" | "value", authored: string | undefined) => string | undefined;
|
|
102
109
|
}
|
|
110
|
+
/** Which schema a filter's `field_id` addresses: app/element fields, or the fixed platform user / user-group directory. */
|
|
111
|
+
export type FilterFieldScope = "app" | "user" | "userGroup";
|
|
103
112
|
export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
|
|
104
|
-
readonly field: (value: TfValue, fieldScope:
|
|
113
|
+
readonly field: (value: TfValue, fieldScope: FilterFieldScope) => Field;
|
|
105
114
|
readonly aspect?: (value: TfValue) => Field;
|
|
106
115
|
readonly reference: (value: TfValue, role: "left" | "value") => ReferenceValue;
|
|
107
116
|
/**
|
|
@@ -111,6 +120,17 @@ export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
|
|
|
111
120
|
*/
|
|
112
121
|
readonly referenceType?: (value: TfValue, fallback: ValueType) => ValueType;
|
|
113
122
|
readonly literal?: (value: TfValue, valueType: string) => TfValue;
|
|
123
|
+
/** Decode a RECORD_FIELD value's source-record field reference; without it only raw platform ids decode. */
|
|
124
|
+
readonly recordField?: (value: TfValue) => Field;
|
|
125
|
+
/**
|
|
126
|
+
* A TEXT-wrapped literal `literal` resolved from an option-id lookup is an
|
|
127
|
+
* option LABEL, not a stored word. Set this when the owner cannot rebuild a
|
|
128
|
+
* bare label into the same lookup — list views keep raw words literal, so
|
|
129
|
+
* dropping the fact there rewrites the stored wrapper type. Owners that
|
|
130
|
+
* always resolve labels (access policies) leave it off and keep printing
|
|
131
|
+
* plain labels.
|
|
132
|
+
*/
|
|
133
|
+
readonly optionLookupsAreIdentities?: boolean;
|
|
114
134
|
}
|
|
115
135
|
export type WireFilterValue = Readonly<{
|
|
116
136
|
type: string;
|
|
@@ -184,5 +204,5 @@ export declare function filterWireToTf(value: unknown): TfFilter;
|
|
|
184
204
|
/** Canonical Terraform-HCL filter -> platform wire shape for tables/datamines. */
|
|
185
205
|
export declare function filterTfToWire(value: TfValue): WireFilter;
|
|
186
206
|
/** The only Terraform-HCL filter -> strongly typed deserializer AST. */
|
|
187
|
-
export declare function filterFromTf<Field, ReferenceValue>(value: TfValue, codec: FilterFromTfCodec<Field, ReferenceValue>, fieldScope?:
|
|
207
|
+
export declare function filterFromTf<Field, ReferenceValue>(value: TfValue, codec: FilterFromTfCodec<Field, ReferenceValue>, fieldScope?: FilterFieldScope): Filter<Field, ReferenceValue>;
|
|
188
208
|
export {};
|
|
@@ -231,14 +231,22 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
if (type === "record_field") {
|
|
234
|
-
if (raw.field === undefined
|
|
235
|
-
throw new EntityTfError("record_field filter value requires field
|
|
236
|
-
|
|
234
|
+
if (raw.field === undefined)
|
|
235
|
+
throw new EntityTfError("record_field filter value requires field");
|
|
236
|
+
const aspect = raw.aspect ?? raw.object;
|
|
237
|
+
const sourceFieldType = raw.sourceFieldType ?? raw.source_field_type;
|
|
238
|
+
let field;
|
|
239
|
+
if (codec.recordField !== undefined)
|
|
240
|
+
field = codec.recordField(raw.field);
|
|
241
|
+
else if (typeof raw.field === "string")
|
|
242
|
+
field = raw.field;
|
|
243
|
+
else
|
|
244
|
+
throw new EntityTfError("record_field filter value field must be a platform id in this filter context");
|
|
237
245
|
return {
|
|
238
246
|
type,
|
|
239
|
-
field
|
|
240
|
-
object:
|
|
241
|
-
source_field_type: String(
|
|
247
|
+
field,
|
|
248
|
+
...(aspect !== undefined && { object: aspect }),
|
|
249
|
+
...(sourceFieldType !== undefined && { source_field_type: String(sourceFieldType).toLowerCase() }),
|
|
242
250
|
...((raw.dynamicField ?? raw.dynamic_field) !== undefined && { dynamic_field: (raw.dynamicField ?? raw.dynamic_field) }),
|
|
243
251
|
...((raw.dynamicFieldAspect ?? raw.dynamic_field_object) !== undefined && { dynamic_field_object: (raw.dynamicFieldAspect ?? raw.dynamic_field_object) }),
|
|
244
252
|
...(typeof raw.required === "boolean" && { required: raw.required }),
|
|
@@ -249,7 +257,15 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
|
249
257
|
}
|
|
250
258
|
if (raw.value === undefined)
|
|
251
259
|
throw new EntityTfError(`${type} filter value requires value`);
|
|
252
|
-
|
|
260
|
+
// A UUID wrapper already implies an option label (#1120); a TEXT wrapper
|
|
261
|
+
// carries the fact explicitly, so the owner's literal hook sees one answer.
|
|
262
|
+
const isOptionLabel = type === "uuid" || raw.option === true;
|
|
263
|
+
const resolved = codec.literal?.(raw.value, field, type, isOptionLabel) ?? raw.value;
|
|
264
|
+
// Writing an option label where the platform stored an id is a silent data
|
|
265
|
+
// change on a live view. Only a resolved lookup is an expression.
|
|
266
|
+
if (raw.option === true && !isTfExpr(resolved)) {
|
|
267
|
+
throw new EntityTfError(`option selection ${JSON.stringify(raw.value)} has no declared option identity`);
|
|
268
|
+
}
|
|
253
269
|
if (isTfExpr(resolved))
|
|
254
270
|
return { type, value: resolved };
|
|
255
271
|
if (type === "number") {
|
|
@@ -555,22 +571,38 @@ function filterValueFromTf(value, codec, fieldScope) {
|
|
|
555
571
|
...(typeof value.aspect_id === "string" && { aspect: value.aspect_id }),
|
|
556
572
|
...(value.treat_null_as_equals !== undefined && { treatNullAsEquals: value.treat_null_as_equals }),
|
|
557
573
|
};
|
|
558
|
-
case "record_field":
|
|
559
|
-
if (
|
|
560
|
-
throw new EntityTfError("record_field filter value requires field
|
|
574
|
+
case "record_field": {
|
|
575
|
+
if (value.field === undefined)
|
|
576
|
+
throw new EntityTfError("record_field filter value requires field");
|
|
577
|
+
if ((value.object !== undefined && typeof value.object !== "string") || (value.source_field_type !== undefined && typeof value.source_field_type !== "string")) {
|
|
578
|
+
throw new EntityTfError("record_field filter value object and source_field_type must be literal strings");
|
|
561
579
|
}
|
|
580
|
+
let field;
|
|
581
|
+
if (typeof value.field === "string")
|
|
582
|
+
field = value.field;
|
|
583
|
+
else if (codec.recordField !== undefined)
|
|
584
|
+
field = codec.recordField(value.field);
|
|
585
|
+
else
|
|
586
|
+
throw new EntityTfError("record_field filter value field reference cannot be reconstructed in this filter context");
|
|
562
587
|
return {
|
|
563
588
|
type: "RECORD_FIELD",
|
|
564
|
-
field
|
|
565
|
-
aspect: value.object,
|
|
566
|
-
sourceFieldType: value.source_field_type.toUpperCase(),
|
|
589
|
+
field,
|
|
590
|
+
...(value.object !== undefined && { aspect: value.object }),
|
|
591
|
+
...(value.source_field_type !== undefined && { sourceFieldType: value.source_field_type.toUpperCase() }),
|
|
567
592
|
...(typeof value.dynamic_field === "string" && { dynamicField: value.dynamic_field }),
|
|
568
593
|
...(typeof value.dynamic_field_object === "string" && { dynamicFieldAspect: value.dynamic_field_object }),
|
|
569
594
|
...(value.required !== undefined && { required: value.required }),
|
|
570
595
|
};
|
|
596
|
+
}
|
|
571
597
|
case "number": return { type: "NUMBER", value: typeof literal === "number" ? literal : Number(literal) };
|
|
572
598
|
case "boolean": return { type: "BOOLEAN", value: typeof literal === "boolean" ? literal : String(literal).toLowerCase() === "true" };
|
|
573
|
-
case "text":
|
|
599
|
+
case "text": {
|
|
600
|
+
// `type` stays the stored wrapper. An expression the codec collapsed to a
|
|
601
|
+
// plain string was an id lookup, so this literal is an option LABEL —
|
|
602
|
+
// the second, independent fact, which a TEXT wrapper cannot express.
|
|
603
|
+
const option = codec.optionLookupsAreIdentities === true && isTfExpr(value.value);
|
|
604
|
+
return { type: "TEXT", value: String(literal), ...(option && { option: true }) };
|
|
605
|
+
}
|
|
574
606
|
case "uuid":
|
|
575
607
|
case "date":
|
|
576
608
|
case "datetime": return { type: type.toUpperCase(), value: String(literal) };
|
|
@@ -32,9 +32,18 @@ export type FilterReference = {
|
|
|
32
32
|
variableId?: string;
|
|
33
33
|
variableTaskRefKey?: string;
|
|
34
34
|
};
|
|
35
|
-
export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> =
|
|
35
|
+
export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> =
|
|
36
|
+
/**
|
|
37
|
+
* `type` is the value wrapper the platform stored. `option` is the
|
|
38
|
+
* independent fact that `value` is a picklist/status/stage option LABEL
|
|
39
|
+
* whose stored value is that option's id — live list views hold option ids
|
|
40
|
+
* behind a TEXT wrapper as well as a UUID one, and a UUID wrapper already
|
|
41
|
+
* implies the label is an option, so only the TEXT wrapper needs to say so.
|
|
42
|
+
*/
|
|
43
|
+
{
|
|
36
44
|
type: "TEXT";
|
|
37
45
|
value: string;
|
|
46
|
+
option?: true;
|
|
38
47
|
} | {
|
|
39
48
|
type: "NUMBER";
|
|
40
49
|
value: number;
|
|
@@ -62,9 +71,9 @@ export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> =
|
|
|
62
71
|
valueType?: "ID" | "EMAIL" | "DOMAIN";
|
|
63
72
|
} | {
|
|
64
73
|
type: "RECORD_FIELD";
|
|
65
|
-
field: string;
|
|
66
|
-
aspect
|
|
67
|
-
sourceFieldType
|
|
74
|
+
field: FieldValue | string;
|
|
75
|
+
aspect?: string;
|
|
76
|
+
sourceFieldType?: string;
|
|
68
77
|
dynamicField?: string;
|
|
69
78
|
dynamicFieldAspect?: string;
|
|
70
79
|
required?: boolean;
|
|
@@ -12,3 +12,19 @@ export interface ForeignRootDataRef {
|
|
|
12
12
|
}
|
|
13
13
|
/** Resolve a foreign root through its graph-declared reference lookup facet. */
|
|
14
14
|
export declare function resolveForeignRef(kind: KindId, token: ForeignRootToken, orgRefs: OrgRefLookup, diagnostics?: string[], where?: string): ForeignRootDataRef;
|
|
15
|
+
declare const FOREIGN_FIELD_OWNER_RESOURCE_TYPES: {
|
|
16
|
+
readonly app: "elementum_app";
|
|
17
|
+
readonly element: "elementum_element";
|
|
18
|
+
readonly task: "elementum_task";
|
|
19
|
+
readonly table: "elementum_table";
|
|
20
|
+
};
|
|
21
|
+
export type ForeignFieldOwnerKind = keyof typeof FOREIGN_FIELD_OWNER_RESOURCE_TYPES;
|
|
22
|
+
/**
|
|
23
|
+
* The `data.elementum_field` label for a field on a foreign root: provider
|
|
24
|
+
* root type + the root's data-block label + the field's display name, the
|
|
25
|
+
* same label `ei export` writes. Every entity must derive it here — two
|
|
26
|
+
* entities naming the same (root, field) lookup differently emit duplicate,
|
|
27
|
+
* semantically identical data blocks.
|
|
28
|
+
*/
|
|
29
|
+
export declare function foreignFieldDataLabel(ownerKind: ForeignFieldOwnerKind, ownerTfLabel: string, fieldName: string): string;
|
|
30
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expr } from "../../engine/tf/index.js";
|
|
1
|
+
import { expr, sanitizeName } from "../../engine/tf/index.js";
|
|
2
2
|
/** Resolve a foreign root through its graph-declared reference lookup facet. */
|
|
3
3
|
export function resolveForeignRef(kind, token, orgRefs, diagnostics, where = "foreign reference") {
|
|
4
4
|
const resolved = orgRefs.resolveForeignRoot(kind, token);
|
|
@@ -10,3 +10,19 @@ export function resolveForeignRef(kind, token, orgRefs, diagnostics, where = "fo
|
|
|
10
10
|
tfLabel: resolved.tfLabel,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
+
const FOREIGN_FIELD_OWNER_RESOURCE_TYPES = {
|
|
14
|
+
app: "elementum_app",
|
|
15
|
+
element: "elementum_element",
|
|
16
|
+
task: "elementum_task",
|
|
17
|
+
table: "elementum_table",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The `data.elementum_field` label for a field on a foreign root: provider
|
|
21
|
+
* root type + the root's data-block label + the field's display name, the
|
|
22
|
+
* same label `ei export` writes. Every entity must derive it here — two
|
|
23
|
+
* entities naming the same (root, field) lookup differently emit duplicate,
|
|
24
|
+
* semantically identical data blocks.
|
|
25
|
+
*/
|
|
26
|
+
export function foreignFieldDataLabel(ownerKind, ownerTfLabel, fieldName) {
|
|
27
|
+
return sanitizeName(`${FOREIGN_FIELD_OWNER_RESOURCE_TYPES[ownerKind]}_${ownerTfLabel}_${fieldName}`);
|
|
28
|
+
}
|
|
@@ -24,15 +24,12 @@ export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx)
|
|
|
24
24
|
// field resource of its own in this stream). `scopeTfLabel`/`scope`
|
|
25
25
|
// already identify the RESOLVED target (see this module's header
|
|
26
26
|
// comment), so the label prefix to strip is known without any extra
|
|
27
|
-
// lookup
|
|
28
|
-
// `
|
|
29
|
-
const prefix
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const taskPrefix = `elementum_task_${scopeTfLabel}_`;
|
|
34
|
-
if (scope === "task" && fieldRef.label.startsWith(taskPrefix)) {
|
|
35
|
-
return tfLabelToTsLabel(fieldRef.label.slice(taskPrefix.length));
|
|
27
|
+
// lookup: `foreignFieldDataLabel`'s `<owner type>_<target>_` form, or
|
|
28
|
+
// the `<scope>_<target>_` form older builds wrote.
|
|
29
|
+
for (const prefix of [`${ownerType}_${scopeTfLabel}_`, `${scope}_${scopeTfLabel}_`]) {
|
|
30
|
+
if (fieldRef.label.startsWith(prefix)) {
|
|
31
|
+
return tfLabelToTsLabel(fieldRef.label.slice(prefix.length));
|
|
32
|
+
}
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
if (isTfExpr(fieldRef) && fieldRef.$expr === "local") {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GroupRef } from "../../catalog/index.js";
|
|
2
|
+
import type { OrgRefLookup } from "../../engine/build/context.js";
|
|
3
|
+
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
4
|
+
import { type TfValue } from "../../engine/tf/index.js";
|
|
5
|
+
import type { RoleUserRef } from "../role/build.js";
|
|
6
|
+
/** A portable user identity for a skill visibility grant. */
|
|
7
|
+
export type SkillUserRef = RoleUserRef;
|
|
8
|
+
/** Restrict skill visibility to these users or group members. Empty lists remove the restriction. */
|
|
9
|
+
export interface SkillAccessPolicy {
|
|
10
|
+
readonly users?: readonly SkillUserRef[];
|
|
11
|
+
readonly groups?: readonly GroupRef[];
|
|
12
|
+
}
|
|
13
|
+
/** Validate the complete policy before emitting any access-changing configuration. */
|
|
14
|
+
export declare function normalizeSkillAccessPolicy(value: unknown): SkillAccessPolicy;
|
|
15
|
+
export declare function skillAccessPolicyToTf(value: unknown, orgRefs: OrgRefLookup): Record<string, TfValue>;
|
|
16
|
+
/** Any unresolved principal blocks pull; dropping even one could broaden access on the next apply. */
|
|
17
|
+
export declare function skillAccessPolicyFromTf(attrs: Readonly<Record<string, TfValue>>, ctx: FromTfContext): SkillAccessPolicy | undefined;
|