backend-manager 3.2.39 → 3.2.41

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.2.39",
3
+ "version": "3.2.41",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -55,12 +55,12 @@
55
55
  "moment": "^2.30.1",
56
56
  "nanoid": "^3.3.7",
57
57
  "node-fetch": "^2.7.0",
58
- "node-powertools": "^1.2.1",
58
+ "node-powertools": "^1.2.2",
59
59
  "npm-api": "^1.0.1",
60
60
  "paypal-server-api": "^1.0.3",
61
61
  "pushid": "^1.0.0",
62
- "resolve-account": "^1.0.12",
63
- "semver": "^7.5.4",
62
+ "resolve-account": "^1.0.13",
63
+ "semver": "^7.6.0",
64
64
  "shortid": "^2.2.16",
65
65
  "sizeitup": "^1.0.7",
66
66
  "uid-generator": "^2.0.0",
@@ -93,13 +93,30 @@ OpenAI.prototype.request = function (options) {
93
93
  // console.log('*** input!!!', input.content.slice(0, 50), input.path);
94
94
  // console.log('*** input.content', input.content.slice(0, 50));
95
95
  // console.log('*** input.path', input.path);
96
- _log('Loading', input);
96
+ // _log('Loading', input);
97
97
 
98
- return powertools.template(
99
- input.path ? jetpack.read(input.path) : input.content,
100
- input.settings,
101
- )
102
- .trim();
98
+ let content = '';
99
+
100
+ // Load content
101
+ if (input.path) {
102
+ if (!jetpack.exists(input.path)) {
103
+ return new Error(`Path ${input.path} not found`);
104
+ }
105
+
106
+ if (jetpack.isDirectory(input.path)) {
107
+ return new Error(`Path ${input.path} is a directory`);
108
+ }
109
+
110
+ try {
111
+ content = jetpack.read(input.path);
112
+ } catch (e) {
113
+ return new Error(`Error reading file ${input.path}: ${e}`);
114
+ }
115
+ } else {
116
+ content = input.content;
117
+ }
118
+
119
+ return powertools.template(content, input.settings).trim();
103
120
  }
104
121
 
105
122
  // Log
@@ -119,6 +136,15 @@ OpenAI.prototype.request = function (options) {
119
136
  _log('Message', message);
120
137
  _log('User', user);
121
138
 
139
+ // Check for errors
140
+ if (prompt instanceof Error) {
141
+ return reject(assistant.errorify(`Error loading prompt: ${prompt}`, {code: 400}));
142
+ }
143
+
144
+ if (message instanceof Error) {
145
+ return reject(assistant.errorify(`Error loading message: ${message}`, {code: 400}));
146
+ }
147
+
122
148
  function _request(mode, options) {
123
149
  return new Promise(async function(resolve, reject) {
124
150
  let resultPath = '';