@accordproject/template-engine 3.0.1 → 4.0.0

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