biz-email-builder-shared 1.6.50 → 1.6.53

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.
@@ -4,7 +4,7 @@ interface IPromptOptions {
4
4
  apiKey: string;
5
5
  parseJSON: boolean;
6
6
  }
7
- export declare function getMessage(promptConfig: IMessageSchema, payload: Record<string, any>): string;
7
+ export declare function getMessage(promptConfig: IMessageSchema, payload?: Record<string, any>): string;
8
8
  export declare const getPromptResult: (retryCount: number, options: IPromptOptions, userMessage: IMessageSchema, systemMessage: IMessageSchema, payload: Record<string, any>) => Promise<string | object>;
9
9
  export {};
10
10
  //# sourceMappingURL=getPromptResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPromptResult.d.ts","sourceRoot":"","sources":["../../src/utilities/getPromptResult.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACpB;AAOD,wBAAgB,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAO7F;AAED,eAAO,MAAM,eAAe,eACd,MAAM,WACT,cAAc,eACV,cAAc,iBACZ,cAAc,WACpB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC3B,OAAO,CAAC,MAAM,GAAG,MAAM,CA4DzB,CAAC"}
1
+ {"version":3,"file":"getPromptResult.d.ts","sourceRoot":"","sources":["../../src/utilities/getPromptResult.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACpB;AAOD,wBAAgB,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,MAAM,CASlG;AAED,eAAO,MAAM,eAAe,eACd,MAAM,WACT,cAAc,eACV,cAAc,iBACZ,cAAc,WACpB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC3B,OAAO,CAAC,MAAM,GAAG,MAAM,CA4DzB,CAAC"}
@@ -13,13 +13,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.getPromptResult = void 0;
14
14
  exports.getMessage = getMessage;
15
15
  const openai_1 = __importDefault(require("openai"));
16
- function getMessage(promptConfig, payload) {
16
+ function getMessage(promptConfig, payload = {}) {
17
17
  if (!promptConfig)
18
18
  return "";
19
19
  const { keys = [], message = "" } = promptConfig;
20
20
  return keys.reduce((msg, key) => {
21
21
  var _a;
22
- return msg.replace(`\$\{${key}\}`, (_a = payload[key]) !== null && _a !== void 0 ? _a : "");
22
+ const value = (_a = payload === null || payload === void 0 ? void 0 : payload[key]) !== null && _a !== void 0 ? _a : ""; // safe access
23
+ return msg.replace(`\$\{${key}\}`, String(value));
23
24
  }, message).trim();
24
25
  }
25
26
  const getPromptResult = async (retryCount, options, userMessage, systemMessage, payload) => {
@@ -78,7 +79,7 @@ const getPromptResult = async (retryCount, options, userMessage, systemMessage,
78
79
  if (retryCount <= 1) {
79
80
  throw new Error((error === null || error === void 0 ? void 0 : error.status) ? `OPENAI - ${error.status}` : error.message || "Unknown OpenAI error");
80
81
  }
81
- return (0, exports.getPromptResult)(retryCount - 1, options, userMessage, systemMessage, payload);
82
+ return (0, exports.getPromptResult)(retryCount - 1, options, userMessage, systemMessage, payload !== null && payload !== void 0 ? payload : {});
82
83
  }
83
84
  };
84
85
  exports.getPromptResult = getPromptResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz-email-builder-shared",
3
- "version": "1.6.50",
3
+ "version": "1.6.53",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [