@poppinss/utils 5.0.0 → 6.0.0-1

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.
Files changed (109) hide show
  1. package/README.md +661 -873
  2. package/build/index.d.ts +16 -10
  3. package/build/index.js +21 -53
  4. package/build/lodash/main.cjs +37 -0
  5. package/build/src/{Helpers/base64.d.ts → base64.d.ts} +7 -23
  6. package/build/src/{Helpers/base64.js → base64.js} +9 -22
  7. package/build/src/{Helpers/compose.d.ts → compose.d.ts} +0 -11
  8. package/build/src/compose.js +3 -0
  9. package/build/src/{defineStaticProperty.d.ts → define_static_property.d.ts} +2 -6
  10. package/build/src/define_static_property.js +21 -0
  11. package/build/src/exception.d.ts +16 -0
  12. package/build/src/exception.js +29 -0
  13. package/build/src/flatten.d.ts +1 -1
  14. package/build/src/flatten.js +4 -13
  15. package/build/src/fs_import_all.d.ts +3 -0
  16. package/build/src/fs_import_all.js +28 -0
  17. package/build/src/fs_read_all.d.ts +3 -0
  18. package/build/src/fs_read_all.js +55 -0
  19. package/build/src/is_script_file.d.ts +1 -0
  20. package/build/src/is_script_file.js +12 -0
  21. package/build/src/json/main.d.ts +7 -0
  22. package/build/src/json/main.js +7 -0
  23. package/build/src/json/safe_parse.d.ts +2 -0
  24. package/build/src/json/safe_parse.js +7 -0
  25. package/build/src/json/safe_stringify.d.ts +2 -0
  26. package/build/src/json/safe_stringify.js +18 -0
  27. package/build/src/message_builder.d.ts +5 -0
  28. package/build/src/message_builder.js +43 -0
  29. package/build/src/natural_sort.d.ts +1 -0
  30. package/build/src/natural_sort.js +3 -0
  31. package/build/src/object_builder.d.ts +10 -0
  32. package/build/src/object_builder.js +31 -0
  33. package/build/src/{Helpers/safeEqual.d.ts → safe_equal.d.ts} +1 -4
  34. package/build/src/safe_equal.js +14 -0
  35. package/build/src/slash.d.ts +1 -5
  36. package/build/src/slash.js +1 -24
  37. package/build/src/string/bytes.d.ts +6 -0
  38. package/build/src/string/bytes.js +12 -0
  39. package/build/src/string/change_case.d.ts +13 -0
  40. package/build/src/string/change_case.js +75 -0
  41. package/build/src/string/excerpt.d.ts +4 -0
  42. package/build/src/string/excerpt.js +10 -0
  43. package/build/src/string/interpolate.d.ts +1 -0
  44. package/build/src/{Helpers → string}/interpolate.js +1 -22
  45. package/build/src/string/main.d.ts +46 -0
  46. package/build/src/string/main.js +43 -0
  47. package/build/src/string/milliseconds.d.ts +5 -0
  48. package/build/src/string/milliseconds.js +16 -0
  49. package/build/src/string/ordinal.d.ts +1 -0
  50. package/build/src/string/ordinal.js +21 -0
  51. package/build/src/string/pluralize.d.ts +12 -0
  52. package/build/src/string/pluralize.js +12 -0
  53. package/build/src/string/random.d.ts +1 -0
  54. package/build/src/string/random.js +7 -0
  55. package/build/src/string/seconds.d.ts +5 -0
  56. package/build/src/string/seconds.js +16 -0
  57. package/build/src/string/sentence.d.ts +5 -0
  58. package/build/src/string/sentence.js +13 -0
  59. package/build/src/string/slugify.d.ts +2 -0
  60. package/build/src/string/slugify.js +2 -0
  61. package/build/src/string/truncate.d.ts +4 -0
  62. package/build/src/string/truncate.js +10 -0
  63. package/build/src/types.d.ts +14 -0
  64. package/build/src/types.js +1 -0
  65. package/lodash/lodash.types.d.ts +44 -0
  66. package/package.json +70 -82
  67. package/build/helpers.d.ts +0 -1
  68. package/build/helpers.js +0 -25
  69. package/build/src/Exception.d.ts +0 -17
  70. package/build/src/Exception.js +0 -68
  71. package/build/src/Helpers/MessageBuilder.d.ts +0 -28
  72. package/build/src/Helpers/MessageBuilder.js +0 -97
  73. package/build/src/Helpers/ObjectBuilder.d.ts +0 -46
  74. package/build/src/Helpers/ObjectBuilder.js +0 -75
  75. package/build/src/Helpers/compose.js +0 -15
  76. package/build/src/Helpers/fsReadAll.d.ts +0 -4
  77. package/build/src/Helpers/fsReadAll.js +0 -23
  78. package/build/src/Helpers/index.d.ts +0 -14
  79. package/build/src/Helpers/index.js +0 -62
  80. package/build/src/Helpers/interpolate.d.ts +0 -7
  81. package/build/src/Helpers/requireAll.d.ts +0 -8
  82. package/build/src/Helpers/requireAll.js +0 -65
  83. package/build/src/Helpers/resolveDir.d.ts +0 -5
  84. package/build/src/Helpers/resolveDir.js +0 -46
  85. package/build/src/Helpers/resolveFrom.d.ts +0 -5
  86. package/build/src/Helpers/resolveFrom.js +0 -27
  87. package/build/src/Helpers/safeEqual.js +0 -42
  88. package/build/src/Helpers/string.d.ts +0 -124
  89. package/build/src/Helpers/string.js +0 -328
  90. package/build/src/Helpers/types.d.ts +0 -86
  91. package/build/src/Helpers/types.js +0 -161
  92. package/build/src/ManagerConfigValidator.d.ts +0 -20
  93. package/build/src/ManagerConfigValidator.js +0 -55
  94. package/build/src/defineStaticProperty.js +0 -57
  95. package/build/src/esmRequire.d.ts +0 -5
  96. package/build/src/esmRequire.js +0 -20
  97. package/build/src/esmResolver.d.ts +0 -1
  98. package/build/src/esmResolver.js +0 -15
  99. package/build/src/fast-safe-stringify.d.ts +0 -2
  100. package/build/src/fast-safe-stringify.js +0 -101
  101. package/build/src/isScriptFile.d.ts +0 -5
  102. package/build/src/isScriptFile.js +0 -28
  103. package/build/src/lodash.d.ts +0 -13
  104. package/build/src/lodash.js +0 -39
  105. package/build/src/safeParse.d.ts +0 -5
  106. package/build/src/safeParse.js +0 -42
  107. package/build/src/safeStringify.d.ts +0 -5
  108. package/build/src/safeStringify.js +0 -39
  109. package/types/lodash.types.d.ts +0 -65
