@salesforce/plugin-bre-to-cml 1.2.17 → 1.3.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.
Files changed (50) hide show
  1. package/README.md +117 -4
  2. package/lib/commands/cml/convert/surcharge-rules.d.ts +12 -0
  3. package/lib/commands/cml/convert/surcharge-rules.js +79 -5
  4. package/lib/commands/cml/convert/surcharge-rules.js.map +1 -1
  5. package/lib/commands/cml/convert/underwriting-rules.d.ts +51 -3
  6. package/lib/commands/cml/convert/underwriting-rules.js +206 -13
  7. package/lib/commands/cml/convert/underwriting-rules.js.map +1 -1
  8. package/lib/commands/insurance/import/record-updates.d.ts +66 -0
  9. package/lib/commands/insurance/import/record-updates.js +239 -0
  10. package/lib/commands/insurance/import/record-updates.js.map +1 -0
  11. package/lib/shared/cml-operators.d.ts +9 -1
  12. package/lib/shared/cml-operators.js +23 -5
  13. package/lib/shared/cml-operators.js.map +1 -1
  14. package/lib/shared/insurance/confirm-org-changes.d.ts +49 -0
  15. package/lib/shared/insurance/confirm-org-changes.js +43 -0
  16. package/lib/shared/insurance/confirm-org-changes.js.map +1 -0
  17. package/lib/shared/insurance/insurance-cml-merge.d.ts +198 -5
  18. package/lib/shared/insurance/insurance-cml-merge.js +504 -28
  19. package/lib/shared/insurance/insurance-cml-merge.js.map +1 -1
  20. package/lib/shared/insurance/insurance-context-tags.d.ts +124 -0
  21. package/lib/shared/insurance/insurance-context-tags.js +210 -0
  22. package/lib/shared/insurance/insurance-context-tags.js.map +1 -0
  23. package/lib/shared/insurance/insurance-org.d.ts +12 -0
  24. package/lib/shared/insurance/insurance-org.js +38 -2
  25. package/lib/shared/insurance/insurance-org.js.map +1 -1
  26. package/lib/shared/insurance/insurance-rule-convert-command.d.ts +27 -0
  27. package/lib/shared/insurance/insurance-rule-convert-command.js +57 -4
  28. package/lib/shared/insurance/insurance-rule-convert-command.js.map +1 -1
  29. package/lib/shared/insurance/insurance-rule-generator.d.ts +101 -8
  30. package/lib/shared/insurance/insurance-rule-generator.js +293 -42
  31. package/lib/shared/insurance/insurance-rule-generator.js.map +1 -1
  32. package/lib/shared/insurance/models.d.ts +2 -1
  33. package/lib/shared/insurance/planned-change-mapper.d.ts +15 -0
  34. package/lib/shared/insurance/planned-change-mapper.js +51 -0
  35. package/lib/shared/insurance/planned-change-mapper.js.map +1 -0
  36. package/lib/shared/insurance/planned-change.d.ts +83 -0
  37. package/lib/shared/insurance/planned-change.js +74 -0
  38. package/lib/shared/insurance/planned-change.js.map +1 -0
  39. package/lib/shared/insurance/record-update-apply.d.ts +100 -0
  40. package/lib/shared/insurance/record-update-apply.js +303 -0
  41. package/lib/shared/insurance/record-update-apply.js.map +1 -0
  42. package/lib/shared/insurance/record-update-plan.d.ts +104 -0
  43. package/lib/shared/insurance/record-update-plan.js +397 -0
  44. package/lib/shared/insurance/record-update-plan.js.map +1 -0
  45. package/messages/cml.convert.surcharge-rules.md +3 -1
  46. package/messages/cml.convert.underwriting-rules.md +1 -1
  47. package/messages/insurance.import.record-updates.md +176 -0
  48. package/oclif.lock +25 -25
  49. package/oclif.manifest.json +95 -3
  50. package/package.json +16 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-updates.js","sourceRoot":"","sources":["../../../../src/commands/insurance/import/record-updates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAW,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAC/G,OAAO,EAEL,eAAe,EACf,YAAY,GACb,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAIL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EA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;;;GAQG;AACH,SAAS,kBAAkB,CAAC,QAA+B,EAAE,OAAe,EAAE,KAAa;IACzF,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC;IAChE,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC,WAAW,CAAC,mCAAmC,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACjH,CAAC;IACD,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC,WAAW,CAAC,gCAAgC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7G,OAAO,QAAQ,CAAC,WAAW,CAAC,qBAAqB,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1F,CAAC"}
