@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
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
1
|
+
import { expr, renderBlock, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
2
|
+
import { VOICE_AUTH_RESOURCE_TYPE } from "../org/voice-auth.js";
|
|
3
|
+
import { voiceAuthFailureAction } from "./voice-auth.js";
|
|
2
4
|
const CATEGORY = "elementum_category";
|
|
3
5
|
const GROUP = "elementum_group";
|
|
4
6
|
const USER = "elementum_user";
|
|
@@ -150,5 +152,61 @@ export function organizationToTf(organization, ctx) {
|
|
|
150
152
|
for (const [name, block] of resourceVariables)
|
|
151
153
|
variables.set(name, block);
|
|
152
154
|
}
|
|
155
|
+
for (const [key, config] of Object.entries(organization.voiceAuths)) {
|
|
156
|
+
blocks.push({ kind: "resource", type: VOICE_AUTH_RESOURCE_TYPE, label: tsLabelToTfLabel(key), attrs: voiceAuthAttrs(config) });
|
|
157
|
+
}
|
|
153
158
|
return [...variables.values(), ...blocks];
|
|
154
159
|
}
|
|
160
|
+
/** Resource HCL for one organization.ts voice auth, used when adoption imports it. */
|
|
161
|
+
export function renderVoiceAuthAdoptionResource(label, value) {
|
|
162
|
+
if (!isOrganizationVoiceAuth(value))
|
|
163
|
+
return undefined;
|
|
164
|
+
return renderBlock({
|
|
165
|
+
kind: "resource",
|
|
166
|
+
type: VOICE_AUTH_RESOURCE_TYPE,
|
|
167
|
+
label,
|
|
168
|
+
attrs: voiceAuthAttrs(value),
|
|
169
|
+
}).trimEnd();
|
|
170
|
+
}
|
|
171
|
+
function isOrganizationVoiceAuth(value) {
|
|
172
|
+
if (value === null || typeof value !== "object")
|
|
173
|
+
return false;
|
|
174
|
+
const config = value;
|
|
175
|
+
return typeof config.name === "string" && config.name !== ""
|
|
176
|
+
&& typeof config.knownCallers?.treatment === "string"
|
|
177
|
+
&& typeof config.unknownCallers?.treatment === "string"
|
|
178
|
+
&& typeof config.failure?.action === "string";
|
|
179
|
+
}
|
|
180
|
+
function voiceAuthAttrs(config) {
|
|
181
|
+
const knownCallers = { treatment: config.knownCallers.treatment };
|
|
182
|
+
if (config.knownCallers.firstMessage !== undefined)
|
|
183
|
+
knownCallers["first_message"] = config.knownCallers.firstMessage;
|
|
184
|
+
const unknownCallers = { treatment: config.unknownCallers.treatment };
|
|
185
|
+
if (config.unknownCallers.firstMessage !== undefined)
|
|
186
|
+
unknownCallers["first_message"] = config.unknownCallers.firstMessage;
|
|
187
|
+
const failure = { action: config.failure.action };
|
|
188
|
+
if (config.failure.action === voiceAuthFailureAction.handoff) {
|
|
189
|
+
failure["handoff"] = { phone_number: config.failure.phoneNumber, message: config.failure.message };
|
|
190
|
+
}
|
|
191
|
+
else if (config.failure.message !== undefined) {
|
|
192
|
+
failure["end_call_message"] = config.failure.message;
|
|
193
|
+
}
|
|
194
|
+
const attrs = {
|
|
195
|
+
name: config.name,
|
|
196
|
+
known_callers: knownCallers,
|
|
197
|
+
unknown_callers: unknownCallers,
|
|
198
|
+
failure,
|
|
199
|
+
};
|
|
200
|
+
if (config.instructions !== undefined)
|
|
201
|
+
attrs["instructions"] = config.instructions;
|
|
202
|
+
if (config.firstMessage !== undefined)
|
|
203
|
+
attrs["first_message"] = config.firstMessage;
|
|
204
|
+
if (config.otpRecovery !== undefined) {
|
|
205
|
+
attrs["otp_recovery"] = {
|
|
206
|
+
allow_employee_id_correction: config.otpRecovery.allowEmployeeIdCorrection,
|
|
207
|
+
allow_otp_resend: config.otpRecovery.allowOtpResend,
|
|
208
|
+
repeat_provided_employee_id: config.otpRecovery.repeatProvidedEmployeeId,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return attrs;
|
|
212
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** How a voice auth config treats a caller whose number is already known. */
|
|
2
|
+
export declare const knownCallerAuth: {
|
|
3
|
+
readonly continue: "CONTINUE";
|
|
4
|
+
readonly employeeIdAndOtp: "EMPLOYEE_ID_OTP";
|
|
5
|
+
readonly pin: "PIN";
|
|
6
|
+
};
|
|
7
|
+
export type KnownCallerAuth = (typeof knownCallerAuth)[keyof typeof knownCallerAuth];
|
|
8
|
+
/** How a voice auth config treats a caller whose number is not known. */
|
|
9
|
+
export declare const unknownCallerAuth: {
|
|
10
|
+
readonly continue: "CONTINUE";
|
|
11
|
+
readonly stop: "DO_NOT_CONTINUE";
|
|
12
|
+
readonly employeeIdAndOtp: "EMPLOYEE_ID_OTP";
|
|
13
|
+
};
|
|
14
|
+
export type UnknownCallerAuth = (typeof unknownCallerAuth)[keyof typeof unknownCallerAuth];
|
|
15
|
+
/** What a voice auth config does when verification fails. */
|
|
16
|
+
export declare const voiceAuthFailureAction: {
|
|
17
|
+
readonly endCall: "END_CALL";
|
|
18
|
+
readonly handoff: "HANDOFF";
|
|
19
|
+
};
|
|
20
|
+
export type VoiceAuthFailureAction = (typeof voiceAuthFailureAction)[keyof typeof voiceAuthFailureAction];
|
|
21
|
+
export interface VoiceAuthCallerTreatment<Treatment extends string> {
|
|
22
|
+
readonly treatment: Treatment;
|
|
23
|
+
readonly firstMessage?: string;
|
|
24
|
+
}
|
|
25
|
+
/** End the call, optionally after speaking a message. */
|
|
26
|
+
export interface VoiceAuthEndCall {
|
|
27
|
+
readonly action: typeof voiceAuthFailureAction.endCall;
|
|
28
|
+
readonly message?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Transfer the caller to another number. */
|
|
31
|
+
export interface VoiceAuthHandoff {
|
|
32
|
+
readonly action: typeof voiceAuthFailureAction.handoff;
|
|
33
|
+
readonly phoneNumber: `+${number}`;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
}
|
|
36
|
+
export type VoiceAuthFailure = VoiceAuthEndCall | VoiceAuthHandoff;
|
|
37
|
+
export interface VoiceAuthOtpRecovery {
|
|
38
|
+
readonly allowEmployeeIdCorrection: boolean;
|
|
39
|
+
readonly allowOtpResend: boolean;
|
|
40
|
+
readonly repeatProvidedEmployeeId: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface OrganizationVoiceAuth {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly instructions?: string;
|
|
45
|
+
readonly firstMessage?: string;
|
|
46
|
+
readonly knownCallers: VoiceAuthCallerTreatment<KnownCallerAuth>;
|
|
47
|
+
readonly unknownCallers: VoiceAuthCallerTreatment<UnknownCallerAuth>;
|
|
48
|
+
readonly failure: VoiceAuthFailure;
|
|
49
|
+
readonly otpRecovery?: VoiceAuthOtpRecovery;
|
|
50
|
+
}
|
|
51
|
+
/** An organization-owned voice authentication policy for phone services. */
|
|
52
|
+
export declare function voiceAuth(opts: {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly instructions?: string;
|
|
55
|
+
readonly firstMessage?: string;
|
|
56
|
+
readonly knownCallers: VoiceAuthCallerTreatment<KnownCallerAuth>;
|
|
57
|
+
readonly unknownCallers: VoiceAuthCallerTreatment<UnknownCallerAuth>;
|
|
58
|
+
readonly failure: VoiceAuthFailure;
|
|
59
|
+
readonly otpRecovery?: VoiceAuthOtpRecovery;
|
|
60
|
+
}): OrganizationVoiceAuth;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
|
|
2
|
+
/** How a voice auth config treats a caller whose number is already known. */
|
|
3
|
+
export const knownCallerAuth = {
|
|
4
|
+
continue: "CONTINUE",
|
|
5
|
+
employeeIdAndOtp: "EMPLOYEE_ID_OTP",
|
|
6
|
+
pin: "PIN",
|
|
7
|
+
};
|
|
8
|
+
/** How a voice auth config treats a caller whose number is not known. */
|
|
9
|
+
export const unknownCallerAuth = {
|
|
10
|
+
continue: "CONTINUE",
|
|
11
|
+
stop: "DO_NOT_CONTINUE",
|
|
12
|
+
employeeIdAndOtp: "EMPLOYEE_ID_OTP",
|
|
13
|
+
};
|
|
14
|
+
/** What a voice auth config does when verification fails. */
|
|
15
|
+
export const voiceAuthFailureAction = {
|
|
16
|
+
endCall: "END_CALL",
|
|
17
|
+
handoff: "HANDOFF",
|
|
18
|
+
};
|
|
19
|
+
const E164 = /^\+[1-9]\d{7,14}$/;
|
|
20
|
+
function requireTreatment(where, value, allowed) {
|
|
21
|
+
if (value === undefined)
|
|
22
|
+
throw new EdkValidationError(`${where} is required.`);
|
|
23
|
+
if (!Object.values(allowed).includes(value.treatment)) {
|
|
24
|
+
throw new EdkValidationError(`${where}.treatment ${JSON.stringify(value.treatment)} is not supported.`);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
/** An organization-owned voice authentication policy for phone services. */
|
|
29
|
+
export function voiceAuth(opts) {
|
|
30
|
+
if (opts.name.trim() === "")
|
|
31
|
+
throw new EdkValidationError("voiceAuth name must be non-empty.");
|
|
32
|
+
const knownCallers = requireTreatment("voiceAuth knownCallers", opts.knownCallers, knownCallerAuth);
|
|
33
|
+
const unknownCallers = requireTreatment("voiceAuth unknownCallers", opts.unknownCallers, unknownCallerAuth);
|
|
34
|
+
const failure = opts.failure;
|
|
35
|
+
if (failure === undefined)
|
|
36
|
+
throw new EdkValidationError("voiceAuth failure is required.");
|
|
37
|
+
if (failure.action === voiceAuthFailureAction.handoff) {
|
|
38
|
+
if (!E164.test(failure.phoneNumber)) {
|
|
39
|
+
throw new EdkValidationError("voiceAuth failure phoneNumber must be an E.164 number such as +14155551234.");
|
|
40
|
+
}
|
|
41
|
+
if (failure.message.trim() === "")
|
|
42
|
+
throw new EdkValidationError("voiceAuth handoff message must be non-empty.");
|
|
43
|
+
}
|
|
44
|
+
else if (failure.action === voiceAuthFailureAction.endCall) {
|
|
45
|
+
// Accepted. A message is optional.
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const unexpected = failure;
|
|
49
|
+
throw new EdkValidationError(`voiceAuth failure action ${JSON.stringify(unexpected)} is not supported.`);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
name: opts.name,
|
|
53
|
+
...(opts.instructions !== undefined ? { instructions: opts.instructions } : {}),
|
|
54
|
+
...(opts.firstMessage !== undefined ? { firstMessage: opts.firstMessage } : {}),
|
|
55
|
+
knownCallers,
|
|
56
|
+
unknownCallers,
|
|
57
|
+
failure,
|
|
58
|
+
...(opts.otpRecovery !== undefined ? { otpRecovery: opts.otpRecovery } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentRef, type CatalogRef, type PhoneProviderRef, type PhoneServiceRef } from "../../catalog/index.js";
|
|
1
|
+
import { type AgentRef, type CatalogRef, type PhoneProviderRef, type PhoneServiceRef, type VoiceAuthRef } from "../../catalog/index.js";
|
|
2
2
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
3
|
import { type PhoneServiceNumber } from "./types.js";
|
|
4
4
|
/**
|
|
@@ -9,6 +9,14 @@ export type PhoneServiceOptions<AppRefName extends string = string> = EntityDepl
|
|
|
9
9
|
readonly app: CatalogRef<"app", AppRefName>;
|
|
10
10
|
readonly agent: AgentRef<NoInfer<AppRefName>>;
|
|
11
11
|
readonly provider: PhoneProviderRef;
|
|
12
|
+
/**
|
|
13
|
+
* Organization voice-auth policy applied to calls on this number.
|
|
14
|
+
* `catalog.voiceAuths.<key>` after `pull org`. `{ name }` addresses a policy
|
|
15
|
+
* authored in `organization.ts` in the same apply, before that catalog key exists.
|
|
16
|
+
*/
|
|
17
|
+
readonly voiceAuth?: VoiceAuthRef | {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
};
|
|
12
20
|
};
|
|
13
21
|
export interface PhoneServiceConfigured {
|
|
14
22
|
ref(refName: string): PhoneServiceRef;
|
|
@@ -23,6 +23,7 @@ export function phoneService(opts) {
|
|
|
23
23
|
...(opts.twilioExistingNumber !== undefined ? { twilioExistingNumber: opts.twilioExistingNumber } : {}),
|
|
24
24
|
...(opts.twilioNewNumber !== undefined ? { twilioNewNumber: opts.twilioNewNumber } : {}),
|
|
25
25
|
...(opts.registration !== undefined ? { registration: opts.registration } : {}),
|
|
26
|
+
...(opts.voiceAuth !== undefined ? { voiceAuth: opts.voiceAuth } : {}),
|
|
26
27
|
}),
|
|
27
28
|
...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}),
|
|
28
29
|
};
|
|
@@ -27,6 +27,9 @@ export function printPhoneService(service, opts) {
|
|
|
27
27
|
lines.push(` app: catalog.${opts.appRefName},`);
|
|
28
28
|
lines.push(` agent: catalog.${opts.appRefName}.agents.${service.agentKey},`);
|
|
29
29
|
lines.push(` provider: catalog.phoneProviders.${service.providerKey},`);
|
|
30
|
+
if (service.voiceAuthKey !== undefined) {
|
|
31
|
+
lines.push(` voiceAuth: catalog.voiceAuths.${service.voiceAuthKey},`);
|
|
32
|
+
}
|
|
30
33
|
if (service.callerAccessMode !== undefined) {
|
|
31
34
|
lines.push(` callerAccessMode: callerAccessMode.${constantKey(callerAccessMode, service.callerAccessMode)},`);
|
|
32
35
|
}
|
|
@@ -5,6 +5,7 @@ export interface NormalizedPhoneService {
|
|
|
5
5
|
readonly refName: string;
|
|
6
6
|
readonly agentKey: string;
|
|
7
7
|
readonly providerKey: string;
|
|
8
|
+
readonly voiceAuthKey?: string;
|
|
8
9
|
readonly callerAccessMode?: CallerAccessMode;
|
|
9
10
|
readonly twilioExistingNumber?: {
|
|
10
11
|
readonly phoneNumber: E164PhoneNumber;
|
|
@@ -2,9 +2,10 @@ import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../
|
|
|
2
2
|
import { scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
3
3
|
import { AGENT_RESOURCE_TYPE } from "../agent/module.js";
|
|
4
4
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
5
|
+
import { VOICE_AUTH_RESOURCE_TYPE } from "../org/voice-auth.js";
|
|
5
6
|
import { callerAccessMode } from "./types.js";
|
|
6
7
|
const KNOWN_ATTRS = new Set([
|
|
7
|
-
"app_id", "provider_id", "agent_id", "caller_access_mode", "twilio_existing_number",
|
|
8
|
+
"app_id", "provider_id", "agent_id", "caller_access_mode", "voice_auth_config_id", "twilio_existing_number",
|
|
8
9
|
"twilio_new_number", "registration",
|
|
9
10
|
]);
|
|
10
11
|
const CALLER_ACCESS_MODES = new Set(Object.values(callerAccessMode));
|
|
@@ -43,6 +44,11 @@ export function phoneServiceFromTf(block, opts, ctx) {
|
|
|
43
44
|
ctx.diagnostics.push(`${where}: expected exactly one valid Twilio existing number or new area code; skipped`);
|
|
44
45
|
return undefined;
|
|
45
46
|
}
|
|
47
|
+
const voiceAuthLabel = dataRefLabel(block.attrs["voice_auth_config_id"], VOICE_AUTH_RESOURCE_TYPE)
|
|
48
|
+
?? resourceRefLabel(block.attrs["voice_auth_config_id"], VOICE_AUTH_RESOURCE_TYPE);
|
|
49
|
+
if (block.attrs["voice_auth_config_id"] !== undefined && voiceAuthLabel === undefined) {
|
|
50
|
+
ctx.diagnostics.push(`${where}: voice_auth_config_id is not a resolvable ${VOICE_AUTH_RESOURCE_TYPE} reference; omitted`);
|
|
51
|
+
}
|
|
46
52
|
const callerAccess = optionalString(block.attrs, "caller_access_mode", where, ctx);
|
|
47
53
|
if (callerAccess !== undefined && !isCallerAccessMode(callerAccess)) {
|
|
48
54
|
ctx.diagnostics.push(`${where}: unsupported caller_access_mode "${callerAccess}"; omitted`);
|
|
@@ -59,6 +65,7 @@ export function phoneServiceFromTf(block, opts, ctx) {
|
|
|
59
65
|
refName: scopedLabelToBagKey(opts.appLabel, label, "app"),
|
|
60
66
|
agentKey: scopedLabelToBagKey(opts.appLabel, agentLabel, "app"),
|
|
61
67
|
providerKey: tfLabelToTsLabel(providerLabel),
|
|
68
|
+
...(voiceAuthLabel !== undefined ? { voiceAuthKey: tfLabelToTsLabel(voiceAuthLabel) } : {}),
|
|
62
69
|
...(callerAccess !== undefined && isCallerAccessMode(callerAccess) ? { callerAccessMode: callerAccess } : {}),
|
|
63
70
|
...(hasExisting ? { twilioExistingNumber: { phoneNumber: existingNumber } } : {}),
|
|
64
71
|
...(hasCreated ? { twilioNewNumber: { areaCode: areaCode } } : {}),
|
|
@@ -3,6 +3,7 @@ import { expr, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/ind
|
|
|
3
3
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
4
4
|
import { AGENT_RESOURCE_TYPE } from "../agent/module.js";
|
|
5
5
|
import { PHONE_PROVIDER_ORG_BAG } from "../org/phone-provider.js";
|
|
6
|
+
import { VOICE_AUTH_ORG_BAG, VOICE_AUTH_RESOURCE_TYPE } from "../org/voice-auth.js";
|
|
6
7
|
import { PHONE_SERVICE_RESOURCE_TYPE } from "./module.js";
|
|
7
8
|
export function phoneServiceToTf(entity, opts) {
|
|
8
9
|
if (entity.kind !== "phone-service") {
|
|
@@ -29,6 +30,21 @@ export function phoneServiceToTf(entity, opts) {
|
|
|
29
30
|
};
|
|
30
31
|
if (service.callerAccessMode !== undefined)
|
|
31
32
|
attrs["caller_access_mode"] = service.callerAccessMode;
|
|
33
|
+
const voiceAuthWire = service.voiceAuth;
|
|
34
|
+
if (voiceAuthWire !== undefined) {
|
|
35
|
+
const voiceAuth = voiceAuthWire.__kind === "voiceAuth" && voiceAuthWire.refName !== undefined
|
|
36
|
+
? opts.orgRefs.byTsLabel(VOICE_AUTH_ORG_BAG, voiceAuthWire.refName)
|
|
37
|
+
: voiceAuthWire.name !== undefined
|
|
38
|
+
? opts.orgRefs.byName(VOICE_AUTH_ORG_BAG, voiceAuthWire.name)
|
|
39
|
+
: undefined;
|
|
40
|
+
const described = voiceAuthWire.refName ?? voiceAuthWire.name ?? "";
|
|
41
|
+
if (voiceAuth === undefined) {
|
|
42
|
+
throw new EntityTfError(`phone service "${entity.refName}": voice auth "${described}" is not in org.voiceAuths or organization.ts — re-run \`elementum pull org --data-only\` or author it with voiceAuth(...) and pass { name }`);
|
|
43
|
+
}
|
|
44
|
+
attrs["voice_auth_config_id"] = voiceAuth.managed === true
|
|
45
|
+
? expr.resourceAttr(VOICE_AUTH_RESOURCE_TYPE, voiceAuth.tfLabel, ["id"])
|
|
46
|
+
: expr.dataAttr(VOICE_AUTH_RESOURCE_TYPE, voiceAuth.tfLabel, ["id"]);
|
|
47
|
+
}
|
|
32
48
|
if (service.twilioExistingNumber !== undefined) {
|
|
33
49
|
attrs["twilio_existing_number"] = { phone_number: service.twilioExistingNumber.phoneNumber ?? "" };
|
|
34
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
2
|
import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
|
|
3
3
|
import { scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
4
|
-
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
4
|
+
import { elementAuditFieldReference, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
5
|
import { unextractedFieldRefId } from "../view/from-tf.js";
|
|
6
6
|
import { RECORD_CREATE_FORM_RESOURCE_TYPE } from "./module.js";
|
|
7
7
|
const KNOWN_ATTRS = new Set(["app_id", "sections"]);
|
|
@@ -59,7 +59,7 @@ function sectionFromTf(raw, index, formWhere, owner, ctx) {
|
|
|
59
59
|
ctx.diagnostics.push(`${where}: field_ids entry ${JSON.stringify(fieldId)} is not a known field reference; dropped`);
|
|
60
60
|
}
|
|
61
61
|
else
|
|
62
|
-
fields.push(key);
|
|
62
|
+
fields.push(key === resolved ? elementAuditFieldReference(fieldId, key, owner, ctx) : key);
|
|
63
63
|
}
|
|
64
64
|
const agentLabel = resourceRefLabel(rec["agent_id"], "elementum_agent");
|
|
65
65
|
if (rec["agent_id"] !== undefined && agentLabel === undefined) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dataRefLabel, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
2
|
import { expr, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
3
3
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
4
|
-
import { decodeForeignDataField, fieldKeyFromTfRef, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
4
|
+
import { decodeForeignDataField, elementAuditFieldReference, fieldKeyFromTfRef, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
5
|
import { resolveDataAspectTarget, resolveDataTaskTarget } from "../shared/aspect-target-from-tf.js";
|
|
6
6
|
import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
7
7
|
import { bareForeignFieldIdRef, isBarePlatformId, resolveOwnDataFieldRef, unextractedFieldRefId } from "../view/from-tf.js";
|
|
@@ -49,9 +49,14 @@ function relationshipFromTf(block, owner, ctx) {
|
|
|
49
49
|
// A field pull did not extract keeps its platform id: its key would print
|
|
50
50
|
// as nothing and build would drop the column (#1966). With no id the pull
|
|
51
51
|
// fails (#1978).
|
|
52
|
-
const
|
|
52
|
+
const kept = owner.unextracted === undefined
|
|
53
53
|
? fieldKey
|
|
54
54
|
: unextractedFieldRefId(rec["field_id"], fieldKey, owner.unextracted, ctx, `${where}.columns[${index}]`);
|
|
55
|
+
// A platform audit column keeps its own identity next to an own field
|
|
56
|
+
// under the same key, as in views and layouts (#2513).
|
|
57
|
+
const field = kept === undefined || kept !== fieldKey
|
|
58
|
+
? kept
|
|
59
|
+
: elementAuditFieldReference(rec["field_id"], kept, { type: ownerResourceType, label: owner.label, scope: owner.scope, refName: owner.ownerRefName }, ctx);
|
|
55
60
|
// A bare related id ei couldn't name resolves the same way as the owner
|
|
56
61
|
// side, so the join column is never dropped silently (#1991).
|
|
57
62
|
const relatedRaw = rec["related_field_id"];
|
|
@@ -234,7 +239,7 @@ function bareRelatedFieldRef(v, target, owner, ctx, site) {
|
|
|
234
239
|
const targetLabel = ownTarget ? owner.label : target.managed === true ? target.tfLabel : undefined;
|
|
235
240
|
if (imported !== undefined && subType !== undefined && targetLabel !== undefined && resourceRefLabel(imported.attrs["object_id"], targetResourceType(target)) === targetLabel) {
|
|
236
241
|
const scope = target.kind === "element" ? "element" : "app";
|
|
237
|
-
const key = fieldKeyFromTfRef(expr.resourceAttr(imported.type, imported.label, ["id"]), targetLabel, scope);
|
|
242
|
+
const key = fieldKeyFromTfRef(expr.resourceAttr(imported.type, imported.label, ["id"]), targetLabel, scope, ctx);
|
|
238
243
|
if (key !== undefined) {
|
|
239
244
|
return { kind: target.kind === "table" ? "tableColumn" : "field", key, name: key, parent: target.key, fieldType: subType.authoringType };
|
|
240
245
|
}
|
|
@@ -280,7 +285,7 @@ function relatedFieldRef(value, target, ctx) {
|
|
|
280
285
|
// value is already narrowed to a TfExpr above, so fieldKeyFromTfValue's
|
|
281
286
|
// string-literal (state-registry) branch can never fire here - a plain
|
|
282
287
|
// fieldKeyFromTfRef is what this branch actually needs.
|
|
283
|
-
const key = fieldKeyFromTfRef(value, ownerLabel, scope);
|
|
288
|
+
const key = fieldKeyFromTfRef(value, ownerLabel, scope, ctx);
|
|
284
289
|
if (key !== undefined)
|
|
285
290
|
return { kind: target.kind === "table" ? "tableColumn" : "field", key, name: key, parent: target.key, fieldType: subType.authoringType };
|
|
286
291
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NO_CANVAS, NO_CATALOG, NO_LIFECYCLE } from "../../graph/types.js";
|
|
2
|
-
import { relationshipPairErrors } from "./pair-check.js";
|
|
2
|
+
import { relationshipPair, relationshipPairErrors } from "./pair-check.js";
|
|
3
3
|
export const RELATIONSHIP_RESOURCE_TYPE = "elementum_relationship";
|
|
4
4
|
export const relationshipModule = {
|
|
5
5
|
kind: "relationship",
|
|
@@ -14,5 +14,5 @@ export const relationshipModule = {
|
|
|
14
14
|
lifecycle: NO_LIFECYCLE,
|
|
15
15
|
canvas: NO_CANVAS,
|
|
16
16
|
catalog: NO_CATALOG,
|
|
17
|
-
buildChecks: {
|
|
17
|
+
buildChecks: { validateBuiltRoots: relationshipPairErrors, comparedGroup: relationshipPair },
|
|
18
18
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
2
|
+
import type { BuildCheckFailure, BuiltRootSource } from "../../graph/types.js";
|
|
3
|
+
/** The pair a relationship block joins, which build hashes per root against the last pull (edk#2430). */
|
|
4
|
+
export declare function relationshipPair(block: TfBlock): string | undefined;
|
|
2
5
|
/**
|
|
3
6
|
* A relationship between two managed roots is two platform records, one per side, whose columns the platform
|
|
4
7
|
* mirrors: changing one side changes the other. Each side lives in its owner's source, so the two must mirror
|
|
5
|
-
* each other or the next plan reverts a one-sided edit. Returns one
|
|
8
|
+
* each other or the next plan reverts a one-sided edit. Returns one failure per root pair that disagrees,
|
|
9
|
+
* naming both source files and which one differs from its last pull when that is known (edk#2430).
|
|
6
10
|
*/
|
|
7
|
-
export declare function relationshipPairErrors(
|
|
11
|
+
export declare function relationshipPairErrors(roots: readonly BuiltRootSource[]): BuildCheckFailure[];
|
|
@@ -6,7 +6,7 @@ function managedLabel(value) {
|
|
|
6
6
|
function columnLabel(value) {
|
|
7
7
|
return value !== undefined && isTfExpr(value) && (value.$expr === "resource-attr" || value.$expr === "data-attr") ? value.label : JSON.stringify(value);
|
|
8
8
|
}
|
|
9
|
-
function sideOf(block) {
|
|
9
|
+
function sideOf(block, root) {
|
|
10
10
|
const owner = managedLabel(block.attrs["object_id"]);
|
|
11
11
|
const target = managedLabel(block.attrs["related_object_id"]);
|
|
12
12
|
if (owner === undefined || target === undefined || owner === target || block.label === undefined)
|
|
@@ -15,7 +15,7 @@ function sideOf(block) {
|
|
|
15
15
|
const attrs = (column ?? {});
|
|
16
16
|
return [columnLabel(attrs["field_id"]), columnLabel(attrs["related_field_id"])];
|
|
17
17
|
});
|
|
18
|
-
return { label: block.label, owner, target, columns };
|
|
18
|
+
return { label: block.label, owner, target, columns, root, pull: root.pull.group(pairKey(owner, target)) };
|
|
19
19
|
}
|
|
20
20
|
/** Columns as one comparable key, oriented from `from`'s side. */
|
|
21
21
|
function joinKey(side, from) {
|
|
@@ -25,22 +25,99 @@ function joinKey(side, from) {
|
|
|
25
25
|
function describe(side) {
|
|
26
26
|
return `[${side.columns.map(([own, related]) => `${own} ↔ ${related}`).join(", ")}]`;
|
|
27
27
|
}
|
|
28
|
+
function isRelationshipBlock(block) {
|
|
29
|
+
return block.kind === "resource" && block.type === RELATIONSHIP_RESOURCE_TYPE;
|
|
30
|
+
}
|
|
31
|
+
function pairKey(owner, target) {
|
|
32
|
+
return [owner, target].sort().join(" <> ");
|
|
33
|
+
}
|
|
34
|
+
/** The pair a relationship block joins, which build hashes per root against the last pull (edk#2430). */
|
|
35
|
+
export function relationshipPair(block) {
|
|
36
|
+
if (!isRelationshipBlock(block))
|
|
37
|
+
return undefined;
|
|
38
|
+
const owner = managedLabel(block.attrs["object_id"]);
|
|
39
|
+
const target = managedLabel(block.attrs["related_object_id"]);
|
|
40
|
+
return owner === undefined || target === undefined || owner === target ? undefined : pairKey(owner, target);
|
|
41
|
+
}
|
|
42
|
+
const PULLABLE_KINDS = new Set(["app", "element", "task"]);
|
|
43
|
+
function pulledAt(iso) {
|
|
44
|
+
return iso.replace(/\.\d+Z$/, "Z");
|
|
45
|
+
}
|
|
46
|
+
function repull(root) {
|
|
47
|
+
return PULLABLE_KINDS.has(root.kind) ? `\`elementum pull ${root.kind} ${root.tfLabel}\`` : `a fresh pull of ${root.file}`;
|
|
48
|
+
}
|
|
49
|
+
/** One side's relationships against its last pull on this machine, as a clause naming its file. */
|
|
50
|
+
function pullClause(side) {
|
|
51
|
+
const { root, pull: status } = side;
|
|
52
|
+
switch (status.state) {
|
|
53
|
+
case "unchecked":
|
|
54
|
+
return `${root.file} isn't compared with its pull record in this build`;
|
|
55
|
+
case "unreadable":
|
|
56
|
+
return status.what === "record"
|
|
57
|
+
? `${root.file}'s pull record couldn't be read (.edk-state/pulled-roots.json)`
|
|
58
|
+
: `${root.file} couldn't be read to compare with its pull record`;
|
|
59
|
+
case "unrecorded":
|
|
60
|
+
return `${root.file} has no pull record on this machine`;
|
|
61
|
+
case "unchanged":
|
|
62
|
+
return status.fileEdited
|
|
63
|
+
? `${root.file} was edited after its last pull (${pulledAt(status.pulledAt)}) but not its relationships to ${side.target}`
|
|
64
|
+
: `${root.file} still matches its last pull (${pulledAt(status.pulledAt)})`;
|
|
65
|
+
case "edited":
|
|
66
|
+
return `${root.file}'s relationships to ${side.target} were edited after its last pull (${pulledAt(status.pulledAt)})`;
|
|
67
|
+
case "unknown":
|
|
68
|
+
return `${root.file} was edited after its last pull (${pulledAt(status.pulledAt)}), and whether that touched its relationships to ${side.target} isn't known`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function pulledTogether(a, b) {
|
|
72
|
+
return a.pulledAt === b.pulledAt || (a.pullRun !== undefined && a.pullRun === b.pullRun);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Which of the two sides' relationships differ from their last pull on this machine, as far as that is known.
|
|
76
|
+
* Only this pair's relationships count: an edit elsewhere in a file doesn't make its side the stale one (edk#2430).
|
|
77
|
+
*/
|
|
78
|
+
function staleness(leftSide, rightSide) {
|
|
79
|
+
const [left, right] = [leftSide.root, rightSide.root];
|
|
80
|
+
const [a, b] = [leftSide.pull, rightSide.pull];
|
|
81
|
+
if (a.state === "unchecked" || b.state === "unchecked") {
|
|
82
|
+
return "This build doesn't compare files with their pull records, so which side is stale isn't checked.";
|
|
83
|
+
}
|
|
84
|
+
const sides = `${pullClause(leftSide)}; ${pullClause(rightSide)}`;
|
|
85
|
+
// A re-pull rewrites the whole file, so it's only offered for a file with no edits since its pull (edk#2430).
|
|
86
|
+
if ((a.state === "edited" && b.state === "unchanged") || (a.state === "unchanged" && b.state === "edited")) {
|
|
87
|
+
const [edited, untouched] = a.state === "edited" ? [left, right] : [right, left];
|
|
88
|
+
return `${sides}, so the edit is the difference: make the same change in ${untouched.file}, or undo it in ${edited.file} by hand.`;
|
|
89
|
+
}
|
|
90
|
+
if (a.state === "unchanged" && b.state === "unchanged") {
|
|
91
|
+
if (pulledTogether(a, b)) {
|
|
92
|
+
return a.fileEdited || b.fileEdited
|
|
93
|
+
? `${sides}, and the two were pulled together, so the platform returned the two sides this way; compare both with the platform and fix the relationship by hand.`
|
|
94
|
+
: `${sides}, and the two were pulled together, so the platform returned the two sides this way; re-pull both before changing either.`;
|
|
95
|
+
}
|
|
96
|
+
const [older, newer, olderStatus] = a.pulledAt < b.pulledAt ? [left, right, a] : [right, left, b];
|
|
97
|
+
const fix = olderStatus.fileEdited
|
|
98
|
+
? `mirror ${newer.file}'s side into it by hand (a re-pull would also drop its other edits since that pull)`
|
|
99
|
+
: `re-pull it with ${repull(older)} before hand-editing either`;
|
|
100
|
+
return `${sides}, and ${older.file} was pulled before ${newer.file}, so ${older.file} is the likely stale side: ${fix}.`;
|
|
101
|
+
}
|
|
102
|
+
return `${sides}, so which side is stale isn't known; compare both with the platform before changing either.`;
|
|
103
|
+
}
|
|
28
104
|
/**
|
|
29
105
|
* A relationship between two managed roots is two platform records, one per side, whose columns the platform
|
|
30
106
|
* mirrors: changing one side changes the other. Each side lives in its owner's source, so the two must mirror
|
|
31
|
-
* each other or the next plan reverts a one-sided edit. Returns one
|
|
107
|
+
* each other or the next plan reverts a one-sided edit. Returns one failure per root pair that disagrees,
|
|
108
|
+
* naming both source files and which one differs from its last pull when that is known (edk#2430).
|
|
32
109
|
*/
|
|
33
|
-
export function relationshipPairErrors(
|
|
34
|
-
const sides = blocks
|
|
35
|
-
.filter(
|
|
36
|
-
.map(sideOf)
|
|
37
|
-
.filter((side) => side !== undefined);
|
|
110
|
+
export function relationshipPairErrors(roots) {
|
|
111
|
+
const sides = roots.flatMap((root) => root.blocks
|
|
112
|
+
.filter(isRelationshipBlock)
|
|
113
|
+
.map((block) => sideOf(block, root))
|
|
114
|
+
.filter((side) => side !== undefined));
|
|
38
115
|
const byPair = new Map();
|
|
39
116
|
for (const side of sides) {
|
|
40
|
-
const pair =
|
|
117
|
+
const pair = pairKey(side.owner, side.target);
|
|
41
118
|
byPair.set(pair, [...(byPair.get(pair) ?? []), side]);
|
|
42
119
|
}
|
|
43
|
-
const
|
|
120
|
+
const failures = [];
|
|
44
121
|
for (const [pair, pairSides] of byPair) {
|
|
45
122
|
const [first] = pair.split(" <> ");
|
|
46
123
|
const a = pairSides.filter((side) => side.owner === first);
|
|
@@ -51,18 +128,28 @@ export function relationshipPairErrors(blocks) {
|
|
|
51
128
|
const keysB = b.map((side) => joinKey(side, first)).sort();
|
|
52
129
|
if (keysA.join(" | ") === keysB.join(" | "))
|
|
53
130
|
continue;
|
|
131
|
+
const [left, right] = [a[0], b[0]];
|
|
132
|
+
const address = `${RELATIONSHIP_RESOURCE_TYPE}.${left.label}`;
|
|
133
|
+
const stale = staleness(left, right);
|
|
54
134
|
if (a.length === 1 && b.length === 1) {
|
|
55
|
-
const [left, right] = [a[0], b[0]];
|
|
56
135
|
const mirrored = `[${left.columns.map(([own, related]) => `${related} ↔ ${own}`).join(", ")}]`;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
136
|
+
failures.push({
|
|
137
|
+
address,
|
|
138
|
+
name: left.label,
|
|
139
|
+
message: `relationship ${left.label} (${left.root.file}) joins ${describe(left)} but its counterpart ${right.label} (${right.root.file}) joins ${describe(right)}. ` +
|
|
140
|
+
`The platform mirrors the two sides, so change both: ${right.label} should join ${mirrored} ` +
|
|
141
|
+
`(or ${left.label} should mirror ${right.label}). ${stale}`,
|
|
142
|
+
});
|
|
60
143
|
}
|
|
61
144
|
else {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
145
|
+
failures.push({
|
|
146
|
+
address,
|
|
147
|
+
name: left.label,
|
|
148
|
+
message: `relationships between ${left.owner} (${left.root.file}) and ${right.owner} (${right.root.file}) don't mirror each other: ` +
|
|
149
|
+
`${a.map((side) => `${side.label} ${describe(side)}`).join("; ")} vs ` +
|
|
150
|
+
`${b.map((side) => `${side.label} ${describe(side)}`).join("; ")}. The platform mirrors the two sides, so change both. ${stale}`,
|
|
151
|
+
});
|
|
65
152
|
}
|
|
66
153
|
}
|
|
67
|
-
return
|
|
154
|
+
return failures;
|
|
68
155
|
}
|
|
@@ -4,6 +4,7 @@ import { filterToTf } from "../access-policy/to-tf.js";
|
|
|
4
4
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
5
5
|
import { authoredFieldKeysFromPayload, droppedEntryGap, fieldLookupName, fieldRefToTfValue, skippedResourceGap, unauthoredSiblingFieldRef, UNRESOLVED_FIELD_REF, } from "../field/to-tf.js";
|
|
6
6
|
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
|
|
7
|
+
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
7
8
|
import { autoRelationColumnError } from "./column-contract.js";
|
|
8
9
|
import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
|
|
9
10
|
import { EntityTfError } from "../../engine/entity.js";
|
|
@@ -120,8 +121,10 @@ function resolveOwnerField(value, where, opts) {
|
|
|
120
121
|
return undefined;
|
|
121
122
|
}
|
|
122
123
|
if (typeof value === "string") {
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
// An element's audit keys build to its platform audit field (#2513); the
|
|
125
|
+
// audit-field guard refuses them on an element without audit fields.
|
|
126
|
+
if (opts.scope === "element" && !ELEMENT_SYSTEM_FIELD_KEYS.includes(value)) {
|
|
127
|
+
opts.diagnostics.push(`${where}: element relationships only support system fields ${ELEMENT_SYSTEM_FIELD_KEYS.map((key) => `"${key}"`).join(", ")}; dropped`);
|
|
125
128
|
return undefined;
|
|
126
129
|
}
|
|
127
130
|
const attr = SYSTEM_FIELD_ID_ATTR_BY_KEY.get(value);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GroupRef } from "../../catalog/index.js";
|
|
2
|
+
import type { FilterUserRef } from "../shared/filters/index.js";
|
|
2
3
|
import type { ServiceAccountRef } from "../service-account/ref.js";
|
|
3
4
|
declare const roleAutoShareBrand: unique symbol;
|
|
4
5
|
export type RoleAutoShare = string & {
|
|
@@ -45,10 +46,8 @@ export interface RolePermission {
|
|
|
45
46
|
readonly level: RolePermissionLevel;
|
|
46
47
|
readonly customPermissions?: readonly string[];
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
readonly email: string;
|
|
51
|
-
}
|
|
49
|
+
/** A user named by email. The same shape filters take as a value (#2891). */
|
|
50
|
+
export type RoleUserRef = FilterUserRef;
|
|
52
51
|
export declare function userRef(email: string): RoleUserRef;
|
|
53
52
|
export type RoleGroupRef = GroupRef;
|
|
54
53
|
/** One custom app/element role. Managed Admin/Edit/View roles stay data lookups. */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RolePermission } from "./build.js";
|
|
2
|
+
/**
|
|
3
|
+
* Why a role permission's level can't be used with its group, or undefined
|
|
4
|
+
* when it can. CUSTOM, NONE and groups the table doesn't list are left to
|
|
5
|
+
* the provider, as it does.
|
|
6
|
+
*/
|
|
7
|
+
export declare function rolePermissionLevelError(permission: RolePermission): string | undefined;
|