package/build/index.d.ts CHANGED
@@ -1,10 +1,16 @@
1
- export * as lodash from './src/lodash';
2
- export { slash } from './src/slash';
3
- export { flatten } from './src/flatten';
4
- export { Exception } from './src/Exception';
5
- export { safeParse } from './src/safeParse';
6
- export { esmRequire } from './src/esmRequire';
7
- export { esmResolver } from './src/esmResolver';
8
- export { safeStringify } from './src/safeStringify';
9
- export { defineStaticProperty } from './src/defineStaticProperty';
10
- export { ManagerConfigValidator } from './src/ManagerConfigValidator';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ export { base64 } from './src/base64.js';
3
+ export { compose } from './src/compose.js';
4
+ export { defineStaticProperty } from './src/define_static_property.js';
5
+ export { Exception } from './src/exception.js';
6
+ export { flatten } from './src/flatten.js';
7
+ export { fsImportAll } from './src/fs_import_all.js';
8
+ export { fsReadAll } from './src/fs_read_all.js';
9
+ export { isScriptFile } from './src/is_script_file.js';
10
+ export { MessageBuilder } from './src/message_builder.js';
11
+ export { naturalSort } from './src/natural_sort.js';
12
+ export { ObjectBuilder } from './src/object_builder.js';
13
+ export { safeEqual } from './src/safe_equal.js';
14
+ export { slash } from './src/slash.js';
15
+ export declare function getDirname(url: string | URL): string;
16
+ export declare function getFilename(url: string | URL): string;
package/build/index.js CHANGED
@@ -1,53 +1,21 @@
1
- "use strict";
2
- /*
3
- * @poppinss/utils
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- var desc = Object.getOwnPropertyDescriptor(m, k);
13
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
- desc = { enumerable: true, get: function() { return m[k]; } };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }) : (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- o[k2] = m[k];
20
- }));
21
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22
- Object.defineProperty(o, "default", { enumerable: true, value: v });
23
- }) : function(o, v) {
24
- o["default"] = v;
25
- });
26
- var __importStar = (this && this.__importStar) || function (mod) {
27
- if (mod && mod.__esModule) return mod;
28
- var result = {};
29
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
30
- __setModuleDefault(result, mod);
31
- return result;
32
- };
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.ManagerConfigValidator = exports.defineStaticProperty = exports.safeStringify = exports.esmResolver = exports.esmRequire = exports.safeParse = exports.Exception = exports.flatten = exports.slash = exports.lodash = void 0;
35
- exports.lodash = __importStar(require("./src/lodash"));
36
- var slash_1 = require("./src/slash");
37
- Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return slash_1.slash; } });
38
- var flatten_1 = require("./src/flatten");
39
- Object.defineProperty(exports, "flatten", { enumerable: true, get: function () { return flatten_1.flatten; } });
40
- var Exception_1 = require("./src/Exception");
41
- Object.defineProperty(exports, "Exception", { enumerable: true, get: function () { return Exception_1.Exception; } });
42
- var safeParse_1 = require("./src/safeParse");
43
- Object.defineProperty(exports, "safeParse", { enumerable: true, get: function () { return safeParse_1.safeParse; } });
44
- var esmRequire_1 = require("./src/esmRequire");
45
- Object.defineProperty(exports, "esmRequire", { enumerable: true, get: function () { return esmRequire_1.esmRequire; } });
46
- var esmResolver_1 = require("./src/esmResolver");
47
- Object.defineProperty(exports, "esmResolver", { enumerable: true, get: function () { return esmResolver_1.esmResolver; } });
48
- var safeStringify_1 = require("./src/safeStringify");
49
- Object.defineProperty(exports, "safeStringify", { enumerable: true, get: function () { return safeStringify_1.safeStringify; } });
50
- var defineStaticProperty_1 = require("./src/defineStaticProperty");
51
- Object.defineProperty(exports, "defineStaticProperty", { enumerable: true, get: function () { return defineStaticProperty_1.defineStaticProperty; } });
52
- var ManagerConfigValidator_1 = require("./src/ManagerConfigValidator");
53
- Object.defineProperty(exports, "ManagerConfigValidator", { enumerable: true, get: function () { return ManagerConfigValidator_1.ManagerConfigValidator; } });
1
+ import { fileURLToPath } from 'node:url';
2
+ import { dirname as pathDirname } from 'node:path';
3
+ export { base64 } from './src/base64.js';
4
+ export { compose } from './src/compose.js';
5
+ export { defineStaticProperty } from './src/define_static_property.js';
6
+ export { Exception } from './src/exception.js';
7
+ export { flatten } from './src/flatten.js';
8
+ export { fsImportAll } from './src/fs_import_all.js';
9
+ export { fsReadAll } from './src/fs_read_all.js';
10
+ export { isScriptFile } from './src/is_script_file.js';
11
+ export { MessageBuilder } from './src/message_builder.js';
12
+ export { naturalSort } from './src/natural_sort.js';
13
+ export { ObjectBuilder } from './src/object_builder.js';
14
+ export { safeEqual } from './src/safe_equal.js';
15
+ export { slash } from './src/slash.js';
16
+ export function getDirname(url) {
17
+ return pathDirname(getFilename(url));
18
+ }
19
+ export function getFilename(url) {
20
+ return fileURLToPath(url);
21
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
4
+ * Build: `lodash include="pick,omit,has,get,set,unset,mergeWith,merge,size,clone,cloneDeep,toPath" --production`
5
+ */
6
+ ;(function(){function t(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}function n(t,n){for(var r=-1,e=null==t?0:t.length;++r<e&&n(t[r],r,t)!==false;);return t}function r(t,n){for(var r=-1,e=null==t?0:t.length,u=0,o=[];++r<e;){var i=t[r];n(i,r,t)&&(o[u++]=i)}return o}function e(t,n){for(var r=-1,e=null==t?0:t.length,u=Array(e);++r<e;)u[r]=n(t[r],r,t);return u}function u(t,n){for(var r=-1,e=n.length,u=t.length;++r<e;)t[u+r]=n[r];
7
+ return t}function o(t){return function(n){return null==n?In:n[t]}}function i(t,n){for(var r=-1,e=Array(t);++r<t;)e[r]=n(r);return e}function c(t){return function(n){return t(n)}}function f(t,n){return null==t?In:t[n]}function a(t){return Kr.test(t)}function l(t,n){return function(r){return t(n(r))}}function s(t,n){return"__proto__"==n?In:t[n]}function h(t){return a(t)?p(t):ae(t)}function p(t){for(var n=Jr.lastIndex=0;Jr.test(t);)++n;return n}function y(){}function v(t){var n=-1,r=null==t?0:t.length;
8
+ for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}function b(){this.__data__=De?De(null):{},this.size=0}function _(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function g(t){var n=this.__data__;if(De){var r=n[t];return r===Mn?In:r}return ve.call(n,t)?n[t]:In}function d(t){var n=this.__data__;return De?n[t]!==In:ve.call(n,t)}function j(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=De&&n===In?Mn:n,this}function w(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){
9
+ var e=t[n];this.set(e[0],e[1])}}function O(){this.__data__=[],this.size=0}function m(t){var n=this.__data__,r=N(n,t);return!(r<0)&&(r==n.length-1?n.pop():Se.call(n,r,1),--this.size,true)}function A(t){var n=this.__data__,r=N(n,t);return r<0?In:n[r][1]}function z(t){return N(this.__data__,t)>-1}function x(t,n){var r=this.__data__,e=N(r,t);return e<0?(++this.size,r.push([t,n])):r[e][1]=n,this}function S(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}function k(){
10
+ this.size=0,this.__data__={hash:new v,map:new(Ue||w),string:new v}}function E(t){var n=$t(this,t).delete(t);return this.size-=n?1:0,n}function P(t){return $t(this,t).get(t)}function I(t){return $t(this,t).has(t)}function $(t,n){var r=$t(this,t),e=r.size;return r.set(t,n),this.size+=r.size==e?0:1,this}function F(t){this.size=(this.__data__=new w(t)).size}function L(){this.__data__=new w,this.size=0}function M(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}function T(t){return this.__data__.get(t);
11
+ }function U(t){return this.__data__.has(t)}function B(t,n){var r=this.__data__;if(r instanceof w){var e=r.__data__;if(!Ue||e.length<Fn-1)return e.push([t,n]),this.size=++r.size,this;r=this.__data__=new S(e)}return r.set(t,n),this.size=r.size,this}function C(t,n){var r=ou(t),e=!r&&uu(t),u=!r&&!e&&iu(t),o=!r&&!e&&!u&&au(t),c=r||e||u||o,f=c?i(t.length,String):[],a=f.length;for(var l in t)!n&&!ve.call(t,l)||c&&("length"==l||u&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Rt(l,a))||f.push(l);
12
+ return f}function R(t,n,r){(r===In||cn(t[n],r))&&(r!==In||n in t)||q(t,n,r)}function D(t,n,r){var e=t[n];ve.call(t,n)&&cn(e,r)&&(r!==In||n in t)||q(t,n,r)}function N(t,n){for(var r=t.length;r--;)if(cn(t[r][0],n))return r;return-1}function V(t,n){return t&&mt(n,On(n),t)}function W(t,n){return t&&mt(n,mn(n),t)}function q(t,n,r){"__proto__"==n&&Pe?Pe(t,n,{configurable:true,enumerable:true,value:r,writable:true}):t[n]=r}function G(t,r,e,u,o,i){var c,f=r&Un,a=r&Bn,l=r&Cn;if(e&&(c=o?e(t,u,o,i):e(t)),c!==In)return c;
13
+ if(!hn(t))return t;var s=ou(t);if(s){if(c=Tt(t),!f)return Ot(t,c)}else{var h=nu(t),p=h==Qn||h==Xn;if(iu(t))return bt(t,f);if(h==nr||h==Wn||p&&!o){if(c=a||p?{}:Ut(t),!f)return a?zt(t,W(c,t)):At(t,V(c,t))}else{if(!Xr[h])return o?t:{};c=Bt(t,h,f)}}i||(i=new F);var y=i.get(t);if(y)return y;if(i.set(t,c),fu(t))return t.forEach(function(n){c.add(G(n,r,e,n,t,i))}),c;if(cu(t))return t.forEach(function(n,u){c.set(u,G(n,r,e,u,t,i))}),c;var v=l?a?It:Pt:a?mn:On,b=s?In:v(t);return n(b||t,function(n,u){b&&(u=n,
14
+ n=t[u]),D(c,u,G(n,r,e,u,t,i))}),c}function H(t,n,r,e,o){var i=-1,c=t.length;for(r||(r=Ct),o||(o=[]);++i<c;){var f=t[i];n>0&&r(f)?n>1?H(f,n-1,r,e,o):u(o,f):e||(o[o.length]=f)}return o}function J(t,n){n=vt(n,t);for(var r=0,e=n.length;null!=t&&r<e;)t=t[Yt(n[r++])];return r&&r==e?t:In}function K(t,n,r){var e=n(t);return ou(t)?e:u(e,r(t))}function Q(t){return null==t?t===In?fr:tr:Ee&&Ee in Object(t)?Lt(t):Jt(t)}function X(t,n){return null!=t&&ve.call(t,n)}function Y(t,n){return null!=t&&n in Object(t);
15
+ }function Z(t){return pn(t)&&Q(t)==Wn}function tt(t){return pn(t)&&nu(t)==Yn}function nt(t){return!(!hn(t)||Wt(t))&&(ln(t)?de:Sr).test(Zt(t))}function rt(t){return pn(t)&&nu(t)==or}function et(t){return pn(t)&&sn(t.length)&&!!Qr[Q(t)]}function ut(t){if(!qt(t))return Fe(t);var n=[];for(var r in Object(t))ve.call(t,r)&&"constructor"!=r&&n.push(r);return n}function ot(t){if(!hn(t))return Ht(t);var n=qt(t),r=[];for(var e in t)("constructor"!=e||!n&&ve.call(t,e))&&r.push(e);return r}function it(t,n,r,e,u){
16
+ t!==n&&Xe(n,function(o,i){if(hn(o))u||(u=new F),ct(t,n,i,r,it,e,u);else{var c=e?e(s(t,i),o,i+"",t,n,u):In;c===In&&(c=o),R(t,i,c)}},mn)}function ct(t,n,r,e,u,o,i){var c=s(t,r),f=s(n,r),a=i.get(f);if(a)return R(t,r,a),In;var l=o?o(c,f,r+"",t,n,i):In,h=l===In;if(h){var p=ou(f),y=!p&&iu(f),v=!p&&!y&&au(f);l=f,p||y||v?ou(c)?l=c:an(c)?l=Ot(c):y?(h=false,l=bt(f,true)):v?(h=false,l=wt(f,true)):l=[]:yn(f)||uu(f)?(l=c,uu(c)?l=_n(c):(!hn(c)||e&&ln(c))&&(l=Ut(f))):h=false}h&&(i.set(f,l),u(l,f,e,o,i),i.delete(f)),R(t,r,l);
17
+ }function ft(t,n){return at(t,n,function(n,r){return wn(t,r)})}function at(t,n,r){for(var e=-1,u=n.length,o={};++e<u;){var i=n[e],c=J(t,i);r(c,i)&&st(o,vt(i,t),c)}return o}function lt(t,n){return ru(Kt(t,n,Sn),t+"")}function st(t,n,r,e){if(!hn(t))return t;n=vt(n,t);for(var u=-1,o=n.length,i=o-1,c=t;null!=c&&++u<o;){var f=Yt(n[u]),a=r;if(u!=i){var l=c[f];a=e?e(l,f,c):In,a===In&&(a=hn(l)?l:Rt(n[u+1])?[]:{})}D(c,f,a),c=c[f]}return t}function ht(t,n,r){var e=-1,u=t.length;n<0&&(n=-n>u?0:u+n),r=r>u?u:r,
18
+ r<0&&(r+=u),u=n>r?0:r-n>>>0,n>>>=0;for(var o=Array(u);++e<u;)o[e]=t[e+n];return o}function pt(t){if(typeof t=="string")return t;if(ou(t))return e(t,pt)+"";if(bn(t))return Ke?Ke.call(t):"";var n=t+"";return"0"==n&&1/t==-Nn?"-0":n}function yt(t,n){return n=vt(n,t),t=Qt(t,n),null==t||delete t[Yt(nn(n))]}function vt(t,n){return ou(t)?t:Nt(t,n)?[t]:eu(gn(t))}function bt(t,n){if(n)return t.slice();var r=t.length,e=me?me(r):new t.constructor(r);return t.copy(e),e}function _t(t){var n=new t.constructor(t.byteLength);
19
+ return new Oe(n).set(new Oe(t)),n}function gt(t,n){return new t.constructor(n?_t(t.buffer):t.buffer,t.byteOffset,t.byteLength)}function dt(t){var n=new t.constructor(t.source,xr.exec(t));return n.lastIndex=t.lastIndex,n}function jt(t){return Je?Object(Je.call(t)):{}}function wt(t,n){return new t.constructor(n?_t(t.buffer):t.buffer,t.byteOffset,t.length)}function Ot(t,n){var r=-1,e=t.length;for(n||(n=Array(e));++r<e;)n[r]=t[r];return n}function mt(t,n,r,e){var u=!r;r||(r={});for(var o=-1,i=n.length;++o<i;){
20
+ var c=n[o],f=e?e(r[c],t[c],c,r,t):In;f===In&&(f=t[c]),u?q(r,c,f):D(r,c,f)}return r}function At(t,n){return mt(t,Ze(t),n)}function zt(t,n){return mt(t,tu(t),n)}function xt(t){return lt(function(n,r){var e=-1,u=r.length,o=u>1?r[u-1]:In,i=u>2?r[2]:In;for(o=t.length>3&&typeof o=="function"?(u--,o):In,i&&Dt(r[0],r[1],i)&&(o=u<3?In:o,u=1),n=Object(n);++e<u;){var c=r[e];c&&t(n,c,e,o)}return n})}function St(t){return function(n,r,e){for(var u=-1,o=Object(n),i=e(n),c=i.length;c--;){var f=i[t?c:++u];if(r(o[f],f,o)===false)break;
21
+ }return n}}function kt(t){return yn(t)?In:t}function Et(t){return ru(Kt(t,In,tn),t+"")}function Pt(t){return K(t,On,Ze)}function It(t){return K(t,mn,tu)}function $t(t,n){var r=t.__data__;return Vt(n)?r[typeof n=="string"?"string":"hash"]:r.map}function Ft(t,n){var r=f(t,n);return nt(r)?r:In}function Lt(t){var n=ve.call(t,Ee),r=t[Ee];try{t[Ee]=In;var e=true}catch(t){}var u=_e.call(t);return e&&(n?t[Ee]=r:delete t[Ee]),u}function Mt(t,n,r){n=vt(n,t);for(var e=-1,u=n.length,o=false;++e<u;){var i=Yt(n[e]);
22
+ if(!(o=null!=t&&r(t,i)))break;t=t[i]}return o||++e!=u?o:(u=null==t?0:t.length,!!u&&sn(u)&&Rt(i,u)&&(ou(t)||uu(t)))}function Tt(t){var n=t.length,r=new t.constructor(n);return n&&"string"==typeof t[0]&&ve.call(t,"index")&&(r.index=t.index,r.input=t.input),r}function Ut(t){return typeof t.constructor!="function"||qt(t)?{}:Qe(Ae(t))}function Bt(t,n,r){var e=t.constructor;switch(n){case lr:return _t(t);case Hn:case Jn:return new e(+t);case sr:return gt(t,r);case hr:case pr:case yr:case vr:case br:case _r:
23
+ case gr:case dr:case jr:return wt(t,r);case Yn:return new e;case Zn:case ir:return new e(t);case ur:return dt(t);case or:return new e;case cr:return jt(t)}}function Ct(t){return ou(t)||uu(t)||!!(ke&&t&&t[ke])}function Rt(t,n){var r=typeof t;return n=null==n?Vn:n,!!n&&("number"==r||"symbol"!=r&&kr.test(t))&&t>-1&&t%1==0&&t<n}function Dt(t,n,r){if(!hn(r))return false;var e=typeof n;return!!("number"==e?fn(r)&&Rt(n,r.length):"string"==e&&n in r)&&cn(r[n],t)}function Nt(t,n){if(ou(t))return false;var r=typeof t;
24
+ return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!bn(t))||(Or.test(t)||!wr.test(t)||null!=n&&t in Object(n))}function Vt(t){var n=typeof t;return"string"==n||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==t:null===t}function Wt(t){return!!be&&be in t}function qt(t){var n=t&&t.constructor;return t===(typeof n=="function"&&n.prototype||he)}function Gt(t){var n=en(t,function(t){return r.size===Tn&&r.clear(),t}),r=n.cache;return n}function Ht(t){var n=[];if(null!=t)for(var r in Object(t))n.push(r);
25
+ return n}function Jt(t){return _e.call(t)}function Kt(n,r,e){return r=Le(r===In?n.length-1:r,0),function(){for(var u=arguments,o=-1,i=Le(u.length-r,0),c=Array(i);++o<i;)c[o]=u[r+o];o=-1;for(var f=Array(r+1);++o<r;)f[o]=u[o];return f[r]=e(c),t(n,this,f)}}function Qt(t,n){return n.length<2?t:J(t,ht(n,0,-1))}function Xt(t){var n=0,r=0;return function(){var e=Me(),u=Dn-(e-r);if(r=e,u>0){if(++n>=Rn)return arguments[0]}else n=0;return t.apply(In,arguments)}}function Yt(t){if(typeof t=="string"||bn(t))return t;
26
+ var n=t+"";return"0"==n&&1/t==-Nn?"-0":n}function Zt(t){if(null!=t){try{return ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function tn(t){return(null==t?0:t.length)?H(t,1):[]}function nn(t){var n=null==t?0:t.length;return n?t[n-1]:In}function rn(t){if(null==t)return 0;if(fn(t))return vn(t)?h(t):t.length;var n=nu(t);return n==Yn||n==or?t.size:ut(t).length}function en(t,n){if(typeof t!="function"||null!=n&&typeof n!="function")throw new TypeError(Ln);var r=function(){var e=arguments,u=n?n.apply(this,e):e[0],o=r.cache;
27
+ if(o.has(u))return o.get(u);var i=t.apply(this,e);return r.cache=o.set(u,i)||o,i};return r.cache=new(en.Cache||S),r}function un(t){return G(t,Cn)}function on(t){return G(t,Un|Cn)}function cn(t,n){return t===n||t!==t&&n!==n}function fn(t){return null!=t&&sn(t.length)&&!ln(t)}function an(t){return pn(t)&&fn(t)}function ln(t){if(!hn(t))return false;var n=Q(t);return n==Qn||n==Xn||n==Gn||n==er}function sn(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Vn}function hn(t){var n=typeof t;return null!=t&&("object"==n||"function"==n);
28
+ }function pn(t){return null!=t&&typeof t=="object"}function yn(t){if(!pn(t)||Q(t)!=nr)return false;var n=Ae(t);if(null===n)return true;var r=ve.call(n,"constructor")&&n.constructor;return typeof r=="function"&&r instanceof r&&ye.call(r)==ge}function vn(t){return typeof t=="string"||!ou(t)&&pn(t)&&Q(t)==ir}function bn(t){return typeof t=="symbol"||pn(t)&&Q(t)==cr}function _n(t){return mt(t,mn(t))}function gn(t){return null==t?"":pt(t)}function dn(t,n,r){var e=null==t?In:J(t,n);return e===In?r:e}function jn(t,n){
29
+ return null!=t&&Mt(t,n,X)}function wn(t,n){return null!=t&&Mt(t,n,Y)}function On(t){return fn(t)?C(t):ut(t)}function mn(t){return fn(t)?C(t,true):ot(t)}function An(t,n,r){return null==t?t:st(t,n,r)}function zn(t,n){return null==t||yt(t,n)}function xn(t){return function(){return t}}function Sn(t){return t}function kn(){return[]}function En(){return false}function Pn(t){return ou(t)?e(t,Yt):bn(t)?[t]:Ot(eu(gn(t)))}var In,$n="4.17.5",Fn=200,Ln="Expected a function",Mn="__lodash_hash_undefined__",Tn=500,Un=1,Bn=2,Cn=4,Rn=800,Dn=16,Nn=1/0,Vn=9007199254740991,Wn="[object Arguments]",qn="[object Array]",Gn="[object AsyncFunction]",Hn="[object Boolean]",Jn="[object Date]",Kn="[object Error]",Qn="[object Function]",Xn="[object GeneratorFunction]",Yn="[object Map]",Zn="[object Number]",tr="[object Null]",nr="[object Object]",rr="[object Promise]",er="[object Proxy]",ur="[object RegExp]",or="[object Set]",ir="[object String]",cr="[object Symbol]",fr="[object Undefined]",ar="[object WeakMap]",lr="[object ArrayBuffer]",sr="[object DataView]",hr="[object Float32Array]",pr="[object Float64Array]",yr="[object Int8Array]",vr="[object Int16Array]",br="[object Int32Array]",_r="[object Uint8Array]",gr="[object Uint8ClampedArray]",dr="[object Uint16Array]",jr="[object Uint32Array]",wr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Or=/^\w*$/,mr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ar=/[\\^$.*+?()[\]{}|]/g,zr=/\\(\\)?/g,xr=/\w*$/,Sr=/^\[object .+?Constructor\]$/,kr=/^(?:0|[1-9]\d*)$/,Er="\\ud800-\\udfff",Pr="\\u0300-\\u036f",Ir="\\ufe20-\\ufe2f",$r="\\u20d0-\\u20ff",Fr=Pr+Ir+$r,Lr="\\ufe0e\\ufe0f",Mr="["+Er+"]",Tr="["+Fr+"]",Ur="\\ud83c[\\udffb-\\udfff]",Br="(?:"+Tr+"|"+Ur+")",Cr="[^"+Er+"]",Rr="(?:\\ud83c[\\udde6-\\uddff]){2}",Dr="[\\ud800-\\udbff][\\udc00-\\udfff]",Nr="\\u200d",Vr=Br+"?",Wr="["+Lr+"]?",qr="(?:"+Nr+"(?:"+[Cr,Rr,Dr].join("|")+")"+Wr+Vr+")*",Gr=Wr+Vr+qr,Hr="(?:"+[Cr+Tr+"?",Tr,Rr,Dr,Mr].join("|")+")",Jr=RegExp(Ur+"(?="+Ur+")|"+Hr+Gr,"g"),Kr=RegExp("["+Nr+Er+Fr+Lr+"]"),Qr={};
30
+ Qr[hr]=Qr[pr]=Qr[yr]=Qr[vr]=Qr[br]=Qr[_r]=Qr[gr]=Qr[dr]=Qr[jr]=true,Qr[Wn]=Qr[qn]=Qr[lr]=Qr[Hn]=Qr[sr]=Qr[Jn]=Qr[Kn]=Qr[Qn]=Qr[Yn]=Qr[Zn]=Qr[nr]=Qr[ur]=Qr[or]=Qr[ir]=Qr[ar]=false;var Xr={};Xr[Wn]=Xr[qn]=Xr[lr]=Xr[sr]=Xr[Hn]=Xr[Jn]=Xr[hr]=Xr[pr]=Xr[yr]=Xr[vr]=Xr[br]=Xr[Yn]=Xr[Zn]=Xr[nr]=Xr[ur]=Xr[or]=Xr[ir]=Xr[cr]=Xr[_r]=Xr[gr]=Xr[dr]=Xr[jr]=true,Xr[Kn]=Xr[Qn]=Xr[ar]=false;var Yr=typeof global=="object"&&global&&global.Object===Object&&global,Zr=typeof self=="object"&&self&&self.Object===Object&&self,te=Yr||Zr||Function("return this")(),ne=typeof exports=="object"&&exports&&!exports.nodeType&&exports,re=ne&&typeof module=="object"&&module&&!module.nodeType&&module,ee=re&&re.exports===ne,ue=ee&&Yr.process,oe=function(){
31
+ try{return ue&&ue.binding&&ue.binding("util")}catch(t){}}(),ie=oe&&oe.isMap,ce=oe&&oe.isSet,fe=oe&&oe.isTypedArray,ae=o("length"),le=Array.prototype,se=Function.prototype,he=Object.prototype,pe=te["__core-js_shared__"],ye=se.toString,ve=he.hasOwnProperty,be=function(){var t=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),_e=he.toString,ge=ye.call(Object),de=RegExp("^"+ye.call(ve).replace(Ar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),je=ee?te.Buffer:In,we=te.Symbol,Oe=te.Uint8Array,me=je?je.allocUnsafe:In,Ae=l(Object.getPrototypeOf,Object),ze=Object.create,xe=he.propertyIsEnumerable,Se=le.splice,ke=we?we.isConcatSpreadable:In,Ee=we?we.toStringTag:In,Pe=function(){
32
+ try{var t=Ft(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ie=Object.getOwnPropertySymbols,$e=je?je.isBuffer:In,Fe=l(Object.keys,Object),Le=Math.max,Me=Date.now,Te=Ft(te,"DataView"),Ue=Ft(te,"Map"),Be=Ft(te,"Promise"),Ce=Ft(te,"Set"),Re=Ft(te,"WeakMap"),De=Ft(Object,"create"),Ne=Zt(Te),Ve=Zt(Ue),We=Zt(Be),qe=Zt(Ce),Ge=Zt(Re),He=we?we.prototype:In,Je=He?He.valueOf:In,Ke=He?He.toString:In,Qe=function(){function t(){}return function(n){if(!hn(n))return{};if(ze)return ze(n);t.prototype=n;
33
+ var r=new t;return t.prototype=In,r}}();v.prototype.clear=b,v.prototype.delete=_,v.prototype.get=g,v.prototype.has=d,v.prototype.set=j,w.prototype.clear=O,w.prototype.delete=m,w.prototype.get=A,w.prototype.has=z,w.prototype.set=x,S.prototype.clear=k,S.prototype.delete=E,S.prototype.get=P,S.prototype.has=I,S.prototype.set=$,F.prototype.clear=L,F.prototype.delete=M,F.prototype.get=T,F.prototype.has=U,F.prototype.set=B;var Xe=St(),Ye=Pe?function(t,n){return Pe(t,"toString",{configurable:true,enumerable:false,
34
+ value:xn(n),writable:true})}:Sn,Ze=Ie?function(t){return null==t?[]:(t=Object(t),r(Ie(t),function(n){return xe.call(t,n)}))}:kn,tu=Ie?function(t){for(var n=[];t;)u(n,Ze(t)),t=Ae(t);return n}:kn,nu=Q;(Te&&nu(new Te(new ArrayBuffer(1)))!=sr||Ue&&nu(new Ue)!=Yn||Be&&nu(Be.resolve())!=rr||Ce&&nu(new Ce)!=or||Re&&nu(new Re)!=ar)&&(nu=function(t){var n=Q(t),r=n==nr?t.constructor:In,e=r?Zt(r):"";if(e)switch(e){case Ne:return sr;case Ve:return Yn;case We:return rr;case qe:return or;case Ge:return ar}return n;
35
+ });var ru=Xt(Ye),eu=Gt(function(t){var n=[];return 46===t.charCodeAt(0)&&n.push(""),t.replace(mr,function(t,r,e,u){n.push(e?u.replace(zr,"$1"):r||t)}),n});en.Cache=S;var uu=Z(function(){return arguments}())?Z:function(t){return pn(t)&&ve.call(t,"callee")&&!xe.call(t,"callee")},ou=Array.isArray,iu=$e||En,cu=ie?c(ie):tt,fu=ce?c(ce):rt,au=fe?c(fe):et,lu=xt(function(t,n,r){it(t,n,r)}),su=xt(function(t,n,r,e){it(t,n,r,e)}),hu=Et(function(t,n){var r={};if(null==t)return r;var u=false;n=e(n,function(n){return n=vt(n,t),
36
+ u||(u=n.length>1),n}),mt(t,It(t),r),u&&(r=G(r,Un|Bn|Cn,kt));for(var o=n.length;o--;)yt(r,n[o]);return r}),pu=Et(function(t,n){return null==t?{}:ft(t,n)});y.constant=xn,y.flatten=tn,y.keys=On,y.keysIn=mn,y.memoize=en,y.merge=lu,y.mergeWith=su,y.omit=hu,y.pick=pu,y.set=An,y.toPath=Pn,y.toPlainObject=_n,y.unset=zn,y.clone=un,y.cloneDeep=on,y.eq=cn,y.get=dn,y.has=jn,y.hasIn=wn,y.identity=Sn,y.isArguments=uu,y.isArray=ou,y.isArrayLike=fn,y.isArrayLikeObject=an,y.isBuffer=iu,y.isFunction=ln,y.isLength=sn,
37
+ y.isMap=cu,y.isObject=hn,y.isObjectLike=pn,y.isPlainObject=yn,y.isSet=fu,y.isString=vn,y.isSymbol=bn,y.isTypedArray=au,y.last=nn,y.stubArray=kn,y.stubFalse=En,y.size=rn,y.toString=gn,y.VERSION=$n,typeof define=="function"&&typeof define.amd=="object"&&define.amd?(te._=y, define(function(){return y})):re?((re.exports=y)._=y,ne._=y):te._=y}).call(this);
@@ -1,32 +1,16 @@
1
- /// <reference types="node" />
2
- /**
3
- * Helper class to base64 encode/decode values with option
4
- * for url encoding and decoding
5
- */
1
+ /// <reference types="node" resolution-mode="require"/>
6
2
  declare class Base64 {
7
- /**
8
- * Base64 encode Buffer or string
9
- */
10
3
  encode(arrayBuffer: ArrayBuffer | SharedArrayBuffer): string;
11
4
  encode(data: string, encoding?: BufferEncoding): string;
12
- /**
13
- * Base64 decode a previously encoded string or Buffer.
14
- */
15
- decode(encode: string, encoding: BufferEncoding, strict: true): string | null;
16
- decode(encode: string, encoding: undefined, strict: true): string | null;
17
- decode(encode: string, encoding?: BufferEncoding, strict?: false): string;
5
+ decode(encode: string, encoding: BufferEncoding, strict: true): string;
6
+ decode(encode: string, encoding: undefined, strict: true): string;
7
+ decode(encode: string, encoding?: BufferEncoding, strict?: false): string | null;
18
8
  decode(encode: Buffer, encoding?: BufferEncoding): string;
19
- /**
20
- * Base64 encode Buffer or string to be URL safe. (RFC 4648)
21
- */
22
9
  urlEncode(arrayBuffer: ArrayBuffer | SharedArrayBuffer): string;
23
10
  urlEncode(data: string, encoding?: BufferEncoding): string;
24
- /**
25
- * Base64 URL decode a previously encoded string or Buffer. (RFC 4648)
26
- */
27
- urlDecode(encode: string, encoding: BufferEncoding, strict: true): string | null;
28
- urlDecode(encode: string, encoding: undefined, strict: true): string | null;
29
- urlDecode(encode: string, encoding?: BufferEncoding, strict?: false): string;
11
+ urlDecode(encode: string, encoding: BufferEncoding, strict: true): string;
12
+ urlDecode(encode: string, encoding: undefined, strict: true): string;
13
+ urlDecode(encode: string, encoding?: BufferEncoding, strict?: false): string | null;
30
14
  urlDecode(encode: Buffer, encoding?: BufferEncoding): string;
31
15
  }
32
16
  export declare const base64: Base64;
@@ -1,18 +1,3 @@
1
- "use strict";
2
- /*
3
- * @poppinss/utils
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.base64 = void 0;
12
- /**
13
- * Helper class to base64 encode/decode values with option
14
- * for url encoding and decoding
15
- */
16
1
  class Base64 {
17
2
  encode(data, encoding) {
18
3
  if (typeof data === 'string') {
@@ -25,10 +10,11 @@ class Base64 {
25
10
  return encoded.toString(encoding);
26
11
  }
27
12
  const decoded = Buffer.from(encoded, 'base64').toString(encoding);
28
- if (strict && this.encode(decoded, encoding) !== encoded) {
29
- return null;
13
+ const isInvalid = this.encode(decoded, encoding) !== encoded;
14
+ if (strict && isInvalid) {
15
+ throw new Error('Cannot decode malformed value');
30
16
  }
31
- return decoded;
17
+ return isInvalid ? null : decoded;
32
18
  }
33
19
  urlEncode(data, encoding) {
34
20
  const encoded = typeof data === 'string' ? this.encode(data, encoding) : this.encode(data);
@@ -39,10 +25,11 @@ class Base64 {
39
25
  return encoded.toString(encoding);
40
26
  }
41
27
  const decoded = Buffer.from(encoded, 'base64').toString(encoding);
42
- if (strict && this.urlEncode(decoded, encoding) !== encoded) {
43
- return null;
28
+ const isInvalid = this.urlEncode(decoded, encoding) !== encoded;
29
+ if (strict && isInvalid) {
30
+ throw new Error('Cannot urlDecode malformed value');
44
31
  }
45
- return decoded;
32
+ return isInvalid ? null : decoded;
46
33
  }
47
34
  }
48
- exports.base64 = new Base64();
35
+ export const base64 = new Base64();
@@ -1,21 +1,10 @@
1
1
  declare type Constructor = new (...args: any[]) => any;
2
- /**
3
- * Normalizes constructor to work with mixins. There is an open bug for mixins
4
- * to allow constructors other than `...args: any[]`
5
- *
6
- * https://github.com/microsoft/TypeScript/issues/37142
7
- */
8
2
  export declare type NormalizeConstructor<T extends Constructor> = {
9
3
  new (...args: any[]): InstanceType<T>;
10
4
  } & Omit<T, 'constructor'>;
11
5
  export interface UnaryFunction<T, R> {
12
6
  (source: T): R;
13
7
  }
14
- /**
15
- * Compose a class by applying mixins to it.
16
- * The code is inspired by https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/, its
17
- * just that I have added the support for static types too.
18
- */
19
8
  export declare function compose<T extends Constructor, A>(superclass: T, mixin: UnaryFunction<T, A>): A;
20
9
  export declare function compose<T extends Constructor, A, B>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>): B;
21
10
  export declare function compose<T extends Constructor, A, B, C>(superclass: T, mixin: UnaryFunction<T, A>, mixinB: UnaryFunction<A, B>, mixinC: UnaryFunction<B, C>): C;
@@ -0,0 +1,3 @@
1
+ export function compose(superclass, ...mixins) {
2
+ return mixins.reduce((c, mixin) => mixin(c), superclass);
3
+ }
@@ -1,11 +1,7 @@
1
1
  declare type Constructor = new (...args: any[]) => any;
2
2
  declare type AbstractConstructor = abstract new (...args: any[]) => any;
3
- /**
4
- * Define static properties on a class with inheritance in play.
5
- */
6
- export declare function defineStaticProperty<T extends Constructor | AbstractConstructor, Prop extends keyof T>(self: T, BaseClass: Constructor | AbstractConstructor, { propertyName, defaultValue, strategy, }: {
7
- propertyName: Prop;
8
- defaultValue: T[Prop];
3
+ export declare function defineStaticProperty<T extends Constructor | AbstractConstructor, Prop extends keyof T>(self: T, propertyName: Prop, { initialValue, strategy, }: {
4
+ initialValue: T[Prop];
9
5
  strategy: 'inherit' | 'define' | ((value: T[Prop]) => T[Prop]);
10
6
  }): void;
11
7
  export {};
@@ -0,0 +1,21 @@
1
+ import lodash from '@poppinss/utils/lodash';
2
+ export function defineStaticProperty(self, propertyName, { initialValue, strategy, }) {
3
+ if (!self.hasOwnProperty(propertyName)) {
4
+ const value = self[propertyName];
5
+ if (strategy === 'define' || value === undefined) {
6
+ Object.defineProperty(self, propertyName, {
7
+ value: initialValue,
8
+ configurable: true,
9
+ enumerable: true,
10
+ writable: true,
11
+ });
12
+ return;
13
+ }
14
+ Object.defineProperty(self, propertyName, {
15
+ value: typeof strategy === 'function' ? strategy(value) : lodash.cloneDeep(value),
16
+ configurable: true,
17
+ enumerable: true,
18
+ writable: true,
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,16 @@
1
+ export declare class Exception extends Error {
2
+ static help?: string;
3
+ static code?: string;
4
+ static status?: number;
5
+ static message?: string;
6
+ name: string;
7
+ help?: string;
8
+ code?: string;
9
+ status: number;
10
+ constructor(message?: string, options?: ErrorOptions & {
11
+ code?: string;
12
+ status?: number;
13
+ });
14
+ [Symbol.toStringTag](): string;
15
+ toString(): string;
16
+ }
@@ -0,0 +1,29 @@
1
+ export class Exception extends Error {
2
+ name;
3
+ status;
4
+ constructor(message, options) {
5
+ super(message, options);
6
+ const ErrorConstructor = this.constructor;
7
+ this.name = ErrorConstructor.name;
8
+ this.message = message || ErrorConstructor.message || '';
9
+ this.status = options?.status || ErrorConstructor.status || 500;
10
+ const code = options?.code || ErrorConstructor.code;
11
+ if (code !== undefined) {
12
+ this.code = code;
13
+ }
14
+ const help = ErrorConstructor.help;
15
+ if (help !== undefined) {
16
+ this.help = help;
17
+ }
18
+ Error.captureStackTrace(this, ErrorConstructor);
19
+ }
20
+ [Symbol.toStringTag]() {
21
+ return this.constructor.name;
22
+ }
23
+ toString() {
24
+ if (this.code) {
25
+ return `${this.name} [${this.code}]: ${this.message}`;
26
+ }
27
+ return `${this.name}: ${this.message}`;
28
+ }
29
+ }
@@ -1 +1 @@
1
- export { flattie as flatten } from 'flattie';
1
+ export declare function flatten<X = Record<string, any>, Y = unknown>(input: Y, glue?: string, keepNullish?: boolean): X;
@@ -1,13 +1,4 @@
1
- "use strict";
2
- /*
3
- * @poppinss/utils
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.flatten = void 0;
12
- var flattie_1 = require("flattie");
13
- Object.defineProperty(exports, "flatten", { enumerable: true, get: function () { return flattie_1.flattie; } });
1
+ import { flattie } from 'flattie';
2
+ export function flatten(input, glue, keepNullish) {
3
+ return flattie(input, glue, keepNullish);
4
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { ImportAllFilesOptions } from './types.js';
3
+ export declare function fsImportAll(location: string | URL, options?: ImportAllFilesOptions): Promise<any>;
@@ -0,0 +1,28 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import lodash from '@poppinss/utils/lodash';
3
+ import { extname, relative, sep } from 'node:path';
4
+ import { fsReadAll } from './fs_read_all.js';
5
+ import { isScriptFile } from './is_script_file.js';
6
+ async function importFile(basePath, fileURL, values, options) {
7
+ const filePath = fileURLToPath(fileURL);
8
+ const fileExtension = extname(filePath);
9
+ const collectionKey = relative(basePath, filePath)
10
+ .replace(new RegExp(`${fileExtension}$`), '')
11
+ .split(sep);
12
+ const exportedValue = fileExtension === '.json'
13
+ ? await import(fileURL, { assert: { type: 'json' } })
14
+ : await import(fileURL);
15
+ lodash.set(values, options.transformKeys ? options.transformKeys(collectionKey) : collectionKey, exportedValue.default ? exportedValue.default : { ...exportedValue });
16
+ }
17
+ export async function fsImportAll(location, options) {
18
+ options = options || {};
19
+ const collection = {};
20
+ const normalizedLocation = typeof location === 'string' ? location : fileURLToPath(location);
21
+ const files = await fsReadAll(normalizedLocation, {
22
+ filter: isScriptFile,
23
+ ...options,
24
+ pathType: 'url',
25
+ });
26
+ await Promise.all(files.map((file) => importFile(normalizedLocation, file, collection, options)));
27
+ return collection;
28
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { ReadAllFilesOptions } from './types.js';
3
+ export declare function fsReadAll(location: string | URL, options?: ReadAllFilesOptions): Promise<string[]>;
@@ -0,0 +1,55 @@
1
+ import { join } from 'node:path';
2
+ import { readdir, stat } from 'node:fs/promises';
3
+ import { fileURLToPath, pathToFileURL } from 'node:url';
4
+ import { slash } from './slash.js';
5
+ import { naturalSort } from './natural_sort.js';
6
+ function filterDotFiles(fileName) {
7
+ return fileName[0] !== '.';
8
+ }
9
+ async function readFiles(root, files, options, relativePath) {
10
+ const location = join(root, relativePath);
11
+ const stats = await stat(location);
12
+ if (stats.isDirectory()) {
13
+ let locationFiles = await readdir(location);
14
+ await Promise.all(locationFiles.filter(filterDotFiles).map((file) => {
15
+ return readFiles(root, files, options, join(relativePath, file));
16
+ }));
17
+ return;
18
+ }
19
+ switch (options.pathType) {
20
+ case 'relative':
21
+ default:
22
+ files.push(relativePath);
23
+ break;
24
+ case 'absolute':
25
+ files.push(location);
26
+ break;
27
+ case 'unixRelative':
28
+ files.push(slash(relativePath));
29
+ break;
30
+ case 'unixAbsolute':
31
+ files.push(slash(location));
32
+ break;
33
+ case 'url':
34
+ files.push(pathToFileURL(location).href);
35
+ }
36
+ }
37
+ export async function fsReadAll(location, options) {
38
+ const normalizedLocation = typeof location === 'string' ? location : fileURLToPath(location);
39
+ const normalizedOptions = Object.assign({ absolute: false, sort: naturalSort }, options);
40
+ const files = [];
41
+ try {
42
+ await stat(normalizedLocation);
43
+ }
44
+ catch (error) {
45
+ if (normalizedOptions.ignoreMissingRoot) {
46
+ return [];
47
+ }
48
+ throw error;
49
+ }
50
+ await readFiles(normalizedLocation, files, normalizedOptions, '');
51
+ if (normalizedOptions.filter) {
52
+ return files.filter(normalizedOptions.filter).sort(normalizedOptions.sort);
53
+ }
54
+ return files.sort(normalizedOptions.sort);
55
+ }
@@ -0,0 +1 @@
1
+ export declare function isScriptFile(filePath: string): boolean;
@@ -0,0 +1,12 @@
1
+ import { extname } from 'node:path';
2
+ const JS_MODULES = ['.js', '.json', '.cjs', '.mjs'];
3
+ export function isScriptFile(filePath) {
4
+ const ext = extname(filePath);
5
+ if (JS_MODULES.includes(ext)) {
6
+ return true;
7
+ }
8
+ if (ext === '.ts' && !filePath.endsWith('.d.ts')) {
9
+ return true;
10
+ }
11
+ return false;
12
+ }
@@ -0,0 +1,7 @@
1
+ import { safeParse } from './safe_parse.js';
2
+ import { safeStringify } from './safe_stringify.js';
3
+ declare const json: {
4
+ safeParse: typeof safeParse;
5
+ safeStringify: typeof safeStringify;
6
+ };
7
+ export default json;
@@ -0,0 +1,7 @@
1
+ import { safeParse } from './safe_parse.js';
2
+ import { safeStringify } from './safe_stringify.js';
3
+ const json = {
4
+ safeParse,
5
+ safeStringify,
6
+ };
7
+ export default json;
@@ -0,0 +1,2 @@
1
+ import { JSONReviver } from '../types.js';
2
+ export declare function safeParse(jsonString: string, reviver?: JSONReviver): any;
@@ -0,0 +1,7 @@
1
+ import { parse } from 'secure-json-parse';
2
+ export function safeParse(jsonString, reviver) {
3
+ return parse(jsonString, reviver, {
4
+ protoAction: 'remove',
5
+ constructorAction: 'remove',
6
+ });
7
+ }
@@ -0,0 +1,2 @@
1
+ import { JSONReplacer } from '../types.js';
2
+ export declare function safeStringify(value: any, replacer?: JSONReplacer, space?: string | number): string;
@@ -0,0 +1,18 @@
1
+ import { configure } from 'safe-stable-stringify';
2
+ const stringify = configure({
3
+ bigint: false,
4
+ circularValue: undefined,
5
+ deterministic: false,
6
+ });
7
+ function jsonStringifyReplacer(replacer) {
8
+ return function (key, value) {
9
+ const val = replacer ? replacer.call(this, key, value) : value;
10
+ if (typeof val === 'bigint') {
11
+ return val.toString();
12
+ }
13
+ return val;
14
+ };
15
+ }
16
+ export function safeStringify(value, replacer, space) {
17
+ return stringify(value, jsonStringifyReplacer(replacer), space);
18
+ }
@@ -0,0 +1,5 @@
1
+ export declare class MessageBuilder {
2
+ #private;
3
+ build(message: any, expiresIn?: string | number, purpose?: string): string;
4
+ verify<T extends any>(message: any, purpose?: string): null | T;
5
+ }
@@ -0,0 +1,43 @@
1
+ import json from './json/main.js';
2
+ import milliseconds from './string/milliseconds.js';
3
+ export class MessageBuilder {
4
+ #getExpiryDate(expiresIn) {
5
+ if (!expiresIn) {
6
+ return undefined;
7
+ }
8
+ const expiryMs = milliseconds.parse(expiresIn);
9
+ return new Date(Date.now() + expiryMs);
10
+ }
11
+ #isExpired(message) {
12
+ if (!message.expiryDate) {
13
+ return false;
14
+ }
15
+ try {
16
+ const expiryDate = new Date(message.expiryDate);
17
+ return Number.isNaN(expiryDate.getTime()) || expiryDate < new Date();
18
+ }
19
+ catch (error) {
20
+ return true;
21
+ }
22
+ }
23
+ build(message, expiresIn, purpose) {
24
+ const expiryDate = this.#getExpiryDate(expiresIn);
25
+ return json.safeStringify({ message, purpose, expiryDate });
26
+ }
27
+ verify(message, purpose) {
28
+ const parsed = json.safeParse(message);
29
+ if (parsed === message) {
30
+ return null;
31
+ }
32
+ if (!parsed.message) {
33
+ return null;
34
+ }
35
+ if (parsed.purpose !== purpose) {
36
+ return null;
37
+ }
38
+ if (this.#isExpired(parsed)) {
39
+ return null;
40
+ }
41
+ return parsed.message;
42
+ }
43
+ }
@@ -0,0 +1 @@
1
+ export declare function naturalSort(current: string, next: string): number;
@@ -0,0 +1,3 @@
1
+ export function naturalSort(current, next) {
2
+ return current.localeCompare(next, undefined, { numeric: true, sensitivity: 'base' });
3
+ }