inngest 0.8.6-beta.1 → 0.8.6
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/cloudflare.d.ts +1 -1
- package/cloudflare.d.ts.map +1 -1
- package/cloudflare.js +81 -49
- package/cloudflare.js.map +1 -1
- package/components/Inngest.js +1 -1
- package/components/Inngest.js.map +1 -1
- package/express.d.ts +122 -2
- package/express.d.ts.map +1 -1
- package/express.js +295 -45
- package/express.js.map +1 -1
- package/helpers/types.d.ts +0 -4
- package/helpers/types.d.ts.map +1 -1
- package/index.d.ts +0 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -3
- package/index.js.map +1 -1
- package/landing.d.ts +1 -1
- package/landing.d.ts.map +1 -1
- package/landing.js +1 -1
- package/landing.js.map +1 -1
- package/next.d.ts +1 -1
- package/next.d.ts.map +1 -1
- package/next.js +70 -46
- package/next.js.map +1 -1
- package/package.json +1 -1
- package/redwood.d.ts +1 -1
- package/redwood.d.ts.map +1 -1
- package/redwood.js +99 -50
- package/redwood.js.map +1 -1
- package/remix.d.ts +1 -1
- package/remix.d.ts.map +1 -1
- package/remix.js +106 -61
- package/remix.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/components/InngestCommHandler.d.ts +0 -379
- package/components/InngestCommHandler.d.ts.map +0 -1
- package/components/InngestCommHandler.js +0 -443
- package/components/InngestCommHandler.js.map +0 -1
- package/deno/fresh.d.ts +0 -9
- package/deno/fresh.d.ts.map +0 -1
- package/deno/fresh.js +0 -54
- package/deno/fresh.js.map +0 -1
package/cloudflare.d.ts
CHANGED
package/cloudflare.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,YAAY,EACb,MAAM,WAAW,CAAC;AAqHnB;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,YAOnB,CAAC"}
|
package/cloudflare.js
CHANGED
|
@@ -1,8 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serve = void 0;
|
|
4
|
-
const
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const express_1 = require("./express");
|
|
5
6
|
const consts_1 = require("./helpers/consts");
|
|
7
|
+
const devserver_1 = require("./helpers/devserver");
|
|
8
|
+
const landing_1 = require("./landing");
|
|
9
|
+
class CloudflareCommHandler extends express_1.InngestCommHandler {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.frameworkName = "cloudflare-pages";
|
|
13
|
+
}
|
|
14
|
+
createHandler() {
|
|
15
|
+
return async ({ request: req, env, }) => {
|
|
16
|
+
const headers = { "x-inngest-sdk": this.sdkHeader.join("") };
|
|
17
|
+
let reqUrl;
|
|
18
|
+
let isIntrospection;
|
|
19
|
+
try {
|
|
20
|
+
reqUrl = this.reqUrl(req.url, `https://${req.headers.get("host") || ""}`);
|
|
21
|
+
isIntrospection = reqUrl.searchParams.has(consts_1.queryKeys.Introspect);
|
|
22
|
+
reqUrl.searchParams.delete(consts_1.queryKeys.Introspect);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return new Response(JSON.stringify(err), {
|
|
26
|
+
status: 500,
|
|
27
|
+
headers,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (!this.signingKey && env[consts_1.envKeys.SigningKey]) {
|
|
31
|
+
this.signingKey = env[consts_1.envKeys.SigningKey];
|
|
32
|
+
}
|
|
33
|
+
this._isProd = env.CF_PAGES === "1" || env.ENVIRONMENT === "production";
|
|
34
|
+
switch (req.method) {
|
|
35
|
+
case "GET": {
|
|
36
|
+
const showLandingPage = this.shouldShowLandingPage(env[consts_1.envKeys.LandingPage]);
|
|
37
|
+
if (this._isProd || !showLandingPage)
|
|
38
|
+
break;
|
|
39
|
+
if (isIntrospection) {
|
|
40
|
+
const introspection = Object.assign(Object.assign({}, this.registerBody(reqUrl)), { devServerURL: (0, devserver_1.devServerUrl)(env[consts_1.envKeys.DevServerUrl]).href, hasSigningKey: Boolean(this.signingKey) });
|
|
41
|
+
return new Response(JSON.stringify(introspection), {
|
|
42
|
+
status: 200,
|
|
43
|
+
headers,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Grab landing page and serve
|
|
47
|
+
return new Response(landing_1.landing, {
|
|
48
|
+
status: 200,
|
|
49
|
+
headers: Object.assign(Object.assign({}, headers), { "content-type": "text/html; charset=utf-8" }),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
case "PUT": {
|
|
53
|
+
// Push config to Inngest.
|
|
54
|
+
const { status, message } = await this.register(reqUrl, env[consts_1.envKeys.DevServerUrl]);
|
|
55
|
+
return new Response(JSON.stringify({ message }), { status, headers });
|
|
56
|
+
}
|
|
57
|
+
case "POST": {
|
|
58
|
+
// Inngest is trying to run a step; confirm signed and run.
|
|
59
|
+
const { fnId, stepId } = zod_1.z
|
|
60
|
+
.object({
|
|
61
|
+
fnId: zod_1.z.string().min(1),
|
|
62
|
+
stepId: zod_1.z.string().min(1),
|
|
63
|
+
})
|
|
64
|
+
.parse({
|
|
65
|
+
fnId: reqUrl.searchParams.get(consts_1.queryKeys.FnId),
|
|
66
|
+
stepId: reqUrl.searchParams.get(consts_1.queryKeys.StepId),
|
|
67
|
+
});
|
|
68
|
+
const stepRes = await this.runStep(fnId, stepId, await req.json());
|
|
69
|
+
if (stepRes.status === 500) {
|
|
70
|
+
return new Response(JSON.stringify(stepRes.error), {
|
|
71
|
+
status: stepRes.status,
|
|
72
|
+
headers,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return new Response(JSON.stringify(stepRes.body), {
|
|
76
|
+
status: stepRes.status,
|
|
77
|
+
headers,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return new Response(null, { status: 405, headers });
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
6
85
|
/**
|
|
7
86
|
* In Cloudflare, serve and register any declared functions with Inngest, making
|
|
8
87
|
* them available to be triggered by events.
|
|
@@ -10,54 +89,7 @@ const consts_1 = require("./helpers/consts");
|
|
|
10
89
|
* @public
|
|
11
90
|
*/
|
|
12
91
|
const serve = (nameOrInngest, fns, opts) => {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Assume that we want to override the `fetch` implementation with the one
|
|
16
|
-
* globally available in the Cloudflare env. Specifying it here will
|
|
17
|
-
* ensure we avoid trying to load a Node-compatible version later.
|
|
18
|
-
*/
|
|
19
|
-
fetch: fetch.bind(globalThis) }, opts), ({ request: req, env, }) => {
|
|
20
|
-
const url = new URL(req.url, `https://${req.headers.get("host") || ""}`);
|
|
21
|
-
const isProduction = env.CF_PAGES === "1" || env.ENVIRONMENT === "production";
|
|
22
|
-
return {
|
|
23
|
-
view: () => {
|
|
24
|
-
if (req.method === "GET") {
|
|
25
|
-
return {
|
|
26
|
-
url,
|
|
27
|
-
env,
|
|
28
|
-
isIntrospection: url.searchParams.has(consts_1.queryKeys.Introspect),
|
|
29
|
-
isProduction,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
register: () => {
|
|
34
|
-
if (req.method === "PUT") {
|
|
35
|
-
return {
|
|
36
|
-
env,
|
|
37
|
-
url,
|
|
38
|
-
isProduction,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
run: async () => {
|
|
43
|
-
if (req.method === "POST") {
|
|
44
|
-
return {
|
|
45
|
-
fnId: url.searchParams.get(consts_1.queryKeys.FnId),
|
|
46
|
-
data: (await req.json()),
|
|
47
|
-
env,
|
|
48
|
-
isProduction,
|
|
49
|
-
url,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}, ({ body, status, headers }) => {
|
|
55
|
-
return new Response(body, {
|
|
56
|
-
status,
|
|
57
|
-
headers,
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
return handler.createHandler();
|
|
92
|
+
return (0, express_1.serve)(new CloudflareCommHandler(nameOrInngest, fns, Object.assign({ fetch: fetch.bind(globalThis) }, opts)));
|
|
61
93
|
};
|
|
62
94
|
exports.serve = serve;
|
|
63
95
|
//# sourceMappingURL=cloudflare.js.map
|
package/cloudflare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,uCAImB;AACnB,6CAAsD;AACtD,mDAAmD;AACnD,uCAAoC;AAGpC,MAAM,qBAAsB,SAAQ,4BAAkB;IAAtD;;QACqB,kBAAa,GAAG,kBAAkB,CAAC;IA4GxD,CAAC;IA1GiB,aAAa;QAC3B,OAAO,KAAK,EAAE,EACZ,OAAO,EAAE,GAAG,EACZ,GAAG,GAIJ,EAAqB,EAAE;YACtB,MAAM,OAAO,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAE7D,IAAI,MAAW,CAAC;YAChB,IAAI,eAAwB,CAAC;YAE7B,IAAI;gBACF,MAAM,GAAG,IAAI,CAAC,MAAM,CAClB,GAAG,CAAC,GAAG,EACP,WAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAC3C,CAAC;gBAEF,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,kBA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oBAED,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;wBAChD,MAAM,EAAE,OAAO,CAAC,MAAM;wBACtB,OAAO;qBACR,CAAC,CAAC;iBACJ;aACF;YAED,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC;IACJ,CAAC;CACF;AAED;;;;;GAKG;AACI,MAAM,KAAK,GAAiB,CAAC,aAAa,EAAE,GAAG,EAAE,IAAI,EAAO,EAAE;IACnE,OAAO,IAAA,eAAY,EACjB,IAAI,qBAAqB,CAAC,aAAa,EAAE,GAAG,kBAC1C,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAC1B,IAAI,EACP,CACH,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,KAAK,SAOhB"}
|
package/components/Inngest.js
CHANGED
|
@@ -71,7 +71,7 @@ class Inngest {
|
|
|
71
71
|
eventKey || ((0, env_1.hasProcessEnv)() ? process.env[consts_1.envKeys.EventKey] || "" : "");
|
|
72
72
|
this.inngestBaseUrl = new URL(inngestBaseUrl);
|
|
73
73
|
this.inngestApiUrl = new URL(`e/${this.eventKey}`, this.inngestBaseUrl);
|
|
74
|
-
if (!eventKey) {
|
|
74
|
+
if (!this.eventKey) {
|
|
75
75
|
throw new Error("An event key must be passed to create an Inngest instance.");
|
|
76
76
|
}
|
|
77
77
|
this.headers = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Inngest.js","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8CAA4C;AAC5C,oDAAwE;AACxE,wCAAsE;AActE,wCAAqC;AACrC,uDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,OAAO;IAwBlB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IAC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,EAAE,CACH,CAAC;IACJ,CAAC;IA0DD;;OAEG;IACI,uBAAuB,CAC5B,UAAgB,EAChB,IAAY,EACZ,EAQC;QAED,OAAO,IAAI,iCAAe,CACxB,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,EAClE,EAAE,IAAI,EAAE,EACR,EAAE,CACH,CAAC;IACJ,CAAC;CACF;AAneD,0BAmeC;;AAzZC;;GAEG;AACH,KAAK,oCAAmB,QAA6B;IACnD,IAAI,YAAY,GAAG,eAAe,CAAC;IACnC,QAAQ,QAAQ,CAAC,MAAM,EAAE;QACvB,KAAK,GAAG;YACN,YAAY,GAAG,qBAAqB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,8BAA8B,CAAC;YAC9C,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,WAAW,CAAC;YAC3B,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,qBAAqB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAC1D,MAAM;QACR,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,YAAY,GAAG,6BAA6B,CAAC;YAC7C,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,yBAAyB,CAAC;YACzC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,uBAAuB,CAAC;YACvC,MAAM;KACT;IACD,OAAO,IAAI,KAAK,CAAC,sBAAsB,QAAQ,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
package/express.d.ts
CHANGED
|
@@ -1,9 +1,129 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Inngest } from "./components/Inngest";
|
|
2
|
+
import { InngestFunction } from "./components/InngestFunction";
|
|
3
|
+
import type { FunctionConfig, RegisterOptions, RegisterRequest, StepRunResponse } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* A handler for serving Inngest functions. This type should be used
|
|
6
|
+
* whenever a handler for a new framework is being added to enforce that the
|
|
7
|
+
* registration process is always the same for the user.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare type ServeHandler = (
|
|
12
|
+
/**
|
|
13
|
+
* The name of this app, used to scope and group Inngest functions, or
|
|
14
|
+
* the `Inngest` instance used to declare all functions.
|
|
15
|
+
*/
|
|
16
|
+
nameOrInngest: string | Inngest<any>,
|
|
17
|
+
/**
|
|
18
|
+
* An array of the functions to serve and register with Inngest.
|
|
19
|
+
*/
|
|
20
|
+
functions: InngestFunction<any>[],
|
|
21
|
+
/**
|
|
22
|
+
* A set of options to further configure the registration of Inngest
|
|
23
|
+
* functions.
|
|
24
|
+
*/
|
|
25
|
+
opts?: RegisterOptions) => any;
|
|
2
26
|
/**
|
|
3
27
|
* Serve and register any declared functions with Inngest, making them available
|
|
4
28
|
* to be triggered by events.
|
|
5
29
|
*
|
|
30
|
+
* Can either take an `Inngest` instance and a signing key, or can be used to
|
|
31
|
+
* create custom handlers by passing in an `InngestCommHandler`.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare const serve: (...args: Parameters<ServeHandler> | [commHandler: InngestCommHandler]) => any;
|
|
36
|
+
/**
|
|
37
|
+
* TODO Instead of `createHandler`, expose `createRequest` and `handleResponse`
|
|
38
|
+
*
|
|
39
|
+
* Overriding `createHandler` requires that we always remember crucial steps,
|
|
40
|
+
* e.g. validating signatures, handling POST, etc.
|
|
41
|
+
*
|
|
42
|
+
* We should instead require that new comm handlers override only two functions:
|
|
43
|
+
*
|
|
44
|
+
* `createRequest()`
|
|
45
|
+
* This is the function that is exposed. It must return a valid `HandlerRequest`
|
|
46
|
+
*
|
|
47
|
+
* `handleResponse()`
|
|
48
|
+
* The input is a `StepResponse`, and output can be anything needed for the
|
|
49
|
+
* platform
|
|
50
|
+
*
|
|
51
|
+
* This needs to also account for the ability to validate signatures etc.
|
|
52
|
+
*
|
|
6
53
|
* @public
|
|
7
54
|
*/
|
|
8
|
-
export declare
|
|
55
|
+
export declare class InngestCommHandler {
|
|
56
|
+
name: string;
|
|
57
|
+
/**
|
|
58
|
+
* The URL of the Inngest function registration endpoint.
|
|
59
|
+
*/
|
|
60
|
+
private readonly inngestRegisterUrl;
|
|
61
|
+
protected readonly frameworkName: string;
|
|
62
|
+
protected signingKey: string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* A property that can be set to indicate whether or not we believe we are in
|
|
65
|
+
* production mode.
|
|
66
|
+
*
|
|
67
|
+
* Should be set every time a request is received.
|
|
68
|
+
*/
|
|
69
|
+
protected _isProd: boolean;
|
|
70
|
+
private readonly headers;
|
|
71
|
+
private readonly fetch;
|
|
72
|
+
/**
|
|
73
|
+
* Whether we should show the SDK Landing Page.
|
|
74
|
+
*
|
|
75
|
+
* This purposefully does not take in to account any environment variables, as
|
|
76
|
+
* accessing them safely is platform-specific.
|
|
77
|
+
*/
|
|
78
|
+
protected readonly showLandingPage: boolean | undefined;
|
|
79
|
+
protected readonly serveHost: string | undefined;
|
|
80
|
+
protected readonly servePath: string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* A private collection of functions that are being served. This map is used
|
|
83
|
+
* to find and register functions when interacting with Inngest Cloud.
|
|
84
|
+
*/
|
|
85
|
+
private readonly fns;
|
|
86
|
+
constructor(nameOrInngest: string | Inngest<any>, functions: InngestFunction<any>[], { inngestRegisterUrl, fetch, landingPage, signingKey, serveHost, servePath, }?: RegisterOptions);
|
|
87
|
+
private get hashedSigningKey();
|
|
88
|
+
createHandler(): any;
|
|
89
|
+
protected runStep(functionId: string, stepId: string, data: any): Promise<StepRunResponse>;
|
|
90
|
+
protected configs(url: URL): FunctionConfig[];
|
|
91
|
+
/**
|
|
92
|
+
* Returns an SDK header split in to three parts so that they can be used for
|
|
93
|
+
* different purposes.
|
|
94
|
+
*
|
|
95
|
+
* To use the entire string, run `this.sdkHeader.join("")`.
|
|
96
|
+
*/
|
|
97
|
+
protected get sdkHeader(): [
|
|
98
|
+
prefix: string,
|
|
99
|
+
version: RegisterRequest["sdk"],
|
|
100
|
+
suffix: string
|
|
101
|
+
];
|
|
102
|
+
/**
|
|
103
|
+
* Return an Inngest serve endpoint URL given a potential `path` and `host`.
|
|
104
|
+
*
|
|
105
|
+
* Will automatically use the `serveHost` and `servePath` if they have been
|
|
106
|
+
* set when registering.
|
|
107
|
+
*/
|
|
108
|
+
protected reqUrl(
|
|
109
|
+
/**
|
|
110
|
+
* The path of the Inngest register URL to create. Regardless of the value,
|
|
111
|
+
* will be overwritten by `servePath` if it has been set.
|
|
112
|
+
*/
|
|
113
|
+
path?: string,
|
|
114
|
+
/**
|
|
115
|
+
* The host of the Inngest register URL to create. Regardless of the value,
|
|
116
|
+
* will be overwritten by `serveHost` if it has been set.
|
|
117
|
+
*/
|
|
118
|
+
host?: string): URL;
|
|
119
|
+
protected registerBody(url: URL): RegisterRequest;
|
|
120
|
+
protected register(url: URL, devServerHost: string | undefined): Promise<{
|
|
121
|
+
status: number;
|
|
122
|
+
message: string;
|
|
123
|
+
}>;
|
|
124
|
+
private get isProd();
|
|
125
|
+
protected shouldShowLandingPage(strEnvVar: string | undefined): boolean;
|
|
126
|
+
protected validateSignature(): boolean;
|
|
127
|
+
protected signResponse(): string;
|
|
128
|
+
}
|
|
9
129
|
//# sourceMappingURL=express.d.ts.map
|
package/express.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAA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