@prismatic-io/spectral 7.6.2 → 7.6.4
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.
|
@@ -8,13 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.createPerform = void 0;
|
|
16
|
-
const serialize_error_1 = require("serialize-error");
|
|
17
|
-
const util_1 = __importDefault(require("../util"));
|
|
18
13
|
const cleanParams = (params, cleaners) => Object.entries(params).reduce((result, [key, value]) => {
|
|
19
14
|
const cleanFn = cleaners[key];
|
|
20
15
|
return Object.assign(Object.assign({}, result), { [key]: cleanFn ? cleanFn(value) : value });
|
|
@@ -34,12 +29,7 @@ const createPerform = (performFn, { inputCleaners, errorHandler }) => {
|
|
|
34
29
|
return yield performFn(context, payload, cleanParams(params, inputCleaners));
|
|
35
30
|
}
|
|
36
31
|
catch (error) {
|
|
37
|
-
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
const handled = errorHandler(error);
|
|
41
|
-
const serialized = util_1.default.types.toJSON((0, serialize_error_1.serializeError)(handled));
|
|
42
|
-
throw new Error(serialized);
|
|
32
|
+
throw errorHandler ? errorHandler(error) : error;
|
|
43
33
|
}
|
|
44
34
|
});
|
|
45
35
|
};
|
package/dist/testing.js
CHANGED
|
@@ -155,6 +155,12 @@ const baseDataSourceContext = {
|
|
|
155
155
|
id: "instanceId",
|
|
156
156
|
name: "Instance 1",
|
|
157
157
|
},
|
|
158
|
+
user: {
|
|
159
|
+
id: "userId",
|
|
160
|
+
email: "example@email.com",
|
|
161
|
+
externalId: "1234",
|
|
162
|
+
name: "Example",
|
|
163
|
+
},
|
|
158
164
|
};
|
|
159
165
|
/**
|
|
160
166
|
* Invokes specified DataSourceDefinition perform function using supplied params.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Inputs, DataSourceResult, DataSourceType, ActionInputParameters, ActionLogger, Customer, Instance } from ".";
|
|
1
|
+
import { Inputs, DataSourceResult, DataSourceType, ActionInputParameters, ActionLogger, Customer, Instance, User } from ".";
|
|
2
2
|
/** Context provided to perform method containing helpers and contextual data */
|
|
3
3
|
export interface DataSourceContext {
|
|
4
4
|
logger: ActionLogger;
|
|
5
5
|
customer: Customer;
|
|
6
6
|
instance: Instance;
|
|
7
|
+
user: User;
|
|
7
8
|
}
|
|
8
9
|
/** Definition of the function to perform when a Data Source is invoked. */
|
|
9
10
|
export declare type DataSourcePerformFunction<TInputs extends Inputs, TDataSourceType extends DataSourceType> = (context: DataSourceContext, params: ActionInputParameters<TInputs>) => Promise<DataSourceResult<TDataSourceType>>;
|