@smartsheet-extensions/handler 1.0.0-beta.11 → 1.0.0-beta.12
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/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/transports/lambdaTransport.d.ts.map +1 -1
- package/lib/transports/lambdaTransport.js +16 -12
- package/lib/transports/lambdaTransport.js.map +1 -1
- package/lib/utils/normalizeError.d.ts +1 -1
- package/lib/utils/serializable.d.ts +1 -1
- package/lib/utils/serializable.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
export * from './enhancers/handleBigPayLoad';
|
|
1
2
|
export * from './enhancers/handleHasProperty';
|
|
2
3
|
export * from './enhancers/handlePing';
|
|
3
4
|
export * from './enhancers/handlePromises';
|
|
4
5
|
export * from './enhancers/handleThunks';
|
|
5
6
|
export * from './enhancers/toSerializableObject';
|
|
6
7
|
export * from './enhancers/xorHandler';
|
|
7
|
-
export * from './enhancers/handleBigPayLoad';
|
|
8
8
|
export * from './errors/AbstractError';
|
|
9
9
|
export * from './errors/BadRequestError';
|
|
10
10
|
export * from './errors/ExtensionError';
|
|
11
11
|
export * from './errors/InternalError';
|
|
12
12
|
export * from './errors/NotFoundError';
|
|
13
|
+
export * from './errors/PlatformError';
|
|
13
14
|
export * from './errors/UncaughtError';
|
|
14
15
|
export * from './handler';
|
|
15
16
|
export * from './responses/ErrorResponse';
|
|
@@ -17,6 +18,6 @@ export * from './responses/ExtensionResponse';
|
|
|
17
18
|
export * from './transports/httpTransport';
|
|
18
19
|
export * from './transports/lambdaTransport';
|
|
19
20
|
export * from './utils/compose';
|
|
20
|
-
export * from './utils/serializable';
|
|
21
21
|
export * from './utils/constants';
|
|
22
|
+
export * from './utils/serializable';
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -10,18 +10,19 @@ 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
|
+
__exportStar(require("./enhancers/handleBigPayLoad"), exports);
|
|
13
14
|
__exportStar(require("./enhancers/handleHasProperty"), exports);
|
|
14
15
|
__exportStar(require("./enhancers/handlePing"), exports);
|
|
15
16
|
__exportStar(require("./enhancers/handlePromises"), exports);
|
|
16
17
|
__exportStar(require("./enhancers/handleThunks"), exports);
|
|
17
18
|
__exportStar(require("./enhancers/toSerializableObject"), exports);
|
|
18
19
|
__exportStar(require("./enhancers/xorHandler"), exports);
|
|
19
|
-
__exportStar(require("./enhancers/handleBigPayLoad"), exports);
|
|
20
20
|
__exportStar(require("./errors/AbstractError"), exports);
|
|
21
21
|
__exportStar(require("./errors/BadRequestError"), exports);
|
|
22
22
|
__exportStar(require("./errors/ExtensionError"), exports);
|
|
23
23
|
__exportStar(require("./errors/InternalError"), exports);
|
|
24
24
|
__exportStar(require("./errors/NotFoundError"), exports);
|
|
25
|
+
__exportStar(require("./errors/PlatformError"), exports);
|
|
25
26
|
__exportStar(require("./errors/UncaughtError"), exports);
|
|
26
27
|
__exportStar(require("./handler"), exports);
|
|
27
28
|
__exportStar(require("./responses/ErrorResponse"), exports);
|
|
@@ -29,6 +30,6 @@ __exportStar(require("./responses/ExtensionResponse"), exports);
|
|
|
29
30
|
__exportStar(require("./transports/httpTransport"), exports);
|
|
30
31
|
__exportStar(require("./transports/lambdaTransport"), exports);
|
|
31
32
|
__exportStar(require("./utils/compose"), exports);
|
|
32
|
-
__exportStar(require("./utils/serializable"), exports);
|
|
33
33
|
__exportStar(require("./utils/constants"), exports);
|
|
34
|
+
__exportStar(require("./utils/serializable"), exports);
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAA8C;AAC9C,yDAAuC;AACvC,6DAA2C;AAC3C,2DAAyC;AACzC,mEAAiD;AACjD,yDAAuC;AACvC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6C;AAC7C,gEAA8C;AAC9C,yDAAuC;AACvC,6DAA2C;AAC3C,2DAAyC;AACzC,mEAAiD;AACjD,yDAAuC;AACvC,yDAAuC;AACvC,2DAAyC;AACzC,0DAAwC;AACxC,yDAAuC;AACvC,yDAAuC;AACvC,yDAAuC;AACvC,yDAAuC;AACvC,4CAA0B;AAC1B,4DAA0C;AAC1C,gEAA8C;AAC9C,6DAA2C;AAC3C,+DAA6C;AAC7C,kDAAgC;AAChC,oDAAkC;AAClC,uDAAqC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambdaTransport.d.ts","sourceRoot":"","sources":["../../src/transports/lambdaTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"lambdaTransport.d.ts","sourceRoot":"","sources":["../../src/transports/lambdaTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD,oBAAY,sBAAsB,GAAG,OAAO,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;AAC9E,oBAAY,cAAc,GAAG,GAAG,CAAC;AACjC,oBAAY,eAAe,GAAG,GAAG,CAAC;AAElC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,wBAAwB,CAAC,sBAAsB,CAgC5E,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lambdaTransport = void 0;
|
|
4
|
-
const
|
|
5
|
-
const normalizeError_1 = require("../utils/normalizeError");
|
|
4
|
+
const PlatformError_1 = require("../errors/PlatformError");
|
|
6
5
|
/**
|
|
7
6
|
* This enhancer will return a function that takes a `event` and a `Context`
|
|
8
7
|
* and passes the `body` parameter from the request through to the handler (or
|
|
@@ -13,22 +12,17 @@ const normalizeError_1 = require("../utils/normalizeError");
|
|
|
13
12
|
exports.lambdaTransport = create => () => {
|
|
14
13
|
const handler = create();
|
|
15
14
|
return (event, context, callback) => {
|
|
16
|
-
const normalizeErrorAndRespond = (e) => {
|
|
17
|
-
const error = normalizeError_1.normalizeError(e);
|
|
18
|
-
if (callback) {
|
|
19
|
-
callback(null, error.toJSON());
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
15
|
try {
|
|
23
16
|
if (event === undefined || event === null) {
|
|
24
|
-
throw new
|
|
17
|
+
throw new PlatformError_1.PlatformError('Lambda event can not be undefined or null.');
|
|
25
18
|
}
|
|
26
19
|
if (context === undefined || context === null) {
|
|
27
|
-
throw new
|
|
20
|
+
throw new PlatformError_1.PlatformError('Lambda context can not be undefined or null.');
|
|
28
21
|
}
|
|
29
22
|
handler(event, (err, result) => {
|
|
30
23
|
if (err) {
|
|
31
|
-
|
|
24
|
+
const platErr = new PlatformError_1.PlatformError(err.message, err.stack, 'UNCAUGHT');
|
|
25
|
+
callback(null, platErr.toJSON());
|
|
32
26
|
}
|
|
33
27
|
else {
|
|
34
28
|
callback(null, result);
|
|
@@ -36,7 +30,17 @@ exports.lambdaTransport = create => () => {
|
|
|
36
30
|
});
|
|
37
31
|
}
|
|
38
32
|
catch (err) {
|
|
39
|
-
|
|
33
|
+
if (err instanceof PlatformError_1.PlatformError) {
|
|
34
|
+
callback(null, err.toJSON());
|
|
35
|
+
}
|
|
36
|
+
else if (err instanceof Error) {
|
|
37
|
+
const platErr = new PlatformError_1.PlatformError(err.message, err.stack, 'UNCAUGHT');
|
|
38
|
+
callback(null, platErr.toJSON());
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const platErr = new PlatformError_1.PlatformError(err);
|
|
42
|
+
callback(null, platErr.toJSON());
|
|
43
|
+
}
|
|
40
44
|
}
|
|
41
45
|
};
|
|
42
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambdaTransport.js","sourceRoot":"","sources":["../../src/transports/lambdaTransport.ts"],"names":[],"mappings":";;;AACA,2DAAwD;
|
|
1
|
+
{"version":3,"file":"lambdaTransport.js","sourceRoot":"","sources":["../../src/transports/lambdaTransport.ts"],"names":[],"mappings":";;;AACA,2DAAwD;AAOxD;;;;;;GAMG;AACU,QAAA,eAAe,GAAqD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE;IAC9F,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAClC,IAAI;YACF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;gBACzC,MAAM,IAAI,6BAAa,CAAC,4CAA4C,CAAC,CAAC;aACvE;YAED,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE;gBAC7C,MAAM,IAAI,6BAAa,CAAC,8CAA8C,CAAC,CAAC;aACzE;YAED,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;gBAC7B,IAAI,GAAG,EAAE;oBACP,MAAM,OAAO,GAAG,IAAI,6BAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;oBACtE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;iBAClC;qBAAM;oBACL,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;iBACxB;YACH,CAAC,CAAC,CAAC;SACJ;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,YAAY,6BAAa,EAAE;gBAChC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;aAC9B;iBAAM,IAAI,GAAG,YAAY,KAAK,EAAE;gBAC/B,MAAM,OAAO,GAAG,IAAI,6BAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;gBACtE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;aAClC;iBAAM;gBACL,MAAM,OAAO,GAAG,IAAI,6BAAa,CAAC,GAAG,CAAC,CAAC;gBACvC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;aAClC;SACF;IACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AbstractError } from '../errors/AbstractError';
|
|
2
2
|
import { PlatformError } from '../errors/PlatformError';
|
|
3
|
-
export declare const normalizeError: (e: any) =>
|
|
3
|
+
export declare const normalizeError: (e: any) => PlatformError | AbstractError;
|
|
4
4
|
//# sourceMappingURL=normalizeError.d.ts.map
|
|
@@ -6,7 +6,7 @@ export interface SerializableObject extends Record<string, SerializableValue> {
|
|
|
6
6
|
export declare type SerializableArray = Array<SerializableValue>;
|
|
7
7
|
export declare type SerializableValue = SerializableEmpty | SerializablePrimitive | SerializableObject | SerializableArray;
|
|
8
8
|
export declare const isSerializableEmpty: (o: unknown) => o is null;
|
|
9
|
-
export declare const isSerializablePrimitive: (o: unknown) => o is
|
|
9
|
+
export declare const isSerializablePrimitive: (o: unknown) => o is SerializablePrimitive;
|
|
10
10
|
export declare const isSerializableArray: (o: unknown) => o is SerializableArray;
|
|
11
11
|
export declare const isSerializableObject: (o: unknown) => o is SerializableObject;
|
|
12
12
|
export declare const isSerializable: (o: unknown) => o is SerializableValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializable.d.ts","sourceRoot":"","sources":["../../src/utils/serializable.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;AACjD,oBAAY,qBAAqB,GAAG,MAAM,GAA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