@squarecloud/blob
Version:
Official Square Cloud Blob SDK for NodeJS
1 lines • 26.3 kB
Source Map (JSON)
{"version":3,"sources":["../../src/utils/mimetype/mimetypes.ts","../../src/utils/mimetype/index.ts","../../src/structures/error.ts","../../src/utils/object-url.ts","../../src/structures/object.ts","../../src/utils/path-like.ts","../../src/validation/schemas/create.ts","../../src/validation/schemas/common.ts","../../src/validation/assertions/handlers.ts","../../src/validation/assertions/create.ts","../../src/validation/schemas/list.ts","../../src/validation/assertions/list.ts","../../src/managers/objects.ts","../../src/validation/schemas/stats.ts","../../src/validation/assertions/stats.ts","../../src/index.ts","../../src/managers/api.ts"],"sourcesContent":["export const mimeTypesWithExtension = {\n\t\"video/mp4\": [\"mp4\"],\n\t\"video/mpeg\": [\"mpeg\"],\n\t\"video/webm\": [\"webm\"],\n\t\"video/x-flv\": [\"flv\"],\n\t\"video/x-m4v\": [\"m4v\"],\n\t\"image/jpeg\": [\"jpg\", \"jpeg\"],\n\t\"image/png\": [\"png\"],\n\t\"image/apng\": [\"apng\"],\n\t\"image/tiff\": [\"tiff\"],\n\t\"image/gif\": [\"gif\"],\n\t\"image/webp\": [\"webp\"],\n\t\"image/bmp\": [\"bmp\"],\n\t\"image/svg+xml\": [\"svg\"],\n\t\"image/x-icon\": [\"ico\"],\n\t\"image/ico\": [\"ico\"],\n\t\"image/cur\": [\"cur\"],\n\t\"image/heic\": [\"heic\"],\n\t\"image/heif\": [\"heif\"],\n\t\"audio/wav\": [\"wav\"],\n\t\"audio/ogg\": [\"ogg\"],\n\t\"audio/opus\": [\"opus\"],\n\t\"audio/mp4\": [\"mp4\"],\n\t\"audio/mpeg\": [\"mp3\"],\n\t\"audio/aac\": [\"aac\"],\n\t\"text/plain\": [\"txt\"],\n\t\"text/html\": [\"html\"],\n\t\"text/css\": [\"css\"],\n\t\"text/csv\": [\"csv\"],\n\t\"text/x-sql\": [\"sql\"],\n\t\"application/xml\": [\"xml\"],\n\t\"application/sql\": [\"sql\"],\n\t\"application/x-sql\": [\"sql\"],\n\t\"application/x-sqlite3\": [\"sqlite3\"],\n\t\"application/x-pkcs12\": [\"pfx\"],\n\t\"application/pdf\": [\"pdf\"],\n\t\"application/json\": [\"json\"],\n\t\"application/javascript\": [\"js\"],\n};\n\nexport const mimeTypes = Object.keys(mimeTypesWithExtension) as [\n\tMimeType,\n\t...MimeType[],\n];\n\nexport type MimeType = keyof typeof mimeTypesWithExtension;\n","import { type MimeType, mimeTypes, mimeTypesWithExtension } from \"./mimetypes\";\n\n// biome-ignore lint/complexity/noStaticOnlyClass: organization\nexport class MimeTypeUtil {\n\t/** Supported mime types with their extensions */\n\tstatic mimeTypesWithExtension = mimeTypesWithExtension;\n\t/** All supported mime types */\n\tstatic mimeTypes = mimeTypes;\n\n\t/**\n\t * Returns the corresponding MIME type for a given file extension.\n\t *\n\t * @param extension - The file extension to search for.\n\t * @return The MIME type associated with the extension, or \"text/plain\" if not found.\n\t *\n\t * @example\n\t * ```js\n\t * \tMimeTypeUtil.fromExtension(\"jpeg\") // \"image/jpeg\" | Supported\n\t * \tMimeTypeUtil.fromExtension(\"json\") // \"application/json\" | Supported\n\t * \tMimeTypeUtil.fromExtension(\"potato\") // \"text/plain\" | Unsupported, defaults to text/plain\n\t * ```\n\t */\n\tstatic fromExtension(extension: string): MimeType {\n\t\tconst entries = Object.entries(mimeTypesWithExtension);\n\t\tconst mimeType = entries.find(([, extensions]) =>\n\t\t\textensions.includes(extension),\n\t\t)?.[0];\n\n\t\treturn (mimeType as MimeType) || \"text/plain\";\n\t}\n}\n\nexport * from \"./enum\";\nexport { MimeType } from \"./mimetypes\";\n","export class SquareCloudBlobError extends Error {\n\tconstructor(code: string, message?: string, cause?: unknown) {\n\t\tsuper(message, { cause });\n\n\t\tthis.name = SquareCloudBlobError.name;\n\t\tthis.message = this.getMessage(code);\n\t}\n\n\tprivate getMessage(rawCode: string) {\n\t\tconst code = rawCode\n\t\t\t.replaceAll(\"_\", \" \")\n\t\t\t.toLowerCase()\n\t\t\t.replace(/(^|\\s)\\S/g, (L) => L.toUpperCase());\n\t\tconst message = this.message ? `: ${this.message}` : \"\";\n\n\t\treturn `${code}${message}`;\n\t}\n}\n\nexport class SquareCloudValidationError extends SquareCloudBlobError {\n\tconstructor(...args: ConstructorParameters<typeof SquareCloudBlobError>) {\n\t\tsuper(...args);\n\t\tthis.name = SquareCloudValidationError.name;\n\t}\n}\n","import { SquareCloudBlobError } from \"../structures/error\";\n\nconst objectUrlRegex =\n\t/^(?<url>https:\\/\\/public-blob\\.squarecloud\\.dev)?\\/?(?<userId>\\d+\\/)(?<prefix>[\\w\\d-_]+\\/)?(?<name>[\\w\\d_]+)-(?<hash>[\\w\\d]+)\\.(?<extension>\\w+)$/;\n\n/**\n * Parses the object URL to extract id, userId, prefix, name, hash and extension.\n *\n * @param url - The object URL to parse.\n */\nexport function parseObjectUrl(url: string) {\n\tconst match = url.match(objectUrlRegex);\n\n\tif (!match?.groups) {\n\t\tthrow new SquareCloudBlobError(\"Invalid object URL\");\n\t}\n\n\tconst payload = {\n\t\tuserId: match.groups.userId.replace(\"/\", \"\"),\n\t\tprefix: match.groups.prefix?.replace(\"/\", \"\"),\n\t\tname: match.groups.name,\n\t\thash: match.groups.hash,\n\t\textension: match.groups.extension,\n\t};\n\n\treturn {\n\t\tid: `${payload.userId}/${payload.prefix ? `${payload.prefix}/` : \"\"}${\n\t\t\tpayload.name\n\t\t}-${payload.hash}.${payload.extension}`,\n\t\t...payload,\n\t};\n}\n","import type { BlobObjectData } from \"../types/object\";\nimport { type MimeType, MimeTypeUtil } from \"../utils/mimetype\";\nimport { parseObjectUrl } from \"../utils/object-url\";\n\nexport class BlobObject {\n\t/** The id of the object */\n\tid: string;\n\t/** The url to view or download the object */\n\turl: string;\n\t/** The name of the object */\n\tname: string;\n\t/** The prefix of the object (Optional) */\n\tprefix?: string;\n\t/** The hash of the object */\n\thash: string;\n\t/** The id of the user who created the object */\n\tuserId: string;\n\t/** The file extension of the object */\n\textension: string;\n\t/** The MIME type of the object */\n\tmimeType: MimeType;\n\t/** The size of the object in bytes */\n\tsize: number;\n\t/** The expiration date of the object (Only available using `objects.list`) */\n\texpiresAt?: Date;\n\t/** The creation date of the object (Only available using `objects.list`) */\n\tcreatedAt?: Date;\n\n\tconstructor(data: BlobObjectData) {\n\t\tconst { id, name, prefix, hash, userId, extension } = parseObjectUrl(\n\t\t\tdata.idOrUrl,\n\t\t);\n\n\t\tthis.id = id;\n\t\tthis.url = `https://public-blob.squarecloud.dev/${id}`;\n\t\tthis.name = name;\n\t\tthis.prefix = prefix;\n\t\tthis.hash = hash;\n\t\tthis.userId = userId;\n\t\tthis.extension = extension;\n\t\tthis.mimeType = MimeTypeUtil.fromExtension(extension);\n\t\tthis.size = data.size;\n\t\tthis.expiresAt = data.expiresAt;\n\t\tthis.createdAt = data.createdAt;\n\t}\n}\n","import { readFile } from \"fs/promises\";\nimport { SquareCloudBlobError } from \"../structures/error\";\n\nexport async function parsePathLike(\n\tpathLike: string | Buffer,\n): Promise<Buffer> {\n\tif (typeof pathLike === \"string\") {\n\t\tconst fileBuffer = await readFile(pathLike).catch(() => undefined);\n\n\t\tif (!fileBuffer) {\n\t\t\tthrow new SquareCloudBlobError(\"INVALID_FILE\", \"File not found\");\n\t\t}\n\n\t\treturn fileBuffer;\n\t}\n\n\treturn pathLike;\n}\n","import { z } from \"zod\";\nimport { MimeTypeUtil } from \"../../utils/mimetype\";\nimport { nameLikeSchema } from \"./common\";\n\nexport const createObjectSchema = z\n\t.object({\n\t\t/** A string representing the name for the file. */\n\t\tname: nameLikeSchema,\n\t\t/** Use absolute path, Buffer or Blob */\n\t\tfile: z.string().or(z.instanceof(Buffer)),\n\t\t/** A string representing the MIME type of the file. */\n\t\tmimeType: z.enum(MimeTypeUtil.mimeTypes).optional(),\n\t\t/** A string representing the prefix for the file. */\n\t\tprefix: nameLikeSchema.optional(),\n\t\t/** A number indicating the expiration period of the file, ranging from 1 to 365 days. */\n\t\texpiresIn: z.number().min(1).max(365).optional(),\n\t\t/** Set to true if a security hash is required. */\n\t\tsecurityHash: z.boolean().optional(),\n\t\t/** Set to true if the file should be set for automatic download. */\n\t\tautoDownload: z.boolean().optional(),\n\t})\n\t.refine(({ file, mimeType }) => !(file instanceof Buffer && !mimeType), {\n\t\tmessage: \"mimeType is required if file is a Buffer\",\n\t\tpath: [\"mimeType\"],\n\t});\n\nexport const createObjectPayloadSchema = createObjectSchema.transform(\n\t({ file, securityHash, autoDownload, expiresIn, ...rest }) => ({\n\t\tfile,\n\t\tmimeType:\n\t\t\ttypeof file === \"string\"\n\t\t\t\t? MimeTypeUtil.fromExtension(file.split(\".\")[1])\n\t\t\t\t: undefined,\n\t\tparams: {\n\t\t\t...rest,\n\t\t\texpire: expiresIn,\n\t\t\tsecurity_hash: securityHash,\n\t\t\tauto_download: autoDownload,\n\t\t},\n\t}),\n);\n\nexport const createObjectResponseSchema = z.object({\n\t/** The id of the uploaded file. */\n\tid: z.string(),\n\t/** The name of the uploaded file. */\n\tname: z.string(),\n\t/** The prefix of the uploaded file. */\n\tprefix: z.string().optional(),\n\t/** The size of the uploaded file. */\n\tsize: z.number(),\n\t/** The URL of the uploaded file. (File distributed in Square Cloud CDN) */\n\turl: z.string(),\n});\n","import { z } from \"zod\";\n\nexport const stringSchema = z.string();\n\nexport const nameLikeSchema = z\n\t.string()\n\t.min(3)\n\t.max(32)\n\t.regex(/^[a-zA-Z0-9_]{3,32}$/, {\n\t\tmessage: \"Name must contain only letters, numbers and _\",\n\t});\n","import type { ZodIssue } from \"zod\";\nimport {\n\tSquareCloudBlobError,\n\tSquareCloudValidationError,\n} from \"../../structures/error\";\nimport type {\n\tAPIObjectAssertionProps,\n\tLiteralAssertionProps,\n} from \"../../types/assertions\";\n\nexport function handleLiteralAssertion({\n\tschema,\n\tvalue,\n\texpect,\n\tcode,\n}: LiteralAssertionProps) {\n\ttry {\n\t\tschema.parse(value);\n\t} catch {\n\t\tthrow new SquareCloudValidationError(\n\t\t\tcode ? `INVALID_${code}` : \"VALIDATION_ERROR\",\n\t\t\t`Expect ${expect}, got ${typeof value}`,\n\t\t);\n\t}\n}\n\nexport function handleAPIObjectAssertion({\n\tschema,\n\tvalue,\n\tcode,\n}: APIObjectAssertionProps) {\n\tconst name = code.toLowerCase().replaceAll(\"_\", \" \");\n\n\ttry {\n\t\treturn schema.parse(value);\n\t} catch (err) {\n\t\tconst cause = err.errors?.map((err: ZodIssue) => ({\n\t\t\t...err,\n\t\t\tpath: err.path.join(\" > \"),\n\t\t}));\n\n\t\tthrow new SquareCloudBlobError(\n\t\t\t`INVALID_API_${code}`,\n\t\t\t`Invalid ${name} object received from API`,\n\t\t\t{ cause },\n\t\t);\n\t}\n}\n","import type { CreateObjectResponse } from \"../../types/create\";\nimport { createObjectResponseSchema } from \"../schemas/create\";\nimport { handleAPIObjectAssertion } from \"./handlers\";\n\nexport function assertCreateObjectResponse(\n\tvalue: unknown,\n): CreateObjectResponse {\n\treturn handleAPIObjectAssertion({\n\t\tschema: createObjectResponseSchema,\n\t\tcode: \"CREATE_OBJECT\",\n\t\tvalue,\n\t});\n}\n","import { z } from \"zod\";\n\nexport const listObjectsSchema = z.object({\n\t/** Filter by prefix */\n\tprefix: z.string().optional(),\n\t/** Return objects after this token */\n\tcontinuationToken: z.string().optional(),\n});\n\nexport const listObjectsPayloadSchema = listObjectsSchema\n\t.optional()\n\t.transform((params) => ({ params }));\n\nexport const listObjectResponseSchema = z.object({\n\tid: z.string(),\n\tsize: z.number(),\n\tcreated_at: z.coerce.date(),\n\texpires_at: z.coerce.date().optional(),\n});\n\nexport const listObjectsResponseSchema = z.object({\n\tobjects: z.array(listObjectResponseSchema).default([]),\n});\n","import type { ListObjectsResponse } from \"../../types/list\";\nimport { listObjectsResponseSchema } from \"../schemas/list\";\nimport { handleAPIObjectAssertion } from \"./handlers\";\n\nexport function assertListObjectsResponse(value: unknown): ListObjectsResponse {\n\treturn handleAPIObjectAssertion({\n\t\tschema: listObjectsResponseSchema,\n\t\tcode: \"LIST_OBJECTS\",\n\t\tvalue,\n\t});\n}\n","import type { SquareCloudBlob } from \"..\";\nimport { BlobObject } from \"../structures/object\";\nimport type { CreateObjectResponse, CreateObjectType } from \"../types/create\";\nimport type { ListObjectsResponse, ListObjectsType } from \"../types/list\";\nimport { parsePathLike } from \"../utils/path-like\";\nimport { assertCreateObjectResponse } from \"../validation/assertions/create\";\nimport { assertListObjectsResponse } from \"../validation/assertions/list\";\nimport { createObjectPayloadSchema } from \"../validation/schemas/create\";\nimport { listObjectsPayloadSchema } from \"../validation/schemas/list\";\n\nexport class ObjectsManager {\n\tconstructor(private readonly client: SquareCloudBlob) {}\n\n\t/**\n\t * Lists all objects in the storage.\n\t *\n\t * @example\n\t * ```js\n\t * blob.objects.list();\n\t * ```\n\t */\n\tasync list(options?: ListObjectsType) {\n\t\tconst payload = listObjectsPayloadSchema.parse(options);\n\n\t\tconst { response } = await this.client.api.request<ListObjectsResponse>(\n\t\t\t\"objects\",\n\t\t\t{ params: payload.params },\n\t\t);\n\t\tconst { objects } = assertListObjectsResponse(response);\n\n\t\treturn objects.map((objectData) => {\n\t\t\tconst createdAt = new Date(objectData.created_at);\n\t\t\tconst expiresAt = objectData.expires_at\n\t\t\t\t? new Date(objectData.expires_at)\n\t\t\t\t: undefined;\n\n\t\t\treturn new BlobObject({\n\t\t\t\tidOrUrl: objectData.id,\n\t\t\t\tsize: objectData.size,\n\t\t\t\tcreatedAt,\n\t\t\t\texpiresAt,\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Uploads an object to the storage.\n\t *\n\t * @param object - An object to upload\n\t *\n\t * @example\n\t * ```js\n\t * // Basic usage with absolute path\n\t * blob.objects.create({\n\t * \tfile: \"path/to/file.jpeg\",\n\t * \tname: \"my_image\"\n\t * });\n\t *\n\t * // Advanced usage with Buffer\n\t * blob.objects.create({\n\t * \tfile: Buffer.from(\"content\"),\n\t * \tname: \"my_image\",\n\t * \tmimeType: \"image/jpeg\"\n\t * })\n\t * ```\n\t */\n\tasync create(object: CreateObjectType) {\n\t\tconst payload = createObjectPayloadSchema.parse(object);\n\t\tconst file = await parsePathLike(payload.file);\n\t\tconst type = payload.mimeType || object.mimeType;\n\n\t\tconst formData = new FormData();\n\t\tformData.append(\"file\", new Blob([file], { type }));\n\n\t\tconst { response } = await this.client.api.request<CreateObjectResponse>(\n\t\t\t\"objects\",\n\t\t\t{ method: \"POST\", body: formData, params: payload.params },\n\t\t);\n\n\t\tconst objectData = assertCreateObjectResponse(response);\n\n\t\treturn new BlobObject({\n\t\t\tidOrUrl: objectData.id,\n\t\t\tsize: objectData.size,\n\t\t});\n\t}\n\n\t/**\n\t * Delete an object from the storage.\n\t *\n\t * @param object - An array of object IDs\n\t *\n\t * @example\n\t * ```js\n\t * blob.object.delete(\"userId/prefix/name1_xxx-xxx.mp4\");\n\t * ```\n\t */\n\tasync delete(object: string) {\n\t\tconst { status } = await this.client.api.request(\"objects\", {\n\t\t\tmethod: \"DELETE\",\n\t\t\tbody: { object },\n\t\t});\n\n\t\treturn status === \"success\";\n\t}\n}\n","import { z } from \"zod\";\n\nexport const statsResponseSchema = z.object({\n\t/** The total number of objects in your account. */\n\tobjects: z.number(),\n\t/** The total size of all objects in your account, in bytes. */\n\tsize: z.number(),\n\t/** The total price of storage for all objects in your account, in BRL. */\n\tstoragePrice: z.number(),\n\t/** The total price of all objects in your account, in BRL. */\n\tobjectsPrice: z.number(),\n\t/** The total price of all objects in your account, in BRL. */\n\ttotalEstimate: z.number(),\n});\n","import type { StatsResponse } from \"../../types/stats\";\nimport { statsResponseSchema } from \"../schemas/stats\";\nimport { handleAPIObjectAssertion } from \"./handlers\";\n\nexport function assertStatsResponse(value: unknown): StatsResponse {\n\treturn handleAPIObjectAssertion({\n\t\tschema: statsResponseSchema,\n\t\tcode: \"ACCOUNT_STATS\",\n\t\tvalue,\n\t});\n}\n","import { APIManager } from \"./managers/api\";\nimport { ObjectsManager } from \"./managers/objects\";\nimport type { StatsResponse } from \"./types/stats\";\nimport { assertStatsResponse } from \"./validation/assertions/stats\";\n\nexport class SquareCloudBlob {\n\tpublic static apiInfo = {\n\t\tbaseUrl: \"https://blob.squarecloud.app\",\n\t\tversion: \"v1\",\n\t};\n\n\tpublic readonly api: APIManager;\n\tpublic readonly objects = new ObjectsManager(this);\n\n\tconstructor(apiKey: string) {\n\t\tthis.api = new APIManager(apiKey);\n\t}\n\n\tasync stats() {\n\t\tconst { response } = await this.api.request<StatsResponse>(\"account/stats\");\n\t\treturn assertStatsResponse(response);\n\t}\n}\n\nexport * from \"./structures/object\";\nexport * from \"./types/create\";\nexport * from \"./types/list\";\nexport * from \"./utils/mimetype\";\n","import { SquareCloudBlob } from \"..\";\nimport { SquareCloudBlobError } from \"../structures/error\";\nimport type { APIPayload, APIRequestInit } from \"../types/api\";\n\nexport class APIManager {\n\tpublic readonly baseUrl: string;\n\n\tconstructor(private readonly apiKey: string) {\n\t\tconst { baseUrl, version } = SquareCloudBlob.apiInfo;\n\t\tthis.baseUrl = `${baseUrl}/${version}/`;\n\t}\n\n\tasync request<T>(path: string, options: APIRequestInit = {}) {\n\t\tconst { init, params } = this.parseOptions(options);\n\t\tconst url = new URL(`${path}?${params}`, this.baseUrl);\n\n\t\tconst response = await fetch(url, init);\n\t\tconst data: APIPayload<T> = await response.json();\n\n\t\tif (data.status === \"error\") {\n\t\t\tthrow new SquareCloudBlobError(data.code || \"UNKNOWN_ERROR\");\n\t\t}\n\t\treturn data;\n\t}\n\n\tprivate parseOptions(options: APIRequestInit) {\n\t\tconst paramsObject =\n\t\t\toptions.params &&\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries(options.params)\n\t\t\t\t\t.filter(([, value]) => Boolean(value))\n\t\t\t\t\t.map(([key, value]) => [key, String(value)]),\n\t\t\t);\n\t\tconst params = new URLSearchParams(paramsObject);\n\n\t\tconst { params: _, headers, body, ...rest } = options;\n\n\t\tconst init: RequestInit = {\n\t\t\t...rest,\n\t\t\theaders: { ...(headers || {}), Authorization: this.apiKey },\n\t\t};\n\n\t\tif (body) {\n\t\t\tinit.body = body instanceof FormData ? body : JSON.stringify(body);\n\t\t}\n\n\t\treturn { init, params };\n\t}\n}\n"],"mappings":";;;;;;;;AAAO,IAAM,yBAAyB;AAAA,EACrC,aAAa,CAAC,KAAK;AAAA,EACnB,cAAc,CAAC,MAAM;AAAA,EACrB,cAAc,CAAC,MAAM;AAAA,EACrB,eAAe,CAAC,KAAK;AAAA,EACrB,eAAe,CAAC,KAAK;AAAA,EACrB,cAAc,CAAC,OAAO,MAAM;AAAA,EAC5B,aAAa,CAAC,KAAK;AAAA,EACnB,cAAc,CAAC,MAAM;AAAA,EACrB,cAAc,CAAC,MAAM;AAAA,EACrB,aAAa,CAAC,KAAK;AAAA,EACnB,cAAc,CAAC,MAAM;AAAA,EACrB,aAAa,CAAC,KAAK;AAAA,EACnB,iBAAiB,CAAC,KAAK;AAAA,EACvB,gBAAgB,CAAC,KAAK;AAAA,EACtB,aAAa,CAAC,KAAK;AAAA,EACnB,aAAa,CAAC,KAAK;AAAA,EACnB,cAAc,CAAC,MAAM;AAAA,EACrB,cAAc,CAAC,MAAM;AAAA,EACrB,aAAa,CAAC,KAAK;AAAA,EACnB,aAAa,CAAC,KAAK;AAAA,EACnB,cAAc,CAAC,MAAM;AAAA,EACrB,aAAa,CAAC,KAAK;AAAA,EACnB,cAAc,CAAC,KAAK;AAAA,EACpB,aAAa,CAAC,KAAK;AAAA,EACnB,cAAc,CAAC,KAAK;AAAA,EACpB,aAAa,CAAC,MAAM;AAAA,EACpB,YAAY,CAAC,KAAK;AAAA,EAClB,YAAY,CAAC,KAAK;AAAA,EAClB,cAAc,CAAC,KAAK;AAAA,EACpB,mBAAmB,CAAC,KAAK;AAAA,EACzB,mBAAmB,CAAC,KAAK;AAAA,EACzB,qBAAqB,CAAC,KAAK;AAAA,EAC3B,yBAAyB,CAAC,SAAS;AAAA,EACnC,wBAAwB,CAAC,KAAK;AAAA,EAC9B,mBAAmB,CAAC,KAAK;AAAA,EACzB,oBAAoB,CAA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