From 11e8bcbed1b6690a92550a3a71f84d19143b561b Mon Sep 17 00:00:00 2001 From: Harshit Kumar <10harshitkumar@gmail.com> Date: Tue, 2 Jun 2026 01:19:13 +0530 Subject: [PATCH 1/5] feat(logic): decouple compilation for template logic Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com> --- src/TemplateArchiveProcessor.ts | 135 +++++++++++++------------- test/TemplateArchiveProcessor.test.ts | 59 ++++++++--- 2 files changed, 116 insertions(+), 78 deletions(-) diff --git a/src/TemplateArchiveProcessor.ts b/src/TemplateArchiveProcessor.ts index 5708205..8e0eb45 100644 --- a/src/TemplateArchiveProcessor.ts +++ b/src/TemplateArchiveProcessor.ts @@ -44,6 +44,7 @@ export type InitResponse = { */ export class TemplateArchiveProcessor { template: Template; + private compiledLogicCache?: Record; /** * Creates a template archive processor @@ -82,22 +83,22 @@ export class TemplateArchiveProcessor { } + /** - * Trigger the logic of a template - * @param {object} request - the request to send to the template logic - * @param {object} state - the current state of the template - * @param {[string]} currentTime - the current time, defaults to now - * @param {[number]} utcOffset - the UTC offset, defaults to zero - * @returns {Promise} the response and any events + * Compile the logic of a template + * @returns {Promise>} the compiled code for each typescript file */ - async trigger(data: any, request: any, state?: any, currentTime?: string, utcOffset?: number): Promise { + async compileLogic(): Promise> { + if (this.compiledLogicCache) { + return this.compiledLogicCache; + } + const logicManager = this.template.getLogicManager(); if(logicManager.getLanguage() === 'typescript') { const compiledCode:Record = {}; const tsFiles:Array