@accordproject/template-engine 3.1.0 → 4.2.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 (139) hide show
  1. package/README.md +41 -0
  2. package/lib/JavaScriptEvaluator.d.ts +71 -0
  3. package/lib/JavaScriptEvaluator.js +245 -0
  4. package/lib/JavaScriptEvaluator.js.map +1 -0
  5. package/lib/TemplateArchiveProcessor.d.ts +151 -0
  6. package/lib/TemplateArchiveProcessor.js +447 -0
  7. package/lib/TemplateArchiveProcessor.js.map +1 -0
  8. package/lib/TemplateMarkInterpreter.d.ts +34 -0
  9. package/lib/TemplateMarkInterpreter.js +689 -0
  10. package/lib/TemplateMarkInterpreter.js.map +1 -0
  11. package/lib/TemplateMarkNodes.d.ts +19 -0
  12. package/lib/TemplateMarkNodes.js +45 -0
  13. package/lib/TemplateMarkNodes.js.map +1 -0
  14. package/lib/TemplateMarkToJavaScriptCompiler.d.ts +20 -0
  15. package/lib/TemplateMarkToJavaScriptCompiler.js +99 -0
  16. package/lib/TemplateMarkToJavaScriptCompiler.js.map +1 -0
  17. package/lib/TypeScriptCompilationContext.d.ts +42 -0
  18. package/lib/TypeScriptCompilationContext.js +170 -0
  19. package/lib/TypeScriptCompilationContext.js.map +1 -0
  20. package/lib/TypeScriptRuntime.d.ts +17 -0
  21. package/lib/TypeScriptRuntime.js +84 -0
  22. package/lib/TypeScriptRuntime.js.map +1 -0
  23. package/lib/TypeScriptToJavaScriptCompiler.d.ts +11 -0
  24. package/lib/TypeScriptToJavaScriptCompiler.js +169 -0
  25. package/lib/TypeScriptToJavaScriptCompiler.js.map +1 -0
  26. package/lib/drafting/Boolean/index.d.ts +6 -0
  27. package/lib/drafting/Boolean/index.js +30 -0
  28. package/lib/drafting/Boolean/index.js.map +1 -0
  29. package/lib/drafting/DateTime/index.d.ts +8 -0
  30. package/lib/drafting/DateTime/index.js +33 -0
  31. package/lib/drafting/DateTime/index.js.map +1 -0
  32. package/lib/drafting/Double/format.d.ts +14 -0
  33. package/lib/drafting/Double/format.js +62 -0
  34. package/lib/drafting/Double/format.js.map +1 -0
  35. package/lib/drafting/Double/index.d.ts +8 -0
  36. package/lib/drafting/Double/index.js +33 -0
  37. package/lib/drafting/Double/index.js.map +1 -0
  38. package/lib/drafting/DraftFormat.d.ts +5 -0
  39. package/lib/drafting/DraftFormat.js +18 -0
  40. package/lib/drafting/DraftFormat.js.map +1 -0
  41. package/lib/drafting/Duration/index.d.ts +6 -0
  42. package/lib/drafting/Duration/index.js +39 -0
  43. package/lib/drafting/Duration/index.js.map +1 -0
  44. package/lib/drafting/Integer/format.d.ts +14 -0
  45. package/lib/drafting/Integer/format.js +52 -0
  46. package/lib/drafting/Integer/format.js.map +1 -0
  47. package/lib/drafting/Integer/index.d.ts +8 -0
  48. package/lib/drafting/Integer/index.js +33 -0
  49. package/lib/drafting/Integer/index.js.map +1 -0
  50. package/lib/drafting/Long/index.d.ts +8 -0
  51. package/lib/drafting/Long/index.js +33 -0
  52. package/lib/drafting/Long/index.js.map +1 -0
  53. package/lib/drafting/MonetaryAmount/currencycode.d.ts +35 -0
  54. package/lib/drafting/MonetaryAmount/currencycode.js +53 -0
  55. package/lib/drafting/MonetaryAmount/currencycode.js.map +1 -0
  56. package/lib/drafting/MonetaryAmount/formatTokens.d.ts +13 -0
  57. package/lib/drafting/MonetaryAmount/formatTokens.js +44 -0
  58. package/lib/drafting/MonetaryAmount/formatTokens.js.map +1 -0
  59. package/lib/drafting/MonetaryAmount/index.d.ts +13 -0
  60. package/lib/drafting/MonetaryAmount/index.js +51 -0
  61. package/lib/drafting/MonetaryAmount/index.js.map +1 -0
  62. package/lib/drafting/PreciseAmount/index.d.ts +17 -0
  63. package/lib/drafting/PreciseAmount/index.js +113 -0
  64. package/lib/drafting/PreciseAmount/index.js.map +1 -0
  65. package/lib/drafting/String/index.d.ts +6 -0
  66. package/lib/drafting/String/index.js +25 -0
  67. package/lib/drafting/String/index.js.map +1 -0
  68. package/lib/drafting/index.d.ts +2 -0
  69. package/lib/drafting/index.js +63 -0
  70. package/lib/drafting/index.js.map +1 -0
  71. package/lib/index.d.ts +7 -0
  72. package/lib/index.js +42 -0
  73. package/lib/index.js.map +1 -0
  74. package/lib/llm/LLMConfig.d.ts +121 -0
  75. package/lib/llm/LLMConfig.js +30 -0
  76. package/lib/llm/LLMConfig.js.map +1 -0
  77. package/lib/llm/LLMExecutor.d.ts +77 -0
  78. package/lib/llm/LLMExecutor.js +603 -0
  79. package/lib/llm/LLMExecutor.js.map +1 -0
  80. package/lib/llm/ModelManagerSchema.d.ts +14 -0
  81. package/lib/llm/ModelManagerSchema.js +67 -0
  82. package/lib/llm/ModelManagerSchema.js.map +1 -0
  83. package/lib/llm/Reasoners.d.ts +190 -0
  84. package/lib/llm/Reasoners.js +643 -0
  85. package/lib/llm/Reasoners.js.map +1 -0
  86. package/lib/model-gen/concerto.d.ts +13 -0
  87. package/lib/model-gen/concerto.js +4 -0
  88. package/lib/model-gen/concerto.js.map +1 -0
  89. package/lib/model-gen/concerto.metamodel@1.0.0.d.ts +196 -0
  90. package/lib/model-gen/concerto.metamodel@1.0.0.js +4 -0
  91. package/lib/model-gen/concerto.metamodel@1.0.0.js.map +1 -0
  92. package/lib/model-gen/concerto@1.0.0.d.ts +19 -0
  93. package/lib/model-gen/concerto@1.0.0.js +4 -0
  94. package/lib/model-gen/concerto@1.0.0.js.map +1 -0
  95. package/lib/model-gen/org.accordproject.ciceromark@0.6.0.d.ts +49 -0
  96. package/lib/model-gen/org.accordproject.ciceromark@0.6.0.js +4 -0
  97. package/lib/model-gen/org.accordproject.ciceromark@0.6.0.js.map +1 -0
  98. package/lib/model-gen/org.accordproject.commonmark@0.5.0.d.ts +89 -0
  99. package/lib/model-gen/org.accordproject.commonmark@0.5.0.js +4 -0
  100. package/lib/model-gen/org.accordproject.commonmark@0.5.0.js.map +1 -0
  101. package/lib/model-gen/org.accordproject.templatemark@0.5.0.d.ts +76 -0
  102. package/lib/model-gen/org.accordproject.templatemark@0.5.0.js +11 -0
  103. package/lib/model-gen/org.accordproject.templatemark@0.5.0.js.map +1 -0
  104. package/lib/runtime/declarations.d.ts +2 -0
  105. package/lib/runtime/declarations.js +21 -0
  106. package/lib/runtime/declarations.js.map +1 -0
  107. package/lib/slc/model-gen/concerto.d.ts +13 -0
  108. package/lib/slc/model-gen/concerto.decorator@1.0.0.d.ts +6 -0
  109. package/lib/slc/model-gen/concerto.decorator@1.0.0.js +5 -0
  110. package/lib/slc/model-gen/concerto.decorator@1.0.0.js.map +1 -0
  111. package/lib/slc/model-gen/concerto.js +5 -0
  112. package/lib/slc/model-gen/concerto.js.map +1 -0
  113. package/lib/slc/model-gen/concerto@1.0.0.d.ts +24 -0
  114. package/lib/slc/model-gen/concerto@1.0.0.js +6 -0
  115. package/lib/slc/model-gen/concerto@1.0.0.js.map +1 -0
  116. package/lib/slc/model-gen/org.accordproject.contract@0.2.0.d.ts +7 -0
  117. package/lib/slc/model-gen/org.accordproject.contract@0.2.0.js +5 -0
  118. package/lib/slc/model-gen/org.accordproject.contract@0.2.0.js.map +1 -0
  119. package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.d.ts +15 -0
  120. package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.js +4 -0
  121. package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.js.map +1 -0
  122. package/lib/slc/model-gen/org.accordproject.time@0.3.0.d.ts +46 -0
  123. package/lib/slc/model-gen/org.accordproject.time@0.3.0.js +48 -0
  124. package/lib/slc/model-gen/org.accordproject.time@0.3.0.js.map +1 -0
  125. package/lib/utils.d.ts +35 -0
  126. package/lib/utils.js +122 -0
  127. package/lib/utils.js.map +1 -0
  128. package/lib/worker.d.ts +1 -0
  129. package/{dist → lib}/worker.js +12 -10
  130. package/lib/worker.js.map +1 -0
  131. package/package.json +46 -25
  132. package/umd/template-engine.js +13 -0
  133. package/umd/template-engine.js.LICENSE.txt +21 -0
  134. package/dist/index.d.ts +0 -186
  135. package/dist/index.js +0 -1275
  136. package/dist/index.js.map +0 -1
  137. package/dist/index.mjs +0 -1248
  138. package/dist/index.mjs.map +0 -1
  139. package/dist/worker.js.map +0 -1
