@elementumai/edk 0.9.6 → 0.9.9
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 +34 -3
- package/dist-sdk/src/catalog/factories.d.ts +26 -6
- package/dist-sdk/src/catalog/factories.js +41 -6
- package/dist-sdk/src/catalog/from-authoring.js +27 -33
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.js +93 -42
- package/dist-sdk/src/catalog/token.js +10 -0
- package/dist-sdk/src/catalog/types.d.ts +42 -3
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +2 -2
- package/dist-sdk/src/core/index.js +1 -1
- package/dist-sdk/src/core/platform-id.d.ts +2 -0
- package/dist-sdk/src/core/platform-id.js +4 -0
- package/dist-sdk/src/core/system-fields.d.ts +18 -0
- package/dist-sdk/src/core/system-fields.js +21 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
- package/dist-sdk/src/core/triggers/on-demand.js +33 -12
- package/dist-sdk/src/core/types/app.d.ts +14 -9
- package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
- package/dist-sdk/src/core/types/aspect-category.js +1 -0
- package/dist-sdk/src/core/types/platform.d.ts +1 -1
- package/dist-sdk/src/engine/build/context.d.ts +24 -8
- package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
- package/dist-sdk/src/engine/build/source-context.js +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +18 -0
- package/dist-sdk/src/engine/pull/org.d.ts +4 -0
- package/dist-sdk/src/engine/pull/org.js +17 -2
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
- package/dist-sdk/src/engine/pull/ref-only.js +35 -2
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
- package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
- package/dist-sdk/src/engine/workspace/loader.js +328 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +24 -4
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +11 -3
- package/dist-sdk/src/entities/agent/build.d.ts +54 -8
- package/dist-sdk/src/entities/agent/build.js +36 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +144 -3
- package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
- package/dist-sdk/src/entities/agent/from-tf.js +176 -5
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -4
- package/dist-sdk/src/entities/agent/to-tf.js +186 -11
- package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
- package/dist-sdk/src/entities/agent/tools.js +13 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +16 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +39 -6
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -12
- package/dist-sdk/src/entities/agent-tool/types.js +1 -0
- package/dist-sdk/src/entities/app/build.d.ts +44 -24
- package/dist-sdk/src/entities/app/build.js +18 -8
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +15 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
- package/dist-sdk/src/entities/app/from-tf.js +79 -14
- package/dist-sdk/src/entities/app/index.d.ts +3 -2
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/to-tf.js +30 -6
- package/dist-sdk/src/entities/automation/build.d.ts +37 -18
- package/dist-sdk/src/entities/automation/build.js +121 -12
- package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +8 -10
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +103 -20
- package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/from-tf.js +1165 -91
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +15 -5
- package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
- package/dist-sdk/src/entities/automation/operators.js +1 -0
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -4
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +33 -6
- package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +168 -36
- package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
- package/dist-sdk/src/entities/automation/task-label.js +18 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +159 -45
- package/dist-sdk/src/entities/automation/tasks.js +60 -47
- package/dist-sdk/src/entities/automation/to-tf.d.ts +7 -1
- package/dist-sdk/src/entities/automation/to-tf.js +816 -87
- package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
- package/dist-sdk/src/entities/automation/triggers.js +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
- package/dist-sdk/src/entities/element/build.d.ts +30 -7
- package/dist-sdk/src/entities/element/build.js +7 -3
- package/dist-sdk/src/entities/element/from-tf.js +7 -3
- package/dist-sdk/src/entities/element/index.d.ts +3 -2
- package/dist-sdk/src/entities/element/index.js +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +49 -8
- package/dist-sdk/src/entities/field/build.d.ts +94 -3
- package/dist-sdk/src/entities/field/build.js +82 -3
- package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/from-tf.js +104 -1
- package/dist-sdk/src/entities/field/locals.js +6 -7
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/options.js +12 -2
- package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
- package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
- package/dist-sdk/src/entities/field/to-tf.js +191 -56
- package/dist-sdk/src/entities/field/types.js +2 -0
- package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
- package/dist-sdk/src/entities/org/category-ref.js +12 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.js +18 -13
- package/dist-sdk/src/entities/relationship/from-tf.js +100 -7
- package/dist-sdk/src/entities/role/from-tf.js +10 -4
- package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +24 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +4 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +13 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +14 -8
- package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
- package/dist-sdk/src/entities/shared/handle-description.js +20 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
- package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
- package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
- package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
- package/dist-sdk/src/entities/skill/build.d.ts +51 -2
- package/dist-sdk/src/entities/skill/build.js +65 -8
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +79 -18
- package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/skill/from-tf.js +47 -5
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +89 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +327 -0
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +9 -25
- package/dist-sdk/src/entities/skill/to-tf.js +29 -40
- package/dist-sdk/src/entities/skill/tools.d.ts +12 -2
- package/dist-sdk/src/entities/skill/tools.js +3 -6
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +50 -14
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +9 -7
- package/dist-sdk/src/entities/skill-tool/to-tf.js +29 -23
- package/dist-sdk/src/entities/table/to-tf.js +21 -5
- package/dist-sdk/src/entities/task/to-tf.js +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +36 -10
- package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/to-tf.js +49 -30
- package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
- package/dist-sdk/src/entities/widget/from-tf.js +2 -2
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +52 -23
- package/dist-sdk/src/graph/index.d.ts +19 -1
- package/dist-sdk/src/graph/index.js +20 -0
- package/dist-sdk/src/graph/types.d.ts +22 -0
- package/package.json +11 -5
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* it's reference-model-agnostic (typed params, no id resolution), so there's
|
|
9
9
|
* nothing to retarget; it relocates to a shared home at the cutover.
|
|
10
10
|
*/
|
|
11
|
-
import type { AppOrElementRef, DatamineRef, FieldRef } from "../../catalog/index.js";
|
|
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
14
|
import { type InferTriggerType, type OnDemandTriggerOptions, type TriggerInputFieldDef, type TriggerInputSchema } from "../../core/triggers/on-demand.js";
|
|
@@ -63,14 +63,15 @@ export declare function schedule(opts: ScheduleTriggerOptions): TriggerChain<Sch
|
|
|
63
63
|
* the wire trigger-parameter declarations — a bare type parameter would be
|
|
64
64
|
* erased and deploy a trigger with no declared inputs.
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
type TriggerInputShorthand = Exclude<TriggerFieldTypeAlias, "record">;
|
|
67
|
+
export type TriggerInputSchemaSpec = Record<string, TriggerInputFieldDef | TriggerInputShorthand>;
|
|
67
68
|
/** Normalize a spec entry to the full def shape (type level). */
|
|
68
69
|
type NormalizeSpec<S extends TriggerInputSchemaSpec> = {
|
|
69
|
-
[K in keyof S]: S[K] extends
|
|
70
|
+
[K in keyof S]: S[K] extends TriggerInputShorthand ? {
|
|
70
71
|
type: S[K];
|
|
71
72
|
} : Extract<S[K], TriggerInputFieldDef>;
|
|
72
73
|
};
|
|
73
|
-
export declare function onDemand<S extends TriggerInputSchemaSpec, Options extends OnDemandTriggerOptions = Record<string, never>>(schema: S, options?: Options): TriggerChain<InferTriggerType<NormalizeSpec<S> & TriggerInputSchema, Options>>;
|
|
74
|
+
export declare function onDemand<S extends TriggerInputSchemaSpec, Options extends OnDemandTriggerOptions = Record<string, never>>(schema: S, options?: Options & Record<Exclude<keyof Options, keyof OnDemandTriggerOptions>, never>): TriggerChain<InferTriggerType<NormalizeSpec<S> & TriggerInputSchema, Options>>;
|
|
74
75
|
export interface WebhookTriggerOptions {
|
|
75
76
|
readonly authenticated?: boolean;
|
|
76
77
|
/** Pre-built wire custom-response envelope. */
|
|
@@ -110,7 +111,15 @@ export declare function temporal<A extends AppOrElementRef>(opts: TemporalTrigge
|
|
|
110
111
|
export type approvalProcessStatusUpdatedStatus = "ACTIVE" | "STEP_APPROVED" | "CANCELLED" | "DENIED" | "APPROVED";
|
|
111
112
|
export interface approvalProcessStatusUpdatedTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
|
|
112
113
|
readonly app: A;
|
|
113
|
-
|
|
114
|
+
/**
|
|
115
|
+
* The approval chain template to watch. Optional - the platform's
|
|
116
|
+
* approvalChainTemplate relation is genuinely nullable (edk#712); omit it
|
|
117
|
+
* to fire on any approval chain template's status change. A managed
|
|
118
|
+
* `ApprovalChainRef` token; `unsafePlatformId(...)` is the explicit escape
|
|
119
|
+
* hatch for a raw platform id pulled source can't reconstruct as a ref
|
|
120
|
+
* (same pattern as `dataMine`'s `datamine` option) - never a bare string.
|
|
121
|
+
*/
|
|
122
|
+
readonly approvalChain?: ApprovalChainRef | UnsafePlatformId;
|
|
114
123
|
readonly status: approvalProcessStatusUpdatedStatus;
|
|
115
124
|
}
|
|
116
125
|
/** Fires when an approval chain on a record changes to the configured status. */
|
|
@@ -113,7 +113,7 @@ export function approvalProcessStatusUpdated(opts) {
|
|
|
113
113
|
wire: {
|
|
114
114
|
approvalChain: {
|
|
115
115
|
aspectId: opts.app,
|
|
116
|
-
approvalChainTemplateId: opts.approvalChain,
|
|
116
|
+
...(opts.approvalChain !== undefined ? { approvalChainTemplateId: opts.approvalChain } : {}),
|
|
117
117
|
status: opts.status,
|
|
118
118
|
type: "APPROVAL_CHAIN_UPDATE",
|
|
119
119
|
},
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value-reference codec for the automation tf dialect.
|
|
3
|
+
*
|
|
4
|
+
* The compose wire carries refs as JSON envelopes ({triggerReference},
|
|
5
|
+
* {taskReference}, {variableReference}, {templateReference}, {value}); ei's
|
|
6
|
+
* HCL dialect carries them as `refs["…"]` RESOURCE EXPRESSIONS resolved at
|
|
7
|
+
* apply — `elementum_on_demand_trigger.x.refs["STUDENT_NAME"]` — with plain
|
|
8
|
+
* literals for static values and `${…}` interpolated strings for multi-part
|
|
9
|
+
* templates (cmd/elementum/export/hcl_task.go convertToRefsSyntax). ei's
|
|
10
|
+
* exporter falls back to embedding the raw JSON (with platform ids) when it
|
|
11
|
+
* can't resolve a ref; that fallback is NOT reproduced here — build emits only
|
|
12
|
+
* the id-free refs syntax, and pull reports the JSON fallback loudly instead
|
|
13
|
+
* of guessing.
|
|
14
|
+
*
|
|
15
|
+
* refs-map KEY naming (provider sources):
|
|
16
|
+
* - on_demand trigger: the DECLARED parameter name (the authored schema key;
|
|
17
|
+
* the wire's triggerReference name is the Mobius-canonicalized form —
|
|
18
|
+
* reverse-mapped here via the declared names).
|
|
19
|
+
* - variable task: the variable_name (buildVariableTaskRefs).
|
|
20
|
+
* - execute_script: "Result" for the whole result, "result.<prop>" per
|
|
21
|
+
* output-schema property.
|
|
22
|
+
*/
|
|
23
|
+
import { type TfValue } from "../../engine/tf/index.js";
|
|
24
|
+
import type { RefExpr } from "./deserializer/ast.js";
|
|
25
|
+
/** Map an authored/canonical onDemand param key to the declared parameter name. */
|
|
26
|
+
export declare function onDemandTriggerRefKey(name: string, paramNames: readonly string[]): string;
|
|
27
|
+
export interface WireRefContext {
|
|
28
|
+
/** The automation's tf label (trigger blocks share it). */
|
|
29
|
+
readonly autoLabel: string;
|
|
30
|
+
/** The trigger block's resource type. */
|
|
31
|
+
readonly triggerType: string;
|
|
32
|
+
/** Declared onDemand parameter names (authored schema keys), for reverse canonicalization. */
|
|
33
|
+
readonly paramNames: readonly string[];
|
|
34
|
+
/** Task refKey → its tf resource type (implemented tasks only). */
|
|
35
|
+
readonly taskType: (refKey: string) => string | undefined;
|
|
36
|
+
/** Task refKey → the result property names its output schema declares. */
|
|
37
|
+
readonly taskResultProps: (refKey: string) => readonly string[];
|
|
38
|
+
/** Stamped variable id → its owning task refKey + variable name. */
|
|
39
|
+
readonly variableById: ReadonlyMap<string, {
|
|
40
|
+
taskRefKey: string;
|
|
41
|
+
varName: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
export type WireRefResult = {
|
|
45
|
+
value: TfValue;
|
|
46
|
+
} | {
|
|
47
|
+
unsupported: string;
|
|
48
|
+
};
|
|
49
|
+
/** Wire ref envelope → tf attribute value (literal, refs expression, or template). */
|
|
50
|
+
export declare function wireRefToTf(ref: unknown, ctx: WireRefContext): WireRefResult;
|
|
51
|
+
/** Index the stamped variable ids in a finalized payload: id → {taskRefKey, varName}. */
|
|
52
|
+
export declare function indexVariableIds(tasks: ReadonlyArray<{
|
|
53
|
+
refKey?: string;
|
|
54
|
+
task?: Record<string, unknown>;
|
|
55
|
+
}>): Map<string, {
|
|
56
|
+
taskRefKey: string;
|
|
57
|
+
varName: string;
|
|
58
|
+
}>;
|
|
59
|
+
export interface TfRefContext {
|
|
60
|
+
/** The automation's tf label — the label-strip FALLBACK for refKey recovery. */
|
|
61
|
+
readonly autoLabel: string;
|
|
62
|
+
/** Trigger resource types (any `*_trigger`). */
|
|
63
|
+
readonly isTriggerType: (type: string) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Task tf label → the authored refKey (recovered from the block's `name`
|
|
66
|
+
* attribute when the label derives from it — see from-tf). Labels are
|
|
67
|
+
* snake_case by ei's labeling rule, so this is what preserves caps/spaces
|
|
68
|
+
* in task names across a pull.
|
|
69
|
+
*/
|
|
70
|
+
readonly refKeyByLabel: ReadonlyMap<string, string>;
|
|
71
|
+
}
|
|
72
|
+
export type TfRefResult = {
|
|
73
|
+
ast: RefExpr | string | number | boolean;
|
|
74
|
+
} | {
|
|
75
|
+
unsupported: string;
|
|
76
|
+
};
|
|
77
|
+
/** tf attribute value → printer AST node (inverse of wireRefToTf). */
|
|
78
|
+
export declare function tfRefToAst(value: TfValue, ctx: TfRefContext): TfRefResult;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value-reference codec for the automation tf dialect.
|
|
3
|
+
*
|
|
4
|
+
* The compose wire carries refs as JSON envelopes ({triggerReference},
|
|
5
|
+
* {taskReference}, {variableReference}, {templateReference}, {value}); ei's
|
|
6
|
+
* HCL dialect carries them as `refs["…"]` RESOURCE EXPRESSIONS resolved at
|
|
7
|
+
* apply — `elementum_on_demand_trigger.x.refs["STUDENT_NAME"]` — with plain
|
|
8
|
+
* literals for static values and `${…}` interpolated strings for multi-part
|
|
9
|
+
* templates (cmd/elementum/export/hcl_task.go convertToRefsSyntax). ei's
|
|
10
|
+
* exporter falls back to embedding the raw JSON (with platform ids) when it
|
|
11
|
+
* can't resolve a ref; that fallback is NOT reproduced here — build emits only
|
|
12
|
+
* the id-free refs syntax, and pull reports the JSON fallback loudly instead
|
|
13
|
+
* of guessing.
|
|
14
|
+
*
|
|
15
|
+
* refs-map KEY naming (provider sources):
|
|
16
|
+
* - on_demand trigger: the DECLARED parameter name (the authored schema key;
|
|
17
|
+
* the wire's triggerReference name is the Mobius-canonicalized form —
|
|
18
|
+
* reverse-mapped here via the declared names).
|
|
19
|
+
* - variable task: the variable_name (buildVariableTaskRefs).
|
|
20
|
+
* - execute_script: "Result" for the whole result, "result.<prop>" per
|
|
21
|
+
* output-schema property.
|
|
22
|
+
*/
|
|
23
|
+
import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
24
|
+
import { expr, isTfExpr, sanitizeName } from "../../engine/tf/index.js";
|
|
25
|
+
import { AUTOMATION_SUB_TYPE_BY_RESOURCE, AUTOMATION_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
26
|
+
const VARIABLE_TASK_TYPE = AUTOMATION_SUB_TYPE_BY_TYPE_KEY.get("variable").resourceType;
|
|
27
|
+
/** Map an authored/canonical onDemand param key to the declared parameter name. */
|
|
28
|
+
export function onDemandTriggerRefKey(name, paramNames) {
|
|
29
|
+
if (paramNames.includes(name))
|
|
30
|
+
return name;
|
|
31
|
+
return paramNames.find((p) => normalizeOnDemandParamKey(p) === name) ?? name;
|
|
32
|
+
}
|
|
33
|
+
function refsExpr(type, label, key) {
|
|
34
|
+
return expr.resourceAttr(type, label, ["refs", { index: key }]);
|
|
35
|
+
}
|
|
36
|
+
/** Wire ref envelope → tf attribute value (literal, refs expression, or template). */
|
|
37
|
+
export function wireRefToTf(ref, ctx) {
|
|
38
|
+
if (ref === null || typeof ref !== "object") {
|
|
39
|
+
return typeof ref === "string" || typeof ref === "number" || typeof ref === "boolean"
|
|
40
|
+
? { value: ref }
|
|
41
|
+
: { unsupported: `unrecognized value shape ${JSON.stringify(ref)}` };
|
|
42
|
+
}
|
|
43
|
+
const r = ref;
|
|
44
|
+
if ("value" in r && Object.keys(r).length === 1) {
|
|
45
|
+
const v = r["value"];
|
|
46
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean")
|
|
47
|
+
return { value: v };
|
|
48
|
+
return { unsupported: `static value of unsupported type ${JSON.stringify(v)}` };
|
|
49
|
+
}
|
|
50
|
+
const trig = r["triggerReference"];
|
|
51
|
+
if (trig !== undefined && typeof trig?.name === "string") {
|
|
52
|
+
// The wire carries the AUTHORED name verbatim (canonicalization dropped);
|
|
53
|
+
// exact declared match wins. The canonical-form lookup remains only for
|
|
54
|
+
// sources printed by the old printer, whose access paths were camelCased.
|
|
55
|
+
return { value: refsExpr(ctx.triggerType, ctx.autoLabel, onDemandTriggerRefKey(trig.name, ctx.paramNames)) };
|
|
56
|
+
}
|
|
57
|
+
const task = r["taskReference"];
|
|
58
|
+
if (task !== undefined && typeof task?.name === "string") {
|
|
59
|
+
const refKey = task.taskRefKey ?? "";
|
|
60
|
+
const type = ctx.taskType(refKey);
|
|
61
|
+
if (type === undefined)
|
|
62
|
+
return { unsupported: `taskReference to unknown/uncarried task "${refKey}"` };
|
|
63
|
+
const key = task.name === "result" ? "Result" : task.name;
|
|
64
|
+
if (key !== "Result" && !key.startsWith("result.")) {
|
|
65
|
+
return { unsupported: `taskReference output "${task.name}" has no known refs-map key` };
|
|
66
|
+
}
|
|
67
|
+
if (key.startsWith("result.")) {
|
|
68
|
+
// Per-property result refs exist ONLY when the script declares that
|
|
69
|
+
// property in its output schema — otherwise the apply fails with
|
|
70
|
+
// "Invalid index" on the refs map. Fail at build instead, with the fix.
|
|
71
|
+
const prop = key.slice("result.".length);
|
|
72
|
+
if (!ctx.taskResultProps(refKey).includes(prop)) {
|
|
73
|
+
return {
|
|
74
|
+
unsupported: `references result.${prop} of task "${refKey}", but that task declares no output schema for it — ` +
|
|
75
|
+
`add outputs: { ${prop}: "text" } (or the right type) to its executeScript`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return { value: refsExpr(type, `${ctx.autoLabel}_${sanitizeName(refKey)}`, key) };
|
|
80
|
+
}
|
|
81
|
+
const variable = r["variableReference"];
|
|
82
|
+
if (variable !== undefined && typeof variable?.id === "string") {
|
|
83
|
+
const target = ctx.variableById.get(variable.id);
|
|
84
|
+
if (target === undefined)
|
|
85
|
+
return { unsupported: `variableReference to an id not created in this workflow` };
|
|
86
|
+
return {
|
|
87
|
+
value: refsExpr(VARIABLE_TASK_TYPE, `${ctx.autoLabel}_${sanitizeName(target.taskRefKey)}`, target.varName),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const template = r["templateReference"];
|
|
91
|
+
if (template !== undefined && typeof template?.template === "string") {
|
|
92
|
+
const params = template.parameters ?? [];
|
|
93
|
+
// Single bare placeholder collapses to the ref itself (matches ei).
|
|
94
|
+
if (template.template === "{{{p1}}}" && params.length === 1) {
|
|
95
|
+
return wireRefToTf(params[0]?.value?.value, ctx);
|
|
96
|
+
}
|
|
97
|
+
const byName = new Map();
|
|
98
|
+
for (const p of params) {
|
|
99
|
+
if (typeof p?.value?.name === "string")
|
|
100
|
+
byName.set(p.value.name, p.value.value);
|
|
101
|
+
}
|
|
102
|
+
const parts = [];
|
|
103
|
+
let rest = template.template;
|
|
104
|
+
const placeholder = /\{\{\{(\w+)\}\}\}/;
|
|
105
|
+
for (;;) {
|
|
106
|
+
const m = placeholder.exec(rest);
|
|
107
|
+
if (m === null)
|
|
108
|
+
break;
|
|
109
|
+
if (m.index > 0)
|
|
110
|
+
parts.push(rest.slice(0, m.index));
|
|
111
|
+
const inner = wireRefToTf(byName.get(m[1]), ctx);
|
|
112
|
+
if ("unsupported" in inner)
|
|
113
|
+
return inner;
|
|
114
|
+
if (isTfExpr(inner.value))
|
|
115
|
+
parts.push(inner.value);
|
|
116
|
+
else
|
|
117
|
+
parts.push(String(inner.value));
|
|
118
|
+
rest = rest.slice(m.index + m[0].length);
|
|
119
|
+
}
|
|
120
|
+
if (rest !== "")
|
|
121
|
+
parts.push(rest);
|
|
122
|
+
return { value: { $expr: "template", parts } };
|
|
123
|
+
}
|
|
124
|
+
return { unsupported: `unsupported reference kind: ${Object.keys(r).join(", ")}` };
|
|
125
|
+
}
|
|
126
|
+
/** Index the stamped variable ids in a finalized payload: id → {taskRefKey, varName}. */
|
|
127
|
+
export function indexVariableIds(tasks) {
|
|
128
|
+
const index = new Map();
|
|
129
|
+
for (const t of tasks) {
|
|
130
|
+
const variable = t.task?.["variable"];
|
|
131
|
+
for (const c of variable?.create ?? []) {
|
|
132
|
+
if (typeof c?.id === "string" && typeof c?.name === "string" && typeof t.refKey === "string") {
|
|
133
|
+
index.set(c.id, { taskRefKey: t.refKey, varName: c.name });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return index;
|
|
138
|
+
}
|
|
139
|
+
function refKeyFromLabel(label, autoLabel) {
|
|
140
|
+
return label.startsWith(`${autoLabel}_`) ? label.slice(autoLabel.length + 1) : label;
|
|
141
|
+
}
|
|
142
|
+
/** tf attribute value → printer AST node (inverse of wireRefToTf). */
|
|
143
|
+
export function tfRefToAst(value, ctx) {
|
|
144
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
145
|
+
// A raw JSON envelope means ei fell back past refs syntax (unresolvable
|
|
146
|
+
// ref at export time) — report rather than round-trip platform ids.
|
|
147
|
+
if (typeof value === "string" && value.startsWith('{"')) {
|
|
148
|
+
return { unsupported: "ei exported a raw JSON value reference (refs-syntax fallback); not round-tripped" };
|
|
149
|
+
}
|
|
150
|
+
return { ast: value };
|
|
151
|
+
}
|
|
152
|
+
if (!isTfExpr(value))
|
|
153
|
+
return { unsupported: `unrecognized tf value ${JSON.stringify(value)}` };
|
|
154
|
+
if (value.$expr === "template") {
|
|
155
|
+
const parts = [];
|
|
156
|
+
for (const part of value.parts) {
|
|
157
|
+
if (typeof part === "string") {
|
|
158
|
+
parts.push(part);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const inner = tfRefToAst(part, ctx);
|
|
162
|
+
if ("unsupported" in inner)
|
|
163
|
+
return inner;
|
|
164
|
+
if (typeof inner.ast === "object")
|
|
165
|
+
parts.push(inner.ast);
|
|
166
|
+
else
|
|
167
|
+
parts.push(String(inner.ast));
|
|
168
|
+
}
|
|
169
|
+
return { ast: { kind: "template", parts } };
|
|
170
|
+
}
|
|
171
|
+
if (value.$expr === "resource-attr" && value.path.length === 2 && value.path[0] === "refs") {
|
|
172
|
+
const seg = value.path[1];
|
|
173
|
+
const key = typeof seg === "object" ? seg.index : String(seg);
|
|
174
|
+
const type = value.type;
|
|
175
|
+
if (ctx.isTriggerType(type)) {
|
|
176
|
+
// The refs key IS the declared parameter name — print it verbatim; the
|
|
177
|
+
// printer emits bracket access when it isn't identifier-safe.
|
|
178
|
+
return { ast: { kind: "triggerRef", path: [key] } };
|
|
179
|
+
}
|
|
180
|
+
const refKeyOf = (label) => ctx.refKeyByLabel.get(label) ?? refKeyFromLabel(label, ctx.autoLabel);
|
|
181
|
+
if (type === VARIABLE_TASK_TYPE) {
|
|
182
|
+
return {
|
|
183
|
+
ast: { kind: "variableParamRef", varTask: refKeyOf(value.label), name: key },
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (AUTOMATION_SUB_TYPE_BY_RESOURCE.has(type)) {
|
|
187
|
+
const path = key === "Result" ? ["result"] : key.split(".");
|
|
188
|
+
return { ast: { kind: "taskRef", task: refKeyOf(value.label), path } };
|
|
189
|
+
}
|
|
190
|
+
return { unsupported: `refs expression on unrecognized resource type ${type}` };
|
|
191
|
+
}
|
|
192
|
+
return { unsupported: `unsupported tf expression ${JSON.stringify(value).slice(0, 120)}` };
|
|
193
|
+
}
|
|
@@ -78,7 +78,7 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
|
|
|
78
78
|
}
|
|
79
79
|
return [{ ...style, type: "records", target,
|
|
80
80
|
...(aspect["filter"] !== undefined && {
|
|
81
|
-
filter: filterFromTf(filterWireToTf(decodeJson(aspect["filter"])), { ...owner, ownerRefName: owner.ownerRefName ?? owner.ownerTfLabel }, `${where}.aspect_widget.filter`),
|
|
81
|
+
filter: filterFromTf(filterWireToTf(decodeJson(aspect["filter"])), { ...owner, ownerRefName: owner.ownerRefName ?? owner.ownerTfLabel, foreignFieldRefsById: ctx.foreignFieldRefsById }, `${where}.aspect_widget.filter`),
|
|
82
82
|
}),
|
|
83
83
|
}];
|
|
84
84
|
});
|
|
@@ -22,5 +22,6 @@ export interface DynamicLayoutToTfOptions {
|
|
|
22
22
|
readonly diagnostics: string[];
|
|
23
23
|
readonly orgRefs: OrgRefLookup;
|
|
24
24
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
25
|
+
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
25
26
|
}
|
|
26
27
|
export declare function dynamicLayoutsToTf(layouts: Readonly<Record<string, DynamicLayoutWire>> | undefined, opts: DynamicLayoutToTfOptions): TfBlock[];
|
|
@@ -198,7 +198,7 @@ function resolveField(value, where, opts) {
|
|
|
198
198
|
opts.diagnostics.push(`${where}: field "${refName}" targets a different app; dropped`);
|
|
199
199
|
return undefined;
|
|
200
200
|
}
|
|
201
|
-
const resolved = fieldRefToTfValue(token?.fieldType ?? "", refName, opts.ownerTfLabel, "app");
|
|
201
|
+
const resolved = fieldRefToTfValue(token?.fieldType ?? "", refName, opts.ownerTfLabel, "app", opts.fieldAddresses);
|
|
202
202
|
if (resolved === undefined)
|
|
203
203
|
opts.diagnostics.push(`${where}: field "${refName}" has no Terraform mapping; dropped`);
|
|
204
204
|
return resolved;
|
|
@@ -37,8 +37,8 @@ export interface ElementCloudConnection {
|
|
|
37
37
|
readonly idColumnName?: string;
|
|
38
38
|
}
|
|
39
39
|
export interface ElementV2Options<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> extends EntityDeployOptions {
|
|
40
|
-
/**
|
|
41
|
-
readonly handle
|
|
40
|
+
/** Required platform handle (business acronym, e.g. "PRD") — distinct from the refName. */
|
|
41
|
+
readonly handle: string;
|
|
42
42
|
readonly name: string;
|
|
43
43
|
readonly category: AppCategory;
|
|
44
44
|
readonly namespace?: string;
|
|
@@ -71,13 +71,32 @@ export interface ElementV2Options<F extends Record<string, AppField> = Record<st
|
|
|
71
71
|
* handle, but are **never included in the deploy payload** (the platform owns them).
|
|
72
72
|
*/
|
|
73
73
|
readonly readonlyFields?: R;
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Record-view (LAYOUT surface) display blocks. `field`/`group` blocks map
|
|
76
|
+
* to an `elementum_layout` group section on the element's Initiate stage;
|
|
77
|
+
* `widget`/`comments` blocks and groups nested inside a group have no
|
|
78
|
+
* terraform layout equivalent and are diagnosed and dropped individually.
|
|
79
|
+
* Mutually exclusive with `layouts` — author one or the other, not both.
|
|
80
|
+
*/
|
|
75
81
|
readonly displayBlocks?: readonly DisplayBlock[];
|
|
76
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* New-record form (CREATE surface) display blocks. `field`/`group` blocks
|
|
84
|
+
* map to `elementum_record_create_form` sections; `widget`/`comments`
|
|
85
|
+
* blocks and groups nested inside a group have no terraform equivalent and
|
|
86
|
+
* are diagnosed and dropped individually. Mutually exclusive with
|
|
87
|
+
* `recordCreateForm` — both target the same new-record form; author one or
|
|
88
|
+
* the other, not both.
|
|
89
|
+
*/
|
|
77
90
|
readonly recordCreateDisplayBlocks?: readonly DisplayBlock[];
|
|
78
91
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
92
|
+
* The element's record-detail layout (terraform-path). Unlike apps,
|
|
93
|
+
* elements carry no stages at all — there is exactly one implicit layout
|
|
94
|
+
* (the platform's Initiate stage), so `stage_id` is always omitted on
|
|
95
|
+
* build (letting the provider auto-resolve it). Key this bag `layout` —
|
|
96
|
+
* the pull path (and the `displayBlocks` → `layouts` mapping) always uses
|
|
97
|
+
* that key too, matching the bridge's fixed `<ns>_layout` resource label;
|
|
98
|
+
* a different key still builds correctly but won't resolve to the same
|
|
99
|
+
* terraform address on a re-pull.
|
|
81
100
|
*/
|
|
82
101
|
readonly layouts?: Readonly<Record<string, AppLayout>>;
|
|
83
102
|
/** Saved list views, keyed by view ref name. */
|
|
@@ -89,7 +108,11 @@ export interface ElementV2Options<F extends Record<string, AppField> = Record<st
|
|
|
89
108
|
readonly dashboards?: Readonly<Record<string, AppDashboard>>;
|
|
90
109
|
readonly widgets?: Readonly<Record<string, AppWidget>>;
|
|
91
110
|
readonly dashboardViews?: Readonly<Record<string, AppDashboardView>>;
|
|
92
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Typed new-record form (`elementum_record_create_form`). Mutually
|
|
113
|
+
* exclusive with `recordCreateDisplayBlocks` — author one or the other,
|
|
114
|
+
* not both.
|
|
115
|
+
*/
|
|
93
116
|
readonly recordCreateForm?: AppRecordCreateForm;
|
|
94
117
|
readonly relationships?: Readonly<Record<string, AppRelationship>>;
|
|
95
118
|
/** Display order of `listViews` (by key). Defaults to declaration order. */
|
|
@@ -8,13 +8,16 @@ export const ELEMENT_SYSTEM_FIELD_KEYS = ["id", "title"];
|
|
|
8
8
|
* element validation rules, so a malformed definition fails at define time
|
|
9
9
|
* rather than as an opaque platform error during apply.
|
|
10
10
|
*
|
|
11
|
-
* - `handle` — letters only (A–Z or a–z)
|
|
11
|
+
* - `handle` — required and letters only (A–Z or a–z).
|
|
12
12
|
* Existing elements can carry a lowercase handle (the platform doesn't
|
|
13
13
|
* enforce case), so this only rejects non-letters, not case.
|
|
14
14
|
* - `namespace` — lowercase letters only (a–z), when provided
|
|
15
15
|
*/
|
|
16
16
|
function validateElementOptions(opts) {
|
|
17
|
-
if (opts.handle
|
|
17
|
+
if (!opts.handle) {
|
|
18
|
+
throw new Error(`element "${opts.name}": handle is required by the platform.`);
|
|
19
|
+
}
|
|
20
|
+
if (!/^[A-Za-z]+$/.test(opts.handle)) {
|
|
18
21
|
throw new Error(`element "${opts.name}": handle "${opts.handle}" must be letters only (A–Z or a–z).`);
|
|
19
22
|
}
|
|
20
23
|
if (opts.namespace !== undefined && !/^[a-z]+$/.test(opts.namespace)) {
|
|
@@ -60,7 +63,8 @@ export function element(opts) {
|
|
|
60
63
|
parent: refName,
|
|
61
64
|
parentKind: "element",
|
|
62
65
|
parentName: opts.name,
|
|
63
|
-
fieldType: field.type,
|
|
66
|
+
fieldType: field.expression !== undefined ? "CALCULATED" : field.type,
|
|
67
|
+
...("dynamicSource" in field && field.dynamicSource === true ? { dynamicSource: true } : {}),
|
|
64
68
|
...(field.options !== undefined ? { options: picklistOptionLabels(field.options) } : {}),
|
|
65
69
|
...(field.tags !== undefined ? { tags: field.tags } : {}),
|
|
66
70
|
};
|
|
@@ -82,12 +82,12 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
82
82
|
const hybridTable = optionalBoolean(attrs, "snowflake_hybrid_table", `element "${label}"`, ctx);
|
|
83
83
|
const titleColumnName = optionalString(attrs, "title_column_name", `element "${label}"`, ctx);
|
|
84
84
|
const idColumnName = optionalString(attrs, "id_column_name", `element "${label}"`, ctx);
|
|
85
|
-
const
|
|
85
|
+
const hasCloudMapping = snowDb !== undefined ||
|
|
86
86
|
snowSchema !== undefined ||
|
|
87
87
|
snowTable !== undefined ||
|
|
88
|
-
hybridTable !== undefined ||
|
|
89
88
|
titleColumnName !== undefined ||
|
|
90
|
-
idColumnName !== undefined
|
|
89
|
+
idColumnName !== undefined;
|
|
90
|
+
const cloudConnection = hasCloudMapping
|
|
91
91
|
? {
|
|
92
92
|
kind: "snowflake",
|
|
93
93
|
...(snowDb !== undefined && { database: snowDb }),
|
|
@@ -98,6 +98,9 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
98
98
|
...(idColumnName !== undefined && { idColumnName }),
|
|
99
99
|
}
|
|
100
100
|
: undefined;
|
|
101
|
+
const cloudOptions = !hasCloudMapping && hybridTable !== undefined
|
|
102
|
+
? { snowflake: { hybridTable } }
|
|
103
|
+
: undefined;
|
|
101
104
|
let category;
|
|
102
105
|
if (attrs["category_id"] !== undefined) {
|
|
103
106
|
const dataLabel = dataRefLabel(attrs["category_id"], "elementum_category");
|
|
@@ -176,6 +179,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
176
179
|
fields,
|
|
177
180
|
stages: [],
|
|
178
181
|
...(cloudLinkId !== undefined && { cloudLinkId }),
|
|
182
|
+
...(cloudOptions !== undefined && { cloudOptions }),
|
|
179
183
|
...(cloudConnection !== undefined && { cloudConnection }),
|
|
180
184
|
...(commentsEnabled !== undefined && { commentsEnabled }),
|
|
181
185
|
...(layouts.length > 0 && { layouts }),
|
|
@@ -9,9 +9,10 @@ export { element, type ElementCloudConnection, type ElementConfigured, type Elem
|
|
|
9
9
|
export { type AppRecordCreateForm, type AppRecordCreateFormSection } from "../app/build.js";
|
|
10
10
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, type ListViewDensity, type ManagedViewSort, type ManagedViewSortAggregation, type ManagedViewSortDirection, type ManagedViewSortField, type ManagedViewSortOrder, } from "../view/build.js";
|
|
11
11
|
export { type AppRelationship, type AppRelationshipColumn } from "../relationship/build.js";
|
|
12
|
-
export { dashboardRecordsWidget, dashboardWidgetSize, type DashboardRecordsWidget, type DashboardWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
|
|
13
|
-
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, groupField, jsonField,
|
|
12
|
+
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, type DashboardChartWidget, type DashboardRecordsWidget, type DashboardWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
|
|
13
|
+
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";
|
|
14
14
|
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";
|
|
15
|
+
export { asc, desc, sortBy, type SortDirection, type SortOrder } from "../shared/types/common.js";
|
|
15
16
|
export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyOptions, type AccessPolicyPrincipalRef, type AccessPolicyUserRef, type GroupId, type UserId } from "../access-policy/build.js";
|
|
16
17
|
export { roleAutoShare, rolePermissionGroup, rolePermissionLevel, userRef, type AppRole, type RoleAutoShare, type RoleGroupRef, type RolePermission, type RolePermissionGroup, type RolePermissionLevel, type RoleUserRef } from "../role/build.js";
|
|
17
18
|
export { serviceAccountRef, type ServiceAccountRef } from "../service-account/ref.js";
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { element, } from "./build.js";
|
|
9
9
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, } from "../view/build.js";
|
|
10
|
-
export { dashboardRecordsWidget, dashboardWidgetSize, } from "../dashboard/build.js";
|
|
11
|
-
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, groupField, jsonField,
|
|
10
|
+
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, } from "../dashboard/build.js";
|
|
11
|
+
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, } from "../field/build.js";
|
|
12
12
|
export { calc, dateDifUnit, dateTimeTruncPrecision, field, orderByDirection, predicateOp, weekdayMode, } from "../field/calc.js";
|
|
13
|
+
export { asc, desc, sortBy } from "../shared/types/common.js";
|
|
13
14
|
export { groupId, userId } from "../access-policy/build.js";
|
|
14
15
|
export { roleAutoShare, rolePermissionGroup, rolePermissionLevel, userRef } from "../role/build.js";
|
|
15
16
|
export { serviceAccountRef } from "../service-account/ref.js";
|
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
import { EntityTfError } from "../../engine/entity.js";
|
|
7
7
|
import { expr, snakeSlug } from "../../engine/tf/index.js";
|
|
8
8
|
import { accessPolicyToTf } from "../access-policy/to-tf.js";
|
|
9
|
+
import { displayBlocksToLayoutSections } from "../app/display-blocks-to-layout.js";
|
|
10
|
+
import { displayBlocksToRecordCreateFormSections } from "../app/display-blocks-to-record-create-form.js";
|
|
9
11
|
import { dashboardsToTf } from "../dashboard/to-tf.js";
|
|
10
12
|
import { fieldToTf } from "../field/to-tf.js";
|
|
11
13
|
import { CATEGORY_ORG_BAG } from "../org/category.js";
|
|
14
|
+
import { categoryIdExpr, missingCategoryDiagnostic } from "../org/category-ref.js";
|
|
12
15
|
import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
|
|
13
16
|
import { recordCreateFormToTf } from "../record-create-form/to-tf.js";
|
|
14
17
|
import { relationshipsToTf } from "../relationship/to-tf.js";
|
|
@@ -55,6 +58,12 @@ export function elementToTf(entity, ctx) {
|
|
|
55
58
|
elementAttrs["icon"] = payload.icon;
|
|
56
59
|
if (payload.color !== undefined)
|
|
57
60
|
elementAttrs["color"] = payload.color;
|
|
61
|
+
const hybridTable = payload.cloudOptions?.snowflake?.hybridTable;
|
|
62
|
+
if (payload.cloudOptions !== undefined && payload.cloudConnection !== undefined) {
|
|
63
|
+
throw new EntityTfError(`element "${entity.refName}": cloudOptions and cloudConnection are mutually exclusive`);
|
|
64
|
+
}
|
|
65
|
+
if (hybridTable !== undefined)
|
|
66
|
+
elementAttrs["snowflake_hybrid_table"] = hybridTable;
|
|
58
67
|
// A LINKED element's Snowflake table mapping — create-only (the table
|
|
59
68
|
// binding is immutable once set), but sent every build so a rebuild
|
|
60
69
|
// doesn't null it out on an in-place update.
|
|
@@ -77,10 +86,10 @@ export function elementToTf(entity, ctx) {
|
|
|
77
86
|
if (categoryName !== undefined && categoryName !== "") {
|
|
78
87
|
const category = ctx.orgRefs.byName(CATEGORY_ORG_BAG, categoryName);
|
|
79
88
|
if (category === undefined) {
|
|
80
|
-
ctx.diagnostics.push(
|
|
89
|
+
ctx.diagnostics.push(missingCategoryDiagnostic(categoryName));
|
|
81
90
|
}
|
|
82
91
|
else {
|
|
83
|
-
elementAttrs["category_id"] =
|
|
92
|
+
elementAttrs["category_id"] = categoryIdExpr(category);
|
|
84
93
|
}
|
|
85
94
|
}
|
|
86
95
|
const cloudLink = payload.cloudLinkId;
|
|
@@ -94,11 +103,24 @@ export function elementToTf(entity, ctx) {
|
|
|
94
103
|
elementAttrs["cloud_link_id"] = expr.dataAttr("elementum_cloudlink", resolved.tfLabel, ["id"]);
|
|
95
104
|
}
|
|
96
105
|
}
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
// displayBlocks (LAYOUT surface) → elementum_layout. recordCreateDisplayBlocks
|
|
107
|
+
// (CREATE surface) → elementum_record_create_form. Both mapped below, same
|
|
108
|
+
// mutual-exclusivity precedent: a surface has exactly one terraform target,
|
|
109
|
+
// authored either through the typed builder or through display blocks, not
|
|
110
|
+
// both.
|
|
111
|
+
if (payload.layouts !== undefined && payload.displayBlocks !== undefined) {
|
|
112
|
+
throw new EntityTfError(`element "${entity.refName}": both "layouts" and "displayBlocks" are authored — they both target the record-detail layout; author only one`);
|
|
113
|
+
}
|
|
114
|
+
if (payload.recordCreateForm !== undefined && payload.recordCreateDisplayBlocks !== undefined) {
|
|
115
|
+
throw new EntityTfError(`element "${entity.refName}": both "recordCreateForm" and "recordCreateDisplayBlocks" are authored — they both target the new-record form; author only one`);
|
|
116
|
+
}
|
|
117
|
+
let mappedLayoutSections;
|
|
118
|
+
if (payload.displayBlocks !== undefined) {
|
|
119
|
+
mappedLayoutSections = displayBlocksToLayoutSections(payload.displayBlocks, `element "${entity.refName}" displayBlocks`, ctx.diagnostics);
|
|
99
120
|
}
|
|
100
|
-
|
|
101
|
-
|
|
121
|
+
let mappedRecordCreateFormSections;
|
|
122
|
+
if (payload.recordCreateDisplayBlocks !== undefined) {
|
|
123
|
+
mappedRecordCreateFormSections = displayBlocksToRecordCreateFormSections(payload.recordCreateDisplayBlocks, `element "${entity.refName}" recordCreateDisplayBlocks`, ctx.diagnostics);
|
|
102
124
|
}
|
|
103
125
|
const blocks = [];
|
|
104
126
|
const fieldAddresses = new Map();
|
|
@@ -172,8 +194,20 @@ export function elementToTf(entity, ctx) {
|
|
|
172
194
|
orgRefs: ctx.orgRefs,
|
|
173
195
|
workspaceAspects: ctx.workspaceAspects,
|
|
174
196
|
diagnostics: ctx.diagnostics,
|
|
197
|
+
fieldAddresses,
|
|
175
198
|
}));
|
|
176
|
-
|
|
199
|
+
// An element has exactly one implicit layout (the platform's Initiate
|
|
200
|
+
// stage — see layoutToTf's element-scope stage_id omission) — "layout" is
|
|
201
|
+
// a synthetic bag key here, not a real stage reference. It must match the
|
|
202
|
+
// bridge's own fixed "<prefix>_layout" resource-label convention
|
|
203
|
+
// (cmd/elementum/export/hcl_app.go's generateLayoutIR) and view/from-tf.ts's
|
|
204
|
+
// matching pull-side fallback, so a pull → rebuild round-trip resolves to
|
|
205
|
+
// the same terraform address instead of planning a destroy+recreate.
|
|
206
|
+
const layoutsForViewToTf = payload.layouts ??
|
|
207
|
+
(mappedLayoutSections !== undefined && mappedLayoutSections.length > 0
|
|
208
|
+
? { layout: { sections: mappedLayoutSections } }
|
|
209
|
+
: undefined);
|
|
210
|
+
const { blocks: viewBlocks } = viewToTf(layoutsForViewToTf, payload.listViews, payload.calendarViews, payload.kanbanViews, payload.dashboardViews, undefined, payload.viewOrder, {
|
|
177
211
|
ownerRefName: ctx.appRefName,
|
|
178
212
|
ownerTfLabel: ctx.appTfLabel,
|
|
179
213
|
scope: "element",
|
|
@@ -182,14 +216,20 @@ export function elementToTf(entity, ctx) {
|
|
|
182
216
|
dashboardKeys: new Set(Object.keys(payload.dashboards ?? {})),
|
|
183
217
|
orgRefs: ctx.orgRefs,
|
|
184
218
|
diagnostics: ctx.diagnostics,
|
|
219
|
+
fieldAddresses,
|
|
185
220
|
});
|
|
186
221
|
blocks.push(...viewBlocks);
|
|
187
|
-
const
|
|
222
|
+
const recordCreateFormForToTf = payload.recordCreateForm ??
|
|
223
|
+
(mappedRecordCreateFormSections !== undefined && mappedRecordCreateFormSections.length > 0
|
|
224
|
+
? { sections: mappedRecordCreateFormSections }
|
|
225
|
+
: undefined);
|
|
226
|
+
const recordCreateForm = recordCreateFormToTf(recordCreateFormForToTf, {
|
|
188
227
|
ownerRefName: ctx.appRefName,
|
|
189
228
|
ownerTfLabel: ctx.appTfLabel,
|
|
190
229
|
scope: "element",
|
|
191
230
|
objectId,
|
|
192
231
|
diagnostics: ctx.diagnostics,
|
|
232
|
+
fieldAddresses,
|
|
193
233
|
});
|
|
194
234
|
if (recordCreateForm !== undefined)
|
|
195
235
|
blocks.push(recordCreateForm);
|
|
@@ -213,6 +253,7 @@ export function elementToTf(entity, ctx) {
|
|
|
213
253
|
objectId,
|
|
214
254
|
orgRefs: ctx.orgRefs,
|
|
215
255
|
diagnostics: ctx.diagnostics,
|
|
256
|
+
fieldAddresses,
|
|
216
257
|
});
|
|
217
258
|
blocks.push(block);
|
|
218
259
|
}
|