@adonix.org/cloud-spark 0.0.29 → 0.0.31
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 +4 -3
- package/dist/index.js +25 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -154,6 +154,7 @@ declare class BasicWorker implements CorsProvider {
|
|
|
154
154
|
constructor(_env?: Env, _ctx?: ExecutionContext | undefined);
|
|
155
155
|
protected get env(): Env;
|
|
156
156
|
protected get ctx(): ExecutionContext | undefined;
|
|
157
|
+
protected handleRequest(request: Request): Promise<Response>;
|
|
157
158
|
fetch(request: Request): Promise<Response>;
|
|
158
159
|
protected get(_request: Request): Response | Promise<Response>;
|
|
159
160
|
protected put(_request: Request): Response | Promise<Response>;
|
|
@@ -171,12 +172,12 @@ declare class BasicWorker implements CorsProvider {
|
|
|
171
172
|
getOrigin(): string | null;
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
declare class RoutedWorker extends BasicWorker {
|
|
175
|
+
declare abstract class RoutedWorker extends BasicWorker {
|
|
175
176
|
private routes;
|
|
176
177
|
constructor(env?: Env, ctx?: ExecutionContext);
|
|
177
|
-
protected addRoutes(): void;
|
|
178
|
+
protected abstract addRoutes(): void;
|
|
178
179
|
protected addRoute(route: string | RegExp, callback: (request: Request, ...matches: string[]) => Response | Promise<Response>, method?: Method): void;
|
|
179
|
-
|
|
180
|
+
protected handleRequest(request: Request): Promise<Response>;
|
|
180
181
|
private search;
|
|
181
182
|
protected head(request: Request): Promise<Response>;
|
|
182
183
|
protected get(): Response | Promise<Response>;
|
package/dist/index.js
CHANGED
|
@@ -269,13 +269,10 @@ var BasicWorker = class {
|
|
|
269
269
|
get ctx() {
|
|
270
270
|
return this._ctx;
|
|
271
271
|
}
|
|
272
|
-
async
|
|
273
|
-
|
|
274
|
-
return this.getResponse(MethodNotAllowed, request.method);
|
|
275
|
-
}
|
|
276
|
-
this.origin = request.headers.get("Origin");
|
|
272
|
+
async handleRequest(request) {
|
|
273
|
+
const method = request.method;
|
|
277
274
|
try {
|
|
278
|
-
switch (
|
|
275
|
+
switch (method) {
|
|
279
276
|
case "GET" /* GET */:
|
|
280
277
|
return await this.get(request);
|
|
281
278
|
case "PUT" /* PUT */:
|
|
@@ -291,12 +288,28 @@ var BasicWorker = class {
|
|
|
291
288
|
case "OPTIONS" /* OPTIONS */:
|
|
292
289
|
return await this.options(request);
|
|
293
290
|
default:
|
|
294
|
-
return this.getResponse(MethodNotAllowed,
|
|
291
|
+
return this.getResponse(MethodNotAllowed, method);
|
|
295
292
|
}
|
|
296
293
|
} catch (error) {
|
|
297
294
|
return this.getResponse(InternalServerError, String(error));
|
|
298
295
|
}
|
|
299
296
|
}
|
|
297
|
+
async fetch(request) {
|
|
298
|
+
const method = request.method;
|
|
299
|
+
if (!isMethod(method)) {
|
|
300
|
+
throw new Error(`Unsupported method ${method}`);
|
|
301
|
+
}
|
|
302
|
+
if (!this.isAllowed(method)) {
|
|
303
|
+
return this.getResponse(MethodNotAllowed, method);
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
new URL(request.url);
|
|
307
|
+
} catch {
|
|
308
|
+
return this.getResponse(BadRequest, "Malformed URL");
|
|
309
|
+
}
|
|
310
|
+
this.origin = request.headers.get("Origin");
|
|
311
|
+
return this.handleRequest(request);
|
|
312
|
+
}
|
|
300
313
|
get(_request) {
|
|
301
314
|
return this.getResponse(NotImplemented);
|
|
302
315
|
}
|
|
@@ -348,8 +361,6 @@ var RoutedWorker = class extends BasicWorker {
|
|
|
348
361
|
super(env, ctx);
|
|
349
362
|
this.addRoutes();
|
|
350
363
|
}
|
|
351
|
-
addRoutes() {
|
|
352
|
-
}
|
|
353
364
|
addRoute(route, callback, method = "GET" /* GET */) {
|
|
354
365
|
if (!isMethod(method)) {
|
|
355
366
|
throw new Error(`Unknown method ${method}`);
|
|
@@ -364,23 +375,12 @@ var RoutedWorker = class extends BasicWorker {
|
|
|
364
375
|
handlers.push({ route, callback: bound });
|
|
365
376
|
this.routes.set(method, handlers);
|
|
366
377
|
}
|
|
367
|
-
async
|
|
368
|
-
|
|
369
|
-
if (!isMethod(method)) {
|
|
370
|
-
throw new Error(`Unsupported method ${method}`);
|
|
371
|
-
}
|
|
372
|
-
if (!this.isAllowed(method)) {
|
|
373
|
-
return this.getResponse(MethodNotAllowed, method);
|
|
374
|
-
}
|
|
375
|
-
let url;
|
|
376
|
-
try {
|
|
377
|
-
url = new URL(request.url);
|
|
378
|
-
} catch {
|
|
379
|
-
return this.getResponse(BadRequest, "Malformed URL");
|
|
380
|
-
}
|
|
381
|
-
return await this.search(request, method, url) ?? super.fetch(request);
|
|
378
|
+
async handleRequest(request) {
|
|
379
|
+
return await this.search(request) ?? super.handleRequest(request);
|
|
382
380
|
}
|
|
383
|
-
async search(request
|
|
381
|
+
async search(request) {
|
|
382
|
+
const method = request.method;
|
|
383
|
+
const url = new URL(request.url);
|
|
384
384
|
const handlers = this.routes.get(method) ?? [];
|
|
385
385
|
const handler = handlers.find(
|
|
386
386
|
({ route }) => route instanceof RegExp ? route.test(url.pathname) : route === url.pathname
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/common.ts","../src/response.ts","../src/basic-worker.ts","../src/routed-worker.ts"],"sourcesContent":["/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { StatusCodes } from \"http-status-codes\";\n\nexport * from \"./common\";\nexport * from \"./response\";\nexport * from \"./basic-worker\";\nexport * from \"./routed-worker\";\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Time = {\n Second: 1,\n Minute: 60,\n Hour: 60 * 60,\n Day: 60 * 60 * 24,\n Week: 60 * 60 * 24 * 7,\n} as const;\n\nexport enum Method {\n GET = \"GET\",\n PUT = \"PUT\",\n POST = \"POST\",\n PATCH = \"PATCH\",\n DELETE = \"DELETE\",\n HEAD = \"HEAD\",\n OPTIONS = \"OPTIONS\",\n}\n\nconst METHOD_SET: Set<string> = new Set(Object.values(Method));\n\nexport function isMethod(value: string): value is Method {\n return METHOD_SET.has(value);\n}\n\nexport function getContentType(type: MimeType): string {\n if (ADD_CHARSET.has(type)) {\n return `${type}; charset=utf-8`;\n }\n return type;\n}\n\nexport enum MimeType {\n PLAIN_TEXT = \"text/plain\",\n HTML = \"text/html\",\n CSS = \"text/css\",\n CSV = \"text/csv\",\n XML = \"text/xml\",\n MARKDOWN = \"text/markdown\",\n RICH_TEXT = \"text/richtext\",\n JSON = \"application/json\",\n XML_APP = \"application/xml\",\n YAML = \"application/x-yaml\",\n FORM_URLENCODED = \"application/x-www-form-urlencoded\",\n NDJSON = \"application/x-ndjson\",\n MSGPACK = \"application/x-msgpack\",\n PROTOBUF = \"application/x-protobuf\",\n MULTIPART_FORM_DATA = \"multipart/form-data\",\n MULTIPART_MIXED = \"multipart/mixed\",\n MULTIPART_ALTERNATIVE = \"multipart/alternative\",\n MULTIPART_DIGEST = \"multipart/digest\",\n MULTIPART_RELATED = \"multipart/related\",\n MULTIPART_SIGNED = \"multipart/signed\",\n MULTIPART_ENCRYPTED = \"multipart/encrypted\",\n OCTET_STREAM = \"application/octet-stream\",\n PDF = \"application/pdf\",\n ZIP = \"application/zip\",\n GZIP = \"application/gzip\",\n MSWORD = \"application/msword\",\n DOCX = \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n EXCEL = \"application/vnd.ms-excel\",\n XLSX = \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n POWERPOINT = \"application/vnd.ms-powerpoint\",\n PPTX = \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n ICO = \"image/x-icon\",\n ICO_MS = \"image/vnd.microsoft.icon\",\n GIF = \"image/gif\",\n PNG = \"image/png\",\n JPEG = \"image/jpeg\",\n WEBP = \"image/webp\",\n SVG = \"image/svg+xml\",\n HEIF = \"image/heif\",\n AVIF = \"image/avif\",\n EVENT_STREAM = \"text/event-stream\",\n TAR = \"application/x-tar\",\n BZIP2 = \"application/x-bzip2\",\n}\n\nconst ADD_CHARSET: Set<MimeType> = new Set([\n MimeType.PLAIN_TEXT,\n MimeType.HTML,\n MimeType.CSS,\n MimeType.CSV,\n MimeType.MARKDOWN,\n MimeType.XML,\n MimeType.JSON,\n MimeType.XML_APP,\n MimeType.FORM_URLENCODED,\n MimeType.NDJSON,\n MimeType.RICH_TEXT,\n MimeType.SVG,\n]);\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getReasonPhrase, StatusCodes } from \"http-status-codes\";\nimport { getContentType, Method, MimeType } from \"./common\";\n\nexport interface CorsProvider {\n getOrigin(): string | null;\n getAllowOrigins(): string[];\n getAllowMethods(): Method[];\n getAllowHeaders(): string[];\n getMaxAge(): number;\n}\n\nexport interface ErrorJson {\n code: number;\n error: string;\n details: string;\n}\n\nexport class WorkerResponse {\n private _headers: Headers = new Headers();\n private _body: BodyInit | null;\n\n constructor(\n protected readonly cors: CorsProvider,\n content: string | null = null,\n protected readonly code: StatusCodes = StatusCodes.OK,\n protected readonly mimeType: MimeType = MimeType.JSON\n ) {\n this._body = this.code === StatusCodes.NO_CONTENT ? null : content;\n }\n\n public createResponse(): Response {\n this.addCorsHeaders();\n if (this.body) {\n this.headers.set(\"Content-Type\", getContentType(this.mimeType));\n }\n return new Response(this.body, this.responseInit);\n }\n\n protected get responseInit(): ResponseInit {\n return {\n headers: this.headers,\n status: this.code,\n statusText: getReasonPhrase(this.code),\n };\n }\n\n protected get body(): BodyInit | null {\n return this._body;\n }\n\n protected get headers(): Headers {\n return this._headers;\n }\n\n protected set headers(headers: Headers) {\n this._headers = headers;\n }\n\n protected addCorsHeaders(): void {\n const origin = this.cors.getOrigin();\n if (!origin) return; // no Origin, skip CORS\n\n if (this.getAllowOrigins().includes(\"*\")) {\n this.headers.set(\"Access-Control-Allow-Origin\", \"*\");\n } else if (this.getAllowOrigins().includes(origin)) {\n this.headers.set(\"Access-Control-Allow-Origin\", origin);\n this.headers.set(\"Access-Control-Allow-Credentials\", \"true\");\n this.headers.set(\"Vary\", \"Origin\");\n }\n this.headers.set(\n \"Access-Control-Allow-Headers\",\n this.getAllowHeaders()\n );\n this.headers.set(\n \"Access-Control-Allow-Methods\",\n this.getAllowMethods()\n );\n this.headers.set(\"Access-Control-Max-Age\", this.getMaxAge());\n this.headers.set(\"X-Content-Type-Options\", \"nosniff\");\n }\n\n protected getAllowMethods(): string {\n return this.cors.getAllowMethods().join(\", \");\n }\n\n protected getAllowHeaders(): string {\n return this.cors.getAllowHeaders().join(\", \");\n }\n\n protected getAllowOrigins(): string[] {\n return this.cors.getAllowOrigins();\n }\n\n protected getMaxAge(): string {\n return String(this.cors.getMaxAge());\n }\n}\n\nexport class JsonResponse extends WorkerResponse {\n private _json: object;\n constructor(\n cors: CorsProvider,\n content: object = {},\n code: StatusCodes = StatusCodes.OK\n ) {\n super(cors, null, code, MimeType.JSON);\n this._json = content;\n }\n\n public get json(): object {\n return this._json;\n }\n\n public set json(json: object) {\n this._json = json;\n }\n\n protected override get body(): string {\n return JSON.stringify(this.json);\n }\n}\n\nexport class HtmlResponse extends WorkerResponse {\n constructor(\n cors: CorsProvider,\n content: string,\n code: StatusCodes = StatusCodes.OK,\n type: MimeType = MimeType.HTML\n ) {\n super(cors, content, code, type);\n }\n}\n\nexport class TextResponse extends WorkerResponse {\n constructor(\n cors: CorsProvider,\n content: string,\n code: StatusCodes = StatusCodes.OK,\n type: MimeType = MimeType.PLAIN_TEXT\n ) {\n super(cors, content, code, type);\n }\n}\n\n/**\n * Remove the body from a GET response.\n */\nexport class Head extends WorkerResponse {\n constructor(cors: CorsProvider, response: Response) {\n super(cors, null, response.status);\n this.headers = new Headers(response.headers);\n }\n}\n\nexport class Options extends WorkerResponse {\n constructor(cors: CorsProvider) {\n super(cors, null, StatusCodes.NO_CONTENT);\n this.headers.set(\"Allow\", this.getAllowMethods());\n }\n}\n\nexport class ErrorResponse extends JsonResponse {\n constructor(\n cors: CorsProvider,\n code: StatusCodes,\n protected details?: string\n ) {\n super(cors, {}, code);\n }\n\n public override get json(): ErrorJson {\n return {\n code: this.code,\n error: getReasonPhrase(this.code),\n details: this.details ?? getReasonPhrase(this.code),\n };\n }\n}\n\nexport class BadRequest extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.BAD_REQUEST, detail);\n }\n}\n\nexport class Unauthorized extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.UNAUTHORIZED, detail);\n }\n}\n\nexport class Forbidden extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.FORBIDDEN, detail);\n }\n}\n\nexport class NotFound extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.NOT_FOUND, detail);\n }\n}\n\nexport class MethodNotAllowed extends ErrorResponse {\n constructor(cors: CorsProvider, method: string) {\n super(\n cors,\n StatusCodes.METHOD_NOT_ALLOWED,\n `${method} method not allowed.`\n );\n this.headers.set(\"Allow\", this.getAllowMethods());\n }\n\n public override get json(): ErrorJson & { allowed: Method[] } {\n return {\n ...super.json,\n allowed: this.cors.getAllowMethods(),\n };\n }\n}\n\nexport class InternalServerError extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.INTERNAL_SERVER_ERROR, detail);\n }\n}\n\nexport class NotImplemented extends ErrorResponse {\n constructor(cors: CorsProvider) {\n super(cors, StatusCodes.NOT_IMPLEMENTED);\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isMethod, Method, Time } from \"./common\";\nimport {\n CorsProvider,\n Head,\n InternalServerError,\n MethodNotAllowed,\n NotImplemented,\n Options,\n WorkerResponse,\n} from \"./response\";\n\nexport class BasicWorker implements CorsProvider {\n private origin: string | null = null;\n\n constructor(\n private readonly _env: Env = {},\n private readonly _ctx?: ExecutionContext\n ) {}\n\n protected get env(): Env {\n return this._env;\n }\n\n protected get ctx(): ExecutionContext | undefined {\n return this._ctx;\n }\n\n public async fetch(request: Request): Promise<Response> {\n if (!this.isAllowed(request.method)) {\n return this.getResponse(MethodNotAllowed, request.method);\n }\n\n this.origin = request.headers.get(\"Origin\");\n\n try {\n switch (request.method) {\n case Method.GET:\n return await this.get(request);\n case Method.PUT:\n return await this.put(request);\n case Method.POST:\n return await this.post(request);\n case Method.PATCH:\n return await this.patch(request);\n case Method.DELETE:\n return await this.delete(request);\n case Method.HEAD:\n return await this.head(request);\n case Method.OPTIONS:\n return await this.options(request);\n default:\n return this.getResponse(MethodNotAllowed, request.method);\n }\n } catch (error) {\n return this.getResponse(InternalServerError, String(error));\n }\n }\n\n protected get(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected put(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected post(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected patch(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected delete(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n private options(_request: Request): Response | Promise<Response> {\n return this.getResponse(Options);\n }\n\n protected async head(request: Request): Promise<Response> {\n return this.getResponse(Head, await this.get(request));\n }\n\n protected getResponse<\n T extends WorkerResponse,\n Ctor extends new (cors: CorsProvider, ...args: any[]) => T\n >(\n ResponseClass: Ctor,\n ...args: ConstructorParameters<Ctor> extends [any, ...infer R]\n ? R\n : never\n ): Response {\n return new ResponseClass(this, ...args).createResponse();\n }\n\n public getAllowOrigins(): string[] {\n return [\"*\"];\n }\n\n public getAllowMethods(): Method[] {\n return [Method.GET, Method.OPTIONS, Method.HEAD];\n }\n\n public isAllowed(method: string): boolean {\n return isMethod(method) && this.getAllowMethods().includes(method);\n }\n\n public getAllowHeaders(): string[] {\n return [\"Content-Type\"];\n }\n\n public getMaxAge(): number {\n return Time.Day;\n }\n\n public getOrigin(): string | null {\n return this.origin;\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BasicWorker } from \"./basic-worker\";\nimport { isMethod, Method } from \"./common\";\nimport {\n BadRequest,\n Head,\n InternalServerError,\n MethodNotAllowed,\n NotFound,\n} from \"./response\";\n\ninterface RouteHandler {\n route: string | RegExp;\n callback: (\n request: Request,\n ...matches: string[]\n ) => Response | Promise<Response>;\n}\n\nexport class RoutedWorker extends BasicWorker {\n private routes: Map<Method, RouteHandler[]> = new Map();\n\n constructor(env: Env = {}, ctx?: ExecutionContext) {\n super(env, ctx);\n this.addRoutes();\n }\n\n protected addRoutes(): void {}\n\n protected addRoute(\n route: string | RegExp,\n callback: (\n request: Request,\n ...matches: string[]\n ) => Response | Promise<Response>,\n method: Method = Method.GET\n ): void {\n if (!isMethod(method)) {\n throw new Error(`Unknown method ${method}`);\n }\n if (!this.getAllowMethods().includes(method)) {\n throw new Error(\n `${method} is not currently allowed. Update or override getAllowedMethods()`\n );\n }\n\n const bound = callback.bind(this);\n const handlers = this.routes.get(method) ?? [];\n handlers.push({ route, callback: bound });\n this.routes.set(method, handlers);\n }\n\n public override async fetch(request: Request): Promise<Response> {\n const method = request.method;\n if (!isMethod(method)) {\n throw new Error(`Unsupported method ${method}`);\n }\n if (!this.isAllowed(method)) {\n return this.getResponse(MethodNotAllowed, method);\n }\n let url: URL;\n try {\n url = new URL(request.url);\n } catch {\n return this.getResponse(BadRequest, \"Malformed URL\");\n }\n\n return (\n (await this.search(request, method, url)) ?? super.fetch(request)\n );\n }\n\n private async search(\n request: Request,\n method: Method,\n url: URL\n ): Promise<Response | undefined> {\n const handlers = this.routes.get(method) ?? [];\n const handler = handlers.find(({ route }) =>\n route instanceof RegExp\n ? route.test(url.pathname)\n : route === url.pathname\n );\n if (handler) {\n try {\n if (handler.route instanceof RegExp) {\n const match = url.pathname.match(handler.route);\n return await handler.callback(request, ...(match ?? []));\n } else {\n return await handler.callback(request);\n }\n } catch (err) {\n return this.getResponse(InternalServerError, String(err));\n }\n }\n return undefined;\n }\n\n protected override async head(request: Request): Promise<Response> {\n return this.getResponse(\n Head,\n await this.fetch(new Request(request, { method: Method.GET }))\n );\n }\n\n protected override get(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override put(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override post(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override patch(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override delete(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n}\n"],"mappings":";AAgBA,SAAS,eAAAA,oBAAmB;;;ACArB,IAAM,OAAO;AAAA,EAChB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM,KAAK;AAAA,EACX,KAAK,KAAK,KAAK;AAAA,EACf,MAAM,KAAK,KAAK,KAAK;AACzB;AAEO,IAAK,SAAL,kBAAKC,YAAL;AACH,EAAAA,QAAA,SAAM;AACN,EAAAA,QAAA,SAAM;AACN,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,WAAQ;AACR,EAAAA,QAAA,YAAS;AACT,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,aAAU;AAPF,SAAAA;AAAA,GAAA;AAUZ,IAAM,aAA0B,IAAI,IAAI,OAAO,OAAO,MAAM,CAAC;AAEtD,SAAS,SAAS,OAAgC;AACrD,SAAO,WAAW,IAAI,KAAK;AAC/B;AAEO,SAAS,eAAe,MAAwB;AACnD,MAAI,YAAY,IAAI,IAAI,GAAG;AACvB,WAAO,GAAG,IAAI;AAAA,EAClB;AACA,SAAO;AACX;AAEO,IAAK,WAAL,kBAAKC,cAAL;AACH,EAAAA,UAAA,gBAAa;AACb,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,SAAM;AACN,EAAAA,UAAA,SAAM;AACN,EAAAA,UAAA,SAAM;AACN,EAAAA,UAAA,cAAW;AACX,EA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ACJ,SAAS,KAAK;AACV,eAAO,KAAK,YAAY,qBAAqB,OAAO,GAAG,CAAC;AAAA,MAC5D;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAAA,EAEA,MAAyB,KAAK,SAAqC;AAC/D,WAAO,KAAK;AAAA,MACR;AAAA,MACA,MAAM,KAAK,MAAM,IAAI,QAAQ,SAAS,EAAE,wBAAmB,CAAC,CAAC;AAAA,IACjE;AAAA,EACJ;AAAA,EAEmB,MAAoC;AACnD,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEmB,MAAoC;AACnD,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEmB,OAAqC;AACpD,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEmB,QAAsC;AACrD,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEmB,SAAuC;AACtD,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AACJ;","names":["StatusCodes","Method","MimeType"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/common.ts","../src/response.ts","../src/basic-worker.ts","../src/routed-worker.ts"],"sourcesContent":["/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { StatusCodes } from \"http-status-codes\";\n\nexport * from \"./common\";\nexport * from \"./response\";\nexport * from \"./basic-worker\";\nexport * from \"./routed-worker\";\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Time = {\n Second: 1,\n Minute: 60,\n Hour: 60 * 60,\n Day: 60 * 60 * 24,\n Week: 60 * 60 * 24 * 7,\n} as const;\n\nexport enum Method {\n GET = \"GET\",\n PUT = \"PUT\",\n POST = \"POST\",\n PATCH = \"PATCH\",\n DELETE = \"DELETE\",\n HEAD = \"HEAD\",\n OPTIONS = \"OPTIONS\",\n}\n\nconst METHOD_SET: Set<string> = new Set(Object.values(Method));\n\nexport function isMethod(value: string): value is Method {\n return METHOD_SET.has(value);\n}\n\nexport function getContentType(type: MimeType): string {\n if (ADD_CHARSET.has(type)) {\n return `${type}; charset=utf-8`;\n }\n return type;\n}\n\nexport enum MimeType {\n PLAIN_TEXT = \"text/plain\",\n HTML = \"text/html\",\n CSS = \"text/css\",\n CSV = \"text/csv\",\n XML = \"text/xml\",\n MARKDOWN = \"text/markdown\",\n RICH_TEXT = \"text/richtext\",\n JSON = \"application/json\",\n XML_APP = \"application/xml\",\n YAML = \"application/x-yaml\",\n FORM_URLENCODED = \"application/x-www-form-urlencoded\",\n NDJSON = \"application/x-ndjson\",\n MSGPACK = \"application/x-msgpack\",\n PROTOBUF = \"application/x-protobuf\",\n MULTIPART_FORM_DATA = \"multipart/form-data\",\n MULTIPART_MIXED = \"multipart/mixed\",\n MULTIPART_ALTERNATIVE = \"multipart/alternative\",\n MULTIPART_DIGEST = \"multipart/digest\",\n MULTIPART_RELATED = \"multipart/related\",\n MULTIPART_SIGNED = \"multipart/signed\",\n MULTIPART_ENCRYPTED = \"multipart/encrypted\",\n OCTET_STREAM = \"application/octet-stream\",\n PDF = \"application/pdf\",\n ZIP = \"application/zip\",\n GZIP = \"application/gzip\",\n MSWORD = \"application/msword\",\n DOCX = \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n EXCEL = \"application/vnd.ms-excel\",\n XLSX = \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n POWERPOINT = \"application/vnd.ms-powerpoint\",\n PPTX = \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n ICO = \"image/x-icon\",\n ICO_MS = \"image/vnd.microsoft.icon\",\n GIF = \"image/gif\",\n PNG = \"image/png\",\n JPEG = \"image/jpeg\",\n WEBP = \"image/webp\",\n SVG = \"image/svg+xml\",\n HEIF = \"image/heif\",\n AVIF = \"image/avif\",\n EVENT_STREAM = \"text/event-stream\",\n TAR = \"application/x-tar\",\n BZIP2 = \"application/x-bzip2\",\n}\n\nconst ADD_CHARSET: Set<MimeType> = new Set([\n MimeType.PLAIN_TEXT,\n MimeType.HTML,\n MimeType.CSS,\n MimeType.CSV,\n MimeType.MARKDOWN,\n MimeType.XML,\n MimeType.JSON,\n MimeType.XML_APP,\n MimeType.FORM_URLENCODED,\n MimeType.NDJSON,\n MimeType.RICH_TEXT,\n MimeType.SVG,\n]);\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getReasonPhrase, StatusCodes } from \"http-status-codes\";\nimport { getContentType, Method, MimeType } from \"./common\";\n\nexport interface CorsProvider {\n getOrigin(): string | null;\n getAllowOrigins(): string[];\n getAllowMethods(): Method[];\n getAllowHeaders(): string[];\n getMaxAge(): number;\n}\n\nexport interface ErrorJson {\n code: number;\n error: string;\n details: string;\n}\n\nexport class WorkerResponse {\n private _headers: Headers = new Headers();\n private _body: BodyInit | null;\n\n constructor(\n protected readonly cors: CorsProvider,\n content: string | null = null,\n protected readonly code: StatusCodes = StatusCodes.OK,\n protected readonly mimeType: MimeType = MimeType.JSON\n ) {\n this._body = this.code === StatusCodes.NO_CONTENT ? null : content;\n }\n\n public createResponse(): Response {\n this.addCorsHeaders();\n if (this.body) {\n this.headers.set(\"Content-Type\", getContentType(this.mimeType));\n }\n return new Response(this.body, this.responseInit);\n }\n\n protected get responseInit(): ResponseInit {\n return {\n headers: this.headers,\n status: this.code,\n statusText: getReasonPhrase(this.code),\n };\n }\n\n protected get body(): BodyInit | null {\n return this._body;\n }\n\n protected get headers(): Headers {\n return this._headers;\n }\n\n protected set headers(headers: Headers) {\n this._headers = headers;\n }\n\n protected addCorsHeaders(): void {\n const origin = this.cors.getOrigin();\n if (!origin) return; // no Origin, skip CORS\n\n if (this.getAllowOrigins().includes(\"*\")) {\n this.headers.set(\"Access-Control-Allow-Origin\", \"*\");\n } else if (this.getAllowOrigins().includes(origin)) {\n this.headers.set(\"Access-Control-Allow-Origin\", origin);\n this.headers.set(\"Access-Control-Allow-Credentials\", \"true\");\n this.headers.set(\"Vary\", \"Origin\");\n }\n this.headers.set(\n \"Access-Control-Allow-Headers\",\n this.getAllowHeaders()\n );\n this.headers.set(\n \"Access-Control-Allow-Methods\",\n this.getAllowMethods()\n );\n this.headers.set(\"Access-Control-Max-Age\", this.getMaxAge());\n this.headers.set(\"X-Content-Type-Options\", \"nosniff\");\n }\n\n protected getAllowMethods(): string {\n return this.cors.getAllowMethods().join(\", \");\n }\n\n protected getAllowHeaders(): string {\n return this.cors.getAllowHeaders().join(\", \");\n }\n\n protected getAllowOrigins(): string[] {\n return this.cors.getAllowOrigins();\n }\n\n protected getMaxAge(): string {\n return String(this.cors.getMaxAge());\n }\n}\n\nexport class JsonResponse extends WorkerResponse {\n private _json: object;\n constructor(\n cors: CorsProvider,\n content: object = {},\n code: StatusCodes = StatusCodes.OK\n ) {\n super(cors, null, code, MimeType.JSON);\n this._json = content;\n }\n\n public get json(): object {\n return this._json;\n }\n\n public set json(json: object) {\n this._json = json;\n }\n\n protected override get body(): string {\n return JSON.stringify(this.json);\n }\n}\n\nexport class HtmlResponse extends WorkerResponse {\n constructor(\n cors: CorsProvider,\n content: string,\n code: StatusCodes = StatusCodes.OK,\n type: MimeType = MimeType.HTML\n ) {\n super(cors, content, code, type);\n }\n}\n\nexport class TextResponse extends WorkerResponse {\n constructor(\n cors: CorsProvider,\n content: string,\n code: StatusCodes = StatusCodes.OK,\n type: MimeType = MimeType.PLAIN_TEXT\n ) {\n super(cors, content, code, type);\n }\n}\n\n/**\n * Remove the body from a GET response.\n */\nexport class Head extends WorkerResponse {\n constructor(cors: CorsProvider, response: Response) {\n super(cors, null, response.status);\n this.headers = new Headers(response.headers);\n }\n}\n\nexport class Options extends WorkerResponse {\n constructor(cors: CorsProvider) {\n super(cors, null, StatusCodes.NO_CONTENT);\n this.headers.set(\"Allow\", this.getAllowMethods());\n }\n}\n\nexport class ErrorResponse extends JsonResponse {\n constructor(\n cors: CorsProvider,\n code: StatusCodes,\n protected details?: string\n ) {\n super(cors, {}, code);\n }\n\n public override get json(): ErrorJson {\n return {\n code: this.code,\n error: getReasonPhrase(this.code),\n details: this.details ?? getReasonPhrase(this.code),\n };\n }\n}\n\nexport class BadRequest extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.BAD_REQUEST, detail);\n }\n}\n\nexport class Unauthorized extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.UNAUTHORIZED, detail);\n }\n}\n\nexport class Forbidden extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.FORBIDDEN, detail);\n }\n}\n\nexport class NotFound extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.NOT_FOUND, detail);\n }\n}\n\nexport class MethodNotAllowed extends ErrorResponse {\n constructor(cors: CorsProvider, method: string) {\n super(\n cors,\n StatusCodes.METHOD_NOT_ALLOWED,\n `${method} method not allowed.`\n );\n this.headers.set(\"Allow\", this.getAllowMethods());\n }\n\n public override get json(): ErrorJson & { allowed: Method[] } {\n return {\n ...super.json,\n allowed: this.cors.getAllowMethods(),\n };\n }\n}\n\nexport class InternalServerError extends ErrorResponse {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.INTERNAL_SERVER_ERROR, detail);\n }\n}\n\nexport class NotImplemented extends ErrorResponse {\n constructor(cors: CorsProvider) {\n super(cors, StatusCodes.NOT_IMPLEMENTED);\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isMethod, Method, Time } from \"./common\";\nimport {\n BadRequest,\n CorsProvider,\n Head,\n InternalServerError,\n MethodNotAllowed,\n NotImplemented,\n Options,\n WorkerResponse,\n} from \"./response\";\n\nexport class BasicWorker implements CorsProvider {\n private origin: string | null = null;\n\n constructor(\n private readonly _env: Env = {},\n private readonly _ctx?: ExecutionContext\n ) {}\n\n protected get env(): Env {\n return this._env;\n }\n\n protected get ctx(): ExecutionContext | undefined {\n return this._ctx;\n }\n\n protected async handleRequest(request: Request): Promise<Response> {\n const method = request.method as Method;\n try {\n switch (method) {\n case Method.GET:\n return await this.get(request);\n case Method.PUT:\n return await this.put(request);\n case Method.POST:\n return await this.post(request);\n case Method.PATCH:\n return await this.patch(request);\n case Method.DELETE:\n return await this.delete(request);\n case Method.HEAD:\n return await this.head(request);\n case Method.OPTIONS:\n return await this.options(request);\n default:\n return this.getResponse(MethodNotAllowed, method);\n }\n } catch (error) {\n return this.getResponse(InternalServerError, String(error));\n }\n }\n\n public async fetch(request: Request): Promise<Response> {\n const method = request.method;\n if (!isMethod(method)) {\n throw new Error(`Unsupported method ${method}`);\n }\n\n if (!this.isAllowed(method)) {\n return this.getResponse(MethodNotAllowed, method);\n }\n\n try {\n new URL(request.url);\n } catch {\n return this.getResponse(BadRequest, \"Malformed URL\");\n }\n\n this.origin = request.headers.get(\"Origin\");\n\n return this.handleRequest(request);\n }\n\n protected get(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected put(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected post(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected patch(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected delete(_request: Request): Response | Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n private options(_request: Request): Response | Promise<Response> {\n return this.getResponse(Options);\n }\n\n protected async head(request: Request): Promise<Response> {\n return this.getResponse(Head, await this.get(request));\n }\n\n protected getResponse<\n T extends WorkerResponse,\n Ctor extends new (cors: CorsProvider, ...args: any[]) => T\n >(\n ResponseClass: Ctor,\n ...args: ConstructorParameters<Ctor> extends [any, ...infer R]\n ? R\n : never\n ): Response {\n return new ResponseClass(this, ...args).createResponse();\n }\n\n public getAllowOrigins(): string[] {\n return [\"*\"];\n }\n\n public getAllowMethods(): Method[] {\n return [Method.GET, Method.OPTIONS, Method.HEAD];\n }\n\n public isAllowed(method: string): boolean {\n return isMethod(method) && this.getAllowMethods().includes(method);\n }\n\n public getAllowHeaders(): string[] {\n return [\"Content-Type\"];\n }\n\n public getMaxAge(): number {\n return Time.Day;\n }\n\n public getOrigin(): string | null {\n return this.origin;\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BasicWorker } from \"./basic-worker\";\nimport { isMethod, Method } from \"./common\";\nimport { Head, InternalServerError, NotFound } from \"./response\";\n\ninterface RouteHandler {\n route: string | RegExp;\n callback: (\n request: Request,\n ...matches: string[]\n ) => Response | Promise<Response>;\n}\n\nexport abstract class RoutedWorker extends BasicWorker {\n private routes: Map<Method, RouteHandler[]> = new Map();\n\n constructor(env: Env = {}, ctx?: ExecutionContext) {\n super(env, ctx);\n this.addRoutes();\n }\n\n protected abstract addRoutes(): void;\n\n protected addRoute(\n route: string | RegExp,\n callback: (\n request: Request,\n ...matches: string[]\n ) => Response | Promise<Response>,\n method: Method = Method.GET\n ): void {\n if (!isMethod(method)) {\n throw new Error(`Unknown method ${method}`);\n }\n if (!this.getAllowMethods().includes(method)) {\n throw new Error(\n `${method} is not currently allowed. Update or override getAllowedMethods()`\n );\n }\n\n const bound = callback.bind(this);\n const handlers = this.routes.get(method) ?? [];\n handlers.push({ route, callback: bound });\n this.routes.set(method, handlers);\n }\n\n protected async handleRequest(request: Request): Promise<Response> {\n return (await this.search(request)) ?? super.handleRequest(request);\n }\n\n private async search(request: Request): Promise<Response | undefined> {\n const method = request.method as Method;\n const url = new URL(request.url);\n const handlers = this.routes.get(method) ?? [];\n const handler = handlers.find(({ route }) =>\n route instanceof RegExp\n ? route.test(url.pathname)\n : route === url.pathname\n );\n if (handler) {\n try {\n if (handler.route instanceof RegExp) {\n const match = url.pathname.match(handler.route);\n return await handler.callback(request, ...(match ?? []));\n } else {\n return await handler.callback(request);\n }\n } catch (err) {\n return this.getResponse(InternalServerError, String(err));\n }\n }\n return undefined;\n }\n\n protected override async head(request: Request): Promise<Response> {\n return this.getResponse(\n Head,\n await this.fetch(new Request(request, { method: Method.GET }))\n );\n }\n\n protected override get(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override put(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override post(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override patch(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override delete(): Response | Promise<Response> {\n return this.getResponse(NotFound);\n }\n}\n"],"mappings":";AAgBA,SAAS,eAAAA,oBAAmB;;;ACArB,IAAM,OAAO;AAAA,EAChB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM,KAAK;AAAA,EACX,KAAK,KAAK,KAAK;AAAA,EACf,MAAM,KAAK,KAAK,KAAK;AACzB;AAEO,IAAK,SAAL,kBAAKC,YAAL;AACH,EAAAA,QAAA,SAAM;AACN,EAAAA,QAAA,SAAM;AACN,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,WAAQ;AACR,EAAAA,QAAA,YAAS;AACT,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,aAAU;AAPF,SAAAA;AAAA,GAAA;AAUZ,IAAM,aAA0B,IAAI,IAAI,OAAO,OAAO,MAAM,CAAC;AAEtD,SAAS,SAAS,OAAgC;AACrD,SAAO,WAAW,IAAI,KAAK;AAC/B;AAEO,SAAS,eAAe,MAAwB;AACnD,MAAI,YAAY,IAAI,IAAI,GAAG;AACvB,WAAO,GAAG,IAAI;AAAA,EAClB;AACA,SAAO;AACX;AAEO,IAAK,WAAL,kBAAKC,cAAL;AACH,EAAAA,UAAA,gBAAa;AACb,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,SAAM;AACN,EAAAA,UAAA,SAAM;AACN,EAAAA,UAAA,SAAM;AACN,EAAAA,UAAA,cAAW;AACX,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,aAAU;AACV,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,qBAAkB;AAClB,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,aAAU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