@alanszp/serverless 7.0.0 → 7.10.2

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.
@@ -0,0 +1 @@
1
+ export * from "./splitCouldNotLoadError";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./splitCouldNotLoadError"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyC"}
@@ -0,0 +1,3 @@
1
+ export declare class SplitCouldNotLoadError extends Error {
2
+ constructor();
3
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SplitCouldNotLoadError = void 0;
4
+ class SplitCouldNotLoadError extends Error {
5
+ constructor() {
6
+ super("Split client couldn't load");
7
+ }
8
+ }
9
+ exports.SplitCouldNotLoadError = SplitCouldNotLoadError;
10
+ //# sourceMappingURL=splitCouldNotLoadError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitCouldNotLoadError.js","sourceRoot":"","sources":["../../src/errors/splitCouldNotLoadError.ts"],"names":[],"mappings":";;;AAAA,MAAa,sBAAuB,SAAQ,KAAK;IAC/C;QACE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACtC,CAAC;CACF;AAJD,wDAIC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./middlewares";
2
+ export * from "./errors";
2
3
  export * from "./handlers";
3
4
  export * from "./types";
package/dist/index.js CHANGED
@@ -10,7 +10,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ // Adding dummy code to deploy package
13
14
  __exportStar(require("./middlewares"), exports);
15
+ __exportStar(require("./errors"), exports);
14
16
  __exportStar(require("./handlers"), exports);
15
17
  __exportStar(require("./types"), exports);
16
18
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA8B;AAC9B,6CAA2B;AAC3B,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAsC;AACtC,gDAA8B;AAC9B,2CAAyB;AACzB,6CAA2B;AAC3B,0CAAwB"}
@@ -1 +1,2 @@
1
1
  export * from "./initializeDBMiddleware";
2
+ export * from "./initializeSplitMiddleware";
@@ -11,4 +11,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./initializeDBMiddleware"), exports);
14
+ __exportStar(require("./initializeSplitMiddleware"), exports);
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyC;AACzC,8DAA4C"}
@@ -0,0 +1,3 @@
1
+ import type { BaseSplitClient } from "@alanszp/split";
2
+ import { MiddlewareObj } from "@middy/core";
3
+ export declare function initializeSplitMiddleware<TEvent, TResult>(splitClient: BaseSplitClient): MiddlewareObj<TEvent, TResult>;
@@ -0,0 +1,32 @@
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.initializeSplitMiddleware = void 0;
13
+ const splitCouldNotLoadError_1 = require("../errors/splitCouldNotLoadError");
14
+ function initializeSplitMiddleware(splitClient) {
15
+ return {
16
+ before: () => __awaiter(this, void 0, void 0, function* () {
17
+ const loaded = yield splitClient.hasLoaded();
18
+ if (!loaded) {
19
+ try {
20
+ yield splitClient.destroy();
21
+ }
22
+ catch (error) { }
23
+ throw new splitCouldNotLoadError_1.SplitCouldNotLoadError();
24
+ }
25
+ }),
26
+ after: () => __awaiter(this, void 0, void 0, function* () {
27
+ yield splitClient.destroy();
28
+ }),
29
+ };
30
+ }
31
+ exports.initializeSplitMiddleware = initializeSplitMiddleware;
32
+ //# sourceMappingURL=initializeSplitMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initializeSplitMiddleware.js","sourceRoot":"","sources":["../../src/middlewares/initializeSplitMiddleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,6EAA0E;AAE1E,SAAgB,yBAAyB,CACvC,WAA4B;IAE5B,OAAO;QACL,MAAM,EAAE,GAAwB,EAAE;YAChC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,EAAE,CAAC;YAE7C,IAAI,CAAC,MAAM,EAAE;gBACX,IAAI;oBACF,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;iBAC7B;gBAAC,OAAO,KAAK,EAAE,GAAE;gBAClB,MAAM,IAAI,+CAAsB,EAAE,CAAC;aACpC;QACH,CAAC,CAAA;QACD,KAAK,EAAE,GAAwB,EAAE;YAC/B,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC,CAAA;KACF,CAAC;AACJ,CAAC;AAlBD,8DAkBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alanszp/serverless",
3
- "version": "7.0.0",
3
+ "version": "7.10.2",
4
4
  "description": "Alan's serverless utils and middlewares.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -20,11 +20,13 @@
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@alanszp/audit": "^5.0.0",
23
- "@alanszp/logger": "^5.0.0"
23
+ "@alanszp/logger": "^5.0.0",
24
+ "@alanszp/split": "^7.8.0"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@alanszp/audit": "^7.0.0",
27
28
  "@alanszp/logger": "^7.0.0",
29
+ "@alanszp/split": "^7.10.2",
28
30
  "@types/lodash": "^4.14.170",
29
31
  "@types/node": "^15.12.3",
30
32
  "ts-node": "^10.0.0",
@@ -41,5 +43,5 @@
41
43
  "cuid": "^2.1.8",
42
44
  "lodash": "^4.17.21"
43
45
  },
44
- "gitHead": "5fe04a249eeca2675e0565e08e99bffea6a2eaa0"
46
+ "gitHead": "7110149ea52fd72593271c26e1465b10a7e83b29"
45
47
  }
@@ -0,0 +1 @@
1
+ export * from "./splitCouldNotLoadError";
@@ -0,0 +1,5 @@
1
+ export class SplitCouldNotLoadError extends Error {
2
+ constructor() {
3
+ super("Split client couldn't load");
4
+ }
5
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ // Adding dummy code to deploy package
1
2
  export * from "./middlewares";
3
+ export * from "./errors";
2
4
  export * from "./handlers";
3
5
  export * from "./types";
@@ -1 +1,2 @@
1
1
  export * from "./initializeDBMiddleware";
2
+ export * from "./initializeSplitMiddleware";
@@ -0,0 +1,23 @@
1
+ import type { BaseSplitClient } from "@alanszp/split";
2
+ import { MiddlewareObj } from "@middy/core";
3
+ import { SplitCouldNotLoadError } from "../errors/splitCouldNotLoadError";
4
+
5
+ export function initializeSplitMiddleware<TEvent, TResult>(
6
+ splitClient: BaseSplitClient
7
+ ): MiddlewareObj<TEvent, TResult> {
8
+ return {
9
+ before: async (): Promise<void> => {
10
+ const loaded = await splitClient.hasLoaded();
11
+
12
+ if (!loaded) {
13
+ try {
14
+ await splitClient.destroy();
15
+ } catch (error) {}
16
+ throw new SplitCouldNotLoadError();
17
+ }
18
+ },
19
+ after: async (): Promise<void> => {
20
+ await splitClient.destroy();
21
+ },
22
+ };
23
+ }