@celljs/lambda-adapter 3.0.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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/cell-api-gateway-mode.yml +2 -0
  4. package/cell-event-mode.yml +2 -0
  5. package/cell-remote.yml +1 -0
  6. package/cell-timer-mode.yml +2 -0
  7. package/cell.yml +0 -0
  8. package/lib/node/api-gateway-application-entry.d.ts +2 -0
  9. package/lib/node/api-gateway-application-entry.d.ts.map +1 -0
  10. package/lib/node/api-gateway-application-entry.js +48 -0
  11. package/lib/node/api-gateway-application-entry.js.map +1 -0
  12. package/lib/node/credentials-provider.d.ts +6 -0
  13. package/lib/node/credentials-provider.d.ts.map +1 -0
  14. package/lib/node/credentials-provider.js +44 -0
  15. package/lib/node/credentials-provider.js.map +1 -0
  16. package/lib/node/event-application-entry.d.ts +2 -0
  17. package/lib/node/event-application-entry.d.ts.map +1 -0
  18. package/lib/node/event-application-entry.js +38 -0
  19. package/lib/node/event-application-entry.js.map +1 -0
  20. package/lib/node/index.d.ts +3 -0
  21. package/lib/node/index.d.ts.map +1 -0
  22. package/lib/node/index.js +19 -0
  23. package/lib/node/index.js.map +1 -0
  24. package/lib/node/module.d.ts +4 -0
  25. package/lib/node/module.d.ts.map +1 -0
  26. package/lib/node/module.js +6 -0
  27. package/lib/node/module.js.map +1 -0
  28. package/lib/node/regin-provider.d.ts +5 -0
  29. package/lib/node/regin-provider.d.ts.map +1 -0
  30. package/lib/node/regin-provider.js +40 -0
  31. package/lib/node/regin-provider.js.map +1 -0
  32. package/lib/node/timer-application-entry.d.ts +2 -0
  33. package/lib/node/timer-application-entry.d.ts.map +1 -0
  34. package/lib/node/timer-application-entry.js +38 -0
  35. package/lib/node/timer-application-entry.js.map +1 -0
  36. package/lib/package.spec.d.ts +1 -0
  37. package/lib/package.spec.d.ts.map +1 -0
  38. package/lib/package.spec.js +4 -0
  39. package/lib/package.spec.js.map +1 -0
  40. package/package.json +50 -0
  41. package/src/node/api-gateway-application-entry.ts +37 -0
  42. package/src/node/credentials-provider.ts +20 -0
  43. package/src/node/event-application-entry.ts +24 -0
  44. package/src/node/index.ts +2 -0
  45. package/src/node/module.ts +4 -0
  46. package/src/node/regin-provider.ts +15 -0
  47. package/src/node/timer-application-entry.ts +25 -0
  48. package/src/package.spec.ts +4 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Cellbang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Cell - Lambda Adapter Component
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/api-gateway-application-entry
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/event-application-entry
@@ -0,0 +1 @@
1
+ mode: "${currentMode|toObjects[.item in [ 'api-gateway', 'timer', 'event']]|suffix('-mode') || 'api-gateway-mode'}"
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/timer-application-entry
package/cell.yml ADDED
File without changes
@@ -0,0 +1,2 @@
1
+ export declare function handler(event: string, context: any): Promise<any>;
2
+ //# sourceMappingURL=api-gateway-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-gateway-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":"AA+BA,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,gBAKxD"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.handler = void 0;
13
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
14
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
15
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
16
+ const dispatcher_protocol_1 = require("@celljs/web/lib/node/dispatcher/dispatcher-protocol");
17
+ const context_1 = require("@celljs/web/lib/node/context");
18
+ const event_protocol_1 = require("@celljs/faas-adapter/lib/node/event/event-protocol");
19
+ const utils_1 = require("@celljs/faas-adapter/lib/node/utils");
20
+ const express = require("express");
21
+ const createProxy = require('@vendia/serverless-express');
22
+ const app = express();
23
+ const proxy = createProxy({ app });
24
+ let listeners;
25
+ function start() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const c = yield dynamic_container_1.container;
28
+ container_provider_1.ContainerProvider.set(c);
29
+ app.all('*', (req, res) => __awaiter(this, void 0, void 0, function* () {
30
+ const dispatcher = c.get(dispatcher_protocol_1.Dispatcher);
31
+ const httpContext = new context_1.Context(req, res);
32
+ context_1.Context.run(() => dispatcher.dispatch(httpContext));
33
+ }));
34
+ listeners = c.getAll(event_protocol_1.FaaSEventListener);
35
+ return c.get(application_protocol_1.Application).start();
36
+ });
37
+ }
38
+ const startPromise = start();
39
+ function handler(event, context) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ yield startPromise;
42
+ yield Promise.all(listeners.map(l => l.onTrigger(event)));
43
+ context.callbackWaitsForEmptyEventLoop = utils_1.FaaSUtils.getCallbackWaitsForEmptyEventLoop();
44
+ return proxy(event, context);
45
+ });
46
+ }
47
+ exports.handler = handler;
48
+ //# sourceMappingURL=api-gateway-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-gateway-application-entry.js","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,6FAAiF;AACjF,0DAAuD;AACvD,uFAAuF;AACvF,+DAAgE;AAChE,mCAAmC;AACnC,MAAM,WAAW,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAE1D,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AAEtB,MAAM,KAAK,GAAG,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AAEnC,IAAI,SAAyC,CAAC;AAE9C,SAAe,KAAK;;QAChB,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;QAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAO,GAAQ,EAAE,GAAQ,EAAE,EAAE;YACtC,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAsB,gCAAU,CAAC,CAAC;YAC1D,MAAM,WAAW,GAAG,IAAI,iBAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAC1C,iBAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;QACxD,CAAC,CAAA,CAAC,CAAC;QACH,SAAS,GAAG,CAAC,CAAC,MAAM,CAA+B,kCAAiB,CAAC,CAAC;QAEtE,OAAO,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;IACnD,CAAC;CAAA;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAE7B,SAAsB,OAAO,CAAC,KAAa,EAAE,OAAY;;QACrD,MAAM,YAAY,CAAC;QACnB,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1D,OAAO,CAAC,8BAA8B,GAAG,iBAAS,CAAC,iCAAiC,EAAE,CAAC;QACvF,OAAO,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;CAAA;AALD,0BAKC"}
@@ -0,0 +1,6 @@
1
+ import { DefaultCredentialsProvider } from '@celljs/cloud/lib/node';
2
+ import { Credentials } from '@celljs/cloud';
3
+ export declare class FaaSCredentialsProvider extends DefaultCredentialsProvider {
4
+ provide(): Promise<Credentials | undefined>;
5
+ }
6
+ //# sourceMappingURL=credentials-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-provider.d.ts","sourceRoot":"","sources":["../../src/node/credentials-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAuB,MAAM,eAAe,CAAC;AAEjE,qBACa,uBAAwB,SAAQ,0BAA0B;IAEpD,OAAO,IAAI,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;CAY7D"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.FaaSCredentialsProvider = void 0;
19
+ const node_1 = require("@celljs/cloud/lib/node");
20
+ const core_1 = require("@celljs/core");
21
+ const cloud_1 = require("@celljs/cloud");
22
+ let FaaSCredentialsProvider = class FaaSCredentialsProvider extends node_1.DefaultCredentialsProvider {
23
+ provide() {
24
+ const _super = Object.create(null, {
25
+ provide: { get: () => super.provide }
26
+ });
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const credentials = yield _super.provide.call(this);
29
+ if (credentials) {
30
+ return credentials;
31
+ }
32
+ return {
33
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
34
+ accessKeySecret: process.env.AWS_SECRET_ACCESS_KEY,
35
+ token: process.env.AWS_SESSION_TOKEN
36
+ };
37
+ });
38
+ }
39
+ };
40
+ FaaSCredentialsProvider = __decorate([
41
+ (0, core_1.Component)({ id: cloud_1.CredentialsProvider, rebind: true })
42
+ ], FaaSCredentialsProvider);
43
+ exports.FaaSCredentialsProvider = FaaSCredentialsProvider;
44
+ //# sourceMappingURL=credentials-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-provider.js","sourceRoot":"","sources":["../../src/node/credentials-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iDAAoE;AACpE,uCAAyC;AACzC,yCAAiE;AAG1D,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,iCAA0B;IAEpD,OAAO;;;;;YAClB,MAAM,WAAW,GAAG,MAAM,OAAM,OAAO,WAAE,CAAC;YAC1C,IAAI,WAAW,EAAE;gBACb,OAAO,WAAW,CAAC;aACtB;YACD,OAAO;gBACH,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAkB;gBAC3C,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAsB;gBACnD,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;aACvC,CAAC;QACN,CAAC;KAAA;CAEJ,CAAA;AAdY,uBAAuB;IADnC,IAAA,gBAAS,EAAC,EAAE,EAAE,EAAE,2BAAmB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACxC,uBAAuB,CAcnC;AAdY,0DAAuB"}
@@ -0,0 +1,2 @@
1
+ export declare function handler(event: string, context: any, callback: any): Promise<any>;
2
+ //# sourceMappingURL=event-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/event-application-entry.ts"],"names":[],"mappings":"AAiBA,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,gBAMvE"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.handler = void 0;
13
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
14
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
15
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
16
+ const event_protocol_1 = require("@celljs/faas-adapter/lib/node/event/event-protocol");
17
+ const utils_1 = require("@celljs/faas-adapter/lib/node/utils");
18
+ let listeners;
19
+ function start() {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const c = yield dynamic_container_1.container;
22
+ container_provider_1.ContainerProvider.set(c);
23
+ yield c.get(application_protocol_1.Application).start();
24
+ listeners = c.getAll(event_protocol_1.FaaSEventListener);
25
+ });
26
+ }
27
+ const startPromise = start();
28
+ function handler(event, context, callback) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ yield startPromise;
31
+ context.callbackWaitsForEmptyEventLoop = utils_1.FaaSUtils.getCallbackWaitsForEmptyEventLoop();
32
+ let result = yield Promise.all(listeners.map(l => l.onTrigger(event)));
33
+ result = result.filter(item => !!item);
34
+ return result.length === 1 ? result[0] : result;
35
+ });
36
+ }
37
+ exports.handler = handler;
38
+ //# sourceMappingURL=event-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-application-entry.js","sourceRoot":"","sources":["../../src/node/event-application-entry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,uFAAuF;AACvF,+DAAgE;AAEhE,IAAI,SAAwC,CAAC;AAE7C,SAAe,KAAK;;QAChB,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;QAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;QAC9C,SAAS,GAAG,CAAC,CAAC,MAAM,CAA8B,kCAAiB,CAAC,CAAC;IACzE,CAAC;CAAA;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAE7B,SAAsB,OAAO,CAAC,KAAa,EAAE,OAAY,EAAE,QAAa;;QACpE,MAAM,YAAY,CAAC;QACnB,OAAO,CAAC,8BAA8B,GAAG,iBAAS,CAAC,iCAAiC,EAAE,CAAC;QACvF,IAAI,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACpD,CAAC;CAAA;AAND,0BAMC"}
@@ -0,0 +1,3 @@
1
+ export * from './credentials-provider';
2
+ export * from './regin-provider';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./credentials-provider"), exports);
18
+ __exportStar(require("./regin-provider"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,mDAAiC"}
@@ -0,0 +1,4 @@
1
+ import './index';
2
+ declare const _default: import("inversify/lib/interfaces/interfaces").interfaces.ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,CAAC;;AAEjB,wBAA0B"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@celljs/core");
4
+ require("./index");
5
+ exports.default = (0, core_1.autoBind)();
6
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AACxC,mBAAiB;AAEjB,kBAAe,IAAA,eAAQ,GAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { DefaultRegionProvider } from '@celljs/cloud/lib/node';
2
+ export declare class FaaSRegionProvider extends DefaultRegionProvider {
3
+ provide(): Promise<string | undefined>;
4
+ }
5
+ //# sourceMappingURL=regin-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regin-provider.d.ts","sourceRoot":"","sources":["../../src/node/regin-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,qBACa,kBAAmB,SAAQ,qBAAqB;IAE1C,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAOxD"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.FaaSRegionProvider = void 0;
19
+ const node_1 = require("@celljs/cloud/lib/node");
20
+ const core_1 = require("@celljs/core");
21
+ const cloud_1 = require("@celljs/cloud");
22
+ let FaaSRegionProvider = class FaaSRegionProvider extends node_1.DefaultRegionProvider {
23
+ provide() {
24
+ const _super = Object.create(null, {
25
+ provide: { get: () => super.provide }
26
+ });
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const region = yield _super.provide.call(this);
29
+ if (region) {
30
+ return region;
31
+ }
32
+ return process.env.AWS_REGION;
33
+ });
34
+ }
35
+ };
36
+ FaaSRegionProvider = __decorate([
37
+ (0, core_1.Component)({ id: cloud_1.RegionProvider, rebind: true })
38
+ ], FaaSRegionProvider);
39
+ exports.FaaSRegionProvider = FaaSRegionProvider;
40
+ //# sourceMappingURL=regin-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regin-provider.js","sourceRoot":"","sources":["../../src/node/regin-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iDAA+D;AAC/D,uCAAyC;AACzC,yCAA+C;AAGxC,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,4BAAqB;IAE1C,OAAO;;;;;YAClB,MAAM,MAAM,GAAG,MAAM,OAAM,OAAO,WAAE,CAAC;YACrC,IAAI,MAAM,EAAE;gBACR,OAAO,MAAM,CAAC;aACjB;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;QAClC,CAAC;KAAA;CACJ,CAAA;AATY,kBAAkB;IAD9B,IAAA,gBAAS,EAAC,EAAE,EAAE,EAAE,sBAAc,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACnC,kBAAkB,CAS9B;AATY,gDAAkB"}
@@ -0,0 +1,2 @@
1
+ export declare function handler(event: string, context: any): Promise<void>;
2
+ //# sourceMappingURL=timer-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timer-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/timer-application-entry.ts"],"names":[],"mappings":"AAmBA,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,iBAIxD"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.handler = void 0;
13
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
14
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
15
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
16
+ const timer_protocol_1 = require("@celljs/faas-adapter/lib/node/timer/timer-protocol");
17
+ const event_protocol_1 = require("@celljs/faas-adapter/lib/node/event/event-protocol");
18
+ let clock;
19
+ let listeners;
20
+ function start() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const c = yield dynamic_container_1.container;
23
+ container_provider_1.ContainerProvider.set(c);
24
+ yield c.get(application_protocol_1.Application).start();
25
+ clock = c.get(timer_protocol_1.Clock);
26
+ listeners = c.getAll(event_protocol_1.FaaSEventListener);
27
+ });
28
+ }
29
+ const startPromise = start();
30
+ function handler(event, context) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ yield startPromise;
33
+ yield Promise.all(listeners.map(l => l.onTrigger(event)));
34
+ return clock.tick();
35
+ });
36
+ }
37
+ exports.handler = handler;
38
+ //# sourceMappingURL=timer-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timer-application-entry.js","sourceRoot":"","sources":["../../src/node/timer-application-entry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,uFAA2E;AAC3E,uFAAuF;AAEvF,IAAI,KAAY,CAAC;AACjB,IAAI,SAAyC,CAAC;AAE9C,SAAe,KAAK;;QAChB,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;QAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;QAC9C,KAAK,GAAG,CAAC,CAAC,GAAG,CAAQ,sBAAK,CAAC,CAAC;QAC5B,SAAS,GAAG,CAAC,CAAC,MAAM,CAA+B,kCAAiB,CAAC,CAAC;IAC1E,CAAC;CAAA;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAE7B,SAAsB,OAAO,CAAC,KAAa,EAAE,OAAY;;QACrD,MAAM,YAAY,CAAC;QACnB,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1D,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;CAAA;AAJD,0BAIC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=package.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ describe('lambda adapter package', () => {
2
+ it('support code coverage statistics', () => { });
3
+ });
4
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IAEpC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@celljs/lambda-adapter",
3
+ "version": "3.0.0",
4
+ "description": "",
5
+ "main": "lib/node/index.js",
6
+ "typings": "lib/node/index.d.ts",
7
+ "dependencies": {
8
+ "@celljs/cloud": "3.0.0",
9
+ "@celljs/core": "3.0.0",
10
+ "@celljs/faas-adapter": "3.0.0",
11
+ "@celljs/web": "3.0.0",
12
+ "@vendia/serverless-express": "^4.5.2",
13
+ "express": "^4.17.1"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "keywords": [
19
+ "cell-component"
20
+ ],
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/cellbang/cell.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/cellbang/cell/issues"
28
+ },
29
+ "homepage": "https://github.com/cellbang/cell",
30
+ "files": [
31
+ "lib",
32
+ "src",
33
+ "cell.yml",
34
+ "cell-remote.yml",
35
+ "cell-api-gateway-mode.yml",
36
+ "cell-timer-mode.yml",
37
+ "cell-event-mode.yml"
38
+ ],
39
+ "scripts": {
40
+ "lint": "cell-component lint",
41
+ "build": "cell-component build",
42
+ "watch": "cell-component watch",
43
+ "clean": "cell-component clean",
44
+ "test": "cell-component test:js"
45
+ },
46
+ "devDependencies": {
47
+ "@celljs/component": "3.0.0"
48
+ },
49
+ "gitHead": "c0ef8d269e33a795406bcbb240cac4b845c6c24c"
50
+ }
@@ -0,0 +1,37 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { Dispatcher } from '@celljs/web/lib/node/dispatcher/dispatcher-protocol';
5
+ import { Context } from '@celljs/web/lib/node/context';
6
+ import { FaaSEventListener } from '@celljs/faas-adapter/lib/node/event/event-protocol';
7
+ import { FaaSUtils } from '@celljs/faas-adapter/lib/node/utils';
8
+ import * as express from 'express';
9
+ const createProxy = require('@vendia/serverless-express');
10
+
11
+ const app = express();
12
+
13
+ const proxy = createProxy({ app });
14
+
15
+ let listeners: FaaSEventListener<any, void>[];
16
+
17
+ async function start() {
18
+ const c = await container;
19
+ ContainerProvider.set(c);
20
+ app.all('*', async (req: any, res: any) => {
21
+ const dispatcher = c.get<Dispatcher<Context>>(Dispatcher);
22
+ const httpContext = new Context(req, res);
23
+ Context.run(() => dispatcher.dispatch(httpContext));
24
+ });
25
+ listeners = c.getAll<FaaSEventListener<any, void>>(FaaSEventListener);
26
+
27
+ return c.get<Application>(Application).start();
28
+ }
29
+
30
+ const startPromise = start();
31
+
32
+ export async function handler(event: string, context: any) {
33
+ await startPromise;
34
+ await Promise.all(listeners.map(l => l.onTrigger(event)));
35
+ context.callbackWaitsForEmptyEventLoop = FaaSUtils.getCallbackWaitsForEmptyEventLoop();
36
+ return proxy(event, context);
37
+ }
@@ -0,0 +1,20 @@
1
+ import { DefaultCredentialsProvider } from '@celljs/cloud/lib/node';
2
+ import { Component } from '@celljs/core';
3
+ import { Credentials, CredentialsProvider } from '@celljs/cloud';
4
+
5
+ @Component({ id: CredentialsProvider, rebind: true })
6
+ export class FaaSCredentialsProvider extends DefaultCredentialsProvider {
7
+
8
+ override async provide(): Promise<Credentials | undefined> {
9
+ const credentials = await super.provide();
10
+ if (credentials) {
11
+ return credentials;
12
+ }
13
+ return {
14
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
15
+ accessKeySecret: process.env.AWS_SECRET_ACCESS_KEY!,
16
+ token: process.env.AWS_SESSION_TOKEN
17
+ };
18
+ }
19
+
20
+ }
@@ -0,0 +1,24 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { FaaSEventListener } from '@celljs/faas-adapter/lib/node/event/event-protocol';
5
+ import { FaaSUtils } from '@celljs/faas-adapter/lib/node/utils';
6
+
7
+ let listeners: FaaSEventListener<any, any>[];
8
+
9
+ async function start() {
10
+ const c = await container;
11
+ ContainerProvider.set(c);
12
+ await c.get<Application>(Application).start();
13
+ listeners = c.getAll<FaaSEventListener<any, any>>(FaaSEventListener);
14
+ }
15
+
16
+ const startPromise = start();
17
+
18
+ export async function handler(event: string, context: any, callback: any) {
19
+ await startPromise;
20
+ context.callbackWaitsForEmptyEventLoop = FaaSUtils.getCallbackWaitsForEmptyEventLoop();
21
+ let result = await Promise.all(listeners.map(l => l.onTrigger(event)));
22
+ result = result.filter(item => !!item);
23
+ return result.length === 1 ? result[0] : result;
24
+ }
@@ -0,0 +1,2 @@
1
+ export * from './credentials-provider';
2
+ export * from './regin-provider';
@@ -0,0 +1,4 @@
1
+ import { autoBind } from '@celljs/core';
2
+ import './index';
3
+
4
+ export default autoBind();
@@ -0,0 +1,15 @@
1
+ import { DefaultRegionProvider } from '@celljs/cloud/lib/node';
2
+ import { Component } from '@celljs/core';
3
+ import { RegionProvider } from '@celljs/cloud';
4
+
5
+ @Component({ id: RegionProvider, rebind: true })
6
+ export class FaaSRegionProvider extends DefaultRegionProvider {
7
+
8
+ override async provide(): Promise<string | undefined> {
9
+ const region = await super.provide();
10
+ if (region) {
11
+ return region;
12
+ }
13
+ return process.env.AWS_REGION;
14
+ }
15
+ }
@@ -0,0 +1,25 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { Clock } from '@celljs/faas-adapter/lib/node/timer/timer-protocol';
5
+ import { FaaSEventListener } from '@celljs/faas-adapter/lib/node/event/event-protocol';
6
+
7
+ let clock: Clock;
8
+ let listeners: FaaSEventListener<any, void>[];
9
+
10
+ async function start() {
11
+ const c = await container;
12
+ ContainerProvider.set(c);
13
+ await c.get<Application>(Application).start();
14
+ clock = c.get<Clock>(Clock);
15
+ listeners = c.getAll<FaaSEventListener<any, void>>(FaaSEventListener);
16
+ }
17
+
18
+ const startPromise = start();
19
+
20
+ export async function handler(event: string, context: any) {
21
+ await startPromise;
22
+ await Promise.all(listeners.map(l => l.onTrigger(event)));
23
+ return clock.tick();
24
+ }
25
+
@@ -0,0 +1,4 @@
1
+ describe('lambda adapter package', () => {
2
+
3
+ it('support code coverage statistics', () => {});
4
+ });