@memberjunction/templates 5.42.0 → 5.43.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/operations/TemplateRunOperation.d.ts +6 -0
- package/dist/operations/TemplateRunOperation.d.ts.map +1 -0
- package/dist/operations/TemplateRunOperation.js +54 -0
- package/dist/operations/TemplateRunOperation.js.map +1 -0
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export * from './TemplateEngine.js';
|
|
|
2
2
|
export * from './extensions/AIPrompt.extension.js';
|
|
3
3
|
export * from './extensions/TemplateEmbed.extension.js';
|
|
4
4
|
export * from './extensions/TemplateExtensionBase.js';
|
|
5
|
+
export * from './operations/TemplateRunOperation.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AAAA,cAAc,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export * from './TemplateEngine.js';
|
|
|
2
2
|
export * from './extensions/AIPrompt.extension.js';
|
|
3
3
|
export * from './extensions/TemplateEmbed.extension.js';
|
|
4
4
|
export * from './extensions/TemplateExtensionBase.js';
|
|
5
|
+
export * from './operations/TemplateRunOperation.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AAAA,cAAc,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
2
|
+
import { TemplateRunOperation, type TemplateRunInput, type TemplateRunOutput } from '@memberjunction/core-entities';
|
|
3
|
+
export declare class TemplateRunServerOperation extends TemplateRunOperation {
|
|
4
|
+
protected InternalExecute(input: TemplateRunInput, provider: IMetadataProvider, user: UserInfo): Promise<TemplateRunOutput>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=TemplateRunOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateRunOperation.d.ts","sourceRoot":"","sources":["../../src/operations/TemplateRunOperation.ts"],"names":[],"mappings":"AAUA,OAAO,EAA0B,iBAAiB,EAAW,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEpG,OAAO,EAAE,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGpH,qBACa,0BAA2B,SAAQ,oBAAoB;cAChD,eAAe,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAqCpI"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview Server implementation of the `Template.Run` Remote Operation — renders a template by ID
|
|
9
|
+
* with optional render data. Extends the CodeGen-emitted {@link TemplateRunOperation} base in
|
|
10
|
+
* `@memberjunction/core-entities` (`generated/remote_operations.ts` — operation key + typed I/O, from the
|
|
11
|
+
* `MJ: Remote Operations` row) and supplies the server body via `TemplateEngineServer`. Registered under
|
|
12
|
+
* `Template.Run`; replaces the bespoke `RunTemplate` GraphQL
|
|
13
|
+
* resolver (which remains as a deprecated backcompat shim).
|
|
14
|
+
* @module @memberjunction/templates
|
|
15
|
+
*/
|
|
16
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
17
|
+
import { BaseRemotableOperation, RunView } from '@memberjunction/core';
|
|
18
|
+
import { TemplateRunOperation } from '@memberjunction/core-entities';
|
|
19
|
+
import { TemplateEngineServer } from '../TemplateEngine.js';
|
|
20
|
+
let TemplateRunServerOperation = class TemplateRunServerOperation extends TemplateRunOperation {
|
|
21
|
+
async InternalExecute(input, provider, user) {
|
|
22
|
+
if (!input?.templateID) {
|
|
23
|
+
throw new Error('templateID is required');
|
|
24
|
+
}
|
|
25
|
+
const startTime = Date.now();
|
|
26
|
+
const templateEntity = await provider.GetEntityObject('MJ: Templates', user);
|
|
27
|
+
await templateEntity.Load(input.templateID);
|
|
28
|
+
if (!templateEntity.IsSaved) {
|
|
29
|
+
throw new Error(`Template with ID ${input.templateID} not found`);
|
|
30
|
+
}
|
|
31
|
+
// Highest-priority content for the template.
|
|
32
|
+
const contentResult = await RunView.FromMetadataProvider(provider).RunView({
|
|
33
|
+
EntityName: 'MJ: Template Contents',
|
|
34
|
+
ExtraFilter: `TemplateID = '${input.templateID}'`,
|
|
35
|
+
OrderBy: 'Priority ASC',
|
|
36
|
+
MaxRows: 1,
|
|
37
|
+
ResultType: 'entity_object',
|
|
38
|
+
}, user);
|
|
39
|
+
if (!contentResult.Results?.length) {
|
|
40
|
+
throw new Error(`No template content found for template ${templateEntity.Name}`);
|
|
41
|
+
}
|
|
42
|
+
await TemplateEngineServer.Instance.Config(true /* refresh to get latest templates */, user, provider);
|
|
43
|
+
const result = await TemplateEngineServer.Instance.RenderTemplate(templateEntity, contentResult.Results[0], input.data ?? {}, true /* skip validation for execution */);
|
|
44
|
+
if (!result.Success) {
|
|
45
|
+
throw new Error(result.Message ?? 'Template render failed');
|
|
46
|
+
}
|
|
47
|
+
return { output: result.Output ?? '', executionTimeMs: Date.now() - startTime };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
TemplateRunServerOperation = __decorate([
|
|
51
|
+
RegisterClass(BaseRemotableOperation, 'Template.Run')
|
|
52
|
+
], TemplateRunServerOperation);
|
|
53
|
+
export { TemplateRunServerOperation };
|
|
54
|
+
//# sourceMappingURL=TemplateRunOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateRunOperation.js","sourceRoot":"","sources":["../../src/operations/TemplateRunOperation.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAqB,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAEpG,OAAO,EAAE,oBAAoB,EAAiD,MAAM,+BAA+B,CAAC;A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C7D,cAAc,EACd,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EACxB,KAAK,CAAC,IAAI,IAAI,EAAE,EAChB,IAAI,CAAC,mCAAmC,CAC3C,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,wBAAwB,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,EAAE,CAAC;IACpF,CAAC;CACJ,CAAA;AAtCY,0BAA0B;IADtC,aAAa,CAAC,sBAAsB,EAAE,cAAc,CAAC;GACzC,0BAA0B,CAsCtC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/templates",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.43.0",
|
|
5
5
|
"description": "MemberJunction Templating Engine and Utilities - Used for any application that requires templating utility functionality. NOTE: this package does use Angular Universal for compilation but is not marked with the usual ng prefix because it is a server-side library and not used within Angular apps.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"typescript": "^5.9.3"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@memberjunction/core": "5.
|
|
23
|
-
"@memberjunction/templates-base-types": "5.
|
|
24
|
-
"@memberjunction/ai": "5.
|
|
25
|
-
"@memberjunction/ai-core-plus": "5.
|
|
26
|
-
"@memberjunction/aiengine": "5.
|
|
27
|
-
"@memberjunction/ai-provider-bundle": "5.
|
|
28
|
-
"@memberjunction/core-entities": "5.
|
|
29
|
-
"@memberjunction/global": "5.
|
|
22
|
+
"@memberjunction/core": "5.43.0",
|
|
23
|
+
"@memberjunction/templates-base-types": "5.43.0",
|
|
24
|
+
"@memberjunction/ai": "5.43.0",
|
|
25
|
+
"@memberjunction/ai-core-plus": "5.43.0",
|
|
26
|
+
"@memberjunction/aiengine": "5.43.0",
|
|
27
|
+
"@memberjunction/ai-provider-bundle": "5.43.0",
|
|
28
|
+
"@memberjunction/core-entities": "5.43.0",
|
|
29
|
+
"@memberjunction/global": "5.43.0",
|
|
30
30
|
"nunjucks": "3.2.4"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|