@accordproject/template-engine 4.0.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.
- package/lib/TemplateArchiveProcessor.d.ts +93 -3
- package/lib/TemplateArchiveProcessor.js +322 -27
- package/lib/TemplateArchiveProcessor.js.map +1 -1
- package/lib/TypeScriptCompilationContext.d.ts +27 -0
- package/lib/TypeScriptCompilationContext.js +116 -3
- package/lib/TypeScriptCompilationContext.js.map +1 -1
- package/lib/drafting/MonetaryAmount/formatTokens.d.ts +13 -0
- package/lib/drafting/MonetaryAmount/formatTokens.js +44 -0
- package/lib/drafting/MonetaryAmount/formatTokens.js.map +1 -0
- package/lib/drafting/MonetaryAmount/index.js +2 -18
- package/lib/drafting/MonetaryAmount/index.js.map +1 -1
- package/lib/drafting/PreciseAmount/index.d.ts +17 -0
- package/lib/drafting/PreciseAmount/index.js +113 -0
- package/lib/drafting/PreciseAmount/index.js.map +1 -0
- package/lib/drafting/index.js +24 -4
- package/lib/drafting/index.js.map +1 -1
- package/lib/llm/LLMConfig.d.ts +121 -0
- package/lib/llm/LLMConfig.js +30 -0
- package/lib/llm/LLMConfig.js.map +1 -0
- package/lib/llm/LLMExecutor.d.ts +77 -0
- package/lib/llm/LLMExecutor.js +603 -0
- package/lib/llm/LLMExecutor.js.map +1 -0
- package/lib/llm/ModelManagerSchema.d.ts +14 -0
- package/lib/llm/ModelManagerSchema.js +67 -0
- package/lib/llm/ModelManagerSchema.js.map +1 -0
- package/lib/llm/Reasoners.d.ts +190 -0
- package/lib/llm/Reasoners.js +643 -0
- package/lib/llm/Reasoners.js.map +1 -0
- package/lib/runtime/declarations.d.ts +0 -1
- package/lib/runtime/declarations.js +1 -2
- package/lib/runtime/declarations.js.map +1 -1
- package/lib/utils.d.ts +29 -0
- package/lib/utils.js +51 -0
- package/lib/utils.js.map +1 -1
- package/package.json +11 -2
- package/umd/template-engine.js +4 -4
- package/umd/template-engine.js.LICENSE.txt +1 -1
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { Template } from '@accordproject/cicero-core';
|
|
2
2
|
import { TwoSlashReturn } from '@typescript/twoslash';
|
|
3
|
+
import { LLMExecutorConfig } from './llm/LLMConfig';
|
|
4
|
+
/** The contract state. */
|
|
3
5
|
export type State = object;
|
|
6
|
+
/** A response/result returned by the contract logic. */
|
|
4
7
|
export type Response = object;
|
|
8
|
+
/** An event emitted by the contract logic. */
|
|
5
9
|
export type Event = object;
|
|
10
|
+
/** The result of triggering a template: the response, updated state, and events. */
|
|
6
11
|
export type TriggerResponse = {
|
|
7
12
|
result: Response;
|
|
8
13
|
state: State;
|
|
9
14
|
events: Event[];
|
|
10
15
|
};
|
|
16
|
+
/** The result of initializing a template: the initial state. */
|
|
11
17
|
export type InitResponse = {
|
|
12
18
|
state: State;
|
|
13
19
|
};
|
|
@@ -16,13 +22,20 @@ export type InitResponse = {
|
|
|
16
22
|
* templatemark for the archive and trigger the logic of the archive
|
|
17
23
|
*/
|
|
18
24
|
export declare class TemplateArchiveProcessor {
|
|
25
|
+
/** The template used by the processor. */
|
|
19
26
|
template: Template;
|
|
27
|
+
/** Cache of compiled logic, keyed by script identifier. */
|
|
20
28
|
private compiledLogicCache?;
|
|
29
|
+
/** Optional LLM fallback configuration. */
|
|
30
|
+
llmConfig?: LLMExecutorConfig;
|
|
31
|
+
/** Lazily-created LLM executor reused across debug/init/trigger calls. */
|
|
32
|
+
private llmExecutor?;
|
|
21
33
|
/**
|
|
22
34
|
* Creates a template archive processor
|
|
23
35
|
* @param {Template} template - the template to be used by the processor
|
|
36
|
+
* @param {LLMExecutorConfig} [llmConfig] - optional LLM fallback configuration
|
|
24
37
|
*/
|
|
25
|
-
constructor(template: Template);
|
|
38
|
+
constructor(template: Template, llmConfig?: LLMExecutorConfig);
|
|
26
39
|
/**
|
|
27
40
|
* Drafts a template by merging it with data
|
|
28
41
|
* @param {any} data the data to merge with the template
|
|
@@ -38,17 +51,94 @@ export declare class TemplateArchiveProcessor {
|
|
|
38
51
|
* @returns {Promise<Record<string, TwoSlashReturn>>} the compiled code for each typescript file
|
|
39
52
|
*/
|
|
40
53
|
compileLogic(enableCompiledLogicCache?: boolean): Promise<Record<string, TwoSlashReturn>>;
|
|
54
|
+
/**
|
|
55
|
+
* Asserts that a runtime payload's declared type is, or extends, the given runtime
|
|
56
|
+
* base type. This enforces the runtime class hierarchy nominally (by `$class`), which
|
|
57
|
+
* the type system cannot: request is a bivariant `trigger` parameter, and State's
|
|
58
|
+
* generated interface is structurally satisfied by any identified concept. Using the
|
|
59
|
+
* model's own assignability, the bare base type and any subclass are accepted while a
|
|
60
|
+
* plain concept that does not extend the base is rejected.
|
|
61
|
+
* @param {any} payload - a serialized Concerto object (has a `$class`), or undefined
|
|
62
|
+
* @param {string} baseFqn - the fully-qualified name of the runtime base type
|
|
63
|
+
* @param {string} role - the payload's role, used in the error message
|
|
64
|
+
* @throws {Error} if the payload's type is not the base type or a subclass of it
|
|
65
|
+
*/
|
|
66
|
+
private assertRuntimeHierarchy;
|
|
67
|
+
/**
|
|
68
|
+
* Populates the `contract` back-reference that `org.accordproject.runtime.Obligation`
|
|
69
|
+
* (and therefore any event that extends it, e.g. a template's `PaymentObligationEvent`)
|
|
70
|
+
* requires, so that template logic never has to set it explicitly.
|
|
71
|
+
*
|
|
72
|
+
* Only events whose `contract` field is not already set are touched, so template logic
|
|
73
|
+
* that deliberately points an obligation at a different contract is left alone. Filling
|
|
74
|
+
* the field in is only meaningful when the template's own data model is itself a
|
|
75
|
+
* `Contract` (or a subtype of it) - that's the only instance in scope at `trigger()` time
|
|
76
|
+
* that the relationship is allowed to point to. The `Serializer` this class uses is
|
|
77
|
+
* constructed with `acceptResourcesForRelationships: true`, so handing it the full `data`
|
|
78
|
+
* resource is enough for it to resolve the relationship from that resource's own
|
|
79
|
+
* `$class`/identifier.
|
|
80
|
+
* @param {Event[]} events - the events returned by the template logic, mutated in place
|
|
81
|
+
* @param {any} data - the contract/clause data instance passed into trigger()
|
|
82
|
+
* @throws {Error} if an Obligation-derived event is missing `contract` and the template's
|
|
83
|
+
* data model does not extend Contract, so there is nothing valid to auto-populate with
|
|
84
|
+
*/
|
|
85
|
+
private populateObligationBackReferences;
|
|
86
|
+
private assertTemplateLogicSubclass;
|
|
87
|
+
/**
|
|
88
|
+
* Determines whether LLM fallback is enabled.
|
|
89
|
+
* @returns {boolean} true if an LLM config is present and not disabled
|
|
90
|
+
*/
|
|
91
|
+
private shouldUseLLM;
|
|
92
|
+
/**
|
|
93
|
+
* Constructs an LLM executor for this template.
|
|
94
|
+
* @returns {LLMExecutor} the LLM executor
|
|
95
|
+
* @throws {Error} if no LLM config is present
|
|
96
|
+
*/
|
|
97
|
+
private makeLLMExecutor;
|
|
98
|
+
/**
|
|
99
|
+
* Executes the template's compiled TypeScript trigger logic.
|
|
100
|
+
* @param {any} data - the data for the template
|
|
101
|
+
* @param {any} request - the request to send to the template logic
|
|
102
|
+
* @param {any} [priorState] - the state produced by init() (or a previous
|
|
103
|
+
* trigger()); required for stateful templates, ignored for stateless ones
|
|
104
|
+
* @param {string} [currentTime] - the current time, defaults to now
|
|
105
|
+
* @param {number} [utcOffset] - the UTC offset, defaults to zero
|
|
106
|
+
* @returns {Promise<TriggerResponse>} the response and any events
|
|
107
|
+
*/
|
|
108
|
+
private executeTypeScriptTrigger;
|
|
109
|
+
/**
|
|
110
|
+
* Executes the template's compiled TypeScript init logic. Returns an empty
|
|
111
|
+
* state when the compiled logic defines no `init` method (stateless template).
|
|
112
|
+
* @param {any} data - the data for the template
|
|
113
|
+
* @param {string} [currentTime] - the current time, defaults to now
|
|
114
|
+
* @param {number} [utcOffset] - the UTC offset, defaults to zero
|
|
115
|
+
* @returns {Promise<InitResponse>} the new state
|
|
116
|
+
*/
|
|
117
|
+
private executeTypeScriptInit;
|
|
41
118
|
/**
|
|
42
119
|
* Trigger the logic of a template.
|
|
120
|
+
*
|
|
121
|
+
* Stateful templates (`this.template.isStateful()`) carry state across
|
|
122
|
+
* executions, so they must always be seeded with `priorState` — the state
|
|
123
|
+
* returned by a prior call to {@link init} (or by a prior call to
|
|
124
|
+
* `trigger`) — before a request can be evaluated. There is no implicit
|
|
125
|
+
* "empty" state for a template that declares custom State fields; calling
|
|
126
|
+
* `trigger` without `priorState` for such a template throws. Stateless
|
|
127
|
+
* templates ignore `priorState` entirely.
|
|
43
128
|
* @param {object} data - the data for the template
|
|
44
129
|
* @param {object} request - the request to send to the template logic
|
|
45
|
-
* @param {object}
|
|
130
|
+
* @param {object} priorState - the state to evaluate the request against.
|
|
131
|
+
* For stateful templates this is required and must be the state produced
|
|
132
|
+
* by init() or a previous trigger(); for stateless templates it is ignored.
|
|
46
133
|
* @param {[string]} currentTime - the current time, defaults to now
|
|
47
134
|
* @param {[number]} utcOffset - the UTC offset, defaults to zero
|
|
48
135
|
* @param {boolean} [enableCompiledLogicCache] - whether to use the compiled logic cache
|
|
49
136
|
* @returns {Promise<TriggerResponse>} the response and any events
|
|
137
|
+
* @throws {Error} if the template is stateful and no priorState is supplied, or if an
|
|
138
|
+
* emitted event extends `org.accordproject.runtime.Obligation` and its `contract`
|
|
139
|
+
* back-reference can't be auto-populated (see {@link populateObligationBackReferences})
|
|
50
140
|
*/
|
|
51
|
-
trigger(data: any, request: any,
|
|
141
|
+
trigger(data: any, request: any, priorState?: any, currentTime?: string, utcOffset?: number, enableCompiledLogicCache?: boolean): Promise<TriggerResponse>;
|
|
52
142
|
/**
|
|
53
143
|
* Init the logic of a template.
|
|
54
144
|
* @param {object} data - the data for the template
|
|
@@ -12,14 +12,49 @@
|
|
|
12
12
|
* See the License for the specific language governing permissions and
|
|
13
13
|
* limitations under the License.
|
|
14
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
15
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
49
|
exports.TemplateArchiveProcessor = void 0;
|
|
50
|
+
const concerto_core_1 = require("@accordproject/concerto-core");
|
|
17
51
|
const TemplateMarkInterpreter_1 = require("./TemplateMarkInterpreter");
|
|
18
52
|
const markdown_template_1 = require("@accordproject/markdown-template");
|
|
19
53
|
const markdown_transform_1 = require("@accordproject/markdown-transform");
|
|
20
54
|
const TypeScriptToJavaScriptCompiler_1 = require("./TypeScriptToJavaScriptCompiler");
|
|
21
55
|
const JavaScriptEvaluator_1 = require("./JavaScriptEvaluator");
|
|
22
|
-
const
|
|
56
|
+
const LLMExecutor_1 = require("./llm/LLMExecutor");
|
|
57
|
+
const utils_1 = require("./utils");
|
|
23
58
|
/**
|
|
24
59
|
* A template archive processor: can draft content using the
|
|
25
60
|
* templatemark for the archive and trigger the logic of the archive
|
|
@@ -28,9 +63,11 @@ class TemplateArchiveProcessor {
|
|
|
28
63
|
/**
|
|
29
64
|
* Creates a template archive processor
|
|
30
65
|
* @param {Template} template - the template to be used by the processor
|
|
66
|
+
* @param {LLMExecutorConfig} [llmConfig] - optional LLM fallback configuration
|
|
31
67
|
*/
|
|
32
|
-
constructor(template) {
|
|
68
|
+
constructor(template, llmConfig) {
|
|
33
69
|
this.template = template;
|
|
70
|
+
this.llmConfig = llmConfig;
|
|
34
71
|
}
|
|
35
72
|
/**
|
|
36
73
|
* Drafts a template by merging it with data
|
|
@@ -50,11 +87,8 @@ class TemplateArchiveProcessor {
|
|
|
50
87
|
const templateMarkTransformer = new markdown_template_1.TemplateMarkTransformer();
|
|
51
88
|
const templateMarkDom = templateMarkTransformer.fromMarkdownTemplate({ content: this.template.getTemplate() }, modelManager, templateKind);
|
|
52
89
|
const now = currentTime ? currentTime : new Date().toISOString();
|
|
53
|
-
// console.log(JSON.stringify(templateMarkDom, null, 2));
|
|
54
90
|
const ciceroMark = await engine.generate(templateMarkDom, data, { now });
|
|
55
|
-
// console.log(JSON.stringify(ciceroMark));
|
|
56
91
|
const result = (0, markdown_transform_1.transform)(ciceroMark.toJSON(), 'ciceromark', ['ciceromark_unquoted', format], null, options);
|
|
57
|
-
// console.log(result);
|
|
58
92
|
return result;
|
|
59
93
|
}
|
|
60
94
|
/**
|
|
@@ -70,14 +104,37 @@ class TemplateArchiveProcessor {
|
|
|
70
104
|
if (logicManager.getLanguage() === 'typescript') {
|
|
71
105
|
const compiledCode = {};
|
|
72
106
|
const tsFiles = logicManager.getScriptManager().getScriptsForTarget('typescript');
|
|
107
|
+
const logicScript = tsFiles.find((tsFile) => tsFile.getIdentifier() === 'logic/logic.ts');
|
|
108
|
+
await this.assertTemplateLogicSubclass(logicScript);
|
|
73
109
|
for (let n = 0; n < tsFiles.length; n++) {
|
|
74
110
|
const tsFile = tsFiles[n];
|
|
75
111
|
const compiler = new TypeScriptToJavaScriptCompiler_1.TypeScriptToJavaScriptCompiler(this.template.getModelManager(), this.template.getTemplateModel().getFullyQualifiedName());
|
|
76
112
|
await compiler.initialize();
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
113
|
+
// The runtime type declarations (IConcept, TemplateLogic, etc.) are
|
|
114
|
+
// provided by the compilation context, with the State / Request / Response /
|
|
115
|
+
// Event type positions bound to the model-derived Runtime* unions (the
|
|
116
|
+
// concrete base plus its subclasses).
|
|
117
|
+
const result = compiler.compile(tsFile.getContents());
|
|
118
|
+
// Surface the runtime-hierarchy constraint violation (TS2344) as a hard
|
|
119
|
+
// error. The state type argument must satisfy the RuntimeState union; a type
|
|
120
|
+
// that is structurally incompatible with the base (e.g. a concept with no
|
|
121
|
+
// $identifier used as state, or an emit that is not assignable to the base
|
|
122
|
+
// Event) fails the constraint. Structural matches to the bare base are
|
|
123
|
+
// allowed here and are instead checked nominally at runtime
|
|
124
|
+
// (assertRuntimeHierarchy). Scoped to the logic entry point and to TS2344 so
|
|
125
|
+
// that unrelated diagnostics (and non-logic scripts such as README.md) do
|
|
126
|
+
// not turn into hard failures.
|
|
127
|
+
const isLogicEntry = tsFile.getIdentifier().endsWith('logic.ts');
|
|
128
|
+
if (isLogicEntry) {
|
|
129
|
+
const hierarchyErrors = (result.errors || [])
|
|
130
|
+
.filter(e => e.category === 1 && e.code === 2344);
|
|
131
|
+
if (hierarchyErrors.length > 0) {
|
|
132
|
+
const message = hierarchyErrors.map(e => e.renderedMessage).join('\n');
|
|
133
|
+
throw new Error('Invalid template: State, Request, Response and Event declarations must ' +
|
|
134
|
+
'be, or extend, their runtime base types (org.accordproject.runtime ' +
|
|
135
|
+
`State / Request / Response and the Concerto Event).\n${message}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
81
138
|
compiledCode[tsFile.getIdentifier()] = result;
|
|
82
139
|
}
|
|
83
140
|
if (enableCompiledLogicCache) {
|
|
@@ -90,17 +147,131 @@ class TemplateArchiveProcessor {
|
|
|
90
147
|
}
|
|
91
148
|
}
|
|
92
149
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @param {
|
|
150
|
+
* Asserts that a runtime payload's declared type is, or extends, the given runtime
|
|
151
|
+
* base type. This enforces the runtime class hierarchy nominally (by `$class`), which
|
|
152
|
+
* the type system cannot: request is a bivariant `trigger` parameter, and State's
|
|
153
|
+
* generated interface is structurally satisfied by any identified concept. Using the
|
|
154
|
+
* model's own assignability, the bare base type and any subclass are accepted while a
|
|
155
|
+
* plain concept that does not extend the base is rejected.
|
|
156
|
+
* @param {any} payload - a serialized Concerto object (has a `$class`), or undefined
|
|
157
|
+
* @param {string} baseFqn - the fully-qualified name of the runtime base type
|
|
158
|
+
* @param {string} role - the payload's role, used in the error message
|
|
159
|
+
* @throws {Error} if the payload's type is not the base type or a subclass of it
|
|
160
|
+
*/
|
|
161
|
+
assertRuntimeHierarchy(payload, baseFqn, role) {
|
|
162
|
+
if (!payload || !payload.$class) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (!(0, utils_1.isAssignableTo)(this.template.getModelManager(), payload.$class, baseFqn)) {
|
|
166
|
+
throw new Error(`Invalid ${role}: '${payload.$class}' must be, or extend, the runtime ` +
|
|
167
|
+
`${role} type (${baseFqn}).`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Populates the `contract` back-reference that `org.accordproject.runtime.Obligation`
|
|
172
|
+
* (and therefore any event that extends it, e.g. a template's `PaymentObligationEvent`)
|
|
173
|
+
* requires, so that template logic never has to set it explicitly.
|
|
174
|
+
*
|
|
175
|
+
* Only events whose `contract` field is not already set are touched, so template logic
|
|
176
|
+
* that deliberately points an obligation at a different contract is left alone. Filling
|
|
177
|
+
* the field in is only meaningful when the template's own data model is itself a
|
|
178
|
+
* `Contract` (or a subtype of it) - that's the only instance in scope at `trigger()` time
|
|
179
|
+
* that the relationship is allowed to point to. The `Serializer` this class uses is
|
|
180
|
+
* constructed with `acceptResourcesForRelationships: true`, so handing it the full `data`
|
|
181
|
+
* resource is enough for it to resolve the relationship from that resource's own
|
|
182
|
+
* `$class`/identifier.
|
|
183
|
+
* @param {Event[]} events - the events returned by the template logic, mutated in place
|
|
184
|
+
* @param {any} data - the contract/clause data instance passed into trigger()
|
|
185
|
+
* @throws {Error} if an Obligation-derived event is missing `contract` and the template's
|
|
186
|
+
* data model does not extend Contract, so there is nothing valid to auto-populate with
|
|
187
|
+
*/
|
|
188
|
+
populateObligationBackReferences(events, data) {
|
|
189
|
+
const modelManager = this.template.getModelManager();
|
|
190
|
+
events.forEach((event) => {
|
|
191
|
+
if (!event || !event.$class || event.contract) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (!(0, utils_1.isAssignableTo)(modelManager, event.$class, utils_1.RUNTIME_OBLIGATION_FQN)) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (data && data.$class && (0, utils_1.isAssignableTo)(modelManager, data.$class, utils_1.RUNTIME_CONTRACT_FQN)) {
|
|
198
|
+
// Relationship fields must be a "<fq-class>#<id>" string, not the full resource.
|
|
199
|
+
// Assigning `data` directly (as before) satisfies acceptResourcesForRelationships
|
|
200
|
+
// during population, but validate() then rejects it: that flag only relaxes what
|
|
201
|
+
// the populator will accept as *input*, it doesn't change what a relationship field
|
|
202
|
+
// is allowed to *hold* afterward - it still must be a Relationship, not a Resource.
|
|
203
|
+
const classDecl = modelManager.getType(data.$class);
|
|
204
|
+
const idField = classDecl.getIdentifierFieldName();
|
|
205
|
+
const idValue = idField ? data[idField] : undefined;
|
|
206
|
+
if (!idField || idValue === undefined) {
|
|
207
|
+
throw new Error(`Cannot populate the required 'contract' back-reference on event '${event.$class}': ` +
|
|
208
|
+
`the data model '${data.$class}' has no resolvable identifier value for field '${idField}'.`);
|
|
209
|
+
}
|
|
210
|
+
event.contract = `${idValue}`;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
throw new Error(`Cannot populate the required 'contract' back-reference on event '${event.$class}': ` +
|
|
214
|
+
`it extends ${utils_1.RUNTIME_OBLIGATION_FQN}, but this template's data model ` +
|
|
215
|
+
`('${data?.$class ?? 'undefined'}') does not extend ${utils_1.RUNTIME_CONTRACT_FQN}. Either ` +
|
|
216
|
+
"change the template model to extend Contract, or have the template logic set " +
|
|
217
|
+
"'contract' explicitly on the event before returning it.");
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
async assertTemplateLogicSubclass(tsFile) {
|
|
221
|
+
if (!tsFile) {
|
|
222
|
+
throw new Error('Template logic compilation requires a logic/logic.ts file.');
|
|
223
|
+
}
|
|
224
|
+
const tsImport = await Promise.resolve().then(() => __importStar(require('typescript')));
|
|
225
|
+
const tsModule = ('default' in tsImport && tsImport.default ? tsImport.default : tsImport);
|
|
226
|
+
const sourceFile = tsModule.createSourceFile(tsFile.getIdentifier(), tsFile.getContents(), tsModule.ScriptTarget.Latest, true, tsModule.ScriptKind.TS);
|
|
227
|
+
const hasTemplateLogicSubclass = sourceFile.statements.some((statement) => {
|
|
228
|
+
if (!tsModule.isClassDeclaration(statement) || !statement.heritageClauses) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
return statement.heritageClauses.some((clause) => clause.token === tsModule.SyntaxKind.ExtendsKeyword &&
|
|
232
|
+
clause.types.some((heritageType) => {
|
|
233
|
+
const expression = heritageType.expression;
|
|
234
|
+
return (tsModule.isIdentifier(expression) && expression.text === 'TemplateLogic') ||
|
|
235
|
+
(tsModule.isPropertyAccessExpression(expression) && expression.name.text === 'TemplateLogic');
|
|
236
|
+
}));
|
|
237
|
+
});
|
|
238
|
+
if (!hasTemplateLogicSubclass) {
|
|
239
|
+
throw new Error(`Template logic compilation requires ${tsFile.getIdentifier()} to define a class extending TemplateLogic.`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Determines whether LLM fallback is enabled.
|
|
244
|
+
* @returns {boolean} true if an LLM config is present and not disabled
|
|
245
|
+
*/
|
|
246
|
+
shouldUseLLM() {
|
|
247
|
+
return !!this.llmConfig && this.llmConfig.mode !== 'disabled';
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Constructs an LLM executor for this template.
|
|
251
|
+
* @returns {LLMExecutor} the LLM executor
|
|
252
|
+
* @throws {Error} if no LLM config is present
|
|
253
|
+
*/
|
|
254
|
+
makeLLMExecutor() {
|
|
255
|
+
if (!this.llmConfig) {
|
|
256
|
+
throw new Error('LLM fallback requested but llmConfig is missing');
|
|
257
|
+
}
|
|
258
|
+
if (!this.llmExecutor) {
|
|
259
|
+
this.llmExecutor = new LLMExecutor_1.LLMExecutor(this.template, this.llmConfig);
|
|
260
|
+
}
|
|
261
|
+
return this.llmExecutor;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Executes the template's compiled TypeScript trigger logic.
|
|
265
|
+
* @param {any} data - the data for the template
|
|
266
|
+
* @param {any} request - the request to send to the template logic
|
|
267
|
+
* @param {any} [priorState] - the state produced by init() (or a previous
|
|
268
|
+
* trigger()); required for stateful templates, ignored for stateless ones
|
|
269
|
+
* @param {string} [currentTime] - the current time, defaults to now
|
|
270
|
+
* @param {number} [utcOffset] - the UTC offset, defaults to zero
|
|
100
271
|
* @returns {Promise<TriggerResponse>} the response and any events
|
|
101
272
|
*/
|
|
102
|
-
async
|
|
103
|
-
const compiledCode = await this.compileLogic(
|
|
273
|
+
async executeTypeScriptTrigger(data, request, priorState, currentTime, utcOffset) {
|
|
274
|
+
const compiledCode = await this.compileLogic();
|
|
104
275
|
const resolvedTime = currentTime ?? new Date().toISOString();
|
|
105
276
|
const resolvedOffset = utcOffset ?? 0;
|
|
106
277
|
const evaluator = new JavaScriptEvaluator_1.JavaScriptEvaluator();
|
|
@@ -110,7 +281,7 @@ class TemplateArchiveProcessor {
|
|
|
110
281
|
functionName: 'trigger',
|
|
111
282
|
code: compiledCode['logic/logic.ts'].code, // TODO DCS - how to find the code to run?
|
|
112
283
|
argumentNames: ['data', 'request', 'state'],
|
|
113
|
-
arguments: [data, request,
|
|
284
|
+
arguments: [data, request, priorState, resolvedTime, resolvedOffset]
|
|
114
285
|
});
|
|
115
286
|
if (evalResponse.result) {
|
|
116
287
|
return evalResponse.result;
|
|
@@ -120,15 +291,21 @@ class TemplateArchiveProcessor {
|
|
|
120
291
|
}
|
|
121
292
|
}
|
|
122
293
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @param {
|
|
126
|
-
* @param {[
|
|
127
|
-
* @param {
|
|
294
|
+
* Executes the template's compiled TypeScript init logic. Returns an empty
|
|
295
|
+
* state when the compiled logic defines no `init` method (stateless template).
|
|
296
|
+
* @param {any} data - the data for the template
|
|
297
|
+
* @param {string} [currentTime] - the current time, defaults to now
|
|
298
|
+
* @param {number} [utcOffset] - the UTC offset, defaults to zero
|
|
128
299
|
* @returns {Promise<InitResponse>} the new state
|
|
129
300
|
*/
|
|
130
|
-
async
|
|
131
|
-
const compiledCode = await this.compileLogic(
|
|
301
|
+
async executeTypeScriptInit(data, currentTime, utcOffset) {
|
|
302
|
+
const compiledCode = await this.compileLogic();
|
|
303
|
+
const logicCode = compiledCode['logic/logic.ts']?.code;
|
|
304
|
+
// Check if the compiled code even contains an `init` method before calling it
|
|
305
|
+
if (!logicCode || (!logicCode.includes('init(') && !logicCode.includes('init ('))) {
|
|
306
|
+
// Stateless template — no init method defined, return empty state
|
|
307
|
+
return { state: {} };
|
|
308
|
+
}
|
|
132
309
|
const resolvedTime = currentTime ?? new Date().toISOString();
|
|
133
310
|
const resolvedOffset = utcOffset ?? 0;
|
|
134
311
|
const evaluator = new JavaScriptEvaluator_1.JavaScriptEvaluator();
|
|
@@ -136,7 +313,7 @@ class TemplateArchiveProcessor {
|
|
|
136
313
|
templateLogic: true,
|
|
137
314
|
verbose: false,
|
|
138
315
|
functionName: 'init',
|
|
139
|
-
code:
|
|
316
|
+
code: logicCode, // TODO DCS - how to find the code to run?
|
|
140
317
|
argumentNames: ['data'],
|
|
141
318
|
arguments: [data, resolvedTime, resolvedOffset]
|
|
142
319
|
});
|
|
@@ -147,6 +324,124 @@ class TemplateArchiveProcessor {
|
|
|
147
324
|
throw new Error('Init failed with message: ' + evalResponse.message);
|
|
148
325
|
}
|
|
149
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Trigger the logic of a template.
|
|
329
|
+
*
|
|
330
|
+
* Stateful templates (`this.template.isStateful()`) carry state across
|
|
331
|
+
* executions, so they must always be seeded with `priorState` — the state
|
|
332
|
+
* returned by a prior call to {@link init} (or by a prior call to
|
|
333
|
+
* `trigger`) — before a request can be evaluated. There is no implicit
|
|
334
|
+
* "empty" state for a template that declares custom State fields; calling
|
|
335
|
+
* `trigger` without `priorState` for such a template throws. Stateless
|
|
336
|
+
* templates ignore `priorState` entirely.
|
|
337
|
+
* @param {object} data - the data for the template
|
|
338
|
+
* @param {object} request - the request to send to the template logic
|
|
339
|
+
* @param {object} priorState - the state to evaluate the request against.
|
|
340
|
+
* For stateful templates this is required and must be the state produced
|
|
341
|
+
* by init() or a previous trigger(); for stateless templates it is ignored.
|
|
342
|
+
* @param {[string]} currentTime - the current time, defaults to now
|
|
343
|
+
* @param {[number]} utcOffset - the UTC offset, defaults to zero
|
|
344
|
+
* @param {boolean} [enableCompiledLogicCache] - whether to use the compiled logic cache
|
|
345
|
+
* @returns {Promise<TriggerResponse>} the response and any events
|
|
346
|
+
* @throws {Error} if the template is stateful and no priorState is supplied, or if an
|
|
347
|
+
* emitted event extends `org.accordproject.runtime.Obligation` and its `contract`
|
|
348
|
+
* back-reference can't be auto-populated (see {@link populateObligationBackReferences})
|
|
349
|
+
*/
|
|
350
|
+
async trigger(data, request, priorState, currentTime, utcOffset, enableCompiledLogicCache) {
|
|
351
|
+
const factory = new concerto_core_1.Factory(this.template.getModelManager());
|
|
352
|
+
const serializer = new concerto_core_1.Serializer(factory, this.template.getModelManager(), { validate: true });
|
|
353
|
+
// Stateful templates must always be triggered against the state produced by
|
|
354
|
+
// init() (or a previous trigger()) — there is no implicit "empty" state for
|
|
355
|
+
// a template that declares custom State fields. Stateless templates have no
|
|
356
|
+
// persistent state, so priorState is not required for them.
|
|
357
|
+
if (this.template.isStateful() && (!priorState || Object.keys(priorState).length === 0)) {
|
|
358
|
+
throw new Error('Stateful templates require priorState: call init() first and pass its ' +
|
|
359
|
+
'returned state (or the state returned by a previous trigger()) as priorState.');
|
|
360
|
+
}
|
|
361
|
+
// validate inputs before execution. A stateless template's init returns an empty
|
|
362
|
+
// placeholder state ({}); skip only that. Any other state - including a non-empty
|
|
363
|
+
// object with no $class - is validated normally (and fails if malformed).
|
|
364
|
+
if (data)
|
|
365
|
+
serializer.fromJSON(data);
|
|
366
|
+
if (request)
|
|
367
|
+
serializer.fromJSON(request);
|
|
368
|
+
if (priorState && Object.keys(priorState).length > 0)
|
|
369
|
+
serializer.fromJSON(priorState);
|
|
370
|
+
// enforce the runtime class hierarchy on the inputs
|
|
371
|
+
this.assertRuntimeHierarchy(request, utils_1.RUNTIME_REQUEST_FQN, 'request');
|
|
372
|
+
this.assertRuntimeHierarchy(priorState, utils_1.RUNTIME_STATE_FQN, 'state');
|
|
373
|
+
let triggerResponse;
|
|
374
|
+
const forceLLM = this.llmConfig?.mode === 'force';
|
|
375
|
+
// Run the template's TypeScript logic unless the caller forces the LLM path.
|
|
376
|
+
if (!forceLLM && this.template.hasLogic()) {
|
|
377
|
+
if (enableCompiledLogicCache) {
|
|
378
|
+
await this.compileLogic(true);
|
|
379
|
+
}
|
|
380
|
+
triggerResponse = await this.executeTypeScriptTrigger(data, request, priorState, currentTime, utcOffset);
|
|
381
|
+
}
|
|
382
|
+
else if (forceLLM || this.shouldUseLLM()) {
|
|
383
|
+
// Otherwise use the LLM executor
|
|
384
|
+
triggerResponse = await this.makeLLMExecutor().trigger(data, request, priorState, currentTime, utcOffset);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
throw new Error('No executable logic found and LLM fallback is disabled');
|
|
388
|
+
}
|
|
389
|
+
// validate outputs after execution (skip only the empty {} placeholder state)
|
|
390
|
+
if (triggerResponse.state && Object.keys(triggerResponse.state).length > 0)
|
|
391
|
+
serializer.fromJSON(triggerResponse.state);
|
|
392
|
+
if (triggerResponse.result)
|
|
393
|
+
serializer.fromJSON(triggerResponse.result);
|
|
394
|
+
if (triggerResponse.events && Array.isArray(triggerResponse.events)) {
|
|
395
|
+
this.populateObligationBackReferences(triggerResponse.events, data);
|
|
396
|
+
triggerResponse.events.forEach(e => serializer.fromJSON(e));
|
|
397
|
+
}
|
|
398
|
+
// enforce the runtime class hierarchy on the outputs
|
|
399
|
+
this.assertRuntimeHierarchy(triggerResponse.state, utils_1.RUNTIME_STATE_FQN, 'state');
|
|
400
|
+
this.assertRuntimeHierarchy(triggerResponse.result, utils_1.RUNTIME_RESPONSE_FQN, 'response');
|
|
401
|
+
if (triggerResponse.events && Array.isArray(triggerResponse.events)) {
|
|
402
|
+
triggerResponse.events.forEach(e => this.assertRuntimeHierarchy(e, utils_1.BASE_EVENT_FQN, 'event'));
|
|
403
|
+
}
|
|
404
|
+
return triggerResponse;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Init the logic of a template.
|
|
408
|
+
* @param {object} data - the data for the template
|
|
409
|
+
* @param {[string]} currentTime - the current time, defaults to now
|
|
410
|
+
* @param {[number]} utcOffset - the UTC offset, defaults to zero
|
|
411
|
+
* @param {boolean} [enableCompiledLogicCache] - whether to use the compiled logic cache
|
|
412
|
+
* @returns {Promise<InitResponse>} the new state
|
|
413
|
+
*/
|
|
414
|
+
async init(data, currentTime, utcOffset, enableCompiledLogicCache) {
|
|
415
|
+
const factory = new concerto_core_1.Factory(this.template.getModelManager());
|
|
416
|
+
const serializer = new concerto_core_1.Serializer(factory, this.template.getModelManager(), { validate: true });
|
|
417
|
+
// validate inputs before execution
|
|
418
|
+
if (data)
|
|
419
|
+
serializer.fromJSON(data);
|
|
420
|
+
let initResponse;
|
|
421
|
+
const forceLLM = this.llmConfig?.mode === 'force';
|
|
422
|
+
// Run the template's TypeScript logic unless the caller forces the LLM path.
|
|
423
|
+
if (!forceLLM && this.template.hasLogic()) {
|
|
424
|
+
if (enableCompiledLogicCache) {
|
|
425
|
+
await this.compileLogic(true);
|
|
426
|
+
}
|
|
427
|
+
initResponse = await this.executeTypeScriptInit(data, currentTime, utcOffset);
|
|
428
|
+
}
|
|
429
|
+
else if (forceLLM || this.shouldUseLLM()) {
|
|
430
|
+
// Otherwise use the LLM executor
|
|
431
|
+
initResponse = await this.makeLLMExecutor().init(data, currentTime, utcOffset);
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
throw new Error('No executable logic found and LLM fallback is disabled');
|
|
435
|
+
}
|
|
436
|
+
// validate outputs after execution. A stateless template returns an empty
|
|
437
|
+
// placeholder state ({}); skip only that - any other state is validated normally.
|
|
438
|
+
if (initResponse.state && Object.keys(initResponse.state).length > 0)
|
|
439
|
+
serializer.fromJSON(initResponse.state);
|
|
440
|
+
// enforce the runtime class hierarchy on the output state (skipped for the empty
|
|
441
|
+
// state of a stateless template, which has no $class)
|
|
442
|
+
this.assertRuntimeHierarchy(initResponse.state, utils_1.RUNTIME_STATE_FQN, 'state');
|
|
443
|
+
return initResponse;
|
|
444
|
+
}
|
|
150
445
|
}
|
|
151
446
|
exports.TemplateArchiveProcessor = TemplateArchiveProcessor;
|
|
152
447
|
//# sourceMappingURL=TemplateArchiveProcessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateArchiveProcessor.js","sourceRoot":"","sources":["../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ration;
|
|
12
12
|
constructor(modelManager: ModelManager, templateConceptFqn?: string);
|
|
13
13
|
getTypeScriptFiles(): Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* Builds a TypeScript union type over the concrete types assignable to a runtime
|
|
16
|
+
* base type (the base itself, when concrete, plus its subclasses), along with the
|
|
17
|
+
* imports required to reference them. Because the base is included, using the bare
|
|
18
|
+
* base type or any subclass type-checks. A plain concept that does not extend the
|
|
19
|
+
* base is still rejected structurally where the base carries a distinguishing member
|
|
20
|
+
* (Response/Event require `$timestamp`); State carries only `$identifier`, so a
|
|
21
|
+
* concept-shaped state is admitted here and instead enforced nominally at runtime
|
|
22
|
+
* (see TemplateArchiveProcessor.assertRuntimeHierarchy). When the base type is absent
|
|
23
|
+
* the union is `never`.
|
|
24
|
+
* @param {string} baseFqn the fully-qualified name of the runtime base type
|
|
25
|
+
* @param {string} aliasPrefix a unique prefix for the imported type aliases
|
|
26
|
+
* @returns {{imports: string, union: string}} the import statements and union type
|
|
27
|
+
*/
|
|
28
|
+
private buildRuntimeUnion;
|
|
29
|
+
/**
|
|
30
|
+
* Emits the runtime SmartLegalContract declarations (IConcept, TemplateLogic, etc.)
|
|
31
|
+
* with the State / Request / Response / Event type positions bound to the model-derived
|
|
32
|
+
* Runtime* unions (the concrete base type plus its subclasses; see buildRuntimeUnion).
|
|
33
|
+
* Because the concrete base is included, using the bare base type or a subclass
|
|
34
|
+
* type-checks. Types that are structurally incompatible with the base still fail here
|
|
35
|
+
* (Response/Event require `$timestamp`); State carries only `$identifier`, so a
|
|
36
|
+
* concept-shaped state type-checks and is instead enforced nominally at runtime (see
|
|
37
|
+
* TemplateArchiveProcessor.assertRuntimeHierarchy).
|
|
38
|
+
* @returns {string} the runtime declarations, as a TypeScript source string
|
|
39
|
+
*/
|
|
40
|
+
private getRuntimeDeclarations;
|
|
14
41
|
getCompilationContext(): string;
|
|
15
42
|
}
|