@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,21 @@
1
+ /*!
2
+ * Accord Project Template Engine v4.2.1 — browser build
3
+ * Licensed under the Apache License, Version 2.0
4
+ */
5
+
6
+ /*!
7
+ * The buffer module from node.js, for the browser.
8
+ *
9
+ * @author Feross Aboukhadijeh <https://feross.org>
10
+ * @license MIT
11
+ */
12
+
13
+ /*! For license information please see concerto-codegen.js.LICENSE.txt */
14
+
15
+ /*! For license information please see markdown-template.js.LICENSE.txt */
16
+
17
+ /*! For license information please see markdown-transform.js.LICENSE.txt */
18
+
19
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
20
+
21
+ /*! jsonpath 1.3.0 */
package/dist/index.d.ts DELETED
@@ -1,186 +0,0 @@
1
- import { ModelManager, ClassDeclaration } from '@accordproject/concerto-core';
2
- import { Template } from '@accordproject/cicero-core';
3
- import { TwoSlashReturn } from '@typescript/twoslash';
4
-
5
- /*
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- /* eslint-disable @typescript-eslint/no-empty-object-type */
20
-
21
- // we duplicate these interfaces here to avoid imports into the runtime
22
- interface IConcept {
23
- $class: string;
24
- }
25
-
26
- interface ITransaction extends IConcept {
27
- $timestamp: Date;
28
- }
29
-
30
- interface IEvent extends IConcept {
31
- $timestamp: Date;
32
- }
33
-
34
- interface IState {
35
- $identifier: string;
36
- }
37
-
38
- interface EngineResponse<S extends IState> {
39
- state?: S;
40
- events?: Array<IEvent>
41
- }
42
-
43
- interface IRequest extends ITransaction {
44
- }
45
-
46
- interface IResponse extends ITransaction {
47
- }
48
-
49
- interface IAsset extends IConcept {
50
- $identifier: string;
51
- }
52
-
53
- interface IContract extends IAsset {
54
- contractId: string;
55
- }
56
-
57
- interface IClause extends IAsset {
58
- clauseId: string;
59
- }
60
-
61
- interface TriggerResponse$1<S extends IState = IState> extends EngineResponse<S> {
62
- result: IResponse;
63
- }
64
-
65
- interface InitResponse$1<S extends IState> extends EngineResponse<S> {}
66
-
67
- type TemplateData$1 = IContract|IClause;
68
-
69
- declare abstract class TemplateLogic<T extends TemplateData$1, S extends IState = IState> {
70
- abstract trigger(data: T, request: IRequest, state:S) : Promise<TriggerResponse$1<S>>;
71
- init(data: T) : Promise<InitResponse$1<S>|undefined>;
72
- }
73
-
74
- type TemplateData = Record<string, unknown>;
75
-
76
- /**
77
- * BEWARE - this type is duplicated in TypeScriptCompilationContext
78
- * for use by code generation
79
- */
80
- type GenerationOptions = {
81
- now?: string;
82
- locale?: string;
83
- disableJavaScriptEvaluation?: boolean;
84
- childProcessJavaScriptEvaluation?: boolean;
85
- timeout?: number;
86
- };
87
-
88
- /**
89
- * A template engine: merges the markup and logic of a template with
90
- * JSON data to produce JSON data.
91
- */
92
- declare class TemplateMarkInterpreter {
93
- modelManager: ModelManager;
94
- templateClass: ClassDeclaration;
95
- clauseLibrary: object;
96
- constructor(modelManager: ModelManager, clauseLibrary: object, templateConceptFqn?: string);
97
- /**
98
- * Checks that a TemplateMark JSON document is valid with respect to the
99
- * TemplateMark model, as well as the template model.
100
- *
101
- * Checks:
102
- * 1. Variable names are valid properties in the template model
103
- * 2. Optional properties have guards
104
- * @param {*} templateMark the TemplateMark JSON object
105
- * @returns {*} TemplateMark JSON that has been typed checked and has type metadata added
106
- * @throws {Error} if the templateMark document is invalid
107
- */
108
- checkTypes(templateMark: object): object;
109
- /**
110
- * Compiles the code nodes containing TS to code nodes containing JS.
111
- * @param {*} templateMark the TemplateMark JSON object
112
- * @returns {*} TemplateMark JSON with JS nodes
113
- * @throws {Error} if the templateMark document is invalid
114
- */
115
- compileTypeScriptToJavaScript(templateMark: object): Promise<object>;
116
- validateCiceroMark(ciceroMark: object): object;
117
- generate(templateMark: object, data: TemplateData, options?: GenerationOptions): Promise<any>;
118
- }
119
-
120
- type State = object;
121
- type Response = object;
122
- type Event = object;
123
- type TriggerResponse = {
124
- result: Response;
125
- state: State;
126
- events: Event[];
127
- };
128
- type InitResponse = {
129
- state: State;
130
- };
131
- /**
132
- * A template archive processor: can draft content using the
133
- * templatemark for the archive and trigger the logic of the archive
134
- */
135
- declare class TemplateArchiveProcessor {
136
- template: Template;
137
- private compiledLogicCache?;
138
- /**
139
- * Creates a template archive processor
140
- * @param {Template} template - the template to be used by the processor
141
- */
142
- constructor(template: Template);
143
- /**
144
- * Drafts a template by merging it with data
145
- * @param {any} data the data to merge with the template
146
- * @param {string} format the output format
147
- * @param {any} options merge options
148
- * @param {[string]} currentTime the current value for 'now'
149
- * @returns {Promise} the drafted content
150
- */
151
- draft(data: any, format: string, options: any, currentTime?: string): Promise<any>;
152
- /**
153
- * Compile the logic of a template
154
- * @param {boolean} [enableCompiledLogicCache] - whether to cache the compiled logic for future use
155
- * @returns {Promise<Record<string, TwoSlashReturn>>} the compiled code for each typescript file
156
- */
157
- compileLogic(enableCompiledLogicCache?: boolean): Promise<Record<string, TwoSlashReturn>>;
158
- /**
159
- * Trigger the logic of a template.
160
- * @param {object} data - the data for the template
161
- * @param {object} request - the request to send to the template logic
162
- * @param {object} state - the current state of the template
163
- * @param {[string]} currentTime - the current time, defaults to now
164
- * @param {[number]} utcOffset - the UTC offset, defaults to zero
165
- * @param {boolean} [enableCompiledLogicCache] - whether to use the compiled logic cache
166
- * @returns {Promise<TriggerResponse>} the response and any events
167
- */
168
- trigger(data: any, request: any, state?: any, currentTime?: string, utcOffset?: number, enableCompiledLogicCache?: boolean): Promise<TriggerResponse>;
169
- /**
170
- * Init the logic of a template.
171
- * @param {object} data - the data for the template
172
- * @param {[string]} currentTime - the current time, defaults to now
173
- * @param {[number]} utcOffset - the UTC offset, defaults to zero
174
- * @param {boolean} [enableCompiledLogicCache] - whether to use the compiled logic cache
175
- * @returns {Promise<InitResponse>} the new state
176
- */
177
- init(data: any, currentTime?: string, utcOffset?: number, enableCompiledLogicCache?: boolean): Promise<InitResponse>;
178
- }
179
-
180
- declare function ensureDirSync(path: string): void;
181
- declare function removeSync(path: string): void;
182
- declare function writeFunctionToString(templateClass: ClassDeclaration, functionName: string, returnType: string, code: string): string;
183
- declare function nameUserCode(templateMarkDom: any): any;
184
- declare function getTemplateClassDeclaration(modelManager: ModelManager, templateConceptFqn?: string): ClassDeclaration;
185
-
186
- export { TemplateArchiveProcessor, TemplateLogic, TemplateMarkInterpreter, ensureDirSync, getTemplateClassDeclaration, nameUserCode, removeSync, writeFunctionToString };