@faasjs/func 6.1.0 → 6.2.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.cjs +15 -9
- package/dist/index.mjs +15 -9
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@ var RunHandler = class {
|
|
|
19
19
|
if (error) reject(error);
|
|
20
20
|
else resolve(result);
|
|
21
21
|
};
|
|
22
|
-
Promise.resolve(data.handler(data)).then(resolve).catch(reject);
|
|
22
|
+
Promise.resolve(data.handler?.(data)).then(resolve).catch(reject);
|
|
23
23
|
});
|
|
24
24
|
} catch (error) {
|
|
25
25
|
data.logger.error(error);
|
|
@@ -59,7 +59,13 @@ var Func = class {
|
|
|
59
59
|
plugins: /* @__PURE__ */ Object.create(null)
|
|
60
60
|
};
|
|
61
61
|
try {
|
|
62
|
-
|
|
62
|
+
const stack = new Error().stack;
|
|
63
|
+
if (stack) {
|
|
64
|
+
const match = stack.split("\n").find((s) => /[^/]\.func\.ts/.test(s))?.match(/\((.*\.func\.ts).*\)/);
|
|
65
|
+
if (match) {
|
|
66
|
+
this.filename = match[1];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
63
69
|
} catch (_) {
|
|
64
70
|
}
|
|
65
71
|
}
|
|
@@ -157,7 +163,7 @@ var Func = class {
|
|
|
157
163
|
context.callbackWaitsForEmptyEventLoop = false;
|
|
158
164
|
const logger$1 = new logger.Logger(context.request_id);
|
|
159
165
|
const data = {
|
|
160
|
-
event,
|
|
166
|
+
event: event ?? /* @__PURE__ */ Object.create(null),
|
|
161
167
|
context,
|
|
162
168
|
callback,
|
|
163
169
|
response: undefined,
|
|
@@ -180,13 +186,13 @@ function usePlugin(plugin) {
|
|
|
180
186
|
if (!plugins.find((p) => p.name === plugin.name)) plugins.push(plugin);
|
|
181
187
|
if (!plugin.mount)
|
|
182
188
|
plugin.mount = async (data) => {
|
|
183
|
-
|
|
184
|
-
if (!
|
|
185
|
-
if (!
|
|
186
|
-
if (!
|
|
187
|
-
if (!
|
|
189
|
+
const parsedData = data || /* @__PURE__ */ Object.create(null);
|
|
190
|
+
if (!parsedData.config) parsedData.config = /* @__PURE__ */ Object.create(null);
|
|
191
|
+
if (!parsedData.context) parsedData.context = /* @__PURE__ */ Object.create(null);
|
|
192
|
+
if (!parsedData.event) parsedData.event = /* @__PURE__ */ Object.create(null);
|
|
193
|
+
if (!parsedData.logger) parsedData.logger = new logger.Logger(plugin.name);
|
|
188
194
|
if (plugin.onMount)
|
|
189
|
-
await plugin.onMount(
|
|
195
|
+
await plugin.onMount(parsedData, async () => Promise.resolve());
|
|
190
196
|
return plugin;
|
|
191
197
|
};
|
|
192
198
|
return plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var RunHandler = class {
|
|
|
17
17
|
if (error) reject(error);
|
|
18
18
|
else resolve(result);
|
|
19
19
|
};
|
|
20
|
-
Promise.resolve(data.handler(data)).then(resolve).catch(reject);
|
|
20
|
+
Promise.resolve(data.handler?.(data)).then(resolve).catch(reject);
|
|
21
21
|
});
|
|
22
22
|
} catch (error) {
|
|
23
23
|
data.logger.error(error);
|
|
@@ -57,7 +57,13 @@ var Func = class {
|
|
|
57
57
|
plugins: /* @__PURE__ */ Object.create(null)
|
|
58
58
|
};
|
|
59
59
|
try {
|
|
60
|
-
|
|
60
|
+
const stack = new Error().stack;
|
|
61
|
+
if (stack) {
|
|
62
|
+
const match = stack.split("\n").find((s) => /[^/]\.func\.ts/.test(s))?.match(/\((.*\.func\.ts).*\)/);
|
|
63
|
+
if (match) {
|
|
64
|
+
this.filename = match[1];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
61
67
|
} catch (_) {
|
|
62
68
|
}
|
|
63
69
|
}
|
|
@@ -155,7 +161,7 @@ var Func = class {
|
|
|
155
161
|
context.callbackWaitsForEmptyEventLoop = false;
|
|
156
162
|
const logger = new Logger(context.request_id);
|
|
157
163
|
const data = {
|
|
158
|
-
event,
|
|
164
|
+
event: event ?? /* @__PURE__ */ Object.create(null),
|
|
159
165
|
context,
|
|
160
166
|
callback,
|
|
161
167
|
response: undefined,
|
|
@@ -178,13 +184,13 @@ function usePlugin(plugin) {
|
|
|
178
184
|
if (!plugins.find((p) => p.name === plugin.name)) plugins.push(plugin);
|
|
179
185
|
if (!plugin.mount)
|
|
180
186
|
plugin.mount = async (data) => {
|
|
181
|
-
|
|
182
|
-
if (!
|
|
183
|
-
if (!
|
|
184
|
-
if (!
|
|
185
|
-
if (!
|
|
187
|
+
const parsedData = data || /* @__PURE__ */ Object.create(null);
|
|
188
|
+
if (!parsedData.config) parsedData.config = /* @__PURE__ */ Object.create(null);
|
|
189
|
+
if (!parsedData.context) parsedData.context = /* @__PURE__ */ Object.create(null);
|
|
190
|
+
if (!parsedData.event) parsedData.event = /* @__PURE__ */ Object.create(null);
|
|
191
|
+
if (!parsedData.logger) parsedData.logger = new Logger(plugin.name);
|
|
186
192
|
if (plugin.onMount)
|
|
187
|
-
await plugin.onMount(
|
|
193
|
+
await plugin.onMount(parsedData, async () => Promise.resolve());
|
|
188
194
|
return plugin;
|
|
189
195
|
};
|
|
190
196
|
return plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/func",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@faasjs/deep_merge": "6.
|
|
34
|
-
"@faasjs/logger": "6.
|
|
33
|
+
"@faasjs/deep_merge": "6.2.0",
|
|
34
|
+
"@faasjs/logger": "6.2.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@faasjs/deep_merge": "6.
|
|
38
|
-
"@faasjs/logger": "6.
|
|
37
|
+
"@faasjs/deep_merge": "6.2.0",
|
|
38
|
+
"@faasjs/logger": "6.2.0"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=22.0.0",
|