@elementumai/edk 0.12.0 → 0.13.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 +8 -2
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +10 -2
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +12 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +4 -0
- package/dist-sdk/src/engine/ei/run.d.ts +8 -0
- package/dist-sdk/src/engine/ei/run.js +46 -7
- package/dist-sdk/src/engine/pull/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +34 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
- package/dist-sdk/src/engine/pull/ref-only.js +7 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +159 -0
- package/dist-sdk/src/engine/pull/stream-root.js +579 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +17 -5
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +70 -1
- package/dist-sdk/src/entities/agent/from-tf.d.ts +36 -1
- package/dist-sdk/src/entities/agent/from-tf.js +289 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +11 -11
- package/dist-sdk/src/entities/agent/to-tf.js +179 -17
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +33 -13
- package/dist-sdk/src/entities/app/build.js +14 -12
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +7 -9
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +3 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
- package/dist-sdk/src/entities/app/stage-keys.js +3 -3
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.d.ts +10 -1
- package/dist-sdk/src/entities/automation/build.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +21 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +665 -112
- package/dist-sdk/src/entities/automation/index.d.ts +2 -1
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +45 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +23 -3
- package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
- package/dist-sdk/src/entities/automation/tasks.js +34 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/automation/to-tf.js +563 -103
- package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
- package/dist-sdk/src/entities/automation/triggers.js +26 -11
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.js +3 -0
- package/dist-sdk/src/entities/chart/to-tf.js +19 -2
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
- package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
- package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -7
- package/dist-sdk/src/entities/element/module.js +5 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +52 -1
- package/dist-sdk/src/entities/field/from-tf.js +212 -14
- package/dist-sdk/src/entities/field/module.js +4 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/field/to-tf.js +33 -12
- package/dist-sdk/src/entities/org/category.js +1 -0
- 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/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +9 -4
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/build.d.ts +3 -4
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- package/dist-sdk/src/entities/search-table/build.d.ts +9 -3
- package/dist-sdk/src/entities/search-table/build.js +4 -4
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +4 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/context.d.ts +14 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +97 -15
- package/dist-sdk/src/entities/shared/filters/index.js +30 -7
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/print.js +19 -6
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +16 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +25 -5
- package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +3 -2
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +3 -2
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +6 -4
- package/dist-sdk/src/entities/view/custom-view-validate.js +36 -18
- package/dist-sdk/src/entities/view/from-tf.js +16 -4
- package/dist-sdk/src/entities/view/to-tf.js +66 -47
- package/dist-sdk/src/entities/visual-flow/module.js +52 -1
- package/dist-sdk/src/entities/widget/from-tf.js +19 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +9 -0
- package/dist-sdk/src/graph/index.js +8 -0
- package/dist-sdk/src/graph/modules.js +13 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +113 -6
- package/package.json +7 -4
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Keys the org `@catalog` barrel holds after its app and element getters
|
|
5
|
+
* (src/catalog/org.ts renderBarrel). A later key in an object literal wins,
|
|
6
|
+
* so an app or element whose catalog key is one of these is shadowed:
|
|
7
|
+
* `catalog.users` is the org user lookups, not the element (edk#2839).
|
|
8
|
+
* `tables` is emitted only while the workspace has a table catalog; the
|
|
9
|
+
* others always are.
|
|
10
|
+
*/
|
|
11
|
+
export const ORG_CATALOG_KEYS = [
|
|
12
|
+
"users",
|
|
13
|
+
"userGroups",
|
|
14
|
+
"aiProviders",
|
|
15
|
+
"cloudLinks",
|
|
16
|
+
"categories",
|
|
17
|
+
"groups",
|
|
18
|
+
"phoneProviders",
|
|
19
|
+
"voiceAuths",
|
|
20
|
+
];
|
|
21
|
+
const ALWAYS_EMITTED_CATALOG_KEYS = new Set(ORG_CATALOG_KEYS);
|
|
22
|
+
const TABLES_CATALOG_KEY = "tables";
|
|
23
|
+
/**
|
|
24
|
+
* True for every key the barrel can hold. Pull and `elementum new` never mint
|
|
25
|
+
* one of these for a new app or element (it becomes `users2`), so adding a
|
|
26
|
+
* table later can't shadow it.
|
|
27
|
+
*/
|
|
28
|
+
export function isReservedCatalogKey(refName) {
|
|
29
|
+
return ALWAYS_EMITTED_CATALOG_KEYS.has(refName) || refName === TABLES_CATALOG_KEY;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* True when the barrel shadows an app or element getter named `refName` now:
|
|
33
|
+
* an always-emitted key, or `tables` while the workspace has a table catalog.
|
|
34
|
+
* Only a shadowed folder is refused or moved; an existing `tables` element in
|
|
35
|
+
* a workspace with no tables keeps working as `catalog.tables`.
|
|
36
|
+
*/
|
|
37
|
+
export function isShadowedCatalogKey(refName, tablesEmitted) {
|
|
38
|
+
return ALWAYS_EMITTED_CATALOG_KEYS.has(refName) || (refName === TABLES_CATALOG_KEY && tablesEmitted);
|
|
39
|
+
}
|
|
40
|
+
/** True when `<orgRoot>/tables/` holds a table catalog, which makes the barrel emit `tables`. */
|
|
41
|
+
export function orgHasTableCatalogs(orgRoot) {
|
|
42
|
+
const dir = join(orgRoot, "tables");
|
|
43
|
+
if (!existsSync(dir))
|
|
44
|
+
return false;
|
|
45
|
+
return readdirSync(dir, { withFileTypes: true })
|
|
46
|
+
.some((entry) => entry.isDirectory() && existsSync(join(dir, entry.name, "generated", "catalog.ts")));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `base` when it isn't a reserved catalog key, else the first of `<base>2`,
|
|
50
|
+
* `<base>3`, … that isn't `taken` (a folder there that belongs to another
|
|
51
|
+
* root).
|
|
52
|
+
*/
|
|
53
|
+
export function unreservedRefName(base, taken = () => false) {
|
|
54
|
+
if (!isReservedCatalogKey(base))
|
|
55
|
+
return base;
|
|
56
|
+
let i = 2;
|
|
57
|
+
while (taken(`${base}${i}`))
|
|
58
|
+
i++;
|
|
59
|
+
return `${base}${i}`;
|
|
60
|
+
}
|
|
61
|
+
/** True when `dir` holds nothing but pull's own `generated/` output (a dependency stub). */
|
|
62
|
+
export function isGeneratedOnlyFolder(dir) {
|
|
63
|
+
return readdirSync(dir).filter((entry) => entry !== ".DS_Store").every((entry) => entry === "generated");
|
|
64
|
+
}
|
|
65
|
+
function shadowedRemedy(bag, refName, suggestion) {
|
|
66
|
+
return `If it is on the platform, commit your work, delete ${bag}/${refName}/ and pull it again; pull picks a folder ` +
|
|
67
|
+
`name the barrel doesn't shadow. Otherwise rename the folder and its file to ${suggestion}, run ` +
|
|
68
|
+
`\`elementum generate\`, and use catalog.${suggestion}. The namespace stays, so nothing on the platform changes (edk#2839).`;
|
|
69
|
+
}
|
|
70
|
+
/** Pull refuses to write over an authored root whose ref name the barrel shadows. */
|
|
71
|
+
export function reservedRefNameError(bag, refName, suggestion) {
|
|
72
|
+
return new Error(`${bag}/${refName}: "${refName}" is a reserved @catalog key (catalog.${refName} is the org's own entry), ` +
|
|
73
|
+
`so the ${bag === "apps" ? "app" : "element"} can't be reached as catalog.${refName}. ${shadowedRemedy(bag, refName, suggestion)}`);
|
|
74
|
+
}
|
|
75
|
+
/** The barrel leaves out a folder with source that an org entry shadows. */
|
|
76
|
+
export function shadowedFolderWarning(bag, refName, suggestion) {
|
|
77
|
+
return `${bag}/${refName}/ can't be reached as catalog.${refName}: that is the org's own entry, so the @catalog barrel ` +
|
|
78
|
+
`leaves the ${bag === "apps" ? "app" : "element"} out. ${shadowedRemedy(bag, refName, suggestion)}`;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Pure shared allocator: app/element collisions receive disambiguated keys.
|
|
82
|
+
* Apps and elements share the barrel's key space: an element whose folder
|
|
83
|
+
* name an app also uses gets `<name>2` (the first free). The barrel, pull and
|
|
84
|
+
* the reserved-name checks all use this, so they agree on each element's key.
|
|
85
|
+
*/
|
|
86
|
+
export function computeElementKeys(appHandles, elementHandles) {
|
|
87
|
+
const used = new Set(appHandles);
|
|
88
|
+
const elementKeys = new Map();
|
|
89
|
+
for (const h of elementHandles) {
|
|
90
|
+
if (!used.has(h)) {
|
|
91
|
+
elementKeys.set(h, h);
|
|
92
|
+
used.add(h);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
let i = 2;
|
|
96
|
+
let candidate = `${h}${i}`;
|
|
97
|
+
while (used.has(candidate)) {
|
|
98
|
+
i++;
|
|
99
|
+
candidate = `${h}${i}`;
|
|
100
|
+
}
|
|
101
|
+
elementKeys.set(h, candidate);
|
|
102
|
+
used.add(candidate);
|
|
103
|
+
}
|
|
104
|
+
return elementKeys;
|
|
105
|
+
}
|
|
106
|
+
/** The `<bag>/<handle>/` folders that hold a catalog (`generated/catalog.ts`), sorted, as the barrel lists them. */
|
|
107
|
+
export function catalogFolders(orgRoot, bag) {
|
|
108
|
+
const dir = join(orgRoot, bag);
|
|
109
|
+
if (!existsSync(dir))
|
|
110
|
+
return [];
|
|
111
|
+
return readdirSync(dir, { withFileTypes: true })
|
|
112
|
+
.filter((entry) => entry.isDirectory() && existsSync(join(dir, entry.name, "generated", "catalog.ts")))
|
|
113
|
+
.map((entry) => entry.name)
|
|
114
|
+
.sort();
|
|
115
|
+
}
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* both parents accept the identical shape.
|
|
6
6
|
*/
|
|
7
7
|
import type { Filter } from "../shared/filters/types.js";
|
|
8
|
+
import type { FilterFieldToken } from "../shared/filters/index.js";
|
|
8
9
|
import type { AccessPolicyGroupRef, AccessPolicyServiceAccountRef, AccessPolicyUserRef } from "./principal.js";
|
|
9
10
|
export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyPrincipal, type AccessPolicyPrincipalRef, type AccessPolicyServiceAccountRef, type AccessPolicyUserRef, type GroupId, type UserId, } from "./principal.js";
|
|
10
11
|
export interface AccessPolicyOptions {
|
|
11
12
|
/** Row-level-security predicate. Omit for the platform default (matches every record). */
|
|
12
|
-
readonly filter?: Filter
|
|
13
|
+
readonly filter?: Filter<FilterFieldToken, unknown>;
|
|
13
14
|
readonly userIds?: readonly AccessPolicyUserRef[];
|
|
14
15
|
readonly groupIds?: readonly AccessPolicyGroupRef[];
|
|
15
16
|
readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
|
|
@@ -36,6 +36,8 @@ export interface NormalizedAccessPolicy {
|
|
|
36
36
|
readonly userIds?: readonly AccessPolicyUserRef[];
|
|
37
37
|
readonly groupIds?: readonly AccessPolicyGroupRef[];
|
|
38
38
|
readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
|
|
39
|
+
/** Pull-only: export matched it to the policy the platform adds for the app's creator (edk#2156); the printer notes it. */
|
|
40
|
+
readonly platformCreatorPolicy?: true;
|
|
39
41
|
}
|
|
40
42
|
export interface FilterFromTfOptions {
|
|
41
43
|
/**
|
|
@@ -44,6 +46,11 @@ export interface FilterFromTfOptions {
|
|
|
44
46
|
* that always rebuild a bare label into its lookup leave this off.
|
|
45
47
|
*/
|
|
46
48
|
readonly optionLookupsAreIdentities?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Access policies (#1733): a stored options-by-label lookup prints as
|
|
51
|
+
* `filter.textOption(label)`, the preferred spelling. Stage keys stay plain.
|
|
52
|
+
*/
|
|
53
|
+
readonly optionLookupsAsTextOption?: boolean;
|
|
47
54
|
}
|
|
48
55
|
/** Decode one `filter` attribute through the shared exhaustive codec. */
|
|
49
56
|
export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string, ctx?: FromTfContext, options?: FilterFromTfOptions): Filter<RefExpr, RefExpr>;
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { EntityTfError } from "../../engine/entity.js";
|
|
14
14
|
import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
|
|
15
|
-
import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr,
|
|
15
|
+
import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedResourceLabel, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
16
|
+
import { pulledFieldBagKey } from "../field/from-tf.js";
|
|
16
17
|
import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
|
|
17
18
|
import { groupId, userId, } from "./principal.js";
|
|
18
19
|
import { KNOWN_ACCESS_POLICY_ATTRS } from "./types.js";
|
|
19
20
|
import { finishPulledMemberList } from "./member-list.js";
|
|
20
|
-
function fieldRef(value, owner, where) {
|
|
21
|
+
function fieldRef(value, owner, where, ctx) {
|
|
21
22
|
if (isTfExpr(value) && value.$expr === "resource-attr" && value.type.endsWith("_field") && value.path[0] === "id") {
|
|
22
23
|
// scopedLabelToBagKey's stripping is a documented no-op when the label
|
|
23
24
|
// isn't actually prefixed for this owner (src/engine/tf/labels.ts) - it
|
|
@@ -30,7 +31,7 @@ function fieldRef(value, owner, where) {
|
|
|
30
31
|
// final throw below can handle it instead of a silent wrong answer.
|
|
31
32
|
const prefix = owner.scope === "element" ? elementResourceLabelPrefix(owner.ownerTfLabel) : appResourceLabelPrefix(owner.ownerTfLabel);
|
|
32
33
|
if (value.label.startsWith(prefix)) {
|
|
33
|
-
return { kind: "field", appHandle: owner.ownerRefName, fieldKey:
|
|
34
|
+
return { kind: "field", appHandle: owner.ownerRefName, fieldKey: pulledFieldBagKey(owner.ownerTfLabel, value.label, owner.scope, ctx) };
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
// A system field (status/title/id/stage/…) has no own resource block — ei
|
|
@@ -84,10 +85,13 @@ function picklistOptionLabel(value, owner) {
|
|
|
84
85
|
export function filterFromTf(value, owner, where, ctx, options) {
|
|
85
86
|
try {
|
|
86
87
|
return deserializeFilterFromTf(value, {
|
|
87
|
-
field: (fieldValue) => fieldRef(fieldValue, owner, where),
|
|
88
|
+
field: (fieldValue) => fieldRef(fieldValue, owner, where, ctx),
|
|
88
89
|
reference: () => { throw new EntityTfError(`${where}: access-policy reference values are not supported`); },
|
|
89
90
|
literal: (literal) => picklistOptionLabel(literal, owner) ?? stageName(literal, owner, ctx) ?? literal,
|
|
90
91
|
...(options?.optionLookupsAreIdentities === true && { optionLookupsAreIdentities: true }),
|
|
92
|
+
...(options?.optionLookupsAsTextOption === true && {
|
|
93
|
+
optionLookupsAreIdentities: (stored) => picklistOptionLabel(stored, owner) !== undefined,
|
|
94
|
+
}),
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
97
|
catch (error) {
|
|
@@ -265,14 +269,22 @@ export function accessPolicyFromTf(block, owner, ctx) {
|
|
|
265
269
|
const filterOwner = owner.foreignFieldRefsById !== undefined
|
|
266
270
|
? owner
|
|
267
271
|
: { ...owner, foreignFieldRefsById: ctx.foreignFieldRefsById };
|
|
268
|
-
|
|
272
|
+
// #1733: a resolved option prints as `filter.textOption(label)`, the
|
|
273
|
+
// preferred spelling; build still resolves a plain label here too.
|
|
274
|
+
const filter = attrs["filter"] !== undefined
|
|
275
|
+
? filterFromTf(attrs["filter"], filterOwner, where, ctx, { optionLookupsAsTextOption: true })
|
|
276
|
+
: { type: "TRUE" };
|
|
269
277
|
const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
|
|
270
278
|
const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
|
|
271
279
|
const serviceAccountIds = principalList(attrs["service_account_ids"], "elementum_service_account", `${where}: service_account_ids`, ctx, owner);
|
|
280
|
+
// The import id is `<object id>:<policy id>`.
|
|
281
|
+
const policyId = ctx.importId(`${block.type}.${label}`)?.split(":").at(-1);
|
|
282
|
+
const platformCreatorPolicy = policyId !== undefined && ctx.platformCreatorPolicyIds?.has(policyId) === true;
|
|
272
283
|
return {
|
|
273
284
|
filter,
|
|
274
285
|
...(userIds !== undefined && { userIds }),
|
|
275
286
|
...(groupIds !== undefined && { groupIds }),
|
|
276
287
|
...(serviceAccountIds !== undefined && { serviceAccountIds }),
|
|
288
|
+
...(platformCreatorPolicy && { platformCreatorPolicy: true }),
|
|
277
289
|
};
|
|
278
290
|
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* the integration harness strips it for fidelity against authored fixtures.
|
|
19
19
|
*/
|
|
20
20
|
import type { OrgRefLookup } from "../../engine/build/context.js";
|
|
21
|
+
import type { OptionIdIndex } from "../../engine/pull/field-refs-registry.js";
|
|
21
22
|
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
22
23
|
import type { Filter } from "../shared/filters/types.js";
|
|
23
24
|
import type { AppServiceAccount } from "../service-account/build.js";
|
|
@@ -41,6 +42,8 @@ export interface AccessPolicyToTfContext {
|
|
|
41
42
|
readonly appRefName?: string;
|
|
42
43
|
readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
|
|
43
44
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
45
|
+
/** Option ids known offline, so a raw id's warning can name its label (#1733). */
|
|
46
|
+
readonly optionIds?: OptionIdIndex;
|
|
44
47
|
/**
|
|
45
48
|
* Resolve an app that owns a `serviceAccountRef` in these policies but is
|
|
46
49
|
* NOT this policy's owner — an element granting an app's service account
|
|
@@ -75,6 +78,22 @@ export interface FilterToTfContext extends Omit<AccessPolicyToTfContext, "orgRef
|
|
|
75
78
|
readonly fieldType?: string;
|
|
76
79
|
readonly name?: string;
|
|
77
80
|
}, where: string) => TfValue | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The owner is only a data source here, so it has no field resources and no
|
|
83
|
+
* options locals. Its own fields go through `foreignField` too (a parent
|
|
84
|
+
* that matches the owner otherwise skips that path), and an option label
|
|
85
|
+
* stays the authored label instead of an options-by-label local.
|
|
86
|
+
*/
|
|
87
|
+
readonly ownerFieldsThroughForeign?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Set by access policies (#1733): `filter.textOption(label)` must name
|
|
90
|
+
* exactly one option of the field, and warnings name this resource. Views
|
|
91
|
+
* and the other filter owners leave it off and keep their option rules.
|
|
92
|
+
*/
|
|
93
|
+
readonly optionSelections?: {
|
|
94
|
+
readonly address: string;
|
|
95
|
+
readonly name: string;
|
|
96
|
+
};
|
|
78
97
|
}
|
|
79
98
|
export interface AccessPolicyToTfResult {
|
|
80
99
|
readonly block: TfBlock;
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { isUnsafePlatformId } from "../../core/index.js";
|
|
21
21
|
import { EntityTfError } from "../../engine/entity.js";
|
|
22
|
+
import { recordValidations } from "../../engine/validation.js";
|
|
22
23
|
import { expr, isUuid, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
23
24
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
24
25
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
26
|
+
import { plainOptionStringWarning, rawOptionIdWarning } from "../shared/raw-option-id.js";
|
|
25
27
|
import { serviceAccountRefToTf } from "../service-account/to-tf.js";
|
|
26
28
|
import { ACCESS_POLICY_RESOURCE_TYPE } from "./types.js";
|
|
27
29
|
import { describeDroppedEntry, finishMemberList } from "./member-list.js";
|
|
@@ -31,12 +33,17 @@ function isFieldToken(v) {
|
|
|
31
33
|
function fieldValueToTf(token, where, ctx) {
|
|
32
34
|
const refName = token.refName ?? "";
|
|
33
35
|
const parent = token.parent;
|
|
34
|
-
|
|
36
|
+
const ownerRefName = ctx.ownerRefName ?? ctx.appRefName;
|
|
37
|
+
const otherOwner = parent !== undefined && parent !== ownerRefName && parent !== ctx.ownerTfLabel;
|
|
38
|
+
// A data-source owner has no field resources. Its own fields (parent matches
|
|
39
|
+
// the owner) still go through foreignField; only a different owner does
|
|
40
|
+
// otherwise.
|
|
41
|
+
if (ctx.foreignField !== undefined && parent !== undefined && (otherOwner || ctx.ownerFieldsThroughForeign === true)) {
|
|
35
42
|
const foreign = ctx.foreignField({ ...token, refName, parent }, where);
|
|
36
43
|
if (foreign !== undefined)
|
|
37
44
|
return foreign;
|
|
38
45
|
}
|
|
39
|
-
const value = fieldRefToTfValue(token.fieldType ?? "", refName, ctx.ownerTfLabel, ctx.scope, ctx.fieldAddresses);
|
|
46
|
+
const value = fieldRefToTfValue(token.fieldType ?? "", refName, ctx.ownerTfLabel, ctx.scope, ctx.fieldAddresses, token.resourceKey);
|
|
40
47
|
if (value === undefined) {
|
|
41
48
|
throw new EntityTfError(`${where}: field token "${refName}" has no terraform field resource mapping`);
|
|
42
49
|
}
|
|
@@ -44,8 +51,16 @@ function fieldValueToTf(token, where, ctx) {
|
|
|
44
51
|
}
|
|
45
52
|
/** Resolve a PICKLIST/STATUS-field-typed string against its options-by-label local, if the field carries picklist metadata. */
|
|
46
53
|
function picklistLiteralToTf(literal, field, ctx) {
|
|
54
|
+
// A data-source owner has no options local in this workspace. The caller
|
|
55
|
+
// keeps the label as authored (`?? value`) instead of a local that does not exist.
|
|
56
|
+
if (ctx.ownerFieldsThroughForeign === true)
|
|
57
|
+
return undefined;
|
|
47
58
|
if (field?.options === undefined || !field.options.includes(literal))
|
|
48
59
|
return undefined;
|
|
60
|
+
return expr.local(optionsLocalName(field, ctx), [{ index: literal }]);
|
|
61
|
+
}
|
|
62
|
+
/** The field's options-by-label local name. */
|
|
63
|
+
function optionsLocalName(field, ctx) {
|
|
49
64
|
// Hand-built refs to an app's system status/stage carry no tags; match them
|
|
50
65
|
// by key, as field resolution does. Elements have no status/stage system fields.
|
|
51
66
|
const systemKey = ctx.scope === "element" ? undefined : field.refName;
|
|
@@ -55,9 +70,47 @@ function picklistLiteralToTf(literal, field, ctx) {
|
|
|
55
70
|
? `${ctx.ownerTfLabel}_stage_options_by_label`
|
|
56
71
|
: undefined;
|
|
57
72
|
// Non-status/stage picklists: the field's own options-by-label local, keyed
|
|
58
|
-
// by its scoped resource label — same
|
|
59
|
-
const
|
|
60
|
-
return
|
|
73
|
+
// by its scoped resource label — same child part fieldToTf uses (#1871).
|
|
74
|
+
const childPart = tsLabelToTfLabel(field.resourceKey ?? field.refName ?? "");
|
|
75
|
+
return localName ?? `${scopedResourceLabel(ctx.ownerTfLabel, childPart, ctx.scope)}_options_by_label`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A filter value on a field with static options (#1733). A raw option id and
|
|
79
|
+
* a plain string each build as before and warn once, naming the preferred
|
|
80
|
+
* `filter.textOption(label)`. On an access policy, `filter.textOption(label)`
|
|
81
|
+
* must also name exactly one option; the other owners of this codec (views,
|
|
82
|
+
* dashboards, relationships, dynamic layouts) do not check that here.
|
|
83
|
+
*/
|
|
84
|
+
function checkOptionSelection(value, field, valueType, isOptionLabel, where, ctx) {
|
|
85
|
+
const selections = ctx.optionSelections;
|
|
86
|
+
const options = field.options;
|
|
87
|
+
if (options === undefined || value === "" || field.tags?.includes("STAGE"))
|
|
88
|
+
return;
|
|
89
|
+
const fieldName = field.name ?? field.refName ?? "unknown";
|
|
90
|
+
const slot = selections !== undefined ? `${where}.filter` : where;
|
|
91
|
+
const warn = (message) => recordValidations([{
|
|
92
|
+
severity: "warning",
|
|
93
|
+
address: selections?.address ?? where,
|
|
94
|
+
name: selections?.name ?? ctx.ownerRefName ?? ctx.ownerTfLabel,
|
|
95
|
+
ownerKind: selections !== undefined ? "access-policy" : "filter",
|
|
96
|
+
message,
|
|
97
|
+
}]);
|
|
98
|
+
if (isUuid(value) && !options.includes(value)) {
|
|
99
|
+
warn(rawOptionIdWarning({ slot, fieldName, id: value, options, localName: optionsLocalName(field, ctx), index: ctx.optionIds }));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!isOptionLabel) {
|
|
103
|
+
warn(plainOptionStringWarning(slot, fieldName, value, options, ctx.resolvePicklistLiterals !== false));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (selections === undefined || valueType !== "text")
|
|
107
|
+
return;
|
|
108
|
+
const matches = options.filter((option) => option === value).length;
|
|
109
|
+
if (matches === 1)
|
|
110
|
+
return;
|
|
111
|
+
throw new EntityTfError(matches === 0
|
|
112
|
+
? `${where}: filter.textOption(${JSON.stringify(value)}) names no option of field "${fieldName}"; expected one of: ${options.map((option) => JSON.stringify(option)).join(", ")}`
|
|
113
|
+
: `${where}: filter.textOption(${JSON.stringify(value)}) matches ${matches} options of field "${fieldName}", so it names no single option`);
|
|
61
114
|
}
|
|
62
115
|
/**
|
|
63
116
|
* Encode one canonical filter through the shared exhaustive Terraform codec.
|
|
@@ -80,8 +133,10 @@ export function filterToTf(f, where, ctx) {
|
|
|
80
133
|
return fieldValueToTf(field, where, ctx);
|
|
81
134
|
},
|
|
82
135
|
reference: () => { throw new EntityTfError(`${where}: access-policy filters do not support reference values`); },
|
|
83
|
-
literal: (value, field,
|
|
136
|
+
literal: (value, field, valueType, isOptionLabel) => {
|
|
84
137
|
if (typeof value === "string") {
|
|
138
|
+
if (isFieldToken(field))
|
|
139
|
+
checkOptionSelection(value, field, valueType, isOptionLabel, where, ctx);
|
|
85
140
|
// An option selection stays an identity whichever wrapper the platform
|
|
86
141
|
// stored it behind, even on views where raw TEXT picklist labels
|
|
87
142
|
// intentionally stay literal (rather than IDs).
|
|
@@ -219,9 +274,11 @@ function accessPolicyTfLabel(ownerTfLabel, index, scope) {
|
|
|
219
274
|
export function accessPolicyToTf(entry, index, ctx) {
|
|
220
275
|
const label = accessPolicyTfLabel(ctx.ownerTfLabel, index, ctx.scope);
|
|
221
276
|
const where = `accessPolicies[${index}]`;
|
|
277
|
+
const address = `${ACCESS_POLICY_RESOURCE_TYPE}.${label}`;
|
|
278
|
+
const optionSelections = { address, name: `${ctx.ownerRefName ?? ctx.ownerTfLabel} ${where}` };
|
|
222
279
|
const attrs = {
|
|
223
280
|
object_id: ctx.objectId,
|
|
224
|
-
filter: entry.filter !== undefined ? filterToTf(entry.filter, where, ctx) : { type: "true" },
|
|
281
|
+
filter: entry.filter !== undefined ? filterToTf(entry.filter, where, { ...ctx, optionSelections }) : { type: "true" },
|
|
225
282
|
};
|
|
226
283
|
// `userIds: []` (and the other lists) removes every member, so it must
|
|
227
284
|
// reach the provider as `[]`: an omitted list changes nothing (#2160). A
|
|
@@ -241,6 +298,6 @@ export function accessPolicyToTf(entry, index, ctx) {
|
|
|
241
298
|
attrs["service_account_ids"] = serviceAccountIds;
|
|
242
299
|
return {
|
|
243
300
|
block: { kind: "resource", type: ACCESS_POLICY_RESOURCE_TYPE, label, attrs },
|
|
244
|
-
address
|
|
301
|
+
address,
|
|
245
302
|
};
|
|
246
303
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { AgentRef, CatalogRef, ConnectorRef, SkillRef } from "../../catalog/index.js";
|
|
1
|
+
import type { AgentRef, CatalogRef, ConnectorRef, ElementCatalogRef, FieldRef, SkillRef } from "../../catalog/index.js";
|
|
2
2
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
3
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
4
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
4
5
|
import type { AgentTool, AgentToolRunAs } from "./tools.js";
|
|
5
6
|
/** JWT authentication config (Hydra's `AgentAuthenticationInput`). */
|
|
6
7
|
export interface AgentAuthentication {
|
|
@@ -53,6 +54,51 @@ export type SkillAccess = {
|
|
|
53
54
|
readonly skills: readonly SkillRef[];
|
|
54
55
|
readonly preloadedSkills?: readonly SkillRef[];
|
|
55
56
|
};
|
|
57
|
+
/** Ask a Question or Approvals, the agent's built-in system skills. */
|
|
58
|
+
export interface AgentSystemSkill {
|
|
59
|
+
readonly enabled: boolean;
|
|
60
|
+
/** Shown with the skill. Omit it to leave the live description unchanged. */
|
|
61
|
+
readonly description?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A record field Ask a Question can offer as a dynamic dropdown.
|
|
65
|
+
* `field` belongs to exactly one of `app` or `element`. `fieldName` is the
|
|
66
|
+
* name the platform stores for the dropdown; it keeps the field's name from
|
|
67
|
+
* when the dropdown was set up, so set it when the field was renamed since.
|
|
68
|
+
* Defaults to the field's display name.
|
|
69
|
+
*/
|
|
70
|
+
export type AgentDynamicDropdown = {
|
|
71
|
+
readonly app: CatalogRef<"app">;
|
|
72
|
+
readonly element?: never;
|
|
73
|
+
readonly field: FieldRef;
|
|
74
|
+
readonly fieldName?: string;
|
|
75
|
+
readonly multiple: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Limits which records the dropdown offers. Use the filter helpers
|
|
78
|
+
* (`filter.eq` and the rest). Omit it to store no filter.
|
|
79
|
+
*/
|
|
80
|
+
readonly filter?: Filter;
|
|
81
|
+
} | {
|
|
82
|
+
readonly app?: never;
|
|
83
|
+
readonly element: ElementCatalogRef;
|
|
84
|
+
readonly field: FieldRef;
|
|
85
|
+
readonly fieldName?: string;
|
|
86
|
+
readonly multiple: boolean;
|
|
87
|
+
/** Limits which records the dropdown offers. Omit it to store no filter. */
|
|
88
|
+
readonly filter?: Filter;
|
|
89
|
+
};
|
|
90
|
+
/** Ask a Question, including the dropdowns it can offer. */
|
|
91
|
+
export interface AgentAskUserQuestion extends AgentSystemSkill {
|
|
92
|
+
readonly dynamicDropdowns?: readonly AgentDynamicDropdown[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Built-in system skills. Omit the whole object to leave the live Ask a
|
|
96
|
+
* Question and Approvals settings unchanged.
|
|
97
|
+
*/
|
|
98
|
+
export interface AgentSystemSkillsConfig {
|
|
99
|
+
readonly askUserQuestion?: AgentAskUserQuestion;
|
|
100
|
+
readonly approvals?: AgentSystemSkill;
|
|
101
|
+
}
|
|
56
102
|
export declare const agentStartingActionVariableType: {
|
|
57
103
|
readonly number: "NUMBER";
|
|
58
104
|
readonly select: "SELECT";
|
|
@@ -122,6 +168,11 @@ export interface AgentV2Options extends EntityDeployOptions {
|
|
|
122
168
|
readonly a2aCreateRecordEnabled?: boolean;
|
|
123
169
|
readonly conversationIdleTimeout?: string;
|
|
124
170
|
readonly skillAccess?: SkillAccess;
|
|
171
|
+
/**
|
|
172
|
+
* Ask a Question and Approvals. Omit it and apply leaves the live value
|
|
173
|
+
* alone, including a value set in the UI.
|
|
174
|
+
*/
|
|
175
|
+
readonly systemSkillsConfig?: AgentSystemSkillsConfig;
|
|
125
176
|
readonly agentAuthentication?: AgentAuthentication;
|
|
126
177
|
readonly a2aSkills?: readonly A2ASkill[];
|
|
127
178
|
readonly tools?: readonly AgentTool[];
|
|
@@ -39,6 +39,37 @@ function serializeStartingAction(action) {
|
|
|
39
39
|
...(action.variables !== undefined ? { variables: action.variables } : {}),
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
+
function serializeSystemSkill(skill) {
|
|
43
|
+
return {
|
|
44
|
+
enabled: skill.enabled,
|
|
45
|
+
...(skill.description !== undefined ? { description: skill.description } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function serializeDynamicDropdown(row) {
|
|
49
|
+
const owner = row.app !== undefined ? { app: row.app } : { element: row.element };
|
|
50
|
+
return {
|
|
51
|
+
...owner,
|
|
52
|
+
field: row.field,
|
|
53
|
+
...(row.fieldName !== undefined ? { fieldName: row.fieldName } : {}),
|
|
54
|
+
multiple: row.multiple,
|
|
55
|
+
...(row.filter !== undefined ? { filter: row.filter } : {}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function serializeSystemSkills(config) {
|
|
59
|
+
return {
|
|
60
|
+
...(config.askUserQuestion !== undefined
|
|
61
|
+
? {
|
|
62
|
+
askUserQuestion: {
|
|
63
|
+
...serializeSystemSkill(config.askUserQuestion),
|
|
64
|
+
...(config.askUserQuestion.dynamicDropdowns !== undefined
|
|
65
|
+
? { dynamicDropdowns: config.askUserQuestion.dynamicDropdowns.map(serializeDynamicDropdown) }
|
|
66
|
+
: {}),
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
: {}),
|
|
70
|
+
...(config.approvals !== undefined ? { approvals: serializeSystemSkill(config.approvals) } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
42
73
|
function serializeSkillAccess(access) {
|
|
43
74
|
const preloaded = access.preloadedSkills !== undefined ? { preloadedSkillIds: access.preloadedSkills } : {};
|
|
44
75
|
if (access.mode === "CUSTOM") {
|
|
@@ -178,6 +209,9 @@ export function agent(opts) {
|
|
|
178
209
|
...(opts.skillAccess !== undefined
|
|
179
210
|
? { skillAccessConfig: serializeSkillAccess(opts.skillAccess) }
|
|
180
211
|
: {}),
|
|
212
|
+
...(opts.systemSkillsConfig !== undefined
|
|
213
|
+
? { systemSkillsConfig: serializeSystemSkills(opts.systemSkillsConfig) }
|
|
214
|
+
: {}),
|
|
181
215
|
...(opts.agentAuthentication !== undefined
|
|
182
216
|
? { agentAuthentication: opts.agentAuthentication }
|
|
183
217
|
: {}),
|
|
@@ -14,6 +14,7 @@ import { quote } from "../../../../pull/util.js";
|
|
|
14
14
|
import { catalogRefForFieldOwner } from "../../../engine/pull/catalog-ref.js";
|
|
15
15
|
import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
|
|
16
16
|
import { safeIdentifier } from "../../../internal/safe-identifier.js";
|
|
17
|
+
import { printFilter } from "../../shared/filters/print.js";
|
|
17
18
|
const TOOL_FACTORY_BY_TYPE_KEY = {
|
|
18
19
|
createRecord: "agentCreateRecord",
|
|
19
20
|
searchAspect: "agentSearchRecords",
|
|
@@ -129,6 +130,9 @@ export function printAgentV2(agent, opts) {
|
|
|
129
130
|
}
|
|
130
131
|
if (usesUnsafePlatformId)
|
|
131
132
|
lines.push(`import { unsafePlatformId } from "${sdkPackageSpecifier("core")}";`);
|
|
133
|
+
if (agent.systemSkillsConfig?.askUserQuestion?.dynamicDropdowns?.some((row) => row.filter !== undefined) === true) {
|
|
134
|
+
lines.push(`import { filter } from "${sdkPackageSpecifier("automations")}";`);
|
|
135
|
+
}
|
|
132
136
|
// Always needed: `connector:` is required and always a catalog.aiProviders
|
|
133
137
|
// token (or the TODO placeholder), and the barrel already re-exports
|
|
134
138
|
// org.aiProviders — no separate relative org.js import is needed here.
|
|
@@ -176,6 +180,9 @@ export function printAgentV2(agent, opts) {
|
|
|
176
180
|
if (agent.skillAccess !== undefined) {
|
|
177
181
|
lines.push(...printSkillAccess(agent.skillAccess, appRefName, crossOrg).map((l) => ` ${l}`));
|
|
178
182
|
}
|
|
183
|
+
if (agent.systemSkillsConfig !== undefined) {
|
|
184
|
+
lines.push(...printSystemSkillsConfig(agent.systemSkillsConfig, appRefName, crossOrg).map((l) => ` ${l}`));
|
|
185
|
+
}
|
|
179
186
|
if (agent.runAs !== undefined)
|
|
180
187
|
lines.push(` runAs: ${printRunAs(agent.runAs, appRefName)},`);
|
|
181
188
|
if (agent.agentAuthentication !== undefined) {
|
|
@@ -208,6 +215,67 @@ export function printAgentV2(agent, opts) {
|
|
|
208
215
|
lines.push("");
|
|
209
216
|
return lines.join("\n");
|
|
210
217
|
}
|
|
218
|
+
function printSystemSkillsConfig(config, appRefName, crossOrg) {
|
|
219
|
+
const lines = ["systemSkillsConfig: {"];
|
|
220
|
+
if (config.askUserQuestion !== undefined) {
|
|
221
|
+
lines.push(" askUserQuestion: {");
|
|
222
|
+
lines.push(` enabled: ${String(config.askUserQuestion.enabled)},`);
|
|
223
|
+
if (config.askUserQuestion.description !== undefined) {
|
|
224
|
+
lines.push(` description: ${quote(config.askUserQuestion.description)},`);
|
|
225
|
+
}
|
|
226
|
+
if (config.askUserQuestion.dynamicDropdowns !== undefined) {
|
|
227
|
+
if (config.askUserQuestion.dynamicDropdowns.length === 0) {
|
|
228
|
+
lines.push(" dynamicDropdowns: [],");
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
lines.push(" dynamicDropdowns: [");
|
|
232
|
+
for (const row of config.askUserQuestion.dynamicDropdowns) {
|
|
233
|
+
lines.push(` ${printDynamicDropdown(row, appRefName, crossOrg)}`);
|
|
234
|
+
}
|
|
235
|
+
lines.push(" ],");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
lines.push(" },");
|
|
239
|
+
}
|
|
240
|
+
if (config.approvals !== undefined) {
|
|
241
|
+
lines.push(" approvals: {");
|
|
242
|
+
lines.push(` enabled: ${String(config.approvals.enabled)},`);
|
|
243
|
+
if (config.approvals.description !== undefined) {
|
|
244
|
+
lines.push(` description: ${quote(config.approvals.description)},`);
|
|
245
|
+
}
|
|
246
|
+
lines.push(" },");
|
|
247
|
+
}
|
|
248
|
+
lines.push("},");
|
|
249
|
+
return lines;
|
|
250
|
+
}
|
|
251
|
+
function printDropdownFilter(filter) {
|
|
252
|
+
return printFilter(filter, {
|
|
253
|
+
field: printDropdownFilterRef,
|
|
254
|
+
reference: printDropdownFilterRef,
|
|
255
|
+
quote,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function printDropdownFilterRef(ref) {
|
|
259
|
+
if (ref.kind === "field") {
|
|
260
|
+
return `catalog${safeMember(ref.appHandle)}.fields${safeMember(ref.fieldKey)}`;
|
|
261
|
+
}
|
|
262
|
+
return `undefined /* TODO: unsupported filter reference ${quote(ref.kind)} */`;
|
|
263
|
+
}
|
|
264
|
+
function printDynamicDropdown(row, appRefName, crossOrg) {
|
|
265
|
+
const ownerKey = row.owner.kind === "element" ? "element" : "app";
|
|
266
|
+
const filterExpr = row.filter === undefined ? "" : `, filter: ${printDropdownFilter(row.filter)}`;
|
|
267
|
+
if (crossOrg && row.owner.self !== true) {
|
|
268
|
+
const name = row.owner.name ?? row.owner.refName;
|
|
269
|
+
const todo = ` // TODO: cross-org clone — "${name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`;
|
|
270
|
+
const owner = `{ __kind: ${quote(ownerKey)}, refName: ${quote(name)}, name: ${quote(name)} }`;
|
|
271
|
+
const field = `{ __kind: "field", refName: ${quote(row.fieldName)}, name: ${quote(row.fieldName)}, fieldType: "TEXT", parent: ${quote(name)}, parentKind: ${quote(ownerKey)}, parentName: ${quote(name)} }`;
|
|
272
|
+
return `{ ${ownerKey}: ${owner}, field: ${field}, multiple: ${String(row.multiple)}${filterExpr} },${todo}`;
|
|
273
|
+
}
|
|
274
|
+
const refName = row.owner.self === true ? appRefName : row.owner.refName;
|
|
275
|
+
const ownerExpr = `catalog${safeMember(refName)}`;
|
|
276
|
+
const storedName = row.storedFieldName === undefined ? "" : ` fieldName: ${quote(row.storedFieldName)},`;
|
|
277
|
+
return `{ ${ownerKey}: ${ownerExpr}, field: ${ownerExpr}.fields${safeMember(row.fieldKey)},${storedName} multiple: ${String(row.multiple)}${filterExpr} },`;
|
|
278
|
+
}
|
|
211
279
|
/** Dot access for identifier-safe names, bracket access otherwise. */
|
|
212
280
|
function safeMember(name) {
|
|
213
281
|
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? `.${name}` : `[${quote(name)}]`;
|
|
@@ -241,7 +309,8 @@ function printSkillRefToken(ref, appRefName, crossOrg) {
|
|
|
241
309
|
const todo = crossOrg
|
|
242
310
|
? ` // TODO: cross-org clone — "${ref.name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`
|
|
243
311
|
: "";
|
|
244
|
-
|
|
312
|
+
const namespace = ref.appNamespace !== undefined ? `, parentNamespace: ${quote(ref.appNamespace)}` : "";
|
|
313
|
+
return `{ __kind: "skill", refName: ${quote(ref.name)}, name: ${quote(ref.name)}, parent: ${quote(ref.appRefName ?? ref.appName)}, parentName: ${quote(ref.appName)}${namespace} },${todo}`;
|
|
245
314
|
}
|
|
246
315
|
function printStartingActionVariableType(type) {
|
|
247
316
|
if (type === "NUMBER")
|