@@ -2,7 +2,15 @@ import { RuleConditionOperator } from './models.js';
2
2
  export declare function escapeQuotes(str: string): string;
3
3
  export declare function doubleQuoted(str: string | undefined): string;
4
4
  export declare function doubleQuotedIfNeeded(value: string | string[] | undefined, dataType: string | undefined): string;
5
- export declare function generateInCmlExpression(left: string, right: string | string[]): string;
5
+ /**
6
+ * Expands an In list into a chain of `==` comparisons. Because those are equality comparisons, the
7
+ * values follow the same quoting rule Equals follows: quoted only for `string`. Quoting a value
8
+ * against an attribute the model declares `decimal` compares a number with a string literal, and
9
+ * the comparison never fires.
10
+ *
11
+ * `dataType` is optional and last so existing callers that pass none keep emitting quoted values.
12
+ */
13
+ export declare function generateInCmlExpression(left: string, right: string | string[], dataType?: string): string;
6
14
  export declare function convertToCmlExpression(left: string, ruleExprOperator: RuleConditionOperator, right?: string | string[], dataType?: string): string;
7
15
  export declare function isKnownOperator(op: string): op is RuleConditionOperator;
8
16
  export declare function operatorRequiresValues(op: RuleConditionOperator): boolean;
@@ -14,11 +14,29 @@ export function doubleQuotedIfNeeded(value, dataType) {
14
14
  const singleValue = value[0];
15
15
  return `${dataType === 'string' ? doubleQuoted(singleValue) ?? '' : singleValue ?? "''"}`;
16
16
  }
