@poppinss/utils 6.7.2 → 6.8.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/README.md CHANGED
@@ -69,7 +69,7 @@ import lodash from '@poppinss/utils/lodash'
69
69
  import assert from '@poppinss/utils/assert'
70
70
 
71
71
  // main module
72
- import { base64, Exception, fsReadAll } from '@poppinss/utils'
72
+ import { base64, fsReadAll } from '@poppinss/utils'
73
73
 
74
74
  // types sub-module
75
75
  import { ReadAllFilesOptions } from '@poppinss/utils/types'
@@ -645,9 +645,11 @@ lodash.pick(collection, keys)
645
645
  ```
646
646
 
647
647
  ### Assertion helpers
648
+
648
649
  The following assertion methods offers type-safe approach for writing conditionals and throwing error when the variable has unexpected values.
649
650
 
650
651
  #### assertExists(message?: string)
652
+
651
653
  Throws [AssertionError](https://nodejs.org/api/assert.html#new-assertassertionerroroptions) when the value is `false`, `null`, or `undefined`.
652
654
 
653
655
  ```ts
@@ -660,6 +662,7 @@ assertExists(value)
660
662
  ```
661
663
 
662
664
  #### assertNotNull(value: unknown, message?: string)
665
+
663
666
  Throws [AssertionError](https://nodejs.org/api/assert.html#new-assertassertionerroroptions) when the value is `null`.
664
667
 
665
668
  ```ts
@@ -672,6 +675,7 @@ assertNotNull(value)
672
675
  ```
673
676
 
674
677
  #### assertIsDefined(value: unknown, message?: string)
678
+
675
679
  Throws [AssertionError](https://nodejs.org/api/assert.html#new-assertassertionerroroptions) when the value is `undefined`.
676
680
 
677
681
  ```ts
@@ -684,6 +688,7 @@ assertIsDefined(value)
684
688
  ```
685
689
 
686
690
  #### assertUnreachable(value: unknown)
691
+
687
692
  Throws [AssertionError](https://nodejs.org/api/assert.html#new-assertassertionerroroptions) when the method is invoked. In other words, this method always throws an exception.
688
693
 
689
694
  ```ts
