@elementumai/edk 0.9.11 → 0.9.13
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 +39 -5
- package/dist-sdk/src/catalog/factories.d.ts +35 -14
- package/dist-sdk/src/catalog/factories.js +64 -13
- package/dist-sdk/src/catalog/from-authoring.js +4 -4
- package/dist-sdk/src/catalog/index.d.ts +1 -1
- package/dist-sdk/src/catalog/org.js +3 -2
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +13 -3
- package/dist-sdk/src/core/triggers/on-demand.d.ts +4 -28
- package/dist-sdk/src/core/triggers/on-demand.js +2 -4
- package/dist-sdk/src/engine/entity.d.ts +2 -0
- package/dist-sdk/src/engine/logging.d.ts +90 -0
- package/dist-sdk/src/engine/logging.js +124 -0
- package/dist-sdk/src/engine/progress.d.ts +122 -0
- package/dist-sdk/src/engine/progress.js +685 -0
- package/dist-sdk/src/engine/pull/result-output.d.ts +24 -0
- package/dist-sdk/src/engine/pull/result-output.js +59 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +8 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -4
- package/dist-sdk/src/entities/app/to-tf.js +9 -13
- package/dist-sdk/src/entities/automation/build.d.ts +11 -16
- package/dist-sdk/src/entities/automation/build.js +60 -16
- package/dist-sdk/src/entities/automation/catalog-render.js +1 -1
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +1 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +23 -5
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +247 -35
- package/dist-sdk/src/entities/automation/from-tf.js +181 -24
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/module.js +2 -2
- package/dist-sdk/src/entities/automation/output-field-types.js +25 -13
- package/dist-sdk/src/entities/automation/script-code.d.ts +12 -4
- package/dist-sdk/src/entities/automation/script-code.js +659 -101
- package/dist-sdk/src/entities/automation/task-label.js +25 -2
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -28
- package/dist-sdk/src/entities/automation/tasks.js +31 -15
- package/dist-sdk/src/entities/automation/to-tf.js +443 -64
- package/dist-sdk/src/entities/automation/triggers.d.ts +15 -9
- package/dist-sdk/src/entities/automation/triggers.js +4 -2
- package/dist-sdk/src/entities/chart/build.d.ts +15 -3
- package/dist-sdk/src/entities/chart/build.js +6 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/chart/from-tf.js +71 -8
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/index.js +1 -1
- package/dist-sdk/src/entities/chart/printer.js +27 -7
- package/dist-sdk/src/entities/chart/to-tf.js +56 -2
- package/dist-sdk/src/entities/datamine/from-tf.js +11 -1
- package/dist-sdk/src/entities/element/build.d.ts +6 -5
- package/dist-sdk/src/entities/element/from-tf.js +3 -2
- package/dist-sdk/src/entities/element/module.js +1 -0
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/element/to-tf.js +9 -1
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +73 -1
- package/dist-sdk/src/entities/field/metadata.d.ts +18 -0
- package/dist-sdk/src/entities/field/metadata.js +34 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +17 -6
- package/dist-sdk/src/entities/relationship/column-contract.d.ts +24 -0
- package/dist-sdk/src/entities/relationship/column-contract.js +41 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +19 -34
- package/dist-sdk/src/entities/relationship/to-tf.js +15 -2
- package/dist-sdk/src/entities/shared/context.d.ts +6 -3
- package/dist-sdk/src/entities/shared/context.js +19 -1
- package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
- package/dist-sdk/src/entities/shared/filters/index.js +36 -1
- package/dist-sdk/src/entities/shared/filters/print.js +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +8 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +10 -6
- package/dist-sdk/src/entities/shared/filters/types.d.ts +2 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -23
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +17 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +38 -12
- package/dist-sdk/src/entities/skill/tools.js +2 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +8 -12
- package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -44
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +45 -7
- package/dist-sdk/src/entities/table/build.js +10 -2
- package/dist-sdk/src/entities/view/to-tf.js +5 -7
- package/dist-sdk/src/entities/widget/build.d.ts +26 -0
- package/dist-sdk/src/entities/widget/from-tf.js +30 -5
- package/dist-sdk/src/entities/widget/to-tf.js +111 -7
- package/dist-sdk/src/graph/types.d.ts +5 -0
- package/package.json +1 -1
- package/dist-sdk/src/core/types/platform.d.ts +0 -2
- package/dist-sdk/src/core/types/platform.js +0 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { EntityTfError } from "../../engine/entity.js";
|
|
9
9
|
import { SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
|
|
10
10
|
import { dataRefLabel, optionalString, resourceRefLabel } from "../../engine/pull/context.js";
|
|
11
|
-
import { bareChildResourceLabel, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
11
|
+
import { bareChildResourceLabel, isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
12
12
|
import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
|
|
13
13
|
import { __pulledExpression } from "../app/deserializer/pulled-expression.js";
|
|
14
14
|
import { optionsFromTf } from "./options.js";
|
|
@@ -510,3 +510,75 @@ export function fieldKeyFromTfValue(v, ownerRefName, ownerTfLabel, scope, ctx) {
|
|
|
510
510
|
}
|
|
511
511
|
return fieldKeyFromTfRef(v, ownerTfLabel, scope);
|
|
512
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Decode `data.elementum_field.<label>` to the target's public field key.
|
|
515
|
+
* ei labels are `elementum_element_<sanitize(displayName)>_<field>` (or
|
|
516
|
+
* `app_<slug>_<field>`), not the catalog bag key. Treating the whole label
|
|
517
|
+
* as the key rebuilds a non-existent `elementum_text_field.<owner>_<label>`.
|
|
518
|
+
*/
|
|
519
|
+
export function decodeForeignDataField(dataLabel, target, ctx) {
|
|
520
|
+
const resolved = ctx.foreignFieldRefsByDataAddress?.get(`elementum_field.${dataLabel}`);
|
|
521
|
+
if (resolved !== undefined && resolved.ownerRefName === target.key) {
|
|
522
|
+
return {
|
|
523
|
+
key: resolved.fieldKey,
|
|
524
|
+
name: ctx.dataName("elementum_field", dataLabel) ?? resolved.fieldName ?? resolved.fieldKey,
|
|
525
|
+
...(resolved.fieldType !== undefined ? { fieldType: resolved.fieldType } : {}),
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
const name = ctx.dataName("elementum_field", dataLabel) ?? tfLabelToTsLabel(dataLabel);
|
|
529
|
+
const catalogFieldKey = ctx.fieldNamesByOwnerRefName?.get(target.key)?.get(name.toLowerCase());
|
|
530
|
+
if (catalogFieldKey !== undefined) {
|
|
531
|
+
const fieldType = fieldTypeFromRegistry(ctx, target.key, catalogFieldKey);
|
|
532
|
+
return { key: catalogFieldKey, name, ...(fieldType !== undefined ? { fieldType } : {}) };
|
|
533
|
+
}
|
|
534
|
+
const stripped = fieldKeyFromForeignDataLabel(dataLabel, target);
|
|
535
|
+
if (stripped !== undefined) {
|
|
536
|
+
const fieldType = fieldTypeFromRegistry(ctx, target.key, stripped);
|
|
537
|
+
return { key: stripped, name, ...(fieldType !== undefined ? { fieldType } : {}) };
|
|
538
|
+
}
|
|
539
|
+
return { key: tfLabelToTsLabel(dataLabel), name };
|
|
540
|
+
}
|
|
541
|
+
function fieldTypeFromRegistry(ctx, ownerRefName, fieldKey) {
|
|
542
|
+
for (const ref of ctx.foreignFieldRefsByDataAddress?.values() ?? []) {
|
|
543
|
+
if (ref.ownerRefName === ownerRefName && ref.fieldKey === fieldKey && ref.fieldType !== undefined) {
|
|
544
|
+
return ref.fieldType;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
for (const ref of ctx.foreignFieldRefsById?.values() ?? []) {
|
|
548
|
+
if (ref.ownerRefName === ownerRefName && ref.fieldKey === fieldKey) {
|
|
549
|
+
const typed = ref;
|
|
550
|
+
if (typed.fieldType !== undefined)
|
|
551
|
+
return typed.fieldType;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (fieldKey === "id")
|
|
555
|
+
return "HANDLE";
|
|
556
|
+
if (fieldKey === "title")
|
|
557
|
+
return "TEXT";
|
|
558
|
+
return undefined;
|
|
559
|
+
}
|
|
560
|
+
/** Strip ei's owner-display prefix from a `data.elementum_field` label. */
|
|
561
|
+
export function fieldKeyFromForeignDataLabel(dataLabel, target) {
|
|
562
|
+
const kind = target.kind === "element" || target.kind === "app" ? target.kind : undefined;
|
|
563
|
+
const ownerType = kind === "element" ? "elementum_element" : kind === "app" ? "elementum_app" : undefined;
|
|
564
|
+
const slugs = [
|
|
565
|
+
target.name !== undefined && target.name !== "" ? sanitizeName(target.name) : undefined,
|
|
566
|
+
target.namespace,
|
|
567
|
+
tsLabelToTfLabel(target.key),
|
|
568
|
+
].filter((slug) => typeof slug === "string" && slug !== "");
|
|
569
|
+
const prefixes = [];
|
|
570
|
+
for (const slug of slugs) {
|
|
571
|
+
if (ownerType !== undefined)
|
|
572
|
+
prefixes.push(`${ownerType}_${slug}_`);
|
|
573
|
+
if (kind !== undefined)
|
|
574
|
+
prefixes.push(`${kind}_${slug}_`);
|
|
575
|
+
prefixes.push(`${slug}_`);
|
|
576
|
+
}
|
|
577
|
+
prefixes.sort((a, b) => b.length - a.length);
|
|
578
|
+
for (const prefix of prefixes) {
|
|
579
|
+
if (dataLabel.startsWith(prefix) && dataLabel.length > prefix.length) {
|
|
580
|
+
return tfLabelToTsLabel(dataLabel.slice(prefix.length));
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return undefined;
|
|
584
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time field catalog used by automation switch filters.
|
|
3
|
+
*
|
|
4
|
+
* Apps already returned this from `appToTf`. Elements must emit the same
|
|
5
|
+
* map so an element-owned automation's `filter.isNull` / `isNotNull` can
|
|
6
|
+
* infer PICKLIST `.id` → UUID instead of falling back to TEXT.
|
|
7
|
+
*/
|
|
8
|
+
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
9
|
+
import { type PicklistValueWire } from "./options.js";
|
|
10
|
+
interface FieldMetadataInner {
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
readonly __refName?: string;
|
|
13
|
+
readonly picklistValues?: readonly PicklistValueWire[];
|
|
14
|
+
readonly tags?: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/** bag key → type/options metadata, keyed the same way as fieldAddresses. */
|
|
17
|
+
export declare function fieldMetadataFromEntries(fields: readonly Record<string, FieldMetadataInner>[] | undefined): Map<string, BuildFieldMetadata>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time field catalog used by automation switch filters.
|
|
3
|
+
*
|
|
4
|
+
* Apps already returned this from `appToTf`. Elements must emit the same
|
|
5
|
+
* map so an element-owned automation's `filter.isNull` / `isNotNull` can
|
|
6
|
+
* infer PICKLIST `.id` → UUID instead of falling back to TEXT.
|
|
7
|
+
*/
|
|
8
|
+
import { snakeSlug } from "../../engine/tf/index.js";
|
|
9
|
+
import { picklistLabel } from "./options.js";
|
|
10
|
+
import { SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
11
|
+
/** bag key → type/options metadata, keyed the same way as fieldAddresses. */
|
|
12
|
+
export function fieldMetadataFromEntries(fields) {
|
|
13
|
+
const fieldMetadata = new Map();
|
|
14
|
+
for (const fieldEntry of fields ?? []) {
|
|
15
|
+
const typeKey = Object.keys(fieldEntry)[0];
|
|
16
|
+
if (typeKey === undefined)
|
|
17
|
+
continue;
|
|
18
|
+
const inner = fieldEntry[typeKey];
|
|
19
|
+
const name = inner.name ?? "";
|
|
20
|
+
const fieldKey = inner.__refName ?? snakeSlug(name);
|
|
21
|
+
const subType = SUB_TYPE_BY_TYPE_KEY.get(typeKey);
|
|
22
|
+
if (fieldKey === "" || name === "" || subType === undefined)
|
|
23
|
+
continue;
|
|
24
|
+
fieldMetadata.set(fieldKey, {
|
|
25
|
+
name,
|
|
26
|
+
fieldType: subType.authoringType,
|
|
27
|
+
...(inner.picklistValues !== undefined
|
|
28
|
+
? { options: inner.picklistValues.map((value) => picklistLabel(value)) }
|
|
29
|
+
: {}),
|
|
30
|
+
...(inner.tags !== undefined ? { tags: inner.tags } : {}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return fieldMetadata;
|
|
34
|
+
}
|
|
@@ -2,18 +2,29 @@ import type { AppOrElementRef, FieldRef, RecordIdentityRef, TableColumnRef, Tabl
|
|
|
2
2
|
import type { Filter } from "../shared/filters/types.js";
|
|
3
3
|
import type { AppViewFieldRef } from "../app/build.js";
|
|
4
4
|
export interface AppRelationshipColumn<Target extends AppOrElementRef | TableRef = AppOrElementRef | TableRef> {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Field on the owning app/element. System `"id"` is HANDLE (the record
|
|
7
|
+
* handle), not the record UUID. AutoRelation create rejects HANDLE joined
|
|
8
|
+
* to a child `relationField` or dynamic dropdown — put the relation field
|
|
9
|
+
* on this side, or join comparable scalars (text/handle/number/…).
|
|
10
|
+
*/
|
|
6
11
|
readonly field: AppViewFieldRef;
|
|
7
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Field/column on `target`. Use title, id, or another scalar whose stored
|
|
14
|
+
* value equals `field`. A child `relationField` or dynamic dropdown is not
|
|
15
|
+
* a valid related join target against parent system `"id"`.
|
|
16
|
+
*/
|
|
8
17
|
readonly relatedField: FieldRef | TableColumnRef | RecordIdentityRef<Target>;
|
|
9
18
|
}
|
|
10
19
|
/**
|
|
11
20
|
* A parent-owned join (`elementum_relationship`) keyed under this app/element's
|
|
12
21
|
* `relationships` bag. `relatedRecords` widgets on this object list rows
|
|
13
|
-
* through these joins. Columns
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
22
|
+
* through these joins. Columns are equality joins of comparable stored values
|
|
23
|
+
* (SQL JOIN ON). Proven creates: TEXT→TEXT, and source `relationField`→related
|
|
24
|
+
* title or id. Do not join this object's system `"id"` (HANDLE) to a child
|
|
25
|
+
* `relationField` or dynamic dropdown (create fails with `Unable to validate`).
|
|
26
|
+
* A child `relationField` / `autoRelate` is an instance link, not a substitute
|
|
27
|
+
* for a join owned here, and does not populate a parent `relatedRecords` widget.
|
|
17
28
|
*/
|
|
18
29
|
export interface AppRelationship<Target extends AppOrElementRef | TableRef = AppOrElementRef | TableRef> {
|
|
19
30
|
readonly target: Target;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoRelation columns are equality joins of comparable stored values.
|
|
3
|
+
*
|
|
4
|
+
* System `id` is HANDLE (`EDKBUILD-17`), not the record UUID. A `relationField`
|
|
5
|
+
* or dynamic dropdown stores a related-record picklist reference. The platform
|
|
6
|
+
* rejects HANDLE → that stored value on create with `Unable to validate`.
|
|
7
|
+
*
|
|
8
|
+
* Proven create pairs:
|
|
9
|
+
* - TEXT → TEXT
|
|
10
|
+
* - source `relationField` → related title or id (HANDLE)
|
|
11
|
+
*
|
|
12
|
+
* Put the relation field on this object's `field` side. Do not use a child
|
|
13
|
+
* `relationField` or dynamic dropdown as `relatedField` against parent system
|
|
14
|
+
* `id`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const HANDLE_TO_RELATION_JOIN_ERROR: string;
|
|
17
|
+
interface FieldTypeProbe {
|
|
18
|
+
readonly fieldType?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function isHandleRelationshipField(field: string | FieldTypeProbe | undefined): boolean;
|
|
21
|
+
export declare function isRelationRelationshipField(field: FieldTypeProbe | undefined): boolean;
|
|
22
|
+
/** Returns the contract error when this column pair is not createable. */
|
|
23
|
+
export declare function autoRelationColumnError(field: string | FieldTypeProbe | undefined, relatedField: FieldTypeProbe | undefined): string | undefined;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoRelation columns are equality joins of comparable stored values.
|
|
3
|
+
*
|
|
4
|
+
* System `id` is HANDLE (`EDKBUILD-17`), not the record UUID. A `relationField`
|
|
5
|
+
* or dynamic dropdown stores a related-record picklist reference. The platform
|
|
6
|
+
* rejects HANDLE → that stored value on create with `Unable to validate`.
|
|
7
|
+
*
|
|
8
|
+
* Proven create pairs:
|
|
9
|
+
* - TEXT → TEXT
|
|
10
|
+
* - source `relationField` → related title or id (HANDLE)
|
|
11
|
+
*
|
|
12
|
+
* Put the relation field on this object's `field` side. Do not use a child
|
|
13
|
+
* `relationField` or dynamic dropdown as `relatedField` against parent system
|
|
14
|
+
* `id`.
|
|
15
|
+
*/
|
|
16
|
+
export const HANDLE_TO_RELATION_JOIN_ERROR = 'AutoRelation cannot join system "id" (HANDLE) to a relationField or dynamic dropdown. ' +
|
|
17
|
+
'The platform rejects that pair on create with "Unable to validate". ' +
|
|
18
|
+
"Put the relationField on this object's field side and match the related " +
|
|
19
|
+
"object's title or id, or join comparable scalars (text/handle/number/…). " +
|
|
20
|
+
"A child relationField + autoRelate is an instance link, not this parent join";
|
|
21
|
+
const RELATED_PICKLIST_TYPES = new Set(["RELATION", "PICKLIST", "MULTI_PICKLIST"]);
|
|
22
|
+
export function isHandleRelationshipField(field) {
|
|
23
|
+
if (field === "id")
|
|
24
|
+
return true;
|
|
25
|
+
if (typeof field === "object") {
|
|
26
|
+
const type = field.fieldType?.toUpperCase();
|
|
27
|
+
return type === "HANDLE";
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
export function isRelationRelationshipField(field) {
|
|
32
|
+
const type = field?.fieldType?.toUpperCase();
|
|
33
|
+
return type !== undefined && RELATED_PICKLIST_TYPES.has(type);
|
|
34
|
+
}
|
|
35
|
+
/** Returns the contract error when this column pair is not createable. */
|
|
36
|
+
export function autoRelationColumnError(field, relatedField) {
|
|
37
|
+
if (isHandleRelationshipField(field) && isRelationRelationshipField(relatedField)) {
|
|
38
|
+
return HANDLE_TO_RELATION_JOIN_ERROR;
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
2
|
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
3
3
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
4
|
-
import { fieldKeyFromTfRef, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
4
|
+
import { decodeForeignDataField, fieldKeyFromTfRef, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
5
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
6
6
|
import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
7
7
|
import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
|
|
@@ -161,40 +161,25 @@ function relatedFieldRef(value, target, ctx) {
|
|
|
161
161
|
}
|
|
162
162
|
const dataLabel = dataRefLabel(value, "elementum_field");
|
|
163
163
|
if (dataLabel !== undefined) {
|
|
164
|
+
const decoded = decodeForeignDataField(dataLabel, {
|
|
165
|
+
key: target.key,
|
|
166
|
+
name: target.name,
|
|
167
|
+
namespace: target.namespace,
|
|
168
|
+
kind: target.kind,
|
|
169
|
+
}, ctx);
|
|
164
170
|
const resolved = ctx.foreignFieldRefsByDataAddress?.get(`elementum_field.${dataLabel}`);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
const name = ctx.dataName("elementum_field", dataLabel) ?? tfLabelToTsLabel(dataLabel);
|
|
179
|
-
// The target may already be a full on-disk catalog rather than a ref-only
|
|
180
|
-
// dependency from this one export stream. Resolve the exported field's
|
|
181
|
-
// display name against that catalog before falling back to the data label;
|
|
182
|
-
// the latter is an exporter implementation label, not a public field key.
|
|
183
|
-
const catalogFieldKey = ctx.fieldNamesByOwnerRefName?.get(target.key)?.get(name.toLowerCase());
|
|
184
|
-
if (catalogFieldKey !== undefined) {
|
|
185
|
-
return {
|
|
186
|
-
kind: target.kind === "table" ? "tableColumn" : "field",
|
|
187
|
-
key: catalogFieldKey,
|
|
188
|
-
name,
|
|
189
|
-
parent: target.key,
|
|
190
|
-
fieldType: "TEXT",
|
|
191
|
-
catalogRef: true,
|
|
192
|
-
...(target.kind === "app" || target.kind === "element" ? { parentKind: target.kind } : {}),
|
|
193
|
-
parentName: target.name,
|
|
194
|
-
...(target.namespace !== undefined ? { parentNamespace: target.namespace } : {}),
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
return { kind: target.kind === "table" ? "tableColumn" : "field", key: tfLabelToTsLabel(dataLabel), name, parent: target.key, fieldType: "TEXT" };
|
|
171
|
+
const catalogHit = decoded.key !== tfLabelToTsLabel(dataLabel);
|
|
172
|
+
return {
|
|
173
|
+
kind: target.kind === "table" ? "tableColumn" : "field",
|
|
174
|
+
key: decoded.key,
|
|
175
|
+
name: decoded.name,
|
|
176
|
+
parent: resolved?.ownerRefName ?? target.key,
|
|
177
|
+
fieldType: decoded.fieldType ?? "TEXT",
|
|
178
|
+
...(catalogHit ? { catalogRef: true } : {}),
|
|
179
|
+
...(resolved?.ownerKind !== undefined ? { parentKind: resolved.ownerKind } : target.kind === "app" || target.kind === "element" ? { parentKind: target.kind } : {}),
|
|
180
|
+
...(resolved?.ownerName !== undefined ? { parentName: resolved.ownerName } : target.name !== undefined ? { parentName: target.name } : {}),
|
|
181
|
+
...(resolved?.ownerNamespace !== undefined ? { parentNamespace: resolved.ownerNamespace } : target.namespace !== undefined ? { parentNamespace: target.namespace } : {}),
|
|
182
|
+
};
|
|
198
183
|
}
|
|
199
184
|
const scope = target.kind === "element" ? "element" : "app";
|
|
200
185
|
const key = fieldKeyFromTfValue(value, target.key, target.tfLabel ?? target.key, scope, ctx);
|
|
@@ -4,6 +4,7 @@ import { filterToTf } from "../access-policy/to-tf.js";
|
|
|
4
4
|
import { 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
|
+
import { autoRelationColumnError } from "./column-contract.js";
|
|
7
8
|
import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
|
|
8
9
|
export function relationshipsToTf(relationships, opts) {
|
|
9
10
|
const blocks = [];
|
|
@@ -17,12 +18,24 @@ export function relationshipsToTf(relationships, opts) {
|
|
|
17
18
|
if (target === undefined)
|
|
18
19
|
continue;
|
|
19
20
|
const columns = [];
|
|
21
|
+
let droppedInvalidJoin = false;
|
|
20
22
|
for (const [index, column] of (relationship.columns ?? []).entries()) {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
+
const columnWhere = `${where}.columns[${index}]`;
|
|
24
|
+
const contractError = autoRelationColumnError(column.field, column.relatedField);
|
|
25
|
+
if (contractError !== undefined) {
|
|
26
|
+
opts.diagnostics.push(`${columnWhere}: ${contractError}; dropped`);
|
|
27
|
+
droppedInvalidJoin = true;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const field = resolveOwnerField(column.field, `${columnWhere}.field`, opts);
|
|
31
|
+
const relatedField = resolveRelatedField(column.relatedField, target, `${columnWhere}.relatedField`, opts);
|
|
23
32
|
if (field !== undefined && relatedField !== undefined)
|
|
24
33
|
columns.push({ field_id: field, related_field_id: relatedField });
|
|
25
34
|
}
|
|
35
|
+
if (columns.length === 0 && droppedInvalidJoin) {
|
|
36
|
+
opts.diagnostics.push(`${where}: no valid join columns remain; dropped`);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
26
39
|
const attrs = {
|
|
27
40
|
object_id: opts.objectId,
|
|
28
41
|
related_object_id: target.value,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* This bridges compile-time type safety with runtime reference building.
|
|
10
10
|
*/
|
|
11
|
-
import type { CalculationTypeOfValue, Ref, Simplify
|
|
11
|
+
import type { CalculationTypeOfValue, Ref, Simplify } from "./ref.js";
|
|
12
12
|
/**
|
|
13
13
|
* Deep ref — a `Ref<T>` that also exposes `T`'s string-keyed properties as
|
|
14
14
|
* nested deep refs. This is what makes `ctx.actions.x.record.id` and
|
|
@@ -75,12 +75,15 @@ export declare function createActionOutputProxy<T>(actionRefKey: string): DeepRe
|
|
|
75
75
|
export declare function createActionsProxy<TActions extends Record<string, unknown>>(actionNames: string[]): Context<never, TActions>["actions"];
|
|
76
76
|
/**
|
|
77
77
|
* A forEach item that is both a Ref to the whole item and a proxy
|
|
78
|
-
* with typed field access: item.fieldName →
|
|
78
|
+
* with typed field access: item.fieldName → DeepRef<T[fieldName]>, drilling
|
|
79
|
+
* into nested object fields (e.g. a DropdownValue's .label) the same way
|
|
80
|
+
* createTriggerProxy/createActionOutputProxy do.
|
|
79
81
|
*/
|
|
80
|
-
export type ForEachItem<T> = Ref<T> &
|
|
82
|
+
export type ForEachItem<T> = Ref<T> & DeepRefs<T>;
|
|
81
83
|
/**
|
|
82
84
|
* Creates a forEach item proxy.
|
|
83
85
|
* item.fieldName → Ref with { kind: "forEach", forEachActionName, name: "fieldName" }
|
|
86
|
+
* item.fieldName.nested → Ref with { ..., name: "fieldName.nested" }
|
|
84
87
|
* Accessing the item directly (without a property) returns a Ref to the whole item.
|
|
85
88
|
*/
|
|
86
89
|
export declare function createForEachItemProxy<T>(forEachActionName: string): ForEachItem<T>;
|
|
@@ -100,9 +100,27 @@ export function createActionsProxy(actionNames) {
|
|
|
100
100
|
},
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Ref to a forEach item field path; further property access extends `name`
|
|
105
|
+
* with dot segments, mirroring createTriggerFieldRef/createActionOutputFieldRef -
|
|
106
|
+
* without this recursion, a nested object field (e.g. item.flow.label) would
|
|
107
|
+
* return a plain, non-proxied Ref from the first hop and fail on the second.
|
|
108
|
+
*/
|
|
109
|
+
function createForEachItemFieldRef(forEachActionName, path) {
|
|
110
|
+
const base = createRef({ kind: "forEach", forEachActionName, name: path });
|
|
111
|
+
return new Proxy(base, {
|
|
112
|
+
get(target, prop, receiver) {
|
|
113
|
+
if (typeof prop === "symbol" || prop === "__data" || prop === "__type" || prop === "__calculationType") {
|
|
114
|
+
return Reflect.get(target, prop, receiver);
|
|
115
|
+
}
|
|
116
|
+
return createForEachItemFieldRef(forEachActionName, `${path}.${String(prop)}`);
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
103
120
|
/**
|
|
104
121
|
* Creates a forEach item proxy.
|
|
105
122
|
* item.fieldName → Ref with { kind: "forEach", forEachActionName, name: "fieldName" }
|
|
123
|
+
* item.fieldName.nested → Ref with { ..., name: "fieldName.nested" }
|
|
106
124
|
* Accessing the item directly (without a property) returns a Ref to the whole item.
|
|
107
125
|
*/
|
|
108
126
|
export function createForEachItemProxy(forEachActionName) {
|
|
@@ -112,7 +130,7 @@ export function createForEachItemProxy(forEachActionName) {
|
|
|
112
130
|
if (typeof prop === "symbol" || prop === "__data" || prop === "__type" || prop === "__calculationType") {
|
|
113
131
|
return target[prop];
|
|
114
132
|
}
|
|
115
|
-
return
|
|
133
|
+
return createForEachItemFieldRef(forEachActionName, prop);
|
|
116
134
|
},
|
|
117
135
|
});
|
|
118
136
|
}
|
|
@@ -11,6 +11,13 @@ export type FilterReferenceValue = FilterReference | {
|
|
|
11
11
|
readonly __rawFilterReference: string;
|
|
12
12
|
};
|
|
13
13
|
export declare function fieldTypeToValueType(type: WorkflowFieldType | string | undefined): ValueType;
|
|
14
|
+
/**
|
|
15
|
+
* GraphQL `ValueType` has no PICKLIST member. A Dropdown option id is UUID;
|
|
16
|
+
* its display label is TEXT. USER/GROUP `.id` is UUID; `.name`/`.email` are TEXT.
|
|
17
|
+
* Used when a trigger-record Ref has no authored `filter.uuid()` / `filter.text()`
|
|
18
|
+
* wrapper — the field's WorkflowFieldType + path suffix is the authority.
|
|
19
|
+
*/
|
|
20
|
+
export declare function referenceValueTypeForField(fieldType: WorkflowFieldType | string | undefined, suffix?: string): ValueType | undefined;
|
|
14
21
|
declare const FILTER_REFERENCE_BRAND: unique symbol;
|
|
15
22
|
export interface FilterReferenceInput {
|
|
16
23
|
readonly [FILTER_REFERENCE_BRAND]: true;
|
|
@@ -18,10 +18,38 @@ export function fieldTypeToValueType(type) {
|
|
|
18
18
|
case "ASPECT_RECORD":
|
|
19
19
|
case "ASPECT_RECORD_ID":
|
|
20
20
|
case "ASPECT_FIELD_ID":
|
|
21
|
+
case "PICKLIST_ID":
|
|
22
|
+
case "MULTI_PICKLIST_ID":
|
|
21
23
|
return "UUID";
|
|
22
24
|
default: return "TEXT";
|
|
23
25
|
}
|
|
24
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* GraphQL `ValueType` has no PICKLIST member. A Dropdown option id is UUID;
|
|
29
|
+
* its display label is TEXT. USER/GROUP `.id` is UUID; `.name`/`.email` are TEXT.
|
|
30
|
+
* Used when a trigger-record Ref has no authored `filter.uuid()` / `filter.text()`
|
|
31
|
+
* wrapper — the field's WorkflowFieldType + path suffix is the authority.
|
|
32
|
+
*/
|
|
33
|
+
export function referenceValueTypeForField(fieldType, suffix = "") {
|
|
34
|
+
if (fieldType === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
const normalized = suffix.toLowerCase();
|
|
37
|
+
if (fieldType === "PICKLIST" || fieldType === "MULTI_PICKLIST" || fieldType === "PICKLIST_ID") {
|
|
38
|
+
if (normalized === "label")
|
|
39
|
+
return "TEXT";
|
|
40
|
+
if (normalized === "id" || normalized === "")
|
|
41
|
+
return "UUID";
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
if (fieldType === "USER" || fieldType === "GROUP" || fieldType === "USER_GROUP" || fieldType === "USER_ID" || fieldType === "GROUP_ID") {
|
|
45
|
+
if (normalized === "id" || normalized === "")
|
|
46
|
+
return "UUID";
|
|
47
|
+
return "TEXT";
|
|
48
|
+
}
|
|
49
|
+
if (normalized === "" || normalized === "id")
|
|
50
|
+
return fieldTypeToValueType(fieldType);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
25
53
|
const FILTER_REFERENCE_BRAND = Symbol("FilterReferenceInput");
|
|
26
54
|
function referenceInput(ref, valueType, options) {
|
|
27
55
|
return { [FILTER_REFERENCE_BRAND]: true, ref, valueType, ...(options?.multiple === true && { multiple: true }) };
|
|
@@ -66,7 +94,14 @@ export function refDataToFilterReference(data) {
|
|
|
66
94
|
case "forEach": return { type: "FOR_EACH", forEachTaskRefKey: data.forEachActionName, name: data.name };
|
|
67
95
|
case "static": return { type: "VALUE", value: data.value };
|
|
68
96
|
case "template": return { type: "VALUE", value: serializeRefData(data) };
|
|
69
|
-
|
|
97
|
+
// A workflow variable used as a filter value (recordSearch/switch/…). ei
|
|
98
|
+
// encodes this as `variable.<uuid>` (#1045). Carry the setVariable action's
|
|
99
|
+
// refKey as a marker; automation build finalize resolves it to the variable's
|
|
100
|
+
// minted id (`variableId`), which to-tf emits as `variable.<uuid>`.
|
|
101
|
+
case "variableParam": return { type: "VARIABLE", name: data.name, variableTaskRefKey: data.variableActionRefKey };
|
|
102
|
+
// A vault secret has no filter reference kind in the platform filter model
|
|
103
|
+
// (jarvis ReferenceType = VALUE/TASK/TRIGGER/FOR_EACH/VARIABLE), so it can
|
|
104
|
+
// never be a filter comparison value — reject it at authoring.
|
|
70
105
|
case "secret": throw new EdkValidationError("Secret refs cannot be used directly in filter values");
|
|
71
106
|
}
|
|
72
107
|
}
|
|
@@ -113,6 +113,8 @@ function printFilterValue(value, codec, call, quote) {
|
|
|
113
113
|
case "UUID":
|
|
114
114
|
helper = "uuid";
|
|
115
115
|
break;
|
|
116
|
+
case undefined:
|
|
117
|
+
return `${codec.reference(value.value)}${options}`;
|
|
116
118
|
default: throw new Error(`unsupported filter reference type "${value.realType}"`);
|
|
117
119
|
}
|
|
118
120
|
return call(helper, `${codec.reference(value.value)}${options}`);
|
|
@@ -89,9 +89,16 @@ export interface FilterToTfCodec {
|
|
|
89
89
|
* right-hand `value`/`values` references — provider Read / ei use different
|
|
90
90
|
* wire forms for TASK refs in each slot (#490).
|
|
91
91
|
*/
|
|
92
|
-
readonly reference: (value: unknown, role?: "left" | "value", realType?: string) => TfValue;
|
|
92
|
+
readonly reference: (value: unknown, role?: "left" | "value", realType?: string, operator?: TfFilterType) => TfValue;
|
|
93
93
|
readonly literal?: (value: TfValue, field: unknown | undefined, valueType: string) => TfValue;
|
|
94
94
|
readonly fieldFromLeftValue?: (value: unknown) => unknown | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Override the REFERENCE `real_type` that would otherwise default to TEXT.
|
|
97
|
+
* Return a GraphQL ValueType (TEXT/UUID/NUMBER/…) or undefined to keep the
|
|
98
|
+
* authored/default value. Used when a trigger-record Ref's field metadata
|
|
99
|
+
* is a better authority than `isNull`'s TEXT operator fallback.
|
|
100
|
+
*/
|
|
101
|
+
readonly referenceRealType?: (reference: unknown, role: "left" | "value", authored: string | undefined) => string | undefined;
|
|
95
102
|
}
|
|
96
103
|
export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
|
|
97
104
|
readonly field: (value: TfValue, fieldScope: "app" | "user") => Field;
|
|
@@ -38,13 +38,13 @@ function wireFilter(value) {
|
|
|
38
38
|
throw new EntityTfError("filter type is required");
|
|
39
39
|
return value;
|
|
40
40
|
}
|
|
41
|
-
function withLeft(filter, codec) {
|
|
41
|
+
function withLeft(filter, codec, operator) {
|
|
42
42
|
if (filter.field !== undefined)
|
|
43
43
|
return { field_id: codec.field(filter.field) };
|
|
44
44
|
if (filter.field_id !== undefined)
|
|
45
45
|
return { field_id: filter.field_id };
|
|
46
46
|
if (filter.leftValue !== undefined) {
|
|
47
|
-
const value = wireFilterValueToTf(filter.leftValue, undefined, codec, "left");
|
|
47
|
+
const value = wireFilterValueToTf(filter.leftValue, undefined, codec, "left", operator);
|
|
48
48
|
if (value.type === "field" && value.field_id !== undefined)
|
|
49
49
|
return { left_value: { field_id: value.field_id } };
|
|
50
50
|
if (value.type === "reference" && value.value_reference !== undefined)
|
|
@@ -76,7 +76,7 @@ export function filterToTf(value, codec) {
|
|
|
76
76
|
return { type, children: filter.children.map((child) => filterToTf(child, codec)) };
|
|
77
77
|
}
|
|
78
78
|
const field = filter.field ?? codec.fieldFromLeftValue?.(filter.leftValue);
|
|
79
|
-
const left = withLeft(filter, codec);
|
|
79
|
+
const left = withLeft(filter, codec, type);
|
|
80
80
|
if (left.field_id === undefined && left.left_value === undefined) {
|
|
81
81
|
throw new EntityTfError(`${type} filter has no left side`);
|
|
82
82
|
}
|
|
@@ -156,7 +156,7 @@ function filterValueToWire(value) {
|
|
|
156
156
|
...(value.required !== undefined && { required: value.required }),
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
function wireFilterValueToTf(value, field, codec, role = "value") {
|
|
159
|
+
function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
160
160
|
if (value === null || typeof value !== "object" || isTfExpr(value)) {
|
|
161
161
|
throw new EntityTfError("invalid wire filter value");
|
|
162
162
|
}
|
|
@@ -177,12 +177,16 @@ function wireFilterValueToTf(value, field, codec, role = "value") {
|
|
|
177
177
|
const reference = raw.value ?? raw.valueReference ?? raw.value_reference;
|
|
178
178
|
if (reference === undefined)
|
|
179
179
|
throw new EntityTfError("reference filter value requires value");
|
|
180
|
+
const authored = raw.realType ?? raw.real_type;
|
|
181
|
+
const authoredType = typeof authored === "string" ? authored : undefined;
|
|
182
|
+
const inferred = codec.referenceRealType?.(reference, role, authoredType);
|
|
183
|
+
const realType = String(inferred ?? authoredType ?? "TEXT");
|
|
180
184
|
// ei export always writes an explicit `multiple = false` on scalar text
|
|
181
185
|
// references. Omitting it plans null-vs-false drift after pull.
|
|
182
186
|
return {
|
|
183
187
|
type,
|
|
184
|
-
value_reference: codec.reference(reference, role,
|
|
185
|
-
real_type:
|
|
188
|
+
value_reference: codec.reference(reference, role, realType, operator),
|
|
189
|
+
real_type: realType.toLowerCase(),
|
|
186
190
|
multiple: typeof raw.multiple === "boolean" ? raw.multiple : false,
|
|
187
191
|
};
|
|
188
192
|
}
|
|
@@ -30,6 +30,7 @@ export type FilterReference = {
|
|
|
30
30
|
type: "VARIABLE";
|
|
31
31
|
name: string;
|
|
32
32
|
variableId?: string;
|
|
33
|
+
variableTaskRefKey?: string;
|
|
33
34
|
};
|
|
34
35
|
export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> = {
|
|
35
36
|
type: "TEXT";
|
|
@@ -69,7 +70,7 @@ export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> =
|
|
|
69
70
|
required?: boolean;
|
|
70
71
|
} | {
|
|
71
72
|
type: "REFERENCE";
|
|
72
|
-
realType
|
|
73
|
+
realType?: ValueType;
|
|
73
74
|
value: ReferenceValue;
|
|
74
75
|
label?: string;
|
|
75
76
|
multiple?: boolean;
|
|
@@ -40,6 +40,11 @@ export interface PrintSkillV2Options {
|
|
|
40
40
|
readonly ownerRefName: string;
|
|
41
41
|
readonly fieldKey: string;
|
|
42
42
|
}>;
|
|
43
|
+
/** Platform table id → canonical table catalog identity. */
|
|
44
|
+
readonly foreignTableRefsById?: ReadonlyMap<string, {
|
|
45
|
+
readonly tableRefName: string;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
}>;
|
|
43
48
|
/** Aspect/table display-name pair → typed search-table identity. */
|
|
44
49
|
readonly foreignSearchTableRefsByName?: ReadonlyMap<string, {
|
|
45
50
|
readonly ownerRefName: string;
|