@cyberskill/shared 1.35.0 → 1.37.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.
Files changed (135) hide show
  1. package/README.md +8 -12
  2. package/dist/_tsup-dts-rollup.d.cts +7239 -0
  3. package/dist/_tsup-dts-rollup.d.ts +7239 -0
  4. package/dist/cli.d.cts +1 -0
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/configs/commitlint/base.d.cts +1 -5
  7. package/dist/configs/commitlint/base.d.ts +1 -5
  8. package/dist/configs/eslint/base.d.cts +1 -1154
  9. package/dist/configs/eslint/base.d.ts +1 -1154
  10. package/dist/configs/eslint/nestjs.d.cts +1 -1156
  11. package/dist/configs/eslint/nestjs.d.ts +1 -1156
  12. package/dist/configs/eslint/nextjs.d.cts +1 -1156
  13. package/dist/configs/eslint/nextjs.d.ts +1 -1156
  14. package/dist/configs/eslint/nodejs.d.cts +1 -1156
  15. package/dist/configs/eslint/nodejs.d.ts +1 -1156
  16. package/dist/configs/eslint/vite-react.d.cts +1 -1157
  17. package/dist/configs/eslint/vite-react.d.ts +1 -1157
  18. package/dist/configs/graphql/graphql-codegen.d.cts +1 -6
  19. package/dist/configs/graphql/graphql-codegen.d.ts +1 -6
  20. package/dist/configs/graphql/index.d.cts +1 -3
  21. package/dist/configs/graphql/index.d.ts +1 -3
  22. package/dist/configs/i18n/react/i18next.d.cts +1 -6
  23. package/dist/configs/i18n/react/i18next.d.ts +1 -6
  24. package/dist/configs/i18n/react/index.d.cts +1 -2
  25. package/dist/configs/i18n/react/index.d.ts +1 -2
  26. package/dist/configs/index.d.cts +1 -9
  27. package/dist/configs/index.d.ts +1 -9
  28. package/dist/configs/lint-staged/base.d.cts +1 -5
  29. package/dist/configs/lint-staged/base.d.ts +1 -5
  30. package/dist/configs/vitest/react/e2e.d.cts +1 -5
  31. package/dist/configs/vitest/react/e2e.d.ts +1 -5
  32. package/dist/configs/vitest/react/unit.d.cts +1 -5
  33. package/dist/configs/vitest/react/unit.d.ts +1 -5
  34. package/dist/configs/vitest/react/unit.setup.d.cts +1 -2
  35. package/dist/configs/vitest/react/unit.setup.d.ts +1 -2
  36. package/dist/constants/index.d.cts +3 -2
  37. package/dist/constants/index.d.ts +3 -2
  38. package/dist/constants/path.d.cts +2 -4
  39. package/dist/constants/path.d.ts +2 -4
  40. package/dist/constants/response-status.d.cts +1 -252
  41. package/dist/constants/response-status.d.ts +1 -252
  42. package/dist/index.cjs +1 -1
  43. package/dist/index.d.cts +118 -40
  44. package/dist/index.d.ts +118 -40
  45. package/dist/index.js +1 -1
  46. package/dist/nodejs/index.cjs +1 -1
  47. package/dist/nodejs/index.d.cts +11 -5
  48. package/dist/nodejs/index.d.ts +11 -5
  49. package/dist/nodejs/index.js +1 -1
  50. package/dist/nodejs/mongo.cjs +1 -1
  51. package/dist/nodejs/mongo.d.cts +3 -55
  52. package/dist/nodejs/mongo.d.ts +3 -55
  53. package/dist/nodejs/mongo.js +1 -1
  54. package/dist/nodejs/mongoose.cjs +1 -1
  55. package/dist/nodejs/mongoose.d.cts +8 -25
  56. package/dist/nodejs/mongoose.d.ts +8 -25
  57. package/dist/nodejs/mongoose.js +1 -1
  58. package/dist/react/apollo-client.d.cts +1 -9
  59. package/dist/react/apollo-client.d.ts +1 -9
  60. package/dist/react/index.d.cts +11 -15
  61. package/dist/react/index.d.ts +11 -15
  62. package/dist/react/loading.d.cts +4 -13
  63. package/dist/react/loading.d.ts +4 -13
  64. package/dist/react/loading.module.d.cts +1 -2
  65. package/dist/react/loading.module.d.ts +1 -2
  66. package/dist/react/next-intl.d.cts +5 -28
  67. package/dist/react/next-intl.d.ts +5 -28
  68. package/dist/react/storage.d.cts +1 -5
  69. package/dist/react/storage.d.ts +1 -5
  70. package/dist/styles/reset.css +1 -63
  71. package/dist/styles/reset.d.cts +1 -2
  72. package/dist/styles/reset.d.ts +1 -2
  73. package/dist/typescript/apollo.d.cts +5 -21
  74. package/dist/typescript/apollo.d.ts +5 -21
  75. package/dist/typescript/command.d.cts +4 -30
  76. package/dist/typescript/command.d.ts +4 -30
  77. package/dist/typescript/config.d.cts +1 -5
  78. package/dist/typescript/config.d.ts +1 -5
  79. package/dist/typescript/graphql-codegen.d.cts +1 -12
  80. package/dist/typescript/graphql-codegen.d.ts +1 -12
  81. package/dist/typescript/index.d.cts +72 -16
  82. package/dist/typescript/index.d.ts +72 -16
  83. package/dist/typescript/loading.d.cts +1 -8
  84. package/dist/typescript/loading.d.ts +1 -8
  85. package/dist/typescript/log.d.cts +1 -10
  86. package/dist/typescript/log.d.ts +1 -10
  87. package/dist/typescript/mongoose.d.cts +53 -163
  88. package/dist/typescript/mongoose.d.ts +53 -163
  89. package/dist/typescript/next-intl.d.cts +3 -23
  90. package/dist/typescript/next-intl.d.ts +3 -23
  91. package/dist/typescript/react.d.cts +2 -11
  92. package/dist/typescript/react.d.ts +2 -11
  93. package/dist/typescript/serializer.d.cts +1 -6
  94. package/dist/typescript/serializer.d.ts +1 -6
  95. package/dist/utils/command.d.cts +5 -17
  96. package/dist/utils/command.d.ts +5 -17
  97. package/dist/utils/common.d.cts +3 -5
  98. package/dist/utils/common.d.ts +3 -5
  99. package/dist/utils/config.d.cts +1 -5
  100. package/dist/utils/config.d.ts +1 -5
  101. package/dist/utils/fs.d.cts +1 -3
  102. package/dist/utils/fs.d.ts +1 -3
  103. package/dist/utils/index-nodejs.cjs +1 -1
  104. package/dist/utils/index-nodejs.d.cts +14 -13
  105. package/dist/utils/index-nodejs.d.ts +14 -13
  106. package/dist/utils/index-nodejs.js +1 -1
  107. package/dist/utils/index.cjs +1 -1
  108. package/dist/utils/index.d.cts +7 -8
  109. package/dist/utils/index.d.ts +7 -8
  110. package/dist/utils/index.js +1 -1
  111. package/dist/utils/log.d.cts +1 -5
  112. package/dist/utils/log.d.ts +1 -5
  113. package/dist/utils/npm-package.d.cts +4 -6
  114. package/dist/utils/npm-package.d.ts +4 -6
  115. package/dist/utils/serializer.d.cts +1 -5
  116. package/dist/utils/serializer.d.ts +1 -5
  117. package/dist/utils/storage-client.d.cts +1 -8
  118. package/dist/utils/storage-client.d.ts +1 -8
  119. package/dist/utils/storage-server.d.cts +3 -11
  120. package/dist/utils/storage-server.d.ts +3 -11
  121. package/dist/utils/validate.d.cts +1 -14
  122. package/dist/utils/validate.d.ts +1 -14
  123. package/package.json +10 -18
  124. package/dist/commands.d.cts +0 -1
  125. package/dist/commands.d.ts +0 -1
  126. package/dist/utils/datetime.cjs +0 -1
  127. package/dist/utils/datetime.d.cts +0 -3
  128. package/dist/utils/datetime.d.ts +0 -3
  129. package/dist/utils/datetime.js +0 -1
  130. package/dist/utils/mongoose.cjs +0 -1
  131. package/dist/utils/mongoose.d.cts +0 -22
  132. package/dist/utils/mongoose.d.ts +0 -22
  133. package/dist/utils/mongoose.js +0 -1
  134. /package/dist/{commands.cjs → cli.cjs} +0 -0
  135. /package/dist/{commands.js → cli.js} +0 -0
