@poppinss/utils 6.5.1 → 6.6.0
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/build/index.d.ts +4 -0
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/package.json +18 -18
package/build/index.d.ts
CHANGED
|
@@ -23,3 +23,7 @@ export declare function getDirname(url: string | URL): string;
|
|
|
23
23
|
* Get filename for a given file path URL
|
|
24
24
|
*/
|
|
25
25
|
export declare function getFilename(url: string | URL): string;
|
|
26
|
+
/**
|
|
27
|
+
* Joins the given URL or string with additional path segments.
|
|
28
|
+
*/
|
|
29
|
+
export declare function join(url: string | URL, ...str: string[]): string;
|
package/build/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// index.ts
|
|
10
10
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
11
|
-
import { dirname as pathDirname } from "node:path";
|
|
11
|
+
import { join as pathJoin, dirname as pathDirname } from "node:path";
|
|
12
12
|
|
|
13
13
|
// src/compose.ts
|
|
14
14
|
function compose(superclass, ...mixins) {
|
|
@@ -350,6 +350,9 @@ function getDirname(url) {
|
|
|
350
350
|
function getFilename(url) {
|
|
351
351
|
return fileURLToPath3(url);
|
|
352
352
|
}
|
|
353
|
+
function join2(url, ...str) {
|
|
354
|
+
return pathJoin(getDirname(url), ...str);
|
|
355
|
+
}
|
|
353
356
|
export {
|
|
354
357
|
Exception,
|
|
355
358
|
InvalidArgumentsException,
|
|
@@ -367,6 +370,7 @@ export {
|
|
|
367
370
|
getFilename,
|
|
368
371
|
importDefault,
|
|
369
372
|
isScriptFile,
|
|
373
|
+
join2 as join,
|
|
370
374
|
naturalSort,
|
|
371
375
|
safeEqual,
|
|
372
376
|
default2 as slash
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../src/compose.ts","../src/exception.ts","../src/exceptions/runtime_exception.ts","../src/import_default.ts","../src/define_static_property.ts","../src/flatten.ts","../src/fs_import_all.ts","../src/fs_read_all.ts","../src/slash.ts","../src/natural_sort.ts","../src/is_script_file.ts","../src/message_builder.ts","../src/object_builder.ts","../src/safe_equal.ts","../src/exceptions/invalid_arguments_exception.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { fileURLToPath } from 'node:url'\nimport { dirname as pathDirname } from 'node:path'\n\nexport { base64 } from './src/base64.js'\nexport { compose } from './src/compose.js'\nexport { importDefault } from './src/import_default.js'\nexport { defineStaticProperty } from './src/define_static_property.js'\nexport { Exception, createError } from './src/exception.js'\nexport { flatten } from './src/flatten.js'\nexport { fsImportAll } from './src/fs_import_all.js'\nexport { fsReadAll } from './src/fs_read_all.js'\nexport { isScriptFile } from './src/is_script_file.js'\nexport { MessageBuilder } from './src/message_builder.js'\nexport { naturalSort } from './src/natural_sort.js'\nexport { ObjectBuilder } from './src/object_builder.js'\nexport { safeEqual } from './src/safe_equal.js'\nexport { slash } from './src/slash.js'\nexport { RuntimeException } from './src/exceptions/runtime_exception.js'\nexport { InvalidArgumentsException } from './src/exceptions/invalid_arguments_exception.js'\n\n/**\n * Get dirname for a given file path URL\n */\nexport function getDirname(url: string | URL) {\n return pathDirname(getFilename(url))\n}\n\n/**\n * Get filename for a given file path URL\n */\nexport function getFilename(url: string | URL) {\n return fileURLToPath(url)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Constructor } from './types.js'\n\ninterface UnaryFunction<T, R> {\n (source: T): R\n}\n\n/**\n * Compose a class by applying mixins to it.\n * The code is inspired by https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/, its\n * just that I have added the support for static types too.\n */\nexport function compose<T extends Constructor, A>(superclass: T, mixin: UnaryFunction<T, A>): A\nexport function compose<T extends Constructor, A, B>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>\n): B\nexport function compose<T extends Constructor, A, B, C>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>\n): C\nexport function compose<T extends Constructor, A, B, C, D>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>\n): D\nexport function compose<T extends Constructor, A, B, C, D, E>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinE: UnaryFunction<D, E>\n): E\nexport function compose<T extends Constructor, A, B, C, D, E, F>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinF: UnaryFunction<E, F>\n): F\nexport function compose<T extends Constructor, A, B, C, D, E, F, G>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinF: UnaryFunction<E, F>,\n mixinG: UnaryFunction<F, G>\n): G\nexport function compose<T extends Constructor, A, B, C, D, E, F, G, H>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinF: UnaryFunction<E, F>,\n mixinG: UnaryFunction<F, G>,\n mixinH: UnaryFunction<G, H>\n): H\nexport function compose<T extends Constructor, A, B, C, D, E, F, G, H, I>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinF: UnaryFunction<E, F>,\n mixinG: UnaryFunction<F, G>,\n mixinH: UnaryFunction<G, H>,\n mixinI: UnaryFunction<H, I>\n): I\nexport function compose<T extends Constructor, Mixins extends UnaryFunction<T, T>>(\n superclass: T,\n ...mixins: Mixins[]\n) {\n return mixins.reduce((c, mixin) => mixin(c), superclass)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { format } from 'node:util'\n\n/**\n * Extended Error object with the option to set error `status` and `code`.\n * At AdonisJs, we prefer exceptions with proper error codes to handle\n * them without relying on message pattern matching.\n *\n * ```js\n * new Exception('message', 500, 'E_RUNTIME_EXCEPTION')\n * ```\n */\nexport class Exception extends Error {\n /**\n * Static properties to defined on the exception once\n * and then re-use them\n */\n declare static help?: string\n declare static code?: string\n declare static status?: number\n declare static message?: string\n\n /**\n * Name of the class that raised the exception.\n */\n name: string\n\n /**\n * Optional help description for the error. You can use it to define additional\n * human readable information for the error.\n */\n declare help?: string\n\n /**\n * A machine readable error code. This will allow the error handling logic\n * to narrow down exceptions based upon the error code.\n */\n declare code?: string\n\n /**\n * A status code for the error. Usually helpful when converting errors\n * to HTTP responses.\n */\n status: number\n\n constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number }) {\n super(message, options)\n\n const ErrorConstructor = this.constructor as typeof Exception\n\n this.name = ErrorConstructor.name\n this.message = message || ErrorConstructor.message || ''\n this.status = options?.status || ErrorConstructor.status || 500\n\n const code = options?.code || ErrorConstructor.code\n if (code !== undefined) {\n this.code = code\n }\n\n const help = ErrorConstructor.help\n if (help !== undefined) {\n this.help = help\n }\n\n Error.captureStackTrace(this, ErrorConstructor)\n }\n\n get [Symbol.toStringTag]() {\n return this.constructor.name\n }\n\n toString() {\n if (this.code) {\n return `${this.name} [${this.code}]: ${this.message}`\n }\n return `${this.name}: ${this.message}`\n }\n}\n\n/**\n * Helper to create anonymous error classes\n */\nexport function createError<T extends any[] = never>(\n message: string,\n code: string,\n status?: number\n): typeof Exception & T extends never\n ? { new (args?: any, options?: ErrorOptions): Exception }\n : { new (args: T, options?: ErrorOptions): Exception } {\n return class extends Exception {\n static message = message\n static code = code\n static status = status\n\n constructor(args: T, options?: ErrorOptions) {\n super(format(message, ...(args || [])), options)\n }\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Exception } from '../exception.js'\n\nexport class RuntimeException extends Exception {\n static code = 'E_RUNTIME_EXCEPTION'\n static status = 500\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { RuntimeException } from './exceptions/runtime_exception.js'\n\n/**\n * Dynamically import a module and ensure it has a default export\n */\nexport async function importDefault<T extends object>(\n importFn: () => Promise<T>,\n filePath?: string\n): Promise<T extends { default: infer A } ? A : never> {\n const moduleExports = await importFn()\n\n /**\n * Make sure a default export exists\n */\n if (!('default' in moduleExports)) {\n const errorMessage = filePath\n ? `Missing \"export default\" in module \"${filePath}\"`\n : `Missing \"export default\" from lazy import \"${importFn}\"`\n\n throw new RuntimeException(errorMessage, {\n cause: {\n source: importFn,\n },\n })\n }\n\n return moduleExports.default as Promise<T extends { default: infer A } ? A : never>\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport lodash from '@poppinss/utils/lodash'\n\ntype Constructor = new (...args: any[]) => any\ntype AbstractConstructor = abstract new (...args: any[]) => any\n\n/**\n * Define static properties on a class with inheritance in play.\n */\nexport function defineStaticProperty<\n T extends Constructor | AbstractConstructor,\n Prop extends keyof T,\n>(\n self: T,\n propertyName: Prop,\n {\n initialValue,\n strategy,\n }: {\n initialValue: T[Prop]\n strategy: 'inherit' | 'define' | ((value: T[Prop]) => T[Prop])\n }\n) {\n if (!self.hasOwnProperty(propertyName)) {\n const value = self[propertyName]\n\n /**\n * Define the property as it is when the strategy is set\n * to \"define\". Or the value on the prototype chain\n * is set to undefined.\n */\n if (strategy === 'define' || value === undefined) {\n Object.defineProperty(self, propertyName, {\n value: initialValue,\n configurable: true,\n enumerable: true,\n writable: true,\n })\n return\n }\n\n Object.defineProperty(self, propertyName, {\n value: typeof strategy === 'function' ? strategy(value) : lodash.cloneDeep(value),\n configurable: true,\n enumerable: true,\n writable: true,\n })\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n// @ts-expect-error (Package has no types)\nimport { flattie } from 'flattie'\n\n/**\n * Recursively flatten an object/array.\n */\nexport function flatten<X = Record<string, any>, Y = unknown>(\n input: Y,\n glue?: string,\n keepNullish?: boolean\n): X {\n return flattie(input, glue, keepNullish)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { fileURLToPath } from 'node:url'\nimport lodash from '@poppinss/utils/lodash'\nimport { extname, relative, sep } from 'node:path'\n\nimport { fsReadAll } from './fs_read_all.js'\nimport { ImportAllFilesOptions } from './types.js'\nimport { isScriptFile } from './is_script_file.js'\n\n/**\n * Import the file and update the values collection with the default\n * export.\n */\nasync function importFile(\n basePath: string,\n fileURL: string,\n values: any,\n options: ImportAllFilesOptions\n) {\n /**\n * Converting URL to file path\n */\n const filePath = fileURLToPath(fileURL)\n\n /**\n * Grab file extension\n */\n const fileExtension = extname(filePath)\n\n const collectionKey = relative(basePath, filePath) // Get file relative path\n .replace(new RegExp(`${fileExtension}$`), '') // Get rid of the file extension\n .split(sep) // Convert nested paths to an array of keys\n\n /**\n * Import module\n */\n const exportedValue =\n fileExtension === '.json'\n ? await import(fileURL, { assert: { type: 'json' } })\n : await import(fileURL)\n\n lodash.set(\n values,\n options.transformKeys ? options.transformKeys(collectionKey) : collectionKey,\n exportedValue.default ? exportedValue.default : { ...exportedValue }\n )\n}\n\n/**\n * Returns an array of file paths from the given location. You can\n * optionally filter and sort files by passing relevant options\n *\n * ```ts\n * await fsReadAll(new URL('./', import.meta.url))\n *\n * await fsReadAll(new URL('./', import.meta.url), {\n * filter: (filePath) => filePath.endsWith('.js')\n * })\n\n * await fsReadAll(new URL('./', import.meta.url), {\n * absolute: true,\n * unixPaths: true\n * })\n* ```\n */\nexport async function fsImportAll(\n location: string | URL,\n options?: ImportAllFilesOptions\n): Promise<any> {\n options = options || {}\n const collection: any = {}\n const normalizedLocation = typeof location === 'string' ? location : fileURLToPath(location)\n const files = await fsReadAll(normalizedLocation, {\n filter: isScriptFile,\n ...options,\n pathType: 'url',\n })\n\n /**\n * Parallelly import all the files and mutate the values collection\n */\n await Promise.all(files.map((file) => importFile(normalizedLocation, file, collection, options!)))\n\n return collection\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { join } from 'node:path'\nimport { readdir, stat } from 'node:fs/promises'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\n\nimport { slash } from './slash.js'\nimport { naturalSort } from './natural_sort.js'\nimport { ReadAllFilesOptions } from './types.js'\n\n/**\n * Filter to remove dot files\n */\nfunction filterDotFiles(fileName: string) {\n return fileName[0] !== '.'\n}\n\n/**\n * Read all files from the directory recursively\n */\nasync function readFiles(\n root: string,\n files: string[],\n options: ReadAllFilesOptions,\n relativePath: string\n): Promise<void> {\n const location = join(root, relativePath)\n const stats = await stat(location)\n\n if (stats.isDirectory()) {\n let locationFiles = await readdir(location)\n\n await Promise.all(\n locationFiles.filter(filterDotFiles).map((file) => {\n return readFiles(root, files, options, join(relativePath, file))\n })\n )\n\n return\n }\n\n const pathType = options.pathType || 'relative'\n switch (pathType) {\n case 'relative':\n files.push(relativePath)\n break\n case 'absolute':\n files.push(location)\n break\n case 'unixRelative':\n files.push(slash(relativePath))\n break\n case 'unixAbsolute':\n files.push(slash(location))\n break\n case 'url':\n files.push(pathToFileURL(location).href)\n }\n}\n\n/**\n * Returns an array of file paths from the given location. You can\n * optionally filter and sort files by passing relevant options\n *\n * ```ts\n * await fsReadAll(new URL('./', import.meta.url))\n *\n * await fsReadAll(new URL('./', import.meta.url), {\n * filter: (filePath) => filePath.endsWith('.js')\n * })\n\n * await fsReadAll(new URL('./', import.meta.url), {\n * absolute: true,\n * unixPaths: true\n * })\n* ```\n */\nexport async function fsReadAll(\n location: string | URL,\n options?: ReadAllFilesOptions\n): Promise<string[]> {\n const normalizedLocation = typeof location === 'string' ? location : fileURLToPath(location)\n const normalizedOptions = Object.assign({ absolute: false, sort: naturalSort }, options)\n const files: string[] = []\n\n /**\n * Check to see if the root directory exists and ignore\n * error when \"ignoreMissingRoot\" is set to true\n */\n try {\n await stat(normalizedLocation)\n } catch (error) {\n if (normalizedOptions.ignoreMissingRoot) {\n return []\n }\n\n throw error\n }\n\n await readFiles(normalizedLocation, files, normalizedOptions, '')\n\n if (normalizedOptions.filter) {\n return files.filter(normalizedOptions.filter).sort(normalizedOptions.sort)\n }\n\n return files.sort(normalizedOptions.sort)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nexport { default as slash } from 'slash'\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/**\n * Perform natural sorting with \"Array.sort()\" method\n */\nexport function naturalSort(current: string, next: string) {\n return current.localeCompare(next, undefined, { numeric: true, sensitivity: 'base' })\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { extname } from 'node:path'\nconst JS_MODULES = ['.js', '.json', '.cjs', '.mjs']\n\n/**\n * Returns `true` when file ends with `.js`, `.json` or\n * `.ts` but not `.d.ts`.\n */\nexport function isScriptFile(filePath: string) {\n const ext = extname(filePath)\n\n if (JS_MODULES.includes(ext)) {\n return true\n }\n\n if (ext === '.ts' && !filePath.endsWith('.d.ts')) {\n return true\n }\n\n return false\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport json from './json/main.js'\nimport milliseconds from './string/milliseconds.js'\n\n/**\n * Message builder exposes an API to \"JSON.stringify\" values by\n * encoding purpose and expiry date inside them.\n *\n * The return value must be further encrypted to prevent tempering.\n */\nexport class MessageBuilder {\n #getExpiryDate(expiresIn?: string | number): undefined | Date {\n if (!expiresIn) {\n return undefined\n }\n\n const expiryMs = milliseconds.parse(expiresIn)\n return new Date(Date.now() + expiryMs)\n }\n\n /**\n * Returns a boolean telling, if message has been expired or not\n */\n #isExpired(message: any) {\n if (!message.expiryDate) {\n return false\n }\n\n const expiryDate = new Date(message.expiryDate)\n return Number.isNaN(expiryDate.getTime()) || expiryDate < new Date()\n }\n\n /**\n * Builds a message by encoding expiry date and purpose inside it.\n */\n build(message: any, expiresIn?: string | number, purpose?: string): string {\n const expiryDate = this.#getExpiryDate(expiresIn)\n return json.safeStringify({ message, purpose, expiryDate })!\n }\n\n /**\n * Verifies the message for expiry and purpose.\n */\n verify<T extends any>(message: any, purpose?: string): null | T {\n const parsed = json.safeParse(message)\n\n /**\n * After JSON.parse we do not receive a valid object\n */\n if (typeof parsed !== 'object' || !parsed) {\n return null\n }\n\n /**\n * Missing \".message\" property\n */\n if (!parsed.message) {\n return null\n }\n\n /**\n * Ensure purposes are same.\n */\n if (parsed.purpose !== purpose) {\n return null\n }\n\n /**\n * Ensure isn't expired\n */\n if (this.#isExpired(parsed)) {\n return null\n }\n\n return parsed.message\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { OmitProperties } from './types.js'\n\n/**\n * A simple class to build an object incrementally. It is helpful when you\n * want to add properties to the object conditionally.\n *\n * Instead of writing\n * ```\n * const obj = {\n * ...(user.id ? { id: user.id } : {}),\n * ...(user.firstName && user.lastName ? { name: `${user.firstName} ${user.lastName}` } : {}),\n * }\n * ```\n *\n * You can write\n *\n * const obj = new ObjectBuilder()\n * .add('id', user.id)\n * .add(\n * 'fullName',\n * user.firstName && user.lastName ? `${user.firstName} ${user.lastName}` : undefined\n * )\n * .toObject()\n */\nexport class ObjectBuilder<\n ReturnType extends Record<string, any>,\n IgnoreNull extends boolean = false,\n> {\n #ignoreNull: boolean\n values: ReturnType\n\n constructor(initialValue: ReturnType, ignoreNull?: IgnoreNull) {\n this.values = initialValue\n this.#ignoreNull = ignoreNull === true ? true : false\n }\n\n /**\n * Add a key-value pair to the object\n *\n * - Undefined values are ignored\n * - Null values are ignored, when `ignoreNull` is set to true\n */\n add<Prop extends string>(key: Prop, value: undefined): this\n add<Prop extends string, Value>(\n key: Prop,\n value: Value\n ): ObjectBuilder<ReturnType & { [P in Prop]: Value }, IgnoreNull>\n add<Prop extends string, Value>(key: Prop, value: Value): this {\n if (value === undefined) {\n return this\n }\n\n if (this.#ignoreNull === true && value === null) {\n return this\n }\n\n ;(this.values as any)[key] = value\n return this\n }\n\n /**\n * Remove key from the object\n */\n remove<K extends keyof ReturnType>(key: K): this {\n delete this.values[key]\n return this\n }\n\n /**\n * Find if a value exists\n */\n has<K extends keyof ReturnType>(key: K): boolean {\n return this.get(key) !== undefined\n }\n\n /**\n * Get the existing value for a given key\n */\n get<K extends keyof ReturnType>(key: K): ReturnType[K] {\n return this.values[key]\n }\n\n /**\n * Get the underlying constructed object\n */\n toObject(): IgnoreNull extends true\n ? { [K in keyof OmitProperties<ReturnType, null>]: ReturnType[K] }\n : { [K in keyof ReturnType]: ReturnType[K] } {\n return this.values\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Buffer } from 'node:buffer'\nimport { timingSafeEqual } from 'node:crypto'\n\ntype BufferSafeValue =\n | ArrayBuffer\n | SharedArrayBuffer\n | number[]\n | string\n | { valueOf(): string | object }\n | { [Symbol.toPrimitive](hint: 'string'): string }\n\n/**\n * Compare two values to see if they are equal. The comparison is done in\n * a way to avoid timing-attacks.\n */\nexport function safeEqual<T extends BufferSafeValue, U extends BufferSafeValue>(\n trustedValue: T,\n userInput: U\n): boolean {\n if (typeof trustedValue === 'string' && typeof userInput === 'string') {\n /**\n * The length of the comparison value.\n */\n const trustedLength = Buffer.byteLength(trustedValue)\n\n /**\n * Expected value\n */\n const trustedValueBuffer = Buffer.alloc(trustedLength, 0, 'utf-8')\n trustedValueBuffer.write(trustedValue)\n\n /**\n * Actual value (taken from user input)\n */\n const userValueBuffer = Buffer.alloc(trustedLength, 0, 'utf-8')\n userValueBuffer.write(userInput)\n\n /**\n * Ensure values are same and also have same length\n */\n return (\n timingSafeEqual(trustedValueBuffer, userValueBuffer) &&\n trustedLength === Buffer.byteLength(userInput)\n )\n }\n\n return timingSafeEqual(\n Buffer.from(trustedValue as ArrayBuffer | SharedArrayBuffer),\n Buffer.from(userInput as ArrayBuffer | SharedArrayBuffer)\n )\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Exception } from '../exception.js'\n\nexport class InvalidArgumentsException extends Exception {\n static code = 'E_INVALID_ARGUMENTS_EXCEPTION'\n static status = 500\n}\n"],"mappings":";;;;;;;;;AASA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,WAAW,mBAAmB;;;AC2EhC,SAAS,QACd,eACG,QACH;AACA,SAAO,OAAO,OAAO,CAAC,GAAG,UAAU,MAAM,CAAC,GAAG,UAAU;AACzD;;;ACjFA,SAAS,cAAc;AAWhB,IAAM,YAAN,cAAwB,MAAM;AAAA;AAAA;AAAA;AAAA,EAanC;AAAA;AAAA;AAAA;AAA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GAAG,MAAM;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAgC,KAAuB;AACrD,WAAO,KAAK,OAAO,GAAG;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAKA,WAE+C;AAC7C,WAAO,KAAK;AAAA,EACd;AACF;;;AC1FA,SAAS,cAAc;AACvB,SAAS,uBAAuB;AAczB,SAAS,UACd,cACA,WACS;AACT,MAAI,OAAO,iBAAiB,YAAY,OAAO,cAAc,UAAU;AAIrE,UAAM,gBAAgB,OAAO,WAAW,YAAY;AAKpD,UAAM,qBAAqB,OAAO,MAAM,eAAe,GAAG,OAAO;AACjE,uBAAmB,MAAM,YAAY;AAKrC,UAAM,kBAAkB,OAAO,MAAM,eAAe,GAAG,OAAO;AAC9D,oBAAgB,MAAM,SAAS;AAK/B,WACE,gBAAgB,oBAAoB,eAAe,KACnD,kBAAkB,OAAO,WAAW,SAAS;AAAA,EAEjD;AAEA,SAAO;AAAA,IACL,OAAO,KAAK,YAA+C;AAAA,IAC3D,OAAO,KAAK,SAA4C;AAAA,EAC1D;AACF;;;AChDO,IAAM,4BAAN,cAAwC,UAAU;AAAA,EACvD,OAAO,OAAO;AAAA,EACd,OAAO,SAAS;AAClB;;;AfkBO,SAAS,WAAW,KAAmB;AAC5C,SAAO,YAAY,YAAY,GAAG,CAAC;AACrC;AAKO,SAAS,YAAY,KAAmB;AAC7C,SAAOG,eAAc,GAAG;AAC1B;","names":["fileURLToPath","fileURLToPath","lodash","extname","default","default","fileURLToPath","extname","lodash","fileURLToPath"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts","../src/compose.ts","../src/exception.ts","../src/exceptions/runtime_exception.ts","../src/import_default.ts","../src/define_static_property.ts","../src/flatten.ts","../src/fs_import_all.ts","../src/fs_read_all.ts","../src/slash.ts","../src/natural_sort.ts","../src/is_script_file.ts","../src/message_builder.ts","../src/object_builder.ts","../src/safe_equal.ts","../src/exceptions/invalid_arguments_exception.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { fileURLToPath } from 'node:url'\nimport { join as pathJoin, dirname as pathDirname } from 'node:path'\n\nexport { base64 } from './src/base64.js'\nexport { compose } from './src/compose.js'\nexport { importDefault } from './src/import_default.js'\nexport { defineStaticProperty } from './src/define_static_property.js'\nexport { Exception, createError } from './src/exception.js'\nexport { flatten } from './src/flatten.js'\nexport { fsImportAll } from './src/fs_import_all.js'\nexport { fsReadAll } from './src/fs_read_all.js'\nexport { isScriptFile } from './src/is_script_file.js'\nexport { MessageBuilder } from './src/message_builder.js'\nexport { naturalSort } from './src/natural_sort.js'\nexport { ObjectBuilder } from './src/object_builder.js'\nexport { safeEqual } from './src/safe_equal.js'\nexport { slash } from './src/slash.js'\nexport { RuntimeException } from './src/exceptions/runtime_exception.js'\nexport { InvalidArgumentsException } from './src/exceptions/invalid_arguments_exception.js'\n\n/**\n * Get dirname for a given file path URL\n */\nexport function getDirname(url: string | URL) {\n return pathDirname(getFilename(url))\n}\n\n/**\n * Get filename for a given file path URL\n */\nexport function getFilename(url: string | URL) {\n return fileURLToPath(url)\n}\n\n/**\n * Joins the given URL or string with additional path segments.\n */\nexport function join(url: string | URL, ...str: string[]) {\n return pathJoin(getDirname(url), ...str)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Constructor } from './types.js'\n\ninterface UnaryFunction<T, R> {\n (source: T): R\n}\n\n/**\n * Compose a class by applying mixins to it.\n * The code is inspired by https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/, its\n * just that I have added the support for static types too.\n */\nexport function compose<T extends Constructor, A>(superclass: T, mixin: UnaryFunction<T, A>): A\nexport function compose<T extends Constructor, A, B>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>\n): B\nexport function compose<T extends Constructor, A, B, C>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>\n): C\nexport function compose<T extends Constructor, A, B, C, D>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>\n): D\nexport function compose<T extends Constructor, A, B, C, D, E>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinE: UnaryFunction<D, E>\n): E\nexport function compose<T extends Constructor, A, B, C, D, E, F>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinF: UnaryFunction<E, F>\n): F\nexport function compose<T extends Constructor, A, B, C, D, E, F, G>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinF: UnaryFunction<E, F>,\n mixinG: UnaryFunction<F, G>\n): G\nexport function compose<T extends Constructor, A, B, C, D, E, F, G, H>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinF: UnaryFunction<E, F>,\n mixinG: UnaryFunction<F, G>,\n mixinH: UnaryFunction<G, H>\n): H\nexport function compose<T extends Constructor, A, B, C, D, E, F, G, H, I>(\n superclass: T,\n mixin: UnaryFunction<T, A>,\n mixinB: UnaryFunction<A, B>,\n mixinC: UnaryFunction<B, C>,\n mixinD: UnaryFunction<C, D>,\n mixinF: UnaryFunction<E, F>,\n mixinG: UnaryFunction<F, G>,\n mixinH: UnaryFunction<G, H>,\n mixinI: UnaryFunction<H, I>\n): I\nexport function compose<T extends Constructor, Mixins extends UnaryFunction<T, T>>(\n superclass: T,\n ...mixins: Mixins[]\n) {\n return mixins.reduce((c, mixin) => mixin(c), superclass)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { format } from 'node:util'\n\n/**\n * Extended Error object with the option to set error `status` and `code`.\n * At AdonisJs, we prefer exceptions with proper error codes to handle\n * them without relying on message pattern matching.\n *\n * ```js\n * new Exception('message', 500, 'E_RUNTIME_EXCEPTION')\n * ```\n */\nexport class Exception extends Error {\n /**\n * Static properties to defined on the exception once\n * and then re-use them\n */\n declare static help?: string\n declare static code?: string\n declare static status?: number\n declare static message?: string\n\n /**\n * Name of the class that raised the exception.\n */\n name: string\n\n /**\n * Optional help description for the error. You can use it to define additional\n * human readable information for the error.\n */\n declare help?: string\n\n /**\n * A machine readable error code. This will allow the error handling logic\n * to narrow down exceptions based upon the error code.\n */\n declare code?: string\n\n /**\n * A status code for the error. Usually helpful when converting errors\n * to HTTP responses.\n */\n status: number\n\n constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number }) {\n super(message, options)\n\n const ErrorConstructor = this.constructor as typeof Exception\n\n this.name = ErrorConstructor.name\n this.message = message || ErrorConstructor.message || ''\n this.status = options?.status || ErrorConstructor.status || 500\n\n const code = options?.code || ErrorConstructor.code\n if (code !== undefined) {\n this.code = code\n }\n\n const help = ErrorConstructor.help\n if (help !== undefined) {\n this.help = help\n }\n\n Error.captureStackTrace(this, ErrorConstructor)\n }\n\n get [Symbol.toStringTag]() {\n return this.constructor.name\n }\n\n toString() {\n if (this.code) {\n return `${this.name} [${this.code}]: ${this.message}`\n }\n return `${this.name}: ${this.message}`\n }\n}\n\n/**\n * Helper to create anonymous error classes\n */\nexport function createError<T extends any[] = never>(\n message: string,\n code: string,\n status?: number\n): typeof Exception & T extends never\n ? { new (args?: any, options?: ErrorOptions): Exception }\n : { new (args: T, options?: ErrorOptions): Exception } {\n return class extends Exception {\n static message = message\n static code = code\n static status = status\n\n constructor(args: T, options?: ErrorOptions) {\n super(format(message, ...(args || [])), options)\n }\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Exception } from '../exception.js'\n\nexport class RuntimeException extends Exception {\n static code = 'E_RUNTIME_EXCEPTION'\n static status = 500\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { RuntimeException } from './exceptions/runtime_exception.js'\n\n/**\n * Dynamically import a module and ensure it has a default export\n */\nexport async function importDefault<T extends object>(\n importFn: () => Promise<T>,\n filePath?: string\n): Promise<T extends { default: infer A } ? A : never> {\n const moduleExports = await importFn()\n\n /**\n * Make sure a default export exists\n */\n if (!('default' in moduleExports)) {\n const errorMessage = filePath\n ? `Missing \"export default\" in module \"${filePath}\"`\n : `Missing \"export default\" from lazy import \"${importFn}\"`\n\n throw new RuntimeException(errorMessage, {\n cause: {\n source: importFn,\n },\n })\n }\n\n return moduleExports.default as Promise<T extends { default: infer A } ? A : never>\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport lodash from '@poppinss/utils/lodash'\n\ntype Constructor = new (...args: any[]) => any\ntype AbstractConstructor = abstract new (...args: any[]) => any\n\n/**\n * Define static properties on a class with inheritance in play.\n */\nexport function defineStaticProperty<\n T extends Constructor | AbstractConstructor,\n Prop extends keyof T,\n>(\n self: T,\n propertyName: Prop,\n {\n initialValue,\n strategy,\n }: {\n initialValue: T[Prop]\n strategy: 'inherit' | 'define' | ((value: T[Prop]) => T[Prop])\n }\n) {\n if (!self.hasOwnProperty(propertyName)) {\n const value = self[propertyName]\n\n /**\n * Define the property as it is when the strategy is set\n * to \"define\". Or the value on the prototype chain\n * is set to undefined.\n */\n if (strategy === 'define' || value === undefined) {\n Object.defineProperty(self, propertyName, {\n value: initialValue,\n configurable: true,\n enumerable: true,\n writable: true,\n })\n return\n }\n\n Object.defineProperty(self, propertyName, {\n value: typeof strategy === 'function' ? strategy(value) : lodash.cloneDeep(value),\n configurable: true,\n enumerable: true,\n writable: true,\n })\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n// @ts-expect-error (Package has no types)\nimport { flattie } from 'flattie'\n\n/**\n * Recursively flatten an object/array.\n */\nexport function flatten<X = Record<string, any>, Y = unknown>(\n input: Y,\n glue?: string,\n keepNullish?: boolean\n): X {\n return flattie(input, glue, keepNullish)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { fileURLToPath } from 'node:url'\nimport lodash from '@poppinss/utils/lodash'\nimport { extname, relative, sep } from 'node:path'\n\nimport { fsReadAll } from './fs_read_all.js'\nimport { ImportAllFilesOptions } from './types.js'\nimport { isScriptFile } from './is_script_file.js'\n\n/**\n * Import the file and update the values collection with the default\n * export.\n */\nasync function importFile(\n basePath: string,\n fileURL: string,\n values: any,\n options: ImportAllFilesOptions\n) {\n /**\n * Converting URL to file path\n */\n const filePath = fileURLToPath(fileURL)\n\n /**\n * Grab file extension\n */\n const fileExtension = extname(filePath)\n\n const collectionKey = relative(basePath, filePath) // Get file relative path\n .replace(new RegExp(`${fileExtension}$`), '') // Get rid of the file extension\n .split(sep) // Convert nested paths to an array of keys\n\n /**\n * Import module\n */\n const exportedValue =\n fileExtension === '.json'\n ? await import(fileURL, { assert: { type: 'json' } })\n : await import(fileURL)\n\n lodash.set(\n values,\n options.transformKeys ? options.transformKeys(collectionKey) : collectionKey,\n exportedValue.default ? exportedValue.default : { ...exportedValue }\n )\n}\n\n/**\n * Returns an array of file paths from the given location. You can\n * optionally filter and sort files by passing relevant options\n *\n * ```ts\n * await fsReadAll(new URL('./', import.meta.url))\n *\n * await fsReadAll(new URL('./', import.meta.url), {\n * filter: (filePath) => filePath.endsWith('.js')\n * })\n\n * await fsReadAll(new URL('./', import.meta.url), {\n * absolute: true,\n * unixPaths: true\n * })\n* ```\n */\nexport async function fsImportAll(\n location: string | URL,\n options?: ImportAllFilesOptions\n): Promise<any> {\n options = options || {}\n const collection: any = {}\n const normalizedLocation = typeof location === 'string' ? location : fileURLToPath(location)\n const files = await fsReadAll(normalizedLocation, {\n filter: isScriptFile,\n ...options,\n pathType: 'url',\n })\n\n /**\n * Parallelly import all the files and mutate the values collection\n */\n await Promise.all(files.map((file) => importFile(normalizedLocation, file, collection, options!)))\n\n return collection\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { join } from 'node:path'\nimport { readdir, stat } from 'node:fs/promises'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\n\nimport { slash } from './slash.js'\nimport { naturalSort } from './natural_sort.js'\nimport { ReadAllFilesOptions } from './types.js'\n\n/**\n * Filter to remove dot files\n */\nfunction filterDotFiles(fileName: string) {\n return fileName[0] !== '.'\n}\n\n/**\n * Read all files from the directory recursively\n */\nasync function readFiles(\n root: string,\n files: string[],\n options: ReadAllFilesOptions,\n relativePath: string\n): Promise<void> {\n const location = join(root, relativePath)\n const stats = await stat(location)\n\n if (stats.isDirectory()) {\n let locationFiles = await readdir(location)\n\n await Promise.all(\n locationFiles.filter(filterDotFiles).map((file) => {\n return readFiles(root, files, options, join(relativePath, file))\n })\n )\n\n return\n }\n\n const pathType = options.pathType || 'relative'\n switch (pathType) {\n case 'relative':\n files.push(relativePath)\n break\n case 'absolute':\n files.push(location)\n break\n case 'unixRelative':\n files.push(slash(relativePath))\n break\n case 'unixAbsolute':\n files.push(slash(location))\n break\n case 'url':\n files.push(pathToFileURL(location).href)\n }\n}\n\n/**\n * Returns an array of file paths from the given location. You can\n * optionally filter and sort files by passing relevant options\n *\n * ```ts\n * await fsReadAll(new URL('./', import.meta.url))\n *\n * await fsReadAll(new URL('./', import.meta.url), {\n * filter: (filePath) => filePath.endsWith('.js')\n * })\n\n * await fsReadAll(new URL('./', import.meta.url), {\n * absolute: true,\n * unixPaths: true\n * })\n* ```\n */\nexport async function fsReadAll(\n location: string | URL,\n options?: ReadAllFilesOptions\n): Promise<string[]> {\n const normalizedLocation = typeof location === 'string' ? location : fileURLToPath(location)\n const normalizedOptions = Object.assign({ absolute: false, sort: naturalSort }, options)\n const files: string[] = []\n\n /**\n * Check to see if the root directory exists and ignore\n * error when \"ignoreMissingRoot\" is set to true\n */\n try {\n await stat(normalizedLocation)\n } catch (error) {\n if (normalizedOptions.ignoreMissingRoot) {\n return []\n }\n\n throw error\n }\n\n await readFiles(normalizedLocation, files, normalizedOptions, '')\n\n if (normalizedOptions.filter) {\n return files.filter(normalizedOptions.filter).sort(normalizedOptions.sort)\n }\n\n return files.sort(normalizedOptions.sort)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nexport { default as slash } from 'slash'\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/**\n * Perform natural sorting with \"Array.sort()\" method\n */\nexport function naturalSort(current: string, next: string) {\n return current.localeCompare(next, undefined, { numeric: true, sensitivity: 'base' })\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { extname } from 'node:path'\nconst JS_MODULES = ['.js', '.json', '.cjs', '.mjs']\n\n/**\n * Returns `true` when file ends with `.js`, `.json` or\n * `.ts` but not `.d.ts`.\n */\nexport function isScriptFile(filePath: string) {\n const ext = extname(filePath)\n\n if (JS_MODULES.includes(ext)) {\n return true\n }\n\n if (ext === '.ts' && !filePath.endsWith('.d.ts')) {\n return true\n }\n\n return false\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport json from './json/main.js'\nimport milliseconds from './string/milliseconds.js'\n\n/**\n * Message builder exposes an API to \"JSON.stringify\" values by\n * encoding purpose and expiry date inside them.\n *\n * The return value must be further encrypted to prevent tempering.\n */\nexport class MessageBuilder {\n #getExpiryDate(expiresIn?: string | number): undefined | Date {\n if (!expiresIn) {\n return undefined\n }\n\n const expiryMs = milliseconds.parse(expiresIn)\n return new Date(Date.now() + expiryMs)\n }\n\n /**\n * Returns a boolean telling, if message has been expired or not\n */\n #isExpired(message: any) {\n if (!message.expiryDate) {\n return false\n }\n\n const expiryDate = new Date(message.expiryDate)\n return Number.isNaN(expiryDate.getTime()) || expiryDate < new Date()\n }\n\n /**\n * Builds a message by encoding expiry date and purpose inside it.\n */\n build(message: any, expiresIn?: string | number, purpose?: string): string {\n const expiryDate = this.#getExpiryDate(expiresIn)\n return json.safeStringify({ message, purpose, expiryDate })!\n }\n\n /**\n * Verifies the message for expiry and purpose.\n */\n verify<T extends any>(message: any, purpose?: string): null | T {\n const parsed = json.safeParse(message)\n\n /**\n * After JSON.parse we do not receive a valid object\n */\n if (typeof parsed !== 'object' || !parsed) {\n return null\n }\n\n /**\n * Missing \".message\" property\n */\n if (!parsed.message) {\n return null\n }\n\n /**\n * Ensure purposes are same.\n */\n if (parsed.purpose !== purpose) {\n return null\n }\n\n /**\n * Ensure isn't expired\n */\n if (this.#isExpired(parsed)) {\n return null\n }\n\n return parsed.message\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { OmitProperties } from './types.js'\n\n/**\n * A simple class to build an object incrementally. It is helpful when you\n * want to add properties to the object conditionally.\n *\n * Instead of writing\n * ```\n * const obj = {\n * ...(user.id ? { id: user.id } : {}),\n * ...(user.firstName && user.lastName ? { name: `${user.firstName} ${user.lastName}` } : {}),\n * }\n * ```\n *\n * You can write\n *\n * const obj = new ObjectBuilder()\n * .add('id', user.id)\n * .add(\n * 'fullName',\n * user.firstName && user.lastName ? `${user.firstName} ${user.lastName}` : undefined\n * )\n * .toObject()\n */\nexport class ObjectBuilder<\n ReturnType extends Record<string, any>,\n IgnoreNull extends boolean = false,\n> {\n #ignoreNull: boolean\n values: ReturnType\n\n constructor(initialValue: ReturnType, ignoreNull?: IgnoreNull) {\n this.values = initialValue\n this.#ignoreNull = ignoreNull === true ? true : false\n }\n\n /**\n * Add a key-value pair to the object\n *\n * - Undefined values are ignored\n * - Null values are ignored, when `ignoreNull` is set to true\n */\n add<Prop extends string>(key: Prop, value: undefined): this\n add<Prop extends string, Value>(\n key: Prop,\n value: Value\n ): ObjectBuilder<ReturnType & { [P in Prop]: Value }, IgnoreNull>\n add<Prop extends string, Value>(key: Prop, value: Value): this {\n if (value === undefined) {\n return this\n }\n\n if (this.#ignoreNull === true && value === null) {\n return this\n }\n\n ;(this.values as any)[key] = value\n return this\n }\n\n /**\n * Remove key from the object\n */\n remove<K extends keyof ReturnType>(key: K): this {\n delete this.values[key]\n return this\n }\n\n /**\n * Find if a value exists\n */\n has<K extends keyof ReturnType>(key: K): boolean {\n return this.get(key) !== undefined\n }\n\n /**\n * Get the existing value for a given key\n */\n get<K extends keyof ReturnType>(key: K): ReturnType[K] {\n return this.values[key]\n }\n\n /**\n * Get the underlying constructed object\n */\n toObject(): IgnoreNull extends true\n ? { [K in keyof OmitProperties<ReturnType, null>]: ReturnType[K] }\n : { [K in keyof ReturnType]: ReturnType[K] } {\n return this.values\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Buffer } from 'node:buffer'\nimport { timingSafeEqual } from 'node:crypto'\n\ntype BufferSafeValue =\n | ArrayBuffer\n | SharedArrayBuffer\n | number[]\n | string\n | { valueOf(): string | object }\n | { [Symbol.toPrimitive](hint: 'string'): string }\n\n/**\n * Compare two values to see if they are equal. The comparison is done in\n * a way to avoid timing-attacks.\n */\nexport function safeEqual<T extends BufferSafeValue, U extends BufferSafeValue>(\n trustedValue: T,\n userInput: U\n): boolean {\n if (typeof trustedValue === 'string' && typeof userInput === 'string') {\n /**\n * The length of the comparison value.\n */\n const trustedLength = Buffer.byteLength(trustedValue)\n\n /**\n * Expected value\n */\n const trustedValueBuffer = Buffer.alloc(trustedLength, 0, 'utf-8')\n trustedValueBuffer.write(trustedValue)\n\n /**\n * Actual value (taken from user input)\n */\n const userValueBuffer = Buffer.alloc(trustedLength, 0, 'utf-8')\n userValueBuffer.write(userInput)\n\n /**\n * Ensure values are same and also have same length\n */\n return (\n timingSafeEqual(trustedValueBuffer, userValueBuffer) &&\n trustedLength === Buffer.byteLength(userInput)\n )\n }\n\n return timingSafeEqual(\n Buffer.from(trustedValue as ArrayBuffer | SharedArrayBuffer),\n Buffer.from(userInput as ArrayBuffer | SharedArrayBuffer)\n )\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Exception } from '../exception.js'\n\nexport class InvalidArgumentsException extends Exception {\n static code = 'E_INVALID_ARGUMENTS_EXCEPTION'\n static status = 500\n}\n"],"mappings":";;;;;;;;;AASA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,QAAQ,UAAU,WAAW,mBAAmB;;;AC2ElD,SAAS,QACd,eACG,QACH;AACA,SAAO,OAAO,OAAO,CAAC,GAAG,UAAU,MAAM,CAAC,GAAG,UAAU;AACzD;;;ACjFA,SAAS,cAAc;AAWhB,IAAM,YAAN,cAAwB,MAAM;AAAA;AAAA;AAAA;AAAA,EAanC;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA;AAAA,EAEA,YAAY,SAAkB,SAA6D;AACzF,UAAM,SAAS,OAAO;AAEtB,UAA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AAK,OAAO,GAAG;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAKA,WAE+C;AAC7C,WAAO,KAAK;AAAA,EACd;AACF;;;AC1FA,SAAS,cAAc;AACvB,SAAS,uBAAuB;AAczB,SAAS,UACd,cACA,WACS;AACT,MAAI,OAAO,iBAAiB,YAAY,OAAO,cAAc,UAAU;AAIrE,UAAM,gBAAgB,OAAO,WAAW,YAAY;AAKpD,UAAM,qBAAqB,OAAO,MAAM,eAAe,GAAG,OAAO;AACjE,uBAAmB,MAAM,YAAY;AAKrC,UAAM,kBAAkB,OAAO,MAAM,eAAe,GAAG,OAAO;AAC9D,oBAAgB,MAAM,SAAS;AAK/B,WACE,gBAAgB,oBAAoB,eAAe,KACnD,kBAAkB,OAAO,WAAW,SAAS;AAAA,EAEjD;AAEA,SAAO;AAAA,IACL,OAAO,KAAK,YAA+C;AAAA,IAC3D,OAAO,KAAK,SAA4C;AAAA,EAC1D;AACF;;;AChDO,IAAM,4BAAN,cAAwC,UAAU;AAAA,EACvD,OAAO,OAAO;AAAA,EACd,OAAO,SAAS;AAClB;;;AfkBO,SAAS,WAAW,KAAmB;AAC5C,SAAO,YAAY,YAAY,GAAG,CAAC;AACrC;AAKO,SAAS,YAAY,KAAmB;AAC7C,SAAOG,eAAc,GAAG;AAC1B;AAKO,SAASC,MAAK,QAAsB,KAAe;AACxD,SAAO,SAAS,WAAW,GAAG,GAAG,GAAG,GAAG;AACzC;","names":["fileURLToPath","fileURLToPath","lodash","extname","default","default","fileURLToPath","extname","lodash","fileURLToPath","join"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poppinss/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Handy utilities for repetitive work",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -50,20 +50,20 @@
|
|
|
50
50
|
"author": "virk,poppinss",
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@adonisjs/eslint-config": "^1.1.
|
|
54
|
-
"@adonisjs/prettier-config": "^1.1.
|
|
55
|
-
"@adonisjs/tsconfig": "^1.1.
|
|
56
|
-
"@commitlint/cli": "^18.
|
|
57
|
-
"@commitlint/config-conventional": "^18.
|
|
58
|
-
"@japa/assert": "^2.0.
|
|
53
|
+
"@adonisjs/eslint-config": "^1.1.9",
|
|
54
|
+
"@adonisjs/prettier-config": "^1.1.9",
|
|
55
|
+
"@adonisjs/tsconfig": "^1.1.9",
|
|
56
|
+
"@commitlint/cli": "^18.4.3",
|
|
57
|
+
"@commitlint/config-conventional": "^18.4.3",
|
|
58
|
+
"@japa/assert": "^2.0.1",
|
|
59
59
|
"@japa/expect-type": "^2.0.0",
|
|
60
|
-
"@japa/runner": "^3.0
|
|
61
|
-
"@swc/core": "^1.3.
|
|
62
|
-
"@types/fs-extra": "^11.0.
|
|
63
|
-
"@types/node": "^20.
|
|
64
|
-
"c8": "^8.0.
|
|
60
|
+
"@japa/runner": "^3.1.0",
|
|
61
|
+
"@swc/core": "^1.3.99",
|
|
62
|
+
"@types/fs-extra": "^11.0.4",
|
|
63
|
+
"@types/node": "^20.10.0",
|
|
64
|
+
"c8": "^8.0.1",
|
|
65
65
|
"del-cli": "^5.1.0",
|
|
66
|
-
"eslint": "^8.
|
|
66
|
+
"eslint": "^8.54.0",
|
|
67
67
|
"fs-extra": "^11.1.1",
|
|
68
68
|
"github-label-sync": "^2.3.1",
|
|
69
69
|
"husky": "^8.0.3",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
"lodash-cli": "^4.17.5",
|
|
72
72
|
"move-file-cli": "^3.0.0",
|
|
73
73
|
"np": "^8.0.4",
|
|
74
|
-
"prettier": "^3.0
|
|
74
|
+
"prettier": "^3.1.0",
|
|
75
75
|
"ts-node": "^10.9.1",
|
|
76
|
-
"tsup": "^
|
|
77
|
-
"typescript": "
|
|
76
|
+
"tsup": "^8.0.1",
|
|
77
|
+
"typescript": "~5.2.2"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@lukeed/ms": "^2.0.1",
|
|
81
|
-
"@types/bytes": "^3.1.
|
|
82
|
-
"@types/pluralize": "^0.0.
|
|
81
|
+
"@types/bytes": "^3.1.4",
|
|
82
|
+
"@types/pluralize": "^0.0.33",
|
|
83
83
|
"bytes": "^3.1.2",
|
|
84
84
|
"case-anything": "^2.1.13",
|
|
85
85
|
"flattie": "^1.1.0",
|