@pogodisco/task-runner 0.0.3 → 0.1.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/wrap-schema.d.ts +2 -0
- package/dist/utils/wrap-schema.js +10 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./wrap-schema.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./wrap-schema.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { SchemaOptions, TaskMap, TaskSchemaWithContracts } from "../main.js";
|
|
2
|
+
export declare function wrapSchema<T extends TaskMap, I extends Record<string, any>, O>(schema: TaskSchemaWithContracts<T, I, O>, options?: SchemaOptions): (initArgs: I) => Promise<import("@pogodisco/response").TResponse<O>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { withResponse } from "@pogodisco/response";
|
|
2
|
+
import { runSchema, } from "../main.js";
|
|
3
|
+
export function wrapSchema(schema, options) {
|
|
4
|
+
return withResponse(async (initArgs) => {
|
|
5
|
+
const res = await runSchema(schema, initArgs, options || {});
|
|
6
|
+
if (!res.ok)
|
|
7
|
+
throw res;
|
|
8
|
+
return res.data._output;
|
|
9
|
+
});
|
|
10
|
+
}
|