@cloudnux/cli 0.15.0 → 0.17.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.
@@ -308,6 +308,26 @@
308
308
  "message"
309
309
  ]
310
310
  },
311
+ "InvokeTrigger": {
312
+ "type": "object",
313
+ "properties": {
314
+ "options": {
315
+ "type": "object",
316
+ "properties": {
317
+ "name": {
318
+ "type": "string"
319
+ }
320
+ },
321
+ "required": [
322
+ "name"
323
+ ],
324
+ "additionalProperties": false
325
+ }
326
+ },
327
+ "required": [
328
+ "options"
329
+ ]
330
+ },
311
331
  "WebSocketTrigger": {
312
332
  "type": "object",
313
333
  "properties": {
@@ -350,7 +370,8 @@
350
370
  "http",
351
371
  "schedule",
352
372
  "event",
353
- "websocket"
373
+ "websocket",
374
+ "invoke"
354
375
  ]
355
376
  }
356
377
  },
@@ -402,6 +423,18 @@
402
423
  "then": {
403
424
  "$ref": "#/definitions/WebSocketTrigger"
404
425
  }
426
+ },
427
+ {
428
+ "if": {
429
+ "properties": {
430
+ "type": {
431
+ "const": "invoke"
432
+ }
433
+ }
434
+ },
435
+ "then": {
436
+ "$ref": "#/definitions/InvokeTrigger"
437
+ }
405
438
  }
406
439
  ],
407
440
  "required": [
@@ -3,6 +3,7 @@ import { awsCloudProvider } from "@cloudnux/aws-cloud-provider";
3
3
  import {
4
4
  httpHandler,
5
5
  eventBrokerHandler,
6
+ invokeHandler,
6
7
  scheduleHandler,
7
8
  websocketHandler,
8
9
  useCloudProvider,
@@ -48,6 +49,14 @@ router.websocket(
48
49
  (event, context) => {
49
50
  return websocketHandler(src["<%= entry.handler %>"],event,context, <%- JSON.stringify(entry.trigger, null, 2) %> );
50
51
  }
52
+ );
53
+ <%_ } _%>
54
+ <%_ if(entry.trigger.type.toLowerCase() === "invoke") { _%>
55
+ router.invoke(
56
+ "<%= entry.trigger.options.name %>",
57
+ (event, context) => {
58
+ return invokeHandler(src["<%= entry.handler %>"], event, context);
59
+ }
51
60
  );
52
61
  <%_ } _%>
53
62
  <%_ } _%>
@@ -5,6 +5,7 @@ import { queuesPlugin } from "@cloudnux/local-cloud-provider/queue-plugin";
5
5
  import { schedulerPlugin } from "@cloudnux/local-cloud-provider/schedule-plugin";
6
6
  import { devConsolePlugin } from "@cloudnux/local-cloud-provider/dev-console-plugin";
7
7
  import { websocketsPlugin } from "@cloudnux/local-cloud-provider/websocket-plugin";
8
+ import { invokesPlugin } from "@cloudnux/local-cloud-provider/invoke-plugin";
8
9
 
9
10
  // __dirname is injected by the esbuild banner and resolves to the workingDir/env folder
10
11
  process.env.DEV_CLOUD_LOCATION_PATH ??= path.join(__dirname, '.local-location');
@@ -21,6 +22,7 @@ router.register(queuesPlugin, { prefix: "queues", config: { persistence: { direc
21
22
  router.register(schedulerPlugin, { prefix: "schedules", config: { persistence: { directory: path.join(__dirname, 'scheduler-data') } } });
22
23
  router.register(devConsolePlugin, { prefix: 'console' });
23
24
  router.register(websocketsPlugin, { prefix: "websockets" });
25
+ router.register(invokesPlugin);
24
26
 
25
27
  <%_ for(const module of moduleNames){ _%>
26
28
  router.register(<%=module%>Entries, { prefix: "api" });
@@ -5,10 +5,11 @@
5
5
  - config: the full entrypoint object
6
6
  %>
7
7
  import { RouterInstance } from '@cloudnux/local-cloud-provider';
8
- import { httpHandler, scheduleHandler, eventBrokerHandler, websocketHandler } from "@cloudnux/cloud-sdk";
8
+ import { httpHandler, scheduleHandler, eventBrokerHandler, invokeHandler, websocketHandler } from "@cloudnux/cloud-sdk";
9
9
  import "@cloudnux/local-cloud-provider/schedule-plugin";
10
10
  import "@cloudnux/local-cloud-provider/queue-plugin";
11
11
  import "@cloudnux/local-cloud-provider/websocket-plugin";
12
+ import "@cloudnux/local-cloud-provider/invoke-plugin";
12
13
 
13
14
  import * as src from "<%= source %>";
14
15
 
@@ -18,7 +19,6 @@ async function entries(app: RouterInstance) {
18
19
  app.route({
19
20
  method: "<%= entry.trigger.options.method %>" as any,
20
21
  url: `/http<%= $$convertRouteParamstoFastifyRouteTemplate(entry.trigger.options.route) %>`,
21
- module : "<%=module%>",
22
22
  handler: async (request, reply) => {
23
23
  await httpHandler(src["<%= entry.handler %>"], request, reply);
24
24
  }
@@ -39,11 +39,15 @@ async function entries(app: RouterInstance) {
39
39
  "<%=module%>"
40
40
  );
41
41
  <%_ } _%>
42
+ <%_ if(entry.trigger.type === "invoke") { _%>
43
+ app.invokes.register("<%=module%>","<%= entry.trigger.options.name %>",
44
+ (envelop) => invokeHandler(src["<%= entry.handler %>"], envelop)
45
+ );
46
+ <%_ } _%>
42
47
  <%_ if(entry.trigger.type === "websocket") { _%>
43
48
  app.websockets.registerHandler({
44
49
  path: "<%= $$convertRouteParamstoFastifyRouteTemplate(entry.trigger.options.path) %>",
45
50
  event: "<%= entry.trigger.options.event %>",
46
- module: "<%=module%>",
47
51
  <%_ if(entry.trigger.options.route) { _%>
48
52
  route: "<%= entry.trigger.options.route %>",
49
53
  <%_ } _%>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudnux/cli",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",