@mynthio/sdk 0.0.39 → 0.0.41

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.
Files changed (42) hide show
  1. package/README.md +49 -9
  2. package/dist/convex/index.d.ts +39 -90
  3. package/dist/convex/index.js +41 -2
  4. package/dist/handler.d.ts +28 -0
  5. package/dist/handler.js +121 -0
  6. package/dist/index.d.ts +675 -328
  7. package/dist/index.js +1469 -2
  8. package/dist/next/index.d.ts +14 -22
  9. package/dist/next/index.js +25 -2
  10. package/dist/tanstack-start/index.d.ts +18 -21
  11. package/dist/tanstack-start/index.js +11 -2
  12. package/dist/types.d.ts +610 -592
  13. package/package.json +16 -21
  14. package/dist/client.d.ts +0 -41
  15. package/dist/client.d.ts.map +0 -1
  16. package/dist/constants.d.ts +0 -94
  17. package/dist/constants.d.ts.map +0 -1
  18. package/dist/convex/index.d.ts.map +0 -1
  19. package/dist/convex/utils.d.ts +0 -2
  20. package/dist/convex/utils.d.ts.map +0 -1
  21. package/dist/image-alt-result.d.ts +0 -22
  22. package/dist/image-alt-result.d.ts.map +0 -1
  23. package/dist/image-generation-result.d.ts +0 -58
  24. package/dist/image-generation-result.d.ts.map +0 -1
  25. package/dist/image-rate-result.d.ts +0 -24
  26. package/dist/image-rate-result.d.ts.map +0 -1
  27. package/dist/image-review-result.d.ts +0 -31
  28. package/dist/image-review-result.d.ts.map +0 -1
  29. package/dist/index-apss16tr.js +0 -3
  30. package/dist/index-pjgsme75.js +0 -3
  31. package/dist/index.d.ts.map +0 -1
  32. package/dist/next/index.d.ts.map +0 -1
  33. package/dist/tanstack-start/index.d.ts.map +0 -1
  34. package/dist/task-async.d.ts +0 -95
  35. package/dist/task-async.d.ts.map +0 -1
  36. package/dist/types.d.ts.map +0 -1
  37. package/dist/uploads.d.ts +0 -31
  38. package/dist/uploads.d.ts.map +0 -1
  39. package/dist/video-generation-result.d.ts +0 -46
  40. package/dist/video-generation-result.d.ts.map +0 -1
  41. package/dist/webhooks/utils.d.ts +0 -5
  42. package/dist/webhooks/utils.d.ts.map +0 -1
@@ -1,24 +1,16 @@
1
- import type { MynthSDKTypes } from "../types";
1
+ import { n as WebhookHandlerOptions, t as WebhookEventHandlers } from "../handler.js";
2
+ //#region src/next/index.d.ts
2
3
  export type MynthWebhookHandlerContext = {
3
- /** The original request received by the Next.js Route Handler. */
4
- request: Request;
5
- };
6
- export type MynthWebhookEventHandlers = {
7
- imageTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageCompletedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
8
- imageTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageFailedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
9
- imageRateTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageRateCompletedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
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
- videoTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskVideoCompletedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
16
- videoTaskFailed?: (payload: MynthSDKTypes.WebhookTaskVideoFailedPayload, context: MynthWebhookHandlerContext) => void | Promise<void>;
17
- };
18
- export type MynthWebhookHandlerOptions = {
19
- /** Defaults to MYNTH_WEBHOOK_SECRET at request time. */
20
- 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;
21
11
  };
12
+ export type MynthWebhookEventHandlers = WebhookEventHandlers<MynthWebhookHandlerContext>;
13
+ export type MynthWebhookHandlerOptions = WebhookHandlerOptions;
22
14
  /**
23
15
  * Create a Next.js App Router handler for signed Mynth webhooks.
24
16
  *
@@ -28,11 +20,11 @@ export type MynthWebhookHandlerOptions = {
28
20
  * import { mynthWebhookHandler } from "@mynthio/sdk/next";
29
21
  *
30
22
  * export const POST = mynthWebhookHandler({
31
- * imageTaskCompleted: async (payload, { request }) => {
32
- * console.log(payload.task.id, request.url);
23
+ * imageTaskCompleted: async (payload, { deliveryId }) => {
24
+ * console.log(deliveryId, payload.task.id);
33
25
  * },
34
26
  * });
35
27
  * ```
36
28
  */
37
29
  export declare function mynthWebhookHandler(eventHandlers: MynthWebhookEventHandlers, options?: MynthWebhookHandlerOptions): (request: Request) => Promise<Response>;
38
- //# sourceMappingURL=index.d.ts.map
30
+ //#endregion
@@ -1,2 +1,25 @@
1
- // @bun
2
- import{a}from"../index-pjgsme75.js";import"../index-apss16tr.js";export{a as mynthWebhookHandler};
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,26 +1,23 @@
1
- import type { MynthSDKTypes } from "../types";
2
- import { type MynthWebhookHandlerOptions } from "../next";
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
- /** 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;
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
- export type MynthTanStackStartEventHandlers<TContext = unknown, TParams extends Record<string, string> = Record<string, string>> = {
12
- imageTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageCompletedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
13
- imageTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageFailedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
14
- imageRateTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageRateCompletedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
15
- imageRateTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageRateFailedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
16
- imageAltTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskImageAltCompletedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
17
- imageAltTaskFailed?: (payload: MynthSDKTypes.WebhookTaskImageAltFailedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
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
- videoTaskCompleted?: (payload: MynthSDKTypes.WebhookTaskVideoCompletedPayload, context: MynthTanStackStartHandlerContext<TContext, TParams>) => void | Promise<void>;
21
- 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;
22
18
  };
23
- export type MynthTanStackStartHandlerOptions = MynthWebhookHandlerOptions;
19
+ export type MynthTanStackStartEventHandlers<TContext = unknown, TParams extends Record<string, string> = Record<string, string>> = WebhookEventHandlers<MynthTanStackStartEventContext<TContext, TParams>>;
20
+ export type MynthTanStackStartHandlerOptions = WebhookHandlerOptions;
24
21
  /** Create a TanStack Start server route handler for signed Mynth webhooks. */
25
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>;
26
- //# sourceMappingURL=index.d.ts.map
23
+ //#endregion
@@ -1,2 +1,11 @@
1
- // @bun
2
- import{a as A}from"../index-pjgsme75.js";import"../index-apss16tr.js";function F(z,B={}){return async(m)=>{return A({imageTaskCompleted:(j)=>z.imageTaskCompleted?.(j,m),imageTaskFailed:(j)=>z.imageTaskFailed?.(j,m),imageRateTaskCompleted:(j)=>z.imageRateTaskCompleted?.(j,m),imageRateTaskFailed:(j)=>z.imageRateTaskFailed?.(j,m),imageAltTaskCompleted:(j)=>z.imageAltTaskCompleted?.(j,m),imageAltTaskFailed:(j)=>z.imageAltTaskFailed?.(j,m),imageReviewTaskCompleted:(j)=>z.imageReviewTaskCompleted?.(j,m),imageReviewTaskFailed:(j)=>z.imageReviewTaskFailed?.(j,m),videoTaskCompleted:(j)=>z.videoTaskCompleted?.(j,m),videoTaskFailed:(j)=>z.videoTaskFailed?.(j,m)},B)(m.request.clone())}}export{F as mynthWebhookHandler};
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 };