@elementumai/edk 0.9.19 → 0.9.20
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 +146 -6
- package/dist-sdk/src/catalog/factories.d.ts +24 -1
- package/dist-sdk/src/catalog/factories.js +30 -0
- package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
- package/dist-sdk/src/catalog/from-authoring.js +34 -9
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/render.js +6 -6
- package/dist-sdk/src/catalog/token.js +7 -0
- package/dist-sdk/src/catalog/types.d.ts +34 -1
- package/dist-sdk/src/catalog/types.js +11 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +39 -3
- package/dist-sdk/src/core/triggers/on-demand.js +10 -2
- package/dist-sdk/src/engine/build/context.d.ts +1 -1
- package/dist-sdk/src/engine/ei/run.d.ts +149 -0
- package/dist-sdk/src/engine/ei/run.js +1132 -0
- package/dist-sdk/src/engine/logging.d.ts +17 -0
- package/dist-sdk/src/engine/logging.js +18 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
- package/dist-sdk/src/engine/pull/ref-only.js +10 -7
- package/dist-sdk/src/engine/pull/result-output.d.ts +6 -0
- package/dist-sdk/src/engine/pull/result-output.js +87 -3
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +6 -0
- package/dist-sdk/src/engine/tf/labels.js +9 -0
- package/dist-sdk/src/engine/tf/model.d.ts +22 -1
- package/dist-sdk/src/engine/tf/parse.js +92 -4
- package/dist-sdk/src/engine/tf/render.d.ts +4 -2
- package/dist-sdk/src/engine/tf/render.js +41 -7
- package/dist-sdk/src/engine/validation.d.ts +39 -0
- package/dist-sdk/src/engine/validation.js +85 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +5 -2
- package/dist-sdk/src/entities/agent/build.d.ts +4 -16
- package/dist-sdk/src/entities/agent/build.js +40 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +4 -2
- package/dist-sdk/src/entities/agent/to-tf.js +6 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +7 -1
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +27 -5
- package/dist-sdk/src/entities/app/build.d.ts +89 -20
- package/dist-sdk/src/entities/app/build.js +51 -6
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +16 -0
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +7 -2
- package/dist-sdk/src/entities/app/index.d.ts +6 -6
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +5 -2
- package/dist-sdk/src/entities/app/to-tf.js +19 -11
- package/dist-sdk/src/entities/automation/build.d.ts +47 -5
- package/dist-sdk/src/entities/automation/build.js +137 -20
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +24 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +314 -39
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +428 -48
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.js +37 -8
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +17 -0
- package/dist-sdk/src/entities/automation/script-code.js +91 -5
- package/dist-sdk/src/entities/automation/system-ref-name.js +4 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +2 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +9 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +24 -2
- package/dist-sdk/src/entities/automation/tasks.js +38 -9
- package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/automation/to-tf.js +489 -83
- package/dist-sdk/src/entities/automation/triggers.d.ts +4 -2
- package/dist-sdk/src/entities/automation/triggers.js +4 -0
- package/dist-sdk/src/entities/chart/to-tf.js +10 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +24 -31
- package/dist-sdk/src/entities/element/build.d.ts +25 -13
- package/dist-sdk/src/entities/element/build.js +4 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/element/from-tf.js +58 -1
- package/dist-sdk/src/entities/element/index.d.ts +5 -3
- package/dist-sdk/src/entities/element/index.js +1 -0
- package/dist-sdk/src/entities/element/module.js +9 -3
- package/dist-sdk/src/entities/element/to-tf.js +8 -2
- package/dist-sdk/src/entities/field/build.d.ts +14 -1
- package/dist-sdk/src/entities/field/build.js +3 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/field/from-tf.js +39 -1
- package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
- package/dist-sdk/src/entities/field/media-types.js +30 -0
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +23 -2
- package/dist-sdk/src/entities/field/to-tf.js +130 -14
- package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
- package/dist-sdk/src/entities/file-reader/module.js +1 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
- package/dist-sdk/src/entities/file-reader/types.js +1 -1
- package/dist-sdk/src/entities/portal/build.d.ts +26 -0
- package/dist-sdk/src/entities/portal/build.js +37 -0
- package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
- package/dist-sdk/src/entities/portal/from-tf.js +75 -0
- package/dist-sdk/src/entities/portal/index.d.ts +1 -0
- package/dist-sdk/src/entities/portal/index.js +1 -0
- package/dist-sdk/src/entities/portal/module.d.ts +3 -0
- package/dist-sdk/src/entities/portal/module.js +28 -0
- package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/portal/to-tf.js +73 -0
- package/dist-sdk/src/entities/portal/types.d.ts +1 -0
- package/dist-sdk/src/entities/portal/types.js +1 -0
- package/dist-sdk/src/entities/relationship/module.js +2 -0
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
- package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
- package/dist-sdk/src/entities/search-table/module.js +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
- package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
- package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +17 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +8 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.js +14 -4
- package/dist-sdk/src/entities/shared/filters/print.js +17 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +5 -1
- package/dist-sdk/src/entities/shared/filters/types.d.ts +9 -1
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -5
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +2 -1
- package/dist-sdk/src/entities/skill/from-tf.js +66 -13
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
- package/dist-sdk/src/entities/skill/to-tf.js +14 -4
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +8 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +27 -5
- package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
- package/dist-sdk/src/entities/table/catalog.js +66 -0
- package/dist-sdk/src/entities/table/module.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +2 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -9
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +71 -18
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +19 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +82 -10
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +53 -23
- package/dist-sdk/src/entities/view/agent-view-layout.js +1 -1
- package/dist-sdk/src/entities/view/from-tf.d.ts +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +124 -12
- package/dist-sdk/src/entities/view/module.js +30 -3
- package/dist-sdk/src/entities/view/to-tf.d.ts +14 -1
- package/dist-sdk/src/entities/view/to-tf.js +67 -10
- package/dist-sdk/src/entities/view/types.d.ts +4 -15
- package/dist-sdk/src/entities/view/types.js +15 -15
- package/dist-sdk/src/entities/widget/build.d.ts +16 -1
- package/dist-sdk/src/entities/widget/build.js +11 -1
- package/dist-sdk/src/entities/widget/to-tf.js +34 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +16 -5
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +11 -0
- package/dist-sdk/src/graph/index.js +21 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +55 -2
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +10 -1
|
@@ -11,6 +11,7 @@ import { dataRefLabel, optionalString, resourceRefLabel } from "../../engine/pul
|
|
|
11
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
|
+
import { isAttachmentMediaType } from "./media-types.js";
|
|
14
15
|
import { optionsFromTf } from "./options.js";
|
|
15
16
|
import { isCalculationResultType } from "./calculation-types.js";
|
|
16
17
|
import { KNOWN_FIELD_ATTRS, SUB_TYPE_BY_RESOURCE } from "./types.js";
|
|
@@ -465,6 +466,34 @@ export function fieldFromTf(block, owner, ctx) {
|
|
|
465
466
|
const tags = Array.isArray(fieldRole) && fieldRole.every((t) => typeof t === "string")
|
|
466
467
|
? fieldRole
|
|
467
468
|
: undefined;
|
|
469
|
+
let mediaTypes;
|
|
470
|
+
if (subType.typeKey === "attachment" && attrs["media_types"] !== undefined) {
|
|
471
|
+
const raw = attrs["media_types"];
|
|
472
|
+
if (!Array.isArray(raw)) {
|
|
473
|
+
ctx.diagnostics.push(`${where}: media_types must be a list of MIME types; omitted`);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
// Any invalid entry drops the whole list. Printing only the valid
|
|
477
|
+
// entries would shrink the live restriction on the next build.
|
|
478
|
+
// Omitting mediaTypes leaves the live value in place (provider
|
|
479
|
+
// UseStateForNullSet). `*/*` is invalid here too — see media-types.ts.
|
|
480
|
+
const values = [];
|
|
481
|
+
const invalid = [];
|
|
482
|
+
for (const entry of raw) {
|
|
483
|
+
if (isAttachmentMediaType(entry))
|
|
484
|
+
values.push(entry);
|
|
485
|
+
else
|
|
486
|
+
invalid.push(entry);
|
|
487
|
+
}
|
|
488
|
+
if (invalid.length > 0) {
|
|
489
|
+
const shown = invalid.map((entry) => JSON.stringify(entry)).join(", ");
|
|
490
|
+
ctx.diagnostics.push(`${where}: media_types entries ${shown} are not MIME types (expected type/subtype); omitted so the live restriction is kept`);
|
|
491
|
+
}
|
|
492
|
+
else if (values.length > 0) {
|
|
493
|
+
mediaTypes = values;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
468
497
|
// A group/user field's default_value is a `data.elementum_group|user.<label>.id`
|
|
469
498
|
// EXPRESSION on the wire (the platform has no stable raw id to hand
|
|
470
499
|
// authored source, and the field is Optional-without-Computed — omitting
|
|
@@ -543,6 +572,7 @@ export function fieldFromTf(block, owner, ctx) {
|
|
|
543
572
|
...(options !== undefined && { options }),
|
|
544
573
|
...(config !== undefined && { config }),
|
|
545
574
|
...(tags !== undefined && tags.length > 0 && { tags }),
|
|
575
|
+
...(mediaTypes !== undefined && { mediaTypes }),
|
|
546
576
|
...(relatedObject !== undefined && { relatedObject }),
|
|
547
577
|
...(relatedLabelField !== undefined && { relatedLabelField }),
|
|
548
578
|
...(autoRelate !== undefined && { autoRelate }),
|
|
@@ -620,7 +650,7 @@ export function decodeForeignDataField(dataLabel, target, ctx) {
|
|
|
620
650
|
const fieldType = fieldTypeFromRegistry(ctx, target.key, catalogFieldKey);
|
|
621
651
|
return { key: catalogFieldKey, name, ...(fieldType !== undefined ? { fieldType } : {}) };
|
|
622
652
|
}
|
|
623
|
-
const stripped = fieldKeyFromForeignDataLabel(dataLabel, target);
|
|
653
|
+
const stripped = fieldKeyFromForeignDataLabel(dataLabel, { ...target, ownerDataLabel: foreignFieldOwnerDataLabel(dataLabel, ctx) });
|
|
624
654
|
if (stripped !== undefined) {
|
|
625
655
|
const fieldType = fieldTypeFromRegistry(ctx, target.key, stripped);
|
|
626
656
|
return { key: stripped, name, ...(fieldType !== undefined ? { fieldType } : {}) };
|
|
@@ -646,11 +676,19 @@ function fieldTypeFromRegistry(ctx, ownerRefName, fieldKey) {
|
|
|
646
676
|
return "TEXT";
|
|
647
677
|
return undefined;
|
|
648
678
|
}
|
|
679
|
+
/** The label of the app/element/task lookup a foreign `data.elementum_field` reads through its `object_id`. */
|
|
680
|
+
function foreignFieldOwnerDataLabel(dataLabel, ctx) {
|
|
681
|
+
const objectId = ctx.dataAttrs?.("elementum_field", dataLabel)?.["object_id"];
|
|
682
|
+
return dataRefLabel(objectId, "elementum_app") ?? dataRefLabel(objectId, "elementum_element") ?? dataRefLabel(objectId, "elementum_task");
|
|
683
|
+
}
|
|
649
684
|
/** Strip ei's owner-display prefix from a `data.elementum_field` label. */
|
|
650
685
|
export function fieldKeyFromForeignDataLabel(dataLabel, target) {
|
|
651
686
|
const kind = target.kind === "element" || target.kind === "app" || target.kind === "task" ? target.kind : undefined;
|
|
652
687
|
const ownerType = kind === "element" ? "elementum_element" : kind === "app" ? "elementum_app" : kind === "task" ? "elementum_task" : undefined;
|
|
688
|
+
// ei prefixes a foreign field lookup's label with its owner lookup's label, which can differ from the
|
|
689
|
+
// owner's catalog key (a namespace-derived refName), so strip by that label too.
|
|
653
690
|
const slugs = [
|
|
691
|
+
target.ownerDataLabel,
|
|
654
692
|
target.name !== undefined && target.name !== "" ? sanitizeName(target.name) : undefined,
|
|
655
693
|
target.namespace,
|
|
656
694
|
tsLabelToTfLabel(target.key),
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function isAttachmentMediaType(entry: unknown): entry is string;
|
|
2
|
+
/**
|
|
3
|
+
* Throws when an authored attachment field lists nothing, or lists a value
|
|
4
|
+
* that is not `type/subtype`. An empty list would reject every upload.
|
|
5
|
+
*/
|
|
6
|
+
export declare function assertAttachmentMediaTypes(fieldName: string, mediaTypes: readonly unknown[]): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attachment `mediaTypes` entries. A value is `type/subtype`: token
|
|
3
|
+
* characters, no surrounding whitespace, and `*` only as the whole subtype
|
|
4
|
+
* (`image/*`). An extension (`pdf`, `.docx`) or a partial type (`image/`)
|
|
5
|
+
* is rejected so a field cannot deploy a list that matches no upload.
|
|
6
|
+
*
|
|
7
|
+
* `*`/`*` stays rejected in authoring and on pull. A null `mediaTypes` list
|
|
8
|
+
* rejects every upload (#1374), and there is no evidence yet that the
|
|
9
|
+
* platform treats `*`/`*` as allow-all. Whether it does is an open question;
|
|
10
|
+
* until that is confirmed, do not accept `*`/`*` as a way to clear the
|
|
11
|
+
* restriction.
|
|
12
|
+
*/
|
|
13
|
+
const MIME_MEDIA_TYPE = /^[A-Za-z0-9][\w.+-]*\/(\*|[A-Za-z0-9][\w.+-]*)$/;
|
|
14
|
+
export function isAttachmentMediaType(entry) {
|
|
15
|
+
return typeof entry === "string" && MIME_MEDIA_TYPE.test(entry);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Throws when an authored attachment field lists nothing, or lists a value
|
|
19
|
+
* that is not `type/subtype`. An empty list would reject every upload.
|
|
20
|
+
*/
|
|
21
|
+
export function assertAttachmentMediaTypes(fieldName, mediaTypes) {
|
|
22
|
+
if (mediaTypes.length === 0) {
|
|
23
|
+
throw new Error(`attachment field "${fieldName}": mediaTypes is empty; an empty list would reject every upload.`);
|
|
24
|
+
}
|
|
25
|
+
for (const entry of mediaTypes) {
|
|
26
|
+
if (!isAttachmentMediaType(entry)) {
|
|
27
|
+
throw new Error(`attachment field "${fieldName}": mediaTypes entry ${JSON.stringify(entry)} is not a MIME type (expected type/subtype).`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -12,6 +12,18 @@
|
|
|
12
12
|
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
13
13
|
import { type ChildResourceScope, type TfBlock, type TfExpr, type TfValue } from "../../engine/tf/index.js";
|
|
14
14
|
import { type PicklistValueWire } from "./options.js";
|
|
15
|
+
/**
|
|
16
|
+
* The authored fields known to belong to an app/element. Maps produced by a
|
|
17
|
+
* root emitter also provide exact addresses; sets reconstructed from a
|
|
18
|
+
* workspace sibling still provide the ownership fact needed to distinguish
|
|
19
|
+
* an authored audit-key field from the element's platform audit field.
|
|
20
|
+
*/
|
|
21
|
+
export interface FieldOwnership {
|
|
22
|
+
has(refName: string): boolean;
|
|
23
|
+
get?(refName: string): string | undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Reconstruct custom-field ownership from a loaded app/element payload. */
|
|
26
|
+
export declare function authoredFieldKeysFromPayload(payload: unknown): ReadonlySet<string> | undefined;
|
|
15
27
|
/** Slim `AppOrElementRef` token shape as it appears in a def() payload (post-`slimTokens`). */
|
|
16
28
|
interface AspectTokenWire {
|
|
17
29
|
readonly __kind?: string;
|
|
@@ -102,6 +114,8 @@ export interface FieldInnerWire {
|
|
|
102
114
|
readonly autoRelate?: boolean;
|
|
103
115
|
/** "decimal" fields only. */
|
|
104
116
|
readonly decimalPlaces?: number;
|
|
117
|
+
/** Attachment fields only — allowed MIME types. Omitted from HCL when unset or empty. */
|
|
118
|
+
readonly mediaTypes?: readonly string[];
|
|
105
119
|
}
|
|
106
120
|
export interface FieldToTfOptions {
|
|
107
121
|
/** The owning stream root's terraform label (namespace). */
|
|
@@ -125,6 +139,8 @@ export interface FieldToTfOptions {
|
|
|
125
139
|
* `data` lookup, which can only ever find something already live).
|
|
126
140
|
*/
|
|
127
141
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
142
|
+
/** All custom fields authored by the owning root, including later entries. */
|
|
143
|
+
readonly fieldOwnership?: FieldOwnership;
|
|
128
144
|
}
|
|
129
145
|
export interface FieldToTfResult {
|
|
130
146
|
readonly block: TfBlock;
|
|
@@ -133,7 +149,12 @@ export interface FieldToTfResult {
|
|
|
133
149
|
/** `<resourceType>.<tfLabel>` — locals/build-vs-export bookkeeping. */
|
|
134
150
|
readonly address: string;
|
|
135
151
|
}
|
|
136
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Field display names must be unique within an app or element. The platform rejects the second one only at
|
|
154
|
+
* apply ("Duplicate key found.", naming neither field) after the rest of the apply has landed, so fail the build
|
|
155
|
+
* first and name both fields.
|
|
156
|
+
*/
|
|
157
|
+
export declare function claimFieldDisplayName(seen: Map<string, string>, field: FieldToTfResult): void;
|
|
137
158
|
export declare function fieldToTf(typeKey: string, inner: FieldInnerWire, opts: FieldToTfOptions): FieldToTfResult | undefined;
|
|
138
|
-
export declare function fieldRefToTfValue(fieldType: string, refName: string, ownerTfLabel: string, scope?: ChildResourceScope,
|
|
159
|
+
export declare function fieldRefToTfValue(fieldType: string, refName: string, ownerTfLabel: string, scope?: ChildResourceScope, fieldOwnership?: FieldOwnership): TfExpr | undefined;
|
|
139
160
|
export {};
|
|
@@ -12,11 +12,32 @@
|
|
|
12
12
|
import { EntityTfError } from "../../engine/entity.js";
|
|
13
13
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
14
14
|
import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, snakeSlug, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
15
|
-
import { SYSTEM_FIELD_KEY_SET } from "../../core/system-fields.js";
|
|
15
|
+
import { SYSTEM_FIELD_KEY_SET, systemFieldTag } from "../../core/system-fields.js";
|
|
16
|
+
import { ELEMENT_AUDIT_SYSTEM_FIELD_KEYS, ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
16
17
|
import { filterToTf as filterWireToTfCodec } from "../shared/filters/tf-codec.js";
|
|
17
18
|
import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
|
|
19
|
+
import { isAttachmentMediaType } from "./media-types.js";
|
|
18
20
|
import { picklistLabel } from "./options.js";
|
|
19
21
|
import { SUB_TYPE_BY_AUTHORING_TYPE, SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
22
|
+
/** Reconstruct custom-field ownership from a loaded app/element payload. */
|
|
23
|
+
export function authoredFieldKeysFromPayload(payload) {
|
|
24
|
+
if (typeof payload !== "object" || payload === null)
|
|
25
|
+
return undefined;
|
|
26
|
+
const fields = payload.fields;
|
|
27
|
+
const keys = new Set();
|
|
28
|
+
for (const entry of fields ?? []) {
|
|
29
|
+
const inner = Object.values(entry)[0];
|
|
30
|
+
if (inner === undefined || systemFieldTag(inner) !== undefined)
|
|
31
|
+
continue;
|
|
32
|
+
const key = inner.__refName ?? snakeSlug(inner.name ?? "");
|
|
33
|
+
if (key !== "")
|
|
34
|
+
keys.add(key);
|
|
35
|
+
}
|
|
36
|
+
return keys;
|
|
37
|
+
}
|
|
38
|
+
function workspaceFieldOwnership(aspect) {
|
|
39
|
+
return authoredFieldKeysFromPayload(aspect.streamRootEntity?.payload);
|
|
40
|
+
}
|
|
20
41
|
/** `unknown` → the tagged org-field-ref shape, or undefined for anything else. */
|
|
21
42
|
function asOrgFieldRef(v) {
|
|
22
43
|
if (typeof v !== "object" || v === null || v.__kind !== "orgFieldRef")
|
|
@@ -89,12 +110,24 @@ function resolveRelatedObject(token, opts, where) {
|
|
|
89
110
|
const refName = token.refName ?? "";
|
|
90
111
|
const kind = token.__kind === "element" ? "element" : token.__kind === "task" ? "task" : "app";
|
|
91
112
|
if (kind === (opts.scope ?? "app") && refName === opts.appRefName) {
|
|
92
|
-
return {
|
|
113
|
+
return {
|
|
114
|
+
value: opts.objectId,
|
|
115
|
+
refName,
|
|
116
|
+
kind,
|
|
117
|
+
target: { kind: opts.scope ?? "app", tfLabel: opts.ownerTfLabel },
|
|
118
|
+
fieldOwnership: opts.fieldOwnership,
|
|
119
|
+
};
|
|
93
120
|
}
|
|
94
121
|
const sibling = kind !== "task" ? opts.workspaceAspects?.get(workspaceAspectKey(kind, refName)) : undefined;
|
|
95
122
|
if (sibling !== undefined) {
|
|
96
123
|
const resourceType = kind === "element" ? "elementum_element" : "elementum_app";
|
|
97
|
-
return {
|
|
124
|
+
return {
|
|
125
|
+
value: expr.resourceAttr(resourceType, sibling.tfLabel, ["id"]),
|
|
126
|
+
refName,
|
|
127
|
+
kind,
|
|
128
|
+
target: sibling,
|
|
129
|
+
fieldOwnership: workspaceFieldOwnership(sibling),
|
|
130
|
+
};
|
|
98
131
|
}
|
|
99
132
|
const name = token.name ?? refName;
|
|
100
133
|
if (name === "") {
|
|
@@ -168,7 +201,7 @@ function resolveFieldOnObject(token, object, opts, where, attrName = "relatedLab
|
|
|
168
201
|
opts.diagnostics.push(`${where}: ${attrName} token "${refName}" resolves to table "${object.target.tfLabel}" — tables expose columns, not fields; dropped`);
|
|
169
202
|
return undefined;
|
|
170
203
|
}
|
|
171
|
-
const value = fieldRefToTfValue(token.fieldType ?? "", refName, object.target.tfLabel, object.target.kind);
|
|
204
|
+
const value = fieldRefToTfValue(token.fieldType ?? "", refName, object.target.tfLabel, object.target.kind, object.fieldOwnership);
|
|
172
205
|
if (value === undefined) {
|
|
173
206
|
opts.diagnostics.push(`${where}: ${attrName} token "${refName}" has no terraform field resource mapping (fieldType ${JSON.stringify(token.fieldType ?? "")}); dropped`);
|
|
174
207
|
}
|
|
@@ -214,7 +247,7 @@ function stageOrgRefs(real) {
|
|
|
214
247
|
foreignApp: (tfLabel, name, namespace) => pending.push(() => real.foreignApp(tfLabel, name, namespace)),
|
|
215
248
|
foreignTask: (tfLabel, name, namespace) => pending.push(() => real.foreignTask(tfLabel, name, namespace)),
|
|
216
249
|
foreignElement: (tfLabel, name, namespace) => pending.push(() => real.foreignElement(tfLabel, name, namespace)),
|
|
217
|
-
foreignField: (type, tfLabel, objectId, name) => pending.push(() => real.foreignField(type, tfLabel, objectId, name)),
|
|
250
|
+
foreignField: (type, tfLabel, objectId, name, extraAttrs) => pending.push(() => real.foreignField(type, tfLabel, objectId, name, extraAttrs)),
|
|
218
251
|
};
|
|
219
252
|
return { orgRefs, commit: () => { for (const apply of pending)
|
|
220
253
|
apply(); } };
|
|
@@ -255,7 +288,13 @@ function buildDynamicPicklistConfigAttr(cfg, opts, where, typeKey) {
|
|
|
255
288
|
// field's own app/element) — a cascading-parent trigger, not a field
|
|
256
289
|
// on relatedAspectId's target. See `AppField.parentField`'s doc
|
|
257
290
|
// comment (the sibling STATIC mechanism this mirrors).
|
|
258
|
-
const owner = {
|
|
291
|
+
const owner = {
|
|
292
|
+
value: opts.objectId,
|
|
293
|
+
refName: opts.appRefName,
|
|
294
|
+
kind: opts.scope ?? "app",
|
|
295
|
+
target: { kind: opts.scope ?? "app", tfLabel: opts.ownerTfLabel },
|
|
296
|
+
fieldOwnership: opts.fieldOwnership,
|
|
297
|
+
};
|
|
259
298
|
const parentFieldId = resolveFieldOnObject(cfg.parentFieldId, owner, opts_, where, "parentFieldId");
|
|
260
299
|
if (parentFieldId === undefined)
|
|
261
300
|
return undefined;
|
|
@@ -292,7 +331,13 @@ function buildDynamicPicklistConfigAttr(cfg, opts, where, typeKey) {
|
|
|
292
331
|
attrs["values_render_type"] = cfg.valuesRenderType;
|
|
293
332
|
if (cfg.filter !== undefined) {
|
|
294
333
|
let unresolvedField = false;
|
|
295
|
-
const owner = {
|
|
334
|
+
const owner = {
|
|
335
|
+
value: opts.objectId,
|
|
336
|
+
refName: opts.appRefName,
|
|
337
|
+
kind: opts.scope ?? "app",
|
|
338
|
+
target: { kind: opts.scope ?? "app", tfLabel: opts.ownerTfLabel },
|
|
339
|
+
fieldOwnership: opts.fieldOwnership,
|
|
340
|
+
};
|
|
296
341
|
try {
|
|
297
342
|
const filterValue = filterWireToTfCodec(cfg.filter, {
|
|
298
343
|
recordField: (token) => {
|
|
@@ -346,6 +391,7 @@ function resolveDynamicMappingFieldOwner(token, opts, where) {
|
|
|
346
391
|
refName: opts.appRefName,
|
|
347
392
|
kind: opts.scope ?? "app",
|
|
348
393
|
target: { kind: opts.scope ?? "app", tfLabel: opts.ownerTfLabel },
|
|
394
|
+
fieldOwnership: opts.fieldOwnership,
|
|
349
395
|
};
|
|
350
396
|
}
|
|
351
397
|
if (token.parent === undefined || token.parentKind === undefined) {
|
|
@@ -392,6 +438,7 @@ function buildStaticPicklistConfigAttr(cfg, opts, where) {
|
|
|
392
438
|
refName: opts.appRefName,
|
|
393
439
|
kind: opts.scope ?? "app",
|
|
394
440
|
target: { kind: opts.scope ?? "app", tfLabel: opts.ownerTfLabel },
|
|
441
|
+
fieldOwnership: opts.fieldOwnership,
|
|
395
442
|
};
|
|
396
443
|
if (cfg.parentFieldId !== undefined) {
|
|
397
444
|
const parentFieldId = resolveFieldOnObject(cfg.parentFieldId, owner, opts, where, "parentFieldId");
|
|
@@ -410,6 +457,28 @@ function buildStaticPicklistConfigAttr(cfg, opts, where) {
|
|
|
410
457
|
return attrs;
|
|
411
458
|
}
|
|
412
459
|
/** One custom field → its resource block; undefined = degraded (diagnostic already pushed). */
|
|
460
|
+
/** Field resources whose provider schema has no `default_value`; the platform default for these is an option/record id the provider does not manage. */
|
|
461
|
+
const NO_DEFAULT_VALUE_RESOURCES = new Map([
|
|
462
|
+
["elementum_dropdown_field", "Dropdown"],
|
|
463
|
+
["elementum_multiselect_field", "Multi-select"],
|
|
464
|
+
["elementum_relation_field", "Relation"],
|
|
465
|
+
["elementum_attachment_field", "Attachment"],
|
|
466
|
+
]);
|
|
467
|
+
/**
|
|
468
|
+
* Field display names must be unique within an app or element. The platform rejects the second one only at
|
|
469
|
+
* apply ("Duplicate key found.", naming neither field) after the rest of the apply has landed, so fail the build
|
|
470
|
+
* first and name both fields.
|
|
471
|
+
*/
|
|
472
|
+
export function claimFieldDisplayName(seen, field) {
|
|
473
|
+
const name = field.block.attrs["name"];
|
|
474
|
+
if (typeof name !== "string")
|
|
475
|
+
return;
|
|
476
|
+
const prior = seen.get(name);
|
|
477
|
+
if (prior !== undefined) {
|
|
478
|
+
throw new EntityTfError(`fields.${field.bagKey} and fields.${prior} both have the display name ${JSON.stringify(name)}; field display names must be unique within an app or element`);
|
|
479
|
+
}
|
|
480
|
+
seen.set(name, field.bagKey);
|
|
481
|
+
}
|
|
413
482
|
export function fieldToTf(typeKey, inner, opts) {
|
|
414
483
|
const { ownerTfLabel, scope = "app", objectId, diagnostics } = opts;
|
|
415
484
|
const name = inner.name ?? "";
|
|
@@ -486,7 +555,7 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
486
555
|
if (typeof include.picklist === "object" && include.picklist !== null) {
|
|
487
556
|
const field = include.picklist.picklistFieldId;
|
|
488
557
|
if (field?.refName !== undefined) {
|
|
489
|
-
const value = fieldRefToTfValue(field.fieldType ?? "PICKLIST", field.refName, ownerTfLabel, scope);
|
|
558
|
+
const value = fieldRefToTfValue(field.fieldType ?? "PICKLIST", field.refName, ownerTfLabel, scope, opts.fieldOwnership);
|
|
490
559
|
if (value !== undefined) {
|
|
491
560
|
attrs["include_type"] = "PICKLIST";
|
|
492
561
|
attrs["picklist_field_id"] = value;
|
|
@@ -509,7 +578,10 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
509
578
|
if (subType.typeKey === "calculated" && inner.defaultValue !== undefined) {
|
|
510
579
|
diagnostics.push(`field "${name}": calculated fields do not support defaultValue; dropped`);
|
|
511
580
|
}
|
|
512
|
-
if (subType.
|
|
581
|
+
else if (NO_DEFAULT_VALUE_RESOURCES.has(subType.resourceType) && inner.defaultValue !== undefined) {
|
|
582
|
+
diagnostics.push(`field "${name}": ${NO_DEFAULT_VALUE_RESOURCES.get(subType.resourceType)} fields cannot set defaultValue; defaultValue dropped`);
|
|
583
|
+
}
|
|
584
|
+
if (subType.typeKey !== "calculated" && !NO_DEFAULT_VALUE_RESOURCES.has(subType.resourceType) && inner.defaultValue !== undefined) {
|
|
513
585
|
const orgRef = asOrgFieldRef(inner.defaultValue);
|
|
514
586
|
if (orgRef !== undefined) {
|
|
515
587
|
if (opts.orgRefs === undefined) {
|
|
@@ -533,6 +605,16 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
533
605
|
if (inner.tags !== undefined && inner.tags.length > 0) {
|
|
534
606
|
attrs["field_role"] = [...inner.tags];
|
|
535
607
|
}
|
|
608
|
+
if (inner.mediaTypes !== undefined) {
|
|
609
|
+
if (subType.typeKey !== "attachment") {
|
|
610
|
+
diagnostics.push(`field "${name}": mediaTypes is only valid on attachment fields; dropped`);
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
const mediaTypes = attachmentMediaTypes(inner.mediaTypes, diagnostics, name);
|
|
614
|
+
if (mediaTypes !== undefined)
|
|
615
|
+
attrs["media_types"] = mediaTypes;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
536
618
|
if (typeKey === "decimal" && inner.decimalPlaces !== undefined) {
|
|
537
619
|
if (attrs["decimal_places"] !== undefined && attrs["decimal_places"] !== inner.decimalPlaces) {
|
|
538
620
|
diagnostics.push(`field "${name}": decimalPlaces conflicts with numericFormat.decimalPlaces; decimalPlaces wins`);
|
|
@@ -626,6 +708,26 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
626
708
|
const block = { kind: "resource", type: subType.resourceType, label: tfLabel, attrs };
|
|
627
709
|
return { block, bagKey, address: `${subType.resourceType}.${tfLabel}` };
|
|
628
710
|
}
|
|
711
|
+
/**
|
|
712
|
+
* Attachment `media_types`. An unset or empty list stays omitted so a field
|
|
713
|
+
* without a restriction keeps its previous HCL. A value that is not
|
|
714
|
+
* `type/subtype` drops the attribute rather than emitting a list that
|
|
715
|
+
* matches no upload.
|
|
716
|
+
*/
|
|
717
|
+
function attachmentMediaTypes(value, diagnostics, name) {
|
|
718
|
+
if (!Array.isArray(value)) {
|
|
719
|
+
diagnostics.push(`field "${name}": mediaTypes must be a list of MIME types; dropped`);
|
|
720
|
+
return undefined;
|
|
721
|
+
}
|
|
722
|
+
const badAt = value.findIndex((entry) => !isAttachmentMediaType(entry));
|
|
723
|
+
if (badAt !== -1) {
|
|
724
|
+
diagnostics.push(`field "${name}": mediaTypes entry ${JSON.stringify(value[badAt])} is not a MIME type (expected type/subtype); dropped`);
|
|
725
|
+
return undefined;
|
|
726
|
+
}
|
|
727
|
+
if (value.length === 0)
|
|
728
|
+
return undefined;
|
|
729
|
+
return [...value];
|
|
730
|
+
}
|
|
629
731
|
function scalarOrUndefined(v) {
|
|
630
732
|
return typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? v : undefined;
|
|
631
733
|
}
|
|
@@ -643,16 +745,30 @@ function scalarOrUndefined(v) {
|
|
|
643
745
|
* diagnostic wording since the two failure cases usually read differently
|
|
644
746
|
* at each call site.
|
|
645
747
|
*/
|
|
646
|
-
/**
|
|
647
|
-
|
|
648
|
-
|
|
748
|
+
/**
|
|
749
|
+
* Element system fields resolve through their `element/locals.ts` locals.
|
|
750
|
+
* Elements have no status/stage fields; the audit fields exist only on some
|
|
751
|
+
* elements, which the build checks against `systemFields.audit`. An element
|
|
752
|
+
* may author its own field under an audit key (`createdAt: dateTimeField(…)`),
|
|
753
|
+
* which shadows the audit field, so a key in `fieldAddresses` is that field.
|
|
754
|
+
*/
|
|
755
|
+
const ELEMENT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_SYSTEM_FIELD_KEYS);
|
|
756
|
+
const ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_AUDIT_SYSTEM_FIELD_KEYS);
|
|
757
|
+
export function fieldRefToTfValue(fieldType, refName, ownerTfLabel, scope = "app", fieldOwnership) {
|
|
649
758
|
if (!isCanonicalTsLabel(refName))
|
|
650
759
|
return undefined;
|
|
651
|
-
|
|
760
|
+
if (scope === "element" &&
|
|
761
|
+
ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET.has(refName) &&
|
|
762
|
+
fieldOwnership === undefined) {
|
|
763
|
+
throw new EntityTfError(`element field "${refName}" requires authored-field ownership metadata to distinguish a custom field from the platform audit field`);
|
|
764
|
+
}
|
|
765
|
+
const isSystemField = scope === "element"
|
|
766
|
+
? ELEMENT_SYSTEM_FIELD_KEY_SET.has(refName) && !(ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET.has(refName) && fieldOwnership?.has(refName) === true)
|
|
767
|
+
: SYSTEM_FIELD_KEY_SET.has(refName);
|
|
652
768
|
if (isSystemField) {
|
|
653
769
|
return expr.local(`${ownerTfLabel}_${tsLabelToTfLabel(refName)}_field_id`);
|
|
654
770
|
}
|
|
655
|
-
const knownAddress =
|
|
771
|
+
const knownAddress = fieldOwnership?.get?.(refName);
|
|
656
772
|
if (knownAddress !== undefined) {
|
|
657
773
|
const dotIndex = knownAddress.indexOf(".");
|
|
658
774
|
if (dotIndex !== -1) {
|
|
@@ -151,14 +151,22 @@ export function fileReaderFromTf(block, appTfLabel, _ctx) {
|
|
|
151
151
|
const fields = parseExcelFields(attrs.fields ?? [], where);
|
|
152
152
|
// document_content/document_name/file_type are never returned by
|
|
153
153
|
// Read() on an already-imported resource (the provider's schema docs
|
|
154
|
-
// say so),
|
|
154
|
+
// say so), and older exports emitted placeholders for them - even
|
|
155
155
|
// document_content's empty-string placeholder counts as a change on
|
|
156
|
-
// this always-forces-replacement attribute, so reproducing
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
156
|
+
// this always-forces-replacement attribute, so reproducing them plans a
|
|
157
|
+
// spurious destroy+recreate. Only a real document is extracted: one a
|
|
158
|
+
// re-pull filled from this workspace's own state
|
|
159
|
+
// (alignExportWithState), which is what the reader holds.
|
|
160
|
+
// Adoption separately strips these attributes from `.tf/in/` itself
|
|
160
161
|
// (stripUnrecoverableExcelFileReaderAttrs in engine/adopt/adopt.ts),
|
|
161
162
|
// since its gate plans against ei's raw export, not this extractor.
|
|
163
|
+
const document = typeof attrs.document_content === "string" && attrs.document_content !== ""
|
|
164
|
+
? {
|
|
165
|
+
documentContent: attrs.document_content,
|
|
166
|
+
...(typeof attrs.document_name === "string" && { documentName: attrs.document_name }),
|
|
167
|
+
...(typeof attrs.file_type === "string" && { fileType: attrs.file_type }),
|
|
168
|
+
}
|
|
169
|
+
: {};
|
|
162
170
|
return {
|
|
163
171
|
fileReader: {
|
|
164
172
|
refName,
|
|
@@ -167,6 +175,7 @@ export function fileReaderFromTf(block, appTfLabel, _ctx) {
|
|
|
167
175
|
name,
|
|
168
176
|
firstRowIsHeader: attrs.first_row_is_header,
|
|
169
177
|
fields,
|
|
178
|
+
...document,
|
|
170
179
|
},
|
|
171
180
|
},
|
|
172
181
|
};
|
|
@@ -87,6 +87,7 @@ export const fileReaderModule = {
|
|
|
87
87
|
key: t.typeKey,
|
|
88
88
|
resourceType: t.resourceType,
|
|
89
89
|
implemented: t.implemented === true,
|
|
90
|
+
...(t.unreadableAttributes !== undefined && { unreadableAttributes: t.unreadableAttributes }),
|
|
90
91
|
})),
|
|
91
92
|
},
|
|
92
93
|
data: { participates: true, resourceType: "elementum_ai_file_reader", lookupAttr: "name", referencedByBuild: false },
|
|
@@ -21,6 +21,8 @@ export interface FileReaderSubType {
|
|
|
21
21
|
readonly resourceType: string;
|
|
22
22
|
/** Round-trips on the terraform path (to-tf + from-tf + printer). */
|
|
23
23
|
readonly implemented?: true;
|
|
24
|
+
/** Attributes the platform never returns on read; a re-pull fills them from state. */
|
|
25
|
+
readonly unreadableAttributes?: readonly string[];
|
|
24
26
|
}
|
|
25
27
|
export declare const FILE_READER_SUB_TYPES: readonly FileReaderSubType[];
|
|
26
28
|
export declare const FILE_READER_SUB_TYPE_BY_TYPE_KEY: ReadonlyMap<string, FileReaderSubType>;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* provider's `values` attribute.
|
|
16
16
|
*/
|
|
17
17
|
export const FILE_READER_SUB_TYPES = [
|
|
18
|
-
{ typeKey: "excel", resourceType: "elementum_excel_file_reader", implemented: true },
|
|
18
|
+
{ typeKey: "excel", resourceType: "elementum_excel_file_reader", implemented: true, unreadableAttributes: ["document_content", "document_name", "file_type"] },
|
|
19
19
|
{ typeKey: "json", resourceType: "elementum_json_file_reader", implemented: true },
|
|
20
20
|
{ typeKey: "text", resourceType: "elementum_text_file_reader", implemented: true },
|
|
21
21
|
{ typeKey: "xml", resourceType: "elementum_xml_file_reader", implemented: true },
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ViewRef } from "../../catalog/index.js";
|
|
2
|
+
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
|
+
/** One portal menu entry: a managed view under its own slug. */
|
|
4
|
+
export interface PortalMenuItem {
|
|
5
|
+
readonly view: ViewRef;
|
|
6
|
+
readonly slug: string;
|
|
7
|
+
/** Menu text; the platform shows the view's name when omitted. */
|
|
8
|
+
readonly label?: string;
|
|
9
|
+
/** Opens this view when the portal opens. At most one item. */
|
|
10
|
+
readonly home?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface DefinePortalOptions extends EntityDeployOptions {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly slug: string;
|
|
15
|
+
/** Once set, the platform can change it but not clear it. */
|
|
16
|
+
readonly description?: string;
|
|
17
|
+
/** Once set, the platform can change it but not clear it. */
|
|
18
|
+
readonly icon?: string;
|
|
19
|
+
/** Once set, the platform can change it but not clear it. */
|
|
20
|
+
readonly color?: string;
|
|
21
|
+
readonly menu?: readonly PortalMenuItem[];
|
|
22
|
+
}
|
|
23
|
+
export interface PortalConfigured {
|
|
24
|
+
def(refName: string): DeployableEntity;
|
|
25
|
+
}
|
|
26
|
+
export declare function portal(opts: DefinePortalOptions): PortalConfigured;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { slimTokens } from "../../catalog/index.js";
|
|
2
|
+
// View names aren't unique, so a catalog view is identified by its owner, bag
|
|
3
|
+
// and key; only a viewRef outside the workspace falls back to its name.
|
|
4
|
+
const viewKey = (view) => view.viewType !== undefined
|
|
5
|
+
? `${view.parentKind ?? "app"}:${view.parent}:${view.viewType}:${view.refName}`
|
|
6
|
+
: `${view.parentKind ?? "app"}:${view.parentNamespace ?? view.parent}:${view.name}`;
|
|
7
|
+
export function portal(opts) {
|
|
8
|
+
const where = `portal ${JSON.stringify(opts.name)}`;
|
|
9
|
+
if (opts.name.trim() === "")
|
|
10
|
+
throw new Error("portal requires a non-empty name.");
|
|
11
|
+
if (opts.slug.trim() === "")
|
|
12
|
+
throw new Error(`${where}: slug is required.`);
|
|
13
|
+
for (const key of ["description", "icon", "color"]) {
|
|
14
|
+
if (opts[key]?.trim() === "")
|
|
15
|
+
throw new Error(`${where}: ${key} can't be empty; leave it out instead.`);
|
|
16
|
+
}
|
|
17
|
+
const menu = opts.menu ?? [];
|
|
18
|
+
const slugs = new Set();
|
|
19
|
+
const views = new Set();
|
|
20
|
+
for (const item of menu) {
|
|
21
|
+
if (item.slug.trim() === "")
|
|
22
|
+
throw new Error(`${where}: menu item for view ${JSON.stringify(item.view.name)} needs a slug.`);
|
|
23
|
+
if (item.label?.trim() === "")
|
|
24
|
+
throw new Error(`${where}: menu item ${JSON.stringify(item.slug)} has an empty label; leave it out to show the view's name.`);
|
|
25
|
+
if (slugs.has(item.slug))
|
|
26
|
+
throw new Error(`${where}: menu slug ${JSON.stringify(item.slug)} is used twice.`);
|
|
27
|
+
if (views.has(viewKey(item.view)))
|
|
28
|
+
throw new Error(`${where}: view ${JSON.stringify(item.view.name)} is in the menu twice.`);
|
|
29
|
+
slugs.add(item.slug);
|
|
30
|
+
views.add(viewKey(item.view));
|
|
31
|
+
}
|
|
32
|
+
if (menu.filter((item) => item.home === true).length > 1)
|
|
33
|
+
throw new Error(`${where}: only one menu item can be the homepage.`);
|
|
34
|
+
return { def(refName) {
|
|
35
|
+
return { kind: "portal", parent: "org", refName, payload: slimTokens(opts), ...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}) };
|
|
36
|
+
} };
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
3
|
+
/** A view's owner as the export looks it up: an app or element by namespace, a task by name. */
|
|
4
|
+
export type PortalViewOwner = {
|
|
5
|
+
readonly kind: "app" | "element";
|
|
6
|
+
readonly namespace: string;
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: "task";
|
|
9
|
+
readonly name: string;
|
|
10
|
+
};
|
|
11
|
+
export interface NormalizedPortalItem {
|
|
12
|
+
readonly owner: PortalViewOwner;
|
|
13
|
+
readonly viewName: string;
|
|
14
|
+
readonly slug: string;
|
|
15
|
+
readonly label?: string;
|
|
16
|
+
readonly home?: true;
|
|
17
|
+
}
|
|
18
|
+
export interface NormalizedPortal {
|
|
19
|
+
readonly refName: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly slug: string;
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
readonly icon?: string;
|
|
24
|
+
readonly color?: string;
|
|
25
|
+
readonly items: readonly NormalizedPortalItem[];
|
|
26
|
+
}
|
|
27
|
+
export declare function portalFromTf(block: TfBlock, ctx: FromTfContext): NormalizedPortal;
|