@wundr.io/prompt-templates 1.0.3 → 1.0.12
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/package.json +8 -5
- package/dist/engine.d.ts +0 -206
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -506
- package/dist/engine.js.map +0 -1
- package/dist/helpers.d.ts +0 -201
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js +0 -566
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -56
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -102
- package/dist/index.js.map +0 -1
- package/dist/loader.d.ts +0 -129
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -415
- package/dist/loader.js.map +0 -1
- package/dist/macros.d.ts +0 -64
- package/dist/macros.d.ts.map +0 -1
- package/dist/macros.js +0 -620
- package/dist/macros.js.map +0 -1
- package/dist/types.d.ts +0 -443
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -62
- package/dist/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wundr.io/prompt-templates",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Jinja2-style dynamic prompt templating using Handlebars for the Wundr platform",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
8
11
|
"scripts": {
|
|
9
12
|
"build": "tsc",
|
|
10
13
|
"build:watch": "tsc --watch",
|
|
@@ -24,11 +27,11 @@
|
|
|
24
27
|
},
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"@types/node": "^20.9.0",
|
|
30
|
+
"eslint": "^8.57.1",
|
|
27
31
|
"jest": "^29.7.0",
|
|
32
|
+
"prettier": "^3.3.3",
|
|
28
33
|
"ts-jest": "^29.4.1",
|
|
29
|
-
"typescript": "^5.2.2"
|
|
30
|
-
"eslint": "^8.57.1",
|
|
31
|
-
"prettier": "^3.3.3"
|
|
34
|
+
"typescript": "^5.2.2"
|
|
32
35
|
},
|
|
33
36
|
"publishConfig": {
|
|
34
37
|
"access": "public"
|
package/dist/engine.d.ts
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @wundr/prompt-templates - PromptTemplateEngine for dynamic prompt rendering
|
|
3
|
-
*/
|
|
4
|
-
import Handlebars from 'handlebars';
|
|
5
|
-
import type { TemplateLoader } from './loader.js';
|
|
6
|
-
import type { PromptTemplateConfig, TemplateContext, RenderOptions, RenderResult, MacroDefinition, HelperFunction, EngineEvents, EngineEventHandler } from './types.js';
|
|
7
|
-
/**
|
|
8
|
-
* PromptTemplateEngine provides Jinja2-style templating using Handlebars
|
|
9
|
-
*/
|
|
10
|
-
export declare class PromptTemplateEngine {
|
|
11
|
-
private readonly handlebars;
|
|
12
|
-
private readonly templates;
|
|
13
|
-
private readonly templateConfigs;
|
|
14
|
-
private readonly macros;
|
|
15
|
-
private readonly customHelpers;
|
|
16
|
-
private readonly eventHandlers;
|
|
17
|
-
private readonly loader;
|
|
18
|
-
private readonly defaultOptions;
|
|
19
|
-
/**
|
|
20
|
-
* Create a new PromptTemplateEngine
|
|
21
|
-
*
|
|
22
|
-
* @param options - Default render options
|
|
23
|
-
* @param loaderBaseDir - Base directory for template loading
|
|
24
|
-
*/
|
|
25
|
-
constructor(options?: Partial<RenderOptions>, loaderBaseDir?: string);
|
|
26
|
-
/**
|
|
27
|
-
* Render a template string with the given context
|
|
28
|
-
*
|
|
29
|
-
* @param template - Template string or template ID
|
|
30
|
-
* @param context - Context data for rendering
|
|
31
|
-
* @param options - Render options
|
|
32
|
-
* @returns Render result with output or error
|
|
33
|
-
*/
|
|
34
|
-
render(template: string, context?: TemplateContext, options?: Partial<RenderOptions>): RenderResult;
|
|
35
|
-
/**
|
|
36
|
-
* Render a template asynchronously (useful for timeout support)
|
|
37
|
-
*
|
|
38
|
-
* @param template - Template string or template ID
|
|
39
|
-
* @param context - Context data for rendering
|
|
40
|
-
* @param options - Render options
|
|
41
|
-
* @returns Promise resolving to render result
|
|
42
|
-
*/
|
|
43
|
-
renderAsync(template: string, context?: TemplateContext, options?: Partial<RenderOptions>): Promise<RenderResult>;
|
|
44
|
-
/**
|
|
45
|
-
* Register a template configuration
|
|
46
|
-
*
|
|
47
|
-
* @param config - Template configuration
|
|
48
|
-
* @returns The engine instance for chaining
|
|
49
|
-
*/
|
|
50
|
-
registerTemplate(config: PromptTemplateConfig): this;
|
|
51
|
-
/**
|
|
52
|
-
* Load and register a template from file
|
|
53
|
-
*
|
|
54
|
-
* @param templatePath - Path to the template file
|
|
55
|
-
* @returns The engine instance for chaining
|
|
56
|
-
*/
|
|
57
|
-
loadTemplate(templatePath: string): this;
|
|
58
|
-
/**
|
|
59
|
-
* Load and register a template from file asynchronously
|
|
60
|
-
*
|
|
61
|
-
* @param templatePath - Path to the template file
|
|
62
|
-
* @returns Promise resolving to the engine instance
|
|
63
|
-
*/
|
|
64
|
-
loadTemplateAsync(templatePath: string): Promise<this>;
|
|
65
|
-
/**
|
|
66
|
-
* Register a custom macro
|
|
67
|
-
*
|
|
68
|
-
* @param macro - Macro definition
|
|
69
|
-
* @returns The engine instance for chaining
|
|
70
|
-
*/
|
|
71
|
-
registerMacro(macro: MacroDefinition): this;
|
|
72
|
-
/**
|
|
73
|
-
* Register multiple macros
|
|
74
|
-
*
|
|
75
|
-
* @param macros - Array of macro definitions
|
|
76
|
-
* @returns The engine instance for chaining
|
|
77
|
-
*/
|
|
78
|
-
registerMacros(macros: MacroDefinition[]): this;
|
|
79
|
-
/**
|
|
80
|
-
* Register a custom helper function
|
|
81
|
-
*
|
|
82
|
-
* @param name - Helper name
|
|
83
|
-
* @param fn - Helper function
|
|
84
|
-
* @param description - Optional description
|
|
85
|
-
* @returns The engine instance for chaining
|
|
86
|
-
*/
|
|
87
|
-
registerHelper(name: string, fn: HelperFunction, description?: string): this;
|
|
88
|
-
/**
|
|
89
|
-
* Unregister a helper
|
|
90
|
-
*
|
|
91
|
-
* @param name - Helper name to remove
|
|
92
|
-
* @returns The engine instance for chaining
|
|
93
|
-
*/
|
|
94
|
-
unregisterHelper(name: string): this;
|
|
95
|
-
/**
|
|
96
|
-
* Get a registered template configuration
|
|
97
|
-
*
|
|
98
|
-
* @param id - Template ID
|
|
99
|
-
* @returns Template configuration or undefined
|
|
100
|
-
*/
|
|
101
|
-
getTemplate(id: string): PromptTemplateConfig | undefined;
|
|
102
|
-
/**
|
|
103
|
-
* Get all registered template IDs
|
|
104
|
-
*
|
|
105
|
-
* @returns Array of template IDs
|
|
106
|
-
*/
|
|
107
|
-
getTemplateIds(): string[];
|
|
108
|
-
/**
|
|
109
|
-
* Get a registered macro
|
|
110
|
-
*
|
|
111
|
-
* @param name - Macro name
|
|
112
|
-
* @returns Macro definition or undefined
|
|
113
|
-
*/
|
|
114
|
-
getMacro(name: string): MacroDefinition | undefined;
|
|
115
|
-
/**
|
|
116
|
-
* Get all registered macro names
|
|
117
|
-
*
|
|
118
|
-
* @returns Array of macro names
|
|
119
|
-
*/
|
|
120
|
-
getMacroNames(): string[];
|
|
121
|
-
/**
|
|
122
|
-
* Get all registered helper names
|
|
123
|
-
*
|
|
124
|
-
* @returns Array of helper names
|
|
125
|
-
*/
|
|
126
|
-
getHelperNames(): string[];
|
|
127
|
-
/**
|
|
128
|
-
* Check if a template is registered
|
|
129
|
-
*
|
|
130
|
-
* @param id - Template ID
|
|
131
|
-
* @returns True if template is registered
|
|
132
|
-
*/
|
|
133
|
-
hasTemplate(id: string): boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Remove a registered template
|
|
136
|
-
*
|
|
137
|
-
* @param id - Template ID
|
|
138
|
-
* @returns True if template was removed
|
|
139
|
-
*/
|
|
140
|
-
removeTemplate(id: string): boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Clear all registered templates
|
|
143
|
-
*/
|
|
144
|
-
clearTemplates(): void;
|
|
145
|
-
/**
|
|
146
|
-
* Add an event listener
|
|
147
|
-
*
|
|
148
|
-
* @param event - Event name
|
|
149
|
-
* @param handler - Event handler function
|
|
150
|
-
* @returns Function to remove the listener
|
|
151
|
-
*/
|
|
152
|
-
on<K extends keyof EngineEvents>(event: K, handler: EngineEventHandler<K>): () => void;
|
|
153
|
-
/**
|
|
154
|
-
* Get the underlying Handlebars instance (for advanced usage)
|
|
155
|
-
*
|
|
156
|
-
* @returns Handlebars instance
|
|
157
|
-
*/
|
|
158
|
-
getHandlebars(): typeof Handlebars;
|
|
159
|
-
/**
|
|
160
|
-
* Get the template loader instance
|
|
161
|
-
*
|
|
162
|
-
* @returns Template loader
|
|
163
|
-
*/
|
|
164
|
-
getLoader(): TemplateLoader;
|
|
165
|
-
/**
|
|
166
|
-
* Register all built-in helpers
|
|
167
|
-
*/
|
|
168
|
-
private registerBuiltinHelpers;
|
|
169
|
-
/**
|
|
170
|
-
* Register built-in macros as partials
|
|
171
|
-
*/
|
|
172
|
-
private registerBuiltinMacros;
|
|
173
|
-
/**
|
|
174
|
-
* Register arithmetic helpers
|
|
175
|
-
*/
|
|
176
|
-
private registerArithmeticHelpers;
|
|
177
|
-
/**
|
|
178
|
-
* Register logical helpers
|
|
179
|
-
*/
|
|
180
|
-
private registerLogicalHelpers;
|
|
181
|
-
/**
|
|
182
|
-
* Get or compile a template
|
|
183
|
-
*/
|
|
184
|
-
private getOrCompileTemplate;
|
|
185
|
-
/**
|
|
186
|
-
* Prepare context with defaults and system values
|
|
187
|
-
*/
|
|
188
|
-
private prepareContext;
|
|
189
|
-
/**
|
|
190
|
-
* Create a template error from an exception
|
|
191
|
-
*/
|
|
192
|
-
private createTemplateError;
|
|
193
|
-
/**
|
|
194
|
-
* Emit an event to all registered handlers
|
|
195
|
-
*/
|
|
196
|
-
private emit;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Create a new PromptTemplateEngine instance
|
|
200
|
-
*
|
|
201
|
-
* @param options - Default render options
|
|
202
|
-
* @param loaderBaseDir - Base directory for template loading
|
|
203
|
-
* @returns Configured engine instance
|
|
204
|
-
*/
|
|
205
|
-
export declare function createEngine(options?: Partial<RenderOptions>, loaderBaseDir?: string): PromptTemplateEngine;
|
|
206
|
-
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,UAAmC,MAAM,YAAY,CAAC;AAM7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,YAAY,EAGZ,eAAe,EAEf,cAAc,EACd,YAAY,EACZ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAapB;;GAEG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CACd;IACZ,OAAO,CAAC,QAAQ,CAAC,eAAe,CACpB;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAClE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4C;IAC1E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAGhB;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0B;IAEzD;;;;;OAKG;gBACS,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,EAAE,MAAM;IAiBpE;;;;;;;OAOG;IACH,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,eAAmC,EAC5C,OAAO,CAAC,EAAE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