@arkstack/filesystem 0.12.3 → 0.12.4

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.
@@ -7,5 +7,4 @@ declare class StorageLinkCommand extends Command {
7
7
  handle(): Promise<void>;
8
8
  }
9
9
  //#endregion
10
- export { StorageLinkCommand };
11
- //# sourceMappingURL=StorageLinkCommand.d.ts.map
10
+ export { StorageLinkCommand };
@@ -12,5 +12,3 @@ var StorageLinkCommand = class extends Command {
12
12
  };
13
13
  //#endregion
14
14
  export { StorageLinkCommand };
15
-
16
- //# sourceMappingURL=StorageLinkCommand.js.map
package/dist/index.d.ts CHANGED
@@ -173,5 +173,4 @@ declare class FtpDriver implements DriverContract {
173
173
  }>;
174
174
  }
175
175
  //#endregion
176
- export { CustomDiskConfig, CustomDiskDriverRegistry, DiskConfig, DriverConfig, FileLike, FilesystemConfig, FtpDriver, FtpDriverConfig, KnownDisks, LocalDriverConfig, S3DriverConfig, Storage };
177
- //# sourceMappingURL=index.d.ts.map
176
+ export { CustomDiskConfig, CustomDiskDriverRegistry, DiskConfig, DriverConfig, FileLike, FilesystemConfig, FtpDriver, FtpDriverConfig, KnownDisks, LocalDriverConfig, S3DriverConfig, Storage };
@@ -557,5 +557,3 @@ var Storage = class Storage {
557
557
  };
558
558
  //#endregion
559
559
  export { FtpDriver as n, Storage as t };
560
-
561
- //# sourceMappingURL=src-Sdprva2c.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/filesystem",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "type": "module",
5
5
  "description": "Filesystem module for Arkstack, providing shared file storage and filesystem utitlities for the framework.",
6
6
  "homepage": "https://arkstack.toneflix.net",
@@ -39,8 +39,8 @@
39
39
  "@aws-sdk/s3-request-presigner": "^3.1011.0",
40
40
  "flydrive": "^2.0.0",
41
41
  "ssh2-sftp-client": "^12.1.0",