@@ -829,7 +834,7 @@ defineStaticProperty(UserModel, 'columns', {
829
834
  A custom exception class with support for defining the error status, error code, and help description. This class aims to standardize exceptions within your projects.
830
835
 
831
836
  ```ts
832
- import { Exception } from '@poppinss/utils'
837
+ import { Exception } from '@poppinss/utils/exception'
833
838
 
834
839
  class ResourceNotFound extends Exception {
835
840
  static code = 'E_RESOURCE_NOT_FOUND'
@@ -848,7 +853,7 @@ constructor that accepts an array of values to use for interpolation.
848
853
  The interpolation of error message is performed using the `util.format` message.
849
854
 
850
855
  ```ts
851
- import { createError } from '@poppinss/utils'
856
+ import { createError } from '@poppinss/utils/exception'
852
857
  const E_RESOURCE_NOT_FOUND = createError(
853
858
  'Unable to find resource with id %d',
854
859
  'E_RESOURCE_NOT_FOUND'
@@ -1051,7 +1056,7 @@ if (safeEqual(trustedValue, userInput)) {
1051
1056
  Convert OS-specific file paths to Unix file paths. The method is exported directly from the [slash](https://npm.im/slash) package.
1052
1057
 
1053
1058
  ```ts
1054
- import { slash } from '@poppinss/utils'
1059
+ import { slash } from '@poppinss/utils/slash'
1055
1060
  slash('foo\\bar') // foo/bar
1056
1061
  ```
1057
1062
 
@@ -1229,6 +1234,7 @@ const filename = getFilename(import.meta.url)
1229
1234
  ```
1230
1235
 
1231
1236
  #### joinToURL
1237
+
1232
1238
  Similar to the Node.js `path.join`, but instead expects the first parameter to be a URL instance or a string with the `file:///` protocol.
1233
1239
 
1234
1240
  The return value is an absolute file system path without the `file:///` protocol.
@@ -0,0 +1,55 @@
1
+ // src/exception.ts
2
+ import { format } from "node:util";
3
+ var Exception = class extends Error {
4
+ /**
5
+ * Name of the class that raised the exception.
6
+ */
7
+ name;
8
+ /**
9
+ * A status code for the error. Usually helpful when converting errors
10
+ * to HTTP responses.
11
+ */
12
+ status;
13
+ constructor(message, options) {
14
+ super(message, options);
15
+ const ErrorConstructor = this.constructor;
16
+ this.name = ErrorConstructor.name;
17
+ this.message = message || ErrorConstructor.message || "";
18
+ this.status = options?.status || ErrorConstructor.status || 500;
19
+ const code = options?.code || ErrorConstructor.code;
20
+ if (code !== void 0) {
21
+ this.code = code;
22
+ }
23
+ const help = ErrorConstructor.help;
24
+ if (help !== void 0) {
25
+ this.help = help;
26
+ }
27
+ Error.captureStackTrace(this, ErrorConstructor);
28
+ }
29
+ get [Symbol.toStringTag]() {
30
+ return this.constructor.name;
31
+ }
32
+ toString() {
33
+ if (this.code) {
34
+ return `${this.name} [${this.code}]: ${this.message}`;
35
+ }
36
+ return `${this.name}: ${this.message}`;
37
+ }
38
+ };
39
+ function createError(message, code, status) {
40
+ return class extends Exception {
41
+ static message = message;
42
+ static code = code;
43
+ static status = status;
44
+ constructor(args, options) {
45
+ super(format(message, ...args || []), options);
46
+ this.name = "Exception";
47
+ }
48
+ };
49
+ }
50
+
51
+ export {
52
+ Exception,
53
+ createError
54
+ };
55
+ //# sourceMappingURL=chunk-GGIWJLUJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/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 { 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 this.name = 'Exception'\n }\n }\n}\n"],"mappings":";AASA,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,UAAM,mBAAmB,KAAK;AAE9B,SAAK,OAAO,iBAAiB;AAC7B,SAAK,UAAU,WAAW,iBAAiB,WAAW;AACtD,SAAK,SAAS,SAAS,UAAU,iBAAiB,UAAU;AAE5D,UAAM,OAAO,SAAS,QAAQ,iBAAiB;AAC/C,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,OAAO,iBAAiB;AAC9B,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,kBAAkB,MAAM,gBAAgB;AAAA,EAChD;AAAA,EAEA,KAAK,OAAO,WAAW,IAAI;AACzB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEA,WAAW;AACT,QAAI,KAAK,MAAM;AACb,aAAO,GAAG,KAAK,IAAI,KAAK,KAAK,IAAI,MAAM,KAAK,OAAO;AAAA,IACrD;AACA,WAAO,GAAG,KAAK,IAAI,KAAK,KAAK,OAAO;AAAA,EACtC;AACF;AAKO,SAAS,YACd,SACA,MACA,QAGuD;AACvD,SAAO,cAAc,UAAU;AAAA,IAC7B,OAAO,UAAU;AAAA,IACjB,OAAO,OAAO;AAAA,IACd,OAAO,SAAS;AAAA,IAEhB,YAAY,MAAS,SAAwB;AAC3C,YAAM,OAAO,SAAS,GAAI,QAAQ,CAAC,CAAE,GAAG,OAAO;AAC/C,WAAK,OAAO;AAAA,IACd;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,21 @@
1
+ import {
2
+ Exception
3
+ } from "./chunk-GGIWJLUJ.js";
4
+
5
+ // src/exceptions/runtime_exception.ts
6
+ var RuntimeException = class extends Exception {
7
+ static code = "E_RUNTIME_EXCEPTION";
8
+ static status = 500;
9
+ };
10
+
11
+ // src/exceptions/invalid_arguments_exception.ts
12
+ var InvalidArgumentsException = class extends Exception {
13
+ static code = "E_INVALID_ARGUMENTS_EXCEPTION";
14
+ static status = 500;
15
+ };
16
+
17
+ export {
18
+ RuntimeException,
19
+ InvalidArgumentsException
20
+ };
21
+ //# sourceMappingURL=chunk-PNT36FCE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/exceptions/runtime_exception.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 { 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 { Exception } from '../exception.js'\n\nexport class InvalidArgumentsException extends Exception {\n static code = 'E_INVALID_ARGUMENTS_EXCEPTION'\n static status = 500\n}\n"],"mappings":";;;;;AAWO,IAAM,mBAAN,cAA+B,UAAU;AAAA,EAC9C,OAAO,OAAO;AAAA,EACd,OAAO,SAAS;AAClB;;;ACHO,IAAM,4BAAN,cAAwC,UAAU;AAAA,EACvD,OAAO,OAAO;AAAA,EACd,OAAO,SAAS;AAClB;","names":[]}
@@ -0,0 +1,7 @@
1
+ // src/slash.ts
2
+ import { default as default2 } from "slash";
3
+
4
+ export {
5
+ default2 as default
6
+ };
7
+ //# sourceMappingURL=chunk-RRTFLKKC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/slash.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\nexport { default as slash } from 'slash'\n"],"mappings":";AASA,SAAoB,WAAXA,gBAAwB;","names":["default"]}
package/build/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  export { Secret } from './src/secret.js';
3
2
  export { base64 } from './src/base64.js';
4
3
  export { compose } from './src/compose.js';
package/build/index.js CHANGED
@@ -3,8 +3,16 @@ import {
3
3
  milliseconds_default
4
4
  } from "./chunk-NKGAOHNN.js";
5
5
  import {
6
- main_default
7
- } from "./chunk-IOBSMUFC.js";
6
+ default as default2
7
+ } from "./chunk-RRTFLKKC.js";
8
+ import {
9
+ InvalidArgumentsException,
10
+ RuntimeException
11
+ } from "./chunk-PNT36FCE.js";
12
+ import {
13
+ Exception,
14
+ createError
15
+ } from "./chunk-GGIWJLUJ.js";
8
16
 
9
17
  // index.ts
10
18
  import { fileURLToPath as fileURLToPath3 } from "node:url";
@@ -55,62 +63,6 @@ function compose(superclass, ...mixins) {
55
63
  return mixins.reduce((c, mixin) => mixin(c), superclass);
56
64
  }
57
65
 
58
- // src/exception.ts
59
- import { format } from "node:util";
60
- var Exception = class extends Error {
61
- /**
62
- * Name of the class that raised the exception.
63
- */
64
- name;
65
- /**
66
- * A status code for the error. Usually helpful when converting errors
67
- * to HTTP responses.
68
- */
69
- status;
70
- constructor(message, options) {
71
- super(message, options);
72
- const ErrorConstructor = this.constructor;
73
- this.name = ErrorConstructor.name;
74
- this.message = message || ErrorConstructor.message || "";
75
- this.status = options?.status || ErrorConstructor.status || 500;
76
- const code = options?.code || ErrorConstructor.code;
77
- if (code !== void 0) {
78
- this.code = code;
79
- }
80
- const help = ErrorConstructor.help;
81
- if (help !== void 0) {
82
- this.help = help;
83
- }
84
- Error.captureStackTrace(this, ErrorConstructor);
85
- }
86
- get [Symbol.toStringTag]() {
87
- return this.constructor.name;
88
- }
89
- toString() {
90
- if (this.code) {
91
- return `${this.name} [${this.code}]: ${this.message}`;
92
- }
93
- return `${this.name}: ${this.message}`;
94
- }
95
- };
96
- function createError(message, code, status) {
97
- return class extends Exception {
98
- static message = message;
99
- static code = code;
100
- static status = status;
101
- constructor(args, options) {
102
- super(format(message, ...args || []), options);
103
- this.name = "Exception";
104
- }
105
- };
106
- }
107
-
108
- // src/exceptions/runtime_exception.ts
109
- var RuntimeException = class extends Exception {
110
- static code = "E_RUNTIME_EXCEPTION";
111
- static status = 500;
112
- };
113
-
114
66
  // src/import_default.ts
115
67
  async function importDefault(importFn, filePath) {
116
68
  const moduleExports = await importFn();
@@ -167,9 +119,6 @@ import { join } from "node:path";
167
119
  import { readdir, stat } from "node:fs/promises";
168
120
  import { fileURLToPath, pathToFileURL } from "node:url";
169
121
 
170
- // src/slash.ts
171
- import { default as default2 } from "slash";
172
-
173
122
  // src/natural_sort.ts
174
123
  function naturalSort(current, next) {
175
124
  return current.localeCompare(next, void 0, { numeric: true, sensitivity: "base" });
@@ -247,7 +196,7 @@ async function importFile(basePath, fileURL, values, options) {
247
196
  const filePath = fileURLToPath2(fileURL);
248
197
  const fileExtension = extname2(filePath);
249
198
  const collectionKey = relative(basePath, filePath).replace(new RegExp(`${fileExtension}$`), "").split(sep);
250
- const exportedValue = fileExtension === ".json" ? await import(fileURL, { assert: { type: "json" } }) : await import(fileURL);
199
+ const exportedValue = fileExtension === ".json" ? await import(fileURL, { with: { type: "json" } }) : await import(fileURL);
251
200
  lodash2.set(
252
201
  values,
253
202
  options.transformKeys ? options.transformKeys(collectionKey) : collectionKey,
@@ -267,6 +216,42 @@ async function fsImportAll(location, options) {
267
216
  return collection;
268
217
  }
269
218
 
219
+ // src/json/safe_parse.ts
220
+ import { parse } from "secure-json-parse";
221
+ function safeParse(jsonString, reviver) {
222
+ return parse(jsonString, reviver, {
223
+ protoAction: "remove",
224
+ constructorAction: "remove"
225
+ });
226
+ }
227
+
228
+ // src/json/safe_stringify.ts
229
+ import { configure } from "safe-stable-stringify";
230
+ var stringify = configure({
231
+ bigint: false,
232
+ circularValue: void 0,
233
+ deterministic: false
234
+ });
235
+ function jsonStringifyReplacer(replacer) {
236
+ return function(key, value) {
237
+ const val = replacer ? replacer.call(this, key, value) : value;
238
+ if (typeof val === "bigint") {
239
+ return val.toString();
240
+ }
241
+ return val;
242
+ };
243
+ }
244
+ function safeStringify(value, replacer, space) {
245
+ return stringify(value, jsonStringifyReplacer(replacer), space);
246
+ }
247
+
248
+ // src/json/main.ts
249
+ var json = {
250
+ safeParse,
251
+ safeStringify
252
+ };
253
+ var main_default = json;
254
+
270
255
  // src/message_builder.ts
271
256
  var MessageBuilder = class {
272
257
  #getExpiryDate(expiresIn) {
@@ -378,12 +363,6 @@ function safeEqual(trustedValue, userInput) {
378
363
  );
379
364
  }
380
365
 
381
- // src/exceptions/invalid_arguments_exception.ts
382
- var InvalidArgumentsException = class extends Exception {
383
- static code = "E_INVALID_ARGUMENTS_EXCEPTION";
384
- static status = 500;
385
- };
386
-
387
366
  // index.ts
388
367
  function getDirname(url) {
389
368
  return pathDirname(getFilename(url));
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts","../src/secret.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 { Secret } from './src/secret.js'\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 * Join paths to a URL instance or a URL string. The return\n * value will be a file path without the `file:///` protocol.\n */\nexport function joinToURL(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\nconst REDACTED = '[redacted]'\n\n/**\n * Define a Secret value that hides itself from the logs or the console\n * statements.\n *\n * The idea is to prevent accedential leaking of sensitive information.\n * Idea borrowed from.\n * https://transcend.io/blog/keep-sensitive-values-out-of-your-logs-with-types\n */\nexport class Secret<T> {\n /** The secret value */\n #value: T\n #keyword: string\n\n constructor(value: T, redactedKeyword?: string) {\n this.#value = value\n this.#keyword = redactedKeyword || REDACTED\n }\n\n toJSON(): string {\n return this.#keyword\n }\n valueOf(): string {\n return this.#keyword\n }\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.#keyword\n }\n toLocaleString(): string {\n return this.#keyword\n }\n toString(): string {\n return this.#keyword\n }\n\n /**\n * Returns the original value\n */\n release(): T {\n return this.#value\n }\n\n /**\n * Transform the original value and create a new\n * secret from it.\n */\n map<R>(transformFunc: (value: T) => R): Secret<R> {\n return new Secret(transformFunc(this.#value))\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 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 this.name = 'Exception'\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;;;ACDzD,IAAM,WAAW;AAUV,IAAM,SAAN,MAAM,QAAU;AAAA;AAAA,EAErB;AAAA,EACA;AAAA,EAEA,YAAY,OAAU,iBAA0B;AAC9C,SAAK,SAAS;AACd,SAAK,WAAW,mBAAmB;AAAA,EACrC;AAAA,EAEA,SAAiB;AACf,WAAO,KAAK;AAAA,EACd;AAAA,EACA,UAAkB;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,CAAC,OAAO,IAAI,4BAA4B,CAAC,IAAY;AACnD,WAAO,KAAK;AAAA,EACd;AAAA,EACA,iBAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EACA,WAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,UAAa;AACX,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAO,eAA2C;AAChD,WAAO,IAAI,QAAO,cAAc,KAAK,MAAM,CAAC;AAAA,EAC9C;AACF;;;AC0BO,SAAS,QACd,eACG,QACH;AACA,SAAO,OAAO,OAAO,CAAC,GAAG,UAAU,MAAM,CAAC,G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A,OAAmC,KAAc;AAC/C,WAAO,KAAK,OAAO,GAAG;AACtB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,IAAgC,KAAiB;AAC/C,WAAO,KAAK,IAAI,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;;;AhBmBO,SAAS,WAAW,KAAmB;AAC5C,SAAO,YAAY,YAAY,GAAG,CAAC;AACrC;AAKO,SAAS,YAAY,KAAmB;AAC7C,SAAOG,eAAc,GAAG;AAC1B;AAMO,SAAS,UAAU,QAAsB,KAAe;AAC7D,SAAO,SAAS,WAAW,GAAG,GAAG,GAAG,GAAG;AACzC;","names":["fileURLToPath","fileURLToPath","lodash","extname","default","default","fileURLToPath","extname","lodash","fileURLToPath"]}
1
+ {"version":3,"sources":["../index.ts","../src/secret.ts","../src/compose.ts","../src/import_default.ts","../src/define_static_property.ts","../src/flatten.ts","../src/fs_import_all.ts","../src/fs_read_all.ts","../src/natural_sort.ts","../src/is_script_file.ts","../src/json/safe_parse.ts","../src/json/safe_stringify.ts","../src/json/main.ts","../src/message_builder.ts","../src/object_builder.ts","../src/safe_equal.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 { Secret } from './src/secret.js'\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 * Join paths to a URL instance or a URL string. The return\n * value will be a file path without the `file:///` protocol.\n */\nexport function joinToURL(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\nconst REDACTED = '[redacted]'\n\n/**\n * Define a Secret value that hides itself from the logs or the console\n * statements.\n *\n * The idea is to prevent accidental leaking of sensitive information.\n * Idea borrowed from.\n * https://transcend.io/blog/keep-sensitive-values-out-of-your-logs-with-types\n */\nexport class Secret<T> {\n /** The secret value */\n #value: T\n #keyword: string\n\n constructor(value: T, redactedKeyword?: string) {\n this.#value = value\n this.#keyword = redactedKeyword || REDACTED\n }\n\n toJSON(): string {\n return this.#keyword\n }\n valueOf(): string {\n return this.#keyword\n }\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.#keyword\n }\n toLocaleString(): string {\n return this.#keyword\n }\n toString(): string {\n return this.#keyword\n }\n\n /**\n * Returns the original value\n */\n release(): T {\n return this.#value\n }\n\n /**\n * Transform the original value and create a new\n * secret from it.\n */\n map<R>(transformFunc: (value: T) => R): Secret<R> {\n return new Secret(transformFunc(this.#value))\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 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 { 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\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, { with: { 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\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 { parse } from 'secure-json-parse'\nimport { JSONReviver } from '../types.js'\n\n/**\n * A drop-in replacement for JSON.parse with prototype poisoning protection.\n */\nexport function safeParse(jsonString: string, reviver?: JSONReviver): any {\n return parse(jsonString, reviver, {\n protoAction: 'remove',\n constructorAction: 'remove',\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 { configure } from 'safe-stable-stringify'\nimport { JSONReplacer } from '../types.js'\n\nconst stringify = configure({\n bigint: false,\n circularValue: undefined,\n deterministic: false,\n})\n\n/**\n * Replacer to handle custom data types.\n *\n * - Bigints are converted to string\n */\nfunction jsonStringifyReplacer(replacer?: JSONReplacer): JSONReplacer {\n return function (key, value) {\n const val = replacer ? replacer.call(this, key, value) : value\n\n if (typeof val === 'bigint') {\n return val.toString()\n }\n\n return val\n }\n}\n\n/**\n * String Javascript values to a JSON string. Handles circular\n * references and bigints\n */\nexport function safeStringify(\n value: any,\n replacer?: JSONReplacer,\n space?: string | number\n): string | undefined {\n return stringify(value, jsonStringifyReplacer(replacer), space)\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 { safeParse } from './safe_parse.js'\nimport { safeStringify } from './safe_stringify.js'\n\nconst json = {\n safeParse,\n safeStringify,\n}\n\nexport default json\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"],"mappings":";;;;;;;;;;;;;;;;;AASA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,QAAQ,UAAU,WAAW,mBAAmB;;;ACDzD,IAAM,WAAW;AAUV,IAAM,SAAN,MAAM,QAAU;AAAA;AAAA,EAErB;AAAA,EACA;AAAA,EAEA,YAAY,OAAU,iBAA0B;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T;AAAA;AAAA;AAAA;AAAA,EAKA,OAAmC,KAAc;AAC/C,WAAO,KAAK,OAAO,GAAG;AACtB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,IAAgC,KAAiB;AAC/C,WAAO,KAAK,IAAI,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;;;Af1BO,SAAS,WAAW,KAAmB;AAC5C,SAAO,YAAY,YAAY,GAAG,CAAC;AACrC;AAKO,SAAS,YAAY,KAAmB;AAC7C,SAAOG,eAAc,GAAG;AAC1B;AAMO,SAAS,UAAU,QAAsB,KAAe;AAC7D,SAAO,SAAS,WAAW,GAAG,GAAG,GAAG,GAAG;AACzC;","names":["fileURLToPath","fileURLToPath","lodash","extname","default","fileURLToPath","extname","lodash","fileURLToPath"]}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  /**
3
2
  * Helper class to base64 encode/decode values with option
4
3
  * for url encoding and decoding
@@ -0,0 +1,9 @@
1
+ import {
2
+ Exception,
3
+ createError
4
+ } from "../chunk-GGIWJLUJ.js";
5
+ export {
6
+ Exception,
7
+ createError
8
+ };
9
+ //# sourceMappingURL=exception.js.map
@@ -0,0 +1,2 @@
1
+ export * from './invalid_arguments_exception.js';
2
+ export * from './runtime_exception.js';
@@ -0,0 +1,10 @@
1
+ import {
2
+ InvalidArgumentsException,
3
+ RuntimeException
4
+ } from "../../chunk-PNT36FCE.js";
5
+ import "../../chunk-GGIWJLUJ.js";
6
+ export {
7
+ InvalidArgumentsException,
8
+ RuntimeException
9
+ };
10
+ //# sourceMappingURL=main.js.map
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { ImportAllFilesOptions } from './types.js';
3
2
  /**
4
3
  * Returns an array of file paths from the given location. You can
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { ReadAllFilesOptions } from './types.js';
3
2
  /**
4
3
  * Returns an array of file paths from the given location. You can
@@ -2,7 +2,7 @@
2
2
  * Define a Secret value that hides itself from the logs or the console
3
3
  * statements.
4
4
  *
5
- * The idea is to prevent accedential leaking of sensitive information.
5
+ * The idea is to prevent accidental leaking of sensitive information.
6
6
  * Idea borrowed from.
7
7
  * https://transcend.io/blog/keep-sensitive-values-out-of-your-logs-with-types
8
8
  */
@@ -0,0 +1,7 @@
1
+ import {
2
+ default as default2
3
+ } from "../chunk-RRTFLKKC.js";
4
+ export {
5
+ default2 as slash
6
+ };
7
+ //# sourceMappingURL=slash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -33,15 +33,15 @@ declare const string: {
33
33
  sentence: typeof sentence;
34
34
  condenseWhitespace: typeof condenseWhitespace;
35
35
  seconds: {
36
- format(seconds: number, long?: boolean | undefined): string;
36
+ format(seconds: number, long?: boolean): string;
37
37
  parse(duration: string | number): number;
38
38
  };
39
39
  milliseconds: {
40
- format(milliseconds: number, long?: boolean | undefined): string;
40
+ format(milliseconds: number, long?: boolean): string;
41
41
  parse(duration: string | number): number;
42
42
  };
43
43
  bytes: {
44
- format(valueInBytes: number, options?: import("bytes").BytesOptions | undefined): string;
44
+ format(valueInBytes: number, options?: import("bytes").BytesOptions): string;
45
45
  parse(unit: string | number): number;
46
46
  };
47
47
  ordinal: typeof ordinal;
@@ -3,4 +3,4 @@ import { default as slugifyPkg } from 'slugify';
3
3
  * Typings of the slugify package are a bit off and therefore we have
4
4
  * to do this manual dance of re-assigning types
5
5
  */
6
- export declare const slug: typeof slugifyPkg.default;
6
+ export declare const slug: (typeof slugifyPkg)["default"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poppinss/utils",
3
- "version": "6.7.2",
3
+ "version": "6.8.0",
4
4
  "description": "Handy utilities for repetitive work",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -22,7 +22,10 @@
22
22
  "./string": "./build/src/string/main.js",
23
23
  "./string_builder": "./build/src/string_builder.js",
24
24
  "./json": "./build/src/json/main.js",
25
- "./types": "./build/src/types.js"
25
+ "./types": "./build/src/types.js",
26
+ "./exceptions": "./build/exceptions/src/exceptions/index.js",
27
+ "./exception": "./build/src/exception.js",
28
+ "./slash": "./build/src/slash.js"
26
29
  },
27
30
  "engines": {
28
31
  "node": ">=18.16.0"
@@ -31,67 +34,56 @@
31
34
  "pretest": "npm run lint",
32
35
  "test": "npm run build:lodash && c8 npm run quick:test",
33
36
  "build:lodash": "lodash include=\"pick,omit,has,get,set,unset,mergeWith,merge,size,clone,cloneDeep,toPath\" --production && move-file ./lodash.custom.min.js build/lodash/main.cjs",
34
- "quick:test": "node --loader=ts-node/esm bin/test.ts",
35
- "clean": "del-cli build",
37
+ "lint": "eslint",
38
+ "format": "prettier --write .",
36
39
  "typecheck": "tsc --noEmit",
37
- "precompile": "npm run lint && npm run clean",
40
+ "precompile": "npm run lint",
38
41
  "compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
39
42
  "build": "npm run compile && npm run build:lodash",
40
- "release": "np",
41
43
  "version": "npm run build",
42
44
  "prepublishOnly": "npm run build",
43
- "lint": "eslint . --ext=.ts",
44
- "format": "prettier --write .",
45
- "sync-labels": "github-label-sync --labels .github/labels.json poppinss/utils"
45
+ "release": "release-it",
46
+ "quick:test": "node --import=ts-node-maintained/register/esm bin/test.ts"
46
47
  },
47
- "keywords": [
48
- "toolkit",
49
- "utilities"
50
- ],
51
- "author": "virk,poppinss",
52
- "license": "MIT",
53
48
  "devDependencies": {
54
- "@adonisjs/eslint-config": "^1.2.1",
55
- "@adonisjs/logger": "^5.4.2-7",
56
- "@adonisjs/prettier-config": "^1.2.1",
57
- "@adonisjs/tsconfig": "^1.2.1",
58
- "@commitlint/cli": "^18.6.0",
59
- "@commitlint/config-conventional": "^18.6.0",
60
- "@japa/assert": "^2.1.0",
61
- "@japa/expect-type": "^2.0.1",
62
- "@japa/runner": "^3.1.1",
63
- "@swc/core": "^1.3.107",
49
+ "@adonisjs/eslint-config": "^2.0.0-beta.6",
50
+ "@adonisjs/logger": "^6.0.3",
51
+ "@adonisjs/prettier-config": "^1.4.0",
52
+ "@adonisjs/tsconfig": "^1.4.0",
53
+ "@japa/assert": "^3.0.0",
54
+ "@japa/expect-type": "^2.0.2",
55
+ "@japa/runner": "^3.1.4",
56
+ "@release-it/conventional-changelog": "^8.0.2",
57
+ "@swc/core": "^1.7.26",
64
58
  "@types/fs-extra": "^11.0.4",
65
- "@types/node": "^20.11.10",
66
- "c8": "^9.1.0",
67
- "del-cli": "^5.1.0",
68
- "eslint": "^8.55.0",
59
+ "@types/node": "^22.5.5",
60
+ "c8": "^10.1.2",
61
+ "eslint": "^9.10.0",
69
62
  "fs-extra": "^11.2.0",
70
- "github-label-sync": "^2.3.1",
71
- "husky": "^9.0.7",
72
63
  "lodash": "^4.17.21",
73
64
  "lodash-cli": "^4.17.5",
74
65
  "move-file-cli": "^3.0.0",
75
- "np": "^9.2.0",
76
- "prettier": "^3.2.4",
77
- "ts-node": "^10.9.2",
78
- "tsup": "^8.0.1",
79
- "typescript": "^5.3.3"
66
+ "prettier": "^3.3.3",
67
+ "release-it": "^17.6.0",
68
+ "ts-node-maintained": "^10.9.4",
69
+ "tsup": "^8.2.4",
70
+ "typescript": "^5.6.2"
80
71
  },
81
72
  "dependencies": {
82
73
  "@lukeed/ms": "^2.0.2",
83
74
  "@types/bytes": "^3.1.4",
84
75
  "@types/pluralize": "^0.0.33",
85
76
  "bytes": "^3.1.2",
86
- "case-anything": "^2.1.13",
87
- "flattie": "^1.1.0",
77
+ "case-anything": "^3.1.0",
78
+ "flattie": "^1.1.1",
88
79
  "pluralize": "^8.0.0",
89
- "safe-stable-stringify": "^2.4.3",
80
+ "safe-stable-stringify": "^2.5.0",
90
81
  "secure-json-parse": "^2.7.0",
91
82
  "slash": "^5.1.0",
92
83
  "slugify": "^1.6.6",
93
84
  "truncatise": "^0.0.8"
94
85
  },
86
+ "homepage": "https://github.com/poppinss/utils#readme",
95
87
  "repository": {
96
88
  "type": "git",
97
89
  "url": "git+https://github.com/poppinss/utils.git"
@@ -99,45 +91,24 @@
99
91
  "bugs": {
100
92
  "url": "https://github.com/poppinss/utils/issues"
101
93
  },
102
- "homepage": "https://github.com/poppinss/utils#readme",
103
- "c8": {
104
- "reporter": [
105
- "text",
106
- "html"
107
- ],
108
- "exclude": [
109
- "**/build/lodash/**",
110
- "tests/**",
111
- "test_helpers/**"
112
- ]
113
- },
114
- "commitlint": {
115
- "extends": [
116
- "@commitlint/config-conventional"
117
- ]
118
- },
94
+ "keywords": [
95
+ "toolkit",
96
+ "utilities"
97
+ ],
98
+ "author": "virk,poppinss",
99
+ "license": "MIT",
119
100
  "publishConfig": {
120
- "access": "public",
121
- "tag": "latest"
122
- },
123
- "np": {
124
- "message": "chore(release): %s",
125
- "tag": "latest",
126
- "branch": "main",
127
- "anyBranch": false
101
+ "provenance": true
128
102
  },
129
- "eslintConfig": {
130
- "extends": "@adonisjs/eslint-config/package"
131
- },
132
- "prettier": "@adonisjs/prettier-config",
133
103
  "tsup": {
134
104
  "entry": [
135
105
  "./index.ts",
136
106
  "./src/assert.ts",
137
107
  "./src/string/main.ts",
138
108
  "./src/string_builder.ts",
139
- "./src/json/main.ts",
140
- "./src/types.ts"
109
+ "./src/slash.ts",
110
+ "./src/exception.ts",
111
+ "./src/exceptions/main.ts"
141
112
  ],
142
113
  "outDir": "./build",
143
114
  "clean": true,
@@ -145,5 +116,41 @@
145
116
  "dts": false,
146
117
  "sourcemap": true,
147
118
  "target": "esnext"
148
- }
119
+ },
120
+ "release-it": {
121
+ "git": {
122
+ "requireCleanWorkingDir": true,
123
+ "requireUpstream": true,
124
+ "commitMessage": "chore(release): ${version}",
125
+ "tagAnnotation": "v${version}",
126
+ "push": true,
127
+ "tagName": "v${version}"
128
+ },
129
+ "github": {
130
+ "release": true
131
+ },
132
+ "npm": {
133
+ "publish": true,
134
+ "skipChecks": true
135
+ },
136
+ "plugins": {
137
+ "@release-it/conventional-changelog": {
138
+ "preset": {
139
+ "name": "angular"
140
+ }
141
+ }
142
+ }
143
+ },
144
+ "c8": {
145
+ "reporter": [
146
+ "text",
147
+ "html"
148
+ ],
149
+ "exclude": [
150
+ "**/build/lodash/**",
151
+ "tests/**",
152
+ "test_helpers/**"
153
+ ]
154
+ },
155
+ "prettier": "@adonisjs/prettier-config"
149
156
  }
@@ -1,40 +0,0 @@
1
- // src/json/safe_parse.ts
2
- import { parse } from "secure-json-parse";
3
- function safeParse(jsonString, reviver) {
4
- return parse(jsonString, reviver, {
5
- protoAction: "remove",
6
- constructorAction: "remove"
7
- });
8
- }
9
-
10
- // src/json/safe_stringify.ts
11
- import { configure } from "safe-stable-stringify";
12
- var stringify = configure({
13
- bigint: false,
14
- circularValue: void 0,
15
- deterministic: false
16
- });
17
- function jsonStringifyReplacer(replacer) {
18
- return function(key, value) {
19
- const val = replacer ? replacer.call(this, key, value) : value;
20
- if (typeof val === "bigint") {
21
- return val.toString();
22
- }
23
- return val;
24
- };
25
- }
26
- function safeStringify(value, replacer, space) {
27
- return stringify(value, jsonStringifyReplacer(replacer), space);
28
- }
29
-
30
- // src/json/main.ts
31
- var json = {
32
- safeParse,
33
- safeStringify
34
- };
35
- var main_default = json;
36
-
37
- export {
38
- main_default
39
- };
40
- //# sourceMappingURL=chunk-IOBSMUFC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/json/safe_parse.ts","../src/json/safe_stringify.ts","../src/json/main.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 { parse } from 'secure-json-parse'\nimport { JSONReviver } from '../types.js'\n\n/**\n * A drop-in replacement for JSON.parse with prototype poisoning protection.\n */\nexport function safeParse(jsonString: string, reviver?: JSONReviver): any {\n return parse(jsonString, reviver, {\n protoAction: 'remove',\n constructorAction: 'remove',\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 { configure } from 'safe-stable-stringify'\nimport { JSONReplacer } from '../types.js'\n\nconst stringify = configure({\n bigint: false,\n circularValue: undefined,\n deterministic: false,\n})\n\n/**\n * Replacer to handle custom data types.\n *\n * - Bigints are converted to string\n */\nfunction jsonStringifyReplacer(replacer?: JSONReplacer): JSONReplacer {\n return function (key, value) {\n const val = replacer ? replacer.call(this, key, value) : value\n\n if (typeof val === 'bigint') {\n return val.toString()\n }\n\n return val\n }\n}\n\n/**\n * String Javascript values to a JSON string. Handles circular\n * references and bigints\n */\nexport function safeStringify(\n value: any,\n replacer?: JSONReplacer,\n space?: string | number\n): string | undefined {\n return stringify(value, jsonStringifyReplacer(replacer), space)\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 { safeParse } from './safe_parse.js'\nimport { safeStringify } from './safe_stringify.js'\n\nconst json = {\n safeParse,\n safeStringify,\n}\n\nexport default json\n"],"mappings":";AASA,SAAS,aAAa;AAMf,SAAS,UAAU,YAAoB,SAA4B;AACxE,SAAO,MAAM,YAAY,SAAS;AAAA,IAChC,aAAa;AAAA,IACb,mBAAmB;AAAA,EACrB,CAAC;AACH;;;ACXA,SAAS,iBAAiB;AAG1B,IAAM,YAAY,UAAU;AAAA,EAC1B,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,eAAe;AACjB,CAAC;AAOD,SAAS,sBAAsB,UAAuC;AACpE,SAAO,SAAU,KAAK,OAAO;AAC3B,UAAM,MAAM,WAAW,SAAS,KAAK,MAAM,KAAK,KAAK,IAAI;AAEzD,QAAI,OAAO,QAAQ,UAAU;AAC3B,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO;AAAA,EACT;AACF;AAMO,SAAS,cACd,OACA,UACA,OACoB;AACpB,SAAO,UAAU,OAAO,sBAAsB,QAAQ,GAAG,KAAK;AAChE;;;ACjCA,IAAM,OAAO;AAAA,EACX;AAAA,EACA;AACF;AAEA,IAAO,eAAQ;","names":[]}
@@ -1,7 +0,0 @@
1
- import {
2
- main_default
3
- } from "../../chunk-IOBSMUFC.js";
4
- export {
5
- main_default as default
6
- };
7
- //# sourceMappingURL=main.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map