@hatchet-dev/typescript-sdk 0.12.0 → 0.12.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.
|
@@ -238,13 +238,17 @@ class AdminClient {
|
|
|
238
238
|
* @param input an object containing the input to the workflow
|
|
239
239
|
*/
|
|
240
240
|
scheduleWorkflow(name, options) {
|
|
241
|
+
let computedName = name;
|
|
241
242
|
try {
|
|
243
|
+
if (this.config.namespace && !name.startsWith(this.config.namespace)) {
|
|
244
|
+
computedName = this.config.namespace + name;
|
|
245
|
+
}
|
|
242
246
|
let input;
|
|
243
247
|
if (options === null || options === void 0 ? void 0 : options.input) {
|
|
244
248
|
input = JSON.stringify(options.input);
|
|
245
249
|
}
|
|
246
250
|
this.client.scheduleWorkflow({
|
|
247
|
-
name,
|
|
251
|
+
name: computedName,
|
|
248
252
|
schedules: options === null || options === void 0 ? void 0 : options.schedules,
|
|
249
253
|
input,
|
|
250
254
|
});
|
|
@@ -28,26 +28,18 @@ export declare class WebhookHandler {
|
|
|
28
28
|
* This method is an asynchronous function that returns an Express middleware handler.
|
|
29
29
|
* The handler function is responsible for handling incoming requests and invoking the
|
|
30
30
|
* corresponding logic based on the provided secret.
|
|
31
|
-
*
|
|
32
|
-
* @param {string} secret - The secret key used to authenticate and authorize the incoming requests.
|
|
33
|
-
*
|
|
34
|
-
* @return {Function} - An Express middleware handler function that receives the request and response objects.
|
|
35
31
|
*/
|
|
36
32
|
expressHandler({ secret }: HandlerOpts): (req: any, res: any) => void;
|
|
37
33
|
/**
|
|
38
34
|
* A method that returns an HTTP request handler.
|
|
39
|
-
*
|
|
40
|
-
* @param {string} secret - The secret key used for verification.
|
|
41
|
-
*
|
|
42
|
-
* @returns {function} - An HTTP request handler function.
|
|
43
35
|
*/
|
|
44
36
|
httpHandler({ secret }: HandlerOpts): (req: IncomingMessage, res: ServerResponse) => void;
|
|
37
|
+
/**
|
|
38
|
+
* A method that returns a Next.js pages router request handler.
|
|
39
|
+
*/
|
|
40
|
+
nextJSPagesHandler({ secret }: HandlerOpts): (req: any, res: any) => Promise<any>;
|
|
45
41
|
/**
|
|
46
42
|
* A method that returns a Next.js request handler.
|
|
47
|
-
*
|
|
48
|
-
* @param {any} req - The request object received from Next.js.
|
|
49
|
-
* @param {string} secret - The secret key used to verify the request.
|
|
50
|
-
* @return {Promise<Response>} - A Promise that resolves with a Response object.
|
|
51
43
|
*/
|
|
52
44
|
nextJSHandler({ secret }: HandlerOpts): {
|
|
53
45
|
GET: () => Promise<Response>;
|
|
@@ -75,10 +75,6 @@ class WebhookHandler {
|
|
|
75
75
|
* This method is an asynchronous function that returns an Express middleware handler.
|
|
76
76
|
* The handler function is responsible for handling incoming requests and invoking the
|
|
77
77
|
* corresponding logic based on the provided secret.
|
|
78
|
-
*
|
|
79
|
-
* @param {string} secret - The secret key used to authenticate and authorize the incoming requests.
|
|
80
|
-
*
|
|
81
|
-
* @return {Function} - An Express middleware handler function that receives the request and response objects.
|
|
82
78
|
*/
|
|
83
79
|
expressHandler({ secret }) {
|
|
84
80
|
return (req, res) => {
|
|
@@ -116,10 +112,6 @@ class WebhookHandler {
|
|
|
116
112
|
}
|
|
117
113
|
/**
|
|
118
114
|
* A method that returns an HTTP request handler.
|
|
119
|
-
*
|
|
120
|
-
* @param {string} secret - The secret key used for verification.
|
|
121
|
-
*
|
|
122
|
-
* @returns {function} - An HTTP request handler function.
|
|
123
115
|
*/
|
|
124
116
|
httpHandler({ secret }) {
|
|
125
117
|
return (req, res) => {
|
|
@@ -155,12 +147,29 @@ class WebhookHandler {
|
|
|
155
147
|
});
|
|
156
148
|
};
|
|
157
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* A method that returns a Next.js pages router request handler.
|
|
152
|
+
*/
|
|
153
|
+
nextJSPagesHandler({ secret }) {
|
|
154
|
+
return (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
if (req.method === 'GET') {
|
|
156
|
+
return res.status(200).send(okMessage);
|
|
157
|
+
}
|
|
158
|
+
const sig = req.headers['x-hatchet-signature'];
|
|
159
|
+
const body = JSON.stringify(req.body);
|
|
160
|
+
if (req.method === 'PUT') {
|
|
161
|
+
const resp = yield this.getHealthcheckResponse(body, sig, secret);
|
|
162
|
+
return res.status(200).send(JSON.stringify(resp));
|
|
163
|
+
}
|
|
164
|
+
if (req.method !== 'POST') {
|
|
165
|
+
return res.status(405).send('Method not allowed');
|
|
166
|
+
}
|
|
167
|
+
yield this.handle(body, sig, secret);
|
|
168
|
+
return res.status(200).send('ok');
|
|
169
|
+
});
|
|
170
|
+
}
|
|
158
171
|
/**
|
|
159
172
|
* A method that returns a Next.js request handler.
|
|
160
|
-
*
|
|
161
|
-
* @param {any} req - The request object received from Next.js.
|
|
162
|
-
* @param {string} secret - The secret key used to verify the request.
|
|
163
|
-
* @return {Promise<Response>} - A Promise that resolves with a Response object.
|
|
164
173
|
*/
|
|
165
174
|
nextJSHandler({ secret }) {
|
|
166
175
|
const ok = () => __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"eslint-plugin-react": "^7.34.1",
|
|
80
80
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
81
81
|
"eslint-plugin-react-refresh": "^0.4.6",
|
|
82
|
-
"eslint-plugin-unused-imports": "^
|
|
82
|
+
"eslint-plugin-unused-imports": "^4.1.3",
|
|
83
83
|
"grpc-tools": "^1.12.4",
|
|
84
84
|
"jest": "^29.7.0",
|
|
85
85
|
"prettier": "^3.1.1",
|
|
86
86
|
"resolve-tspaths": "^0.8.17",
|
|
87
87
|
"ts-jest": "^29.1.1",
|
|
88
88
|
"ts-node": "^10.9.2",
|
|
89
|
-
"ts-proto": "^
|
|
89
|
+
"ts-proto": "^2.0.2",
|
|
90
90
|
"typedoc": "^0.26.2",
|
|
91
91
|
"typedoc-plugin-markdown": "^4.0.2",
|
|
92
92
|
"typescript": "^5.3.3"
|