@@ -1 +1 @@
1
- function e(e,r,t,n,o,a,i){try{var s=e[a](i);var c=s.value}catch(e){t(e);return}if(s.done){r(c)}else{Promise.resolve(c).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,a){var i=r.apply(t,n);function s(r){e(i,o,a,s,c,"next",r)}function c(r){e(i,o,a,s,c,"throw",r)}s(undefined)})}}function t(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(r){t(e,r,n[r])})}return e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function a(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,r){if(e==null)return{};var t=s(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function s(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,a;for(a=0;a<n.length;a++){o=n[a];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function c(e,r){var t,n,o,a,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return c([e,r])}}function c(a){if(t)throw new TypeError("Generator is already executing.");while(i)try{if(t=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=r.call(e,i)}catch(e){a=[6,e];n=0}finally{t=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}import u from"boxen";import E from"chalk";import{exec as l}from"node:child_process";import f from"node:process";import*as d from"node:util";import S from"node-persist";import p from"node:os";import g from"node:path";import h from"node:process";var O=h.env.CYBERSKILL_STORAGE_DIR||g.join(p.homedir(),".cyberskill-storage");function v(){return m.apply(this,arguments)}function m(){m=r(function(){var e;return c(this,function(r){switch(r.label){case 0:e=S.defaultInstance;if(e)return[3,2];return[4,S.init({dir:O,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return m.apply(this,arguments)}var A={get:function e(e){return r(function(){var r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,v()];case 1:n.sent();return[4,S.getItem(e)];case 2:return[2,(r=n.sent())!==null&&r!==void 0?r:null];case 3:t=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return r(function(){var r;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,v()];case 1:n.sent();return[4,S.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,v()];case 1:t.sent();return[4,S.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,v()];case 1:t.sent();return[4,S.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return c(this,function(r){try{return[2,"".concat(O," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var y=f.env.DEBUG==="true",D=d.promisify(l),T=E.gray,R=E.blue,_=function(){return T("[".concat(new Date().toLocaleTimeString(),"]"))};function C(e){var r=E[e];return typeof r=="function"?r:E.green}function I(e,r,t,n){var o=C(r);console.log("".concat(_()," ").concat(o("".concat(t," ").concat(e))," ").concat(n))}function M(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,o=n===void 0?"green":n,a=t.padding,i=a===void 0?1:a,s=t.margin,c=s===void 0?1:s,E=t.borderStyle,l=E===void 0?"round":E,f=t.titleColor,d=f===void 0?"bold":f;var S=C(o),p=C(d);if(typeof r=="string"){console.log(u(p(S("".concat(e,"\n").concat(r))),{padding:i,margin:c,borderStyle:l,borderColor:o}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,o=e.message;console.log("".concat(_()," ").concat(S("File:")," ").concat(R("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(S("Rule:")," ").concat(S(n))),console.log(" ".concat(S("Message:")," ").concat(S(o)))}),console.log(u(p(S("".concat(e,": ").concat(r.length))),{padding:i,margin:c,borderStyle:l,borderColor:o})),console.log(T("─".repeat(40))))}var N={success:function(e){return I("SUCCESS","green","✔",e)},error:function(e){return I("ERROR","red","✖",e)},warning:function(e){return I("WARNING","yellow","⚠",e)},info:function(e){return I("INFO","blue","ℹ",e)},printBoxedLog:M},G=function(e){return"error_list:".concat(e)};function P(e){return b.apply(this,arguments)}function b(){b=r(function(e){var t,n,o;return c(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];t=Date.now(),n=G(t);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,A.set(n,{errors:e,timestamp:t})];case 2:a.sent(),setTimeout(/*#__PURE__*/r(function(){var e;return c(this,function(r){switch(r.label){case 0:return[4,A.getLogLink(n)];case 1:e=r.sent();e&&N.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=a.sent();N.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return b.apply(this,arguments)}function w(){return L.apply(this,arguments)}function L(){L=r(function(){var e,t,n;return c(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,A.keys()];case 1:e=o.sent(),t=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=r(function(e){var r;return c(this,function(t){switch(t.label){case 0:return[4,A.get(e)];case 1:return[2,((r=t.sent())===null||r===void 0?void 0:r.errors)||[]]}})});return function(r){return e.apply(this,arguments)}}()))];case 2:return[2,o.sent().flat()];case 3:n=o.sent();return[2,(N.error("Failed to retrieve stored errors: ".concat(n.message)),[])];case 4:return[2]}})});return L.apply(this,arguments)}function U(){return F.apply(this,arguments)}function F(){F=r(function(){var e,r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,A.keys()];case 1:e=n.sent(),r=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(r.map(function(e){return A.remove(e)}))];case 2:n.sent();return[3,4];case 3:t=n.sent();N.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return F.apply(this,arguments)}function k(e){var r=[],t=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,i=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var s=o.exec(e)||[],c=a.exec(e)||[],u=i.exec(e)||[];s.length&&n?r.push({file:n,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()}):c.length?r.push({file:c[1],position:"".concat(c[2],":").concat(c[3]),type:c[4]==="error"?"error":"warning",message:c[5].trim()}):u.length?r.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):t.push(e.trim())}}),r.length&&P(r),t.length&&y&&(N.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function j(e){try{var r=JSON.parse(e),t=[];r.forEach(function(e){var r=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,a=e.column,i=e.ruleId,s=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(o,":").concat(a),rule:i,message:s})})}),t.length&&P(t)}catch(r){k(e)}}function x(e){return q.apply(this,arguments)}function q(){q=r(function(e){var r,t,n,o,a,i,s,u,E;var l=arguments;return c(this,function(c){switch(c.label){case 0:r=l.length>1&&l[1]!==void 0?l[1]:j;t=new AbortController;f.on("SIGINT",function(){N.warning("Process interrupted. Terminating..."),t.abort(),f.exit()});c.label=1;case 1:c.trys.push([1,3,,4]);return[4,D(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=c.sent(),o=n.stdout,a=n.stderr;[o,a].forEach(function(e){return e&&r(e)});return[3,4];case 3:i=c.sent();s=i.stdout,u=i.stderr,E=i.message;[s,u].forEach(function(e){return e&&r(e)}),!u&&!s&&N.error("Command failed: ".concat(E));return[3,4];case 4:return[2]}})});return q.apply(this,arguments)}import*as Q from"node:fs";var H=function(e){return Q.existsSync(e)};import{GraphQLError as B}from"graphql";var Y={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function V(e){var r=e.message,t=e.status,n=t===void 0?Y.INTERNAL_SERVER_ERROR:t,o=e.type,a=o===void 0?"graphql":o;var i;var s=(i=r!==null&&r!==void 0?r:n.MESSAGE)!==null&&i!==void 0?i:"Internal server error";throw a==="graphql"?new B(s,{extensions:{code:n.CODE}}):new Error(s)}import W from"crypto-js";import J from"mongoose-aggregate-paginate-v2";import K from"mongoose-paginate-v2";import $ from"slugify";import{v4 as X}from"uuid";import{format as z}from"date-fns";function Z(){return z(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function ee(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function er(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function et(e){return new e.Schema({id:{type:String,default:X,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function en(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,a=e.standalone,i=a===void 0?!1:a;var s=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=s.virtual(r,t);n&&o.get(n)}),i||s.add(et(r)),s}function eo(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,a=o===void 0?!1:o,i=e.aggregate,s=i===void 0?!1:i,c=e.virtuals,u=c===void 0?[]:c,E=e.middlewares,l=E===void 0?[]:E;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var f=en({mongoose:r,schema:n,virtuals:u});return ee(f,[a&&K,s&&J]),er(f,l),r.model(t,f)}var ea=$.default||$;function ei(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;var t=r||{},o=t.lower,a=o===void 0?!0:o,s=t.locale,c=s===void 0?"vi":s,u=i(t,["lower","locale"]);return ea(e,n({lower:a,locale:c},u))}function es(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return W.SHA256(e).toString(W.enc.Hex).slice(0,r)}function ec(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;return a(n({},r,t&&{id:{$ne:t}}),{$or:[{slug:e},{slugHistory:e}]})}function eu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.isNew,t=r===void 0?!0:r,o=e.returnDateAs,i=o===void 0?"string":o;var s=i==="string"?Z():new Date;return a(n({},t&&{id:X()}),{isDel:!1,createdAt:s,updatedAt:s})}import eE from"node-fetch";import el from"node:fs";import ef from"node:path";import{dirname as ed}from"node:path";import eS from"node:process";import{fileURLToPath as ep}from"node:url";var eg=ep(import.meta.url),eh=ed(eg),eO=eS.env.INIT_CWD||eS.cwd();var ev=24*60*60*1e3;function em(e){return e?ef.join(eO,"node_modules",e,"package.json"):ef.join(eO,"package.json")}function eA(e){return ey.apply(this,arguments)}function ey(){ey=r(function(e){var r,t,n,o,a,i,s,u,E,l;var f=arguments;return c(this,function(c){switch(c.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:!1;t="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,A.get(t)];case 1:o=c.sent();return[4,A.get(n)];case 2:a=c.sent(),i=o&&Date.now()-o.timestamp<ev;if(!r&&i)return[2,(N.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];s={};(a===null||a===void 0?void 0:a.etag)&&(s["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(s["If-Modified-Since"]=a.lastModified);c.label=3;case 3:c.trys.push([3,8,,9]);N.info("Fetching latest version for ".concat(e,"..."));return[4,eE("https://registry.npmjs.org/".concat(e,"/latest"),{headers:s})];case 4:u=c.sent();if(u.status===304&&o)return[2,(N.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:E=c.sent().version;return[4,A.set(t,{version:E,timestamp:Date.now()})];case 6:c.sent();return[4,A.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(c.sent(),N.success("Cached latest version for ".concat(e,": ").concat(E)),E)];case 8:l=c.sent();if(N.error("Error fetching latest version for ".concat(e,": ").concat(l.message)),o)return[2,(N.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw l;case 9:return[2]}})});return ey.apply(this,arguments)}function eD(e){return eT.apply(this,arguments)}function eT(){eT=r(function(e){var r,t,n,o,a;var i=arguments;return c(this,function(s){switch(s.label){case 0:r=i.length>1&&i[1]!==void 0?i[1]:!0;s.label=1;case 1:s.trys.push([1,3,,4]);t=em(e);if(!el.existsSync(t))return[2,(N.info("".concat(e," is not installed.")),!0)];n=JSON.parse(el.readFileSync(t,"utf-8")).version;return[4,eA(e,r)];case 2:o=s.sent();return[2,(N.info("Installed version of ".concat(e,": ").concat(n)),N.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=s.sent();return[2,(N.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return eT.apply(this,arguments)}function eR(e){return e_.apply(this,arguments)}function e_(){e_=r(function(e){var r,o,i,s;return c(this,function(c){switch(c.label){case 0:c.trys.push([0,4,,5]);return[4,eA(e,!0)];case 1:r=c.sent(),o=em();if(!el.existsSync(o)){N.error("package.json not found. Cannot update ".concat(e));return[2]}i=JSON.parse(el.readFileSync(o,"utf-8"));i.dependencies=a(n({},i.dependencies),t({},e,r)),el.writeFileSync(o,JSON.stringify(i,null,2)),N.info("Updated ".concat(e," to version ").concat(r));return[4,x("npm i -f")];case 2:c.sent();return[4,x("npm run lint:fix")];case 3:c.sent(),N.success("".concat(e," updated successfully."));return[3,5];case 4:s=c.sent();throw N.error("Failed to update ".concat(e,": ").concat(s.message)),s;case 5:return[2]}})});return e_.apply(this,arguments)}function eC(e,r){try{var t=ef.join(e,"package.json");return el.existsSync(t)?JSON.parse(el.readFileSync(t,"utf-8")).name===r:!1}catch(e){return N.error("Error reading package.json: ".concat(e.message)),!1}}export{J as aggregatePaginate,U as clearAllErrorLists,N as commandLog,x as executeCommand,H as fileExists,eo as generateModel,en as generateSchema,es as generateShortId,ei as generateSlug,ec as generateSlugQuery,eA as getLatestPackageVersion,eu as getMongoGenericFields,w as getStoredErrorLists,v as initNodePersist,eC as isCurrentProject,eD as isPackageOutdated,K as mongoosePaginate,P as saveErrorListToStorage,O as storageDir,A as storageServer,V as throwResponse,eR as updatePackage};
1
+ function e(e,r,t,n,o,a,s){try{var i=e[a](s);var c=i.value}catch(e){t(e);return}if(i.done){r(c)}else{Promise.resolve(c).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,a){var s=r.apply(t,n);function i(r){e(s,o,a,i,c,"next",r)}function c(r){e(s,o,a,i,c,"throw",r)}i(undefined)})}}function t(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(r){t(e,r,n[r])})}return e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function a(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,r){var t,n,o,a,s={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),"throw":i(1),"return":i(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function i(e){return function(r){return c([e,r])}}function c(a){if(t)throw new TypeError("Generator is already executing.");while(s)try{if(t=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:s.label++;return{value:a[1],done:false};case 5:s.label++;n=a[1];a=[0];continue;case 7:a=s.ops.pop();s.trys.pop();continue;default:if(!(o=s.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){s=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(a[0]===6&&s.label<o[1]){s.label=o[1];o=a;break}if(o&&s.label<o[2]){s.label=o[2];s.ops.push(a);break}if(o[2])s.ops.pop();s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e];n=0}finally{t=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}import i from"boxen";import c from"chalk";import{exec as u}from"node:child_process";import E from"node:process";import*as l from"node:util";import f from"node-persist";import S from"node:os";import p from"node:path";import d from"node:process";var O=d.env.CYBERSKILL_STORAGE_DIR||p.join(S.homedir(),".cyberskill-storage");function h(){return g.apply(this,arguments)}function g(){g=r(function(){var e;return s(this,function(r){switch(r.label){case 0:e=f.defaultInstance;if(e)return[3,2];return[4,f.init({dir:O,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return g.apply(this,arguments)}var A={get:function e(e){return r(function(){var r,t;return s(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,h()];case 1:n.sent();return[4,f.getItem(e)];case 2:return[2,(r=n.sent())!==null&&r!==void 0?r:null];case 3:t=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return r(function(){var r;return s(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,h()];case 1:n.sent();return[4,f.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return s(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,h()];case 1:t.sent();return[4,f.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return s(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,h()];case 1:t.sent();return[4,f.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return s(this,function(r){try{return[2,"".concat(O," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var v=E.env.DEBUG==="true",m=l.promisify(u),T=c.gray,y=c.blue,D=function(){return T("[".concat(new Date().toLocaleTimeString(),"]"))};function R(e){var r=c[e];return typeof r=="function"?r:c.green}function C(e,r,t,n){var o=R(r);console.log("".concat(D()," ").concat(o("".concat(t," ").concat(e))," ").concat(n))}function _(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,o=n===void 0?"green":n,a=t.padding,s=a===void 0?1:a,c=t.margin,u=c===void 0?1:c,E=t.borderStyle,l=E===void 0?"round":E,f=t.titleColor,S=f===void 0?"bold":f;var p=R(o),d=R(S);if(typeof r=="string"){console.log(i(d(p("".concat(e,"\n").concat(r))),{padding:s,margin:u,borderStyle:l,borderColor:o}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,o=e.message;console.log("".concat(D()," ").concat(p("File:")," ").concat(y("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(p("Rule:")," ").concat(p(n))),console.log(" ".concat(p("Message:")," ").concat(p(o)))}),console.log(i(d(p("".concat(e,": ").concat(r.length))),{padding:s,margin:u,borderStyle:l,borderColor:o})),console.log(T("─".repeat(40))))}var I={success:function(e){return C("SUCCESS","green","✔",e)},error:function(e){return C("ERROR","red","✖",e)},warning:function(e){return C("WARNING","yellow","⚠",e)},info:function(e){return C("INFO","blue","ℹ",e)},printBoxedLog:_},N=function(e){return"error_list:".concat(e)};function M(e){return G.apply(this,arguments)}function G(){G=r(function(e){var t,n,o;return s(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];t=Date.now(),n=N(t);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,A.set(n,{errors:e,timestamp:t})];case 2:a.sent(),setTimeout(/*#__PURE__*/r(function(){var e;return s(this,function(r){switch(r.label){case 0:return[4,A.getLogLink(n)];case 1:e=r.sent();e&&I.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=a.sent();I.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return G.apply(this,arguments)}function P(){return b.apply(this,arguments)}function b(){b=r(function(){var e,t,n;return s(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,A.keys()];case 1:e=o.sent(),t=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=r(function(e){var r;return s(this,function(t){switch(t.label){case 0:return[4,A.get(e)];case 1:return[2,((r=t.sent())===null||r===void 0?void 0:r.errors)||[]]}})});return function(r){return e.apply(this,arguments)}}()))];case 2:return[2,o.sent().flat()];case 3:n=o.sent();return[2,(I.error("Failed to retrieve stored errors: ".concat(n.message)),[])];case 4:return[2]}})});return b.apply(this,arguments)}function L(){return w.apply(this,arguments)}function w(){w=r(function(){var e,r,t;return s(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,A.keys()];case 1:e=n.sent(),r=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(r.map(function(e){return A.remove(e)}))];case 2:n.sent();return[3,4];case 3:t=n.sent();I.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return w.apply(this,arguments)}function U(e){var r=[],t=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,s=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var i=o.exec(e)||[],c=a.exec(e)||[],u=s.exec(e)||[];i.length&&n?r.push({file:n,position:"".concat(i[1],":").concat(i[2]),type:i[3]==="error"?"error":"warning",message:i[4].trim(),rule:i[5].trim()}):c.length?r.push({file:c[1],position:"".concat(c[2],":").concat(c[3]),type:c[4]==="error"?"error":"warning",message:c[5].trim()}):u.length?r.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):t.push(e.trim())}}),r.length&&M(r),t.length&&v&&(I.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function F(e){try{var r=JSON.parse(e),t=[];r.forEach(function(e){var r=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,a=e.column,s=e.ruleId,i=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(o,":").concat(a),rule:s,message:i})})}),t.length&&M(t)}catch(r){U(e)}}function k(e){return x.apply(this,arguments)}function x(){x=r(function(e){var r,t,n,o,a,i,c,u,l;var f=arguments;return s(this,function(s){switch(s.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:F;t=new AbortController;E.on("SIGINT",function(){I.warning("Process interrupted. Terminating..."),t.abort(),E.exit()});s.label=1;case 1:s.trys.push([1,3,,4]);return[4,m(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=s.sent(),o=n.stdout,a=n.stderr;[o,a].forEach(function(e){return e&&r(e)});return[3,4];case 3:i=s.sent();c=i.stdout,u=i.stderr,l=i.message;[c,u].forEach(function(e){return e&&r(e)}),!u&&!c&&I.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return x.apply(this,arguments)}import*as j from"node:fs";var Q=function(e){return j.existsSync(e)};import{GraphQLError as q}from"graphql";var H={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function B(e){var r=e.message,t=e.status,n=t===void 0?H.INTERNAL_SERVER_ERROR:t,o=e.type,a=o===void 0?"graphql":o;var s;var i=(s=r!==null&&r!==void 0?r:n.MESSAGE)!==null&&s!==void 0?s:"Internal server error";throw a==="graphql"?new q(i,{extensions:{code:n.CODE}}):new Error(i)}import Y from"node-fetch";import V from"node:fs";import W from"node:path";import{dirname as J}from"node:path";import K from"node:process";import{fileURLToPath as X}from"node:url";var $=X(import.meta.url),z=J($),Z=K.env.INIT_CWD||K.cwd();var ee=24*60*60*1e3;function er(e){return e?W.join(Z,"node_modules",e,"package.json"):W.join(Z,"package.json")}function et(e){return en.apply(this,arguments)}function en(){en=r(function(e){var r,t,n,o,a,i,c,u,E,l;var f=arguments;return s(this,function(s){switch(s.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:!1;t="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,A.get(t)];case 1:o=s.sent();return[4,A.get(n)];case 2:a=s.sent(),i=o&&Date.now()-o.timestamp<ee;if(!r&&i)return[2,(I.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];c={};(a===null||a===void 0?void 0:a.etag)&&(c["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(c["If-Modified-Since"]=a.lastModified);s.label=3;case 3:s.trys.push([3,8,,9]);I.info("Fetching latest version for ".concat(e,"..."));return[4,Y("https://registry.npmjs.org/".concat(e,"/latest"),{headers:c})];case 4:u=s.sent();if(u.status===304&&o)return[2,(I.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:E=s.sent().version;return[4,A.set(t,{version:E,timestamp:Date.now()})];case 6:s.sent();return[4,A.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(s.sent(),I.success("Cached latest version for ".concat(e,": ").concat(E)),E)];case 8:l=s.sent();if(I.error("Error fetching latest version for ".concat(e,": ").concat(l.message)),o)return[2,(I.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw l;case 9:return[2]}})});return en.apply(this,arguments)}function eo(e){return ea.apply(this,arguments)}function ea(){ea=r(function(e){var r,t,n,o,a;var i=arguments;return s(this,function(s){switch(s.label){case 0:r=i.length>1&&i[1]!==void 0?i[1]:!0;s.label=1;case 1:s.trys.push([1,3,,4]);t=er(e);if(!V.existsSync(t))return[2,(I.info("".concat(e," is not installed.")),!0)];n=JSON.parse(V.readFileSync(t,"utf-8")).version;return[4,et(e,r)];case 2:o=s.sent();return[2,(I.info("Installed version of ".concat(e,": ").concat(n)),I.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=s.sent();return[2,(I.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return ea.apply(this,arguments)}function es(e){return ei.apply(this,arguments)}function ei(){ei=r(function(e){var r,o,i,c;return s(this,function(s){switch(s.label){case 0:s.trys.push([0,4,,5]);return[4,et(e,!0)];case 1:r=s.sent(),o=er();if(!V.existsSync(o)){I.error("package.json not found. Cannot update ".concat(e));return[2]}i=JSON.parse(V.readFileSync(o,"utf-8"));i.dependencies=a(n({},i.dependencies),t({},e,r)),V.writeFileSync(o,JSON.stringify(i,null,2)),I.info("Updated ".concat(e," to version ").concat(r));return[4,k("npm i -f")];case 2:s.sent();return[4,k("npm run lint:fix")];case 3:s.sent(),I.success("".concat(e," updated successfully."));return[3,5];case 4:c=s.sent();throw I.error("Failed to update ".concat(e,": ").concat(c.message)),c;case 5:return[2]}})});return ei.apply(this,arguments)}function ec(e,r){try{var t=W.join(e,"package.json");return V.existsSync(t)?JSON.parse(V.readFileSync(t,"utf-8")).name===r:!1}catch(e){return I.error("Error reading package.json: ".concat(e.message)),!1}}export{L as clearAllErrorLists,I as commandLog,k as executeCommand,Q as fileExists,et as getLatestPackageVersion,P as getStoredErrorLists,h as initNodePersist,ec as isCurrentProject,eo as isPackageOutdated,M as saveErrorListToStorage,O as storageDir,A as storageServer,B as throwResponse,es as updatePackage};
@@ -1 +1 @@
1
- "use strict";function e(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function r(e){if(Array.isArray(e))return e}function t(r){if(Array.isArray(r))return e(r)}function n(e,r,t,n,o,u,a){try{var i=e[u](a);var c=i.value}catch(e){t(e);return}if(i.done){r(c)}else{Promise.resolve(c).then(n,o)}}function o(e){return function(){var r=this,t=arguments;return new Promise(function(o,u){var a=e.apply(r,t);function i(e){n(a,o,u,i,c,"next",e)}function c(e){n(a,o,u,i,c,"throw",e)}i(undefined)})}}function u(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function a(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function i(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function c(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var o=true;var u=false;var a,i;try{for(t=t.call(e);!(o=(a=t.next()).done);o=true){n.push(a.value);if(r&&n.length===r)break}}catch(e){u=true;i=e}finally{try{if(!o&&t["return"]!=null)t["return"]()}finally{if(u)throw i}}return n}function f(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))}n.forEach(function(r){u(e,r,t[r])})}return e}function y(e,t){return r(e)||c(e,t)||d(e,t)||f()}function p(e){return t(e)||i(e)||d(e)||l()}function v(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function d(r,t){if(!r)return;if(typeof r==="string")return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if(n==="Object"&&r.constructor)n=r.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}function b(e,r){var t,n,o,u,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:i(0),"throw":i(1),"return":i(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function i(e){return function(r){return c([e,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var m=Object.create;var h=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var A=function(e,r){for(var t in r)h(e,t,{get:r[t],enumerable:!0})},j=function(e,r,t,n){var o=true,u=false,a=undefined;if(r&&(typeof r==="undefined"?"undefined":v(r))=="object"||typeof r=="function")try{var i=function(){var o=f.value;!O.call(e,o)&&o!==t&&h(e,o,{get:function(){return r[o]},enumerable:!(n=g(r,o))||n.enumerable})};for(var c=w(r)[Symbol.iterator](),f;!(o=(f=c.next()).done);o=true)i()}catch(e){u=true;a=e}finally{try{if(!o&&c.return!=null){c.return()}}finally{if(u){throw a}}}return e};var E=function(e,r,t){return t=e!=null?m(S(e)):{},j(r||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)},_=function(e){return j(h({},"__esModule",{value:!0}),e)};var x={};A(x,{deepMerge:function(){return U},getMongoDateTime:function(){return C},isJson:function(){return M},regexSearchMapper:function(){return I},removeAccent:function(){return R},serializer:function(){return J},storageClient:function(){return N},validate:function(){return q}});module.exports=_(x);var k=E(require("unorm"),1);function M(e){try{return JSON.parse(e),!0}catch(e){return!1}}var P={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},D=Object.entries(P).reduce(function(e,r){var t=y(r,2),n=t[0],o=t[1];return e[n.toUpperCase()]=o.map(function(e){return e.toUpperCase()}),e},{});function I(e){e=k.default.nfkc(e);var r=s({},P,D);var t=true,n=false,o=undefined;try{for(var u=Object.entries(r)[Symbol.iterator](),a;!(t=(a=u.next()).done);t=true){var i=y(a.value,2),c=i[0],f=i[1];var l="[".concat(c).concat(f.join(""),"]"),v="(".concat([c].concat(p(f)).join("|"),")");e=e.replace(new RegExp(l,"g"),v)}}catch(e){n=true;o=e}finally{try{if(!t&&u.return!=null){u.return()}}finally{if(n){throw o}}}return e}function R(e){return e.normalize("NFD").replace(RegExp("\\p{Diacritic}","gu"),"")}function U(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=function(e,r){var t=s({},e);return Object.keys(r).forEach(function(e){if(!Object.hasOwnProperty.call(r,e))return;var o=r[e],u=t[e];Array.isArray(o)?t[e]=p(new Set(p(Array.isArray(u)?u:[]).concat(p(o)))):(typeof o==="undefined"?"undefined":v(o))=="object"&&o!==null&&!Array.isArray(o)?t[e]=n((typeof u==="undefined"?"undefined":v(u))=="object"&&u!==null&&!Array.isArray(u)?u:{},o):t[e]=o}),t};return r.flatMap(function(e){return Array.isArray(e)?e:[e]}).reduce(function(e,r){return n(e,r)},{})}var z=require("date-fns");function C(){return(0,z.format)(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}var J={serialize:function(e){return JSON.stringify(e,function(e,r){return a(r,Date)?{__type:"Date",value:r.toISOString()}:r})},deserialize:function(e){return JSON.parse(e,function(e,r){return(r===null||r===void 0?void 0:r.__type)==="Date"?new Date(r.value):r})}};var T=E(require("localforage"),1),N={get:function e(e){return o(function(){var r;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,T.default.getItem(e)];case 1:return[2,t.sent()];case 2:r=t.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),r),null)];case 3:return[2]}})})()},set:function e(e,r){return o(function(){var t;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,T.default.setItem(e,r)];case 1:n.sent();return[3,3];case 2:t=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},remove:function e(e){return o(function(){var r;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,T.default.removeItem(e)];case 1:t.sent();return[3,3];case 2:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},keys:function e(){return o(function(){var e,r;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,T.default.keys()];case 1:return[2,(e=t.sent())!==null&&e!==void 0?e:[]];case 2:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 3:return[2]}})})()}};var q={common:{isEmpty:function e(e){return e==null?!0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":v(e))=="object"?a(e,Date)?!1:Object.keys(e).length===0:typeof e=="string"?e.trim().length===0:!1},isEmptyValidator:function e(){return /*#__PURE__*/function(){var e=o(function(e){return b(this,function(r){return[2,!q.common.isEmpty(e)]})});return function(r){return e.apply(this,arguments)}}()},isUniqueValidator:function e(e){return /*#__PURE__*/function(){var r=o(function(r){var t;return b(this,function(n){switch(n.label){case 0:if(!Array.isArray(e)||e.length===0)throw new Error("Fields must be a non-empty array of strings.");t={$or:e.map(function(e){return u({},e,r)})};return[4,this.constructor.findOne(t)];case 1:return[2,!n.sent()]}})});return function(e){return r.apply(this,arguments)}}()},matchesRegexValidator:function e(e){return /*#__PURE__*/function(){var r=o(function(r){return b(this,function(t){if(!Array.isArray(e)||e.some(function(e){return!a(e,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,e.every(function(e){return e.test(r)})]})});return function(e){return r.apply(this,arguments)}}()}}};0&&(module.exports={deepMerge:deepMerge,getMongoDateTime:getMongoDateTime,isJson:isJson,regexSearchMapper:regexSearchMapper,removeAccent:removeAccent,serializer:serializer,storageClient:storageClient,validate:validate});
1
+ "use strict";function r(r,e){if(e==null||e>r.length)e=r.length;for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function e(r){if(Array.isArray(r))return r}function t(e){if(Array.isArray(e))return r(e)}function n(r,e,t,n,o,u,a){try{var i=r[u](a);var c=i.value}catch(r){t(r);return}if(i.done){e(c)}else{Promise.resolve(c).then(n,o)}}function o(r){return function(){var e=this,t=arguments;return new Promise(function(o,u){var a=r.apply(e,t);function i(r){n(a,o,u,i,c,"next",r)}function c(r){n(a,o,u,i,c,"throw",r)}i(undefined)})}}function u(r,e,t){if(e in r){Object.defineProperty(r,e,{value:t,enumerable:true,configurable:true,writable:true})}else{r[e]=t}return r}function a(r,e){if(e!=null&&typeof Symbol!=="undefined"&&e[Symbol.hasInstance]){return!!e[Symbol.hasInstance](r)}else{return r instanceof e}}function i(r){if(typeof Symbol!=="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function c(r,e){var t=r==null?null:typeof Symbol!=="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t==null)return;var n=[];var o=true;var u=false;var a,i;try{for(t=t.call(r);!(o=(a=t.next()).done);o=true){n.push(a.value);if(e&&n.length===e)break}}catch(r){u=true;i=r}finally{try{if(!o&&t["return"]!=null)t["return"]()}finally{if(u)throw i}}return n}function l(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))}n.forEach(function(e){u(r,e,t[e])})}return r}function y(r,t){return e(r)||c(r,t)||d(r,t)||l()}function p(r){return t(r)||i(r)||d(r)||f()}function v(r){"@swc/helpers - typeof";return r&&typeof Symbol!=="undefined"&&r.constructor===Symbol?"symbol":typeof r}function d(e,t){if(!e)return;if(typeof e==="string")return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}function b(r,e){var t,n,o,u,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:i(0),"throw":i(1),"return":i(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function i(r){return function(e){return c([r,e])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=e.call(r,a)}catch(r){u=[6,r];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var h=Object.create;var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var A=function(r,e){for(var t in e)m(r,t,{get:e[t],enumerable:!0})},j=function(r,e,t,n){var o=true,u=false,a=undefined;if(e&&(typeof e==="undefined"?"undefined":v(e))=="object"||typeof e=="function")try{var i=function(){var o=l.value;!O.call(r,o)&&o!==t&&m(r,o,{get:function(){return e[o]},enumerable:!(n=g(e,o))||n.enumerable})};for(var c=w(e)[Symbol.iterator](),l;!(o=(l=c.next()).done);o=true)i()}catch(r){u=true;a=r}finally{try{if(!o&&c.return!=null){c.return()}}finally{if(u){throw a}}}return r};var E=function(r,e,t){return t=r!=null?h(S(r)):{},j(e||!r||!r.__esModule?m(t,"default",{value:r,enumerable:!0}):t,r)},_=function(r){return j(m({},"__esModule",{value:!0}),r)};var x={};A(x,{deepMerge:function(){return U},isJson:function(){return P},regexSearchMapper:function(){return D},removeAccent:function(){return R},serializer:function(){return z},storageClient:function(){return J},validate:function(){return N}});module.exports=_(x);var k=E(require("unorm"),1);function P(r){try{return JSON.parse(r),!0}catch(r){return!1}}var I={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},M=Object.entries(I).reduce(function(r,e){var t=y(e,2),n=t[0],o=t[1];return r[n.toUpperCase()]=o.map(function(r){return r.toUpperCase()}),r},{});function D(r){r=k.default.nfkc(r);var e=s({},I,M);var t=true,n=false,o=undefined;try{for(var u=Object.entries(e)[Symbol.iterator](),a;!(t=(a=u.next()).done);t=true){var i=y(a.value,2),c=i[0],l=i[1];var f="[".concat(c).concat(l.join(""),"]"),v="(".concat([c].concat(p(l)).join("|"),")");r=r.replace(new RegExp(f,"g"),v)}}catch(r){n=true;o=r}finally{try{if(!t&&u.return!=null){u.return()}}finally{if(n){throw o}}}return r}function R(r){return r.normalize("NFD").replace(RegExp("\\p{Diacritic}","gu"),"")}function U(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++){e[t]=arguments[t]}var n=function(r,e){var t=s({},r);return Object.keys(e).forEach(function(r){if(!Object.hasOwnProperty.call(e,r))return;var o=e[r],u=t[r];Array.isArray(o)?t[r]=p(new Set(p(Array.isArray(u)?u:[]).concat(p(o)))):(typeof o==="undefined"?"undefined":v(o))=="object"&&o!==null&&!Array.isArray(o)?t[r]=n((typeof u==="undefined"?"undefined":v(u))=="object"&&u!==null&&!Array.isArray(u)?u:{},o):t[r]=o}),t};return e.flatMap(function(r){return Array.isArray(r)?r:[r]}).reduce(function(r,e){return n(r,e)},{})}var z={serialize:function(r){return JSON.stringify(r,function(r,e){return a(e,Date)?{__type:"Date",value:e.toISOString()}:e})},deserialize:function(r){return JSON.parse(r,function(r,e){return(e===null||e===void 0?void 0:e.__type)==="Date"?new Date(e.value):e})}};var C=E(require("localforage"),1),J={get:function r(r){return o(function(){var e;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,C.default.getItem(r)];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(r,'":'),e),null)];case 3:return[2]}})})()},set:function r(r,e){return o(function(){var t;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,C.default.setItem(r,e)];case 1:n.sent();return[3,3];case 2:t=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(r,'":'),t);return[3,3];case 3:return[2]}})})()},remove:function r(r){return o(function(){var e;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,C.default.removeItem(r)];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(r,'":'),e);return[3,3];case 3:return[2]}})})()},keys:function r(){return o(function(){var r,e;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,C.default.keys()];case 1:return[2,(r=t.sent())!==null&&r!==void 0?r:[]];case 2:e=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",e),[])];case 3:return[2]}})})()}};var N={common:{isEmpty:function r(r){return r==null?!0:Array.isArray(r)?r.length===0:(typeof r==="undefined"?"undefined":v(r))=="object"?a(r,Date)?!1:Object.keys(r).length===0:typeof r=="string"?r.trim().length===0:!1},isEmptyValidator:function r(){return /*#__PURE__*/function(){var r=o(function(r){return b(this,function(e){return[2,!N.common.isEmpty(r)]})});return function(e){return r.apply(this,arguments)}}()},isUniqueValidator:function r(r){return /*#__PURE__*/function(){var e=o(function(e){var t;return b(this,function(n){switch(n.label){case 0:if(!Array.isArray(r)||r.length===0)throw new Error("Fields must be a non-empty array of strings.");t={$or:r.map(function(r){return u({},r,e)})};return[4,this.constructor.findOne(t)];case 1:return[2,!n.sent()]}})});return function(r){return e.apply(this,arguments)}}()},matchesRegexValidator:function r(r){return /*#__PURE__*/function(){var e=o(function(e){return b(this,function(t){if(!Array.isArray(r)||r.some(function(r){return!a(r,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,r.every(function(r){return r.test(e)})]})});return function(r){return e.apply(this,arguments)}}()}}};0&&(module.exports={deepMerge:deepMerge,isJson:isJson,regexSearchMapper:regexSearchMapper,removeAccent:removeAccent,serializer:serializer,storageClient:storageClient,validate:validate});
@@ -1,8 +1,7 @@
1
- export { isJson, regexSearchMapper, removeAccent } from './common.cjs';
2
- export { deepMerge } from './config.cjs';
3
- export { getMongoDateTime } from './datetime.cjs';
4
- export { serializer } from './serializer.cjs';
5
- export { storageClient } from './storage-client.cjs';
6
- export { validate } from './validate.cjs';
7
- import '../typescript/config.cjs';
8
- import '../typescript/serializer.cjs';
1
+ export { isJson_alias_2 as isJson } from '../_tsup-dts-rollup.cjs';
2
+ export { regexSearchMapper_alias_2 as regexSearchMapper } from '../_tsup-dts-rollup.cjs';
3
+ export { removeAccent_alias_2 as removeAccent } from '../_tsup-dts-rollup.cjs';
4
+ export { deepMerge_alias_2 as deepMerge } from '../_tsup-dts-rollup.cjs';
5
+ export { serializer_alias_1 as serializer } from '../_tsup-dts-rollup.cjs';
6
+ export { storageClient_alias_1 as storageClient } from '../_tsup-dts-rollup.cjs';
7
+ export { validate_alias_1 as validate } from '../_tsup-dts-rollup.cjs';
@@ -1,8 +1,7 @@
1
- export { isJson, regexSearchMapper, removeAccent } from './common.js';
2
- export { deepMerge } from './config.js';
3
- export { getMongoDateTime } from './datetime.js';
4
- export { serializer } from './serializer.js';
5
- export { storageClient } from './storage-client.js';
6
- export { validate } from './validate.js';
7
- import '../typescript/config.js';
8
- import '../typescript/serializer.js';
1
+ export { isJson_alias_2 as isJson } from '../_tsup-dts-rollup.js';
2
+ export { regexSearchMapper_alias_2 as regexSearchMapper } from '../_tsup-dts-rollup.js';
3
+ export { removeAccent_alias_2 as removeAccent } from '../_tsup-dts-rollup.js';
4
+ export { deepMerge_alias_2 as deepMerge } from '../_tsup-dts-rollup.js';
5
+ export { serializer_alias_1 as serializer } from '../_tsup-dts-rollup.js';
6
+ export { storageClient_alias_1 as storageClient } from '../_tsup-dts-rollup.js';
7
+ export { validate_alias_1 as validate } from '../_tsup-dts-rollup.js';
@@ -1 +1 @@
1
- function r(r,e){if(e==null||e>r.length)e=r.length;for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function e(r){if(Array.isArray(r))return r}function t(e){if(Array.isArray(e))return r(e)}function n(r,e,t,n,o,u,a){try{var i=r[u](a);var c=i.value}catch(r){t(r);return}if(i.done){e(c)}else{Promise.resolve(c).then(n,o)}}function o(r){return function(){var e=this,t=arguments;return new Promise(function(o,u){var a=r.apply(e,t);function i(r){n(a,o,u,i,c,"next",r)}function c(r){n(a,o,u,i,c,"throw",r)}i(undefined)})}}function u(r,e,t){if(e in r){Object.defineProperty(r,e,{value:t,enumerable:true,configurable:true,writable:true})}else{r[e]=t}return r}function a(r,e){if(e!=null&&typeof Symbol!=="undefined"&&e[Symbol.hasInstance]){return!!e[Symbol.hasInstance](r)}else{return r instanceof e}}function i(r){if(typeof Symbol!=="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function c(r,e){var t=r==null?null:typeof Symbol!=="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t==null)return;var n=[];var o=true;var u=false;var a,i;try{for(t=t.call(r);!(o=(a=t.next()).done);o=true){n.push(a.value);if(e&&n.length===e)break}}catch(r){u=true;i=r}finally{try{if(!o&&t["return"]!=null)t["return"]()}finally{if(u)throw i}}return n}function s(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))}n.forEach(function(e){u(r,e,t[e])})}return r}function y(r,t){return e(r)||c(r,t)||m(r,t)||s()}function p(r){return t(r)||i(r)||m(r)||f()}function h(r){"@swc/helpers - typeof";return r&&typeof Symbol!=="undefined"&&r.constructor===Symbol?"symbol":typeof r}function m(e,t){if(!e)return;if(typeof e==="string")return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}function b(r,e){var t,n,o,u,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:i(0),"throw":i(1),"return":i(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function i(r){return function(e){return c([r,e])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=e.call(r,a)}catch(r){u=[6,r];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}import v from"unorm";function d(r){try{return JSON.parse(r),!0}catch(r){return!1}}var g={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},w=Object.entries(g).reduce(function(r,e){var t=y(e,2),n=t[0],o=t[1];return r[n.toUpperCase()]=o.map(function(r){return r.toUpperCase()}),r},{});function S(r){r=v.nfkc(r);var e=l({},g,w);var t=true,n=false,o=undefined;try{for(var u=Object.entries(e)[Symbol.iterator](),a;!(t=(a=u.next()).done);t=true){var i=y(a.value,2),c=i[0],s=i[1];var f="[".concat(c).concat(s.join(""),"]"),h="(".concat([c].concat(p(s)).join("|"),")");r=r.replace(new RegExp(f,"g"),h)}}catch(r){n=true;o=r}finally{try{if(!t&&u.return!=null){u.return()}}finally{if(n){throw o}}}return r}function A(r){return r.normalize("NFD").replace(RegExp("\\p{Diacritic}","gu"),"")}function O(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++){e[t]=arguments[t]}var n=function(r,e){var t=l({},r);return Object.keys(e).forEach(function(r){if(!Object.hasOwnProperty.call(e,r))return;var o=e[r],u=t[r];Array.isArray(o)?t[r]=p(new Set(p(Array.isArray(u)?u:[]).concat(p(o)))):(typeof o==="undefined"?"undefined":h(o))=="object"&&o!==null&&!Array.isArray(o)?t[r]=n((typeof u==="undefined"?"undefined":h(u))=="object"&&u!==null&&!Array.isArray(u)?u:{},o):t[r]=o}),t};return e.flatMap(function(r){return Array.isArray(r)?r:[r]}).reduce(function(r,e){return n(r,e)},{})}import{format as E}from"date-fns";function j(){return E(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}var k={serialize:function(r){return JSON.stringify(r,function(r,e){return a(e,Date)?{__type:"Date",value:e.toISOString()}:e})},deserialize:function(r){return JSON.parse(r,function(r,e){return(e===null||e===void 0?void 0:e.__type)==="Date"?new Date(e.value):e})}};import _ from"localforage";var x={get:function r(r){return o(function(){var e;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,_.getItem(r)];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(r,'":'),e),null)];case 3:return[2]}})})()},set:function r(r,e){return o(function(){var t;return b(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,_.setItem(r,e)];case 1:n.sent();return[3,3];case 2:t=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(r,'":'),t);return[3,3];case 3:return[2]}})})()},remove:function r(r){return o(function(){var e;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,_.removeItem(r)];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(r,'":'),e);return[3,3];case 3:return[2]}})})()},keys:function r(){return o(function(){var r,e;return b(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,_.keys()];case 1:return[2,(r=t.sent())!==null&&r!==void 0?r:[]];case 2:e=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",e),[])];case 3:return[2]}})})()}};var I={common:{isEmpty:function r(r){return r==null?!0:Array.isArray(r)?r.length===0:(typeof r==="undefined"?"undefined":h(r))=="object"?a(r,Date)?!1:Object.keys(r).length===0:typeof r=="string"?r.trim().length===0:!1},isEmptyValidator:function r(){return /*#__PURE__*/function(){var r=o(function(r){return b(this,function(e){return[2,!I.common.isEmpty(r)]})});return function(e){return r.apply(this,arguments)}}()},isUniqueValidator:function r(r){return /*#__PURE__*/function(){var e=o(function(e){var t;return b(this,function(n){switch(n.label){case 0:if(!Array.isArray(r)||r.length===0)throw new Error("Fields must be a non-empty array of strings.");t={$or:r.map(function(r){return u({},r,e)})};return[4,this.constructor.findOne(t)];case 1:return[2,!n.sent()]}})});return function(r){return e.apply(this,arguments)}}()},matchesRegexValidator:function r(r){return /*#__PURE__*/function(){var e=o(function(e){return b(this,function(t){if(!Array.isArray(r)||r.some(function(r){return!a(r,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,r.every(function(r){return r.test(e)})]})});return function(r){return e.apply(this,arguments)}}()}}};export{O as deepMerge,j as getMongoDateTime,d as isJson,S as regexSearchMapper,A as removeAccent,k as serializer,x as storageClient,I as validate};
1
+ function r(r,e){if(e==null||e>r.length)e=r.length;for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function e(r){if(Array.isArray(r))return r}function t(e){if(Array.isArray(e))return r(e)}function n(r,e,t,n,o,u,a){try{var i=r[u](a);var c=i.value}catch(r){t(r);return}if(i.done){e(c)}else{Promise.resolve(c).then(n,o)}}function o(r){return function(){var e=this,t=arguments;return new Promise(function(o,u){var a=r.apply(e,t);function i(r){n(a,o,u,i,c,"next",r)}function c(r){n(a,o,u,i,c,"throw",r)}i(undefined)})}}function u(r,e,t){if(e in r){Object.defineProperty(r,e,{value:t,enumerable:true,configurable:true,writable:true})}else{r[e]=t}return r}function a(r,e){if(e!=null&&typeof Symbol!=="undefined"&&e[Symbol.hasInstance]){return!!e[Symbol.hasInstance](r)}else{return r instanceof e}}function i(r){if(typeof Symbol!=="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function c(r,e){var t=r==null?null:typeof Symbol!=="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t==null)return;var n=[];var o=true;var u=false;var a,i;try{for(t=t.call(r);!(o=(a=t.next()).done);o=true){n.push(a.value);if(e&&n.length===e)break}}catch(r){u=true;i=r}finally{try{if(!o&&t["return"]!=null)t["return"]()}finally{if(u)throw i}}return n}function s(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))}n.forEach(function(e){u(r,e,t[e])})}return r}function y(r,t){return e(r)||c(r,t)||b(r,t)||s()}function p(r){return t(r)||i(r)||b(r)||l()}function h(r){"@swc/helpers - typeof";return r&&typeof Symbol!=="undefined"&&r.constructor===Symbol?"symbol":typeof r}function b(e,t){if(!e)return;if(typeof e==="string")return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}function v(r,e){var t,n,o,u,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:i(0),"throw":i(1),"return":i(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function i(r){return function(e){return c([r,e])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=e.call(r,a)}catch(r){u=[6,r];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}import m from"unorm";function d(r){try{return JSON.parse(r),!0}catch(r){return!1}}var g={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},w=Object.entries(g).reduce(function(r,e){var t=y(e,2),n=t[0],o=t[1];return r[n.toUpperCase()]=o.map(function(r){return r.toUpperCase()}),r},{});function S(r){r=m.nfkc(r);var e=f({},g,w);var t=true,n=false,o=undefined;try{for(var u=Object.entries(e)[Symbol.iterator](),a;!(t=(a=u.next()).done);t=true){var i=y(a.value,2),c=i[0],s=i[1];var l="[".concat(c).concat(s.join(""),"]"),h="(".concat([c].concat(p(s)).join("|"),")");r=r.replace(new RegExp(l,"g"),h)}}catch(r){n=true;o=r}finally{try{if(!t&&u.return!=null){u.return()}}finally{if(n){throw o}}}return r}function A(r){return r.normalize("NFD").replace(RegExp("\\p{Diacritic}","gu"),"")}function E(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++){e[t]=arguments[t]}var n=function(r,e){var t=f({},r);return Object.keys(e).forEach(function(r){if(!Object.hasOwnProperty.call(e,r))return;var o=e[r],u=t[r];Array.isArray(o)?t[r]=p(new Set(p(Array.isArray(u)?u:[]).concat(p(o)))):(typeof o==="undefined"?"undefined":h(o))=="object"&&o!==null&&!Array.isArray(o)?t[r]=n((typeof u==="undefined"?"undefined":h(u))=="object"&&u!==null&&!Array.isArray(u)?u:{},o):t[r]=o}),t};return e.flatMap(function(r){return Array.isArray(r)?r:[r]}).reduce(function(r,e){return n(r,e)},{})}var O={serialize:function(r){return JSON.stringify(r,function(r,e){return a(e,Date)?{__type:"Date",value:e.toISOString()}:e})},deserialize:function(r){return JSON.parse(r,function(r,e){return(e===null||e===void 0?void 0:e.__type)==="Date"?new Date(e.value):e})}};import j from"localforage";var k={get:function r(r){return o(function(){var e;return v(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,j.getItem(r)];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(r,'":'),e),null)];case 3:return[2]}})})()},set:function r(r,e){return o(function(){var t;return v(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,j.setItem(r,e)];case 1:n.sent();return[3,3];case 2:t=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(r,'":'),t);return[3,3];case 3:return[2]}})})()},remove:function r(r){return o(function(){var e;return v(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,j.removeItem(r)];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(r,'":'),e);return[3,3];case 3:return[2]}})})()},keys:function r(){return o(function(){var r,e;return v(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,j.keys()];case 1:return[2,(r=t.sent())!==null&&r!==void 0?r:[]];case 2:e=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",e),[])];case 3:return[2]}})})()}};var _={common:{isEmpty:function r(r){return r==null?!0:Array.isArray(r)?r.length===0:(typeof r==="undefined"?"undefined":h(r))=="object"?a(r,Date)?!1:Object.keys(r).length===0:typeof r=="string"?r.trim().length===0:!1},isEmptyValidator:function r(){return /*#__PURE__*/function(){var r=o(function(r){return v(this,function(e){return[2,!_.common.isEmpty(r)]})});return function(e){return r.apply(this,arguments)}}()},isUniqueValidator:function r(r){return /*#__PURE__*/function(){var e=o(function(e){var t;return v(this,function(n){switch(n.label){case 0:if(!Array.isArray(r)||r.length===0)throw new Error("Fields must be a non-empty array of strings.");t={$or:r.map(function(r){return u({},r,e)})};return[4,this.constructor.findOne(t)];case 1:return[2,!n.sent()]}})});return function(r){return e.apply(this,arguments)}}()},matchesRegexValidator:function r(r){return /*#__PURE__*/function(){var e=o(function(e){return v(this,function(t){if(!Array.isArray(r)||r.some(function(r){return!a(r,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,r.every(function(r){return r.test(e)})]})});return function(r){return e.apply(this,arguments)}}()}}};export{E as deepMerge,d as isJson,S as regexSearchMapper,A as removeAccent,O as serializer,k as storageClient,_ as validate};
@@ -1,5 +1 @@
1
- import { T_ThrowResponseArgs } from '../typescript/log.cjs';
2
-
3
- declare function throwResponse({ message, status, type, }: T_ThrowResponseArgs): never;
4
-
5
- export { throwResponse };
1
+ export { throwResponse_alias_2 as throwResponse } from '../_tsup-dts-rollup.cjs';
@@ -1,5 +1 @@
1
- import { T_ThrowResponseArgs } from '../typescript/log.js';
2
-
3
- declare function throwResponse({ message, status, type, }: T_ThrowResponseArgs): never;
4
-
5
- export { throwResponse };
1
+ export { throwResponse_alias_2 as throwResponse } from '../_tsup-dts-rollup.js';
@@ -1,6 +1,4 @@
1
- declare function getLatestPackageVersion(packageName: string, forceRefresh?: boolean): Promise<string>;
2
- declare function isPackageOutdated(packageName: string, forceRefresh?: boolean): Promise<boolean>;
3
- declare function updatePackage(packageName: string): Promise<void>;
4
- declare function isCurrentProject(WORKING_DIRECTORY: string, PACKAGE_NAME: string): boolean;
5
-
6
- export { getLatestPackageVersion, isCurrentProject, isPackageOutdated, updatePackage };
1
+ export { getLatestPackageVersion_alias_2 as getLatestPackageVersion } from '../_tsup-dts-rollup.cjs';
2
+ export { isPackageOutdated_alias_2 as isPackageOutdated } from '../_tsup-dts-rollup.cjs';
3
+ export { updatePackage_alias_2 as updatePackage } from '../_tsup-dts-rollup.cjs';
4
+ export { isCurrentProject_alias_2 as isCurrentProject } from '../_tsup-dts-rollup.cjs';
@@ -1,6 +1,4 @@
1
- declare function getLatestPackageVersion(packageName: string, forceRefresh?: boolean): Promise<string>;
2
- declare function isPackageOutdated(packageName: string, forceRefresh?: boolean): Promise<boolean>;
3
- declare function updatePackage(packageName: string): Promise<void>;
4
- declare function isCurrentProject(WORKING_DIRECTORY: string, PACKAGE_NAME: string): boolean;
5
-
6
- export { getLatestPackageVersion, isCurrentProject, isPackageOutdated, updatePackage };
1
+ export { getLatestPackageVersion_alias_2 as getLatestPackageVersion } from '../_tsup-dts-rollup.js';
2
+ export { isPackageOutdated_alias_2 as isPackageOutdated } from '../_tsup-dts-rollup.js';
3
+ export { updatePackage_alias_2 as updatePackage } from '../_tsup-dts-rollup.js';
4
+ export { isCurrentProject_alias_2 as isCurrentProject } from '../_tsup-dts-rollup.js';
@@ -1,5 +1 @@
1
- import { I_Serializer } from '../typescript/serializer.cjs';
2
-
3
- declare const serializer: I_Serializer<unknown>;
4
-
5
- export { serializer };
1
+ export { serializer_alias_2 as serializer } from '../_tsup-dts-rollup.cjs';
@@ -1,5 +1 @@
1
- import { I_Serializer } from '../typescript/serializer.js';
2
-
3
- declare const serializer: I_Serializer<unknown>;
4
-
5
- export { serializer };
1
+ export { serializer_alias_2 as serializer } from '../_tsup-dts-rollup.js';
@@ -1,8 +1 @@
1
- declare const storageClient: {
2
- get<T = unknown>(key: string): Promise<T | null>;
3
- set<T = unknown>(key: string, value: T): Promise<void>;
4
- remove(key: string): Promise<void>;
5
- keys(): Promise<string[]>;
6
- };
7
-
8
- export { storageClient };
1
+ export { storageClient_alias_2 as storageClient } from '../_tsup-dts-rollup.cjs';
@@ -1,8 +1 @@
1
- declare const storageClient: {
2
- get<T = unknown>(key: string): Promise<T | null>;
3
- set<T = unknown>(key: string, value: T): Promise<void>;
4
- remove(key: string): Promise<void>;
5
- keys(): Promise<string[]>;
6
- };
7
-
8
- export { storageClient };
1
+ export { storageClient_alias_2 as storageClient } from '../_tsup-dts-rollup.js';
@@ -1,11 +1,3 @@
1
- declare const storageDir: string;
2
- declare function initNodePersist(): Promise<void>;
3
- declare const storageServer: {
4
- get<T = unknown>(key: string): Promise<T | null>;
5
- set<T = unknown>(key: string, value: T): Promise<void>;
6
- remove(key: string): Promise<void>;
7
- keys(): Promise<string[]>;
8
- getLogLink(key: string): Promise<string | null>;
9
- };
10
-
11
- export { initNodePersist, storageDir, storageServer };
1
+ export { initNodePersist_alias_2 as initNodePersist } from '../_tsup-dts-rollup.cjs';
2
+ export { storageDir_alias_2 as storageDir } from '../_tsup-dts-rollup.cjs';
3
+ export { storageServer_alias_2 as storageServer } from '../_tsup-dts-rollup.cjs';
@@ -1,11 +1,3 @@
1
- declare const storageDir: string;
2
- declare function initNodePersist(): Promise<void>;
3
- declare const storageServer: {
4
- get<T = unknown>(key: string): Promise<T | null>;
5
- set<T = unknown>(key: string, value: T): Promise<void>;
6
- remove(key: string): Promise<void>;
7
- keys(): Promise<string[]>;
8
- getLogLink(key: string): Promise<string | null>;
9
- };
10
-
11
- export { initNodePersist, storageDir, storageServer };
1
+ export { initNodePersist_alias_2 as initNodePersist } from '../_tsup-dts-rollup.js';
2
+ export { storageDir_alias_2 as storageDir } from '../_tsup-dts-rollup.js';
3
+ export { storageServer_alias_2 as storageServer } from '../_tsup-dts-rollup.js';
@@ -1,14 +1 @@
1
- declare const validate: {
2
- common: {
3
- isEmpty(value: unknown): boolean;
4
- isEmptyValidator<T>(): (this: T, value: unknown) => Promise<boolean>;
5
- isUniqueValidator<T extends {
6
- constructor: {
7
- findOne: (query: Record<string, unknown>) => Promise<unknown>;
8
- };
9
- }>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
10
- matchesRegexValidator(regexArray: RegExp[]): (value: string) => Promise<boolean>;
11
- };
12
- };
13
-
14
- export { validate };
1
+ export { validate_alias_2 as validate } from '../_tsup-dts-rollup.cjs';
@@ -1,14 +1 @@
1
- declare const validate: {
2
- common: {
3
- isEmpty(value: unknown): boolean;
4
- isEmptyValidator<T>(): (this: T, value: unknown) => Promise<boolean>;
5
- isUniqueValidator<T extends {
6
- constructor: {
7
- findOne: (query: Record<string, unknown>) => Promise<unknown>;
8
- };
9
- }>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
10
- matchesRegexValidator(regexArray: RegExp[]): (value: string) => Promise<boolean>;
11
- };
12
- };
13
-
14
- export { validate };
1
+ export { validate_alias_2 as validate } from '../_tsup-dts-rollup.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cyberskill/shared",
3
3
  "type": "module",
4
- "version": "1.35.0",
4
+ "version": "1.37.0",
5
5
  "description": "CyberSkill Shared",
6
6
  "author": "Stephen Cheng",
7
7
  "license": "MIT",
@@ -132,23 +132,13 @@
132
132
  "types": "./dist/utils/index-nodejs.d.ts",
133
133
  "import": "./dist/utils/index-nodejs.js",
134
134
  "require": "./dist/utils/index-nodejs.cjs"
135
- },
136
- "./commands": {
137
- "types": "./dist/commands/index.d.ts",
138
- "import": "./dist/commands/index.js",
139
- "require": "./dist/commands/index.cjs"
140
- },
141
- "./vendors/graphql/codegen": {
142
- "types": "./dist/vendors/graphql/codegen.d.ts",
143
- "import": "./dist/vendors/graphql/codegen.js",
144
- "require": "./dist/vendors/graphql/codegen.cjs"
145
135
  }
146
136
  },
147
137
  "main": "./dist/index.cjs",
148
138
  "module": "./dist/index.js",
149
139
  "types": "./dist/index.d.ts",
150
140
  "bin": {
151
- "cyberskill": "./dist/commands.js"
141
+ "cyberskill": "./dist/cli.js"
152
142
  },
153
143
  "files": [
154
144
  "dist",
@@ -157,12 +147,12 @@
157
147
  "scripts": {
158
148
  "build": "tsup",
159
149
  "dev": "tsup --watch",
160
- "lint": "npx tsx src/commands.ts lint",
161
- "lint:fix": "npx tsx src/commands.ts lint:fix",
150
+ "lint": "npx tsx src/cli.ts lint",
151
+ "lint:fix": "npx tsx src/cli.ts lint:fix",
162
152
  "lint:inspect": "npx @eslint/config-inspector",
163
- "reset": "npx tsx src/commands.ts reset",
164
- "setup": "npx tsx src/commands.ts setup",
165
- "inspect": "npx tsx src/commands.ts inspect"
153
+ "reset": "npx tsx src/cli.ts reset",
154
+ "setup": "npx tsx src/cli.ts setup",
155
+ "inspect": "npx tsx src/cli.ts inspect"
166
156
  },
167
157
  "dependencies": {
168
158
  "@antfu/eslint-config": "4.11.0",
@@ -174,8 +164,9 @@
174
164
  "@graphql-codegen/cli": "5.0.5",
175
165
  "@graphql-codegen/client-preset": "4.7.0",
176
166
  "@graphql-codegen/typescript-react-apollo": "4.3.2",
167
+ "@microsoft/api-extractor": "7.52.1",
177
168
  "@next/eslint-plugin-next": "15.2.3",
178
- "@swc/core": "1.11.12",
169
+ "@swc/core": "1.11.13",
179
170
  "@testing-library/jest-dom": "6.6.3",
180
171
  "@testing-library/react": "16.2.0",
181
172
  "@types/crypto-js": "4.2.2",
@@ -204,6 +195,7 @@
204
195
  "jsdom": "26.0.0",
205
196
  "lint-staged": "15.5.0",
206
197
  "localforage": "1.10.0",
198
+ "modern-normalize": "3.0.1",
207
199
  "mongoose": "8.12.2",
208
200
  "mongoose-aggregate-paginate-v2": "1.1.4",
209
201
  "mongoose-paginate-v2": "1.9.0",
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
@@ -1 +0,0 @@
1
- "use strict";function e(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}var t=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var u=function(e,r){for(var n in r)t(e,n,{get:r[n],enumerable:!0})},a=function(u,a,f,i){var c=true,l=false,y=undefined;if(a&&(typeof a==="undefined"?"undefined":e(a))=="object"||typeof a=="function")try{var d=function(){var e=s.value;!o.call(u,e)&&e!==f&&t(u,e,{get:function(){return a[e]},enumerable:!(i=r(a,e))||i.enumerable})};for(var m=n(a)[Symbol.iterator](),s;!(c=(s=m.next()).done);c=true)d()}catch(e){l=true;y=e}finally{try{if(!c&&m.return!=null){m.return()}}finally{if(l){throw y}}}return u};var f=function(e){return a(t({},"__esModule",{value:!0}),e)};var i={};u(i,{getMongoDateTime:function(){return l}});module.exports=f(i);var c=require("date-fns");function l(){return(0,c.format)(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}0&&(module.exports={getMongoDateTime:getMongoDateTime});
@@ -1,3 +0,0 @@
1
- declare function getMongoDateTime(): string;
2
-
3
- export { getMongoDateTime };
@@ -1,3 +0,0 @@
1
- declare function getMongoDateTime(): string;
2
-
3
- export { getMongoDateTime };
@@ -1 +0,0 @@
1
- import{format as t}from"date-fns";function e(){return t(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}export{e as getMongoDateTime};
@@ -1 +0,0 @@
1
- "use strict";function e(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function r(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){e(r,t,n[t])})}return r}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function n(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{t(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,r){if(e==null)return{};var t=u(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function u(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,u;for(u=0;u<n.length;u++){o=n[u];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function a(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}var i=Object.create;var l=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var s=function(e,r){for(var t in r)l(e,t,{get:r[t],enumerable:!0})},v=function(e,r,t,n){var o=true,u=false,i=undefined;if(r&&(typeof r==="undefined"?"undefined":a(r))=="object"||typeof r=="function")try{var g=function(){var o=v.value;!d.call(e,o)&&o!==t&&l(e,o,{get:function(){return r[o]},enumerable:!(n=c(r,o))||n.enumerable})};for(var s=f(r)[Symbol.iterator](),v;!(o=(v=s.next()).done);o=true)g()}catch(e){u=true;i=e}finally{try{if(!o&&s.return!=null){s.return()}}finally{if(u){throw i}}}return e};var y=function(e,r,t){return t=e!=null?i(g(e)):{},v(r||!e||!e.__esModule?l(t,"default",{value:e,enumerable:!0}):t,e)},p=function(e){return v(l({},"__esModule",{value:!0}),e)};var m={};s(m,{aggregatePaginate:function(){return O.default},generateModel:function(){return x},generateSchema:function(){return E},generateShortId:function(){return I},generateSlug:function(){return A},generateSlugQuery:function(){return _},getMongoGenericFields:function(){return k},mongoosePaginate:function(){return h.default}});module.exports=p(m);var b=y(require("crypto-js"),1),O=y(require("mongoose-aggregate-paginate-v2"),1),h=y(require("mongoose-paginate-v2"),1),S=y(require("slugify"),1),w=require("uuid");var j=require("date-fns");function P(){return(0,j.format)(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function D(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function M(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function q(e){return new e.Schema({id:{type:String,default:w.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function E(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,u=e.standalone,a=u===void 0?!1:u;var i=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=i.virtual(r,t);n&&o.get(n)}),a||i.add(q(r)),i}function x(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,u=o===void 0?!1:o,a=e.aggregate,i=a===void 0?!1:a,l=e.virtuals,c=l===void 0?[]:l,f=e.middlewares,g=f===void 0?[]:f;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var d=E({mongoose:r,schema:n,virtuals:c});return D(d,[u&&h.default,i&&O.default]),M(d,g),r.model(t,d)}var H=S.default.default||S.default;function A(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var n=t||{},u=n.lower,a=u===void 0?!0:u,i=n.locale,l=i===void 0?"vi":i,c=o(n,["lower","locale"]);return H(e,r({lower:a,locale:l},c))}function I(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return b.default.SHA256(e).toString(b.default.enc.Hex).slice(0,r)}function _(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;return n(r({},t,o&&{id:{$ne:o}}),{$or:[{slug:e},{slugHistory:e}]})}function k(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.isNew,o=t===void 0?!0:t,u=e.returnDateAs,a=u===void 0?"string":u;var i=a==="string"?P():new Date;return n(r({},o&&{id:(0,w.v4)()}),{isDel:!1,createdAt:i,updatedAt:i})}0&&(module.exports={aggregatePaginate:aggregatePaginate,generateModel:generateModel,generateSchema:generateSchema,generateShortId:generateShortId,generateSlug:generateSlug,generateSlugQuery:generateSlugQuery,getMongoGenericFields:getMongoGenericFields,mongoosePaginate:mongoosePaginate});
@@ -1,22 +0,0 @@
1
- export { default as aggregatePaginate } from 'mongoose-aggregate-paginate-v2';
2
- export { default as mongoosePaginate } from 'mongoose-paginate-v2';
3
- import { C_Document, I_GenerateSchemaOptions, T_MongooseShema, I_GenerateModelOptions, I_ExtendedModel, I_SlugifyOptions, T_FilterQuery, T_GenerateSlugQueryResponse } from '../typescript/mongoose.cjs';
4
- import 'mongodb';
5
- import 'mongoose';
6
-
7
- declare function generateSchema<D extends Partial<C_Document>>({ mongoose, schema, virtuals, standalone, }: I_GenerateSchemaOptions<D>): T_MongooseShema<D>;
8
- declare function generateModel<D extends Partial<C_Document>>({ mongoose, name, schema, pagination, aggregate, virtuals, middlewares, }: I_GenerateModelOptions<D>): I_ExtendedModel<D>;
9
- declare function generateSlug(str?: string, options?: I_SlugifyOptions): string;
10
- declare function generateShortId(uuid: string, length?: number): string;
11
- declare function generateSlugQuery<D>(slug: string, filters?: T_FilterQuery<D>, id?: string): T_GenerateSlugQueryResponse<D>;
12
- declare function getMongoGenericFields<T extends 'date' | 'string'>({ isNew, returnDateAs, }?: {
13
- isNew?: boolean;
14
- returnDateAs?: T;
15
- }): {
16
- id?: string;
17
- isDel: boolean;
18
- createdAt: T extends 'string' ? string : Date;
19
- updatedAt: T extends 'string' ? string : Date;
20
- };
21
-
22
- export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getMongoGenericFields };
@@ -1,22 +0,0 @@
1
- export { default as aggregatePaginate } from 'mongoose-aggregate-paginate-v2';
2
- export { default as mongoosePaginate } from 'mongoose-paginate-v2';
3
- import { C_Document, I_GenerateSchemaOptions, T_MongooseShema, I_GenerateModelOptions, I_ExtendedModel, I_SlugifyOptions, T_FilterQuery, T_GenerateSlugQueryResponse } from '../typescript/mongoose.js';
4
- import 'mongodb';
5
- import 'mongoose';
6
-
7
- declare function generateSchema<D extends Partial<C_Document>>({ mongoose, schema, virtuals, standalone, }: I_GenerateSchemaOptions<D>): T_MongooseShema<D>;
8
- declare function generateModel<D extends Partial<C_Document>>({ mongoose, name, schema, pagination, aggregate, virtuals, middlewares, }: I_GenerateModelOptions<D>): I_ExtendedModel<D>;
9
- declare function generateSlug(str?: string, options?: I_SlugifyOptions): string;
10
- declare function generateShortId(uuid: string, length?: number): string;
11
- declare function generateSlugQuery<D>(slug: string, filters?: T_FilterQuery<D>, id?: string): T_GenerateSlugQueryResponse<D>;
12
- declare function getMongoGenericFields<T extends 'date' | 'string'>({ isNew, returnDateAs, }?: {
13
- isNew?: boolean;
14
- returnDateAs?: T;
15
- }): {
16
- id?: string;
17
- isDel: boolean;
18
- createdAt: T extends 'string' ? string : Date;
19
- updatedAt: T extends 'string' ? string : Date;
20
- };
21
-
22
- export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getMongoGenericFields };
@@ -1 +0,0 @@
1
- function e(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function r(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){e(r,t,n[t])})}return r}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function n(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{t(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,r){if(e==null)return{};var t=i(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function i(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,i;for(i=0;i<n.length;i++){o=n[i];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}import a from"crypto-js";import u from"mongoose-aggregate-paginate-v2";import c from"mongoose-paginate-v2";import l from"slugify";import{v4 as f}from"uuid";import{format as s}from"date-fns";function g(){return s(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function v(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function d(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function m(e){return new e.Schema({id:{type:String,default:f,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function p(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,i=e.standalone,a=i===void 0?!1:i;var u=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=u.virtual(r,t);n&&o.get(n)}),a||u.add(m(r)),u}function y(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,i=o===void 0?!1:o,a=e.aggregate,l=a===void 0?!1:a,f=e.virtuals,s=f===void 0?[]:f,g=e.middlewares,m=g===void 0?[]:g;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var y=p({mongoose:r,schema:n,virtuals:s});return v(y,[i&&c,l&&u]),d(y,m),r.model(t,y)}var O=l.default||l;function b(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var n=t||{},i=n.lower,a=i===void 0?!0:i,u=n.locale,c=u===void 0?"vi":u,l=o(n,["lower","locale"]);return O(e,r({lower:a,locale:c},l))}function h(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return a.SHA256(e).toString(a.enc.Hex).slice(0,r)}function w(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;return n(r({},t,o&&{id:{$ne:o}}),{$or:[{slug:e},{slugHistory:e}]})}function j(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.isNew,o=t===void 0?!0:t,i=e.returnDateAs,a=i===void 0?"string":i;var u=a==="string"?g():new Date;return n(r({},o&&{id:f()}),{isDel:!1,createdAt:u,updatedAt:u})}export{u as aggregatePaginate,y as generateModel,p as generateSchema,h as generateShortId,b as generateSlug,w as generateSlugQuery,j as getMongoGenericFields,c as mongoosePaginate};
File without changes
File without changes