@mynthio/sdk 0.0.40 → 0.0.42
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/README.md +20 -4
- package/dist/convex/index.d.ts +39 -100
- package/dist/convex/index.js +41 -2
- package/dist/handler.d.ts +28 -0
- package/dist/handler.js +121 -0
- package/dist/index.d.ts +701 -360
- package/dist/index.js +1514 -2
- package/dist/next/index.d.ts +14 -24
- package/dist/next/index.js +25 -2
- package/dist/tanstack-start/index.d.ts +18 -23
- package/dist/tanstack-start/index.js +11 -2
- package/dist/types.d.ts +609 -660
- package/package.json +16 -21
- package/dist/client.d.ts +0 -41
- package/dist/client.d.ts.map +0 -1
- package/dist/constants.d.ts +0 -95
- package/dist/constants.d.ts.map +0 -1
- package/dist/convex/index.d.ts.map +0 -1
- package/dist/convex/utils.d.ts +0 -2
- package/dist/convex/utils.d.ts.map +0 -1
- package/dist/image-alt-result.d.ts +0 -19
- package/dist/image-alt-result.d.ts.map +0 -1
- package/dist/image-generation-result.d.ts +0 -58
- package/dist/image-generation-result.d.ts.map +0 -1
- package/dist/image-rate-result.d.ts +0 -21
- package/dist/image-rate-result.d.ts.map +0 -1
- package/dist/image-remove-background-result.d.ts +0 -24
- package/dist/image-remove-background-result.d.ts.map +0 -1
- package/dist/image-review-result.d.ts +0 -28
- package/dist/image-review-result.d.ts.map +0 -1
- package/dist/index-apss16tr.js +0 -3
- package/dist/index-ty295921.js +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/next/index.d.ts.map +0 -1
- package/dist/tanstack-start/index.d.ts.map +0 -1
- package/dist/task-async.d.ts +0 -95
- package/dist/task-async.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/uploads.d.ts +0 -31
- package/dist/uploads.d.ts.map +0 -1
- package/dist/video-generation-result.d.ts +0 -46
- package/dist/video-generation-result.d.ts.map +0 -1
- package/dist/webhooks/utils.d.ts +0 -5
- package/dist/webhooks/utils.d.ts.map +0 -1
package/dist/next/index.d.ts
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { n as WebhookHandlerOptions, t as WebhookEventHandlers } from "../handler.js";
|
|
2
|
+
//#region src/next/index.d.ts
|
|
2
3
|
export type MynthWebhookHandlerContext = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
imageRateTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageRateFailedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
11
|
-
imageAltTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageAltCompletedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
12
|
-
imageAltTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageAltFailedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
13
|
-
imageReviewTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageReviewCompletedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
14
|
-
imageReviewTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageReviewFailedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
15
|
-
imageRemoveBackgroundTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageRemoveBackgroundCompletedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
16
|
-
imageRemoveBackgroundTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageRemoveBackgroundFailedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
17
|
-
videoTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskVideoCompletedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
18
|
-
videoTaskFailed?: (payload: MynthSDKTypes.WebhookTaskVideoFailedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
|
|
19
|
-
};
|
|
20
|
-
export type MynthWebhookHandlerOptions = {
|
|
21
|
-
/** Defaults to MYNTH_WEBHOOK_SECRET at request time. */
|
|
22
|
-
webhookSecret?: string;
|
|
4
|
+
/** The original request received by the Next.js Route Handler. */
|
|
5
|
+
request: Request;
|
|
6
|
+
/**
|
|
7
|
+
* The `X-Mynth-Delivery` ID. Every retry of a delivery repeats it, so store
|
|
8
|
+
* it and skip IDs you have already handled.
|
|
9
|
+
*/
|
|
10
|
+
deliveryId: string;
|
|
23
11
|
};
|
|
12
|
+
export type MynthWebhookEventHandlers = WebhookEventHandlers<MynthWebhookHandlerContext>;
|
|
13
|
+
export type MynthWebhookHandlerOptions = WebhookHandlerOptions;
|
|
24
14
|
/**
|
|
25
15
|
* Create a Next.js App Router handler for signed Mynth webhooks.
|
|
26
16
|
*
|
|
@@ -30,11 +20,11 @@ export type MynthWebhookHandlerOptions = {
|
|
|
30
20
|
* import { mynthWebhookHandler } from "@mynthio/sdk/next";
|
|
31
21
|
*
|
|
32
22
|
* export const POST = mynthWebhookHandler({
|
|
33
|
-
* imageTaskCompleted: async (payload, {
|
|
34
|
-
* console.log(payload.task.id
|
|
23
|
+
* imageTaskCompleted: async (payload, { deliveryId }) => {
|
|
24
|
+
* console.log(deliveryId, payload.task.id);
|
|
35
25
|
* },
|
|
36
26
|
* });
|
|
37
27
|
* ```
|
|
38
28
|
*/
|
|
39
29
|
export declare function mynthWebhookHandler(eventHandlers: MynthWebhookEventHandlers, options?: MynthWebhookHandlerOptions): (request: Request) => Promise<Response>;
|
|
40
|
-
//#
|
|
30
|
+
//#endregion
|
package/dist/next/index.js
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { t as handleWebhookRequest } from "../handler.js";
|
|
2
|
+
//#region src/next/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* Create a Next.js App Router handler for signed Mynth webhooks.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* // app/api/mynth-webhook/route.ts
|
|
9
|
+
* import { mynthWebhookHandler } from "@mynthio/sdk/next";
|
|
10
|
+
*
|
|
11
|
+
* export const POST = mynthWebhookHandler({
|
|
12
|
+
* imageTaskCompleted: async (payload, { deliveryId }) => {
|
|
13
|
+
* console.log(deliveryId, payload.task.id);
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function mynthWebhookHandler(eventHandlers, options = {}) {
|
|
19
|
+
return (request) => handleWebhookRequest(request, eventHandlers, (deliveryId) => ({
|
|
20
|
+
request,
|
|
21
|
+
deliveryId
|
|
22
|
+
}), options);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { mynthWebhookHandler };
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { n as WebhookHandlerOptions, t as WebhookEventHandlers } from "../handler.js";
|
|
2
|
+
//#region src/tanstack-start/index.d.ts
|
|
3
3
|
export type MynthTanStackStartHandlerContext<TContext = unknown, TParams extends Record<string, string> = Record<string, string>> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
/** The original, unread request received by the TanStack Start server route. */
|
|
5
|
+
request: Request;
|
|
6
|
+
/** Dynamic parameters for the matched route. */
|
|
7
|
+
params: TParams;
|
|
8
|
+
/** Context provided by TanStack Start request middleware. */
|
|
9
|
+
context: TContext;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
imageReviewTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageReviewCompletedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
|
|
19
|
-
imageReviewTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageReviewFailedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
|
|
20
|
-
imageRemoveBackgroundTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageRemoveBackgroundCompletedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
|
|
21
|
-
imageRemoveBackgroundTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageRemoveBackgroundFailedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
|
|
22
|
-
videoTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskVideoCompletedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
|
|
23
|
-
videoTaskFailed?: (payload: MynthSDKTypes.WebhookTaskVideoFailedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
|
|
11
|
+
/** What event callbacks receive: the route context plus the delivery ID. */
|
|
12
|
+
export type MynthTanStackStartEventContext<TContext = unknown, TParams extends Record<string, string> = Record<string, string>> = MynthTanStackStartHandlerContext<TContext, TParams> & {
|
|
13
|
+
/**
|
|
14
|
+
* The `X-Mynth-Delivery` ID. Every retry of a delivery repeats it, so store
|
|
15
|
+
* it and skip IDs you have already handled.
|
|
16
|
+
*/
|
|
17
|
+
deliveryId: string;
|
|
24
18
|
};
|
|
25
|
-
export type
|
|
19
|
+
export type MynthTanStackStartEventHandlers<TContext = unknown, TParams extends Record<string, string> = Record<string, string>> = WebhookEventHandlers<MynthTanStackStartEventContext<TContext, TParams>>;
|
|
20
|
+
export type MynthTanStackStartHandlerOptions = WebhookHandlerOptions;
|
|
26
21
|
/** Create a TanStack Start server route handler for signed Mynth webhooks. */
|
|
27
22
|
export declare function mynthWebhookHandler<TContext = unknown, TParams extends Record<string, string> = Record<string, string>>(eventHandlers: MynthTanStackStartEventHandlers<TContext, TParams>, options?: MynthTanStackStartHandlerOptions): (context: MynthTanStackStartHandlerContext<TContext, TParams>) => Promise<Response>;
|
|
28
|
-
//#
|
|
23
|
+
//#endregion
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { t as handleWebhookRequest } from "../handler.js";
|
|
2
|
+
//#region src/tanstack-start/index.ts
|
|
3
|
+
/** Create a TanStack Start server route handler for signed Mynth webhooks. */
|
|
4
|
+
function mynthWebhookHandler(eventHandlers, options = {}) {
|
|
5
|
+
return (context) => handleWebhookRequest(context.request.clone(), eventHandlers, (deliveryId) => ({
|
|
6
|
+
...context,
|
|
7
|
+
deliveryId
|
|
8
|
+
}), options);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { mynthWebhookHandler };
|