@elementumai/edk 0.8.0-preview.11 → 0.8.1
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 +378 -324
- package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
- package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
- package/dist-sdk/src/catalog/factories.d.ts +56 -3
- package/dist-sdk/src/catalog/factories.js +65 -2
- package/dist-sdk/src/catalog/from-authoring.js +6 -1
- package/dist-sdk/src/catalog/index.d.ts +3 -2
- package/dist-sdk/src/catalog/index.js +3 -2
- package/dist-sdk/src/catalog/org.d.ts +1 -1
- package/dist-sdk/src/catalog/org.js +83 -6
- package/dist-sdk/src/catalog/render.d.ts +13 -1
- package/dist-sdk/src/catalog/render.js +21 -4
- package/dist-sdk/src/catalog/token.js +14 -0
- package/dist-sdk/src/catalog/types.d.ts +60 -3
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +2 -0
- package/dist-sdk/src/core/system-fields.js +2 -0
- package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
- package/dist-sdk/src/core/types/ai-provider.js +1 -25
- package/dist-sdk/src/core/types/app.d.ts +20 -1
- package/dist-sdk/src/engine/build/context.d.ts +18 -0
- package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
- package/dist-sdk/src/engine/build/source-context.js +23 -0
- package/dist-sdk/src/engine/pull/context.d.ts +15 -0
- package/dist-sdk/src/engine/pull/org.d.ts +10 -0
- package/dist-sdk/src/engine/pull/org.js +34 -4
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +45 -0
- package/dist-sdk/src/engine/tf/labels.js +71 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
- package/dist-sdk/src/entities/access-policy/build.js +7 -0
- package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
- package/dist-sdk/src/entities/access-policy/filter.js +83 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +48 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +189 -0
- package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
- package/dist-sdk/src/entities/access-policy/module.js +17 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +36 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +149 -0
- package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/types.js +10 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +199 -32
- package/dist-sdk/src/entities/agent/from-tf.d.ts +18 -3
- package/dist-sdk/src/entities/agent/from-tf.js +135 -15
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +8 -2
- package/dist-sdk/src/entities/agent/to-tf.js +62 -10
- package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
- package/dist-sdk/src/entities/agent/tools.js +46 -7
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
- package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +103 -17
- package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
- package/dist-sdk/src/entities/agent-tool/types.js +38 -6
- package/dist-sdk/src/entities/app/build.d.ts +63 -13
- package/dist-sdk/src/entities/app/build.js +48 -1
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/from-tf.js +32 -15
- package/dist-sdk/src/entities/app/index.d.ts +4 -1
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/module.js +9 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
- package/dist-sdk/src/entities/app/to-tf.js +33 -4
- package/dist-sdk/src/entities/automation/build.d.ts +57 -13
- package/dist-sdk/src/entities/automation/build.js +48 -36
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +179 -43
- package/dist-sdk/src/entities/automation/filter.d.ts +15 -3
- package/dist-sdk/src/entities/automation/filter.js +12 -2
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
- package/dist-sdk/src/entities/automation/from-tf.js +1229 -223
- package/dist-sdk/src/entities/automation/index.d.ts +4 -0
- package/dist-sdk/src/entities/automation/index.js +4 -0
- package/dist-sdk/src/entities/automation/module.js +29 -32
- package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
- package/dist-sdk/src/entities/automation/operators.js +27 -1
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
- package/dist-sdk/src/entities/automation/script-code.js +272 -5
- package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
- package/dist-sdk/src/entities/automation/tasks.js +83 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
- package/dist-sdk/src/entities/automation/to-tf.js +1134 -231
- package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
- package/dist-sdk/src/entities/automation/types.d.ts +29 -4
- package/dist-sdk/src/entities/automation/types.js +76 -46
- package/dist-sdk/src/entities/element/build.d.ts +23 -10
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/from-tf.js +18 -3
- package/dist-sdk/src/entities/element/index.d.ts +4 -1
- package/dist-sdk/src/entities/element/index.js +2 -1
- package/dist-sdk/src/entities/element/module.js +3 -1
- package/dist-sdk/src/entities/element/to-tf.js +21 -3
- package/dist-sdk/src/entities/field/build.d.ts +56 -13
- package/dist-sdk/src/entities/field/build.js +10 -0
- package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
- package/dist-sdk/src/entities/field/from-tf.js +118 -7
- package/dist-sdk/src/entities/field/module.js +3 -2
- package/dist-sdk/src/entities/field/to-tf.d.ts +27 -9
- package/dist-sdk/src/entities/field/to-tf.js +62 -17
- package/dist-sdk/src/entities/field/types.d.ts +26 -0
- package/dist-sdk/src/entities/field/types.js +34 -12
- package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
- package/dist-sdk/src/entities/file-reader/build.js +23 -23
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
- package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
- package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
- package/dist-sdk/src/entities/file-reader/index.js +7 -2
- package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
- package/dist-sdk/src/entities/file-reader/module.js +115 -0
- package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
- package/dist-sdk/src/entities/file-reader/types.js +30 -0
- package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
- package/dist-sdk/src/entities/org/ai-provider.js +46 -0
- package/dist-sdk/src/entities/org/connector.d.ts +8 -1
- package/dist-sdk/src/entities/org/connector.js +12 -14
- package/dist-sdk/src/entities/org/group.js +10 -1
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/user.js +10 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +44 -9
- package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +31 -0
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -8
- package/dist-sdk/src/entities/skill/from-tf.js +4 -3
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/module.js +6 -1
- package/dist-sdk/src/entities/skill/to-tf.js +3 -2
- package/dist-sdk/src/entities/skill/tools.d.ts +25 -3
- package/dist-sdk/src/entities/skill/tools.js +17 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +15 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.js +32 -11
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +32 -9
- package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
- package/dist-sdk/src/entities/view/from-tf.js +11 -9
- package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
- package/dist-sdk/src/entities/view/to-tf.js +33 -18
- package/dist-sdk/src/entities/view/types.d.ts +1 -1
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
- package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
- package/dist-sdk/src/graph/index.d.ts +8 -0
- package/dist-sdk/src/graph/index.js +13 -9
- package/dist-sdk/src/graph/modules.js +6 -1
- package/dist-sdk/src/graph/types.d.ts +77 -3
- package/package.json +42 -14
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
- package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
|
@@ -17,6 +17,7 @@ import type { WorkflowFieldType } from "../shared/types/field-types.js";
|
|
|
17
17
|
import { type SystemFieldKey } from "../../core/system-fields.js";
|
|
18
18
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
19
19
|
import type { AspectFieldInput } from "../../../elementum-entity-client/clients/aspects/models/field-types.js";
|
|
20
|
+
import type { AccessPolicyOptions } from "../access-policy/build.js";
|
|
20
21
|
import { type DisplayBlock } from "./display-blocks.js";
|
|
21
22
|
import type { Expr, ExprType } from "../field/calc.js";
|
|
22
23
|
/**
|
|
@@ -87,6 +88,8 @@ export interface AppField {
|
|
|
87
88
|
readonly config?: AppPicklistConfig;
|
|
88
89
|
/** Numeric format (`NUMBER` / `DECIMAL`) — pure config, no refs. */
|
|
89
90
|
readonly numericFormat?: Record<string, unknown>;
|
|
91
|
+
/** `DECIMAL` only — display/storage precision (`elementum_decimal_field.decimal_places`). */
|
|
92
|
+
readonly decimalPlaces?: number;
|
|
90
93
|
/** QR format (`TEXT` / `HANDLE`) — pure config, no refs. */
|
|
91
94
|
readonly qrFormat?: Record<string, unknown>;
|
|
92
95
|
/**
|
|
@@ -94,6 +97,16 @@ export interface AppField {
|
|
|
94
97
|
* field serializes as a calculated field; `type` is the declared output type.
|
|
95
98
|
*/
|
|
96
99
|
readonly expression?: Expr<ExprType>;
|
|
100
|
+
/**
|
|
101
|
+
* `RELATION` only — raw platform ids of the related aspect/field
|
|
102
|
+
* (`elementum_relation_field.related_object_id`/`related_label_field_id`),
|
|
103
|
+
* not catalog tokens: a non-recursive export never discovers the related
|
|
104
|
+
* aspect's own identity, so there's nothing to resolve them against.
|
|
105
|
+
*/
|
|
106
|
+
readonly relatedAspectId?: string;
|
|
107
|
+
readonly relatedLabelFieldId?: string;
|
|
108
|
+
/** `RELATION` only. Defaults to `true` on the platform. */
|
|
109
|
+
readonly autoRelate?: boolean;
|
|
97
110
|
}
|
|
98
111
|
/** A picklist option with optional dependent-dropdown parent links. */
|
|
99
112
|
export interface PicklistOption {
|
|
@@ -126,17 +139,21 @@ export interface AppCloudOptions {
|
|
|
126
139
|
}
|
|
127
140
|
/**
|
|
128
141
|
* An override for a platform-managed (system) field. Only what the platform
|
|
129
|
-
* genuinely allows overriding is authorable: the display name
|
|
130
|
-
* status
|
|
131
|
-
*
|
|
132
|
-
*
|
|
142
|
+
* genuinely allows overriding is authorable: the display name, an optional
|
|
143
|
+
* description (title/id/status only — the app resource has no
|
|
144
|
+
* `*_field_description` attribute for the others), and, for the status/stage
|
|
145
|
+
* picklists, the option set. `type` and the required/showOnCreate booleans
|
|
146
|
+
* are fixed by the platform's per-tag config and deliberately have no
|
|
147
|
+
* authoring slot.
|
|
133
148
|
*/
|
|
134
149
|
export interface AppSystemFieldOverride {
|
|
135
150
|
readonly name: string;
|
|
151
|
+
readonly description?: string;
|
|
136
152
|
}
|
|
137
153
|
/** A system-picklist override (status/stage): display name + option set. */
|
|
138
154
|
export interface AppSystemPicklistOverride {
|
|
139
155
|
readonly name: string;
|
|
156
|
+
readonly description?: string;
|
|
140
157
|
readonly options: readonly (string | PicklistOption)[];
|
|
141
158
|
}
|
|
142
159
|
/**
|
|
@@ -212,7 +229,7 @@ export interface AppListView {
|
|
|
212
229
|
/** Opaque JSON pass-through — see `filter`. */
|
|
213
230
|
readonly sort?: unknown;
|
|
214
231
|
}
|
|
215
|
-
export interface AppV2Options extends EntityDeployOptions {
|
|
232
|
+
export interface AppV2Options<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> extends EntityDeployOptions {
|
|
216
233
|
readonly name: string;
|
|
217
234
|
readonly category: AppCategory;
|
|
218
235
|
readonly namespace?: string;
|
|
@@ -237,7 +254,7 @@ export interface AppV2Options extends EntityDeployOptions {
|
|
|
237
254
|
/** Cloud-backing options (Snowflake-only); applied on create only. */
|
|
238
255
|
readonly cloudOptions?: AppCloudOptions;
|
|
239
256
|
/** Fields keyed by ref name. At least one required by the compose API. */
|
|
240
|
-
readonly fields:
|
|
257
|
+
readonly fields: F;
|
|
241
258
|
/**
|
|
242
259
|
* Overrides for the platform's auto-provisioned system fields (ID, Title,
|
|
243
260
|
* Status, Stage, and the audit fields). Omit entirely when the app keeps
|
|
@@ -251,7 +268,7 @@ export interface AppV2Options extends EntityDeployOptions {
|
|
|
251
268
|
* reference them by typed handle (e.g. `app.fields.title`), but are **never included in the
|
|
252
269
|
* deploy payload** (the platform owns them; sending them on compose would be rejected).
|
|
253
270
|
*/
|
|
254
|
-
readonly readonlyFields?:
|
|
271
|
+
readonly readonlyFields?: R;
|
|
255
272
|
/** Record-view (LAYOUT surface) display blocks. */
|
|
256
273
|
readonly displayBlocks?: readonly DisplayBlock[];
|
|
257
274
|
/** New-record form (CREATE surface) display blocks. */
|
|
@@ -267,6 +284,8 @@ export interface AppV2Options extends EntityDeployOptions {
|
|
|
267
284
|
readonly listViews?: Readonly<Record<string, AppListView>>;
|
|
268
285
|
/** Display order of `listViews` (by key). Defaults to declaration order. */
|
|
269
286
|
readonly viewOrder?: readonly string[];
|
|
287
|
+
/** App-level sharing & row-level-security policies (`elementum_access_policy`), in declaration order. */
|
|
288
|
+
readonly accessPolicies?: readonly AccessPolicyOptions[];
|
|
270
289
|
}
|
|
271
290
|
/**
|
|
272
291
|
* Serialize an authored field to its `AspectFieldInput` wire shape — shared
|
|
@@ -297,9 +316,40 @@ export declare function assertNoSystemKeyCollision(builder: string, name: string
|
|
|
297
316
|
* always carry their option set; the other keys are name-only.
|
|
298
317
|
*/
|
|
299
318
|
export declare function serializeSystemFields(overrides: AppSystemFields | undefined): AspectFieldInput[];
|
|
300
|
-
/**
|
|
301
|
-
|
|
302
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Per-field `FieldRef`s for an authored `fields:` bag, keyed exactly like it,
|
|
321
|
+
* each carrying its own literal `fieldType` (not the widened
|
|
322
|
+
* `WorkflowFieldType` union) — this is what lets `defineApp(...).ref()` serve
|
|
323
|
+
* as the catalog's live source for fields (`src/catalog/render.ts`'s
|
|
324
|
+
* `ownFile`) without losing the per-field type precision `RecordShape`
|
|
325
|
+
* (`entities/field/record-shape.ts`) needs to discriminate value types.
|
|
326
|
+
*/
|
|
327
|
+
export type AppFieldRefs<F extends Record<string, AppField>> = {
|
|
328
|
+
readonly [K in keyof F]: FieldRef & {
|
|
329
|
+
readonly fieldType: F[K]["type"];
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* An app's reference surface: identity plus its fields (the only bag other
|
|
334
|
+
* entities may point at). Generic over the authored `fields:` bag (`F`) and
|
|
335
|
+
* `readonlyFields:` bag (`R`) so `app.ref(name).fields.priority.fieldType`
|
|
336
|
+
* narrows to its literal (e.g. `"PICKLIST"`); the platform-owned system
|
|
337
|
+
* fields round out the bag via `Record<SystemFieldKey, FieldRef>` — a finite
|
|
338
|
+
* union of literal keys, deliberately NOT a wide `Record<string, FieldRef>`.
|
|
339
|
+
*
|
|
340
|
+
* That distinction is load-bearing, not style: a wide `string`-keyed index
|
|
341
|
+
* signature anywhere in this intersection poisons `RecordShape`
|
|
342
|
+
* (`entities/field/record-shape.ts`) when `DeepRef`
|
|
343
|
+
* (`entities/shared/context.ts`) re-maps its keys a second time for
|
|
344
|
+
* `ctx.trigger.record`/`ctx.tasks.<t>.record` drilling — every field
|
|
345
|
+
* collapses to `Ref<string>`, losing e.g. a picklist's `.id`/`.label`. Found
|
|
346
|
+
* and verified via isolated repro before this fix landed; `R`'s default is
|
|
347
|
+
* `Record<never, never>` (a literal empty object, no index signature) for
|
|
348
|
+
* the same reason — `Record<string, never>` would reintroduce it even when
|
|
349
|
+
* no `readonlyFields` are declared.
|
|
350
|
+
*/
|
|
351
|
+
export type AppRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> = AspectRef & {
|
|
352
|
+
readonly fields: AppFieldRefs<F> & Record<SystemFieldKey, FieldRef> & R;
|
|
303
353
|
};
|
|
304
354
|
/**
|
|
305
355
|
* The configured result of `defineApp` — its reference surface (`ref()`) and
|
|
@@ -311,8 +361,8 @@ export type AppRef = AspectRef & {
|
|
|
311
361
|
* inside `defineApp({...})` would be the same redundant property the rest of
|
|
312
362
|
* the system avoids, just one level up.
|
|
313
363
|
*/
|
|
314
|
-
export interface AppConfigured {
|
|
315
|
-
ref(refName: string): AppRef
|
|
364
|
+
export interface AppConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> {
|
|
365
|
+
ref(refName: string): AppRef<F, R>;
|
|
316
366
|
def(refName: string): DeployableEntity;
|
|
317
367
|
}
|
|
318
|
-
export declare function defineApp(opts: AppV2Options): AppConfigured
|
|
368
|
+
export declare function defineApp<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>>(opts: AppV2Options<F, R>): AppConfigured<F, R>;
|
|
@@ -15,7 +15,12 @@
|
|
|
15
15
|
import { slimTokens } from "../../catalog/index.js";
|
|
16
16
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS, SYSTEM_FIELD_REQUIRED, SYSTEM_FIELD_TAG_BY_KEY, WRITABLE_SYSTEM_TAG_NAMES, } from "../../core/system-fields.js";
|
|
17
17
|
import { serializeDisplayBlocks } from "./display-blocks.js";
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Map a platform field type to the `AspectFieldInput` variant key. "relation"
|
|
20
|
+
* is a terraform-only synthetic key (no `elementum-entity-client` REST
|
|
21
|
+
* variant exists — `elementum_relation_field` never round-trips through the
|
|
22
|
+
* legacy compose API), hence the widened value type over `AspectFieldInputKey`.
|
|
23
|
+
*/
|
|
19
24
|
const TYPE_TO_KEY = {
|
|
20
25
|
TEXT: "text",
|
|
21
26
|
RICH_TEXT: "text",
|
|
@@ -35,6 +40,7 @@ const TYPE_TO_KEY = {
|
|
|
35
40
|
JSON: "json",
|
|
36
41
|
PICKLIST: "picklist",
|
|
37
42
|
MULTI_PICKLIST: "multiPicklist",
|
|
43
|
+
RELATION: "relation",
|
|
38
44
|
};
|
|
39
45
|
const SYSTEM_FIELD_TAG_TO_TYPE = {
|
|
40
46
|
HANDLE: "HANDLE",
|
|
@@ -158,9 +164,20 @@ export function serializeField(field, refName) {
|
|
|
158
164
|
if ((key === "number" || key === "decimal") && field.numericFormat !== undefined) {
|
|
159
165
|
base.format = field.numericFormat;
|
|
160
166
|
}
|
|
167
|
+
if (key === "decimal" && field.decimalPlaces !== undefined) {
|
|
168
|
+
base.decimalPlaces = field.decimalPlaces;
|
|
169
|
+
}
|
|
161
170
|
if ((key === "text" || key === "html") && field.qrFormat !== undefined) {
|
|
162
171
|
base.format = field.qrFormat;
|
|
163
172
|
}
|
|
173
|
+
if (key === "relation") {
|
|
174
|
+
if (field.relatedAspectId !== undefined)
|
|
175
|
+
base.relatedAspectId = field.relatedAspectId;
|
|
176
|
+
if (field.relatedLabelFieldId !== undefined)
|
|
177
|
+
base.relatedLabelFieldId = field.relatedLabelFieldId;
|
|
178
|
+
if (field.autoRelate !== undefined)
|
|
179
|
+
base.autoRelate = field.autoRelate;
|
|
180
|
+
}
|
|
164
181
|
return { [key]: base };
|
|
165
182
|
}
|
|
166
183
|
/**
|
|
@@ -213,6 +230,7 @@ export function serializeSystemFields(overrides) {
|
|
|
213
230
|
type: SYSTEM_FIELD_TAG_TO_TYPE[tag],
|
|
214
231
|
required: SYSTEM_FIELD_REQUIRED[key],
|
|
215
232
|
tags: [tag],
|
|
233
|
+
...(override.description !== undefined ? { description: override.description } : {}),
|
|
216
234
|
...(key === "status" ? { options: override.options } : {}),
|
|
217
235
|
};
|
|
218
236
|
return serializeField(field, key);
|
|
@@ -245,6 +263,9 @@ function validateAppOptions(opts) {
|
|
|
245
263
|
throw new Error(`defineApp "${opts.name}": namespace "${opts.namespace}" must be lowercase letters only (a–z).`);
|
|
246
264
|
}
|
|
247
265
|
}
|
|
266
|
+
function picklistOptionLabels(options) {
|
|
267
|
+
return options.map((option) => typeof option === "string" ? option : option.label);
|
|
268
|
+
}
|
|
248
269
|
export function defineApp(opts) {
|
|
249
270
|
validateAppOptions(opts);
|
|
250
271
|
const fieldEntries = Object.values(opts.fields);
|
|
@@ -276,9 +297,30 @@ export function defineApp(opts) {
|
|
|
276
297
|
name: field.name,
|
|
277
298
|
parent: refName,
|
|
278
299
|
fieldType: field.type,
|
|
300
|
+
...(field.options !== undefined ? { options: picklistOptionLabels(field.options) } : {}),
|
|
279
301
|
...(field.tags !== undefined ? { tags: field.tags } : {}),
|
|
280
302
|
};
|
|
281
303
|
}
|
|
304
|
+
// Every app has these platform-owned fields even when the authoring file
|
|
305
|
+
// omits systemFields (omission means "use the platform default", not
|
|
306
|
+
// "the field does not exist"). Keep them on the reference surface so
|
|
307
|
+
// automation authoring can always use app.fields.title/id/createdBy/etc.
|
|
308
|
+
// They remain absent from def().payload unless explicitly overridden.
|
|
309
|
+
for (const key of SYSTEM_FIELD_KEYS) {
|
|
310
|
+
if (fields[key] !== undefined)
|
|
311
|
+
continue;
|
|
312
|
+
const tag = SYSTEM_FIELD_TAG_BY_KEY[key];
|
|
313
|
+
const override = opts.systemFields?.[key];
|
|
314
|
+
fields[key] = {
|
|
315
|
+
__kind: "field",
|
|
316
|
+
refName: key,
|
|
317
|
+
name: override?.name ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key],
|
|
318
|
+
parent: refName,
|
|
319
|
+
fieldType: SYSTEM_FIELD_TAG_TO_TYPE[tag],
|
|
320
|
+
tags: [tag],
|
|
321
|
+
...(override !== undefined && "options" in override ? { options: picklistOptionLabels(override.options) } : {}),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
282
324
|
// readonlyFields are platform-managed (system) fields — merged into the ref's `fields` bag
|
|
283
325
|
// so other entities can reference them by typed handle, but excluded from `def()` payload.
|
|
284
326
|
if (opts.readonlyFields !== undefined) {
|
|
@@ -286,6 +328,10 @@ export function defineApp(opts) {
|
|
|
286
328
|
fields[bagKey] = { ...ref, refName: bagKey, parent: refName };
|
|
287
329
|
}
|
|
288
330
|
}
|
|
331
|
+
// `fields` is built loosely (`Record<string, FieldRef>`) since the loop
|
|
332
|
+
// above can't statically prove per-key literal `fieldType`s to the
|
|
333
|
+
// compiler — the runtime values are exactly right (each field's own
|
|
334
|
+
// `field.type` literal), so this cast just states what's already true.
|
|
289
335
|
return { __kind: kind, refName: refName, name: opts.name, fields };
|
|
290
336
|
},
|
|
291
337
|
def(refName) {
|
|
@@ -312,6 +358,7 @@ export function defineApp(opts) {
|
|
|
312
358
|
...(opts.layouts !== undefined ? { layouts: opts.layouts } : {}),
|
|
313
359
|
...(opts.listViews !== undefined ? { listViews: opts.listViews } : {}),
|
|
314
360
|
...(opts.viewOrder !== undefined ? { viewOrder: opts.viewOrder } : {}),
|
|
361
|
+
...(opts.accessPolicies !== undefined ? { accessPolicies: opts.accessPolicies } : {}),
|
|
315
362
|
};
|
|
316
363
|
return {
|
|
317
364
|
kind,
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { AppCategory, AppField, AppStage, AspectType } from "../../../core/types/app.js";
|
|
13
13
|
import type { DisplayBlock } from "../../../core/types/display-block.js";
|
|
14
|
+
import type { NormalizedAccessPolicy } from "../../access-policy/from-tf.js";
|
|
14
15
|
/**
|
|
15
16
|
* Keyed via `withUniqueKeys`, so two stages named "Review" become
|
|
16
17
|
* `review` / `review2` deterministically. The printer emits each
|
|
@@ -162,4 +163,6 @@ export interface NormalizedApp {
|
|
|
162
163
|
readonly listViews?: readonly NormalizedListView[];
|
|
163
164
|
/** Display order of `listViews`, by key (`elementum_managed_view_order`). */
|
|
164
165
|
readonly viewOrder?: readonly string[];
|
|
166
|
+
/** App/element-level sharing & row-level-security policies (`elementum_access_policy`), in export order. */
|
|
167
|
+
readonly accessPolicies?: readonly NormalizedAccessPolicy[];
|
|
165
168
|
}
|
|
@@ -20,4 +20,4 @@ export interface AppFromTfViewBlocks {
|
|
|
20
20
|
readonly listViewBlocks: readonly TfBlock[];
|
|
21
21
|
readonly managedViewOrderBlocks: readonly TfBlock[];
|
|
22
22
|
}
|
|
23
|
-
export declare function appFromTf(appBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: AppFromTfViewBlocks): AppFromTfResult;
|
|
23
|
+
export declare function appFromTf(appBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: AppFromTfViewBlocks, accessPolicyBlocks?: readonly TfBlock[]): AppFromTfResult;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { EntityTfError } from "../../engine/entity.js";
|
|
11
11
|
import { dataRefLabel, optionalString, plainObject } from "../../engine/pull/context.js";
|
|
12
12
|
import { snakeSlug, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
13
|
+
import { accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
13
14
|
import { fieldFromTf } from "../field/from-tf.js";
|
|
14
15
|
import { optionsFromTf } from "../field/options.js";
|
|
15
16
|
import { viewsFromTf } from "../view/from-tf.js";
|
|
@@ -34,7 +35,7 @@ const KNOWN_APP_ATTRS = new Set([
|
|
|
34
35
|
"status_field_description",
|
|
35
36
|
"comments_enabled",
|
|
36
37
|
]);
|
|
37
|
-
export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlocks: [], listViewBlocks: [], managedViewOrderBlocks: [] }) {
|
|
38
|
+
export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlocks: [], listViewBlocks: [], managedViewOrderBlocks: [] }, accessPolicyBlocks = []) {
|
|
38
39
|
const label = appBlock.label;
|
|
39
40
|
if (label === undefined || label === "") {
|
|
40
41
|
throw new EntityTfError("elementum_app block is missing its label");
|
|
@@ -55,11 +56,9 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
55
56
|
if (handle === undefined) {
|
|
56
57
|
ctx.diagnostics.push(`app "${label}": export stream carries no handle; derived "${label.toUpperCase()}"`);
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
59
|
+
const titleFieldDescription = optionalString(attrs, "title_field_description", `app "${label}"`, ctx);
|
|
60
|
+
const idFieldDescription = optionalString(attrs, "id_field_description", `app "${label}"`, ctx);
|
|
61
|
+
const statusFieldDescription = optionalString(attrs, "status_field_description", `app "${label}"`, ctx);
|
|
63
62
|
// Captured on the normalized shape (same as the wire normalize) but not yet
|
|
64
63
|
// authorable — defineApp has no slot and build won't re-emit it.
|
|
65
64
|
// Platform default is false. Only loud-warn when true — a rebuilt stream
|
|
@@ -99,14 +98,16 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
99
98
|
// --- System-field attributes → tagged NormalizedField entries.
|
|
100
99
|
const fields = [];
|
|
101
100
|
const titleName = optionalString(attrs, "title_field_name", `app "${label}"`, ctx);
|
|
102
|
-
if (titleName !== undefined)
|
|
103
|
-
fields.push(systemEntry("title", titleName, "TEXT", "TITLE"));
|
|
101
|
+
if (titleName !== undefined || titleFieldDescription !== undefined) {
|
|
102
|
+
fields.push(systemEntry("title", titleName ?? "Title", "TEXT", "TITLE", titleFieldDescription));
|
|
103
|
+
}
|
|
104
104
|
const idName = optionalString(attrs, "id_field_name", `app "${label}"`, ctx);
|
|
105
|
-
if (idName !== undefined)
|
|
106
|
-
fields.push(systemEntry("id", idName, "TEXT", "HANDLE"));
|
|
105
|
+
if (idName !== undefined || idFieldDescription !== undefined) {
|
|
106
|
+
fields.push(systemEntry("id", idName ?? "ID", "TEXT", "HANDLE", idFieldDescription));
|
|
107
|
+
}
|
|
107
108
|
const statusName = optionalString(attrs, "status_field_name", `app "${label}"`, ctx) ?? "Status";
|
|
108
109
|
const statusOptions = optionsFromTf(attrs["status_options"], `app "${label}" status_options`, ctx);
|
|
109
|
-
if (statusName !== "Status" || statusOptions !== undefined) {
|
|
110
|
+
if (statusName !== "Status" || statusOptions !== undefined || statusFieldDescription !== undefined) {
|
|
110
111
|
fields.push({
|
|
111
112
|
key: "status",
|
|
112
113
|
field: {
|
|
@@ -114,6 +115,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
114
115
|
name: statusName,
|
|
115
116
|
type: "PICKLIST",
|
|
116
117
|
tags: ["STATUS"],
|
|
118
|
+
...(statusFieldDescription !== undefined && { description: statusFieldDescription }),
|
|
117
119
|
...(statusOptions !== undefined && { options: statusOptions }),
|
|
118
120
|
},
|
|
119
121
|
});
|
|
@@ -142,7 +144,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
142
144
|
ctx.diagnostics.push(`app "${label}": stages is not a list; dropped`);
|
|
143
145
|
}
|
|
144
146
|
// --- Custom field resources (entities/field).
|
|
145
|
-
const owner = { type: APP_RESOURCE_TYPE, label };
|
|
147
|
+
const owner = { type: APP_RESOURCE_TYPE, label, scope: "app" };
|
|
146
148
|
for (const block of fieldBlocks) {
|
|
147
149
|
const entry = fieldFromTf(block, owner, ctx);
|
|
148
150
|
if (entry !== undefined)
|
|
@@ -153,7 +155,21 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
153
155
|
ctx.diagnostics.push(`app "${label}": no import block in the stream — adoption has no identity to bind`);
|
|
154
156
|
}
|
|
155
157
|
// --- View pass: layouts / list views / view order (entities/view), owner passed in.
|
|
156
|
-
const { layouts, listViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.managedViewOrderBlocks, { type: APP_RESOURCE_TYPE, label, stageKeys: new Set(stages.map((stage) => stage.key)) }, ctx);
|
|
158
|
+
const { layouts, listViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.managedViewOrderBlocks, { type: APP_RESOURCE_TYPE, label, ownerTfLabel: refName, scope: "app", stageKeys: new Set(stages.map((stage) => stage.key)) }, ctx);
|
|
159
|
+
// --- Access policies (entities/access-policy), owner passed in.
|
|
160
|
+
const accessPolicyOwner = {
|
|
161
|
+
type: APP_RESOURCE_TYPE,
|
|
162
|
+
label,
|
|
163
|
+
ownerRefName: refName,
|
|
164
|
+
ownerTfLabel: label,
|
|
165
|
+
scope: "app",
|
|
166
|
+
};
|
|
167
|
+
const accessPolicies = [];
|
|
168
|
+
for (const block of accessPolicyBlocks) {
|
|
169
|
+
const entry = accessPolicyFromTf(block, accessPolicyOwner, ctx);
|
|
170
|
+
if (entry !== undefined)
|
|
171
|
+
accessPolicies.push(entry);
|
|
172
|
+
}
|
|
157
173
|
const app = {
|
|
158
174
|
id: appId ?? "",
|
|
159
175
|
name,
|
|
@@ -172,9 +188,10 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
172
188
|
...(layouts.length > 0 && { layouts }),
|
|
173
189
|
...(listViews.length > 0 && { listViews }),
|
|
174
190
|
...(viewOrder !== undefined && { viewOrder }),
|
|
191
|
+
...(accessPolicies.length > 0 && { accessPolicies }),
|
|
175
192
|
};
|
|
176
193
|
return { app, ...(cloudLinkHandle !== undefined && { cloudLinkHandle }) };
|
|
177
194
|
}
|
|
178
|
-
function systemEntry(key, name, type, tag) {
|
|
179
|
-
return { key, field: { id: "", name, type, tags: [tag] } };
|
|
195
|
+
function systemEntry(key, name, type, tag, description) {
|
|
196
|
+
return { key, field: { id: "", name, type, tags: [tag], ...(description !== undefined && { description }) } };
|
|
180
197
|
}
|
|
@@ -7,5 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { defineApp, type AppCategory, type AppCloudOptions, type AppField, type AppPicklistConfig, type AppPicklistDynamicConfig, type AppV2Options, type PicklistOption, } from "./build.js";
|
|
9
9
|
export { type DisplayBlock } from "./display-blocks.js";
|
|
10
|
-
export { attachmentField, booleanField, dateField, dateTimeField, decimalField, groupField, htmlField, jsonField, multiPicklistField, numberField, picklistField, textField, userField, type BaseFieldOptions, type NumericFieldOptions, type PicklistFieldOptions, type TextFieldOptions, } from "../field/build.js";
|
|
10
|
+
export { attachmentField, booleanField, dateField, dateTimeField, decimalField, groupField, htmlField, jsonField, multiPicklistField, numberField, picklistField, relationField, textField, userField, type BaseFieldOptions, type NumericFieldOptions, type PicklistFieldOptions, type RelationFieldOptions, type TextFieldOptions, } from "../field/build.js";
|
|
11
11
|
export { calc, field, type Expr, type ExprType } from "../field/calc.js";
|
|
12
|
+
export { type AccessPolicyGroupRef, type AccessPolicyOptions, type AccessPolicyUserRef } from "../access-policy/build.js";
|
|
13
|
+
export * as accessPolicyFilter from "../access-policy/filter.js";
|
|
14
|
+
export { type AccessPolicyFilter, type AccessPolicyFilterValue, type CurrentUserFilterValue } from "../access-policy/filter.js";
|
|
@@ -6,5 +6,6 @@
|
|
|
6
6
|
* dedicated builders despite sharing this module's field/print internals.
|
|
7
7
|
*/
|
|
8
8
|
export { defineApp, } from "./build.js";
|
|
9
|
-
export { attachmentField, booleanField, dateField, dateTimeField, decimalField, groupField, htmlField, jsonField, multiPicklistField, numberField, picklistField, textField, userField, } from "../field/build.js";
|
|
9
|
+
export { attachmentField, booleanField, dateField, dateTimeField, decimalField, groupField, htmlField, jsonField, multiPicklistField, numberField, picklistField, relationField, textField, userField, } from "../field/build.js";
|
|
10
10
|
export { calc, field } from "../field/calc.js";
|
|
11
|
+
export * as accessPolicyFilter from "../access-policy/filter.js";
|
|
@@ -17,11 +17,12 @@ function extractAppStreamRoot(stream, ctx) {
|
|
|
17
17
|
const layoutBlocks = viewBlocks.filter((b) => b.type === LAYOUT_RESOURCE_TYPE);
|
|
18
18
|
const listViewBlocks = viewBlocks.filter((b) => b.type === LIST_VIEW_RESOURCE_TYPE);
|
|
19
19
|
const managedViewOrderBlocks = stream.byKind.get("managed-view-order") ?? [];
|
|
20
|
+
const accessPolicyBlocks = stream.byKind.get("access-policy") ?? [];
|
|
20
21
|
const { app, cloudLinkHandle } = appFromTf(appBlocks[0], fieldBlocks, ctx, {
|
|
21
22
|
layoutBlocks,
|
|
22
23
|
listViewBlocks,
|
|
23
24
|
managedViewOrderBlocks,
|
|
24
|
-
});
|
|
25
|
+
}, accessPolicyBlocks);
|
|
25
26
|
return {
|
|
26
27
|
instance: app,
|
|
27
28
|
...(cloudLinkHandle !== undefined && { cloudLinkHandle }),
|
|
@@ -42,11 +43,17 @@ export const appModule = {
|
|
|
42
43
|
extractStreamRoot: extractAppStreamRoot,
|
|
43
44
|
toTf: (entity, ctx) => {
|
|
44
45
|
const result = appToTf(entity, {
|
|
46
|
+
appRefName: ctx.appRefName,
|
|
45
47
|
appTfLabel: ctx.appTfLabel,
|
|
46
48
|
orgRefs: ctx.orgRefs,
|
|
47
49
|
diagnostics: ctx.diagnostics,
|
|
48
50
|
});
|
|
49
|
-
return {
|
|
51
|
+
return {
|
|
52
|
+
blocks: result.blocks,
|
|
53
|
+
fieldAddresses: result.fieldAddresses,
|
|
54
|
+
fieldNames: result.fieldNames,
|
|
55
|
+
fieldMetadata: result.fieldMetadata,
|
|
56
|
+
};
|
|
50
57
|
},
|
|
51
58
|
appendLocals: (localsAttrs, ctx) => {
|
|
52
59
|
appendAppLocals(localsAttrs, ctx.appTfLabel);
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* never silent, never thrown (plan §4.3).
|
|
16
16
|
*/
|
|
17
17
|
import type { ToTfContext } from "../../engine/build/context.js";
|
|
18
|
+
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
18
19
|
import { type DeployableEntity } from "../../engine/entity.js";
|
|
19
20
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
20
21
|
/** System-field tags that fold into the app resource instead of emitting a field resource. */
|
|
@@ -23,6 +24,10 @@ export interface AppToTfResult {
|
|
|
23
24
|
readonly blocks: readonly TfBlock[];
|
|
24
25
|
/** bag key → terraform address, for the app catalog / locals bookkeeping. */
|
|
25
26
|
readonly fieldAddresses: ReadonlyMap<string, string>;
|
|
27
|
+
/** bag key → platform display name, used to render portable automation refs. */
|
|
28
|
+
readonly fieldNames: ReadonlyMap<string, string>;
|
|
29
|
+
/** bag key → type/options metadata, used by automation switch filters. */
|
|
30
|
+
readonly fieldMetadata: ReadonlyMap<string, BuildFieldMetadata>;
|
|
26
31
|
}
|
|
27
32
|
/** `elementum_app` + one field resource per custom field, in ei's dialect. */
|
|
28
33
|
export declare function appToTf(entity: DeployableEntity, ctx: ToTfContext): AppToTfResult;
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { EntityTfError } from "../../engine/entity.js";
|
|
18
18
|
import { expr, snakeSlug } from "../../engine/tf/index.js";
|
|
19
|
+
import { accessPolicyToTf } from "../access-policy/to-tf.js";
|
|
19
20
|
import { picklistLabel } from "../field/options.js";
|
|
20
21
|
import { fieldToTf } from "../field/to-tf.js";
|
|
22
|
+
import { SUB_TYPE_BY_TYPE_KEY } from "../field/types.js";
|
|
21
23
|
import { CATEGORY_ORG_BAG } from "../org/category.js";
|
|
22
24
|
import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
|
|
23
25
|
import { viewToTf } from "../view/to-tf.js";
|
|
@@ -98,6 +100,8 @@ export function appToTf(entity, ctx) {
|
|
|
98
100
|
// --- Field pass: fold system-tagged fields, emit one resource per custom field.
|
|
99
101
|
const blocks = [];
|
|
100
102
|
const fieldAddresses = new Map();
|
|
103
|
+
const fieldMetadata = new Map();
|
|
104
|
+
const fieldNames = new Map();
|
|
101
105
|
let statusOptions;
|
|
102
106
|
let stages;
|
|
103
107
|
const objectId = expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]);
|
|
@@ -107,6 +111,20 @@ export function appToTf(entity, ctx) {
|
|
|
107
111
|
continue;
|
|
108
112
|
const inner = fieldEntry[typeKey];
|
|
109
113
|
const name = inner.name ?? "";
|
|
114
|
+
const fieldKey = inner.__refName ?? snakeSlug(name);
|
|
115
|
+
const subType = SUB_TYPE_BY_TYPE_KEY.get(typeKey);
|
|
116
|
+
if (fieldKey !== "" && name !== "" && subType !== undefined) {
|
|
117
|
+
fieldMetadata.set(fieldKey, {
|
|
118
|
+
name,
|
|
119
|
+
fieldType: subType.authoringType,
|
|
120
|
+
...(inner.picklistValues !== undefined
|
|
121
|
+
? { options: inner.picklistValues.map((value) => picklistLabel(value)) }
|
|
122
|
+
: {}),
|
|
123
|
+
...(inner.tags !== undefined ? { tags: inner.tags } : {}),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (fieldKey !== "" && name !== "")
|
|
127
|
+
fieldNames.set(fieldKey, name);
|
|
110
128
|
const systemTag = inner.tags?.find((tag) => SYSTEM_FIELD_TAGS.has(tag));
|
|
111
129
|
if (systemTag !== undefined) {
|
|
112
130
|
switch (systemTag) {
|
|
@@ -159,7 +177,7 @@ export function appToTf(entity, ctx) {
|
|
|
159
177
|
continue;
|
|
160
178
|
}
|
|
161
179
|
// Custom field → one `elementum_*_field` resource (entities/field).
|
|
162
|
-
const field = fieldToTf(typeKey, inner, { objectId, diagnostics: ctx.diagnostics });
|
|
180
|
+
const field = fieldToTf(typeKey, inner, { ownerTfLabel: ctx.appTfLabel, objectId, diagnostics: ctx.diagnostics, orgRefs: ctx.orgRefs });
|
|
163
181
|
if (field === undefined)
|
|
164
182
|
continue;
|
|
165
183
|
blocks.push(field.block);
|
|
@@ -172,12 +190,23 @@ export function appToTf(entity, ctx) {
|
|
|
172
190
|
appAttrs["stages"] = stages ?? [];
|
|
173
191
|
// --- View pass: layouts / list views / view order (entities/view), owner passed in.
|
|
174
192
|
const { blocks: viewBlocks } = viewToTf(payload.layouts, payload.listViews, payload.viewOrder, {
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
ownerTfLabel: ctx.appTfLabel,
|
|
194
|
+
aspectName: payload.name ?? "",
|
|
177
195
|
objectId,
|
|
178
196
|
diagnostics: ctx.diagnostics,
|
|
179
197
|
});
|
|
180
198
|
blocks.push(...viewBlocks);
|
|
199
|
+
// --- Access policy pass (entities/access-policy), owner passed in.
|
|
200
|
+
for (const [index, entry] of (payload.accessPolicies ?? []).entries()) {
|
|
201
|
+
const { block } = accessPolicyToTf(entry, index, {
|
|
202
|
+
ownerTfLabel: ctx.appTfLabel,
|
|
203
|
+
scope: "app",
|
|
204
|
+
objectId,
|
|
205
|
+
orgRefs: ctx.orgRefs,
|
|
206
|
+
diagnostics: ctx.diagnostics,
|
|
207
|
+
});
|
|
208
|
+
blocks.push(block);
|
|
209
|
+
}
|
|
181
210
|
blocks.unshift({ kind: "resource", type: APP_RESOURCE_TYPE, label: ctx.appTfLabel, attrs: appAttrs });
|
|
182
|
-
return { blocks, fieldAddresses };
|
|
211
|
+
return { blocks, fieldAddresses, fieldNames, fieldMetadata };
|
|
183
212
|
}
|