42
- "@arkstack/contract": "^0.12.3",
43
- "@arkstack/common": "^0.12.3"
42
+ "@arkstack/common": "^0.12.4",
43
+ "@arkstack/contract": "^0.12.4"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/ssh2-sftp-client": "^9.0.6"
@@ -1 +0,0 @@
1
- {"version":3,"file":"StorageLinkCommand.js","names":[],"sources":["../../src/commands/StorageLinkCommand.ts"],"sourcesContent":["import { Command } from '@h3ravel/musket'\nimport { Storage } from '../'\n\nexport class StorageLinkCommand extends Command {\n protected signature = `storage:link\n {--force : Remove existing links before creating new ones.}\n `\n protected description = 'Create symbolic links for filesystem.links configuration.'\n\n async handle () {\n Storage.link(this.options())\n }\n}"],"mappings":";;;AAGA,IAAa,qBAAb,cAAwC,QAAQ;CAC5C,YAAsB;;;CAGtB,cAAwB;CAExB,MAAM,SAAU;EACZ,QAAQ,KAAK,KAAK,SAAS,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"src-Sdprva2c.js","names":[],"sources":["../src/FtpDriver.ts","../src/Driver.ts","../src/Storage.ts"],"sourcesContent":["import { DriveDirectory, DriveFile } from 'flydrive'\nimport type {\n DriverContract,\n ObjectMetaData,\n ObjectVisibility,\n SignedURLOptions,\n WriteOptions,\n} from 'flydrive/types'\nimport { createReadStream, createWriteStream } from 'node:fs'\n\nimport Client from 'ssh2-sftp-client'\nimport { Readable } from 'node:stream'\nimport path from 'node:path'\n\nexport class FtpDriver implements DriverContract {\n private config: {\n host: string\n username: string\n password: string\n port?: number\n verbose?: boolean\n privateKey?: string\n }\n\n constructor(config: string | {\n host: string\n username: string\n password: string\n port?: number\n verbose?: boolean\n privateKey?: string\n }) {\n if (typeof config === 'string') {\n const url = new URL(config)\n\n this.config = {\n host: url.hostname,\n username: url.username,\n password: url.password,\n port: url.port ? parseInt(url.port, 10) : 22,\n verbose: url.searchParams.get('verbose') === 'true',\n }\n } else {\n this.config = config\n }\n }\n\n getConfig () {\n return this.config\n }\n\n private async init () {\n const client = new Client()\n\n await client.connect({\n host: this.config.host,\n username: this.config.username,\n password: this.config.password,\n port: this.config.port || 22,\n })\n\n return client\n }\n\n private async load<T> (handle: (client: Client) => Promise<T>): Promise<T> {\n const client = await this.init()\n\n try {\n return await handle(client)\n } catch (e) {\n if (this.config.verbose) {\n throw e\n }\n } finally {\n await client.end()\n }\n\n return null as any\n }\n\n /**\n * Return a boolean value indicating if the file exists\n * or not.\n */\n async exists (key: string): Promise<boolean> {\n const client = await this.load((client) => {\n return client.stat(key)\n }).catch(() => {\n return null\n })\n\n return !!client\n }\n\n /**\n * Return the file contents as a UTF-8 string. Throw an exception\n * if the file is missing.\n */\n async get (key: string): Promise<string> {\n const stream = await this.getStream(key)\n\n const chunks: Uint8Array[] = []\n for await (const chunk of stream) {\n chunks.push(chunk)\n }\n\n return Buffer.concat(chunks).toString('utf-8')\n }\n\n /**\n * Return the file contents as a Readable stream. Throw an exception\n * if the file is missing.\n */\n async getStream (key: string): Promise<Readable> {\n const dst = createWriteStream('/tmp/' + path.basename(key))\n await this.load((client) => {\n return client.get(key, dst)\n }).catch(() => {\n return null\n })\n\n return createReadStream('/tmp/' + path.basename(key))\n }\n\n /**\n * Return the file contents as a Uint8Array. Throw an exception\n * if the file is missing.\n */\n async getBytes (key: string): Promise<Uint8Array> {\n const content = await this.get(key)\n\n return new Uint8Array(Buffer.from(content, 'utf-8'))\n }\n\n /**\n * Return metadata of the file. Throw an exception\n * if the file is missing.\n */\n async getMetaData (key: string): Promise<ObjectMetaData> {\n const stat = await this.load((client) => {\n return client.stat(key)\n }).catch(() => {\n return null\n })\n\n if (!stat) {\n throw new Error('E_CANNOT_READ_FILE')\n }\n\n return {\n contentType: undefined,\n contentLength: stat.size,\n etag: key,\n lastModified: new Date(stat.modifyTime),\n }\n }\n\n /**\n * Return visibility of the file. Infer visibility from the initial\n * config, when the driver does not support the concept of visibility.\n */\n async getVisibility (key: string): Promise<ObjectVisibility> {\n void key\n\n return 'private'\n }\n\n /**\n * Return the public URL of the file. Throw an exception when the driver\n * does not support generating URLs.\n */\n async getUrl (key: string): Promise<string> {\n void key\n throw new Error('E_URL_GENERATION_UNSUPPORTED')\n }\n\n /**\n * Return the signed URL to serve a private file. Throw exception\n * when the driver does not support generating URLs.\n */\n async getSignedUrl (key: string, options?: SignedURLOptions): Promise<string> {\n void key\n void options\n throw new Error('E_URL_GENERATION_UNSUPPORTED')\n }\n /**\n * Return the signed/temporary URL that can be used to directly upload\n * the file contents to the storage.\n */\n async getSignedUploadUrl (key: string, options?: SignedURLOptions): Promise<string> {\n void key\n void options\n throw new Error('E_URL_GENERATION_UNSUPPORTED')\n }\n\n /**\n * Update the visibility of the file. Result in a NOOP\n * when the driver does not support the concept of\n * visibility.\n */\n async setVisibility (key: string, visibility: ObjectVisibility): Promise<void> {\n void key\n void visibility\n }\n\n /**\n * Create a new file or update an existing file. The contents\n * will be a UTF-8 string or \"Uint8Array\".\n */\n async put (key: string, contents: string | Uint8Array, options?: WriteOptions): Promise<void> {\n if (contents instanceof Uint8Array) {\n contents = Buffer.from(contents)\n }\n\n const stream = Readable.from(contents)\n\n await this.putStream(key, stream, options)\n }\n\n /**\n * Create a new file or update an existing file. The contents\n * will be a Readable stream.\n */\n async putStream (key: string, contents: Readable, options?: WriteOptions): Promise<void> {\n const dst = createWriteStream('/tmp/' + path.basename(key), {\n encoding: options?.contentEncoding as never || 'utf-8',\n })\n\n await new Promise((resolve, reject) => {\n contents.pipe(dst)\n contents.on('error', reject)\n dst.on('finish', resolve)\n dst.on('error', reject)\n })\n\n await this.load((client) => {\n return client.put('/tmp/' + path.basename(key), key)\n })\n }\n\n /**\n * Copy the existing file to the destination. Make sure the new file\n * has the same visibility as the existing file. It might require\n * manually fetching the visibility of the \"source\" file.\n */\n async copy (source: string, destination: string, options?: WriteOptions): Promise<void> {\n void options\n await this.load((client) => {\n return client.rcopy(source, destination)\n })\n }\n\n /**\n * Move the existing file to the destination. Make sure the new file\n * has the same visibility as the existing file. It might require\n * manually fetching the visibility of the \"source\" file.\n */\n async move (source: string, destination: string, options?: WriteOptions): Promise<void> {\n void options\n await this.load((client) => {\n return client.rename(source, destination)\n })\n }\n\n /**\n * Delete an existing file. Do not throw an error if the\n * file is already missing\n */\n async delete (key: string): Promise<void> {\n await this.load((client) => {\n return client.delete(key)\n }).catch(() => {\n return null\n })\n }\n\n /**\n * Delete all files inside a folder. Do not throw an error\n * if the folder does not exist or is empty.\n */\n async deleteAll (prefix: string): Promise<void> {\n await this.load((client) => {\n return client.rmdir(prefix, true)\n }).catch(() => {\n return null\n })\n }\n\n\n /**\n * Switch bucket at runtime if supported.\n */\n bucket (config: string | {\n host: string\n username: string\n password: string\n port?: number\n verbose?: boolean\n privateKey?: string\n }): DriverContract {\n return new FtpDriver(config)\n }\n\n /**\n * List all files from a given folder or the root of the storage.\n * Do not throw an error if the request folder does not exist.\n */\n async listAll (\n prefix: string,\n options?: {\n recursive?: boolean\n paginationToken?: string\n }\n ): Promise<{\n paginationToken?: string\n objects: Iterable<DriveFile | DriveDirectory>\n }> {\n void options\n\n const data = await this.load((client) => {\n return client.list(prefix)\n }).catch(() => {\n return null\n })\n\n return data ? {\n objects: data.map((file) => {\n if (file.type === 'd') {\n return new DriveDirectory(file.name)\n } else {\n return new DriveFile(file.name, this, {\n contentType: undefined,\n contentLength: file.size,\n etag: file.name,\n lastModified: new Date(file.modifyTime),\n })\n }\n })\n } : { objects: [] }\n }\n\n}\n","import { CustomDiskConfig, CustomDiskDriverRegistry, DriverConfig, FtpDriverConfig, LocalDriverConfig, S3DriverConfig } from './types'\nimport { DriverContract, SignedURLOptions } from 'flydrive/types'\n\nimport { FSDriver } from 'flydrive/drivers/fs'\nimport { FtpDriver } from './FtpDriver'\nimport { S3Driver } from 'flydrive/drivers/s3'\nimport { appUrl } from '@arkstack/common'\n\ntype BuiltInDriverMap = { [K in keyof Driver]: Driver[K] }\n\ntype DriverFor<K extends string> = K extends keyof BuiltInDriverMap\n ? ReturnType<BuiltInDriverMap[K]>\n : ReturnType<BuiltInDriverMap['custom']>\n\nexport class Driver {\n private static customDrivers = new Map<\n keyof CustomDiskDriverRegistry | (string & {}),\n DriverContract | (new (config?: CustomDiskConfig) => DriverContract)\n >()\n\n constructor(private config: DriverConfig) { }\n\n static make<K extends 'local' | 'ftp' | 's3' | (string & {})> (\n name: K,\n config: DriverConfig<K>\n ): DriverFor<K> {\n if (!['local', 'ftp', 's3'].includes(name) && !this.customDrivers.has(name)) {\n throw new Error(`Unsupported driver: ${name}`)\n }\n\n const driver = new Driver(config as never)\n\n if (this.customDrivers.has(name)) {\n return driver.custom(name) as DriverFor<K>\n }\n\n return driver['ftp'].apply(this) as DriverFor<K>\n\n }\n\n local () {\n const config = this.config as LocalDriverConfig\n\n return new FSDriver({\n location: config.location ?? new URL(config.root!, import.meta.url),\n visibility: config.visibility ?? 'public',\n urlBuilder: {\n async generateURL (key: string, _path: string) {\n return appUrl(key)\n },\n\n async generateSignedURL (key: string, _path: string, _opts: SignedURLOptions) {\n return appUrl(key)\n },\n },\n })\n }\n\n s3 () {\n const config = this.config as S3DriverConfig\n\n return new S3Driver({\n credentials: config.credentials ?? {\n accessKeyId: config.key!,\n secretAccessKey: config.secret!,\n },\n endpoint: config.endpoint,\n region: config.region,\n bucket: config.bucket,\n visibility: 'private',\n cdnUrl: config.cdnUrl ?? config.url,\n })\n }\n\n ftp () {\n const config = this.config as FtpDriverConfig\n\n return new FtpDriver({\n host: config.host,\n username: config.username,\n password: config.password,\n port: config.port,\n verbose: config.verbose,\n privateKey: config.privateKey,\n })\n }\n\n custom (name: string): DriverContract {\n if (!Driver.customDrivers.has(name)) {\n throw new Error(`Unsupported driver: ${name} has not been registered`)\n }\n\n const DriverInstance = Driver.customDrivers.get(name)!\n\n if (typeof DriverInstance === 'function') {\n const config = this.config as CustomDiskConfig\n\n return new DriverInstance(config)\n }\n\n return DriverInstance\n }\n\n /**\n * Register a new custom driver\n * \n * @param name \n * @param driver \n */\n static registerDriver (name: string, driver: DriverContract) {\n Driver.customDrivers.set(name, driver)\n }\n\n /**\n * Unregister a new custom driver\n * \n * @param name \n */\n static removeDriver (name: string) {\n Driver.customDrivers.delete(name)\n }\n}","import { DriveDirectory, DriveFile, DriveManager } from 'flydrive'\nimport { DriverConfig, FileLike } from './types'\nimport { DriverContract, ObjectMetaData, ObjectVisibility, SignedURLOptions, WriteOptions } from 'flydrive/types'\nimport { rmSync, symlinkSync } from 'node:fs'\n\nimport { Arkstack } from '@arkstack/contract'\nimport { Driver } from './Driver'\nimport { Logger } from '@h3ravel/shared'\nimport { Readable } from 'node:stream'\nimport { config } from '@arkstack/common'\nimport path from 'node:path'\n\nexport class Storage implements DriverContract {\n driver: DriveManager<any>\n services: Record<string, () => DriverContract> = {}\n diskName: string\n\n constructor() {\n const disks = Object.entries(config('filesystem.disks', {})) as Array<[string, DriverConfig]>\n const customDrivers = config('filesystem.custom_drivers', {}) as Record<string, DriverContract>\n\n for (const [name, driver] of Object.entries(customDrivers)) {\n Driver.registerDriver(name, driver)\n }\n\n for (const [disk, conf] of disks) {\n this.services[disk] = () => Driver.make(disk, conf)\n }\n\n this.diskName = config('filesystem.default')\n this.driver = new DriveManager({\n default: config('filesystem.default'),\n services: this.services\n })\n }\n\n /**\n * Static method to get a disk instance directly from the Storage class without needing to instantiate it first.\n * \n * @param diskName The name of the disk to use. If not provided, the default disk will be used.\n * @returns A Storage instance\n */\n static disk<K extends string> (diskName?: K): Storage {\n const storage = new Storage()\n\n if (diskName) {\n storage.diskName = diskName\n storage.driver = new DriveManager({\n default: diskName,\n services: storage.services\n })\n }\n\n return storage\n }\n\n /**\n * Generate a unique name for the file based on random numbers and original extension\n * \n * @param file The file object containing the original name\n * @returns A unique file name\n */\n static generateName = (file: { name?: string; originalname?: string }): string => {\n const name = file.originalname || file.name || 'file'\n\n if (typeof config('filesystem.fileNameGenerator') === 'function') {\n return config('filesystem.fileNameGenerator')(name)\n }\n\n return Math.floor(Math.random() * 999999999999).toString() +\n '_' + Math.floor(Math.random() * 999999999999) +\n '.' + (name).split('.').pop()\n }\n\n /**\n * Save the file to the storage and return the public URL and the file path\n * \n * @param file The file object containing the file data\n * @param filePath The path where the file should be saved\n * @param fileName The name to save the file as (optional)\n * @returns A tuple containing the public URL and the file path\n */\n static saveFile = async (\n file: FileLike,\n filePath: string = '',\n fileName?: string\n ): Promise<[string, string]> => {\n return new Storage().saveFile(file, filePath, fileName)\n }\n\n /**\n * Save the file to the storage and return the public URL and the file path\n * \n * @param file The file object containing the file data\n * @param filePath The path where the file should be saved\n * @param fileName The name to save the file as (optional)\n * @returns A tuple containing the public URL and the file path\n */\n saveFile = async (\n file: FileLike,\n filePath: string = '',\n fileName?: string\n ): Promise<[string, string]> => {\n const name = fileName || Storage.generateName(file)\n const drive = this.driver.use()\n\n if (file instanceof File && !file.buffer) {\n file.buffer = Buffer.from(await file.arrayBuffer())\n }\n\n await drive.put(path.join(filePath, name), file.buffer)\n\n const url = await drive.getUrl(path.join(filePath, name))\n const pth = this.diskName === 'local' ? path.join(filePath, name) : url\n\n return [url, pth]\n }\n\n /**\n * Return a boolean indicating if the file exists\n */\n exists (key: string): Promise<boolean> {\n return this.driver.use().exists(key)\n }\n /**\n * Return contents of a object for the given key as a UTF-8 string.\n * Should throw \"E_CANNOT_READ_FILE\" error when the file\n * does not exists.\n */\n get (key: string): Promise<string> {\n return this.driver.use().get(key)\n }\n /**\n * Return contents of a object for the given key as a Readable stream.\n * Should throw \"E_CANNOT_READ_FILE\" error when the file\n * does not exists.\n */\n getStream (key: string): Promise<Readable> {\n return this.driver.use().getStream(key)\n }\n /**\n * Return contents of an object for the given key as an Uint8Array.\n * Should throw \"E_CANNOT_READ_FILE\" error when the file\n * does not exists.\n */\n getBytes (key: string): Promise<Uint8Array> {\n return this.driver.use().getBytes(key)\n }\n /**\n * Return metadata of an object for the given key.\n */\n getMetaData (key: string): Promise<ObjectMetaData> {\n return this.driver.use().getMetaData(key)\n }\n /**\n * Return the visibility of the file\n */\n getVisibility (key: string): Promise<ObjectVisibility> {\n return this.driver.use().getVisibility(key)\n }\n /**\n * Return the public URL to access the file\n */\n getUrl (key: string): Promise<string> {\n return this.driver.use().getUrl(key)\n }\n /**\n * Return the signed/temporary URL to access the file\n */\n getSignedUrl (key: string, options?: SignedURLOptions): Promise<string> {\n return this.driver.use().getSignedUrl(key, options)\n }\n /**\n * Return the signed/temporary URL that can be used to directly upload\n * the file contents to the storage.\n */\n getSignedUploadUrl (key: string, options?: SignedURLOptions): Promise<string> {\n return this.driver.use().getSignedUploadUrl(key, options)\n }\n /**\n * Update the visibility of the file\n */\n setVisibility (key: string, visibility: ObjectVisibility): Promise<void> {\n return this.driver.use().setVisibility(key, visibility)\n }\n /**\n * Write object to the destination with the provided\n * contents.\n */\n put (key: string, contents: string | Uint8Array | FileLike, options?: WriteOptions): Promise<void> {\n if (!(contents instanceof Uint8Array) && typeof contents !== 'string') {\n contents = contents.buffer\n }\n\n return this.driver.use().put(key, contents, options)\n }\n /**\n * Write object to the destination with the provided\n * contents as a readable stream\n */\n putStream (key: string, contents: Readable, options?: WriteOptions): Promise<void> {\n return this.driver.use().putStream(key, contents, options)\n }\n /**\n * Copy the file from within the disk root location. Both\n * the \"source\" and \"destination\" will be the key names\n * and not absolute paths.\n */\n copy (source: string, destination: string, options?: WriteOptions): Promise<void> {\n return this.driver.use().copy(source, destination, options)\n }\n /**\n * Move the file from within the disk root location. Both\n * the \"source\" and \"destination\" will be the key names\n * and not absolute paths.\n */\n move (source: string, destination: string, options?: WriteOptions): Promise<void> {\n return this.driver.use().move(source, destination, options)\n }\n /**\n * Delete the file for the given key. Should not throw\n * error when file does not exist in first place\n */\n delete (key: string): Promise<void> {\n return this.driver.use().delete(key)\n }\n /**\n * Delete the files and directories matching the provided prefix.\n */\n deleteAll (prefix: string): Promise<void> {\n return this.driver.use().deleteAll(prefix)\n }\n /**\n * The list all method must return an array of objects with\n * the ability to paginate results (if supported).\n */\n listAll (prefix: string, options?: {\n recursive?: boolean;\n paginationToken?: string;\n }): Promise<{\n paginationToken?: string;\n objects: Iterable<DriveFile | DriveDirectory>;\n }> {\n return this.driver.use().listAll(prefix, options)\n }\n /**\n * Switch bucket at runtime if supported.\n */\n bucket (bucket: string): DriverContract {\n return (this.driver.use() as any).bucket(bucket)\n }\n\n /**\n * Create symbolic links for all configured links in the application configuration.\n */\n static link ({ force = false }: { force?: boolean } = {}): void {\n for (const link in config('filesystem.links')) {\n const target = config('filesystem.links')[link]\n\n const unlink = link.replace(Arkstack.rootDir(), '')\n const untarget = target.replace(Arkstack.rootDir(), '')\n\n try {\n if (force) rmSync(link, { recursive: true, force: true })\n symlinkSync(target, link)\n\n Logger.log([\n [' SUCCESS ', 'bgGreen'],\n [`[${unlink}]`, 'green'],\n ['is now linked to', 'white'],\n [`[${untarget}].`, 'green']\n ], ' ')\n } catch (error: any) {\n if (error.code === 'EEXIST') {\n Logger.log([\n [' INFO ', 'bgBlue'],\n [`[${unlink}]`, 'green'],\n ['is already linked to', 'white'],\n [`[${untarget}].`, 'green']\n ], ' ')\n } else {\n Logger.log([\n [' ERROR ', 'bgRed'],\n ['Failed to create symbolic link from', 'white'],\n [`[${unlink}]`, 'green'],\n ['to', 'white'],\n [`[${untarget}]`, 'green'],\n [error.message, 'red']\n ], ' ')\n }\n }\n }\n }\n}"],"mappings":";;;;;;;;;;;AAcA,IAAa,YAAb,MAAa,UAAoC;CAC7C;CASA,YAAY,QAOT;EACC,IAAI,OAAO,WAAW,UAAU;GAC5B,MAAM,MAAM,IAAI,IAAI,OAAO;GAE3B,KAAK,SAAS;IACV,MAAM,IAAI;IACV,UAAU,IAAI;IACd,UAAU,IAAI;IACd,MAAM,IAAI,OAAO,SAAS,IAAI,MAAM,GAAG,GAAG;IAC1C,SAAS,IAAI,aAAa,IAAI,UAAU,KAAK;IAChD;SAED,KAAK,SAAS;;CAItB,YAAa;EACT,OAAO,KAAK;;CAGhB,MAAc,OAAQ;EAClB,MAAM,SAAS,IAAI,QAAQ;EAE3B,MAAM,OAAO,QAAQ;GACjB,MAAM,KAAK,OAAO;GAClB,UAAU,KAA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