@@ -0,0 +1,35 @@
1
+ export declare enum CurrencyCode {
2
+ 'USD' = "$",
3
+ 'EUR' = "\u20AC",
4
+ 'JPY' = "\u00A5",
5
+ 'GBP' = "\u00A3",
6
+ 'AUD' = "A$",
7
+ 'CAD' = "C$",
8
+ 'CHF' = "CHF",
9
+ 'CNY' = "\u5143",
10
+ 'HKD' = "HK$",
11
+ 'NZD' = "NZ$",
12
+ 'KRW' = "\u20A9",
13
+ 'SGD' = "S$",
14
+ 'MXN' = "MEX$",
15
+ 'INR' = "\u20B9",
16
+ 'RUB' = "\u20BD",
17
+ 'ZAR' = "R",
18
+ 'TRY' = "\u20BA",
19
+ 'BRL' = "R$",
20
+ 'TWD' = "NT$",
21
+ 'PLN' = "z\u0142",
22
+ 'THB' = "\u0E3F",
23
+ 'IDR' = "Rp",
24
+ 'HUF' = "Ft",
25
+ 'CZK' = "K\u010D",
26
+ 'ILS' = "\u20AA",
27
+ 'CLP' = "CLP$",
28
+ 'PHP' = "\u20B1",
29
+ 'AED' = "\u062F.\u0625",
30
+ 'COP' = "COL$",
31
+ 'SAR' = "\uFDFC",
32
+ 'MYR' = "RM",
33
+ 'RON' = "L",
34
+ 'BGN' = "\u043B\u0432."
35
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.CurrencyCode = void 0;
17
+ var CurrencyCode;
18
+ (function (CurrencyCode) {
19
+ CurrencyCode["USD"] = "$";
20
+ CurrencyCode["EUR"] = "\u20AC";
21
+ CurrencyCode["JPY"] = "\u00A5";
22
+ CurrencyCode["GBP"] = "\u00A3";
23
+ CurrencyCode["AUD"] = "A$";
24
+ CurrencyCode["CAD"] = "C$";
25
+ CurrencyCode["CHF"] = "CHF";
26
+ CurrencyCode["CNY"] = "\u5143";
27
+ CurrencyCode["HKD"] = "HK$";
28
+ CurrencyCode["NZD"] = "NZ$";
29
+ CurrencyCode["KRW"] = "\u20A9";
30
+ CurrencyCode["SGD"] = "S$";
31
+ CurrencyCode["MXN"] = "MEX$";
32
+ CurrencyCode["INR"] = "\u20B9";
33
+ CurrencyCode["RUB"] = "\u20BD";
34
+ CurrencyCode["ZAR"] = "R";
35
+ CurrencyCode["TRY"] = "\u20BA";
36
+ CurrencyCode["BRL"] = "R$";
37
+ CurrencyCode["TWD"] = "NT$";
38
+ CurrencyCode["PLN"] = "z\u0142";
39
+ CurrencyCode["THB"] = "\u0E3F";
40
+ CurrencyCode["IDR"] = "Rp";
41
+ CurrencyCode["HUF"] = "Ft";
42
+ CurrencyCode["CZK"] = "K\u010D";
43
+ CurrencyCode["ILS"] = "\u20AA";
44
+ CurrencyCode["CLP"] = "CLP$";
45
+ CurrencyCode["PHP"] = "\u20B1";
46
+ CurrencyCode["AED"] = "\u062F.\u0625";
47
+ CurrencyCode["COP"] = "COL$";
48
+ CurrencyCode["SAR"] = "\uFDFC";
49
+ CurrencyCode["MYR"] = "RM";
50
+ CurrencyCode["RON"] = "L";
51
+ CurrencyCode["BGN"] = "\u043B\u0432.";
52
+ })(CurrencyCode || (exports.CurrencyCode = CurrencyCode = {}));
53
+ //# sourceMappingURL=currencycode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currencycode.js","sourceRoot":"","sources":["../../../src/drafting/MonetaryAmount/currencycode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,IAAY,YAkCX;AAlCD,WAAY,YAAY;IACpB,yBAAW,CAAA;IACX,8BAAU,CAAA;IACV,8BAAU,CAAA;IACV,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,0BAAW,CAAA;IACX,2BAAY,CAAA;IACZ,8BAAU,CAAA;IACV,2BAAY,CAAA;IACZ,2BAAY,CAAA;IACZ,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,4BAAa,CAAA;IACb,8BAAU,CAAA;IACV,8BAAU,CAAA;IACV,yBAAU,CAAA;IACV,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,2BAAY,CAAA;IACZ,+BAAW,CAAA;IACX,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,0BAAW,CAAA;IACX,+BAAW,CAAA;IACX,8BAAU,CAAA;IACV,4BAAa,CAAA;IACb,8BAAU,CAAA;IACV,qCAAY,CAAA;IACZ,4BAAa,CAAA;IACb,8BAAU,CAAA;IACV,0BAAW,CAAA;IACX,yBAAU,CAAA;IACV,qCAAY,CAAA;AAChB,CAAC,EAlCW,YAAY,4BAAZ,YAAY,QAkCvB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Symbol from a currency code
3
+ * @param {string} c - the currency code
4
+ * @returns {string} the symbol
5
+ */
6
+ export declare function codeSymbol(c: string): string;
7
+ /**
8
+ * Replaces currency tokens (K for symbol, CCC for code) in a format string
9
+ * @param {string} format - the format string
10
+ * @param {string} code - the currency code
11
+ * @returns {string} the format string with tokens replaced
12
+ */
13
+ export declare function replaceCurrencyTokens(format: string, code: string): string;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.codeSymbol = codeSymbol;
17
+ exports.replaceCurrencyTokens = replaceCurrencyTokens;
18
+ const currencycode_1 = require("./currencycode");
19
+ /**
20
+ * Symbol from a currency code
21
+ * @param {string} c - the currency code
22
+ * @returns {string} the symbol
23
+ */
24
+ function codeSymbol(c) {
25
+ const index = Object.keys(currencycode_1.CurrencyCode).indexOf(c);
26
+ if (index >= 0) {
27
+ return Object.values(currencycode_1.CurrencyCode)[index];
28
+ }
29
+ else {
30
+ return c;
31
+ }
32
+ }
33
+ /**
34
+ * Replaces currency tokens (K for symbol, CCC for code) in a format string
35
+ * @param {string} format - the format string
36
+ * @param {string} code - the currency code
37
+ * @returns {string} the format string with tokens replaced
38
+ */
39
+ function replaceCurrencyTokens(format, code) {
40
+ return format
41
+ .replace(/K/gi, codeSymbol(code))
42
+ .replace(/CCC/gi, code);
43
+ }
44
+ //# sourceMappingURL=formatTokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatTokens.js","sourceRoot":"","sources":["../../../src/drafting/MonetaryAmount/formatTokens.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AASH,gCAQC;AAQD,sDAIC;AA3BD,iDAA8C;AAE9C;;;;GAIG;AACH,SAAgB,UAAU,CAAC,CAAQ;IAC/B,MAAM,KAAK,GAAW,MAAM,CAAC,IAAI,CAAC,2BAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAG,KAAK,IAAG,CAAC,EAAE,CAAC;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAY,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;SACI,CAAC;QACF,OAAO,CAAC,CAAC;IACb,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,MAAc,EAAE,IAAY;IAC9D,OAAO,MAAM;SACR,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;SAChC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { MonetaryAmountFormat } from '../DraftFormat';
2
+ type MonetaryAmount = {
3
+ doubleValue: number;
4
+ currencyCode: string;
5
+ };
6
+ /**
7
+ * Creates a drafter for a monetary amount
8
+ * @param {object} value the monetary amount
9
+ * @param {string} format the format
10
+ * @returns {string} the text
11
+ */
12
+ export default function monetaryAmountDrafter(value: MonetaryAmount, format?: MonetaryAmountFormat): string;
13
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.default = monetaryAmountDrafter;
17
+ const format_1 = require("../Double/format");
18
+ const format_2 = require("../Double/format");
19
+ const formatTokens_1 = require("./formatTokens");
20
+ /**
21
+ * Creates a drafter for monetary amount with no format
22
+ * @param {object} value the monetary amount
23
+ * @returns {string} the text
24
+ */
25
+ function monetaryAmountDefaultDrafter(value) {
26
+ return '' + (0, format_1.draftDoubleIEEE)(value.doubleValue) + ' ' + value.currencyCode;
27
+ }
28
+ /**
29
+ * Creates a drafter for monetary amount with a given format
30
+ * @param {object} value the monetary amount
31
+ * @param {string} format the format
32
+ * @returns {string} the text
33
+ */
34
+ function monetaryAmountFormatDrafter(value, format) {
35
+ return (0, format_2.draftDoubleFormat)(value.doubleValue, (0, formatTokens_1.replaceCurrencyTokens)(format, value.currencyCode));
36
+ }
37
+ /**
38
+ * Creates a drafter for a monetary amount
39
+ * @param {object} value the monetary amount
40
+ * @param {string} format the format
41
+ * @returns {string} the text
42
+ */
43
+ function monetaryAmountDrafter(value, format) {
44
+ if (format) {
45
+ return monetaryAmountFormatDrafter(value, format);
46
+ }
47
+ else {
48
+ return monetaryAmountDefaultDrafter(value);
49
+ }
50
+ }
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/MonetaryAmount/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAsCH,wCAMC;AA1CD,6CAAmD;AACnD,6CAAqD;AAErD,iDAAuD;AAOvD;;;;GAIG;AACH,SAAS,4BAA4B,CAAC,KAAoB;IACtD,OAAO,EAAE,GAAG,IAAA,wBAAe,EAAC,KAAK,CAAC,WAAW,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC;AAC9E,CAAC;AAGD;;;;;GAKG;AACH,SAAS,2BAA2B,CAAC,KAAoB,EAAC,MAA2B;IACjF,OAAO,IAAA,0BAAiB,EAAC,KAAK,CAAC,WAAW,EAAE,IAAA,oCAAqB,EAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;AACnG,CAAC;AAED;;;;;GAKG;AACH,SAAwB,qBAAqB,CAAC,KAAoB,EAAC,MAA4B;IAC3F,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,2BAA2B,CAAC,KAAK,EAAC,MAAM,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACJ,OAAO,4BAA4B,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { MonetaryAmountFormat } from '../DraftFormat';
2
+ export type PreciseAmount = {
3
+ unscaledValue: string;
4
+ unit: {
5
+ code: string;
6
+ scheme?: string;
7
+ identifier?: string;
8
+ scale: number;
9
+ };
10
+ };
11
+ /**
12
+ * Creates a drafter for a precise amount
13
+ * @param {object} value the precise amount
14
+ * @param {string} format the format
15
+ * @returns {string} the text
16
+ */
17
+ export default function preciseAmountDrafter(value: PreciseAmount, format?: MonetaryAmountFormat): string;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.default = preciseAmountDrafter;
17
+ const formatTokens_1 = require("../MonetaryAmount/formatTokens");
18
+ /**
19
+ * Helper to reconstruct the decimal string representation of a PreciseAmount
20
+ * without losing precision via JavaScript floats.
21
+ */
22
+ function reconstructDecimalString(value, scale) {
23
+ if (scale === 0)
24
+ return value;
25
+ let isNegative = false;
26
+ let absValue = value;
27
+ if (absValue.startsWith('-')) {
28
+ isNegative = true;
29
+ absValue = absValue.substring(1);
30
+ }
31
+ if (absValue.length <= scale) {
32
+ absValue = absValue.padStart(scale + 1, '0');
33
+ }
34
+ const insertPos = absValue.length - scale;
35
+ const integerPart = absValue.substring(0, insertPos);
36
+ const decimalPart = absValue.substring(insertPos);
37
+ let result = `${integerPart}.${decimalPart}`;
38
+ if (isNegative) {
39
+ result = '-' + result;
40
+ }
41
+ return result;
42
+ }
43
+ /**
44
+ * Creates a drafter for precise amount with no format
45
+ * @param {object} value the precise amount
46
+ * @returns {string} the text
47
+ */
48
+ function preciseAmountDefaultDrafter(value) {
49
+ return reconstructDecimalString(value.unscaledValue, value.unit.scale) + ' ' + value.unit.code;
50
+ }
51
+ /**
52
+ * Creates a drafter for precise amount with a given format
53
+ * @param {object} value the precise amount
54
+ * @param {string} format the format
55
+ * @returns {string} the text
56
+ */
57
+ function preciseAmountFormatDrafter(value, format) {
58
+ const strValue = reconstructDecimalString(value.unscaledValue, value.unit.scale);
59
+ const formatWithTokens = (0, formatTokens_1.replaceCurrencyTokens)(format, value.unit.code);
60
+ return formatWithTokens.replace(/0(.)0((.)(0+))?/gi, function (_a, sep1, _b, sep2, digits) {
61
+ const len = digits ? digits.length : 0;
62
+ const parts = strValue.split('.');
63
+ let integerPart = parts[0];
64
+ let decimalPart = parts.length > 1 ? parts[1] : '';
65
+ // Adjust decimal part to 'len' digits
66
+ if (len === 0) {
67
+ decimalPart = '';
68
+ }
69
+ else {
70
+ if (decimalPart.length > len) {
71
+ // Truncate without rounding (to preserve strict string handling without complex BigInt math)
72
+ decimalPart = decimalPart.substring(0, len);
73
+ }
74
+ else {
75
+ decimalPart = decimalPart.padEnd(len, '0');
76
+ }
77
+ }
78
+ let res = '';
79
+ if (sep2 && len > 0) {
80
+ res += sep2 + decimalPart;
81
+ }
82
+ let isNegative = false;
83
+ if (integerPart.startsWith('-')) {
84
+ isNegative = true;
85
+ integerPart = integerPart.substring(1);
86
+ }
87
+ // Apply grouping (sep1)
88
+ while (integerPart.length > 3) {
89
+ res = sep1 + integerPart.substring(integerPart.length - 3) + res;
90
+ integerPart = integerPart.substring(0, integerPart.length - 3);
91
+ }
92
+ res = integerPart + res;
93
+ if (isNegative) {
94
+ res = '-' + res;
95
+ }
96
+ return res;
97
+ });
98
+ }
99
+ /**
100
+ * Creates a drafter for a precise amount
101
+ * @param {object} value the precise amount
102
+ * @param {string} format the format
103
+ * @returns {string} the text
104
+ */
105
+ function preciseAmountDrafter(value, format) {
106
+ if (format) {
107
+ return preciseAmountFormatDrafter(value, format);
108
+ }
109
+ else {
110
+ return preciseAmountDefaultDrafter(value);
111
+ }
112
+ }
113
+ //# sourceMappingURL=index.js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AAI,IAAI,GAAG,WAAW,CAAC;QAC9B,CAAC;QAED,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,UAAU,GAAG,IAAI,CAAC;YAClB,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;QAED,wBAAwB;QACxB,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,GAAG,GAAG,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;YACjE,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,GAAG,GAAG,WAAW,GAAG,GAAG,CAAC;QAExB,IAAI,UAAU,EAAE,CAAC;YACb,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;QACpB,CAAC;QAED,OAAO,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;GAKG;AACH,SAAwB,oBAAoB,CAAC,KAAmB,EAAC,MAA4B;IACzF,IAAI,MAAM,EAAE,CAAC;QACT,OAAO,0BAA0B,CAAC,KAAK,EAAC,MAAM,CAAC,CAAC;IACpD,CAAC;SAAM,CAAC;QACJ,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Creates a drafter for String
3
+ * @param {object} value the String
4
+ * @returns {string} the text
5
+ */
6
+ export default function stringDrafter(value: string): string;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.default = stringDrafter;
17
+ /**
18
+ * Creates a drafter for String
19
+ * @param {object} value the String
20
+ * @returns {string} the text
21
+ */
22
+ function stringDrafter(value) {
23
+ return value;
24
+ }
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drafting/String/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAOH,gCAEC;AAPD;;;;GAIG;AACH,SAAwB,aAAa,CAAC,KAAY;IAC9C,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { DraftFormat } from './DraftFormat';
2
+ export declare function getDrafter(typeName: string): ((value: any, format?: DraftFormat) => string) | null;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.getDrafter = getDrafter;
20
+ /* eslint-disable @typescript-eslint/no-explicit-any */
21
+ const Boolean_1 = __importDefault(require("./Boolean"));
22
+ const DateTime_1 = __importDefault(require("./DateTime"));
23
+ const Double_1 = __importDefault(require("./Double"));
24
+ const Integer_1 = __importDefault(require("./Integer"));
25
+ const Duration_1 = __importDefault(require("./Duration"));
26
+ const Long_1 = __importDefault(require("./Long"));
27
+ const MonetaryAmount_1 = __importDefault(require("./MonetaryAmount"));
28
+ const PreciseAmount_1 = __importDefault(require("./PreciseAmount"));
29
+ const String_1 = __importDefault(require("./String"));
30
+ const concerto_core_1 = require("@accordproject/concerto-core");
31
+ function drafterKey(fqn) {
32
+ if (concerto_core_1.ModelUtil.isPrimitiveType(fqn)) {
33
+ return fqn; // Boolean, String, Integer, ...
34
+ }
35
+ try {
36
+ const ns = concerto_core_1.ModelUtil.getNamespace(fqn);
37
+ const name = concerto_core_1.ModelUtil.getShortName(fqn);
38
+ const { name: nsName, version } = concerto_core_1.ModelUtil.parseNamespace(ns);
39
+ const major = version ? version.split('.')[0] : '';
40
+ return `${nsName}@${major}.${name}`;
41
+ }
42
+ catch {
43
+ // Not a versioned namespace type (e.g. user-defined concept without a version).
44
+ // Return as-is so it hits the default: null branch in getDrafter.
45
+ return fqn;
46
+ }
47
+ }
48
+ function getDrafter(typeName) {
49
+ switch (drafterKey(typeName)) {
50
+ case 'Boolean': return Boolean_1.default;
51
+ case 'DateTime': return DateTime_1.default;
52
+ case 'Double': return Double_1.default;
53
+ case 'Integer': return Integer_1.default;
54
+ case 'Long': return Long_1.default;
55
+ case 'org.accordproject.money@0.MonetaryAmount': return MonetaryAmount_1.default;
56
+ case 'org.accordproject.money@1.PreciseAmount': return PreciseAmount_1.default;
57
+ case 'org.accordproject.time@0.Duration': return Duration_1.default;
58
+ case 'org.accordproject.time@0.Period': return Duration_1.default;
59
+ case 'String': return String_1.default;
60
+ default: return null;
61
+ }
62
+ }
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/drafting/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;AAiCH,gCAcC;AA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AAC;QAC9E,KAAK,yCAAyC,CAAC,CAAC,OAAO,uBAAoB,CAAC;QAC5E,KAAK,mCAAmC,CAAC,CAAC,OAAO,kBAAe,CAAC;QACjE,KAAK,iCAAiC,CAAC,CAAC,OAAO,kBAAe,CAAC;QAC/D,KAAK,QAAQ,CAAC,CAAC,OAAO,gBAAa,CAAC;QACpC,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC;IACrB,CAAC;AACL,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { TemplateLogic } from './slc/SmartLegalContract.d.ts';
2
+ export { TemplateMarkInterpreter } from './TemplateMarkInterpreter';
3
+ export { TemplateArchiveProcessor } from './TemplateArchiveProcessor';
4
+ export { TemplateLogic };
5
+ export * from './utils';
6
+ export { ModelManager } from '@accordproject/concerto-core';
7
+ export { TemplateMarkTransformer } from '@accordproject/markdown-template';
package/lib/index.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.TemplateMarkTransformer = exports.ModelManager = exports.TemplateArchiveProcessor = exports.TemplateMarkInterpreter = void 0;
31
+ var TemplateMarkInterpreter_1 = require("./TemplateMarkInterpreter");
32
+ Object.defineProperty(exports, "TemplateMarkInterpreter", { enumerable: true, get: function () { return TemplateMarkInterpreter_1.TemplateMarkInterpreter; } });
33
+ var TemplateArchiveProcessor_1 = require("./TemplateArchiveProcessor");
34
+ Object.defineProperty(exports, "TemplateArchiveProcessor", { enumerable: true, get: function () { return TemplateArchiveProcessor_1.TemplateArchiveProcessor; } });
35
+ __exportStar(require("./utils"), exports);
36
+ // Re-exported for convenience so a single browser bundle can run the full
37
+ // model -> template -> agreement flow (and so consumers share one concerto instance).
38
+ var concerto_core_1 = require("@accordproject/concerto-core");
39
+ Object.defineProperty(exports, "ModelManager", { enumerable: true, get: function () { return concerto_core_1.ModelManager; } });
40
+ var markdown_template_1 = require("@accordproject/markdown-template");
41
+ Object.defineProperty(exports, "TemplateMarkTransformer", { enumerable: true, get: function () { return markdown_template_1.TemplateMarkTransformer; } });
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;AAIH,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AAEjC,0CAAwB;AAExB,0EAA0E;AAC1E,sFAAsF;AACtF,8DAA4D;AAAnD,6GAAA,YAAY,OAAA;AACrB,sEAA2E;AAAlE,4HAAA,uBAAuB,OAAA"}
@@ -0,0 +1,121 @@
1
+ export type LLMMode = 'disabled' | 'fallback' | 'force';
2
+ /** Effort levels the Groq API accepts. */
3
+ export declare const GROQ_EFFORT_LEVELS: readonly ["none", "low", "medium", "high"];
4
+ export type GroqEffort = (typeof GROQ_EFFORT_LEVELS)[number];
5
+ /**
6
+ * Effort levels the OpenAI Chat Completions API accepts. Only reasoning models
7
+ * take the parameter at all — a non-reasoning model (e.g. `gpt-4o`) rejects it.
8
+ */
9
+ export declare const OPENAI_EFFORT_LEVELS: readonly ["minimal", "low", "medium", "high"];
10
+ export type OpenAIEffort = (typeof OPENAI_EFFORT_LEVELS)[number];
11
+ /**
12
+ * Effort levels the Anthropic Messages API accepts (GA, no beta header).
13
+ * Supported on Opus 4.5+ and Sonnet 5; `xhigh` arrived with Opus 4.7, and
14
+ * Sonnet 4.5 / Haiku 4.5 reject the parameter entirely.
15
+ */
16
+ export declare const ANTHROPIC_EFFORT_LEVELS: readonly ["low", "medium", "high", "xhigh", "max"];
17
+ export type AnthropicEffort = (typeof ANTHROPIC_EFFORT_LEVELS)[number];
18
+ /** Union of every effort level any supported provider accepts. */
19
+ export type ReasoningEffort = GroqEffort | OpenAIEffort | AnthropicEffort;
20
+ /**
21
+ * Shared provider settings.
22
+ */
23
+ export interface BaseProviderConfig {
24
+ apiKey?: string;
25
+ model: string;
26
+ /**
27
+ * Whether the provider supports native structured output.
28
+ */
29
+ isStructuredOutputSupported?: boolean;
30
+ /**
31
+ * Sampling temperature. Only honoured by the `groq` provider — reasoning
32
+ * models reject sampling parameters, so use `effort` instead where available.
33
+ */
34
+ temperature?: number;
35
+ maxTokens?: number;
36
+ topP?: number;
37
+ retries?: number;
38
+ timeoutMs?: number;
39
+ }
40
+ /**
41
+ * Configuration for Groq models.
42
+ */
43
+ export interface GroqProviderConfig extends BaseProviderConfig {
44
+ provider: 'groq';
45
+ /** @default 'https://api.groq.com/openai/v1' */
46
+ baseUrl?: string;
47
+ /** How much reasoning the model should spend on a request. */
48
+ effort?: GroqEffort;
49
+ }
50
+ /**
51
+ * Configuration for OpenAI models.
52
+ */
53
+ export interface OpenAIProviderConfig extends BaseProviderConfig {
54
+ provider: 'openai';
55
+ /**
56
+ * How much reasoning the model should spend on a request. Reasoning models
57
+ * only — a non-reasoning model such as `gpt-4o` rejects the parameter.
58
+ */
59
+ effort?: OpenAIEffort;
60
+ }
61
+ /**
62
+ * Configuration for Anthropic models.
63
+ */
64
+ export interface AnthropicProviderConfig extends BaseProviderConfig {
65
+ provider: 'anthropic';
66
+ /**
67
+ * How much reasoning the model should spend on a request. Only has an effect
68
+ * when {@link AnthropicProviderConfig.thinking} is left on.
69
+ */
70
+ effort?: AnthropicEffort;
71
+ /**
72
+ * Whether to run with adaptive extended thinking, which improves accuracy on
73
+ * the arithmetic these templates do. Defaults to `true`. Opus 4.6+ /
74
+ * Sonnet 4.6+ only; older models reject it with an HTTP 400. Thinking tokens
75
+ * count against {@link BaseProviderConfig.maxTokens}, so keep that generous.
76
+ */
77
+ thinking?: boolean;
78
+ }
79
+ /**
80
+ * Configuration for Google models.
81
+ */
82
+ export interface GoogleProviderConfig extends BaseProviderConfig {
83
+ provider: 'google';
84
+ }
85
+ /**
86
+ * Configuration for Mistral models.
87
+ */
88
+ export interface MistralProviderConfig extends BaseProviderConfig {
89
+ provider: 'mistral';
90
+ }
91
+ /**
92
+ * Configuration for OpenRouter models.
93
+ */
94
+ export interface OpenRouterProviderConfig extends BaseProviderConfig {
95
+ provider: 'openrouter';
96
+ }
97
+ /**
98
+ * Configuration for Ollama models.
99
+ */
100
+ export interface OllamaProviderConfig extends BaseProviderConfig {
101
+ provider: 'ollama';
102
+ /** @default 'http://localhost:11434/v1' */
103
+ baseUrl?: string;
104
+ }
105
+ /**
106
+ * Configuration for OpenAI-compatible providers.
107
+ */
108
+ export interface OpenAICompatibleProviderConfig extends BaseProviderConfig {
109
+ provider: 'openai-compatible';
110
+ /** Base URL of the OpenAI-compatible API. */
111
+ customEndpoint: string;
112
+ }
113
+ export type LLMProviderConfig = GroqProviderConfig | OpenAIProviderConfig | AnthropicProviderConfig | GoogleProviderConfig | MistralProviderConfig | OpenRouterProviderConfig | OllamaProviderConfig | OpenAICompatibleProviderConfig;
114
+ /**
115
+ * Runtime configuration for the LLM executor.
116
+ */
117
+ export interface LLMExecutorConfig {
118
+ mode: LLMMode;
119
+ provider: LLMProviderConfig;
120
+ verbose?: boolean;
121
+ }