@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,7 +11,7 @@
|
|
|
11
11
|
import type { ApprovalChainRef, AppOrElementRef, DatamineRef, FieldRef } from "../../catalog/index.js";
|
|
12
12
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
13
13
|
import type { RecordShape } from "../field/record-shape.js";
|
|
14
|
-
import { type InferTriggerType, type TriggerInputFieldDef, type TriggerInputSchema } from "../../core/triggers/on-demand.js";
|
|
14
|
+
import { type InferTriggerType, type WithOnDemandTriggeredBy, type TriggerInputFieldDef, type TriggerInputSchema } from "../../core/triggers/on-demand.js";
|
|
15
15
|
import type { TriggerFieldTypeAlias } from "../shared/types/field-types.js";
|
|
16
16
|
import type { Filter } from "./filter.js";
|
|
17
17
|
import { type TriggerChain } from "./build.js";
|
|
@@ -71,7 +71,9 @@ type NormalizeSpec<S extends TriggerInputSchemaSpec> = {
|
|
|
71
71
|
type: S[K];
|
|
72
72
|
} : Extract<S[K], TriggerInputFieldDef>;
|
|
73
73
|
};
|
|
74
|
-
export declare function onDemand<S extends TriggerInputSchemaSpec>(schema: S
|
|
74
|
+
export declare function onDemand<S extends TriggerInputSchemaSpec>(schema: S & {
|
|
75
|
+
readonly triggeredBy?: never;
|
|
76
|
+
}): TriggerChain<WithOnDemandTriggeredBy<InferTriggerType<NormalizeSpec<S> & TriggerInputSchema>, NormalizeSpec<S>>>;
|
|
75
77
|
export interface WebhookTriggerOptions {
|
|
76
78
|
readonly authenticated?: boolean;
|
|
77
79
|
/** Pre-built wire custom-response envelope. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
|
|
1
2
|
import { serializeOnDemandTrigger, } from "../../core/triggers/on-demand.js";
|
|
2
3
|
import { chainableTrigger } from "./build.js";
|
|
3
4
|
function recordTriggerFields(opts) {
|
|
@@ -65,6 +66,9 @@ export function schedule(opts) {
|
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
export function onDemand(schema) {
|
|
69
|
+
if (Object.hasOwn(schema, "triggeredBy")) {
|
|
70
|
+
throw new EdkValidationError('onDemand input "triggeredBy" is reserved: ctx.trigger.triggeredBy is the user who ran the automation. Rename the input.');
|
|
71
|
+
}
|
|
68
72
|
const normalized = Object.fromEntries(Object.entries(schema).map(([k, v]) => [k, typeof v === "string" ? { type: v } : v]));
|
|
69
73
|
return chainableTrigger({
|
|
70
74
|
wire: serializeOnDemandTrigger(normalized),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { workspaceAspectKey, } from "../../engine/build/context.js";
|
|
2
2
|
import { EntityTfError } from "../../engine/entity.js";
|
|
3
3
|
import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
4
|
-
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
4
|
+
import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
|
|
5
5
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
6
6
|
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
7
7
|
import { CHART_RESOURCE_TYPE } from "./types.js";
|
|
@@ -19,7 +19,14 @@ function datasourceId(ref, opts, where) {
|
|
|
19
19
|
const local = opts.workspaceAspects?.get(workspaceAspectKey(kind, ref.refName));
|
|
20
20
|
if (local !== undefined) {
|
|
21
21
|
const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : ref.__kind === "task" ? "elementum_task" : TABLE_RESOURCE_TYPE;
|
|
22
|
-
return {
|
|
22
|
+
return {
|
|
23
|
+
ref,
|
|
24
|
+
kind,
|
|
25
|
+
id: expr.resourceAttr(type, local.tfLabel, ["id"]),
|
|
26
|
+
tfLabel: local.tfLabel,
|
|
27
|
+
local: true,
|
|
28
|
+
fieldOwnership: authoredFieldKeysFromPayload(local.streamRootEntity?.payload),
|
|
29
|
+
};
|
|
23
30
|
}
|
|
24
31
|
const name = ref.name ?? ref.refName;
|
|
25
32
|
if (ref.__kind === "app" || ref.__kind === "element") {
|
|
@@ -52,7 +59,7 @@ function fieldId(ref, datasource, opts, where) {
|
|
|
52
59
|
throw new EntityTfError(`${where}: app/element fields cannot belong to a table datasource`);
|
|
53
60
|
if (datasource.local && datasource.ref.__kind !== "task") {
|
|
54
61
|
const scope = datasource.ref.__kind === "element" ? "element" : "app";
|
|
55
|
-
const direct = fieldRefToTfValue(ref.fieldType ?? "", ref.refName, datasource.tfLabel, scope);
|
|
62
|
+
const direct = fieldRefToTfValue(ref.fieldType ?? "", ref.refName, datasource.tfLabel, scope, datasource.fieldOwnership);
|
|
56
63
|
if (direct !== undefined)
|
|
57
64
|
return direct;
|
|
58
65
|
}
|
|
@@ -52,6 +52,17 @@ export interface DynamicLayoutFieldComponent {
|
|
|
52
52
|
readonly fullWidth?: boolean;
|
|
53
53
|
readonly dependsOn?: readonly string[];
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Properties the layout editor offers on every block. Most blocks render only
|
|
57
|
+
* `label`; the editor stores and shows the rest, so they round-trip.
|
|
58
|
+
*/
|
|
59
|
+
export interface DynamicLayoutBlockCommon {
|
|
60
|
+
readonly label?: string;
|
|
61
|
+
readonly title?: string;
|
|
62
|
+
readonly collapsed?: boolean;
|
|
63
|
+
readonly hidden?: boolean;
|
|
64
|
+
readonly sideNavItem?: boolean;
|
|
65
|
+
}
|
|
55
66
|
/** One automation trigger parameter an automation button supplies. */
|
|
56
67
|
export interface DynamicLayoutAutomationButtonInput {
|
|
57
68
|
/** On-demand trigger parameter of the button's automation (or of `automation`). */
|
|
@@ -103,9 +114,12 @@ export interface DynamicLayoutComponentVariantMap {
|
|
|
103
114
|
readonly className?: string;
|
|
104
115
|
};
|
|
105
116
|
readonly row: {
|
|
117
|
+
/** Equal-width grid columns (1-12); the row then ignores `justifyContent` and `wrap`. */
|
|
118
|
+
readonly columns?: number;
|
|
106
119
|
readonly gap?: DynamicLayoutCssLength;
|
|
107
120
|
readonly alignItems?: "start" | "center" | "end" | "stretch" | "baseline";
|
|
108
121
|
readonly justifyContent?: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
122
|
+
/** The renderer wraps a row that leaves this unset. */
|
|
109
123
|
readonly wrap?: boolean;
|
|
110
124
|
readonly className?: string;
|
|
111
125
|
};
|
|
@@ -162,8 +176,7 @@ export interface DynamicLayoutComponentVariantMap {
|
|
|
162
176
|
readonly variant?: "default" | "outline" | "ghost";
|
|
163
177
|
readonly icon?: string;
|
|
164
178
|
};
|
|
165
|
-
readonly updateBlock: {
|
|
166
|
-
readonly title?: string;
|
|
179
|
+
readonly updateBlock: DynamicLayoutBlockCommon & {
|
|
167
180
|
readonly fields?: readonly AppViewFieldRef[];
|
|
168
181
|
readonly submitLabel?: string;
|
|
169
182
|
};
|
|
@@ -188,32 +201,14 @@ export interface DynamicLayoutComponentVariantMap {
|
|
|
188
201
|
readonly currency?: string;
|
|
189
202
|
readonly locale?: string;
|
|
190
203
|
};
|
|
191
|
-
readonly stageBlock:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
readonly
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
readonly
|
|
198
|
-
|
|
199
|
-
readonly title?: string;
|
|
200
|
-
};
|
|
201
|
-
readonly approvalsBlock: {
|
|
202
|
-
readonly label?: string;
|
|
203
|
-
};
|
|
204
|
-
readonly attachmentsBlock: {
|
|
205
|
-
readonly label?: string;
|
|
206
|
-
readonly title?: string;
|
|
207
|
-
};
|
|
208
|
-
readonly relatedTasksBlock: {
|
|
209
|
-
readonly label?: string;
|
|
210
|
-
};
|
|
211
|
-
readonly relationshipsBlock: {
|
|
212
|
-
readonly label?: string;
|
|
213
|
-
};
|
|
214
|
-
readonly relatedItemsBlock: {
|
|
215
|
-
readonly label?: string;
|
|
216
|
-
readonly title?: string;
|
|
204
|
+
readonly stageBlock: DynamicLayoutBlockCommon;
|
|
205
|
+
readonly slaBlock: DynamicLayoutBlockCommon;
|
|
206
|
+
readonly activityLogBlock: DynamicLayoutBlockCommon;
|
|
207
|
+
readonly approvalsBlock: DynamicLayoutBlockCommon;
|
|
208
|
+
readonly attachmentsBlock: DynamicLayoutBlockCommon;
|
|
209
|
+
readonly relatedTasksBlock: DynamicLayoutBlockCommon;
|
|
210
|
+
readonly relationshipsBlock: DynamicLayoutBlockCommon;
|
|
211
|
+
readonly relatedItemsBlock: DynamicLayoutBlockCommon & {
|
|
217
212
|
readonly fieldName?: string;
|
|
218
213
|
readonly color?: string;
|
|
219
214
|
readonly fullWidth?: boolean;
|
|
@@ -222,9 +217,7 @@ export interface DynamicLayoutComponentVariantMap {
|
|
|
222
217
|
/** Record filter over the related app's or element's fields. */
|
|
223
218
|
readonly filter?: Filter<FieldRef, never>;
|
|
224
219
|
};
|
|
225
|
-
readonly surveysBlock:
|
|
226
|
-
readonly label?: string;
|
|
227
|
-
};
|
|
220
|
+
readonly surveysBlock: DynamicLayoutBlockCommon;
|
|
228
221
|
}
|
|
229
222
|
type ExactlyOneVariant<Map extends object> = {
|
|
230
223
|
[K in keyof Map]: {
|
|
@@ -2,12 +2,16 @@ import { type AppOrElementRef, type CloudLinkRef, type FieldRef } from "../../ca
|
|
|
2
2
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
3
|
import type { AccessPolicyOptions } from "../access-policy/build.js";
|
|
4
4
|
import type { ElementDynamicLayout } from "../dynamic-layout/build.js";
|
|
5
|
-
import { type
|
|
5
|
+
import { type AppViewBags, type AppViewRefs, type AppCategory, type AppCustomView, type AppCloudOptions, type AppDashboard, type AppField, type AppFieldRefs, type AppLayout, type AppRecordCreateForm, type AppSystemFieldOverride } from "../app/build.js";
|
|
6
6
|
import { type DisplayBlock } from "../app/display-blocks.js";
|
|
7
7
|
import type { AppRelationship } from "../relationship/build.js";
|
|
8
8
|
import type { AppRole } from "../role/build.js";
|
|
9
9
|
import type { AppWidget } from "../widget/build.js";
|
|
10
10
|
import { type ElementSystemFieldKey } from "./system-fields.js";
|
|
11
|
+
/** A Custom view on an element. Agents are app-owned, so an element's Custom view has none. */
|
|
12
|
+
export type ElementCustomView = Omit<AppCustomView, "agent"> & {
|
|
13
|
+
readonly agent?: never;
|
|
14
|
+
};
|
|
11
15
|
export type { AppCalendarView, AppCategory, AppDashboard, AppDashboardView, AppField, AppKanbanView, AppLayout, AppListView, AppRecordCreateForm, AppRecordCreateFormSection, AppSystemFieldOverride, PicklistOption } from "../app/build.js";
|
|
12
16
|
export type { AppRelationship, AppRelationshipColumn } from "../relationship/build.js";
|
|
13
17
|
export type { AppWidget, CreateRecordWidget, LinkRecordsWidget, RelatedRecordsWidget, RunAutomationWidget, RunAutomationWidgetParameter, WidgetButtonStyle, WidgetButtonType } from "../widget/build.js";
|
|
@@ -16,6 +20,13 @@ export { ELEMENT_SYSTEM_FIELD_KEYS, type ElementSystemFieldKey } from "./system-
|
|
|
16
20
|
export interface ElementSystemFields {
|
|
17
21
|
readonly id?: AppSystemFieldOverride;
|
|
18
22
|
readonly title?: AppSystemFieldOverride;
|
|
23
|
+
/**
|
|
24
|
+
* The element carries the platform's audit fields (Created on/by, Updated
|
|
25
|
+
* on/by). The platform adds them to apps but only to some elements, and
|
|
26
|
+
* EDK cannot create them, so referencing `createdAt`, `createdBy`,
|
|
27
|
+
* `updatedAt` or `updatedBy` on an element without this is a build error.
|
|
28
|
+
*/
|
|
29
|
+
readonly audit?: boolean;
|
|
19
30
|
}
|
|
20
31
|
/**
|
|
21
32
|
* The source table a LINKED element maps to — an existing table in the
|
|
@@ -36,7 +47,14 @@ export interface ElementCloudConnection {
|
|
|
36
47
|
/** The record-id source column on the mapped table. */
|
|
37
48
|
readonly idColumnName?: string;
|
|
38
49
|
}
|
|
39
|
-
|
|
50
|
+
/** An element's managed views: an app's view bags without agent views. */
|
|
51
|
+
export type ElementViewBags = Omit<AppViewBags, "agentViews" | "customViews"> & {
|
|
52
|
+
/** Custom views (pages of Elementum Blocks), keyed by view ref name. */
|
|
53
|
+
readonly customViews?: Readonly<Record<string, ElementCustomView>>;
|
|
54
|
+
};
|
|
55
|
+
/** Element options; `V` carries the view bags so `ref().views` keeps their keys. */
|
|
56
|
+
export type ElementV2Options<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, V extends ElementViewBags = ElementViewBags> = ElementV2OptionsBase<F, R> & V;
|
|
57
|
+
interface ElementV2OptionsBase<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> extends EntityDeployOptions {
|
|
40
58
|
/** Required platform handle (business acronym, e.g. "PRD") — distinct from the refName. */
|
|
41
59
|
readonly handle: string;
|
|
42
60
|
readonly name: string;
|
|
@@ -106,15 +124,8 @@ export interface ElementV2Options<F extends Record<string, AppField> = Record<st
|
|
|
106
124
|
* condition, and save-group keys.
|
|
107
125
|
*/
|
|
108
126
|
readonly dynamicLayouts?: Readonly<Record<string, ElementDynamicLayout>>;
|
|
109
|
-
/** Saved list views, keyed by view ref name. */
|
|
110
|
-
readonly listViews?: Readonly<Record<string, AppListView>>;
|
|
111
|
-
/** Calendar views, keyed by stable view ref name. */
|
|
112
|
-
readonly calendarViews?: Readonly<Record<string, AppCalendarView>>;
|
|
113
|
-
/** Kanban views, keyed by stable view ref name. */
|
|
114
|
-
readonly kanbanViews?: Readonly<Record<string, AppKanbanView>>;
|
|
115
127
|
readonly dashboards?: Readonly<Record<string, AppDashboard>>;
|
|
116
128
|
readonly widgets?: Readonly<Record<string, AppWidget>>;
|
|
117
|
-
readonly dashboardViews?: Readonly<Record<string, AppDashboardView>>;
|
|
118
129
|
/**
|
|
119
130
|
* Typed new-record form (`elementum_record_create_form`). Mutually
|
|
120
131
|
* exclusive with `recordCreateDisplayBlocks` — author one or the other,
|
|
@@ -172,10 +183,11 @@ type ElementSystemFieldRefs<Parent extends string = string> = {
|
|
|
172
183
|
* record`). `id`/`title` round out the bag the same way `AppRef` folds in
|
|
173
184
|
* its full `SystemFieldKey` set — a finite, closed term, not a wide index.
|
|
174
185
|
*/
|
|
175
|
-
export type ElementRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string> = Extract<AppOrElementRef<RefName>, {
|
|
186
|
+
export type ElementRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, RefName extends string = string, V extends ElementViewBags = ElementViewBags> = Extract<AppOrElementRef<RefName>, {
|
|
176
187
|
readonly __kind: "element";
|
|
177
188
|
}> & {
|
|
178
189
|
readonly fields: AppFieldRefs<F, RefName> & ElementSystemFieldRefs<RefName> & R;
|
|
190
|
+
readonly views: AppViewRefs<V, RefName>;
|
|
179
191
|
};
|
|
180
192
|
/**
|
|
181
193
|
* The configured result of `element` — its reference surface (`ref()`)
|
|
@@ -183,9 +195,9 @@ export type ElementRef<F extends Record<string, AppField> = Record<string, AppFi
|
|
|
183
195
|
* argument**, not a constructor option — see `AppConfigured` in
|
|
184
196
|
* `src/aspects/build.ts` for the full rationale (identical here).
|
|
185
197
|
*/
|
|
186
|
-
export interface ElementConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never
|
|
187
|
-
ref<const RefName extends string>(refName: RefName): ElementRef<F, R, RefName>;
|
|
198
|
+
export interface ElementConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, V extends ElementViewBags = ElementViewBags> {
|
|
199
|
+
ref<const RefName extends string>(refName: RefName): ElementRef<F, R, RefName, V>;
|
|
188
200
|
def(refName: string): DeployableEntity;
|
|
189
201
|
}
|
|
190
202
|
/** Build a v2 element entity: org-owned, compose-body payload. Exposes `.ref(refName)` and `.def(refName)`. */
|
|
191
|
-
export declare function element<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never
|
|
203
|
+
export declare function element<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>, const V extends ElementViewBags = ElementViewBags>(opts: ElementV2Options<F, R, V>): ElementConfigured<F, R, V>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { slimTokens } from "../../catalog/index.js";
|
|
2
2
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_REQUIRED, SYSTEM_FIELD_TAG_BY_KEY } from "../../core/system-fields.js";
|
|
3
|
-
import { assertNoSystemKeyCollision, picklistOptionLabels, serializeField, } from "../app/build.js";
|
|
3
|
+
import { appViewRefs, assertNoSystemKeyCollision, picklistOptionLabels, serializeField, } from "../app/build.js";
|
|
4
4
|
import { serializeDisplayBlocks } from "../app/display-blocks.js";
|
|
5
5
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "./system-fields.js";
|
|
6
6
|
export { ELEMENT_SYSTEM_FIELD_KEYS } from "./system-fields.js";
|
|
@@ -105,6 +105,7 @@ export function element(opts) {
|
|
|
105
105
|
name: opts.name,
|
|
106
106
|
...(opts.namespace !== undefined ? { namespace: opts.namespace } : {}),
|
|
107
107
|
fields,
|
|
108
|
+
views: appViewRefs(opts, { refName, name: opts.name, ...(opts.namespace !== undefined ? { namespace: opts.namespace } : {}) }, "element"),
|
|
108
109
|
};
|
|
109
110
|
},
|
|
110
111
|
def(refName) {
|
|
@@ -124,6 +125,7 @@ export function element(opts) {
|
|
|
124
125
|
...(opts.cloudOptions !== undefined ? { cloudOptions: opts.cloudOptions } : {}),
|
|
125
126
|
...(opts.cloudConnection !== undefined ? { cloudConnection: opts.cloudConnection } : {}),
|
|
126
127
|
...(opts.commentsEnabled !== undefined ? { commentsEnabled: opts.commentsEnabled } : {}),
|
|
128
|
+
...(opts.systemFields?.audit === true ? { auditFields: true } : {}),
|
|
127
129
|
fields: [
|
|
128
130
|
...serializeElementSystemFields(opts.systemFields),
|
|
129
131
|
...Object.entries(opts.fields).map(([bagKey, field]) => serializeField(field, bagKey)),
|
|
@@ -137,6 +139,7 @@ export function element(opts) {
|
|
|
137
139
|
...(opts.dashboards !== undefined ? { dashboards: opts.dashboards } : {}),
|
|
138
140
|
...(opts.widgets !== undefined ? { widgets: opts.widgets } : {}),
|
|
139
141
|
...(opts.dashboardViews !== undefined ? { dashboardViews: opts.dashboardViews } : {}),
|
|
142
|
+
...(opts.customViews !== undefined ? { customViews: opts.customViews } : {}),
|
|
140
143
|
...(opts.recordCreateForm !== undefined ? { recordCreateForm: opts.recordCreateForm } : {}),
|
|
141
144
|
...(opts.dynamicLayouts !== undefined ? { dynamicLayouts: opts.dynamicLayouts } : {}),
|
|
142
145
|
...(opts.relationships !== undefined ? { relationships: opts.relationships } : {}),
|
|
@@ -17,6 +17,7 @@ export interface ElementFromTfViewBlocks {
|
|
|
17
17
|
readonly calendarViewBlocks: readonly TfBlock[];
|
|
18
18
|
readonly kanbanViewBlocks: readonly TfBlock[];
|
|
19
19
|
readonly dashboardViewBlocks: readonly TfBlock[];
|
|
20
|
+
readonly customViewBlocks?: readonly TfBlock[];
|
|
20
21
|
readonly managedViewOrderBlocks: readonly TfBlock[];
|
|
21
22
|
readonly recordCreateFormBlocks: readonly TfBlock[];
|
|
22
23
|
readonly dynamicLayoutBlocks?: readonly TfBlock[];
|
|
@@ -26,3 +27,13 @@ export interface ElementFromTfViewBlocks {
|
|
|
26
27
|
readonly widgetBlocks: readonly TfBlock[];
|
|
27
28
|
}
|
|
28
29
|
export declare function elementFromTf(elementBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: ElementFromTfViewBlocks, accessPolicyBlocks?: readonly TfBlock[], roleBlocks?: readonly TfBlock[]): ElementFromTfResult;
|
|
30
|
+
/**
|
|
31
|
+
* The export references an element's audit fields only when the platform
|
|
32
|
+
* gave it those fields, which EDK cannot otherwise observe: through its
|
|
33
|
+
* `<label>_(created|updated)_(at|by)_field_id` locals, or, in the element's
|
|
34
|
+
* own automations, through a trigger's Created/Updated outputs. Locals
|
|
35
|
+
* blocks are skipped by callers: `ei` defines those locals on every element.
|
|
36
|
+
* An authored field with the same display name wins over trigger-output
|
|
37
|
+
* heuristics.
|
|
38
|
+
*/
|
|
39
|
+
export declare function referencesElementAuditFields(label: string, blocks: readonly TfBlock[], authoredFieldNames?: ReadonlySet<string>): boolean;
|
|
@@ -146,7 +146,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
146
146
|
ctx.diagnostics.push(`element "${label}": no import block in the stream — adoption has no identity to bind`);
|
|
147
147
|
}
|
|
148
148
|
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: refName, ownerRefName: refName, scope: "element", ownerType: "ELEMENT_ASPECT" }, ctx);
|
|
149
|
-
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, [], viewBlocks.managedViewOrderBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "element" }, ctx);
|
|
149
|
+
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, customViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, [], viewBlocks.managedViewOrderBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "element" }, ctx, viewBlocks.customViewBlocks);
|
|
150
150
|
if (viewBlocks.recordCreateFormBlocks.length > 1) {
|
|
151
151
|
ctx.diagnostics.push(`element "${label}": found ${viewBlocks.recordCreateFormBlocks.length} record create forms; only the first is used`);
|
|
152
152
|
}
|
|
@@ -169,6 +169,11 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
169
169
|
accessPolicies.push(entry);
|
|
170
170
|
}
|
|
171
171
|
const roles = rolesFromTf(roleBlocks, accessPolicyOwner, ctx);
|
|
172
|
+
const auditFields = referencesElementAuditFields(label, [
|
|
173
|
+
...Object.values(viewBlocks).flatMap((blocks) => blocks ?? []),
|
|
174
|
+
...accessPolicyBlocks,
|
|
175
|
+
...roleBlocks,
|
|
176
|
+
], new Set(fields.map(({ field }) => field.name.toLowerCase())));
|
|
172
177
|
const element = {
|
|
173
178
|
id: elementId ?? "",
|
|
174
179
|
name,
|
|
@@ -186,11 +191,13 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
186
191
|
...(cloudOptions !== undefined && { cloudOptions }),
|
|
187
192
|
...(cloudConnection !== undefined && { cloudConnection }),
|
|
188
193
|
...(commentsEnabled !== undefined && { commentsEnabled }),
|
|
194
|
+
...(auditFields && { auditFields }),
|
|
189
195
|
...(layouts.length > 0 && { layouts }),
|
|
190
196
|
...(listViews.length > 0 && { listViews }),
|
|
191
197
|
...(calendarViews.length > 0 && { calendarViews }),
|
|
192
198
|
...(kanbanViews.length > 0 && { kanbanViews }),
|
|
193
199
|
...(dashboardViews.length > 0 && { dashboardViews }),
|
|
200
|
+
...(customViews.length > 0 && { customViews }),
|
|
194
201
|
...(dashboards.length > 0 && { dashboards }),
|
|
195
202
|
...(widgets.length > 0 && { widgets }),
|
|
196
203
|
...(recordCreateForm !== undefined && { recordCreateForm }),
|
|
@@ -205,3 +212,53 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
205
212
|
function systemEntry(key, name, type, tag, description) {
|
|
206
213
|
return { key, field: { id: "", name, type, tags: [tag], ...(description !== undefined && { description }) } };
|
|
207
214
|
}
|
|
215
|
+
const AUDIT_TRIGGER_REF_NAME = /^(?:Created|Updated) (?:At|On|By)\b/i;
|
|
216
|
+
/**
|
|
217
|
+
* The export references an element's audit fields only when the platform
|
|
218
|
+
* gave it those fields, which EDK cannot otherwise observe: through its
|
|
219
|
+
* `<label>_(created|updated)_(at|by)_field_id` locals, or, in the element's
|
|
220
|
+
* own automations, through a trigger's Created/Updated outputs. Locals
|
|
221
|
+
* blocks are skipped by callers: `ei` defines those locals on every element.
|
|
222
|
+
* An authored field with the same display name wins over trigger-output
|
|
223
|
+
* heuristics.
|
|
224
|
+
*/
|
|
225
|
+
export function referencesElementAuditFields(label, blocks, authoredFieldNames = new Set()) {
|
|
226
|
+
const auditLocal = new RegExp(`^${label}_(?:created|updated)_(?:at|by)_field_id$`);
|
|
227
|
+
const ownedTriggers = elementTriggerAddresses(label, blocks);
|
|
228
|
+
const visit = (value) => {
|
|
229
|
+
if (Array.isArray(value))
|
|
230
|
+
return value.some(visit);
|
|
231
|
+
if (typeof value !== "object" || value === null)
|
|
232
|
+
return false;
|
|
233
|
+
const node = value;
|
|
234
|
+
if (node["$expr"] === "local" && typeof node["name"] === "string" && auditLocal.test(node["name"]))
|
|
235
|
+
return true;
|
|
236
|
+
if (node["$expr"] === "resource-attr" && ownedTriggers.has(`${String(node["type"])}.${String(node["label"])}`)) {
|
|
237
|
+
const path = node["path"];
|
|
238
|
+
const index = path?.[1]?.index;
|
|
239
|
+
if (path?.[0] === "refs" &&
|
|
240
|
+
typeof index === "string" &&
|
|
241
|
+
AUDIT_TRIGGER_REF_NAME.test(index) &&
|
|
242
|
+
!authoredFieldNames.has(index.toLowerCase()))
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
return Object.values(node).some(visit);
|
|
246
|
+
};
|
|
247
|
+
return blocks.some((block) => block.kind !== "locals" && visit(block.attrs));
|
|
248
|
+
}
|
|
249
|
+
/** `<type>.<label>` of the triggers on automations whose `app_id` is this element. */
|
|
250
|
+
function elementTriggerAddresses(label, blocks) {
|
|
251
|
+
const isResource = (value, type, labels) => {
|
|
252
|
+
const node = value;
|
|
253
|
+
return typeof node === "object" && node !== null && node["$expr"] === "resource-attr" && node["type"] === type &&
|
|
254
|
+
typeof node["label"] === "string" && (labels === undefined ? node["label"] === label : labels.has(node["label"]));
|
|
255
|
+
};
|
|
256
|
+
const automations = new Set(blocks.flatMap((block) => block.kind === "resource" && block.type === "elementum_automation" && block.label !== undefined &&
|
|
257
|
+
isResource(block.attrs["app_id"], "elementum_element")
|
|
258
|
+
? [block.label]
|
|
259
|
+
: []));
|
|
260
|
+
return new Set(blocks.flatMap((block) => block.kind === "resource" && block.type?.endsWith("_trigger") === true &&
|
|
261
|
+
isResource(block.attrs["automation"], "elementum_automation", automations)
|
|
262
|
+
? [`${block.type}.${block.label}`]
|
|
263
|
+
: []));
|
|
264
|
+
}
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
* than folding into `src/aspects/` (which still owns `app` and the
|
|
6
6
|
* field/print internals genuinely shared between both aspect kinds).
|
|
7
7
|
*/
|
|
8
|
-
export { element, type ElementCloudConnection, type ElementConfigured, type ElementRef, type ElementV2Options, } from "./build.js";
|
|
8
|
+
export { element, type ElementCloudConnection, type ElementConfigured, type ElementCustomView, type ElementRef, type ElementSystemFields, type ElementV2Options, } from "./build.js";
|
|
9
|
+
export { type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, } from "../view/agent-view-layout.js";
|
|
9
10
|
export { type AppRecordCreateForm, type AppRecordCreateFormSection } from "../app/build.js";
|
|
10
11
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, type ListViewDensity, type ManagedViewSort, type ManagedViewSortAggregation, type ManagedViewSortDirection, type ManagedViewSortField, type ManagedViewSortOrder, } from "../view/build.js";
|
|
11
12
|
export { type AppRelationship, type AppRelationshipColumn } from "../relationship/build.js";
|
|
12
|
-
export {
|
|
13
|
+
export { runAutomationParameterValue, type RunAutomationParameterValue } from "../widget/build.js";
|
|
14
|
+
export { type DynamicLayoutBlockCommon, type DynamicLayoutComponent, type DynamicLayoutCondition, type DynamicLayoutCssLength, type DynamicLayoutDependency, type DynamicLayoutFieldComponent, type DynamicLayoutFieldValidation, type DynamicLayoutSaveGroup, type DynamicLayoutStyle, type DynamicLayoutTypedValue, type DynamicLayoutValidationRule, type ElementDynamicLayout, dynamicLayout, } from "../dynamic-layout/build.js";
|
|
13
15
|
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, type DashboardChartWidget, type DashboardRecordsWidget, type DashboardWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
|
|
14
|
-
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, type BaseFieldOptions, type CalculatedFieldOptions, type InferredCalculatedField, type NumericFieldFormat, type DropdownConfig, type DropdownDisplay, type DropdownFieldOptions, type DropdownOption, type DropdownParentValueRef, type DynamicDropdownConfig, type DynamicDropdownParent, type DynamicDropdownParentMapping, type MultiSelectFieldOptions, type NumericFieldOptions, type RelationFieldOptions, type QrFieldFormat, type TextFieldOptions, } from "../field/build.js";
|
|
16
|
+
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, type AttachmentFieldOptions, type BaseFieldOptions, type CalculatedFieldOptions, type InferredCalculatedField, type NumericFieldFormat, type DropdownConfig, type DropdownDisplay, type DropdownFieldOptions, type DropdownOption, type DropdownParentValueRef, type DynamicDropdownConfig, type DynamicDropdownParent, type DynamicDropdownParentMapping, type MultiSelectFieldOptions, type NumericFieldOptions, type RelationFieldOptions, type QrFieldFormat, type TextFieldOptions, } from "../field/build.js";
|
|
15
17
|
export { calc, dateDifUnit, dateTimeTruncPrecision, field, orderByDirection, predicateOp, weekdayMode, type ConcatExprType, type DateDifUnit, type DateTimeTruncPrecision, type Expr, type ExprType, type FieldRefExprType, type OrderByDirection, type Predicate, type PredicateOp, type StringAggOptions, type StringAggOrderBy, type WeekdayMode, } from "../field/calc.js";
|
|
16
18
|
export { asc, desc, sortBy, type SortDirection, type SortOrder } from "../shared/types/common.js";
|
|
17
19
|
export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyOptions, type AccessPolicyPrincipalRef, type AccessPolicyUserRef, type GroupId, type UserId } from "../access-policy/build.js";
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { element, } from "./build.js";
|
|
9
9
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, } from "../view/build.js";
|
|
10
|
+
export { runAutomationParameterValue } from "../widget/build.js";
|
|
10
11
|
export { dynamicLayout, } from "../dynamic-layout/build.js";
|
|
11
12
|
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, } from "../dashboard/build.js";
|
|
12
13
|
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, } from "../field/build.js";
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { NO_CATALOG, } from "../../graph/types.js";
|
|
7
7
|
import { appendFieldLocals } from "../field/locals.js";
|
|
8
|
-
import { CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE } from "../view/types.js";
|
|
9
|
-
import { elementFromTf } from "./from-tf.js";
|
|
8
|
+
import { CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE } from "../view/types.js";
|
|
9
|
+
import { elementFromTf, referencesElementAuditFields } from "./from-tf.js";
|
|
10
10
|
import { appendElementLocals } from "./locals.js";
|
|
11
11
|
import { elementToTf } from "./to-tf.js";
|
|
12
12
|
export const ELEMENT_RESOURCE_TYPE = "elementum_element";
|
|
@@ -23,6 +23,7 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
23
23
|
const calendarViewBlocks = viewBlocks.filter((b) => b.type === CALENDAR_VIEW_RESOURCE_TYPE);
|
|
24
24
|
const kanbanViewBlocks = viewBlocks.filter((b) => b.type === KANBAN_VIEW_RESOURCE_TYPE);
|
|
25
25
|
const dashboardViewBlocks = viewBlocks.filter((b) => b.type === DASHBOARD_VIEW_RESOURCE_TYPE);
|
|
26
|
+
const customViewBlocks = viewBlocks.filter((b) => b.type === CUSTOM_VIEW_RESOURCE_TYPE);
|
|
26
27
|
const managedViewOrderBlocks = stream.byKind.get("managed-view-order") ?? [];
|
|
27
28
|
const recordCreateFormBlocks = stream.byKind.get("record-create-form") ?? [];
|
|
28
29
|
const dynamicLayoutBlocks = stream.byKind.get("dynamic-layout") ?? [];
|
|
@@ -38,6 +39,7 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
38
39
|
calendarViewBlocks,
|
|
39
40
|
kanbanViewBlocks,
|
|
40
41
|
dashboardViewBlocks,
|
|
42
|
+
customViewBlocks,
|
|
41
43
|
managedViewOrderBlocks,
|
|
42
44
|
recordCreateFormBlocks,
|
|
43
45
|
dynamicLayoutBlocks,
|
|
@@ -46,8 +48,12 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
46
48
|
dashboardWidgetBlocks,
|
|
47
49
|
widgetBlocks,
|
|
48
50
|
}, accessPolicyBlocks, roleBlocks);
|
|
51
|
+
// Automations are extracted separately, but their trigger outputs are the
|
|
52
|
+
// only audit reference some elements have.
|
|
53
|
+
const auditFields = element.auditFields === true ||
|
|
54
|
+
referencesElementAuditFields(elementBlocks[0].label ?? "", stream.allResources, new Set(element.fields.map(({ field }) => field.name.toLowerCase())));
|
|
49
55
|
return {
|
|
50
|
-
instance: element,
|
|
56
|
+
instance: auditFields && element.auditFields !== true ? { ...element, auditFields } : element,
|
|
51
57
|
...(cloudLinkHandle !== undefined && { cloudLinkHandle }),
|
|
52
58
|
};
|
|
53
59
|
}
|
|
@@ -13,7 +13,7 @@ import { displayBlocksToRecordCreateFormSections } from "../app/display-blocks-t
|
|
|
13
13
|
import { dashboardsToTf } from "../dashboard/to-tf.js";
|
|
14
14
|
import { dynamicLayoutsToTf } from "../dynamic-layout/to-tf.js";
|
|
15
15
|
import { fieldMetadataFromEntries } from "../field/metadata.js";
|
|
16
|
-
import { fieldToTf } from "../field/to-tf.js";
|
|
16
|
+
import { authoredFieldKeysFromPayload, claimFieldDisplayName, fieldToTf } from "../field/to-tf.js";
|
|
17
17
|
import { CATEGORY_ORG_BAG } from "../org/category.js";
|
|
18
18
|
import { categoryIdExpr, missingCategoryDiagnostic } from "../org/category-ref.js";
|
|
19
19
|
import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
|
|
@@ -129,9 +129,11 @@ export function elementToTf(entity, ctx) {
|
|
|
129
129
|
}
|
|
130
130
|
const blocks = [];
|
|
131
131
|
const fieldAddresses = new Map();
|
|
132
|
+
const fieldOwnership = authoredFieldKeysFromPayload(payload);
|
|
132
133
|
const fieldNames = new Map();
|
|
133
134
|
const fieldMetadata = fieldMetadataFromEntries(payload.fields);
|
|
134
135
|
const objectId = expr.resourceAttr(ELEMENT_RESOURCE_TYPE, ctx.appTfLabel, ["id"]);
|
|
136
|
+
const fieldDisplayNames = new Map();
|
|
135
137
|
for (const fieldEntry of payload.fields ?? []) {
|
|
136
138
|
const typeKey = Object.keys(fieldEntry)[0];
|
|
137
139
|
if (typeKey === undefined)
|
|
@@ -179,9 +181,11 @@ export function elementToTf(entity, ctx) {
|
|
|
179
181
|
diagnostics: ctx.diagnostics,
|
|
180
182
|
orgRefs: ctx.orgRefs,
|
|
181
183
|
workspaceAspects: ctx.workspaceAspects,
|
|
184
|
+
fieldOwnership,
|
|
182
185
|
});
|
|
183
186
|
if (field === undefined)
|
|
184
187
|
continue;
|
|
188
|
+
claimFieldDisplayName(fieldDisplayNames, field);
|
|
185
189
|
blocks.push(field.block);
|
|
186
190
|
fieldAddresses.set(field.bagKey, field.address);
|
|
187
191
|
}
|
|
@@ -227,10 +231,11 @@ export function elementToTf(entity, ctx) {
|
|
|
227
231
|
objectId,
|
|
228
232
|
dashboardKeys: new Set(Object.keys(payload.dashboards ?? {})),
|
|
229
233
|
orgRefs: ctx.orgRefs,
|
|
234
|
+
workspaceAspects: ctx.workspaceAspects,
|
|
230
235
|
diagnostics: ctx.diagnostics,
|
|
231
236
|
fieldAddresses,
|
|
232
237
|
widgetKeys: new Set(Object.keys(payload.widgets ?? {})),
|
|
233
|
-
});
|
|
238
|
+
}, payload.customViews);
|
|
234
239
|
blocks.push(...viewBlocks);
|
|
235
240
|
const recordCreateFormForToTf = payload.recordCreateForm ??
|
|
236
241
|
(mappedRecordCreateFormSections !== undefined && mappedRecordCreateFormSections.length > 0
|
|
@@ -266,6 +271,7 @@ export function elementToTf(entity, ctx) {
|
|
|
266
271
|
orgRefs: ctx.orgRefs,
|
|
267
272
|
workspaceAspects: ctx.workspaceAspects,
|
|
268
273
|
diagnostics: ctx.diagnostics,
|
|
274
|
+
fieldOwnership: fieldAddresses,
|
|
269
275
|
}));
|
|
270
276
|
// Authored entries only. Creating an element also has the platform mint a
|
|
271
277
|
// creator policy (userIds = [you]) that is NOT in this payload — pull
|
|
@@ -140,6 +140,19 @@ export interface TextFieldOptions extends BaseFieldOptions {
|
|
|
140
140
|
/** @deprecated Prefer `calculatedField({ name, expression })`. */
|
|
141
141
|
readonly expression?: ScalarExpression<"text" | "uuid">;
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Options for `attachmentField`. Always set `mediaTypes` on a new attachment
|
|
145
|
+
* field. Each entry is a MIME type (`application/pdf`, `image/*`,
|
|
146
|
+
* `image/png`); `*` is allowed only as the subtype.
|
|
147
|
+
*
|
|
148
|
+
* Omitting `mediaTypes` on a newly created field leaves the live value null,
|
|
149
|
+
* and the platform rejects every upload. An existing field keeps its live
|
|
150
|
+
* value when `mediaTypes` is omitted (provider UseStateForNullSet; EDK
|
|
151
|
+
* neither sets nor clears it).
|
|
152
|
+
*/
|
|
153
|
+
export interface AttachmentFieldOptions extends BaseFieldOptions {
|
|
154
|
+
readonly mediaTypes?: readonly string[];
|
|
155
|
+
}
|
|
143
156
|
/**
|
|
144
157
|
* Options for `relationField` — a dynamic dropdown sourced from another
|
|
145
158
|
* App/Element/Task's records (`elementum_relation_field`), distinct from a
|
|
@@ -187,7 +200,7 @@ export declare function userField(opts: BaseFieldOptions & WithExpression<"user"
|
|
|
187
200
|
export declare function groupField(opts: BaseFieldOptions & WithExpression<"group">): AppField & {
|
|
188
201
|
readonly type: "GROUP";
|
|
189
202
|
};
|
|
190
|
-
export declare function attachmentField(opts:
|
|
203
|
+
export declare function attachmentField(opts: AttachmentFieldOptions & WithExpression<"attachment">): AppField & {
|
|
191
204
|
readonly type: "ATTACHMENT";
|
|
192
205
|
};
|
|
193
206
|
export declare function jsonField(opts: BaseFieldOptions & WithExpression<"json">): AppField & {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* AppField is accepted.
|
|
19
19
|
*/
|
|
20
20
|
import { assertCalculatedFieldRoot, coerce } from "./calc/runtime.js";
|
|
21
|
+
import { assertAttachmentMediaTypes } from "./media-types.js";
|
|
21
22
|
/** Product-visible rendering modes for dynamically sourced values. */
|
|
22
23
|
export const dropdownDisplay = {
|
|
23
24
|
dropdown: "DROPDOWN",
|
|
@@ -71,6 +72,8 @@ export function groupField(opts) {
|
|
|
71
72
|
return field("GROUP", opts);
|
|
72
73
|
}
|
|
73
74
|
export function attachmentField(opts) {
|
|
75
|
+
if (opts.mediaTypes !== undefined)
|
|
76
|
+
assertAttachmentMediaTypes(opts.name, opts.mediaTypes);
|
|
74
77
|
return field("ATTACHMENT", opts);
|
|
75
78
|
}
|
|
76
79
|
export function jsonField(opts) {
|