@elementumai/edk 0.8.0-preview.11 → 0.8.2-alpha.5
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 +510 -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 +83 -4
- package/dist-sdk/src/catalog/from-authoring.js +19 -2
- 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 +134 -50
- 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 +18 -0
- package/dist-sdk/src/catalog/types.d.ts +75 -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 +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +58 -0
- package/dist-sdk/src/engine/build/context.js +11 -1
- 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 +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +54 -0
- package/dist-sdk/src/engine/tf/labels.js +75 -0
- package/dist-sdk/src/engine/tf/parse.d.ts +15 -0
- package/dist-sdk/src/engine/tf/parse.js +162 -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 +66 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +187 -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 +43 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +164 -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/build.d.ts +2 -0
- package/dist-sdk/src/entities/agent/build.js +1 -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 +257 -32
- package/dist-sdk/src/entities/agent/from-tf.d.ts +29 -9
- package/dist-sdk/src/entities/agent/from-tf.js +146 -19
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +14 -4
- package/dist-sdk/src/entities/agent/to-tf.d.ts +46 -1
- package/dist-sdk/src/entities/agent/to-tf.js +160 -14
- 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-a2a-skill/from-tf.d.ts +17 -0
- package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +64 -0
- package/dist-sdk/src/entities/agent-a2a-skill/module.d.ts +4 -0
- package/dist-sdk/src/entities/agent-a2a-skill/module.js +14 -0
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.d.ts +40 -0
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +47 -0
- 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 +11 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +176 -30
- 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 +91 -13
- package/dist-sdk/src/entities/app/build.js +63 -5
- 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 -22
- 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 +10 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
- package/dist-sdk/src/entities/app/to-tf.js +45 -4
- package/dist-sdk/src/entities/automation/build.d.ts +57 -13
- package/dist-sdk/src/entities/automation/build.js +62 -42
- 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 +206 -47
- package/dist-sdk/src/entities/automation/filter.d.ts +37 -3
- package/dist-sdk/src/entities/automation/filter.js +54 -3
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
- package/dist-sdk/src/entities/automation/from-tf.js +1344 -222
- 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 +1291 -230
- 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 +44 -13
- package/dist-sdk/src/entities/element/build.js +45 -3
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/from-tf.js +28 -14
- 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 +4 -1
- package/dist-sdk/src/entities/element/to-tf.js +26 -3
- package/dist-sdk/src/entities/field/build.d.ts +61 -14
- 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 +46 -11
- package/dist-sdk/src/entities/field/to-tf.js +166 -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 +59 -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 +46 -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 +128 -11
- 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 +7 -1
- package/dist-sdk/src/entities/skill/to-tf.d.ts +26 -0
- package/dist-sdk/src/entities/skill/to-tf.js +65 -4
- package/dist-sdk/src/entities/skill/tools.d.ts +37 -8
- package/dist-sdk/src/entities/skill/tools.js +43 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +34 -4
- package/dist-sdk/src/entities/skill-tool/from-tf.js +128 -18
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +13 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +164 -25
- package/dist-sdk/src/entities/skill-tool/types.d.ts +5 -7
- package/dist-sdk/src/entities/skill-tool/types.js +47 -11
- 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 +39 -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 +8 -1
- package/dist-sdk/src/graph/types.d.ts +98 -4
- package/package.json +49 -16
- 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,22 @@ 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 — the related object/field
|
|
102
|
+
* (`elementum_relation_field.related_object_id`/`related_label_field_id`).
|
|
103
|
+
* Accepts a catalog token (`AspectRef`/`FieldRef`) or a raw platform id. A
|
|
104
|
+
* token naming a SIBLING app/element authored in the same build resolves
|
|
105
|
+
* to a direct resource reference and does NOT need to already exist on
|
|
106
|
+
* the platform; only a token naming something genuinely outside this
|
|
107
|
+
* workspace needs that. Pulling a RELATION field back always yields raw
|
|
108
|
+
* ids: a non-recursive export never discovers the related object's own
|
|
109
|
+
* identity, so there's nothing to resolve a token against on the extract
|
|
110
|
+
* side.
|
|
111
|
+
*/
|
|
112
|
+
readonly relatedObject?: AspectRef | string;
|
|
113
|
+
readonly relatedLabelField?: FieldRef | string;
|
|
114
|
+
/** `RELATION` only. Defaults to `true` on the platform. */
|
|
115
|
+
readonly autoRelate?: boolean;
|
|
97
116
|
}
|
|
98
117
|
/** A picklist option with optional dependent-dropdown parent links. */
|
|
99
118
|
export interface PicklistOption {
|
|
@@ -126,17 +145,21 @@ export interface AppCloudOptions {
|
|
|
126
145
|
}
|
|
127
146
|
/**
|
|
128
147
|
* 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
|
-
*
|
|
148
|
+
* genuinely allows overriding is authorable: the display name, an optional
|
|
149
|
+
* description (title/id/status only — the app resource has no
|
|
150
|
+
* `*_field_description` attribute for the others), and, for the status/stage
|
|
151
|
+
* picklists, the option set. `type` and the required/showOnCreate booleans
|
|
152
|
+
* are fixed by the platform's per-tag config and deliberately have no
|
|
153
|
+
* authoring slot.
|
|
133
154
|
*/
|
|
134
155
|
export interface AppSystemFieldOverride {
|
|
135
156
|
readonly name: string;
|
|
157
|
+
readonly description?: string;
|
|
136
158
|
}
|
|
137
159
|
/** A system-picklist override (status/stage): display name + option set. */
|
|
138
160
|
export interface AppSystemPicklistOverride {
|
|
139
161
|
readonly name: string;
|
|
162
|
+
readonly description?: string;
|
|
140
163
|
readonly options: readonly (string | PicklistOption)[];
|
|
141
164
|
}
|
|
142
165
|
/**
|
|
@@ -212,7 +235,7 @@ export interface AppListView {
|
|
|
212
235
|
/** Opaque JSON pass-through — see `filter`. */
|
|
213
236
|
readonly sort?: unknown;
|
|
214
237
|
}
|
|
215
|
-
export interface AppV2Options extends EntityDeployOptions {
|
|
238
|
+
export interface AppV2Options<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> extends EntityDeployOptions {
|
|
216
239
|
readonly name: string;
|
|
217
240
|
readonly category: AppCategory;
|
|
218
241
|
readonly namespace?: string;
|
|
@@ -236,8 +259,10 @@ export interface AppV2Options extends EntityDeployOptions {
|
|
|
236
259
|
readonly cloudLink?: CloudLinkRef;
|
|
237
260
|
/** Cloud-backing options (Snowflake-only); applied on create only. */
|
|
238
261
|
readonly cloudOptions?: AppCloudOptions;
|
|
262
|
+
/** Enables the record-view comments panel. Platform default is `false`. */
|
|
263
|
+
readonly commentsEnabled?: boolean;
|
|
239
264
|
/** Fields keyed by ref name. At least one required by the compose API. */
|
|
240
|
-
readonly fields:
|
|
265
|
+
readonly fields: F;
|
|
241
266
|
/**
|
|
242
267
|
* Overrides for the platform's auto-provisioned system fields (ID, Title,
|
|
243
268
|
* Status, Stage, and the audit fields). Omit entirely when the app keeps
|
|
@@ -251,7 +276,7 @@ export interface AppV2Options extends EntityDeployOptions {
|
|
|
251
276
|
* reference them by typed handle (e.g. `app.fields.title`), but are **never included in the
|
|
252
277
|
* deploy payload** (the platform owns them; sending them on compose would be rejected).
|
|
253
278
|
*/
|
|
254
|
-
readonly readonlyFields?:
|
|
279
|
+
readonly readonlyFields?: R;
|
|
255
280
|
/** Record-view (LAYOUT surface) display blocks. */
|
|
256
281
|
readonly displayBlocks?: readonly DisplayBlock[];
|
|
257
282
|
/** New-record form (CREATE surface) display blocks. */
|
|
@@ -267,6 +292,12 @@ export interface AppV2Options extends EntityDeployOptions {
|
|
|
267
292
|
readonly listViews?: Readonly<Record<string, AppListView>>;
|
|
268
293
|
/** Display order of `listViews` (by key). Defaults to declaration order. */
|
|
269
294
|
readonly viewOrder?: readonly string[];
|
|
295
|
+
/**
|
|
296
|
+
* App-level sharing & row-level-security policies (`elementum_access_policy`), in declaration order.
|
|
297
|
+
* Creating the app also has the platform mint a separate creator policy
|
|
298
|
+
* (the creating user, typically `whereTrue`) that is not authored here.
|
|
299
|
+
*/
|
|
300
|
+
readonly accessPolicies?: readonly AccessPolicyOptions[];
|
|
270
301
|
}
|
|
271
302
|
/**
|
|
272
303
|
* Serialize an authored field to its `AspectFieldInput` wire shape — shared
|
|
@@ -297,9 +328,40 @@ export declare function assertNoSystemKeyCollision(builder: string, name: string
|
|
|
297
328
|
* always carry their option set; the other keys are name-only.
|
|
298
329
|
*/
|
|
299
330
|
export declare function serializeSystemFields(overrides: AppSystemFields | undefined): AspectFieldInput[];
|
|
300
|
-
/**
|
|
301
|
-
|
|
302
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Per-field `FieldRef`s for an authored `fields:` bag, keyed exactly like it,
|
|
333
|
+
* each carrying its own literal `fieldType` (not the widened
|
|
334
|
+
* `WorkflowFieldType` union) — this is what lets `defineApp(...).ref()` serve
|
|
335
|
+
* as the catalog's live source for fields (`src/catalog/render.ts`'s
|
|
336
|
+
* `ownFile`) without losing the per-field type precision `RecordShape`
|
|
337
|
+
* (`entities/field/record-shape.ts`) needs to discriminate value types.
|
|
338
|
+
*/
|
|
339
|
+
export type AppFieldRefs<F extends Record<string, AppField>> = {
|
|
340
|
+
readonly [K in keyof F]: FieldRef & {
|
|
341
|
+
readonly fieldType: F[K]["type"];
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* An app's reference surface: identity plus its fields (the only bag other
|
|
346
|
+
* entities may point at). Generic over the authored `fields:` bag (`F`) and
|
|
347
|
+
* `readonlyFields:` bag (`R`) so `app.ref(name).fields.priority.fieldType`
|
|
348
|
+
* narrows to its literal (e.g. `"PICKLIST"`); the platform-owned system
|
|
349
|
+
* fields round out the bag via `Record<SystemFieldKey, FieldRef>` — a finite
|
|
350
|
+
* union of literal keys, deliberately NOT a wide `Record<string, FieldRef>`.
|
|
351
|
+
*
|
|
352
|
+
* That distinction is load-bearing, not style: a wide `string`-keyed index
|
|
353
|
+
* signature anywhere in this intersection poisons `RecordShape`
|
|
354
|
+
* (`entities/field/record-shape.ts`) when `DeepRef`
|
|
355
|
+
* (`entities/shared/context.ts`) re-maps its keys a second time for
|
|
356
|
+
* `ctx.trigger.record`/`ctx.tasks.<t>.record` drilling — every field
|
|
357
|
+
* collapses to `Ref<string>`, losing e.g. a picklist's `.id`/`.label`. Found
|
|
358
|
+
* and verified via isolated repro before this fix landed; `R`'s default is
|
|
359
|
+
* `Record<never, never>` (a literal empty object, no index signature) for
|
|
360
|
+
* the same reason — `Record<string, never>` would reintroduce it even when
|
|
361
|
+
* no `readonlyFields` are declared.
|
|
362
|
+
*/
|
|
363
|
+
export type AppRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> = AspectRef & {
|
|
364
|
+
readonly fields: AppFieldRefs<F> & Record<SystemFieldKey, FieldRef> & R;
|
|
303
365
|
};
|
|
304
366
|
/**
|
|
305
367
|
* The configured result of `defineApp` — its reference surface (`ref()`) and
|
|
@@ -311,8 +373,24 @@ export type AppRef = AspectRef & {
|
|
|
311
373
|
* inside `defineApp({...})` would be the same redundant property the rest of
|
|
312
374
|
* the system avoids, just one level up.
|
|
313
375
|
*/
|
|
314
|
-
export interface AppConfigured {
|
|
315
|
-
ref(refName: string): AppRef
|
|
376
|
+
export interface AppConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> {
|
|
377
|
+
ref(refName: string): AppRef<F, R>;
|
|
316
378
|
def(refName: string): DeployableEntity;
|
|
317
379
|
}
|
|
318
|
-
|
|
380
|
+
/**
|
|
381
|
+
* Build a v2 app entity: org-owned, compose-body payload. Exposes
|
|
382
|
+
* `.ref(refName)` and `.def(refName)`.
|
|
383
|
+
*
|
|
384
|
+
* Elements author through `defineElement` (`@elementumai/edk/elements`,
|
|
385
|
+
* `src/elements/build.ts`) instead — a dedicated builder/printer, since a
|
|
386
|
+
* *linked* element's cloud mapping (Cloud Link + Database + Schema + Table,
|
|
387
|
+
* vs. a *standard* element's Elementum-managed table) has no equivalent on an
|
|
388
|
+
* app. `defineApp`'s `type` no longer accepts `"ELEMENT"`.
|
|
389
|
+
*/
|
|
390
|
+
/**
|
|
391
|
+
* The GraphQL API constrains an aspect handle to letters only, either case, no
|
|
392
|
+
* digits (ultron aspects schema: `handle: String @NotEmpty @Pattern(regexp:
|
|
393
|
+
* "[a-zA-Z]*")`). Mirror that rule here rather than inventing a stricter one.
|
|
394
|
+
*/
|
|
395
|
+
export declare const APP_HANDLE_RE: RegExp;
|
|
396
|
+
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.relatedObject !== undefined)
|
|
175
|
+
base.relatedObject = field.relatedObject;
|
|
176
|
+
if (field.relatedLabelField !== undefined)
|
|
177
|
+
base.relatedLabelField = field.relatedLabelField;
|
|
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);
|
|
@@ -228,23 +246,32 @@ export function serializeSystemFields(overrides) {
|
|
|
228
246
|
* vs. a *standard* element's Elementum-managed table) has no equivalent on an
|
|
229
247
|
* app. `defineApp`'s `type` no longer accepts `"ELEMENT"`.
|
|
230
248
|
*/
|
|
249
|
+
/**
|
|
250
|
+
* The GraphQL API constrains an aspect handle to letters only, either case, no
|
|
251
|
+
* digits (ultron aspects schema: `handle: String @NotEmpty @Pattern(regexp:
|
|
252
|
+
* "[a-zA-Z]*")`). Mirror that rule here rather than inventing a stricter one.
|
|
253
|
+
*/
|
|
254
|
+
export const APP_HANDLE_RE = /^[a-zA-Z]+$/;
|
|
231
255
|
/**
|
|
232
256
|
* Client-side validation for `defineApp` — the authoring-time home for app
|
|
233
257
|
* validation rules, so a malformed definition fails at define time rather than
|
|
234
258
|
* as an opaque platform error during apply. App-specific on purpose: elements
|
|
235
259
|
* carry their own equivalent in `src/elements/build.ts`.
|
|
236
260
|
*
|
|
237
|
-
* - `handle` —
|
|
261
|
+
* - `handle` — letters only (a–z, A–Z), when provided (it's optional)
|
|
238
262
|
* - `namespace` — lowercase letters only (a–z), when provided
|
|
239
263
|
*/
|
|
240
264
|
function validateAppOptions(opts) {
|
|
241
|
-
if (opts.handle !== undefined &&
|
|
242
|
-
throw new Error(`defineApp "${opts.name}": handle "${opts.handle}" must
|
|
265
|
+
if (opts.handle !== undefined && !APP_HANDLE_RE.test(opts.handle)) {
|
|
266
|
+
throw new Error(`defineApp "${opts.name}": handle "${opts.handle}" must contain only letters (a–z, A–Z).`);
|
|
243
267
|
}
|
|
244
268
|
if (opts.namespace !== undefined && !/^[a-z]+$/.test(opts.namespace)) {
|
|
245
269
|
throw new Error(`defineApp "${opts.name}": namespace "${opts.namespace}" must be lowercase letters only (a–z).`);
|
|
246
270
|
}
|
|
247
271
|
}
|
|
272
|
+
function picklistOptionLabels(options) {
|
|
273
|
+
return options.map((option) => typeof option === "string" ? option : option.label);
|
|
274
|
+
}
|
|
248
275
|
export function defineApp(opts) {
|
|
249
276
|
validateAppOptions(opts);
|
|
250
277
|
const fieldEntries = Object.values(opts.fields);
|
|
@@ -275,17 +302,46 @@ export function defineApp(opts) {
|
|
|
275
302
|
refName: bagKey,
|
|
276
303
|
name: field.name,
|
|
277
304
|
parent: refName,
|
|
305
|
+
parentKind: kind,
|
|
306
|
+
parentName: opts.name,
|
|
278
307
|
fieldType: field.type,
|
|
308
|
+
...(field.options !== undefined ? { options: picklistOptionLabels(field.options) } : {}),
|
|
279
309
|
...(field.tags !== undefined ? { tags: field.tags } : {}),
|
|
280
310
|
};
|
|
281
311
|
}
|
|
312
|
+
// Every app has these platform-owned fields even when the authoring file
|
|
313
|
+
// omits systemFields (omission means "use the platform default", not
|
|
314
|
+
// "the field does not exist"). Keep them on the reference surface so
|
|
315
|
+
// automation authoring can always use app.fields.title/id/createdBy/etc.
|
|
316
|
+
// They remain absent from def().payload unless explicitly overridden.
|
|
317
|
+
for (const key of SYSTEM_FIELD_KEYS) {
|
|
318
|
+
if (fields[key] !== undefined)
|
|
319
|
+
continue;
|
|
320
|
+
const tag = SYSTEM_FIELD_TAG_BY_KEY[key];
|
|
321
|
+
const override = opts.systemFields?.[key];
|
|
322
|
+
fields[key] = {
|
|
323
|
+
__kind: "field",
|
|
324
|
+
refName: key,
|
|
325
|
+
name: override?.name ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key],
|
|
326
|
+
parent: refName,
|
|
327
|
+
parentKind: kind,
|
|
328
|
+
parentName: opts.name,
|
|
329
|
+
fieldType: SYSTEM_FIELD_TAG_TO_TYPE[tag],
|
|
330
|
+
tags: [tag],
|
|
331
|
+
...(override !== undefined && "options" in override ? { options: picklistOptionLabels(override.options) } : {}),
|
|
332
|
+
};
|
|
333
|
+
}
|
|
282
334
|
// readonlyFields are platform-managed (system) fields — merged into the ref's `fields` bag
|
|
283
335
|
// so other entities can reference them by typed handle, but excluded from `def()` payload.
|
|
284
336
|
if (opts.readonlyFields !== undefined) {
|
|
285
337
|
for (const [bagKey, ref] of Object.entries(opts.readonlyFields)) {
|
|
286
|
-
fields[bagKey] = { ...ref, refName: bagKey, parent: refName };
|
|
338
|
+
fields[bagKey] = { ...ref, refName: bagKey, parent: refName, parentKind: kind, parentName: opts.name };
|
|
287
339
|
}
|
|
288
340
|
}
|
|
341
|
+
// `fields` is built loosely (`Record<string, FieldRef>`) since the loop
|
|
342
|
+
// above can't statically prove per-key literal `fieldType`s to the
|
|
343
|
+
// compiler — the runtime values are exactly right (each field's own
|
|
344
|
+
// `field.type` literal), so this cast just states what's already true.
|
|
289
345
|
return { __kind: kind, refName: refName, name: opts.name, fields };
|
|
290
346
|
},
|
|
291
347
|
def(refName) {
|
|
@@ -303,6 +359,7 @@ export function defineApp(opts) {
|
|
|
303
359
|
...(opts.color !== undefined ? { color: opts.color } : {}),
|
|
304
360
|
...(opts.cloudLink !== undefined ? { cloudLinkId: opts.cloudLink } : {}), // token → id at deploy
|
|
305
361
|
...(opts.cloudOptions !== undefined ? { cloudOptions: opts.cloudOptions } : {}),
|
|
362
|
+
...(opts.commentsEnabled !== undefined ? { commentsEnabled: opts.commentsEnabled } : {}),
|
|
306
363
|
fields: [
|
|
307
364
|
...serializeSystemFields(opts.systemFields),
|
|
308
365
|
...Object.entries(opts.fields).map(([bagKey, field]) => serializeField(field, bagKey)),
|
|
@@ -312,6 +369,7 @@ export function defineApp(opts) {
|
|
|
312
369
|
...(opts.layouts !== undefined ? { layouts: opts.layouts } : {}),
|
|
313
370
|
...(opts.listViews !== undefined ? { listViews: opts.listViews } : {}),
|
|
314
371
|
...(opts.viewOrder !== undefined ? { viewOrder: opts.viewOrder } : {}),
|
|
372
|
+
...(opts.accessPolicies !== undefined ? { accessPolicies: opts.accessPolicies } : {}),
|
|
315
373
|
};
|
|
316
374
|
return {
|
|
317
375
|
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,19 +56,10 @@ 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
|
-
}
|
|
63
|
-
// Captured on the normalized shape (same as the wire normalize) but not yet
|
|
64
|
-
// authorable — defineApp has no slot and build won't re-emit it.
|
|
65
|
-
// Platform default is false. Only loud-warn when true — a rebuilt stream
|
|
66
|
-
// would drop a real enablement (no authoring slot yet).
|
|
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);
|
|
67
62
|
const commentsEnabled = typeof attrs["comments_enabled"] === "boolean" ? attrs["comments_enabled"] : undefined;
|
|
68
|
-
if (commentsEnabled === true) {
|
|
69
|
-
ctx.diagnostics.push(`app "${label}": comments_enabled has no authoring slot yet; a rebuilt stream will omit it`);
|
|
70
|
-
}
|
|
71
63
|
// --- Org data references (category / cloud link).
|
|
72
64
|
let category;
|
|
73
65
|
if (attrs["category_id"] !== undefined) {
|
|
@@ -99,14 +91,16 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
99
91
|
// --- System-field attributes → tagged NormalizedField entries.
|
|
100
92
|
const fields = [];
|
|
101
93
|
const titleName = optionalString(attrs, "title_field_name", `app "${label}"`, ctx);
|
|
102
|
-
if (titleName !== undefined)
|
|
103
|
-
fields.push(systemEntry("title", titleName, "TEXT", "TITLE"));
|
|
94
|
+
if (titleName !== undefined || titleFieldDescription !== undefined) {
|
|
95
|
+
fields.push(systemEntry("title", titleName ?? "Title", "TEXT", "TITLE", titleFieldDescription));
|
|
96
|
+
}
|
|
104
97
|
const idName = optionalString(attrs, "id_field_name", `app "${label}"`, ctx);
|
|
105
|
-
if (idName !== undefined)
|
|
106
|
-
fields.push(systemEntry("id", idName, "TEXT", "HANDLE"));
|
|
98
|
+
if (idName !== undefined || idFieldDescription !== undefined) {
|
|
99
|
+
fields.push(systemEntry("id", idName ?? "ID", "TEXT", "HANDLE", idFieldDescription));
|
|
100
|
+
}
|
|
107
101
|
const statusName = optionalString(attrs, "status_field_name", `app "${label}"`, ctx) ?? "Status";
|
|
108
102
|
const statusOptions = optionsFromTf(attrs["status_options"], `app "${label}" status_options`, ctx);
|
|
109
|
-
if (statusName !== "Status" || statusOptions !== undefined) {
|
|
103
|
+
if (statusName !== "Status" || statusOptions !== undefined || statusFieldDescription !== undefined) {
|
|
110
104
|
fields.push({
|
|
111
105
|
key: "status",
|
|
112
106
|
field: {
|
|
@@ -114,6 +108,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
114
108
|
name: statusName,
|
|
115
109
|
type: "PICKLIST",
|
|
116
110
|
tags: ["STATUS"],
|
|
111
|
+
...(statusFieldDescription !== undefined && { description: statusFieldDescription }),
|
|
117
112
|
...(statusOptions !== undefined && { options: statusOptions }),
|
|
118
113
|
},
|
|
119
114
|
});
|
|
@@ -142,7 +137,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
142
137
|
ctx.diagnostics.push(`app "${label}": stages is not a list; dropped`);
|
|
143
138
|
}
|
|
144
139
|
// --- Custom field resources (entities/field).
|
|
145
|
-
const owner = { type: APP_RESOURCE_TYPE, label };
|
|
140
|
+
const owner = { type: APP_RESOURCE_TYPE, label, scope: "app" };
|
|
146
141
|
for (const block of fieldBlocks) {
|
|
147
142
|
const entry = fieldFromTf(block, owner, ctx);
|
|
148
143
|
if (entry !== undefined)
|
|
@@ -153,7 +148,21 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
153
148
|
ctx.diagnostics.push(`app "${label}": no import block in the stream — adoption has no identity to bind`);
|
|
154
149
|
}
|
|
155
150
|
// --- 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);
|
|
151
|
+
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);
|
|
152
|
+
// --- Access policies (entities/access-policy), owner passed in.
|
|
153
|
+
const accessPolicyOwner = {
|
|
154
|
+
type: APP_RESOURCE_TYPE,
|
|
155
|
+
label,
|
|
156
|
+
ownerRefName: refName,
|
|
157
|
+
ownerTfLabel: label,
|
|
158
|
+
scope: "app",
|
|
159
|
+
};
|
|
160
|
+
const accessPolicies = [];
|
|
161
|
+
for (const block of accessPolicyBlocks) {
|
|
162
|
+
const entry = accessPolicyFromTf(block, accessPolicyOwner, ctx);
|
|
163
|
+
if (entry !== undefined)
|
|
164
|
+
accessPolicies.push(entry);
|
|
165
|
+
}
|
|
157
166
|
const app = {
|
|
158
167
|
id: appId ?? "",
|
|
159
168
|
name,
|
|
@@ -172,9 +181,10 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
172
181
|
...(layouts.length > 0 && { layouts }),
|
|
173
182
|
...(listViews.length > 0 && { listViews }),
|
|
174
183
|
...(viewOrder !== undefined && { viewOrder }),
|
|
184
|
+
...(accessPolicies.length > 0 && { accessPolicies }),
|
|
175
185
|
};
|
|
176
186
|
return { app, ...(cloudLinkHandle !== undefined && { cloudLinkHandle }) };
|
|
177
187
|
}
|
|
178
|
-
function systemEntry(key, name, type, tag) {
|
|
179
|
-
return { key, field: { id: "", name, type, tags: [tag] } };
|
|
188
|
+
function systemEntry(key, name, type, tag, description) {
|
|
189
|
+
return { key, field: { id: "", name, type, tags: [tag], ...(description !== undefined && { description }) } };
|
|
180
190
|
}
|
|
@@ -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,18 @@ 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,
|
|
50
|
+
workspaceAspects: ctx.workspaceAspects,
|
|
48
51
|
});
|
|
49
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
blocks: result.blocks,
|
|
54
|
+
fieldAddresses: result.fieldAddresses,
|
|
55
|
+
fieldNames: result.fieldNames,
|
|
56
|
+
fieldMetadata: result.fieldMetadata,
|
|
57
|
+
};
|
|
50
58
|
},
|
|
51
59
|
appendLocals: (localsAttrs, ctx) => {
|
|
52
60
|
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";
|
|
@@ -66,6 +68,8 @@ export function appToTf(entity, ctx) {
|
|
|
66
68
|
appAttrs["icon"] = payload.icon;
|
|
67
69
|
if (payload.color !== undefined)
|
|
68
70
|
appAttrs["color"] = payload.color;
|
|
71
|
+
if (payload.commentsEnabled !== undefined)
|
|
72
|
+
appAttrs["comments_enabled"] = payload.commentsEnabled;
|
|
69
73
|
const categoryName = payload.category?.name;
|
|
70
74
|
if (categoryName !== undefined && categoryName !== "") {
|
|
71
75
|
const category = ctx.orgRefs.byName(CATEGORY_ORG_BAG, categoryName);
|
|
@@ -98,6 +102,8 @@ export function appToTf(entity, ctx) {
|
|
|
98
102
|
// --- Field pass: fold system-tagged fields, emit one resource per custom field.
|
|
99
103
|
const blocks = [];
|
|
100
104
|
const fieldAddresses = new Map();
|
|
105
|
+
const fieldMetadata = new Map();
|
|
106
|
+
const fieldNames = new Map();
|
|
101
107
|
let statusOptions;
|
|
102
108
|
let stages;
|
|
103
109
|
const objectId = expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]);
|
|
@@ -107,6 +113,20 @@ export function appToTf(entity, ctx) {
|
|
|
107
113
|
continue;
|
|
108
114
|
const inner = fieldEntry[typeKey];
|
|
109
115
|
const name = inner.name ?? "";
|
|
116
|
+
const fieldKey = inner.__refName ?? snakeSlug(name);
|
|
117
|
+
const subType = SUB_TYPE_BY_TYPE_KEY.get(typeKey);
|
|
118
|
+
if (fieldKey !== "" && name !== "" && subType !== undefined) {
|
|
119
|
+
fieldMetadata.set(fieldKey, {
|
|
120
|
+
name,
|
|
121
|
+
fieldType: subType.authoringType,
|
|
122
|
+
...(inner.picklistValues !== undefined
|
|
123
|
+
? { options: inner.picklistValues.map((value) => picklistLabel(value)) }
|
|
124
|
+
: {}),
|
|
125
|
+
...(inner.tags !== undefined ? { tags: inner.tags } : {}),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (fieldKey !== "" && name !== "")
|
|
129
|
+
fieldNames.set(fieldKey, name);
|
|
110
130
|
const systemTag = inner.tags?.find((tag) => SYSTEM_FIELD_TAGS.has(tag));
|
|
111
131
|
if (systemTag !== undefined) {
|
|
112
132
|
switch (systemTag) {
|
|
@@ -159,7 +179,14 @@ export function appToTf(entity, ctx) {
|
|
|
159
179
|
continue;
|
|
160
180
|
}
|
|
161
181
|
// Custom field → one `elementum_*_field` resource (entities/field).
|
|
162
|
-
const field = fieldToTf(typeKey, inner, {
|
|
182
|
+
const field = fieldToTf(typeKey, inner, {
|
|
183
|
+
ownerTfLabel: ctx.appTfLabel,
|
|
184
|
+
appRefName: ctx.appRefName,
|
|
185
|
+
objectId,
|
|
186
|
+
diagnostics: ctx.diagnostics,
|
|
187
|
+
orgRefs: ctx.orgRefs,
|
|
188
|
+
workspaceAspects: ctx.workspaceAspects,
|
|
189
|
+
});
|
|
163
190
|
if (field === undefined)
|
|
164
191
|
continue;
|
|
165
192
|
blocks.push(field.block);
|
|
@@ -172,12 +199,26 @@ export function appToTf(entity, ctx) {
|
|
|
172
199
|
appAttrs["stages"] = stages ?? [];
|
|
173
200
|
// --- View pass: layouts / list views / view order (entities/view), owner passed in.
|
|
174
201
|
const { blocks: viewBlocks } = viewToTf(payload.layouts, payload.listViews, payload.viewOrder, {
|
|
175
|
-
|
|
176
|
-
|
|
202
|
+
ownerTfLabel: ctx.appTfLabel,
|
|
203
|
+
aspectName: payload.name ?? "",
|
|
177
204
|
objectId,
|
|
178
205
|
diagnostics: ctx.diagnostics,
|
|
179
206
|
});
|
|
180
207
|
blocks.push(...viewBlocks);
|
|
208
|
+
// --- Access policy pass (entities/access-policy), owner passed in.
|
|
209
|
+
// Authored entries only. Creating an app also has the platform mint a
|
|
210
|
+
// creator policy (userIds = [you]) that is NOT in this payload — pull
|
|
211
|
+
// will see it; we never emit it here.
|
|
212
|
+
for (const [index, entry] of (payload.accessPolicies ?? []).entries()) {
|
|
213
|
+
const { block } = accessPolicyToTf(entry, index, {
|
|
214
|
+
ownerTfLabel: ctx.appTfLabel,
|
|
215
|
+
scope: "app",
|
|
216
|
+
objectId,
|
|
217
|
+
orgRefs: ctx.orgRefs,
|
|
218
|
+
diagnostics: ctx.diagnostics,
|
|
219
|
+
});
|
|
220
|
+
blocks.push(block);
|
|
221
|
+
}
|
|
181
222
|
blocks.unshift({ kind: "resource", type: APP_RESOURCE_TYPE, label: ctx.appTfLabel, attrs: appAttrs });
|
|
182
|
-
return { blocks, fieldAddresses };
|
|
223
|
+
return { blocks, fieldAddresses, fieldNames, fieldMetadata };
|
|
183
224
|
}
|