@elementumai/edk 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -5
- package/dist-sdk/src/catalog/factories.d.ts +35 -14
- package/dist-sdk/src/catalog/factories.js +64 -13
- package/dist-sdk/src/catalog/from-authoring.js +4 -4
- package/dist-sdk/src/catalog/index.d.ts +1 -1
- package/dist-sdk/src/catalog/org.js +3 -2
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +13 -3
- package/dist-sdk/src/core/triggers/on-demand.d.ts +4 -28
- package/dist-sdk/src/core/triggers/on-demand.js +2 -4
- package/dist-sdk/src/engine/entity.d.ts +2 -0
- package/dist-sdk/src/engine/logging.d.ts +90 -0
- package/dist-sdk/src/engine/logging.js +124 -0
- package/dist-sdk/src/engine/progress.d.ts +119 -0
- package/dist-sdk/src/engine/progress.js +647 -0
- package/dist-sdk/src/engine/pull/result-output.d.ts +24 -0
- package/dist-sdk/src/engine/pull/result-output.js +48 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +8 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -4
- package/dist-sdk/src/entities/app/to-tf.js +9 -13
- package/dist-sdk/src/entities/automation/build.d.ts +11 -16
- package/dist-sdk/src/entities/automation/build.js +38 -8
- package/dist-sdk/src/entities/automation/catalog-render.js +1 -1
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +1 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +23 -5
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +239 -34
- package/dist-sdk/src/entities/automation/from-tf.js +168 -23
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/module.js +2 -2
- package/dist-sdk/src/entities/automation/output-field-types.js +25 -13
- package/dist-sdk/src/entities/automation/script-code.d.ts +12 -4
- package/dist-sdk/src/entities/automation/script-code.js +659 -101
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -28
- package/dist-sdk/src/entities/automation/tasks.js +31 -15
- package/dist-sdk/src/entities/automation/to-tf.js +362 -58
- package/dist-sdk/src/entities/automation/triggers.d.ts +15 -9
- package/dist-sdk/src/entities/automation/triggers.js +4 -2
- package/dist-sdk/src/entities/chart/build.d.ts +15 -3
- package/dist-sdk/src/entities/chart/build.js +6 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/chart/from-tf.js +71 -8
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/index.js +1 -1
- package/dist-sdk/src/entities/chart/printer.js +27 -7
- package/dist-sdk/src/entities/chart/to-tf.js +56 -2
- package/dist-sdk/src/entities/datamine/from-tf.js +11 -1
- package/dist-sdk/src/entities/element/build.d.ts +6 -5
- package/dist-sdk/src/entities/element/from-tf.js +3 -2
- package/dist-sdk/src/entities/element/module.js +1 -0
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/element/to-tf.js +9 -1
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +73 -1
- package/dist-sdk/src/entities/field/metadata.d.ts +18 -0
- package/dist-sdk/src/entities/field/metadata.js +34 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +17 -6
- package/dist-sdk/src/entities/relationship/column-contract.d.ts +24 -0
- package/dist-sdk/src/entities/relationship/column-contract.js +41 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +19 -34
- package/dist-sdk/src/entities/relationship/to-tf.js +15 -2
- package/dist-sdk/src/entities/shared/context.d.ts +6 -3
- package/dist-sdk/src/entities/shared/context.js +19 -1
- package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
- package/dist-sdk/src/entities/shared/filters/index.js +28 -0
- package/dist-sdk/src/entities/shared/filters/print.js +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +8 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +10 -6
- package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -23
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +17 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +38 -12
- package/dist-sdk/src/entities/skill/tools.js +2 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +8 -12
- package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -44
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +45 -7
- package/dist-sdk/src/entities/table/build.js +10 -2
- package/dist-sdk/src/entities/view/to-tf.js +5 -7
- package/dist-sdk/src/entities/widget/build.d.ts +26 -0
- package/dist-sdk/src/entities/widget/from-tf.js +30 -5
- package/dist-sdk/src/entities/widget/to-tf.js +111 -7
- package/dist-sdk/src/graph/types.d.ts +5 -0
- package/package.json +1 -1
- package/dist-sdk/src/core/types/platform.d.ts +0 -2
- package/dist-sdk/src/core/types/platform.js +0 -1
|
@@ -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
|
|
14
|
+
import { type InferTriggerType, 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,7 @@ 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
|
|
74
|
+
export declare function onDemand<S extends TriggerInputSchemaSpec>(schema: S): TriggerChain<InferTriggerType<NormalizeSpec<S> & TriggerInputSchema>>;
|
|
75
75
|
export interface WebhookTriggerOptions {
|
|
76
76
|
readonly authenticated?: boolean;
|
|
77
77
|
/** Pre-built wire custom-response envelope. */
|
|
@@ -148,8 +148,11 @@ export interface DataMineTriggerOptions {
|
|
|
148
148
|
readonly fireOnAlert?: boolean;
|
|
149
149
|
readonly fireOnRecovery?: boolean;
|
|
150
150
|
}
|
|
151
|
+
export interface DataMineTriggerOutput {
|
|
152
|
+
readonly record: Record<string, unknown>;
|
|
153
|
+
}
|
|
151
154
|
/** Fires when a data mine meets/no longer meets requirements. */
|
|
152
|
-
export declare function dataMine(opts: DataMineTriggerOptions): TriggerChain<
|
|
155
|
+
export declare function dataMine(opts: DataMineTriggerOptions): TriggerChain<DataMineTriggerOutput>;
|
|
153
156
|
export interface EmailReceivedTriggerOptions {
|
|
154
157
|
readonly emailAliasId: string;
|
|
155
158
|
}
|
|
@@ -179,17 +182,20 @@ export interface CommentAddedTriggerOutput<A extends AppOrElementRef = AppOrElem
|
|
|
179
182
|
}
|
|
180
183
|
/** Fires when a comment is added to a record on the given aspect. */
|
|
181
184
|
export declare function commentAdded<A extends AppOrElementRef>(opts: CommentAddedTriggerOptions<A>): TriggerChain<CommentAddedTriggerOutput<A>>;
|
|
182
|
-
export type ConversationEndConversationType = "A2A" | "VOICE" | "EMAIL" | "SLACK" | "TEAMS";
|
|
183
|
-
export interface ConversationEndTriggerOptions {
|
|
184
|
-
readonly app:
|
|
185
|
+
export type ConversationEndConversationType = "A2A" | "ELEMENTUM_UI" | "VOICE" | "EMAIL" | "SLACK" | "TEAMS";
|
|
186
|
+
export interface ConversationEndTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
|
|
187
|
+
readonly app: A;
|
|
185
188
|
readonly conversationType: ConversationEndConversationType;
|
|
189
|
+
readonly filter?: Filter;
|
|
186
190
|
}
|
|
187
|
-
export interface ConversationEndTriggerOutput {
|
|
188
|
-
readonly record:
|
|
191
|
+
export interface ConversationEndTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
|
|
192
|
+
readonly record: RecordShape<A>;
|
|
189
193
|
readonly transcript: string;
|
|
194
|
+
/** True when the conversation ended due to timeout. */
|
|
195
|
+
readonly timeoutReached?: boolean;
|
|
190
196
|
}
|
|
191
197
|
/** Fires when a conversation of the selected type ends on the given aspect. */
|
|
192
|
-
export declare function conversationEnd(opts: ConversationEndTriggerOptions): TriggerChain<ConversationEndTriggerOutput
|
|
198
|
+
export declare function conversationEnd<A extends AppOrElementRef>(opts: ConversationEndTriggerOptions<A>): TriggerChain<ConversationEndTriggerOutput<A>>;
|
|
193
199
|
export interface SlackMessageTriggerOutput {
|
|
194
200
|
/** Slack thread id when the inbound message is part of a thread. */
|
|
195
201
|
readonly threadId: string;
|
|
@@ -64,10 +64,10 @@ export function schedule(opts) {
|
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
export function onDemand(schema
|
|
67
|
+
export function onDemand(schema) {
|
|
68
68
|
const normalized = Object.fromEntries(Object.entries(schema).map(([k, v]) => [k, typeof v === "string" ? { type: v } : v]));
|
|
69
69
|
return chainableTrigger({
|
|
70
|
-
wire: serializeOnDemandTrigger(normalized
|
|
70
|
+
wire: serializeOnDemandTrigger(normalized),
|
|
71
71
|
__params: Object.entries(normalized).map(([name, def]) => ({ name, required: def.required ?? false })),
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -180,8 +180,10 @@ export function conversationEnd(opts) {
|
|
|
180
180
|
aspectId: opts.app,
|
|
181
181
|
conversationType: opts.conversationType,
|
|
182
182
|
type: "CONVERSATION_END",
|
|
183
|
+
...(opts.filter !== undefined ? { filter: opts.filter } : {}),
|
|
183
184
|
},
|
|
184
185
|
},
|
|
186
|
+
__recordApp: opts.app.refName,
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
189
|
/** Fires when a Slack message is received. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AppCatalogRef, type AppOrElementRef, type ChartRef, type FieldRef, type TableColumnRef, type TableRef } from "../../catalog/index.js";
|
|
2
2
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
3
|
import type { Filter } from "../shared/filters/types.js";
|
|
4
|
+
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
4
5
|
import type { ChartAggregation, ChartColumnValueType, ChartJoinType, ChartType } from "./types.js";
|
|
5
6
|
export { chartAggregation, chartColumnValueType, chartJoinType, chartType, type ChartAggregation, type ChartColumnValueType, type ChartJoinType, type ChartType, } from "./types.js";
|
|
6
7
|
export type ChartDatasourceRef = AppOrElementRef | TableRef;
|
|
@@ -14,6 +15,16 @@ export type ChartFieldFor<Datasource> = Datasource extends {
|
|
|
14
15
|
interface ChartColumnBase {
|
|
15
16
|
readonly name?: string;
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Pull-only escape hatch for UI charts backed by a synthetic query datasource.
|
|
20
|
+
* The platform owns this shape; new charts should use typed subscriptions.
|
|
21
|
+
*/
|
|
22
|
+
export interface ChartOpaqueSubscription {
|
|
23
|
+
readonly kind: "opaque";
|
|
24
|
+
readonly datasourceId: UnsafePlatformId;
|
|
25
|
+
readonly attributes: Readonly<Record<string, unknown>>;
|
|
26
|
+
}
|
|
27
|
+
export declare function __pulledChartSubscription(opts: Omit<ChartOpaqueSubscription, "kind">): ChartOpaqueSubscription;
|
|
17
28
|
export type ChartColumn<Datasource extends ChartDatasourceRef = ChartDatasourceRef> = (ChartColumnBase & {
|
|
18
29
|
readonly field?: ChartFieldFor<Datasource>;
|
|
19
30
|
readonly aggregation: ChartAggregation;
|
|
@@ -27,9 +38,9 @@ export type ChartColumn<Datasource extends ChartDatasourceRef = ChartDatasourceR
|
|
|
27
38
|
readonly aggregation?: never;
|
|
28
39
|
readonly expression?: never;
|
|
29
40
|
});
|
|
30
|
-
export
|
|
41
|
+
export type ChartGroupBy<Datasource extends ChartDatasourceRef = ChartDatasourceRef> = {
|
|
31
42
|
readonly field: ChartFieldFor<Datasource>;
|
|
32
|
-
}
|
|
43
|
+
};
|
|
33
44
|
declare const chartJoinBrand: unique symbol;
|
|
34
45
|
export interface ChartJoin<From extends ChartDatasourceRef = ChartDatasourceRef, To extends ChartDatasourceRef = ChartDatasourceRef> {
|
|
35
46
|
readonly [chartJoinBrand]: {
|
|
@@ -64,6 +75,7 @@ export interface ChartSubscription<Datasource extends ChartDatasourceRef = Chart
|
|
|
64
75
|
readonly limit?: string;
|
|
65
76
|
readonly tags?: readonly string[];
|
|
66
77
|
}
|
|
78
|
+
export type ChartSubscriptionInput = ChartSubscription | ChartOpaqueSubscription;
|
|
67
79
|
/** Build a chart subscription while preserving datasource/field ownership. */
|
|
68
80
|
export declare function chartSubscription<const Datasource extends ChartDatasourceRef>(opts: Omit<ChartSubscription<Datasource>, typeof chartSubscriptionBrand | "columns" | "groupBy" | "joins"> & {
|
|
69
81
|
readonly columns: readonly ChartColumn<NoInfer<Datasource>>[];
|
|
@@ -85,7 +97,7 @@ export interface DefineChartOptions<AppRefName extends string = string> extends
|
|
|
85
97
|
readonly type: ChartType;
|
|
86
98
|
readonly target?: number;
|
|
87
99
|
readonly properties?: ChartProperties;
|
|
88
|
-
readonly subscriptions: readonly
|
|
100
|
+
readonly subscriptions: readonly ChartSubscriptionInput[];
|
|
89
101
|
}
|
|
90
102
|
export interface ChartConfigured<AppRefName extends string = string> {
|
|
91
103
|
ref<const RefName extends string>(refName: RefName): ChartRef<AppRefName, RefName>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { slimTokens, } from "../../catalog/index.js";
|
|
2
2
|
export { chartAggregation, chartColumnValueType, chartJoinType, chartType, } from "./types.js";
|
|
3
|
+
export function __pulledChartSubscription(opts) {
|
|
4
|
+
return { kind: "opaque", ...opts };
|
|
5
|
+
}
|
|
3
6
|
/** Define an ownership-checked join used by a chart subscription. */
|
|
4
7
|
export function chartJoin(opts) {
|
|
5
8
|
const { from: _from, ...wire } = opts;
|
|
@@ -18,7 +21,9 @@ function validateChart(refName, opts) {
|
|
|
18
21
|
if (opts.subscriptions.length === 0)
|
|
19
22
|
fail("at least one subscription is required");
|
|
20
23
|
for (const [index, subscription] of opts.subscriptions.entries()) {
|
|
21
|
-
if (subscription.
|
|
24
|
+
if ("kind" in subscription && subscription.kind === "opaque")
|
|
25
|
+
continue;
|
|
26
|
+
if (!("columns" in subscription) || subscription.columns.length === 0)
|
|
22
27
|
fail(`subscriptions[${index}] must include at least one column`);
|
|
23
28
|
}
|
|
24
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
-
import { type TfBlock } from "../../engine/tf/index.js";
|
|
2
|
+
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
3
3
|
import type { Filter } from "../shared/filters/types.js";
|
|
4
4
|
import type { ChartProperties } from "./build.js";
|
|
5
5
|
export interface NormalizedChartDatasource {
|
|
@@ -33,6 +33,7 @@ export interface NormalizedChartJoin {
|
|
|
33
33
|
readonly type?: string;
|
|
34
34
|
}
|
|
35
35
|
export interface NormalizedChartSubscription {
|
|
36
|
+
readonly kind?: "typed";
|
|
36
37
|
readonly datasource: NormalizedChartDatasource;
|
|
37
38
|
readonly columns: readonly NormalizedChartColumn[];
|
|
38
39
|
readonly groupBy?: readonly NormalizedChartGroupBy[];
|
|
@@ -41,13 +42,18 @@ export interface NormalizedChartSubscription {
|
|
|
41
42
|
readonly limit?: string;
|
|
42
43
|
readonly tags?: readonly string[];
|
|
43
44
|
}
|
|
45
|
+
export interface NormalizedChartOpaqueSubscription {
|
|
46
|
+
readonly kind: "opaque";
|
|
47
|
+
readonly datasourceId: string;
|
|
48
|
+
readonly attributes: Readonly<Record<string, TfValue>>;
|
|
49
|
+
}
|
|
44
50
|
export interface NormalizedChart {
|
|
45
51
|
readonly refName: string;
|
|
46
52
|
readonly name: string;
|
|
47
53
|
readonly type: string;
|
|
48
54
|
readonly target?: number;
|
|
49
55
|
readonly properties?: ChartProperties;
|
|
50
|
-
readonly subscriptions: readonly NormalizedChartSubscription[];
|
|
56
|
+
readonly subscriptions: readonly (NormalizedChartSubscription | NormalizedChartOpaqueSubscription)[];
|
|
51
57
|
}
|
|
52
58
|
export declare function chartFromTf(block: TfBlock, opts: {
|
|
53
59
|
readonly appLabel: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dataRefLabel, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
2
|
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
3
3
|
import { FIELD_RESOURCE_TYPES } from "../field/types.js";
|
|
4
|
-
import {
|
|
4
|
+
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
5
|
import { filterFromTf } from "../shared/filters/tf-codec.js";
|
|
6
6
|
import { CHART_RESOURCE_TYPE } from "./types.js";
|
|
7
7
|
const APP_RESOURCE_TYPE = "elementum_app";
|
|
@@ -73,7 +73,7 @@ function indexedField(value) {
|
|
|
73
73
|
}
|
|
74
74
|
function fieldFromTf(value, datasource, ctx, where) {
|
|
75
75
|
if (value !== undefined && (datasource.kind === "app" || datasource.kind === "element")) {
|
|
76
|
-
const refName =
|
|
76
|
+
const refName = fieldKeyFromTfValue(value, datasource.refName, datasource.tfLabel, datasource.kind, ctx);
|
|
77
77
|
if (refName !== undefined)
|
|
78
78
|
return { kind: "field", parentKind: datasource.kind, parentRefName: datasource.refName, refName };
|
|
79
79
|
}
|
|
@@ -132,7 +132,62 @@ function fieldFromTf(value, datasource, ctx, where) {
|
|
|
132
132
|
function stringList(value) {
|
|
133
133
|
return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : undefined;
|
|
134
134
|
}
|
|
135
|
+
function opaqueSubscriptionFromTf(value, where, ctx) {
|
|
136
|
+
const rec = plainObject(value);
|
|
137
|
+
const datasourceId = rec?.["datasource_id"];
|
|
138
|
+
const withValue = rec?.["with"];
|
|
139
|
+
const decodedWith = withValue === undefined ? undefined : decodeJson(withValue);
|
|
140
|
+
const columns = rec?.["columns"];
|
|
141
|
+
const columnNames = Array.isArray(columns)
|
|
142
|
+
? columns.map((column) => plainObject(column)?.["name"]).filter((name) => typeof name === "string")
|
|
143
|
+
: [];
|
|
144
|
+
const hasUiRoles = columnNames.includes("Label") && (columnNames.includes("Value") || columnNames.includes("Series"));
|
|
145
|
+
if (typeof datasourceId !== "string" || decodedWith === undefined || plainObject(decodedWith)?.["statement"] === undefined || !hasUiRoles)
|
|
146
|
+
return undefined;
|
|
147
|
+
const attributes = {};
|
|
148
|
+
for (const [key, item] of Object.entries(rec)) {
|
|
149
|
+
if (key === "datasource_id")
|
|
150
|
+
continue;
|
|
151
|
+
if (key === "columns" && Array.isArray(item)) {
|
|
152
|
+
attributes[key] = item.map((column) => {
|
|
153
|
+
const columnObject = plainObject(column);
|
|
154
|
+
if (columnObject === undefined)
|
|
155
|
+
return column;
|
|
156
|
+
return {
|
|
157
|
+
...columnObject,
|
|
158
|
+
...(columnObject["expression"] !== undefined ? { expression: decodeJson(columnObject["expression"]) } : {}),
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
else if (key === "sort" || key === "with" || key === "filter") {
|
|
163
|
+
attributes[key] = decodeJson(item) ?? item;
|
|
164
|
+
}
|
|
165
|
+
else if (key === "group_bys" && Array.isArray(item)) {
|
|
166
|
+
attributes[key] = item.map((group) => {
|
|
167
|
+
const groupObject = plainObject(group);
|
|
168
|
+
return groupObject === undefined ? group : { ...groupObject, ...(groupObject["expression"] !== undefined ? { expression: decodeJson(groupObject["expression"]) } : {}) };
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
else if (key === "joins" && Array.isArray(item)) {
|
|
172
|
+
attributes[key] = item.map((join) => {
|
|
173
|
+
const joinObject = plainObject(join);
|
|
174
|
+
return joinObject === undefined ? join : {
|
|
175
|
+
...joinObject,
|
|
176
|
+
...(joinObject["left_expression"] !== undefined ? { left_expression: decodeJson(joinObject["left_expression"]) } : {}),
|
|
177
|
+
...(joinObject["right_expression"] !== undefined ? { right_expression: decodeJson(joinObject["right_expression"]) } : {}),
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
else
|
|
182
|
+
attributes[key] = item;
|
|
183
|
+
}
|
|
184
|
+
ctx.diagnostics.push(`${where}: preserved UI chart synthetic datasource as an opaque pull-only subscription`);
|
|
185
|
+
return { kind: "opaque", datasourceId, attributes };
|
|
186
|
+
}
|
|
135
187
|
function parseSubscription(value, appLabel, appRefName, ctx, where) {
|
|
188
|
+
const opaque = opaqueSubscriptionFromTf(value, where, ctx);
|
|
189
|
+
if (opaque !== undefined)
|
|
190
|
+
return opaque;
|
|
136
191
|
const rec = plainObject(value);
|
|
137
192
|
if (rec === undefined) {
|
|
138
193
|
ctx.diagnostics.push(`${where}: subscription is not an object; skipped`);
|
|
@@ -153,13 +208,13 @@ function parseSubscription(value, appLabel, appRefName, ctx, where) {
|
|
|
153
208
|
ctx.diagnostics.push(`${where}.columns[${index}]: not an object; subscription skipped`);
|
|
154
209
|
return undefined;
|
|
155
210
|
}
|
|
156
|
-
if (column["expression"] !== undefined) {
|
|
157
|
-
ctx.diagnostics.push(`${where}.columns[${index}]: expression columns are not authorable; subscription skipped`);
|
|
158
|
-
return undefined;
|
|
159
|
-
}
|
|
160
211
|
const field = column["column_id"] !== undefined ? fieldFromTf(column["column_id"], datasource, ctx, `${where}.columns[${index}].column_id`) : undefined;
|
|
161
212
|
if (column["column_id"] !== undefined && field === undefined)
|
|
213
|
+
continue;
|
|
214
|
+
if (column["expression"] !== undefined) {
|
|
215
|
+
ctx.diagnostics.push(`${where}.columns[${index}].expression: unsupported chart expression; subscription skipped`);
|
|
162
216
|
return undefined;
|
|
217
|
+
}
|
|
163
218
|
columns.push({
|
|
164
219
|
...(field !== undefined ? { field } : {}),
|
|
165
220
|
...(typeof column["aggregation"] === "string" ? { aggregation: column["aggregation"] } : {}),
|
|
@@ -168,13 +223,21 @@ function parseSubscription(value, appLabel, appRefName, ctx, where) {
|
|
|
168
223
|
...(typeof column["value_type"] === "string" ? { valueType: column["value_type"] } : {}),
|
|
169
224
|
});
|
|
170
225
|
}
|
|
226
|
+
if (columns.length === 0) {
|
|
227
|
+
ctx.diagnostics.push(`${where}: no resolvable columns remain; subscription skipped`);
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
171
230
|
const rawGroupBys = rec["group_bys"];
|
|
172
231
|
const groupBy = Array.isArray(rawGroupBys) ? [] : undefined;
|
|
173
232
|
if (groupBy !== undefined && Array.isArray(rawGroupBys))
|
|
174
233
|
for (const [index, value] of rawGroupBys.entries()) {
|
|
175
234
|
const group = plainObject(value);
|
|
176
|
-
if (group === undefined || group["
|
|
177
|
-
ctx.diagnostics.push(`${where}.group_bys[${index}]:
|
|
235
|
+
if (group === undefined || (group["column_id"] === undefined && group["expression"] === undefined)) {
|
|
236
|
+
ctx.diagnostics.push(`${where}.group_bys[${index}]: grouping must contain a typed field or supported expression; subscription skipped`);
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
if (group["expression"] !== undefined) {
|
|
240
|
+
ctx.diagnostics.push(`${where}.group_bys[${index}].expression: unsupported chart expression; subscription skipped`);
|
|
178
241
|
return undefined;
|
|
179
242
|
}
|
|
180
243
|
const field = fieldFromTf(group["column_id"], datasource, ctx, `${where}.group_bys[${index}].column_id`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { chartAggregation, chartColumnValueType, chartJoin, chartJoinType, chartSubscription, chartType, defineChart, type ChartAggregation, type ChartColumn, type ChartColumnValueType, type ChartConfigured, type ChartDatasourceRef, type ChartFieldFor, type ChartGroupBy, type ChartJoin, type ChartJoinType, type ChartProperties, type ChartSubscription, type ChartType, type DefineChartOptions, } from "./build.js";
|
|
1
|
+
export { chartAggregation, chartColumnValueType, chartJoin, chartJoinType, chartSubscription, chartType, __pulledChartSubscription, defineChart, type ChartAggregation, type ChartColumn, type ChartColumnValueType, type ChartConfigured, type ChartDatasourceRef, type ChartFieldFor, type ChartGroupBy, type ChartJoin, type ChartJoinType, type ChartOpaqueSubscription, type ChartSubscriptionInput, type ChartProperties, type ChartSubscription, type ChartType, type DefineChartOptions, } from "./build.js";
|
|
2
2
|
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, type DashboardChartWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
|
|
3
3
|
export * as filter from "../shared/filters/index.js";
|
|
4
4
|
export { type Filter } from "../shared/filters/index.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { chartAggregation, chartColumnValueType, chartJoin, chartJoinType, chartSubscription, chartType, defineChart, } from "./build.js";
|
|
1
|
+
export { chartAggregation, chartColumnValueType, chartJoin, chartJoinType, chartSubscription, chartType, __pulledChartSubscription, defineChart, } from "./build.js";
|
|
2
2
|
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, } from "../dashboard/build.js";
|
|
3
3
|
export * as filter from "../shared/filters/index.js";
|
|
@@ -17,6 +17,17 @@ function fieldExpr(value) {
|
|
|
17
17
|
? `catalog.tables${member(value.parentRefName)}.columns${member(value.refName)}`
|
|
18
18
|
: `catalog${member(value.parentRefName)}.fields${member(value.refName)}`;
|
|
19
19
|
}
|
|
20
|
+
function printOpaqueSubscription(subscription) {
|
|
21
|
+
const attrs = Object.entries(subscription.attributes)
|
|
22
|
+
.map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
|
|
23
|
+
.join(", ");
|
|
24
|
+
return [
|
|
25
|
+
" __pulledChartSubscription({",
|
|
26
|
+
` datasourceId: unsafePlatformId(${quote(subscription.datasourceId)}),`,
|
|
27
|
+
` attributes: { ${attrs} },`,
|
|
28
|
+
" }),",
|
|
29
|
+
];
|
|
30
|
+
}
|
|
20
31
|
function printColumn(column) {
|
|
21
32
|
const parts = [];
|
|
22
33
|
if (column.field !== undefined)
|
|
@@ -65,20 +76,25 @@ function printSubscription(subscription) {
|
|
|
65
76
|
}
|
|
66
77
|
export function printChart(chart, opts) {
|
|
67
78
|
const imports = ["chartSubscription", "chartType", "defineChart"];
|
|
68
|
-
if (chart.subscriptions.some((subscription) => subscription.
|
|
79
|
+
if (chart.subscriptions.some((subscription) => subscription.kind === "opaque"))
|
|
80
|
+
imports.push("__pulledChartSubscription");
|
|
81
|
+
if (chart.subscriptions.some((subscription) => subscription.kind !== "opaque" && subscription.columns.some((column) => column.aggregation !== undefined)))
|
|
69
82
|
imports.push("chartAggregation");
|
|
70
|
-
if (chart.subscriptions.some((subscription) => subscription.columns.some((column) => column.valueType !== undefined)))
|
|
83
|
+
if (chart.subscriptions.some((subscription) => subscription.kind !== "opaque" && subscription.columns.some((column) => column.valueType !== undefined)))
|
|
71
84
|
imports.push("chartColumnValueType");
|
|
72
|
-
if (chart.subscriptions.some((subscription) => (subscription.joins?.length ?? 0) > 0))
|
|
85
|
+
if (chart.subscriptions.some((subscription) => subscription.kind !== "opaque" && (subscription.joins?.length ?? 0) > 0))
|
|
73
86
|
imports.push("chartJoin");
|
|
74
|
-
if (chart.subscriptions.some((subscription) => subscription.joins?.some((join) => join.type !== undefined) === true))
|
|
87
|
+
if (chart.subscriptions.some((subscription) => subscription.kind !== "opaque" && subscription.joins?.some((join) => join.type !== undefined) === true))
|
|
75
88
|
imports.push("chartJoinType");
|
|
76
|
-
if (chart.subscriptions.some((subscription) => subscription.filter !== undefined))
|
|
89
|
+
if (chart.subscriptions.some((subscription) => subscription.kind !== "opaque" && subscription.filter !== undefined))
|
|
77
90
|
imports.push("filter");
|
|
78
91
|
const lines = [
|
|
79
92
|
"/** Auto-generated by EDK pull. Hand-edit freely. */",
|
|
80
93
|
`import { ${imports.sort().join(", ")} } from ${quote(sdkPackageSpecifier("charts"))};`,
|
|
81
94
|
'import catalog from "@catalog";',
|
|
95
|
+
...(chart.subscriptions.some((subscription) => subscription.kind === "opaque")
|
|
96
|
+
? [`import { unsafePlatformId } from ${quote(sdkPackageSpecifier("core"))};`]
|
|
97
|
+
: []),
|
|
82
98
|
"",
|
|
83
99
|
"const chart = defineChart({",
|
|
84
100
|
` app: catalog${member(opts.appRefName)},`,
|
|
@@ -97,8 +113,12 @@ export function printChart(chart, opts) {
|
|
|
97
113
|
lines.push(` properties: { ${parts.join(", ")} },`);
|
|
98
114
|
}
|
|
99
115
|
lines.push(" subscriptions: [");
|
|
100
|
-
for (const subscription of chart.subscriptions)
|
|
101
|
-
|
|
116
|
+
for (const subscription of chart.subscriptions) {
|
|
117
|
+
if (subscription.kind === "opaque")
|
|
118
|
+
lines.push(...printOpaqueSubscription(subscription));
|
|
119
|
+
else
|
|
120
|
+
lines.push(...printSubscription(subscription));
|
|
121
|
+
}
|
|
102
122
|
lines.push(" ],", "});", "", "export default chart;", "");
|
|
103
123
|
return lines.join("\n");
|
|
104
124
|
}
|
|
@@ -3,6 +3,7 @@ import { EntityTfError } from "../../engine/entity.js";
|
|
|
3
3
|
import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
4
4
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
5
5
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
6
|
+
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
6
7
|
import { CHART_RESOURCE_TYPE } from "./types.js";
|
|
7
8
|
const APP_RESOURCE_TYPE = "elementum_app";
|
|
8
9
|
const TABLE_RESOURCE_TYPE = "elementum_table";
|
|
@@ -70,13 +71,66 @@ function columnToTf(column, datasource, opts, where) {
|
|
|
70
71
|
return out;
|
|
71
72
|
}
|
|
72
73
|
function filterToTf(value, datasource, opts, where) {
|
|
73
|
-
return
|
|
74
|
+
return serializeFilterToTf(value, {
|
|
74
75
|
field: (field) => fieldId(field, datasource, opts, `${where}.field`),
|
|
75
76
|
aspect: () => datasource.id,
|
|
76
77
|
reference: () => { throw new EntityTfError(`${where}: runtime reference values are not supported in chart filters`); },
|
|
77
|
-
})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function opaqueSubscriptionToTf(subscription, where) {
|
|
81
|
+
if (!isUnsafePlatformId(subscription.datasourceId)) {
|
|
82
|
+
throw new EntityTfError(`${where}: opaque chart datasource must use unsafePlatformId(...)`);
|
|
83
|
+
}
|
|
84
|
+
const out = { datasource_id: subscription.datasourceId.value };
|
|
85
|
+
for (const [key, value] of Object.entries(subscription.attributes ?? {})) {
|
|
86
|
+
if (key === "sort" || key === "with" || key === "filter") {
|
|
87
|
+
out[key] = expr.jsonencode(value);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (key === "columns" && Array.isArray(value)) {
|
|
91
|
+
out[key] = value.map((column) => {
|
|
92
|
+
if (typeof column !== "object" || column === null)
|
|
93
|
+
return column;
|
|
94
|
+
const item = column;
|
|
95
|
+
return {
|
|
96
|
+
...item,
|
|
97
|
+
...(item["expression"] !== undefined ? { expression: expr.jsonencode(item["expression"]) } : {}),
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (key === "group_bys" && Array.isArray(value)) {
|
|
103
|
+
out[key] = value.map((group) => {
|
|
104
|
+
if (typeof group !== "object" || group === null)
|
|
105
|
+
return group;
|
|
106
|
+
const item = group;
|
|
107
|
+
return {
|
|
108
|
+
...item,
|
|
109
|
+
...(item["expression"] !== undefined ? { expression: expr.jsonencode(item["expression"]) } : {}),
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (key === "joins" && Array.isArray(value)) {
|
|
115
|
+
out[key] = value.map((join) => {
|
|
116
|
+
if (typeof join !== "object" || join === null)
|
|
117
|
+
return join;
|
|
118
|
+
const item = join;
|
|
119
|
+
return {
|
|
120
|
+
...item,
|
|
121
|
+
...(item["left_expression"] !== undefined ? { left_expression: expr.jsonencode(item["left_expression"]) } : {}),
|
|
122
|
+
...(item["right_expression"] !== undefined ? { right_expression: expr.jsonencode(item["right_expression"]) } : {}),
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
out[key] = value;
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
78
130
|
}
|
|
79
131
|
function subscriptionToTf(subscription, opts, where) {
|
|
132
|
+
if (subscription.kind === "opaque")
|
|
133
|
+
return opaqueSubscriptionToTf(subscription, where);
|
|
80
134
|
const datasource = datasourceId(subscription.datasource, opts, `${where}.datasource`);
|
|
81
135
|
const out = {
|
|
82
136
|
datasource_id: datasource.id,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
2
|
import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
|
|
3
3
|
import { EntityTfError } from "../../engine/entity.js";
|
|
4
|
-
import { isTfExpr, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
4
|
+
import { isTfExpr, snakeSlug, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
5
5
|
import { filterFromTf } from "../shared/filters/tf-codec.js";
|
|
6
6
|
const KNOWN_DATAMINE_ATTRS = new Set([
|
|
7
7
|
"id",
|
|
@@ -94,6 +94,16 @@ function tableColumnKey(value, tableTfLabel, columnKeyByName, columnKeyById, ctx
|
|
|
94
94
|
if (key !== undefined)
|
|
95
95
|
return key;
|
|
96
96
|
}
|
|
97
|
+
// Older `ei tables export` versions emitted table datamine filters through
|
|
98
|
+
// the generic field data source (`data.elementum_field.<table>_<column>.id`)
|
|
99
|
+
// even though the field belongs to the table. Resolve that legacy shape by
|
|
100
|
+
// its stable table/column label so the pulled datamine remains authorable.
|
|
101
|
+
if (isTfExpr(value) && value.$expr === "data-attr" && value.type === "elementum_field" && value.label.startsWith(`${tableTfLabel}_`) && value.path[0] === "id") {
|
|
102
|
+
const columnSlug = value.label.slice(tableTfLabel.length + 1);
|
|
103
|
+
const match = [...columnKeyByName.entries()].find(([name]) => snakeSlug(name) === columnSlug);
|
|
104
|
+
if (match !== undefined)
|
|
105
|
+
return match[1];
|
|
106
|
+
}
|
|
97
107
|
const fieldLabel = dataRefLabel(value, "elementum_field");
|
|
98
108
|
if (fieldLabel !== undefined) {
|
|
99
109
|
const attrs = ctx.dataAttrs?.("elementum_field", fieldLabel);
|
|
@@ -115,11 +115,12 @@ export interface ElementV2Options<F extends Record<string, AppField> = Record<st
|
|
|
115
115
|
*/
|
|
116
116
|
readonly recordCreateForm?: AppRecordCreateForm;
|
|
117
117
|
/**
|
|
118
|
-
* Parent-owned joins keyed by stable ref name.
|
|
119
|
-
* targeting another app/element lists rows through
|
|
120
|
-
* whose columns join comparable stored values, not
|
|
121
|
-
* `relationField` / `autoRelate`. Do not join system
|
|
122
|
-
*
|
|
118
|
+
* Parent-owned joins keyed by stable ref name. Same join contract as apps:
|
|
119
|
+
* a `relatedRecords` widget targeting another app/element lists rows through
|
|
120
|
+
* a matching entry here whose columns join comparable stored values, not
|
|
121
|
+
* through that child's `relationField` / `autoRelate`. Do not join system
|
|
122
|
+
* `"id"` (HANDLE) to a `relationField` or dynamic dropdown on the related
|
|
123
|
+
* side.
|
|
123
124
|
*/
|
|
124
125
|
readonly relationships?: Readonly<Record<string, AppRelationship>>;
|
|
125
126
|
/** Display order of `listViews` (by key). Defaults to declaration order. */
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* `NormalizedApp` shape (`type: "ELEMENT"`) that `printElementV2` consumes.
|
|
4
4
|
* Mirrors `app/from-tf.ts` without app-only status/stages dialect.
|
|
5
5
|
*/
|
|
6
|
+
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES } from "../../core/system-fields.js";
|
|
6
7
|
import { EntityTfError } from "../../engine/entity.js";
|
|
7
8
|
import { dataRefLabel, optionalBoolean, optionalString } from "../../engine/pull/context.js";
|
|
8
9
|
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
@@ -127,11 +128,11 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
127
128
|
const fields = [];
|
|
128
129
|
const titleName = optionalString(attrs, "title_field_name", `element "${label}"`, ctx);
|
|
129
130
|
if (titleName !== undefined || titleFieldDescription !== undefined) {
|
|
130
|
-
fields.push(systemEntry("title", titleName ??
|
|
131
|
+
fields.push(systemEntry("title", titleName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.title, "TEXT", "TITLE", titleFieldDescription));
|
|
131
132
|
}
|
|
132
133
|
const idName = optionalString(attrs, "id_field_name", `element "${label}"`, ctx);
|
|
133
134
|
if (idName !== undefined || idFieldDescription !== undefined) {
|
|
134
|
-
fields.push(systemEntry("id", idName ??
|
|
135
|
+
fields.push(systemEntry("id", idName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.id, "TEXT", "HANDLE", idFieldDescription));
|
|
135
136
|
}
|
|
136
137
|
const owner = { type: ELEMENT_RESOURCE_TYPE, label, scope: "element" };
|
|
137
138
|
for (const block of fieldBlocks) {
|
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { type ToTfContext } from "../../engine/build/context.js";
|
|
7
7
|
import { type DeployableEntity } from "../../engine/entity.js";
|
|
8
|
+
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
8
9
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
9
10
|
export interface ElementToTfResult {
|
|
10
11
|
readonly blocks: readonly TfBlock[];
|
|
11
12
|
readonly fieldAddresses: ReadonlyMap<string, string>;
|
|
12
13
|
readonly fieldNames: ReadonlyMap<string, string>;
|
|
14
|
+
/** bag key → type/options metadata, used by element-owned automation switch filters. */
|
|
15
|
+
readonly fieldMetadata: ReadonlyMap<string, BuildFieldMetadata>;
|
|
13
16
|
}
|
|
14
17
|
/** `elementum_element` + one field resource per custom field. */
|
|
15
18
|
export declare function elementToTf(entity: DeployableEntity, ctx: ToTfContext): ElementToTfResult;
|
|
@@ -11,6 +11,7 @@ import { displayBlocksToLayoutSections } from "../app/display-blocks-to-layout.j
|
|
|
11
11
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
12
12
|
import { displayBlocksToRecordCreateFormSections } from "../app/display-blocks-to-record-create-form.js";
|
|
13
13
|
import { dashboardsToTf } from "../dashboard/to-tf.js";
|
|
14
|
+
import { fieldMetadataFromEntries } from "../field/metadata.js";
|
|
14
15
|
import { fieldToTf } from "../field/to-tf.js";
|
|
15
16
|
import { CATEGORY_ORG_BAG } from "../org/category.js";
|
|
16
17
|
import { categoryIdExpr, missingCategoryDiagnostic } from "../org/category-ref.js";
|
|
@@ -20,6 +21,7 @@ import { relationshipsToTf } from "../relationship/to-tf.js";
|
|
|
20
21
|
import { rolesToTf } from "../role/to-tf.js";
|
|
21
22
|
import { relationshipTargetsFromBag, widgetsToTf } from "../widget/to-tf.js";
|
|
22
23
|
import { viewToTf } from "../view/to-tf.js";
|
|
24
|
+
import { SYSTEM_FIELD_KEY_BY_TAG } from "../../core/system-fields.js";
|
|
23
25
|
import { ELEMENT_RESOURCE_TYPE } from "./module.js";
|
|
24
26
|
/** System-field tags that fold into the element resource (no field resource). */
|
|
25
27
|
const SYSTEM_FIELD_TAGS = new Set([
|
|
@@ -127,6 +129,7 @@ export function elementToTf(entity, ctx) {
|
|
|
127
129
|
const blocks = [];
|
|
128
130
|
const fieldAddresses = new Map();
|
|
129
131
|
const fieldNames = new Map();
|
|
132
|
+
const fieldMetadata = fieldMetadataFromEntries(payload.fields);
|
|
130
133
|
const objectId = expr.resourceAttr(ELEMENT_RESOURCE_TYPE, ctx.appTfLabel, ["id"]);
|
|
131
134
|
for (const fieldEntry of payload.fields ?? []) {
|
|
132
135
|
const typeKey = Object.keys(fieldEntry)[0];
|
|
@@ -139,6 +142,11 @@ export function elementToTf(entity, ctx) {
|
|
|
139
142
|
fieldNames.set(fieldKey, name);
|
|
140
143
|
const systemTag = inner.tags?.find((tag) => SYSTEM_FIELD_TAGS.has(tag));
|
|
141
144
|
if (systemTag !== undefined) {
|
|
145
|
+
const systemKey = SYSTEM_FIELD_KEY_BY_TAG[systemTag];
|
|
146
|
+
// Same canonical-key guarantee as app/to-tf: cross-app .record.title
|
|
147
|
+
// must resolve against "title", never snakeSlug of a renamed label.
|
|
148
|
+
if (systemKey !== undefined && name !== "")
|
|
149
|
+
fieldNames.set(systemKey, name);
|
|
142
150
|
switch (systemTag) {
|
|
143
151
|
case "TITLE":
|
|
144
152
|
if (name !== "Title")
|
|
@@ -289,5 +297,5 @@ export function elementToTf(entity, ctx) {
|
|
|
289
297
|
label: ctx.appTfLabel,
|
|
290
298
|
attrs: elementAttrs,
|
|
291
299
|
});
|
|
292
|
-
return { blocks, fieldAddresses, fieldNames };
|
|
300
|
+
return { blocks, fieldAddresses, fieldNames, fieldMetadata };
|
|
293
301
|
}
|
|
@@ -35,3 +35,27 @@ export declare function fieldKeyFromTfRef(v: TfValue, ownerTfLabel?: string, sco
|
|
|
35
35
|
* one app or element from becoming a same-owner field token accidentally.
|
|
36
36
|
*/
|
|
37
37
|
export declare function fieldKeyFromTfValue(v: TfValue, ownerRefName: string, ownerTfLabel: string, scope: ChildResourceScope, ctx: FromTfContext): string | undefined;
|
|
38
|
+
export interface DecodedForeignDataField {
|
|
39
|
+
readonly key: string;
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly fieldType?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Decode `data.elementum_field.<label>` to the target's public field key.
|
|
45
|
+
* ei labels are `elementum_element_<sanitize(displayName)>_<field>` (or
|
|
46
|
+
* `app_<slug>_<field>`), not the catalog bag key. Treating the whole label
|
|
47
|
+
* as the key rebuilds a non-existent `elementum_text_field.<owner>_<label>`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function decodeForeignDataField(dataLabel: string, target: {
|
|
50
|
+
readonly key: string;
|
|
51
|
+
readonly name?: string;
|
|
52
|
+
readonly namespace?: string;
|
|
53
|
+
readonly kind?: string;
|
|
54
|
+
}, ctx: FromTfContext): DecodedForeignDataField;
|
|
55
|
+
/** Strip ei's owner-display prefix from a `data.elementum_field` label. */
|
|
56
|
+
export declare function fieldKeyFromForeignDataLabel(dataLabel: string, target: {
|
|
57
|
+
readonly key: string;
|
|
58
|
+
readonly name?: string;
|
|
59
|
+
readonly namespace?: string;
|
|
60
|
+
readonly kind?: string;
|
|
61
|
+
}): string | undefined;
|