17
- export function generateInCmlExpression(left, right) {
17
+ /**
18
+ * Whether values of this resolved CML type are emitted quoted. An absent type means the caller
19
+ * resolved none, and quoting is the conservative direction — an unquoted value reaches the curated
20
+ * model verbatim. (`doubleQuotedIfNeeded` predates this and reads an absent type as non-string;
21
+ * `In`/`NotIn` are new to type-awareness, so an omitted type keeps their long-standing quoting.)
22
+ */
23
+ function quotesValues(dataType) {
24
+ return dataType === undefined || dataType === 'string';
25
+ }
26
+ /**
27
+ * Expands an In list into a chain of `==` comparisons. Because those are equality comparisons, the
28
+ * values follow the same quoting rule Equals follows: quoted only for `string`. Quoting a value
29
+ * against an attribute the model declares `decimal` compares a number with a string literal, and
30
+ * the comparison never fires.
31
+ *
32
+ * `dataType` is optional and last so existing callers that pass none keep emitting quoted values.
33
+ */
34
+ export function generateInCmlExpression(left, right, dataType) {
35
+ const emit = (value) => (quotesValues(dataType) ? doubleQuoted(value) : value);
18
36
  if (typeof right === 'string') {
19
- return `${left} == ${doubleQuoted(right)}`;
37
+ return `${left} == ${emit(right)}`;
20
38
  }
21
- return right.map((r) => `${left} == ${doubleQuoted(r)}`).join(' || ');
39
+ return right.map((r) => `${left} == ${emit(r)}`).join(' || ');
22
40
  }
23
41
  function firstValue(right) {
24
42
  if (right === undefined)
@@ -49,12 +67,12 @@ export function convertToCmlExpression(left, ruleExprOperator, right, dataType)
49
67
  return `!strcontain(${left}, ${doubleQuoted(firstValue(right))})`;
50
68
  case 'In':
51
69
  if (right) {
52
- return `(${generateInCmlExpression(left, right)})`;
70
+ return `(${generateInCmlExpression(left, right, dataType)})`;
53
71
  }
54
72
  return `${left} == null`;
55
73
  case 'NotIn':
56
74
  if (right) {
57
- return `!(${generateInCmlExpression(left, right)})`;
75
+ return `!(${generateInCmlExpression(left, right, dataType)})`;
58
76
  }
59
77
  return `${left} != null`;
60
78
  default: {
@@ -1 +1 @@
1
- {"version":3,"file":"cml-operators.js","sourceRoot":"","sources":["../../src/shared/cml-operators.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAuB;IAClD,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC;IAClC,CAAC;IACD,OAAO,GAAG,IAAI,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAoC,EAAE,QAA4B;IACrG,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;QAC9D,OAAO,GAAG,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;IAChF,CAAC;IACD,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,GAAG,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,IAAY,EAAE,KAAwB;IAC5E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAI,OAAO,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GA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Y,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACpE,KAAK,IAAI;YACP,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;YAC/D,CAAC;YACD,OAAO,GAAG,IAAI,UAAU,CAAC;QAC3B,KAAK,OAAO;YACV,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,uBAAuB,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;YAChE,CAAC;YACD,OAAO,GAAG,IAAI,UAAU,CAAC;QAC3B,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,UAAU,GAAU,gBAAgB,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAwB;IAC1E,QAAQ;IACR,WAAW;IACX,UAAU;IACV,kBAAkB;IAClB,aAAa;IACb,qBAAqB;IACrB,WAAW;IACX,QAAQ;IACR,UAAU;IACV,gBAAgB;IAChB,IAAI;IACJ,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,OAAO,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,cAAc,GAAuC,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAE5F,MAAM,UAAU,sBAAsB,CAAC,EAAyB;IAC9D,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The confirmation gate for the org-mutating insurance import commands
3
+ * (export/review/import design, work item W-23654540 §4). Callers MUST have rendered the full
4
+ * PlannedChange[] — built from read-only operations — before calling this, and MUST NOT issue any
5
+ * write until it resolves.
6
+ *
7
+ * Used today by `insurance import record-updates`; the matrix is command-agnostic, so
8
+ * `cml import as-expression-set` can gate on it when that work lands (§7 step 12).
9
+ */
10
+ /** Minimal surface the gate needs, so it is unit-testable without oclif. */
11
+ export type ConfirmHost = {
12
+ warn(message: string): unknown;
13
+ confirm(options: {
14
+ message: string;
15
+ ms?: number;
16
+ defaultAnswer?: boolean;
17
+ }): Promise<boolean>;
18
+ };
19
+ export type ConfirmOptions = {
20
+ noPrompt: boolean;
21
+ /**
22
+ * Whether a human can actually answer. Callers pass
23
+ * `process.stdout.isTTY && process.stdin.isTTY && !this.jsonEnabled()`.
24
+ */
25
+ interactive: boolean;
26
+ };
27
+ export type ConfirmText = {
28
+ /** Warning emitted when `--no-prompt` bypasses the gate. */
29
+ skippingPrompt: string;
30
+ /** The confirmation question (no question mark, no Y/N — `confirm` adds those). */
31
+ confirmApply: string;
32
+ /**
33
+ * Built lazily: the prompt could not run and `--no-prompt` was not passed. Must carry remediation
34
+ * actions, and must name which cause applied — a terminal that cannot prompt and a `--json` run
35
+ * that must not prompt need different remediation.
36
+ */
37
+ confirmationRequired: () => Error;
38
+ /** Built lazily: the operator answered "no". */
39
+ aborted: () => Error;
40
+ };
41
+ /**
42
+ * Applies the confirmation matrix. Returns normally only when the caller may proceed to write.
43
+ *
44
+ * A non-interactive invocation without `--no-prompt` fails fast instead of prompting: `confirm`
45
+ * does not throw on timeout, it returns `defaultAnswer` (false) after `ms`, which in CI reads as a
46
+ * 30-second hang followed by a silent abort. Detecting up front turns that into an immediate,
47
+ * actionable error.
48
+ */
49
+ export declare function confirmOrThrow(host: ConfirmHost, options: ConfirmOptions, text: ConfirmText): Promise<void>;
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /** How long to wait for an answer before falling back to the (negative) default. */
17
+ const CONFIRM_TIMEOUT_MS = 30_000;
18
+ /**
19
+ * Applies the confirmation matrix. Returns normally only when the caller may proceed to write.
20
+ *
21
+ * A non-interactive invocation without `--no-prompt` fails fast instead of prompting: `confirm`
22
+ * does not throw on timeout, it returns `defaultAnswer` (false) after `ms`, which in CI reads as a
23
+ * 30-second hang followed by a silent abort. Detecting up front turns that into an immediate,
24
+ * actionable error.
25
+ */
26
+ export async function confirmOrThrow(host, options, text) {
27
+ if (options.noPrompt) {
28
+ host.warn(text.skippingPrompt);
29
+ return;
30
+ }
31
+ if (!options.interactive) {
32
+ throw text.confirmationRequired();
33
+ }
34
+ const proceed = await host.confirm({
35
+ message: text.confirmApply,
36
+ defaultAnswer: false,
37
+ ms: CONFIRM_TIMEOUT_MS,
38
+ });
39
+ if (!proceed) {
40
+ throw text.aborted();
41
+ }
42
+ }
43
+ //# sourceMappingURL=confirm-org-changes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-org-changes.js","sourceRoot":"","sources":["../../../src/shared/insurance/confirm-org-changes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0CH,oFAAoF;AACpF,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAiB,EAAE,OAAuB,EAAE,IAAiB;IAChG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/B,OAAO;IACT,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACpC,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,YAAY;QAC1B,aAAa,EAAE,KAAK;QACpB,EAAE,EAAE,kBAAkB;KACvB,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { Connection } from '@salesforce/core';
2
2
  import { ParsedRuleDefinition, RuleRecord } from './models.js';
3
+ import { AttributeDataTypes } from './insurance-rule-generator.js';
4
+ import { ContextTagBindings } from './insurance-context-tags.js';
3
5
  /**
4
6
  * MERGE MODE (insurance-only): instead of building a fresh single-type CML and PATCH-replacing
5
7
  * the org's curated "Gold Standard" ConstraintModel, this module reads the existing model text,
@@ -11,10 +13,36 @@ import { ParsedRuleDefinition, RuleRecord } from './models.js';
11
13
  *
12
14
  * Why pathed keys: when a ProductSurcharge is persisted as ConstraintEngine the platform
13
15
  * auto-generates `RuleKey` as `SC` + sanitize(ProductCode) of every segment in ProductPath (in
14
- * order) + sanitize(apiName), joined by `__`. The Core surcharge engine matches the fired CML rule
15
- * key against that auto-generated RuleKey by exact string, so the CML rule key MUST be pathed too.
16
+ * order) + sanitize(leaf), joined by `__`. The leaf is the parent `Surcharge.Code` (resolved via
17
+ * ProductSurcharge.SurchargeId), NOT the rule apiName — see {@link fetchSurchargeCodes} and
18
+ * {@link buildPathedSurchargeRules}. The Core surcharge engine matches the fired CML rule key
19
+ * against that auto-generated RuleKey by exact string, so the CML rule key MUST be pathed and use
20
+ * the same Code-derived leaf.
16
21
  */
17
22
  export declare const SURCHARGE_RULE_ACTION = "InsuranceSurchargeRule";
23
+ /**
24
+ * A context-tag reference the merge will DECLARE into the model so the rule's expression resolves.
25
+ *
26
+ * Only a BRE `Tag` condition (`attributeId` null) produces one of these, and only when the tag
27
+ * resolved unambiguously against the org's context metadata (see insurance-context-tags.ts). An
28
+ * `Attribute` condition never does: those name product attributes the curated model is expected to
29
+ * already declare, and auto-declaring one would paper over the real cause — usually that the rule
30
+ * targets a type belonging to a different model.
31
+ */
32
+ export type ContextTagDeclaration = {
33
+ /** Raw ContextTag.Title, e.g. `Cause Of Loss`. Carried verbatim by the emitted annotation. */
34
+ tag: string;
35
+ /**
36
+ * `sanitizeName(tag)`, so the CML identifier stays legal even when the title contains spaces or
37
+ * punctuation. The TRUE name is never lost — it travels in the `tagName` / `contextPath`
38
+ * annotation, which is what actually binds the value.
39
+ */
40
+ identifier: string;
41
+ /** CML declaration type from ContextAttribute.DataType (e.g. `date`, `decimal(2)`). */
42
+ cmlType: string;
43
+ /** Which binding form to emit: a top-level `extern`, or an in-type `@(tagName = ...)`. */
44
+ scope: 'transaction' | 'item';
45
+ };
18
46
  export type PathedSurchargeRule = {
19
47
  recordId: string;
20
48
  recordName: string;
@@ -34,6 +62,19 @@ export type PathedSurchargeRule = {
34
62
  statement: string;
35
63
  /** Sanitized attribute names referenced by the rule declaration (for visibility warnings). */
36
64
  referencedAttributes: string[];
65
+ /**
66
+ * The context-tag references this rule needs, resolved against the org. The merge declares each
67
+ * one that the model does not already carry, and treats it as visible for the absent-reference
68
+ * gate. A tag that did NOT resolve is deliberately absent from this list, so it stays invisible to
69
+ * the gate and its rule is withheld exactly as before.
70
+ */
71
+ contextTagDeclarations: ContextTagDeclaration[];
72
+ /**
73
+ * Set when {@link findUnconvertibleConditions} found something in this rule CML cannot express.
74
+ * The merge refuses such a rule outright — `statement` is built anyway (the shapes stay uniform)
75
+ * but must never be placed.
76
+ */
77
+ unconvertibleReason?: string;
37
78
  };
38
79
  export type MergePlacement = {
39
80
  rule: PathedSurchargeRule;
@@ -49,13 +90,65 @@ export type MergeResult = {
49
90
  skips: MergeSkip[];
50
91
  attributeWarnings: string[];
51
92
  };
93
+ export type UwMergePlacement = {
94
+ rule: UnderwritingConstraintRule;
95
+ status: 'inserted' | 'replaced';
96
+ };
97
+ export type UwMergeSkip = {
98
+ rule: UnderwritingConstraintRule;
99
+ reason: string;
100
+ };
101
+ export type UwMergeResult = {
102
+ mergedCml: string;
103
+ placements: UwMergePlacement[];
104
+ skips: UwMergeSkip[];
105
+ attributeWarnings: string[];
106
+ };
107
+ /**
108
+ * Underwriting analogue of {@link PathedSurchargeRule}: instead of a `rule(...)` action statement,
109
+ * underwriting eligibility is emitted as a named `constraint <name> = (<expr>, "<label>");`
110
+ * statement nested inside the leaf product's `type` block (see `buildCmlModel`'s constraint-form
111
+ * branch in insurance-rule-generator.ts, which this mirrors for merge mode).
112
+ */
113
+ export type UnderwritingConstraintRule = {
114
+ recordId: string;
115
+ recordName: string;
116
+ apiName: string;
117
+ /** Full pathed key: UW__<code-of-each-path-segment>__<apiName> (advisory; not emitted in the constraint form, but tracked for the RuleKeyMapping output). */
118
+ ruleKey: string;
119
+ /** Ordered ProductCodes for every ProductPath segment. Empty when the source ProductPath was blank/whitespace-only. */
120
+ pathProductCodes: string[];
121
+ /** Leaf CML type name (ConstraintModelTag of the LAST ProductPath segment). */
122
+ typeName: string | undefined;
123
+ /** Sanitized constraint name used in the CML (the `constraint <name> = (...)` identifier). */
124
+ constraintName: string;
125
+ /** The full generated `constraint <name> = (<expr>, "<label>");` statement. */
126
+ statement: string;
127
+ /**
128
+ * Attributes the declaration references, with their derived CML type — used to auto-insert
129
+ * missing attribute declarations into the leaf type block during merge.
130
+ */
131
+ referencedAttributes: Array<{
132
+ name: string;
133
+ cmlType: string;
134
+ }>;
135
+ /** See {@link PathedSurchargeRule.unconvertibleReason}. */
136
+ unconvertibleReason?: string;
137
+ };
52
138
  /**
53
139
  * Builds the pathed surcharge rule key that mirrors the platform's auto-generated
54
140
  * `ProductSurcharge.RuleKey`: prefix + every path-segment product code + apiName.
55
141
  */
56
142
  export declare function buildPathedRuleKey(prefix: string, pathProductCodes: string[], apiName: string, stageTransition?: string): string;
57
- /** Splits a `ProductPath` into its ordered Product2 ids (slash-separated). */
58
- export declare function splitProductPath(productPath: string): string[];
143
+ /**
144
+ * Splits a `ProductPath` into its ordered Product2 ids (slash-separated).
145
+ *
146
+ * ProductPath is nullable in the org even on records that carry a rule, so nullish input yields an
147
+ * empty path rather than throwing. Callers rely on that: an empty path is already a recognized skip
148
+ * (see the empty-ProductPath guard in mergeSurchargeRules), whereas throwing here aborted the whole
149
+ * conversion run before any record could be skipped.
150
+ */
151
+ export declare function splitProductPath(productPath: string | null | undefined): string[];
59
152
  /**
60
153
  * Reads the org's existing ConstraintModel text for the given CML API name, mirroring the lookup
61
154
  * the common import uses (ExpressionSetDefinition.DeveloperName -> ExpressionSetDefinitionVersion).
@@ -72,16 +165,88 @@ export declare function fetchExistingConstraintModel(conn: Connection, cmlApiNam
72
165
  * correct way to find which existing `type` block a surcharge's leaf product nests into.
73
166
  */
74
167
  export declare function fetchProductTypeTags(conn: Connection, productIds: Set<string>): Promise<Map<string, string>>;
168
+ /**
169
+ * Resolves Surcharge id -> Surcharge.Code. The platform builds the LEAF segment of
170
+ * `ProductSurcharge.RuleKey` from the parent Surcharge's Code (e.g. `basictaxcode`), NOT from the
171
+ * rule apiName. `buildPathedSurchargeRules` uses this map so the emitted CML rule key matches the
172
+ * platform-generated RuleKey exactly; without it the surcharge imports cleanly but never fires
173
+ * ("No active rule model found"). Ids with no resolvable Code are omitted (caller warns + falls
174
+ * back to apiName).
175
+ */
176
+ export declare function fetchSurchargeCodes(conn: Connection, surchargeIds: Set<string>): Promise<Map<string, string>>;
177
+ export declare function escapeRegExp(value: string): string;
178
+ /**
179
+ * [Fix #4] Detects the dominant line ending of a CML text by counting CRLF vs bare-LF occurrences.
180
+ * Returns `\r\n` when at least one CRLF appears AND CRLFs are at least as common as bare LFs (mixed
181
+ * CRLF-majority files still get CRLF; pure-LF and empty files get `\n`). Used by the INSERT path so
182
+ * a CRLF-curated model stays byte-clean after splicing. The L2 replace path preserves the line
183
+ * ending of the REPLACED span directly, so this only matters for new inserts.
184
+ */
185
+ export declare function detectDominantLineEnding(cml: string): string;
186
+ /**
187
+ * Brace-matches the block whose opening `{` is at `openIdx` and returns the index of its matched
188
+ * closing `}`. The scanner ignores `{`/`}`/`"` that appear inside double-quoted string literals,
189
+ * `//` line comments, and `/* *\/` block comments — a curated Gold-Standard model routinely carries
190
+ * comments, and a stray `}` inside one (or inside a quoted rule value) must NOT be mistaken for the
191
+ * structural close, which would return a too-early closeIdx and splice a new rule mid-statement.
192
+ */
193
+ export declare function matchClosingBrace(cml: string, openIdx: number): number | undefined;
194
+ /**
195
+ * Prefix every merge skip raised by {@link findUnconvertibleConditions} carries, so the commands'
196
+ * skip breakdown can bucket it the way it buckets the other reasons.
197
+ */
198
+ export declare const UNCONVERTIBLE_SKIP_PREFIX = "cannot be expressed in CML";
75
199
  /** Builds the `rule(...)` statement for a surcharge, using the same constraint generator as build mode. */
76
200
  export declare function buildSurchargeRuleStatement(declaration: string, ruleKey: string): string;
201
+ export type BuildPathedSurchargeRulesOptions = {
202
+ /**
203
+ * Surcharge id -> Surcharge.Code (from {@link fetchSurchargeCodes}). The platform derives the
204
+ * LEAF segment of ProductSurcharge.RuleKey from the parent Surcharge's Code, so this is preferred
205
+ * over the rule apiName for the key leaf. When a rule's surchargeId is missing or not present in
206
+ * this map, the leaf falls back to the apiName and {@link onSurchargeCodeFallback} fires.
207
+ */
208
+ surchargeIdToCode?: Map<string, string>;
209
+ /** Called with the rule's recordName when its Surcharge.Code could not be resolved (key leaf fell back to apiName). */
210
+ onSurchargeCodeFallback?: (recordName: string) => void;
211
+ /**
212
+ * Org-resolved attribute types (see {@link AttributeDataTypes}). Required for a numeric picklist
213
+ * to be compared as a number: without it the merged rule compares a decimal attribute — as the
214
+ * curated model already declares it — against a quoted string, and the surcharge never fires.
215
+ */
216
+ attributeDataTypes?: AttributeDataTypes;
217
+ /**
218
+ * Raw context tag -> its org-resolved binding (see {@link fetchContextTagBindings}). Absent or
219
+ * empty means no tag resolves, which leaves every Tag-condition rule to the absent-reference gate
220
+ * — the behaviour before context-tag resolution existed, and still the correct fallback.
221
+ */
222
+ contextTagBindings?: ContextTagBindings;
223
+ };
77
224
  /**
78
225
  * Prepares the pathed-rule descriptors for a set of parsed surcharge records.
79
226
  * `productIdToCode` and `productIdToType` must already cover every ProductPath segment.
227
+ * `options.surchargeIdToCode` should map every rule's parent Surcharge id to its Code so the key
228
+ * leaf matches the platform-generated RuleKey (see {@link fetchSurchargeCodes}).
80
229
  */
81
230
  export declare function buildPathedSurchargeRules(prefix: string, ruleDefs: Array<{
82
231
  record: RuleRecord;
83
232
  ruleDef: ParsedRuleDefinition;
84
- }>, productIdToCode: Map<string, string>, productIdToType: Map<string, string>): PathedSurchargeRule[];
233
+ }>, productIdToCode: Map<string, string>, productIdToType: Map<string, string>, options?: BuildPathedSurchargeRulesOptions): PathedSurchargeRule[];
234
+ /**
235
+ * Builds the `constraint <name> = (...)` statement for underwriting eligibility, using the same
236
+ * constraint generator as build mode's constraint-form branch (see `buildCmlModel`).
237
+ */
238
+ export declare function buildUnderwritingConstraintStatement(constraintName: string, declaration: string, label: string): string;
239
+ /**
240
+ * Builds the constraint-form rule descriptors for underwriting eligibility, mirroring
241
+ * {@link buildPathedSurchargeRules} but emitting a named `constraint` statement (matching the
242
+ * constraint-form branch of `buildCmlModel` in insurance-rule-generator.ts) instead of a `rule(...)`
243
+ * action statement. `productIdToCode` and `productIdToType` must already cover every ProductPath
244
+ * segment.
245
+ */
246
+ export declare function buildUnderwritingConstraintRules(keyPrefix: string, constraintLabel: string, ruleDefs: Array<{
247
+ record: RuleRecord;
248
+ ruleDef: ParsedRuleDefinition;
249
+ }>, productIdToCode: Map<string, string>, productIdToType: Map<string, string>, attributeDataTypes?: AttributeDataTypes): UnderwritingConstraintRule[];
85
250
  /**
86
251
  * Merges the pathed surcharge `rule(...)` statements into the existing CML text. If the rule key is
87
252
  * already present, the existing statement line is replaced in place (idempotent). Otherwise the
@@ -89,3 +254,31 @@ export declare function buildPathedSurchargeRules(prefix: string, ruleDefs: Arra
89
254
  * block can't be found are skipped (reported, never silently dropped).
90
255
  */
91
256
  export declare function mergeSurchargeRules(existingCml: string, rules: PathedSurchargeRule[]): MergeResult;
257
+ /**
258
+ * Merges the underwriting `constraint <name> = (...)` statements into the existing CML text.
259
+ * Mirrors {@link mergeSurchargeRules}'s insert/replace/skip shape, but for the constraint form
260
+ * underwriting eligibility uses instead of a `rule(...)` action statement:
261
+ *
262
+ * - If a constraint with the same name already exists in the rule's leaf `type` block, its full
263
+ * statement (from the `constraint` keyword through the terminating `;`) is replaced in place
264
+ * (idempotent — re-running the merge with the same input reproduces the same output).
265
+ * - Otherwise the statement is inserted just before the closing brace of the leaf `type` block.
266
+ * - Any of a rule's `referencedAttributes` not already declared anywhere in the leaf `type` block
267
+ * are reported via `attributeWarnings`; the curated model is never mutated to add them. NOTE: this
268
+ * is weaker than the surcharge merge, which WITHHOLDS such a rule outright — an unresolvable
269
+ * reference makes the solver reject the whole model at deploy, so warning here still lets a
270
+ * model-wide outage through. See findAbsentAttributes.
271
+ *
272
+ * Rules with a blank ProductPath, no resolved leaf type tag, an ambiguous/duplicate type block, or
273
+ * an intra-run duplicate (typeName, constraintName) pair are skipped (reported, never silently
274
+ * dropped) — never throws on a single rule's failure.
275
+ */
276
+ export declare function mergeUnderwritingConstraints(existingCml: string, rules: UnderwritingConstraintRule[]): UwMergeResult;
277
+ /**
278
+ * Returns a copy of `cml` with identical length where every character inside a `//` line comment or
279
+ * a `/* *\/` block comment is replaced by a space (newlines preserved). Used so the replace-anchor
280
+ * scan can ignore comment contents without losing offset alignment with the original text. String
281
+ * literals are left intact: the anchor itself requires the literal `"InsuranceSurchargeRule"` action
282
+ * token, so a same-key VALUE inside another rule's string still won't satisfy the action-scope shape.
283
+ */
284
+ export declare function blankComments(cml: string): string;