diff --git a/plugins/get-current-time/jerapah-plugin.json b/plugins/get-current-time/jerapah-plugin.json new file mode 100644 index 0000000..35294d2 --- /dev/null +++ b/plugins/get-current-time/jerapah-plugin.json @@ -0,0 +1,8 @@ +{ + "id": "get-current-time", + "name": "Get current time", + "version": "0.1.0", + "jerapah": ">=0.1.0 <1.0.0", + "main": "script.js", + "description": "Example user plugin: return the current time as output.datetime" +} diff --git a/plugins/get-current-time/package.json b/plugins/get-current-time/package.json new file mode 100644 index 0000000..2ca2114 --- /dev/null +++ b/plugins/get-current-time/package.json @@ -0,0 +1,7 @@ +{ + "name": "jflow-plugin-get-current-time", + "version": "0.1.0", + "private": true, + "type": "module", + "description": "Example JerapahFlow plugin (no npm dependencies)" +} diff --git a/plugins/get-current-time/script.js b/plugins/get-current-time/script.js new file mode 100644 index 0000000..ad34931 --- /dev/null +++ b/plugins/get-current-time/script.js @@ -0,0 +1,34 @@ +function passContext(ctx) { + if (ctx?.context != null && typeof ctx.context === "object" && !Array.isArray(ctx.context)) { + return { ...ctx.context }; + } + return {}; +} + +function getCurrentTime(ctx) { + const output = { + datetime: new Date().toISOString(), + processId: "1234", + }; + return { output, context: { ...passContext(ctx), ...output } }; +} + +getCurrentTime.meta = { + description: "Return the current time as output.datetime", + config: {}, + input: {}, + output: { + datetime: { type: "string", description: "ISO timestamp" }, + processId: { type: "string" }, + }, + context: { + datetime: { type: "string", description: "ISO timestamp" }, + processId: { type: "string" }, + }, + example: { + data: {}, + config: {}, + }, +}; + +export default getCurrentTime;