@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.
- package/README.md +41 -0
- package/lib/JavaScriptEvaluator.d.ts +71 -0
- package/lib/JavaScriptEvaluator.js +245 -0
- package/lib/JavaScriptEvaluator.js.map +1 -0
- package/lib/TemplateArchiveProcessor.d.ts +61 -0
- package/lib/TemplateArchiveProcessor.js +152 -0
- package/lib/TemplateArchiveProcessor.js.map +1 -0
- package/lib/TemplateMarkInterpreter.d.ts +34 -0
- package/lib/TemplateMarkInterpreter.js +689 -0
- package/lib/TemplateMarkInterpreter.js.map +1 -0
- package/lib/TemplateMarkNodes.d.ts +19 -0
- package/lib/TemplateMarkNodes.js +45 -0
- package/lib/TemplateMarkNodes.js.map +1 -0
- package/lib/TemplateMarkToJavaScriptCompiler.d.ts +20 -0
- package/lib/TemplateMarkToJavaScriptCompiler.js +99 -0
- package/lib/TemplateMarkToJavaScriptCompiler.js.map +1 -0
- package/lib/TypeScriptCompilationContext.d.ts +15 -0
- package/lib/TypeScriptCompilationContext.js +57 -0
- package/lib/TypeScriptCompilationContext.js.map +1 -0
- package/lib/TypeScriptRuntime.d.ts +17 -0
- package/lib/TypeScriptRuntime.js +84 -0
- package/lib/TypeScriptRuntime.js.map +1 -0
- package/lib/TypeScriptToJavaScriptCompiler.d.ts +11 -0
- package/lib/TypeScriptToJavaScriptCompiler.js +169 -0
- package/lib/TypeScriptToJavaScriptCompiler.js.map +1 -0
- package/lib/drafting/Boolean/index.d.ts +6 -0
- package/lib/drafting/Boolean/index.js +30 -0
- package/lib/drafting/Boolean/index.js.map +1 -0
- package/lib/drafting/DateTime/index.d.ts +8 -0
- package/lib/drafting/DateTime/index.js +33 -0
- package/lib/drafting/DateTime/index.js.map +1 -0
- package/lib/drafting/Double/format.d.ts +14 -0
- package/lib/drafting/Double/format.js +62 -0
- package/lib/drafting/Double/format.js.map +1 -0
- package/lib/drafting/Double/index.d.ts +8 -0
- package/lib/drafting/Double/index.js +33 -0
- package/lib/drafting/Double/index.js.map +1 -0
- package/lib/drafting/DraftFormat.d.ts +5 -0
- package/lib/drafting/DraftFormat.js +18 -0
- package/lib/drafting/DraftFormat.js.map +1 -0
- package/lib/drafting/Duration/index.d.ts +6 -0
- package/lib/drafting/Duration/index.js +39 -0
- package/lib/drafting/Duration/index.js.map +1 -0
- package/lib/drafting/Integer/format.d.ts +14 -0
- package/lib/drafting/Integer/format.js +52 -0
- package/lib/drafting/Integer/format.js.map +1 -0
- package/lib/drafting/Integer/index.d.ts +8 -0
- package/lib/drafting/Integer/index.js +33 -0
- package/lib/drafting/Integer/index.js.map +1 -0
- package/lib/drafting/Long/index.d.ts +8 -0
- package/lib/drafting/Long/index.js +33 -0
- package/lib/drafting/Long/index.js.map +1 -0
- package/lib/drafting/MonetaryAmount/currencycode.d.ts +35 -0
- package/lib/drafting/MonetaryAmount/currencycode.js +53 -0
- package/lib/drafting/MonetaryAmount/currencycode.js.map +1 -0
- package/lib/drafting/MonetaryAmount/index.d.ts +13 -0
- package/lib/drafting/MonetaryAmount/index.js +67 -0
- package/lib/drafting/MonetaryAmount/index.js.map +1 -0
- package/lib/drafting/String/index.d.ts +6 -0
- package/lib/drafting/String/index.js +25 -0
- package/lib/drafting/String/index.js.map +1 -0
- package/lib/drafting/index.d.ts +2 -0
- package/lib/drafting/index.js +43 -0
- package/lib/drafting/index.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +42 -0
- package/lib/index.js.map +1 -0
- package/lib/model-gen/concerto.d.ts +13 -0
- package/lib/model-gen/concerto.js +4 -0
- package/lib/model-gen/concerto.js.map +1 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.d.ts +196 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.js +4 -0
- package/lib/model-gen/concerto.metamodel@1.0.0.js.map +1 -0
- package/lib/model-gen/concerto@1.0.0.d.ts +19 -0
- package/lib/model-gen/concerto@1.0.0.js +4 -0
- package/lib/model-gen/concerto@1.0.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.d.ts +49 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.js +4 -0
- package/lib/model-gen/org.accordproject.ciceromark@0.6.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.d.ts +89 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.js +4 -0
- package/lib/model-gen/org.accordproject.commonmark@0.5.0.js.map +1 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.d.ts +76 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.js +11 -0
- package/lib/model-gen/org.accordproject.templatemark@0.5.0.js.map +1 -0
- package/lib/runtime/declarations.d.ts +3 -0
- package/lib/runtime/declarations.js +22 -0
- package/lib/runtime/declarations.js.map +1 -0
- package/lib/slc/model-gen/concerto.d.ts +13 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.d.ts +6 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.js +5 -0
- package/lib/slc/model-gen/concerto.decorator@1.0.0.js.map +1 -0
- package/lib/slc/model-gen/concerto.js +5 -0
- package/lib/slc/model-gen/concerto.js.map +1 -0
- package/lib/slc/model-gen/concerto@1.0.0.d.ts +24 -0
- package/lib/slc/model-gen/concerto@1.0.0.js +6 -0
- package/lib/slc/model-gen/concerto@1.0.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.d.ts +7 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.js +5 -0
- package/lib/slc/model-gen/org.accordproject.contract@0.2.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.d.ts +15 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.js +4 -0
- package/lib/slc/model-gen/org.accordproject.runtime@0.2.0.js.map +1 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.d.ts +46 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.js +48 -0
- package/lib/slc/model-gen/org.accordproject.time@0.3.0.js.map +1 -0
- package/lib/utils.d.ts +6 -0
- package/lib/utils.js +71 -0
- package/lib/utils.js.map +1 -0
- package/lib/worker.d.ts +1 -0
- package/{dist → lib}/worker.js +12 -10
- package/lib/worker.js.map +1 -0
- package/package.json +37 -25
- package/umd/template-engine.js +13 -0
- package/umd/template-engine.js.LICENSE.txt +21 -0
- package/dist/index.d.ts +0 -174
- package/dist/index.js +0 -1244
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1217
- package/dist/index.mjs.map +0 -1
- 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 };
|