@cyberskill/shared 1.47.0 → 1.49.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 (133) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +415 -30
  2. package/dist/_tsup-dts-rollup.d.ts +415 -30
  3. package/dist/cli.cjs +2144 -1
  4. package/dist/cli.d.cts +2 -1
  5. package/dist/cli.d.ts +2 -1
  6. package/dist/cli.js +2064 -1
  7. package/dist/configs/commitlint/base.cjs +64 -1
  8. package/dist/configs/commitlint/base.js +7 -1
  9. package/dist/configs/eslint/base.cjs +121 -1
  10. package/dist/configs/eslint/base.js +52 -1
  11. package/dist/configs/eslint/nestjs.cjs +155 -1
  12. package/dist/configs/eslint/nestjs.js +85 -1
  13. package/dist/configs/eslint/nextjs.cjs +155 -1
  14. package/dist/configs/eslint/nextjs.js +85 -1
  15. package/dist/configs/eslint/nodejs.cjs +156 -1
  16. package/dist/configs/eslint/nodejs.js +86 -1
  17. package/dist/configs/eslint/vite-react.cjs +159 -1
  18. package/dist/configs/eslint/vite-react.js +89 -1
  19. package/dist/configs/graphql/graphql-codegen.cjs +125 -1
  20. package/dist/configs/graphql/graphql-codegen.js +64 -1
  21. package/dist/configs/graphql/index.cjs +126 -1
  22. package/dist/configs/graphql/index.js +64 -1
  23. package/dist/configs/i18n/react/i18next.cjs +80 -1
  24. package/dist/configs/i18n/react/i18next.js +7 -1
  25. package/dist/configs/i18n/react/index.cjs +81 -1
  26. package/dist/configs/i18n/react/index.js +7 -1
  27. package/dist/configs/index.cjs +232 -1
  28. package/dist/configs/index.js +166 -1
  29. package/dist/configs/lint-staged/base.cjs +64 -1
  30. package/dist/configs/lint-staged/base.js +7 -1
  31. package/dist/configs/vitest/react/e2e.cjs +128 -1
  32. package/dist/configs/vitest/react/e2e.js +59 -1
  33. package/dist/configs/vitest/react/unit.cjs +305 -1
  34. package/dist/configs/vitest/react/unit.js +228 -1
  35. package/dist/configs/vitest/react/unit.setup.cjs +60 -1
  36. package/dist/configs/vitest/react/unit.setup.js +8 -1
  37. package/dist/constants/index.cjs +678 -1
  38. package/dist/constants/index.d.cts +31 -1
  39. package/dist/constants/index.d.ts +31 -1
  40. package/dist/constants/index.js +469 -1
  41. package/dist/constants/path.cjs +423 -1
  42. package/dist/constants/path.d.cts +31 -1
  43. package/dist/constants/path.d.ts +31 -1
  44. package/dist/constants/path.js +218 -1
  45. package/dist/constants/response-status.cjs +313 -1
  46. package/dist/constants/response-status.js +252 -1
  47. package/dist/index.cjs +4560 -1
  48. package/dist/index.d.cts +52 -7
  49. package/dist/index.d.ts +52 -7
  50. package/dist/index.js +4143 -1
  51. package/dist/nodejs/index.cjs +2138 -1
  52. package/dist/nodejs/index.js +2054 -1
  53. package/dist/nodejs/mongo.cjs +2137 -1
  54. package/dist/nodejs/mongo.js +2054 -1
  55. package/dist/react/apollo-client.cjs +177 -1
  56. package/dist/react/apollo-client.js +116 -1
  57. package/dist/react/index.cjs +990 -1
  58. package/dist/react/index.js +876 -1
  59. package/dist/react/loading.cjs +301 -1
  60. package/dist/react/loading.js +216 -1
  61. package/dist/react/next-intl.cjs +744 -1
  62. package/dist/react/next-intl.js +655 -1
  63. package/dist/react/storage.cjs +631 -1
  64. package/dist/react/storage.js +558 -1
  65. package/dist/typescript/api-response.cjs +48 -1
  66. package/dist/typescript/apollo.cjs +48 -1
  67. package/dist/typescript/command.cjs +68 -1
  68. package/dist/typescript/command.d.cts +4 -0
  69. package/dist/typescript/command.d.ts +4 -0
  70. package/dist/typescript/command.js +7 -1
  71. package/dist/typescript/config.cjs +48 -1
  72. package/dist/typescript/fs.cjs +48 -0
  73. package/dist/typescript/fs.d.cts +1 -0
  74. package/dist/typescript/fs.d.ts +1 -0
  75. package/dist/typescript/fs.js +0 -0
  76. package/dist/typescript/graphql-codegen.cjs +48 -1
  77. package/dist/typescript/index.cjs +175 -1
  78. package/dist/typescript/index.d.cts +5 -0
  79. package/dist/typescript/index.d.ts +5 -0
  80. package/dist/typescript/index.js +151 -1
  81. package/dist/typescript/loading.cjs +48 -1
  82. package/dist/typescript/log.cjs +48 -1
  83. package/dist/typescript/mongo.cjs +164 -1
  84. package/dist/typescript/mongo.js +145 -1
  85. package/dist/typescript/next-intl.cjs +48 -1
  86. package/dist/typescript/react.cjs +48 -1
  87. package/dist/typescript/serializer.cjs +48 -1
  88. package/dist/typescript/string.cjs +48 -1
  89. package/dist/utils/command.cjs +1387 -1
  90. package/dist/utils/command.d.cts +2 -0
  91. package/dist/utils/command.d.ts +2 -0
  92. package/dist/utils/command.js +1287 -1
  93. package/dist/utils/common.cjs +300 -1
  94. package/dist/utils/common.js +219 -1
  95. package/dist/utils/config.cjs +146 -1
  96. package/dist/utils/config.js +89 -1
  97. package/dist/utils/fs.cjs +132 -1
  98. package/dist/utils/fs.d.cts +5 -1
  99. package/dist/utils/fs.d.ts +5 -1
  100. package/dist/utils/fs.js +47 -1
  101. package/dist/utils/index-nodejs.cjs +1752 -1
  102. package/dist/utils/index-nodejs.d.cts +16 -6
  103. package/dist/utils/index-nodejs.d.ts +16 -6
  104. package/dist/utils/index-nodejs.js +1581 -1
  105. package/dist/utils/index.cjs +727 -1
  106. package/dist/utils/index.js +625 -1
  107. package/dist/utils/log.cjs +330 -1
  108. package/dist/utils/log.js +269 -1
  109. package/dist/utils/package.cjs +941 -0
  110. package/dist/utils/package.d.cts +3 -0
  111. package/dist/utils/package.d.ts +3 -0
  112. package/dist/utils/package.js +857 -0
  113. package/dist/utils/path.cjs +291 -0
  114. package/dist/utils/path.d.cts +6 -0
  115. package/dist/utils/path.d.ts +6 -0
  116. package/dist/utils/path.js +191 -0
  117. package/dist/utils/serializer.cjs +91 -1
  118. package/dist/utils/serializer.js +30 -1
  119. package/dist/utils/storage-client.cjs +349 -1
  120. package/dist/utils/storage-client.js +276 -1
  121. package/dist/utils/storage-server.cjs +636 -1
  122. package/dist/utils/storage-server.d.cts +1 -1
  123. package/dist/utils/storage-server.d.ts +1 -1
  124. package/dist/utils/storage-server.js +550 -1
  125. package/dist/utils/string.cjs +152 -1
  126. package/dist/utils/string.js +75 -1
  127. package/dist/utils/validate.cjs +90 -1
  128. package/dist/utils/validate.js +33 -1
  129. package/package.json +11 -12
  130. package/dist/utils/npm-package.cjs +0 -1
  131. package/dist/utils/npm-package.d.cts +0 -5
  132. package/dist/utils/npm-package.d.ts +0 -5
  133. package/dist/utils/npm-package.js +0 -1
package/dist/index.cjs CHANGED
@@ -1 +1,4560 @@
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){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function s(e,r,t,n,s,a,o){try{var u=e[a](o);var i=u.value}catch(e){t(e);return}if(u.done){r(i)}else{Promise.resolve(i).then(n,s)}}function a(e){return function(){var r=this,t=arguments;return new Promise(function(n,a){var o=e.apply(r,t);function u(e){s(o,n,a,u,i,"next",e)}function i(e){s(o,n,a,u,i,"throw",e)}u(undefined)})}}function o(e,r,t){r=f(r);return _(e,w()?Reflect.construct(r,t||[],f(e).constructor):r.apply(e,t))}function u(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}function i(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function c(e,r,t){if(r)i(e.prototype,r);if(t)i(e,t);return e}function l(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 f(e){f=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return f(e)}function d(e,r){if(typeof r!=="function"&&r!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:true,configurable:true}});if(r)A(e,r)}function E(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function g(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function v(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var s=true;var a=false;var o,u;try{for(t=t.call(e);!(s=(o=t.next()).done);s=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){a=true;u=e}finally{try{if(!s&&t["return"]!=null)t["return"]()}finally{if(a)throw u}}return n}function h(){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 p(){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 m(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){l(e,r,t[r])})}return e}function y(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 S(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{y(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=R(e,r);var n,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++){n=a[s];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function R(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var s,a;for(a=0;a<n.length;a++){s=n[a];if(r.indexOf(s)>=0)continue;t[s]=e[s]}return t}function _(e,r){if(r&&(C(r)==="object"||typeof r==="function")){return r}return n(e)}function A(e,r){A=Object.setPrototypeOf||function e(e,r){e.__proto__=r;return e};return A(e,r)}function b(e,t){return r(e)||v(e,t)||D(e,t)||h()}function N(e){return t(e)||g(e)||D(e)||p()}function C(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 w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}function T(e,r){var t,n,s,a,o={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]};return a={next:u(0),"throw":u(1),"return":u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(r){return i([e,r])}}function i(a){if(t)throw new TypeError("Generator is already executing.");while(o)try{if(t=1,n&&(s=a[0]&2?n["return"]:a[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;if(n=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:o.label++;return{value:a[1],done:false};case 5:o.label++;n=a[1];a=[0];continue;case 7:a=o.ops.pop();o.trys.pop();continue;default:if(!(s=o.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){o=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(a[0]===6&&o.label<s[1]){o.label=s[1];s=a;break}if(s&&o.label<s[2]){o.label=s[2];o.ops.push(a);break}if(s[2])o.ops.pop();o.trys.pop();continue}a=r.call(e,o)}catch(e){a=[6,e];n=0}finally{t=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var I=Object.create;var M=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var G=function(e,r){for(var t in r)M(e,t,{get:r[t],enumerable:!0})},U=function(e,r,t,n){var s=true,a=false,o=undefined;if(r&&(typeof r==="undefined"?"undefined":C(r))=="object"||typeof r=="function")try{var u=function(){var s=c.value;!x.call(e,s)&&s!==t&&M(e,s,{get:function(){return r[s]},enumerable:!(n=P(r,s))||n.enumerable})};for(var i=L(r)[Symbol.iterator](),c;!(s=(c=i.next()).done);s=true)u()}catch(e){a=true;o=e}finally{try{if(!s&&i.return!=null){i.return()}}finally{if(a){throw o}}}return e};var j=function(e,r,t){return t=e!=null?I(k(e)):{},U(r||!e||!e.__esModule?M(t,"default",{value:e,enumerable:!0}):t,e)},q=function(e){return U(M({},"__esModule",{value:!0}),e)};var F={};G(F,{ApolloProvider:function(){return eS},C_Collection:function(){return e$},C_Db:function(){return eJ},C_Document:function(){return eW},C_Model:function(){return ez},E_ErrorType:function(){return eH},Loading:function(){return eC},LoadingContext:function(){return eb},LoadingProvider:function(){return eD},MongoController:function(){return ef},MongooseController:function(){return ed},NextIntlContext:function(){return eG},NextIntlProvider:function(){return eV},PROJECT_ROOT:function(){return $},RESPONSE_STATUS:function(){return X},WORKING_DIRECTORY:function(){return K},aggregatePaginate:function(){return er.default},clearAllErrorLists:function(){return rv},commandLog:function(){return rc},deepMerge:function(){return B},executeCommand:function(){return ry},fileExists:function(){return rR},generateShortId:function(){return ei},generateSlug:function(){return eu},getLatestPackageVersion:function(){return rT},getStoredErrorLists:function(){return rE},initNodePersist:function(){return e6},installDependencies:function(){return rG},isCurrentProject:function(){return rx},isJson:function(){return rq},isPackageOutdated:function(){return rM},mongo:function(){return el},mongoosePaginate:function(){return et.default},regexSearchMapper:function(){return rV},removeAccent:function(){return rH},saveErrorListToStorage:function(){return rf},serializer:function(){return eM},storageClient:function(){return eL},storageDir:function(){return e8},storageServer:function(){return e9},throwResponse:function(){return rA},updatePackage:function(){return rL},useLoading:function(){return eN},useNextIntl:function(){return eU},useStorage:function(){return ek},useTranslateNextIntl:function(){return ej},validate:function(){return ec},withNextIntl:function(){return eq}});module.exports=q(F);var Q=function(){return(typeof document==="undefined"?"undefined":C(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},V=Q();var H=j(require("@antfu/eslint-config"),1);function B(){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=m({},e);return Object.keys(r).forEach(function(e){if(!Object.hasOwnProperty.call(r,e))return;var s=r[e],a=t[e];Array.isArray(s)?t[e]=N(new Set(N(Array.isArray(a)?a:[]).concat(N(s)))):(typeof s==="undefined"?"undefined":C(s))=="object"&&s!==null&&!Array.isArray(s)?t[e]=n((typeof a==="undefined"?"undefined":C(a))=="object"&&a!==null&&!Array.isArray(a)?a:{},s):t[e]=s}),t};return r.flatMap(function(e){return Array.isArray(e)?e:[e]}).reduce(function(e,r){return n(e,r)},{})}var Y=require("path"),J=j(require("process"),1),W=require("url"),z=(0,W.fileURLToPath)(V),$=(0,Y.dirname)(z),K=J.default.env.INIT_CWD||J.default.cwd();var X={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"}};var Z=require("date-fns"),ee=require("mongoose"),er=j(require("mongoose-aggregate-paginate-v2"),1),et=j(require("mongoose-paginate-v2"),1),en=require("uuid");var es=j(require("crypto-js"),1),ea=j(require("slugify"),1),eo=ea.default.default||ea.default;function eu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;var t=r||{},n=t.lower,s=n===void 0?!0:n,a=t.locale,o=a===void 0?"vi":a,u=O(t,["lower","locale"]);return eo(e,m({lower:s,locale:o},u))}function ei(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return es.default.SHA256(e).toString(es.default.enc.Hex).slice(0,r)}var ec={isEmpty:function e(e){return e==null?!0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":C(e))=="object"?E(e,Date)?!1:Object.keys(e).length===0:typeof e=="string"?e.trim().length===0:!1}};var el={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return(0,Z.format)(e,"yyyy-MM-dd HH:mm:ss.SSS")},createGenericFields:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.returnDateAs,t=r===void 0?"string":r;var n=t==="string"?el.getDateTime():new Date;return{id:(0,en.v4)(),isDel:!1,createdAt:n,updatedAt:n}},applyPlugins:function e(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})},applyMiddlewares:function e(e,r){r.forEach(function(r){var t=r.method,n=r.pre,s=r.post;t&&n&&e.pre(t,n),t&&s&&e.post(t,s)})},createGenericSchema:function e(e){return new e.Schema({id:{type:String,default:en.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})},createSchema:function e(e){var r=e.mongoose,t=e.schema,n=e.virtuals,s=n===void 0?[]:n,a=e.standalone,o=a===void 0?!1:a;var u=new r.Schema(t,{strict:!0});return s.forEach(function(e){var r=e.name,t=e.options,n=e.get;var s=u.virtual(r,t);n&&s.get(n)}),o||u.add(el.createGenericSchema(r)),u},createModel:function e(e){var r=e.mongoose,t=e.name,n=e.schema,s=e.pagination,a=s===void 0?!1:s,o=e.aggregate,u=o===void 0?!1:o,i=e.virtuals,c=i===void 0?[]:i,l=e.middlewares,f=l===void 0?[]:l;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var d=el.createSchema({mongoose:r,schema:n,virtuals:c});return el.applyPlugins(d,[a&&et.default,u&&er.default]),el.applyMiddlewares(d,f),r.model(t,d)},createSlugQuery:function e(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;return S(m({},r,t&&{id:{$ne:t}}),{$or:[{slug:e},{slugHistory:e}]})},validator:{isEmpty:function e(){return /*#__PURE__*/function(){var e=a(function(e){return T(this,function(r){return[2,!ec.isEmpty(e)]})});return function(r){return e.apply(this,arguments)}}()},isUnique:function e(e){return /*#__PURE__*/function(){var r=a(function(r){var t;return T(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 l({},e,r)})};return[4,this.constructor.findOne(t)];case 1:return[2,!n.sent()]}})});return function(e){return r.apply(this,arguments)}}()},matchesRegex:function e(e){return /*#__PURE__*/function(){var r=a(function(r){return T(this,function(t){if(!Array.isArray(e)||e.some(function(e){return!E(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)}}()}}},ef=/*#__PURE__*/function(){function e(r,t){u(this,e);this.collection=r.collection(t)}c(e,[{key:"createOne",value:function e(e){var r=this;return a(function(){var t,n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);t=m({},el.createGenericFields(),e);n={success:!0,message:"Document created successfully"};return[4,r.collection.insertOne(t)];case 1:return[2,(n.result=a.sent(),n)];case 2:s=a.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"createMany",value:function e(e){var r=this;return a(function(){var t,n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);t=e.map(function(e){return m({},el.createGenericFields(),e)});return[4,r.collection.insertMany(t)];case 1:n=a.sent();return[2,n.insertedCount===0?{success:!1,message:"No documents were inserted"}:{success:!0,message:"".concat(n.insertedCount," documents created successfully"),result:n}];case 2:s=a.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"findOne",value:function e(e){var r=this;return a(function(){var t,n;return T(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,r.collection.findOne(e)];case 1:t=s.sent();return[2,t?{success:!0,message:"Document found",result:t}:{success:!1,message:"Document not found"}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"findAll",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var r=this;return a(function(){var t,n;return T(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t={success:!0,message:"Documents retrieved successfully"};return[4,r.collection.find(e).toArray()];case 1:return[2,(t.result=s.sent(),t)];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"count",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var r=this;return a(function(){var t,n;return T(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t={success:!0,message:"Count retrieved successfully"};return[4,r.collection.countDocuments(e)];case 1:return[2,(t.result=s.sent(),t)];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"updateOne",value:function e(e,r){var t=this;return a(function(){var n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);return[4,t.collection.updateOne(e,{$set:r})];case 1:n=a.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document updated successfully",result:n}];case 2:s=a.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"updateMany",value:function e(e,r){var t=this;return a(function(){var n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);return[4,t.collection.updateMany(e,{$set:r})];case 1:n=a.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents updated successfully",result:n}];case 2:s=a.sent();return[2,{success:!1,message:s.message}];case 3:return[2]}})})()}},{key:"deleteOne",value:function e(e){var r=this;return a(function(){var t,n;return T(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,r.collection.deleteOne(e)];case 1:t=s.sent();return[2,t.deletedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document deleted successfully",result:t}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}},{key:"deleteMany",value:function e(e){var r=this;return a(function(){var t,n;return T(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,r.collection.deleteMany(e)];case 1:t=s.sent();return[2,t.deletedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents deleted successfully",result:t}];case 2:n=s.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})})()}}]);return e}(),ed=/*#__PURE__*/function(){function e(r){u(this,e);this.model=r}c(e,[{key:"getModelName",value:function e(){return this.model.modelName}},{key:"findOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;var s=this;return a(function(){var a,o,u;return T(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);a=s.model.findOne(e,r,t);n&&a.populate(n);return[4,a.exec()];case 1:o=i.sent();return[2,o?{success:!0,result:o}:{success:!1,message:"No ".concat(s.getModelName()," found."),code:X.NOT_FOUND.CODE}];case 2:u=i.sent();return[2,{success:!1,message:u.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findAll",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;var s=this;return a(function(){var a,o,u;return T(this,function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);a=s.model.find(e,r,t);n&&a.populate(n);o={success:!0};return[4,a.exec()];case 1:return[2,(o.result=i.sent(),o)];case 2:u=i.sent();return[2,{success:!1,message:u.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findPaging",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var t=this;return a(function(){var n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);n={success:!0};return[4,t.model.paginate(e,r)];case 1:return[2,(n.result=a.sent(),n)];case 2:s=a.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"findPagingAggregate",value:function e(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var t=this;return a(function(){var n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);n={success:!0};return[4,t.model.aggregatePaginate(t.model.aggregate(e),r)];case 1:return[2,(n.result=a.sent(),n)];case 2:s=a.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"count",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var r=this;return a(function(){var t,n;return T(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t={success:!0};return[4,r.model.countDocuments(e)];case 1:return[2,(t.result=s.sent(),t)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createOne",value:function e(e){var r=this;return a(function(){var t,n;return T(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t={success:!0};return[4,r.model.create(e)];case 1:return[2,(t.result=s.sent(),t)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createMany",value:function e(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var t=this;return a(function(){var n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);n={success:!0};return[4,t.model.insertMany(e,r)];case 1:return[2,(n.result=a.sent().map(function(e){return E(e,ee.Document)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 2:s=a.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"updateOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return a(function(){var s,a;return T(this,function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);return[4,n.model.findOneAndUpdate(e,r,m({new:!0},t)).exec()];case 1:s=o.sent();return[2,s?{success:!0,result:s}:{success:!1,message:"Failed to update ".concat(n.getModelName(),"."),code:X.NOT_FOUND.CODE}];case 2:a=o.sent();return[2,{success:!1,message:a.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"updateMany",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return a(function(){var s,a;return T(this,function(o){switch(o.label){case 0:o.trys.push([0,2,,3]);s={success:!0};return[4,n.model.updateMany(e,r,t).exec()];case 1:return[2,(s.result=o.sent(),s)];case 2:a=o.sent();return[2,{success:!1,message:a.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"deleteOne",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var t=this;return a(function(){var n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);return[4,t.model.findOneAndDelete(e,r).exec()];case 1:n=a.sent();return[2,n?{success:!0,result:n}:{success:!1,message:"No ".concat(t.getModelName()," found to delete."),code:X.NOT_FOUND.CODE}];case 2:s=a.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"deleteMany",value:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var t=this;return a(function(){var n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);return[4,t.model.deleteMany(e,r).exec()];case 1:n=a.sent();return[2,n.deletedCount===0?{success:!1,message:"No documents found to delete.",code:X.NOT_FOUND.CODE}:{success:!0,result:n}];case 2:s=a.sent();return[2,{success:!1,message:s.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}},{key:"createShortId",value:function e(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;var t=this;return a(function(){var n,s,a,o;return T(this,function(u){switch(u.label){case 0:n=new Set;s=0;u.label=1;case 1:if(!(s<10))return[3,5];a=ei(e,s+r);o=!n.has(a);if(!o)return[3,3];n.add(a);return[4,t.model.exists({shortId:a})];case 2:o=!u.sent();u.label=3;case 3:if(o)return[2,{success:!0,result:a}];u.label=4;case 4:s++;return[3,1];case 5:return[2,{success:!1,message:"Failed to create a unique shortId",code:X.INTERNAL_SERVER_ERROR.CODE}]}})})()}},{key:"createSlug",value:function e(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=this;return a(function(){var s,o,u,i,c,l,f,d,E,g,v;return T(this,function(h){switch(h.label){case 0:h.trys.push([0,8,,9]);s=r[e],o=/*#__PURE__*/function(){var e=a(function(e){var s,a,o;return T(this,function(u){switch(u.label){case 0:return[4,n.model.findOne(el.createSlugQuery(e,t,r.id))];case 1:s=u.sent();if(!s)return[2,e];a=1;u.label=2;case 2:o="".concat(e,"-").concat(a);return[4,n.model.findOne(el.createSlugQuery(o,t,r.id))];case 3:s=u.sent(),a++;u.label=4;case 4:if(s)return[3,2];u.label=5;case 5:return[2,o]}})});return function r(r){return e.apply(this,arguments)}}();if(!((typeof s==="undefined"?"undefined":C(s))=="object"))return[3,5];u={};i=[];for(c in s)i.push(c);l=0;h.label=1;case 1:if(!(l<i.length))return[3,4];f=i[l];d=eu(s[f]);return[4,o(d)];case 2:u[f]=h.sent();h.label=3;case 3:l++;return[3,1];case 4:return[2,{success:!0,result:u}];case 5:E=eu(s);g={success:!0};return[4,o(E)];case 6:return[2,(g.result=h.sent(),g)];case 7:return[3,9];case 8:v=h.sent();return[2,{success:!1,message:"Failed to create a unique slug: ".concat(v.message),code:X.INTERNAL_SERVER_ERROR.CODE}];case 9:return[2]}})})()}},{key:"aggregate",value:function e(e){var r=this;return a(function(){var t,n;return T(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t={success:!0};return[4,r.model.aggregate(e)];case 1:return[2,(t.result=s.sent(),t)];case 2:n=s.sent();return[2,{success:!1,message:n.message,code:X.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})})()}}]);return e}();var eE=require("@apollo/client"),eg=require("@apollo/client/link/error"),ev=require("@apollo/client/link/subscriptions"),eh=require("@apollo/client/utilities"),ep=require("graphql-ws"),em=require("react/jsx-runtime");function ey(e){var r=(0,eg.onError)(function(e){var r=e.graphQLErrors,t=e.networkError;r===null||r===void 0?void 0:r.forEach(function(e){var r=e.message,t=e.locations,n=e.path;return console.error("[GraphQL error]: Message: ".concat(r,", Location: ").concat(t,", Path: ").concat(n))}),t&&console.error("[Network error]: ".concat(t))}),t=new eE.HttpLink({uri:e===null||e===void 0?void 0:e.uri,credentials:"include"}),n=(e===null||e===void 0?void 0:e.wsUrl)?new ev.GraphQLWsLink((0,ep.createClient)({url:e.wsUrl})):null,s=n?(0,eE.split)(function(e){var r=e.query;var t=(0,eh.getMainDefinition)(r);if(t.kind==="OperationDefinition"){var n=t.operation;return n==="subscription"}return!1},n,t):t,a=new eE.ApolloLink(function(e,r){return e.variables&&(e.variables=JSON.parse(JSON.stringify(e.variables),function(e,r){return e==="__typename"?void 0:r})),r(e)});return{errorLink:r,httpLink:t,wsLink:n,splitLink:s,cleanTypeName:a}}function eS(e){var r=e.isNextJS,t=e.options,n=e.children,s=e.client,a=e.provider,o=e.cache;var u=s!==null&&s!==void 0?s:eE.ApolloClient;if(typeof u!="function")throw new TypeError("Invalid ApolloClient provided. Ensure CustomClient is a class.");var i=a||eE.ApolloProvider,c=o||eE.InMemoryCache,l=ey(t),f=l.cleanTypeName,d=l.errorLink,g=l.splitLink,v=new u(m({cache:E(c,eE.InMemoryCache)?c:new eE.InMemoryCache,link:eE.ApolloLink.from([f,d,g].filter(Boolean))},t));return r?(0,em.jsx)(i,{makeClient:function(){return v},children:n}):(0,em.jsx)(i,{client:v,children:n})}var eO=j(require("classnames"),1),eR=require("react"),e_=j(require("./react/loading.module.scss"),1),eA=require("react/jsx-runtime"),eb=(0,eR.createContext)(void 0);function eN(){var e=(0,eR.use)(eb);if(!e)throw new Error("useLoading must be used within a LoadingProvider");return e}function eC(e){var r=e.full,t=r===void 0?!1:r,n=e.block,s=n===void 0?!1:n,a=e.className,o=a===void 0?"":a,u=e.message,i=u===void 0?"Loading":u,c=O(e,["full","block","className","message"]);function l(){return(0,eA.jsxs)("div",S(m({className:e_.default.container},c),{children:[(0,eA.jsx)("div",{className:e_.default.ring}),(0,eA.jsx)("div",{className:e_.default.ring}),(0,eA.jsx)("div",{className:e_.default.ring}),(0,eA.jsx)("div",{className:e_.default.ring}),i&&(0,eA.jsx)("div",{className:e_.default.message,children:i})]}))}return t?(0,eA.jsx)("div",{className:(0,eO.default)(e_.default.fullscreen,o),children:l()}):s?(0,eA.jsx)("div",{className:(0,eO.default)(e_.default.block,o),children:l()}):l()}function eD(e){var r=e.children;var t=b((0,eR.useState)(!1),2),n=t[0],s=t[1],a=b((0,eR.useState)(!1),2),o=a[0],u=a[1],i=(0,eR.useCallback)(function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;s(!0),u(e)},[]),c=(0,eR.useCallback)(function(){s(!1),u(!1)},[]),l=(0,eR.useMemo)(function(){return{isLoading:n,isGlobalLoading:o,showLoading:i,hideLoading:c}},[n,o,i,c]);return(0,eA.jsx)(eb,{value:l,children:n?(0,eA.jsx)(eC,{full:o}):r})}var ew=require("next-intl"),eT=require("react");var eI=require("react");var eM={serialize:function(e){return JSON.stringify(e,function(e,r){return E(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 eP=j(require("localforage"),1),eL={get:function e(e){return a(function(){var r;return T(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,eP.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 a(function(){var t;return T(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,eP.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 a(function(){var r;return T(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,eP.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 a(function(){var e,r;return T(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,eP.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]}})})()}};function ek(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:eM;var n=b((0,eI.useState)(r),2),s=n[0],o=n[1],u=b((0,eI.useState)(!1),2),i=u[0],c=u[1];(0,eI.useEffect)(function(){var n=!0;return a(function(){var s,a,u,i;return T(this,function(l){switch(l.label){case 0:l.trys.push([0,6,7,8]);return[4,eL.get(e)];case 1:s=l.sent();if(!n)return[3,5];if(!(s!==null))return[3,2];a=t.deserialize(s);o(a);return[3,5];case 2:if(!(r!==void 0))return[3,4];u=t.serialize(r);return[4,eL.set(e,u)];case 3:l.sent(),o(r);return[3,5];case 4:o(void 0);l.label=5;case 5:return[3,8];case 6:i=l.sent();console.error('Error loading value for key "'.concat(e,'":'),i),n&&o(r);return[3,8];case 7:n&&c(!0);return[7];case 8:return[2]}})})(),function(){n=!1,c(!1)}},[e,r,t]),(0,eI.useEffect)(function(){if(!i)return;a(function(){var r,n;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,3,,4]);if(!(s!==void 0))return[3,2];r=t.serialize(s);return[4,eL.set(e,r)];case 1:a.sent();a.label=2;case 2:return[3,4];case 3:n=a.sent();console.error('Error saving value for key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},[s,e,t,i]);var l=(0,eI.useCallback)(function(e){o(function(r){return typeof e=="function"?e(r):e})},[]),f=(0,eI.useCallback)(/*#__PURE__*/a(function(){var r;return T(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,eL.remove(e)];case 1:t.sent(),o(void 0);return[3,3];case 2:r=t.sent();console.error('Error removing key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})}),[e]);return{value:s,set:l,remove:f}}var ex=require("react/jsx-runtime"),eG=(0,eT.createContext)(void 0);function eU(){var e=(0,eT.use)(eG);if(!e)throw new Error("useNextIntl must be used within a NextIntlProvider");return e}var ej=ew.useTranslations;function eq(e){var r=function(r){var t;var n=eU(),s=n.currentLanguage,a=r.messages,o=r.languages,u="en",i=a[(s===null||s===void 0?void 0:s.value)||u],c=(t=o.find(function(e){return e.value===(s===null||s===void 0?void 0:s.value)}))===null||t===void 0?void 0:t.timezone;return a?(0,ex.jsx)(ew.NextIntlClientProvider,{locale:(s===null||s===void 0?void 0:s.value)||u,messages:i,timeZone:c,children:(0,ex.jsx)(e,m({},r))}):(console.warn("Missing messages for language: ".concat((s===null||s===void 0?void 0:s.value)||u)),null)};return r.displayName="withNextIntl(".concat(e.displayName||e.name||"Component",")"),r}function eF(e){var r=e.children;return(0,ex.jsx)(ex.Fragment,{children:r})}var eQ=eq(eF);function eV(e){var r=e.children,t=e.languages,n=e.messages;var s;var a=ek("lang",(s=t===null||t===void 0?void 0:t[0])!==null&&s!==void 0?s:{}),o=a.value,u=a.set,i=(0,eT.useMemo)(function(){return{languages:t,currentLanguage:o,setCurrentLanguage:u}},[t,u,o]);return(0,ex.jsx)(eG,{value:i,children:(0,ex.jsx)(eQ,{languages:t,messages:n,children:r})})}var eH=function(e){return e.Error="error",e.Warning="warning",e}(eH||{});var eB=require("mongodb"),eY=require("mongoose"),eJ=/*#__PURE__*/function(e){d(r,e);function r(){u(this,r);return o(this,r,arguments)}return r}(eB.Db),eW=/*#__PURE__*/function(e){d(r,e);function r(){u(this,r);return o(this,r,arguments)}return r}(eY.Document),ez=/*#__PURE__*/function(e){d(r,e);function r(){u(this,r);return o(this,r,arguments)}return r}(eY.Model),e$=/*#__PURE__*/function(e){d(r,e);function r(){u(this,r);return o(this,r,arguments)}return r}(eB.Collection);var eK=j(require("boxen"),1),eX=j(require("chalk"),1),eZ=require("child_process"),e0=j(require("process"),1),e2=j(require("util"),1);var e1=j(require("node-persist"),1),e3=j(require("os"),1),e4=j(require("path"),1),e5=j(require("process"),1),e8=e5.default.env.CYBERSKILL_STORAGE_DIR||e4.default.join(e3.default.homedir(),".cyberskill-storage");function e6(){return e7.apply(this,arguments)}function e7(){e7=a(function(){var e;return T(this,function(r){switch(r.label){case 0:e=e1.default.defaultInstance;if(e)return[3,2];return[4,e1.default.init({dir:e8,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 e7.apply(this,arguments)}var e9={get:function e(e){return a(function(){var r,t;return T(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,e6()];case 1:n.sent();return[4,e1.default.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,r){return a(function(){var t;return T(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,e6()];case 1:n.sent();return[4,e1.default.setItem(e,r)];case 2:n.sent();return[3,4];case 3:t=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},remove:function e(e){return a(function(){var r;return T(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,e6()];case 1:t.sent();return[4,e1.default.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 a(function(){var e,r;return T(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,e6()];case 1:t.sent();return[4,e1.default.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 a(function(){return T(this,function(r){try{return[2,"".concat(e8," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var re=e0.default.env.DEBUG==="true",rr=e2.promisify(eZ.exec),rt=eX.default,rn=rt.gray,rs=rt.blue,ra=function(){return rn("[".concat(new Date().toLocaleTimeString(),"]"))};function ro(e){var r=eX.default[e];return typeof r=="function"?r:eX.default.green}function ru(e,r,t,n){var s=ro(r);console.log("".concat(ra()," ").concat(s("".concat(t," ").concat(e))," ").concat(n))}function ri(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,s=n===void 0?"green":n,a=t.padding,o=a===void 0?1:a,u=t.margin,i=u===void 0?1:u,c=t.borderStyle,l=c===void 0?"round":c,f=t.titleColor,d=f===void 0?"bold":f;var E=ro(s),g=ro(d);if(typeof r=="string"){console.log((0,eK.default)(g(E("".concat(e,"\n").concat(r))),{padding:o,margin:i,borderStyle:l,borderColor:s}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,s=e.message;console.log("".concat(ra()," ").concat(E("File:")," ").concat(rs("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(E("Rule:")," ").concat(E(n))),console.log(" ".concat(E("Message:")," ").concat(E(s)))}),console.log((0,eK.default)(g(E("".concat(e,": ").concat(r.length))),{padding:o,margin:i,borderStyle:l,borderColor:s})),console.log(rn("─".repeat(40))))}var rc={success:function(e){return ru("SUCCESS","green","✔",e)},error:function(e){return ru("ERROR","red","✖",e)},warning:function(e){return ru("WARNING","yellow","⚠",e)},info:function(e){return ru("INFO","blue","ℹ",e)},printBoxedLog:ri},rl=function(e){return"error_list:".concat(e)};function rf(e){return rd.apply(this,arguments)}function rd(){rd=a(function(e){var r,t,n;return T(this,function(s){switch(s.label){case 0:if(e.length===0)return[2];r=Date.now(),t=rl(r);s.label=1;case 1:s.trys.push([1,3,,4]);return[4,e9.set(t,{errors:e,timestamp:r})];case 2:s.sent(),setTimeout(/*#__PURE__*/a(function(){var e;return T(this,function(r){switch(r.label){case 0:return[4,e9.getLogLink(t)];case 1:e=r.sent();e&&rc.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:n=s.sent();rc.error("Failed to save errors: ".concat(n.message));return[3,4];case 4:return[2]}})});return rd.apply(this,arguments)}function rE(){return rg.apply(this,arguments)}function rg(){rg=a(function(){var e,r,t;return T(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,e9.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(/*#__PURE__*/function(){var e=a(function(e){var r;return T(this,function(t){switch(t.label){case 0:return[4,e9.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,n.sent().flat()];case 3:t=n.sent();return[2,(rc.error("Failed to retrieve stored errors: ".concat(t.message)),[])];case 4:return[2]}})});return rg.apply(this,arguments)}function rv(){return rh.apply(this,arguments)}function rh(){rh=a(function(){var e,r,t;return T(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,e9.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 e9.remove(e)}))];case 2:n.sent();return[3,4];case 3:t=n.sent();rc.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return rh.apply(this,arguments)}function rp(e){var r=[],t=[],n="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,o=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var u=s.exec(e)||[],i=a.exec(e)||[],c=o.exec(e)||[];u.length&&n?r.push({file:n,position:"".concat(u[1],":").concat(u[2]),type:u[3]==="error"?"error":"warning",message:u[4].trim(),rule:u[5].trim()}):i.length?r.push({file:i[1],position:"".concat(i[2],":").concat(i[3]),type:i[4]==="error"?"error":"warning",message:i[5].trim()}):c.length?r.push({file:"commitlint",type:"error",message:c[1].trim(),rule:c[2].trim()}):t.push(e.trim())}}),r.length&&rf(r),t.length&&re&&(rc.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function rm(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,s=e.line,a=e.column,o=e.ruleId,u=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(s,":").concat(a),rule:o,message:u})})}),t.length&&rf(t)}catch(r){rp(e)}}function ry(e){return rS.apply(this,arguments)}function rS(){rS=a(function(e){var r,t,n,s,a,o,u,i,c;var l=arguments;return T(this,function(f){switch(f.label){case 0:r=l.length>1&&l[1]!==void 0?l[1]:rm;t=new AbortController;e0.default.on("SIGINT",function(){rc.warning("Process interrupted. Terminating..."),t.abort(),e0.default.exit()});f.label=1;case 1:f.trys.push([1,3,,4]);return[4,rr(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=f.sent(),s=n.stdout,a=n.stderr;[s,a].forEach(function(e){return e&&r(e)});return[3,4];case 3:o=f.sent();u=o.stdout,i=o.stderr,c=o.message;[u,i].forEach(function(e){return e&&r(e)}),!i&&!u&&rc.error("Command failed: ".concat(c));return[3,4];case 4:return[2]}})});return rS.apply(this,arguments)}var rO=j(require("fs"),1),rR=function(e){return rO.existsSync(e)};var r_=require("graphql");function rA(e){var r=e.message,t=e.status,n=t===void 0?X.INTERNAL_SERVER_ERROR:t,s=e.type,a=s===void 0?"graphql":s;var o;var u=(o=r!==null&&r!==void 0?r:n.MESSAGE)!==null&&o!==void 0?o:"Internal server error";throw a==="graphql"?new r_.GraphQLError(u,{extensions:{code:n.CODE}}):new Error(u)}var rb=j(require("node-fetch"),1),rN=j(require("fs"),1),rC=j(require("path"),1);var rD=24*60*60*1e3;function rw(e){return e?rC.default.join(K,"node_modules",e,"package.json"):rC.default.join(K,"package.json")}function rT(e){return rI.apply(this,arguments)}function rI(){rI=a(function(e){var r,t,n,s,a,o,u,i,c,l;var f=arguments;return T(this,function(d){switch(d.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,e9.get(t)];case 1:s=d.sent();return[4,e9.get(n)];case 2:a=d.sent(),o=s&&Date.now()-s.timestamp<rD;if(!r&&o)return[2,s.version];u={};(a===null||a===void 0?void 0:a.etag)&&(u["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(u["If-Modified-Since"]=a.lastModified);d.label=3;case 3:d.trys.push([3,8,,9]);return[4,(0,rb.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:u})];case 4:i=d.sent();if(i.status===304&&s)return[2,s.version];if(!i.ok)throw new Error("Failed to fetch latest version: ".concat(i.statusText));return[4,i.json()];case 5:c=d.sent().version;return[4,e9.set(t,{version:c,timestamp:Date.now()})];case 6:d.sent();return[4,e9.set(n,{etag:i.headers.get("ETag")||void 0,lastModified:i.headers.get("Last-Modified")||void 0})];case 7:return[2,(d.sent(),c)];case 8:l=d.sent();if(rc.error("Error fetching latest version for ".concat(e,": ").concat(l.message)),s)return[2,(rc.warning("Falling back to cached version for ".concat(e,": ").concat(s.version)),s.version)];throw l;case 9:return[2]}})});return rI.apply(this,arguments)}function rM(e){return rP.apply(this,arguments)}function rP(){rP=a(function(e){var r,t,n,s,a;var o=arguments;return T(this,function(u){switch(u.label){case 0:r=o.length>1&&o[1]!==void 0?o[1]:!0;u.label=1;case 1:u.trys.push([1,3,,4]);t=rw(e);if(!rN.default.existsSync(t))return[2,(rc.info("".concat(e," is not installed.")),!0)];n=JSON.parse(rN.default.readFileSync(t,"utf-8")).version;return[4,rT(e,r)];case 2:s=u.sent();return[2,(rc.info("Installed version of ".concat(e,": ").concat(n)),rc.info("Latest version of ".concat(e,": ").concat(s)),n!==s)];case 3:a=u.sent();return[2,(rc.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return rP.apply(this,arguments)}function rL(e){return rk.apply(this,arguments)}function rk(){rk=a(function(e){var r,t,n,s;return T(this,function(a){switch(a.label){case 0:a.trys.push([0,4,,5]);return[4,rT(e,!0)];case 1:r=a.sent(),t=rw();if(!rN.default.existsSync(t)){rc.error("package.json not found. Cannot update ".concat(e));return[2]}n=JSON.parse(rN.default.readFileSync(t,"utf-8"));n.dependencies=S(m({},n.dependencies),l({},e,r)),rN.default.writeFileSync(t,JSON.stringify(n,null,2)),rc.info("Updated ".concat(e," to version ").concat(r));return[4,rG()];case 2:a.sent();return[4,ry("pnpm run lint:fix")];case 3:a.sent(),rc.success("".concat(e," updated successfully."));return[3,5];case 4:s=a.sent();throw rc.error("Failed to update ".concat(e,": ").concat(s.message)),s;case 5:return[2]}})});return rk.apply(this,arguments)}function rx(e,r){try{var t=rC.default.join(e,"package.json");return rN.default.existsSync(t)?JSON.parse(rN.default.readFileSync(t,"utf-8")).name===r:!1}catch(e){return rc.error("Error reading package.json: ".concat(e.message)),!1}}function rG(){return rU.apply(this,arguments)}function rU(){rU=a(function(){var e,r,t,n,s,a,o,u,i,c,l;return T(this,function(f){switch(f.label){case 0:e=[{command:"pnpm install",message:"Standard installation"},{command:"pnpm install --legacy-peer-deps",message:"Attempting installation with --legacy-peer-deps"},{command:"pnpm install --force",message:"Attempting forced installation"}];r=true,t=false,n=undefined;f.label=1;case 1:f.trys.push([1,8,9,10]);s=e[Symbol.iterator]();f.label=2;case 2:if(!!(r=(a=s.next()).done))return[3,7];o=a.value,u=o.command,i=o.message;f.label=3;case 3:f.trys.push([3,5,,6]);rc.info("".concat(i,"..."));return[4,ry(u)];case 4:f.sent(),rc.success("Dependencies installed using: ".concat(u));return[2];case 5:c=f.sent();rc.warning("Failed with: ".concat(u)),rc.error("Error: ".concat(c.message));return[3,6];case 6:r=true;return[3,2];case 7:return[3,10];case 8:l=f.sent();t=true;n=l;return[3,10];case 9:try{if(!r&&s.return!=null){s.return()}}finally{if(t){throw n}}return[7];case 10:throw new Error("Failed to install dependencies after multiple attempts.")}})});return rU.apply(this,arguments)}var rj=j(require("unorm"),1);function rq(e){try{return JSON.parse(e),!0}catch(e){return!1}}var rF={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},rQ=Object.entries(rF).reduce(function(e,r){var t=b(r,2),n=t[0],s=t[1];return e[n.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function rV(e){e=rj.default.nfkc(e);var r=m({},rF,rQ);var t=true,n=false,s=undefined;try{for(var a=Object.entries(r)[Symbol.iterator](),o;!(t=(o=a.next()).done);t=true){var u=b(o.value,2),i=u[0],c=u[1];var l="[".concat(i).concat(c.join(""),"]"),f="(".concat([i].concat(N(c)).join("|"),")");e=e.replace(new RegExp(l,"g"),f)}}catch(e){n=true;s=e}finally{try{if(!t&&a.return!=null){a.return()}}finally{if(n){throw s}}}return e}function rH(e){return e.normalize("NFD").replace(RegExp("\\p{Diacritic}","gu"),"")}0&&(module.exports={ApolloProvider:ApolloProvider,C_Collection:C_Collection,C_Db:C_Db,C_Document:C_Document,C_Model:C_Model,E_ErrorType:E_ErrorType,Loading:Loading,LoadingContext:LoadingContext,LoadingProvider:LoadingProvider,MongoController:MongoController,MongooseController:MongooseController,NextIntlContext:NextIntlContext,NextIntlProvider:NextIntlProvider,PROJECT_ROOT:PROJECT_ROOT,RESPONSE_STATUS:RESPONSE_STATUS,WORKING_DIRECTORY:WORKING_DIRECTORY,aggregatePaginate:aggregatePaginate,clearAllErrorLists:clearAllErrorLists,commandLog:commandLog,deepMerge:deepMerge,executeCommand:executeCommand,fileExists:fileExists,generateShortId:generateShortId,generateSlug:generateSlug,getLatestPackageVersion:getLatestPackageVersion,getStoredErrorLists:getStoredErrorLists,initNodePersist:initNodePersist,installDependencies:installDependencies,isCurrentProject:isCurrentProject,isJson:isJson,isPackageOutdated:isPackageOutdated,mongo:mongo,mongoosePaginate:mongoosePaginate,regexSearchMapper:regexSearchMapper,removeAccent:removeAccent,saveErrorListToStorage:saveErrorListToStorage,serializer:serializer,storageClient:storageClient,storageDir:storageDir,storageServer:storageServer,throwResponse:throwResponse,updatePackage:updatePackage,useLoading:useLoading,useNextIntl:useNextIntl,useStorage:useStorage,useTranslateNextIntl:useTranslateNextIntl,validate:validate,withNextIntl:withNextIntl});
1
+ "use strict";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_with_holes(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
10
+ function _array_without_holes(arr) {
11
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
12
+ }
13
+ function _assert_this_initialized(self) {
14
+ if (self === void 0) {
15
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
16
+ }
17
+ return self;
18
+ }
19
+ function asyncGeneratorStep(gen, resolve1, reject, _next, _throw, key, arg) {
20
+ try {
21
+ var info = gen[key](arg);
22
+ var value = info.value;
23
+ } catch (error) {
24
+ reject(error);
25
+ return;
26
+ }
27
+ if (info.done) {
28
+ resolve1(value);
29
+ } else {
30
+ Promise.resolve(value).then(_next, _throw);
31
+ }
32
+ }
33
+ function _async_to_generator(fn) {
34
+ return function() {
35
+ var self = this, args = arguments;
36
+ return new Promise(function(resolve1, reject) {
37
+ var gen = fn.apply(self, args);
38
+ function _next(value) {
39
+ asyncGeneratorStep(gen, resolve1, reject, _next, _throw, "next", value);
40
+ }
41
+ function _throw(err) {
42
+ asyncGeneratorStep(gen, resolve1, reject, _next, _throw, "throw", err);
43
+ }
44
+ _next(undefined);
45
+ });
46
+ };
47
+ }
48
+ function _call_super(_this, derived, args) {
49
+ derived = _get_prototype_of(derived);
50
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
51
+ }
52
+ function _class_call_check(instance, Constructor) {
53
+ if (!(instance instanceof Constructor)) {
54
+ throw new TypeError("Cannot call a class as a function");
55
+ }
56
+ }
57
+ function _defineProperties(target, props) {
58
+ for(var i = 0; i < props.length; i++){
59
+ var descriptor = props[i];
60
+ descriptor.enumerable = descriptor.enumerable || false;
61
+ descriptor.configurable = true;
62
+ if ("value" in descriptor) descriptor.writable = true;
63
+ Object.defineProperty(target, descriptor.key, descriptor);
64
+ }
65
+ }
66
+ function _create_class(Constructor, protoProps, staticProps) {
67
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
68
+ if (staticProps) _defineProperties(Constructor, staticProps);
69
+ return Constructor;
70
+ }
71
+ function _define_property(obj, key, value) {
72
+ if (key in obj) {
73
+ Object.defineProperty(obj, key, {
74
+ value: value,
75
+ enumerable: true,
76
+ configurable: true,
77
+ writable: true
78
+ });
79
+ } else {
80
+ obj[key] = value;
81
+ }
82
+ return obj;
83
+ }
84
+ function _get_prototype_of(o) {
85
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
86
+ return o.__proto__ || Object.getPrototypeOf(o);
87
+ };
88
+ return _get_prototype_of(o);
89
+ }
90
+ function _inherits(subClass, superClass) {
91
+ if (typeof superClass !== "function" && superClass !== null) {
92
+ throw new TypeError("Super expression must either be null or a function");
93
+ }
94
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
95
+ constructor: {
96
+ value: subClass,
97
+ writable: true,
98
+ configurable: true
99
+ }
100
+ });
101
+ if (superClass) _set_prototype_of(subClass, superClass);
102
+ }
103
+ function _instanceof(left, right) {
104
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
105
+ return !!right[Symbol.hasInstance](left);
106
+ } else {
107
+ return left instanceof right;
108
+ }
109
+ }
110
+ function _iterable_to_array(iter) {
111
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
112
+ }
113
+ function _iterable_to_array_limit(arr, i) {
114
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
115
+ if (_i == null) return;
116
+ var _arr = [];
117
+ var _n = true;
118
+ var _d = false;
119
+ var _s, _e;
120
+ try {
121
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
122
+ _arr.push(_s.value);
123
+ if (i && _arr.length === i) break;
124
+ }
125
+ } catch (err) {
126
+ _d = true;
127
+ _e = err;
128
+ } finally{
129
+ try {
130
+ if (!_n && _i["return"] != null) _i["return"]();
131
+ } finally{
132
+ if (_d) throw _e;
133
+ }
134
+ }
135
+ return _arr;
136
+ }
137
+ function _non_iterable_rest() {
138
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
139
+ }
140
+ function _non_iterable_spread() {
141
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
142
+ }
143
+ function _object_spread(target) {
144
+ for(var i = 1; i < arguments.length; i++){
145
+ var source = arguments[i] != null ? arguments[i] : {};
146
+ var ownKeys = Object.keys(source);
147
+ if (typeof Object.getOwnPropertySymbols === "function") {
148
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
149
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
150
+ }));
151
+ }
152
+ ownKeys.forEach(function(key) {
153
+ _define_property(target, key, source[key]);
154
+ });
155
+ }
156
+ return target;
157
+ }
158
+ function ownKeys(object, enumerableOnly) {
159
+ var keys = Object.keys(object);
160
+ if (Object.getOwnPropertySymbols) {
161
+ var symbols = Object.getOwnPropertySymbols(object);
162
+ if (enumerableOnly) {
163
+ symbols = symbols.filter(function(sym) {
164
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
165
+ });
166
+ }
167
+ keys.push.apply(keys, symbols);
168
+ }
169
+ return keys;
170
+ }
171
+ function _object_spread_props(target, source) {
172
+ source = source != null ? source : {};
173
+ if (Object.getOwnPropertyDescriptors) {
174
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
175
+ } else {
176
+ ownKeys(Object(source)).forEach(function(key) {
177
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
178
+ });
179
+ }
180
+ return target;
181
+ }
182
+ function _object_without_properties(source, excluded) {
183
+ if (source == null) return {};
184
+ var target = _object_without_properties_loose(source, excluded);
185
+ var key, i;
186
+ if (Object.getOwnPropertySymbols) {
187
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
188
+ for(i = 0; i < sourceSymbolKeys.length; i++){
189
+ key = sourceSymbolKeys[i];
190
+ if (excluded.indexOf(key) >= 0) continue;
191
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
192
+ target[key] = source[key];
193
+ }
194
+ }
195
+ return target;
196
+ }
197
+ function _object_without_properties_loose(source, excluded) {
198
+ if (source == null) return {};
199
+ var target = {};
200
+ var sourceKeys = Object.keys(source);
201
+ var key, i;
202
+ for(i = 0; i < sourceKeys.length; i++){
203
+ key = sourceKeys[i];
204
+ if (excluded.indexOf(key) >= 0) continue;
205
+ target[key] = source[key];
206
+ }
207
+ return target;
208
+ }
209
+ function _possible_constructor_return(self, call) {
210
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
211
+ return call;
212
+ }
213
+ return _assert_this_initialized(self);
214
+ }
215
+ function _set_prototype_of(o, p) {
216
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
217
+ o.__proto__ = p;
218
+ return o;
219
+ };
220
+ return _set_prototype_of(o, p);
221
+ }
222
+ function _sliced_to_array(arr, i) {
223
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
224
+ }
225
+ function _to_consumable_array(arr) {
226
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
227
+ }
228
+ function _type_of(obj) {
229
+ "@swc/helpers - typeof";
230
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
231
+ }
232
+ function _unsupported_iterable_to_array(o, minLen) {
233
+ if (!o) return;
234
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
235
+ var n = Object.prototype.toString.call(o).slice(8, -1);
236
+ if (n === "Object" && o.constructor) n = o.constructor.name;
237
+ if (n === "Map" || n === "Set") return Array.from(n);
238
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
239
+ }
240
+ function _is_native_reflect_construct() {
241
+ try {
242
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
243
+ } catch (_) {}
244
+ return (_is_native_reflect_construct = function() {
245
+ return !!result;
246
+ })();
247
+ }
248
+ function _ts_generator(thisArg, body) {
249
+ var f, y, t, g, _ = {
250
+ label: 0,
251
+ sent: function() {
252
+ if (t[0] & 1) throw t[1];
253
+ return t[1];
254
+ },
255
+ trys: [],
256
+ ops: []
257
+ };
258
+ return g = {
259
+ next: verb(0),
260
+ "throw": verb(1),
261
+ "return": verb(2)
262
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
263
+ return this;
264
+ }), g;
265
+ function verb(n) {
266
+ return function(v) {
267
+ return step([
268
+ n,
269
+ v
270
+ ]);
271
+ };
272
+ }
273
+ function step(op) {
274
+ if (f) throw new TypeError("Generator is already executing.");
275
+ while(_)try {
276
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
277
+ if (y = 0, t) op = [
278
+ op[0] & 2,
279
+ t.value
280
+ ];
281
+ switch(op[0]){
282
+ case 0:
283
+ case 1:
284
+ t = op;
285
+ break;
286
+ case 4:
287
+ _.label++;
288
+ return {
289
+ value: op[1],
290
+ done: false
291
+ };
292
+ case 5:
293
+ _.label++;
294
+ y = op[1];
295
+ op = [
296
+ 0
297
+ ];
298
+ continue;
299
+ case 7:
300
+ op = _.ops.pop();
301
+ _.trys.pop();
302
+ continue;
303
+ default:
304
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
305
+ _ = 0;
306
+ continue;
307
+ }
308
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
309
+ _.label = op[1];
310
+ break;
311
+ }
312
+ if (op[0] === 6 && _.label < t[1]) {
313
+ _.label = t[1];
314
+ t = op;
315
+ break;
316
+ }
317
+ if (t && _.label < t[2]) {
318
+ _.label = t[2];
319
+ _.ops.push(op);
320
+ break;
321
+ }
322
+ if (t[2]) _.ops.pop();
323
+ _.trys.pop();
324
+ continue;
325
+ }
326
+ op = body.call(thisArg, _);
327
+ } catch (e) {
328
+ op = [
329
+ 6,
330
+ e
331
+ ];
332
+ y = 0;
333
+ } finally{
334
+ f = t = 0;
335
+ }
336
+ if (op[0] & 5) throw op[1];
337
+ return {
338
+ value: op[0] ? op[1] : void 0,
339
+ done: true
340
+ };
341
+ }
342
+ }
343
+ var __create = Object.create;
344
+ var __defProp = Object.defineProperty;
345
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
346
+ var __getOwnPropNames = Object.getOwnPropertyNames;
347
+ var __getProtoOf = Object.getPrototypeOf;
348
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
349
+ var __export = function(target, all) {
350
+ for(var name in all)__defProp(target, name, {
351
+ get: all[name],
352
+ enumerable: true
353
+ });
354
+ };
355
+ var __copyProps = function(to, from, except, desc) {
356
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
357
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
358
+ try {
359
+ var _loop = function() {
360
+ var key = _step.value;
361
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
362
+ get: function() {
363
+ return from[key];
364
+ },
365
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
366
+ });
367
+ };
368
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
369
+ } catch (err) {
370
+ _didIteratorError = true;
371
+ _iteratorError = err;
372
+ } finally{
373
+ try {
374
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
375
+ _iterator.return();
376
+ }
377
+ } finally{
378
+ if (_didIteratorError) {
379
+ throw _iteratorError;
380
+ }
381
+ }
382
+ }
383
+ }
384
+ return to;
385
+ };
386
+ var __toESM = function(mod, isNodeMode, target) {
387
+ return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
388
+ // file that has been converted to a CommonJS file using a Babel-
389
+ // compatible transform (i.e. "__esModule" has not been set), then set
390
+ // "default" to the CommonJS "module.exports" for node compatibility.
391
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
392
+ value: mod,
393
+ enumerable: true
394
+ }) : target, mod);
395
+ };
396
+ var __toCommonJS = function(mod) {
397
+ return __copyProps(__defProp({}, "__esModule", {
398
+ value: true
399
+ }), mod);
400
+ };
401
+ // src/index.ts
402
+ var index_exports = {};
403
+ __export(index_exports, {
404
+ ApolloProvider: function() {
405
+ return ApolloProvider;
406
+ },
407
+ BUILD_DIRECTORY: function() {
408
+ return BUILD_DIRECTORY;
409
+ },
410
+ COMMAND: function() {
411
+ return COMMAND;
412
+ },
413
+ COMMIT_LINT_CLI: function() {
414
+ return COMMIT_LINT_CLI;
415
+ },
416
+ CYBERSKILL_CLI: function() {
417
+ return CYBERSKILL_CLI;
418
+ },
419
+ CYBERSKILL_DIRECTORY: function() {
420
+ return CYBERSKILL_DIRECTORY;
421
+ },
422
+ CYBERSKILL_PACKAGE_NAME: function() {
423
+ return CYBERSKILL_PACKAGE_NAME;
424
+ },
425
+ CYBERSKILL_STORAGE: function() {
426
+ return CYBERSKILL_STORAGE;
427
+ },
428
+ C_Collection: function() {
429
+ return C_Collection;
430
+ },
431
+ C_Db: function() {
432
+ return C_Db;
433
+ },
434
+ C_Document: function() {
435
+ return C_Document;
436
+ },
437
+ C_Model: function() {
438
+ return C_Model;
439
+ },
440
+ ESLINT_CLI: function() {
441
+ return ESLINT_CLI;
442
+ },
443
+ ESLINT_INSPECT_CLI: function() {
444
+ return ESLINT_INSPECT_CLI;
445
+ },
446
+ E_ErrorType: function() {
447
+ return E_ErrorType;
448
+ },
449
+ GIT_CLI: function() {
450
+ return GIT_CLI;
451
+ },
452
+ GIT_COMMIT_EDITMSG: function() {
453
+ return GIT_COMMIT_EDITMSG;
454
+ },
455
+ GIT_HOOK: function() {
456
+ return GIT_HOOK;
457
+ },
458
+ GIT_IGNORE: function() {
459
+ return GIT_IGNORE;
460
+ },
461
+ HOOK: function() {
462
+ return HOOK;
463
+ },
464
+ LINT_STAGED_CLI: function() {
465
+ return LINT_STAGED_CLI;
466
+ },
467
+ Loading: function() {
468
+ return Loading;
469
+ },
470
+ LoadingContext: function() {
471
+ return LoadingContext;
472
+ },
473
+ LoadingProvider: function() {
474
+ return LoadingProvider;
475
+ },
476
+ MongoController: function() {
477
+ return MongoController;
478
+ },
479
+ MongooseController: function() {
480
+ return MongooseController;
481
+ },
482
+ NODE_MODULES: function() {
483
+ return NODE_MODULES;
484
+ },
485
+ NODE_MODULES_INSPECT_CLI: function() {
486
+ return NODE_MODULES_INSPECT_CLI;
487
+ },
488
+ NextIntlContext: function() {
489
+ return NextIntlContext;
490
+ },
491
+ NextIntlProvider: function() {
492
+ return NextIntlProvider;
493
+ },
494
+ PACKAGE_JSON: function() {
495
+ return PACKAGE_JSON;
496
+ },
497
+ PACKAGE_LOCK_JSON: function() {
498
+ return PACKAGE_LOCK_JSON;
499
+ },
500
+ PATH: function() {
501
+ return PATH;
502
+ },
503
+ PNPM_CLI: function() {
504
+ return PNPM_CLI;
505
+ },
506
+ PNPM_DLX_CLI: function() {
507
+ return PNPM_DLX_CLI;
508
+ },
509
+ PNPM_EXEC_CLI: function() {
510
+ return PNPM_EXEC_CLI;
511
+ },
512
+ PNPM_LOCK_YAML: function() {
513
+ return PNPM_LOCK_YAML;
514
+ },
515
+ RESPONSE_STATUS: function() {
516
+ return RESPONSE_STATUS;
517
+ },
518
+ RIMRAF_CLI: function() {
519
+ return RIMRAF_CLI;
520
+ },
521
+ SIMPLE_GIT_HOOK_CLI: function() {
522
+ return SIMPLE_GIT_HOOK_CLI;
523
+ },
524
+ SIMPLE_GIT_HOOK_JSON: function() {
525
+ return SIMPLE_GIT_HOOK_JSON;
526
+ },
527
+ TSCONFIG_JSON: function() {
528
+ return TSCONFIG_JSON;
529
+ },
530
+ TSC_CLI: function() {
531
+ return TSC_CLI;
532
+ },
533
+ TSX_CLI: function() {
534
+ return TSX_CLI;
535
+ },
536
+ VITEST_CLI: function() {
537
+ return VITEST_CLI;
538
+ },
539
+ WORKING_DIRECTORY: function() {
540
+ return WORKING_DIRECTORY;
541
+ },
542
+ aggregatePaginate: function() {
543
+ return import_mongoose_aggregate_paginate_v2.default;
544
+ },
545
+ appendFileSync: function() {
546
+ return appendFileSync2;
547
+ },
548
+ checkPackage: function() {
549
+ return checkPackage;
550
+ },
551
+ clearAllErrorLists: function() {
552
+ return clearAllErrorLists;
553
+ },
554
+ commandFormatter: function() {
555
+ return commandFormatter;
556
+ },
557
+ commandLog: function() {
558
+ return commandLog;
559
+ },
560
+ deepMerge: function() {
561
+ return deepMerge;
562
+ },
563
+ dirname: function() {
564
+ return dirname2;
565
+ },
566
+ executeCommand: function() {
567
+ return executeCommand;
568
+ },
569
+ existsSync: function() {
570
+ return existsSync2;
571
+ },
572
+ generateShortId: function() {
573
+ return generateShortId;
574
+ },
575
+ generateSlug: function() {
576
+ return generateSlug;
577
+ },
578
+ getLatestPackageVersion: function() {
579
+ return getLatestPackageVersion;
580
+ },
581
+ getPackageJson: function() {
582
+ return getPackageJson;
583
+ },
584
+ getStorageDir: function() {
585
+ return getStorageDir;
586
+ },
587
+ getStoredErrorLists: function() {
588
+ return getStoredErrorLists;
589
+ },
590
+ initNodePersist: function() {
591
+ return initNodePersist;
592
+ },
593
+ isJson: function() {
594
+ return isJson;
595
+ },
596
+ join: function() {
597
+ return join2;
598
+ },
599
+ mongo: function() {
600
+ return mongo;
601
+ },
602
+ mongoosePaginate: function() {
603
+ return import_mongoose_paginate_v2.default;
604
+ },
605
+ readFileSync: function() {
606
+ return readFileSync2;
607
+ },
608
+ regexSearchMapper: function() {
609
+ return regexSearchMapper;
610
+ },
611
+ removeAccent: function() {
612
+ return removeAccent;
613
+ },
614
+ require: function() {
615
+ return require2;
616
+ },
617
+ resolve: function() {
618
+ return resolve2;
619
+ },
620
+ resolveCommands: function() {
621
+ return resolveCommands;
622
+ },
623
+ resolveCyberSkillPath: function() {
624
+ return resolveCyberSkillPath;
625
+ },
626
+ resolveWorkingPath: function() {
627
+ return resolveWorkingPath;
628
+ },
629
+ rmSync: function() {
630
+ return rmSync2;
631
+ },
632
+ saveErrorListToStorage: function() {
633
+ return saveErrorListToStorage;
634
+ },
635
+ serializer: function() {
636
+ return serializer;
637
+ },
638
+ storageClient: function() {
639
+ return storageClient;
640
+ },
641
+ storageServer: function() {
642
+ return storageServer;
643
+ },
644
+ throwResponse: function() {
645
+ return throwResponse;
646
+ },
647
+ useLoading: function() {
648
+ return useLoading;
649
+ },
650
+ useNextIntl: function() {
651
+ return useNextIntl;
652
+ },
653
+ useStorage: function() {
654
+ return useStorage;
655
+ },
656
+ useTranslateNextIntl: function() {
657
+ return useTranslateNextIntl;
658
+ },
659
+ validate: function() {
660
+ return validate;
661
+ },
662
+ withNextIntl: function() {
663
+ return withNextIntl;
664
+ },
665
+ writeFileSync: function() {
666
+ return writeFileSync2;
667
+ }
668
+ });
669
+ module.exports = __toCommonJS(index_exports);
670
+ // node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.52.2_@types+node@22.13.17__@swc+core@1.11.16_@swc_95e38cac10676cdf66b55e0093c30cae/node_modules/tsup/assets/cjs_shims.js
671
+ var getImportMetaUrl = function() {
672
+ return typeof document === "undefined" ? new URL("file:".concat(__filename)).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
673
+ };
674
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
675
+ // src/configs/index.ts
676
+ var import_eslint_config = __toESM(require("@antfu/eslint-config"), 1);
677
+ // src/utils/config.ts
678
+ function deepMerge() {
679
+ for(var _len = arguments.length, configs = new Array(_len), _key = 0; _key < _len; _key++){
680
+ configs[_key] = arguments[_key];
681
+ }
682
+ var merge = function(target, source) {
683
+ var result = _object_spread({}, target);
684
+ Object.keys(source).forEach(function(key) {
685
+ if (!Object.hasOwnProperty.call(source, key)) {
686
+ return;
687
+ }
688
+ var sourceValue = source[key];
689
+ var targetValue = result[key];
690
+ if (Array.isArray(sourceValue)) {
691
+ result[key] = _to_consumable_array(/* @__PURE__ */ new Set(_to_consumable_array(Array.isArray(targetValue) ? targetValue : []).concat(_to_consumable_array(sourceValue))));
692
+ } else if ((typeof sourceValue === "undefined" ? "undefined" : _type_of(sourceValue)) === "object" && sourceValue !== null && !Array.isArray(sourceValue)) {
693
+ result[key] = merge((typeof targetValue === "undefined" ? "undefined" : _type_of(targetValue)) === "object" && targetValue !== null && !Array.isArray(targetValue) ? targetValue : {}, sourceValue);
694
+ } else {
695
+ result[key] = sourceValue;
696
+ }
697
+ });
698
+ return result;
699
+ };
700
+ return configs.flatMap(function(config) {
701
+ return Array.isArray(config) ? config : [
702
+ config
703
+ ];
704
+ }).reduce(function(acc, config) {
705
+ return merge(acc, config);
706
+ }, {});
707
+ }
708
+ // src/constants/path.ts
709
+ var import_node_process3 = __toESM(require("process"), 1);
710
+ var import_node_url = require("url");
711
+ // src/utils/command.ts
712
+ var import_boxen = __toESM(require("boxen"), 1);
713
+ var import_chalk = __toESM(require("chalk"), 1);
714
+ var import_node_child_process = require("child_process");
715
+ var import_node_process2 = __toESM(require("process"), 1);
716
+ var util = __toESM(require("util"), 1);
717
+ // src/typescript/command.ts
718
+ var E_ErrorType = /* @__PURE__ */ function(E_ErrorType2) {
719
+ E_ErrorType2["Error"] = "error";
720
+ E_ErrorType2["Warning"] = "warning";
721
+ return E_ErrorType2;
722
+ }(E_ErrorType || {});
723
+ // src/utils/package.ts
724
+ var import_node_fetch = __toESM(require("node-fetch"), 1);
725
+ // src/utils/fs.ts
726
+ var fs = __toESM(require("fs"), 1);
727
+ var existsSync2 = function(filePath) {
728
+ return fs.existsSync(filePath);
729
+ };
730
+ function readFileSync2(filePath, options) {
731
+ var content = fs.readFileSync(filePath, "utf-8");
732
+ if (options === null || options === void 0 ? void 0 : options.asJson) {
733
+ try {
734
+ var parsed = JSON.parse(content);
735
+ if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === "object" && parsed !== null) {
736
+ return parsed;
737
+ }
738
+ throw new Error("Parsed JSON is not an object or array");
739
+ } catch (e) {
740
+ throw new Error("Failed to parse JSON from file: ".concat(filePath));
741
+ }
742
+ }
743
+ return content;
744
+ }
745
+ function writeFileSync2(filePath, data) {
746
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
747
+ var tmp = options.isJson, isJson2 = tmp === void 0 ? false : tmp;
748
+ var content = isJson2 && (typeof data === "undefined" ? "undefined" : _type_of(data)) === "object" ? JSON.stringify(data, null, 4) : String(data);
749
+ fs.writeFileSync(filePath, content, "utf-8");
750
+ }
751
+ function appendFileSync2(filePath, data) {
752
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
753
+ var tmp = options.isJson, isJson2 = tmp === void 0 ? false : tmp;
754
+ var content = isJson2 && (typeof data === "undefined" ? "undefined" : _type_of(data)) === "object" ? JSON.stringify(data, null, 4) : String(data);
755
+ fs.appendFileSync(filePath, content, "utf-8");
756
+ }
757
+ function rmSync2(filePaths) {
758
+ filePaths.forEach(function(filePath) {
759
+ if (existsSync2(filePath)) {
760
+ fs.rmSync(filePath, {
761
+ recursive: true,
762
+ force: true
763
+ });
764
+ }
765
+ });
766
+ }
767
+ // src/utils/path.ts
768
+ var import_node_module = require("module");
769
+ var path = __toESM(require("path"), 1);
770
+ function resolveCyberSkillPath() {
771
+ for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
772
+ urls[_key] = arguments[_key];
773
+ }
774
+ var _path;
775
+ return (_path = path).resolve.apply(_path, [
776
+ CYBERSKILL_DIRECTORY
777
+ ].concat(_to_consumable_array(urls)));
778
+ }
779
+ function resolveWorkingPath() {
780
+ for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
781
+ urls[_key] = arguments[_key];
782
+ }
783
+ var _path;
784
+ return (_path = path).resolve.apply(_path, [
785
+ WORKING_DIRECTORY
786
+ ].concat(_to_consumable_array(urls)));
787
+ }
788
+ function resolve2() {
789
+ for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
790
+ urls[_key] = arguments[_key];
791
+ }
792
+ var _path;
793
+ return (_path = path).resolve.apply(_path, _to_consumable_array(urls));
794
+ }
795
+ function dirname2(url) {
796
+ return path.dirname(url);
797
+ }
798
+ function require2() {
799
+ return (0, import_node_module.createRequire)(CYBERSKILL_DIRECTORY);
800
+ }
801
+ function join2() {
802
+ for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
803
+ urls[_key] = arguments[_key];
804
+ }
805
+ var _path;
806
+ return (_path = path).join.apply(_path, _to_consumable_array(urls));
807
+ }
808
+ // src/utils/storage-server.ts
809
+ var import_node_persist = __toESM(require("node-persist"), 1);
810
+ var import_node_os = __toESM(require("os"), 1);
811
+ var import_node_path = __toESM(require("path"), 1);
812
+ var import_node_process = __toESM(require("process"), 1);
813
+ function getStorageDir() {
814
+ return import_node_process.default.env.CYBERSKILL_STORAGE_DIR || import_node_path.default.join(import_node_os.default.homedir(), CYBERSKILL_STORAGE);
815
+ }
816
+ function initNodePersist() {
817
+ return _initNodePersist.apply(this, arguments);
818
+ }
819
+ function _initNodePersist() {
820
+ _initNodePersist = _async_to_generator(function() {
821
+ return _ts_generator(this, function(_state) {
822
+ switch(_state.label){
823
+ case 0:
824
+ if (!!import_node_persist.default.defaultInstance) return [
825
+ 3,
826
+ 2
827
+ ];
828
+ return [
829
+ 4,
830
+ import_node_persist.default.init({
831
+ dir: getStorageDir(),
832
+ stringify: JSON.stringify,
833
+ parse: JSON.parse,
834
+ encoding: "utf8",
835
+ logging: false,
836
+ forgiveParseErrors: true
837
+ })
838
+ ];
839
+ case 1:
840
+ _state.sent();
841
+ _state.label = 2;
842
+ case 2:
843
+ return [
844
+ 2
845
+ ];
846
+ }
847
+ });
848
+ });
849
+ return _initNodePersist.apply(this, arguments);
850
+ }
851
+ var storageServer = {
852
+ get: function get(key) {
853
+ return _async_to_generator(function() {
854
+ var result, error;
855
+ return _ts_generator(this, function(_state) {
856
+ switch(_state.label){
857
+ case 0:
858
+ _state.trys.push([
859
+ 0,
860
+ 3,
861
+ ,
862
+ 4
863
+ ]);
864
+ return [
865
+ 4,
866
+ initNodePersist()
867
+ ];
868
+ case 1:
869
+ _state.sent();
870
+ return [
871
+ 4,
872
+ import_node_persist.default.getItem(key)
873
+ ];
874
+ case 2:
875
+ result = _state.sent();
876
+ return [
877
+ 2,
878
+ result !== null && result !== void 0 ? result : null
879
+ ];
880
+ case 3:
881
+ error = _state.sent();
882
+ console.error('❌ [Storage:get] Error getting key "'.concat(key, '":'), error);
883
+ return [
884
+ 2,
885
+ null
886
+ ];
887
+ case 4:
888
+ return [
889
+ 2
890
+ ];
891
+ }
892
+ });
893
+ })();
894
+ },
895
+ set: function set(key, value) {
896
+ return _async_to_generator(function() {
897
+ var error;
898
+ return _ts_generator(this, function(_state) {
899
+ switch(_state.label){
900
+ case 0:
901
+ _state.trys.push([
902
+ 0,
903
+ 3,
904
+ ,
905
+ 4
906
+ ]);
907
+ return [
908
+ 4,
909
+ initNodePersist()
910
+ ];
911
+ case 1:
912
+ _state.sent();
913
+ return [
914
+ 4,
915
+ import_node_persist.default.setItem(key, value)
916
+ ];
917
+ case 2:
918
+ _state.sent();
919
+ return [
920
+ 3,
921
+ 4
922
+ ];
923
+ case 3:
924
+ error = _state.sent();
925
+ console.error('❌ [Storage:set] Error setting key "'.concat(key, '":'), error);
926
+ return [
927
+ 3,
928
+ 4
929
+ ];
930
+ case 4:
931
+ return [
932
+ 2
933
+ ];
934
+ }
935
+ });
936
+ })();
937
+ },
938
+ remove: function remove(key) {
939
+ return _async_to_generator(function() {
940
+ var error;
941
+ return _ts_generator(this, function(_state) {
942
+ switch(_state.label){
943
+ case 0:
944
+ _state.trys.push([
945
+ 0,
946
+ 3,
947
+ ,
948
+ 4
949
+ ]);
950
+ return [
951
+ 4,
952
+ initNodePersist()
953
+ ];
954
+ case 1:
955
+ _state.sent();
956
+ return [
957
+ 4,
958
+ import_node_persist.default.removeItem(key)
959
+ ];
960
+ case 2:
961
+ _state.sent();
962
+ return [
963
+ 3,
964
+ 4
965
+ ];
966
+ case 3:
967
+ error = _state.sent();
968
+ console.error('❌ [Storage:remove] Error removing key "'.concat(key, '":'), error);
969
+ return [
970
+ 3,
971
+ 4
972
+ ];
973
+ case 4:
974
+ return [
975
+ 2
976
+ ];
977
+ }
978
+ });
979
+ })();
980
+ },
981
+ keys: function keys() {
982
+ return _async_to_generator(function() {
983
+ var keys, error;
984
+ return _ts_generator(this, function(_state) {
985
+ switch(_state.label){
986
+ case 0:
987
+ _state.trys.push([
988
+ 0,
989
+ 3,
990
+ ,
991
+ 4
992
+ ]);
993
+ return [
994
+ 4,
995
+ initNodePersist()
996
+ ];
997
+ case 1:
998
+ _state.sent();
999
+ return [
1000
+ 4,
1001
+ import_node_persist.default.keys()
1002
+ ];
1003
+ case 2:
1004
+ keys = _state.sent();
1005
+ if (!Array.isArray(keys)) {
1006
+ console.warn("⚠️ [Storage:keys] Invalid keys response:", keys);
1007
+ return [
1008
+ 2,
1009
+ []
1010
+ ];
1011
+ }
1012
+ return [
1013
+ 2,
1014
+ keys
1015
+ ];
1016
+ case 3:
1017
+ error = _state.sent();
1018
+ console.error("❌ [Storage:keys] Error getting keys:", error);
1019
+ return [
1020
+ 2,
1021
+ []
1022
+ ];
1023
+ case 4:
1024
+ return [
1025
+ 2
1026
+ ];
1027
+ }
1028
+ });
1029
+ })();
1030
+ },
1031
+ getLogLink: function getLogLink(key) {
1032
+ return _async_to_generator(function() {
1033
+ var storagePath;
1034
+ return _ts_generator(this, function(_state) {
1035
+ try {
1036
+ storagePath = getStorageDir();
1037
+ return [
1038
+ 2,
1039
+ "".concat(storagePath, " (key: ").concat(key, ")")
1040
+ ];
1041
+ } catch (error) {
1042
+ console.error("❌ [Storage:getLogLink] Error getting log link:", error);
1043
+ return [
1044
+ 2,
1045
+ null
1046
+ ];
1047
+ }
1048
+ return [
1049
+ 2
1050
+ ];
1051
+ });
1052
+ })();
1053
+ }
1054
+ };
1055
+ // src/utils/package.ts
1056
+ var CACHE_EXPIRATION_MS = 24 * 60 * 60 * 1e3;
1057
+ function getPackageJson(packageName) {
1058
+ var workingPackageJsonPath = join2(WORKING_DIRECTORY, PACKAGE_JSON);
1059
+ if (existsSync2(workingPackageJsonPath)) {
1060
+ try {
1061
+ var pkg = readFileSync2(workingPackageJsonPath, {
1062
+ asJson: true
1063
+ });
1064
+ if (pkg.name === packageName) {
1065
+ return {
1066
+ path: workingPackageJsonPath,
1067
+ file: pkg
1068
+ };
1069
+ }
1070
+ } catch (error) {
1071
+ commandLog.warning("Failed to read local package.json: ".concat(error.message));
1072
+ }
1073
+ }
1074
+ var externalPackageJsonPath = join2(WORKING_DIRECTORY, NODE_MODULES, packageName, PACKAGE_JSON);
1075
+ if (existsSync2(externalPackageJsonPath)) {
1076
+ try {
1077
+ var pkg1 = readFileSync2(externalPackageJsonPath, {
1078
+ asJson: true
1079
+ });
1080
+ if (pkg1.name === packageName) {
1081
+ return {
1082
+ path: externalPackageJsonPath,
1083
+ file: pkg1
1084
+ };
1085
+ }
1086
+ } catch (error) {
1087
+ commandLog.warning("Failed to read node_modules package.json for ".concat(packageName, ": ").concat(error.message));
1088
+ }
1089
+ }
1090
+ return false;
1091
+ }
1092
+ function getLatestPackageVersion(packageName) {
1093
+ return _getLatestPackageVersion.apply(this, arguments);
1094
+ }
1095
+ function _getLatestPackageVersion() {
1096
+ _getLatestPackageVersion = _async_to_generator(function(packageName) {
1097
+ var forceRefresh, versionCacheKey, metadataCacheKey, cached, metadata, isCacheValid, headers, response, data, latestVersion, error;
1098
+ var _arguments = arguments;
1099
+ return _ts_generator(this, function(_state) {
1100
+ switch(_state.label){
1101
+ case 0:
1102
+ forceRefresh = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : false;
1103
+ versionCacheKey = "npm_version:".concat(packageName);
1104
+ metadataCacheKey = "npm_metadata:".concat(packageName);
1105
+ return [
1106
+ 4,
1107
+ storageServer.get(versionCacheKey)
1108
+ ];
1109
+ case 1:
1110
+ cached = _state.sent();
1111
+ return [
1112
+ 4,
1113
+ storageServer.get(metadataCacheKey)
1114
+ ];
1115
+ case 2:
1116
+ metadata = _state.sent();
1117
+ isCacheValid = cached && Date.now() - cached.timestamp < CACHE_EXPIRATION_MS;
1118
+ if (!forceRefresh && isCacheValid) {
1119
+ return [
1120
+ 2,
1121
+ cached.version
1122
+ ];
1123
+ }
1124
+ headers = {};
1125
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.etag) {
1126
+ headers["If-None-Match"] = metadata.etag;
1127
+ }
1128
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.lastModified) {
1129
+ headers["If-Modified-Since"] = metadata.lastModified;
1130
+ }
1131
+ _state.label = 3;
1132
+ case 3:
1133
+ _state.trys.push([
1134
+ 3,
1135
+ 8,
1136
+ ,
1137
+ 9
1138
+ ]);
1139
+ return [
1140
+ 4,
1141
+ (0, import_node_fetch.default)("https://registry.npmjs.org/".concat(packageName, "/latest"), {
1142
+ headers: headers
1143
+ })
1144
+ ];
1145
+ case 4:
1146
+ response = _state.sent();
1147
+ if (response.status === 304 && cached) {
1148
+ return [
1149
+ 2,
1150
+ cached.version
1151
+ ];
1152
+ }
1153
+ if (!response.ok) {
1154
+ throw new Error("Failed to fetch latest version: ".concat(response.statusText));
1155
+ }
1156
+ return [
1157
+ 4,
1158
+ response.json()
1159
+ ];
1160
+ case 5:
1161
+ data = _state.sent();
1162
+ latestVersion = data.version;
1163
+ return [
1164
+ 4,
1165
+ storageServer.set(versionCacheKey, {
1166
+ version: latestVersion,
1167
+ timestamp: Date.now()
1168
+ })
1169
+ ];
1170
+ case 6:
1171
+ _state.sent();
1172
+ return [
1173
+ 4,
1174
+ storageServer.set(metadataCacheKey, {
1175
+ etag: response.headers.get("ETag") || void 0,
1176
+ lastModified: response.headers.get("Last-Modified") || void 0
1177
+ })
1178
+ ];
1179
+ case 7:
1180
+ _state.sent();
1181
+ return [
1182
+ 2,
1183
+ latestVersion
1184
+ ];
1185
+ case 8:
1186
+ error = _state.sent();
1187
+ commandLog.error("Error fetching latest version for ".concat(packageName, ": ").concat(error.message));
1188
+ if (cached) {
1189
+ commandLog.warning("Falling back to cached version for ".concat(packageName, ": ").concat(cached.version));
1190
+ return [
1191
+ 2,
1192
+ cached.version
1193
+ ];
1194
+ }
1195
+ throw error;
1196
+ case 9:
1197
+ return [
1198
+ 2
1199
+ ];
1200
+ }
1201
+ });
1202
+ });
1203
+ return _getLatestPackageVersion.apply(this, arguments);
1204
+ }
1205
+ function checkPackage(packageName) {
1206
+ return _checkPackage.apply(this, arguments);
1207
+ }
1208
+ function _checkPackage() {
1209
+ _checkPackage = _async_to_generator(function(packageName) {
1210
+ var result, packageFound, cyberskillPackageJsonPath, isCurrentProject, _tmp, error;
1211
+ return _ts_generator(this, function(_state) {
1212
+ switch(_state.label){
1213
+ case 0:
1214
+ result = {
1215
+ isInstalled: false,
1216
+ isCurrentProject: false,
1217
+ installedPath: "",
1218
+ installedVersion: "",
1219
+ latestVersion: "",
1220
+ file: {}
1221
+ };
1222
+ _state.label = 1;
1223
+ case 1:
1224
+ _state.trys.push([
1225
+ 1,
1226
+ 5,
1227
+ ,
1228
+ 6
1229
+ ]);
1230
+ packageFound = getPackageJson(packageName);
1231
+ if (!packageFound) {
1232
+ return [
1233
+ 2,
1234
+ result
1235
+ ];
1236
+ }
1237
+ cyberskillPackageJsonPath = resolveCyberSkillPath(PACKAGE_JSON);
1238
+ isCurrentProject = packageFound.path === cyberskillPackageJsonPath;
1239
+ result.file = packageFound.file;
1240
+ result.isInstalled = true;
1241
+ result.installedPath = packageFound.path;
1242
+ result.installedVersion = packageFound.file.version;
1243
+ result.isCurrentProject = isCurrentProject;
1244
+ if (!isCurrentProject) return [
1245
+ 3,
1246
+ 2
1247
+ ];
1248
+ _tmp = packageFound.file.version;
1249
+ return [
1250
+ 3,
1251
+ 4
1252
+ ];
1253
+ case 2:
1254
+ return [
1255
+ 4,
1256
+ getLatestPackageVersion(packageName, true)
1257
+ ];
1258
+ case 3:
1259
+ _tmp = _state.sent();
1260
+ _state.label = 4;
1261
+ case 4:
1262
+ result.latestVersion = _tmp;
1263
+ return [
1264
+ 2,
1265
+ result
1266
+ ];
1267
+ case 5:
1268
+ error = _state.sent();
1269
+ commandLog.error('Error checking package "'.concat(packageName, '": ').concat(error.message));
1270
+ return [
1271
+ 2,
1272
+ result
1273
+ ];
1274
+ case 6:
1275
+ return [
1276
+ 2
1277
+ ];
1278
+ }
1279
+ });
1280
+ });
1281
+ return _checkPackage.apply(this, arguments);
1282
+ }
1283
+ // src/utils/command.ts
1284
+ var DEBUG = import_node_process2.default.env.DEBUG === "true";
1285
+ var execPromise = util.promisify(import_node_child_process.exec);
1286
+ var _import_chalk_default = import_chalk.default, gray = _import_chalk_default.gray, blue = _import_chalk_default.blue;
1287
+ var getTimeStamp = function() {
1288
+ return gray("[".concat(/* @__PURE__ */ new Date().toLocaleTimeString(), "]"));
1289
+ };
1290
+ function chalkKeyword(color) {
1291
+ var chalkColor = import_chalk.default[color];
1292
+ return typeof chalkColor === "function" ? chalkColor : import_chalk.default.green;
1293
+ }
1294
+ function printLog(type, color, icon, message) {
1295
+ var chalkColor = chalkKeyword(color);
1296
+ console.log("".concat(getTimeStamp(), " ").concat(chalkColor("".concat(icon, " ").concat(type)), " ").concat(message));
1297
+ }
1298
+ function printBoxedLog(title, content) {
1299
+ var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, _ref_color = _ref.color, color = _ref_color === void 0 ? "green" : _ref_color, _ref_padding = _ref.padding, padding = _ref_padding === void 0 ? 1 : _ref_padding, _ref_margin = _ref.margin, margin = _ref_margin === void 0 ? 1 : _ref_margin, _ref_borderStyle = _ref.borderStyle, borderStyle = _ref_borderStyle === void 0 ? "round" : _ref_borderStyle, _ref_titleColor = _ref.titleColor, titleColor = _ref_titleColor === void 0 ? "bold" : _ref_titleColor;
1300
+ var chalkColor = chalkKeyword(color);
1301
+ var chalkTitleColor = chalkKeyword(titleColor);
1302
+ if (typeof content === "string") {
1303
+ console.log((0, import_boxen.default)(chalkTitleColor(chalkColor("".concat(title, "\n").concat(content))), {
1304
+ padding: padding,
1305
+ margin: margin,
1306
+ borderStyle: borderStyle,
1307
+ borderColor: color
1308
+ }));
1309
+ return;
1310
+ }
1311
+ if (Array.isArray(content) && content.length) {
1312
+ content.forEach(function(param) {
1313
+ var file = param.file, position = param.position, rule = param.rule, message = param.message;
1314
+ console.log("".concat(getTimeStamp(), " ").concat(chalkColor("File:"), " ").concat(blue("".concat(file).concat(position ? ":".concat(position) : ""))));
1315
+ if (rule) console.log(" ".concat(chalkColor("Rule:"), " ").concat(chalkColor(rule)));
1316
+ console.log(" ".concat(chalkColor("Message:"), " ").concat(chalkColor(message)));
1317
+ });
1318
+ console.log((0, import_boxen.default)(chalkTitleColor(chalkColor("".concat(title, ": ").concat(content.length))), {
1319
+ padding: padding,
1320
+ margin: margin,
1321
+ borderStyle: borderStyle,
1322
+ borderColor: color
1323
+ }));
1324
+ console.log(gray("\u2500".repeat(40)));
1325
+ }
1326
+ }
1327
+ var commandLog = {
1328
+ success: function(message) {
1329
+ return printLog("SUCCESS", "green", "\u2714", message);
1330
+ },
1331
+ error: function(message) {
1332
+ return printLog("ERROR", "red", "\u2716", message);
1333
+ },
1334
+ warning: function(message) {
1335
+ return printLog("WARNING", "yellow", "\u26A0", message);
1336
+ },
1337
+ info: function(message) {
1338
+ return printLog("INFO", "blue", "\u2139", message);
1339
+ },
1340
+ printBoxedLog: printBoxedLog
1341
+ };
1342
+ var getErrorListKey = function(timestamp) {
1343
+ return "error_list:".concat(timestamp);
1344
+ };
1345
+ function saveErrorListToStorage(errorList) {
1346
+ return _saveErrorListToStorage.apply(this, arguments);
1347
+ }
1348
+ function _saveErrorListToStorage() {
1349
+ _saveErrorListToStorage = _async_to_generator(function(errorList) {
1350
+ var timestamp, key, error;
1351
+ return _ts_generator(this, function(_state) {
1352
+ switch(_state.label){
1353
+ case 0:
1354
+ if (errorList.length === 0) {
1355
+ return [
1356
+ 2
1357
+ ];
1358
+ }
1359
+ timestamp = Date.now();
1360
+ key = getErrorListKey(timestamp);
1361
+ _state.label = 1;
1362
+ case 1:
1363
+ _state.trys.push([
1364
+ 1,
1365
+ 3,
1366
+ ,
1367
+ 4
1368
+ ]);
1369
+ return [
1370
+ 4,
1371
+ storageServer.set(key, {
1372
+ errors: errorList,
1373
+ timestamp: timestamp
1374
+ })
1375
+ ];
1376
+ case 2:
1377
+ _state.sent();
1378
+ setTimeout(/*#__PURE__*/ _async_to_generator(function() {
1379
+ var logPath;
1380
+ return _ts_generator(this, function(_state) {
1381
+ switch(_state.label){
1382
+ case 0:
1383
+ return [
1384
+ 4,
1385
+ storageServer.getLogLink(key)
1386
+ ];
1387
+ case 1:
1388
+ logPath = _state.sent();
1389
+ if (logPath) {
1390
+ commandLog.info("\uD83D\uDCC2 Open the error list manually: ".concat(logPath));
1391
+ }
1392
+ return [
1393
+ 2
1394
+ ];
1395
+ }
1396
+ });
1397
+ }), 10);
1398
+ return [
1399
+ 3,
1400
+ 4
1401
+ ];
1402
+ case 3:
1403
+ error = _state.sent();
1404
+ commandLog.error("Failed to save errors: ".concat(error.message));
1405
+ return [
1406
+ 3,
1407
+ 4
1408
+ ];
1409
+ case 4:
1410
+ return [
1411
+ 2
1412
+ ];
1413
+ }
1414
+ });
1415
+ });
1416
+ return _saveErrorListToStorage.apply(this, arguments);
1417
+ }
1418
+ function getStoredErrorLists() {
1419
+ return _getStoredErrorLists.apply(this, arguments);
1420
+ }
1421
+ function _getStoredErrorLists() {
1422
+ _getStoredErrorLists = _async_to_generator(function() {
1423
+ var keys, errorKeys, allErrors, error;
1424
+ return _ts_generator(this, function(_state) {
1425
+ switch(_state.label){
1426
+ case 0:
1427
+ _state.trys.push([
1428
+ 0,
1429
+ 3,
1430
+ ,
1431
+ 4
1432
+ ]);
1433
+ return [
1434
+ 4,
1435
+ storageServer.keys()
1436
+ ];
1437
+ case 1:
1438
+ keys = _state.sent();
1439
+ errorKeys = Array.isArray(keys) ? keys.filter(function(key) {
1440
+ var _key_startsWith;
1441
+ return key === null || key === void 0 ? void 0 : (_key_startsWith = key.startsWith) === null || _key_startsWith === void 0 ? void 0 : _key_startsWith.call(key, "error_list:");
1442
+ }) : [];
1443
+ return [
1444
+ 4,
1445
+ Promise.all(errorKeys.map(/*#__PURE__*/ function() {
1446
+ var _ref = _async_to_generator(function(key) {
1447
+ var entry;
1448
+ return _ts_generator(this, function(_state) {
1449
+ switch(_state.label){
1450
+ case 0:
1451
+ return [
1452
+ 4,
1453
+ storageServer.get(key)
1454
+ ];
1455
+ case 1:
1456
+ entry = _state.sent();
1457
+ return [
1458
+ 2,
1459
+ (entry === null || entry === void 0 ? void 0 : entry.errors) || []
1460
+ ];
1461
+ }
1462
+ });
1463
+ });
1464
+ return function(key) {
1465
+ return _ref.apply(this, arguments);
1466
+ };
1467
+ }()))
1468
+ ];
1469
+ case 2:
1470
+ allErrors = _state.sent();
1471
+ return [
1472
+ 2,
1473
+ allErrors.flat()
1474
+ ];
1475
+ case 3:
1476
+ error = _state.sent();
1477
+ commandLog.error("Failed to retrieve stored errors: ".concat(error.message));
1478
+ return [
1479
+ 2,
1480
+ []
1481
+ ];
1482
+ case 4:
1483
+ return [
1484
+ 2
1485
+ ];
1486
+ }
1487
+ });
1488
+ });
1489
+ return _getStoredErrorLists.apply(this, arguments);
1490
+ }
1491
+ function clearAllErrorLists() {
1492
+ return _clearAllErrorLists.apply(this, arguments);
1493
+ }
1494
+ function _clearAllErrorLists() {
1495
+ _clearAllErrorLists = _async_to_generator(function() {
1496
+ var keys, errorKeys, error;
1497
+ return _ts_generator(this, function(_state) {
1498
+ switch(_state.label){
1499
+ case 0:
1500
+ _state.trys.push([
1501
+ 0,
1502
+ 3,
1503
+ ,
1504
+ 4
1505
+ ]);
1506
+ return [
1507
+ 4,
1508
+ storageServer.keys()
1509
+ ];
1510
+ case 1:
1511
+ keys = _state.sent();
1512
+ errorKeys = Array.isArray(keys) ? keys.filter(function(key) {
1513
+ var _key_startsWith;
1514
+ return key === null || key === void 0 ? void 0 : (_key_startsWith = key.startsWith) === null || _key_startsWith === void 0 ? void 0 : _key_startsWith.call(key, "error_list:");
1515
+ }) : [];
1516
+ return [
1517
+ 4,
1518
+ Promise.all(errorKeys.map(function(key) {
1519
+ return storageServer.remove(key);
1520
+ }))
1521
+ ];
1522
+ case 2:
1523
+ _state.sent();
1524
+ return [
1525
+ 3,
1526
+ 4
1527
+ ];
1528
+ case 3:
1529
+ error = _state.sent();
1530
+ commandLog.error("Failed to clear error lists: ".concat(error.message));
1531
+ return [
1532
+ 3,
1533
+ 4
1534
+ ];
1535
+ case 4:
1536
+ return [
1537
+ 2
1538
+ ];
1539
+ }
1540
+ });
1541
+ });
1542
+ return _clearAllErrorLists.apply(this, arguments);
1543
+ }
1544
+ function parseTextErrors(output) {
1545
+ var errorList = [];
1546
+ var unmatchedLines = [];
1547
+ var lastFilePath = "";
1548
+ var eslintErrorDetailsRegex = /^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/;
1549
+ var tsRegex = /^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/;
1550
+ var commitlintRegex = /^✖\s+(.*?)\s+\[(.*?)\]$/;
1551
+ output.split("\n").forEach(function(line) {
1552
+ if (line.startsWith("/")) {
1553
+ lastFilePath = line.trim();
1554
+ } else {
1555
+ var eslintMatch = eslintErrorDetailsRegex.exec(line) || [];
1556
+ var tsMatch = tsRegex.exec(line) || [];
1557
+ var commitlintMatch = commitlintRegex.exec(line) || [];
1558
+ if (eslintMatch.length && lastFilePath) {
1559
+ errorList.push({
1560
+ file: lastFilePath,
1561
+ position: "".concat(eslintMatch[1], ":").concat(eslintMatch[2]),
1562
+ type: eslintMatch[3] === "error" /* Error */ ? "error" /* Error */ : "warning" /* Warning */ ,
1563
+ message: eslintMatch[4].trim(),
1564
+ rule: eslintMatch[5].trim()
1565
+ });
1566
+ } else if (tsMatch.length) {
1567
+ errorList.push({
1568
+ file: tsMatch[1],
1569
+ position: "".concat(tsMatch[2], ":").concat(tsMatch[3]),
1570
+ type: tsMatch[4] === "error" /* Error */ ? "error" /* Error */ : "warning" /* Warning */ ,
1571
+ message: tsMatch[5].trim()
1572
+ });
1573
+ } else if (commitlintMatch.length) {
1574
+ errorList.push({
1575
+ file: "commitlint",
1576
+ type: "error" /* Error */ ,
1577
+ message: commitlintMatch[1].trim(),
1578
+ rule: commitlintMatch[2].trim()
1579
+ });
1580
+ } else {
1581
+ unmatchedLines.push(line.trim());
1582
+ }
1583
+ }
1584
+ });
1585
+ if (errorList.length) {
1586
+ saveErrorListToStorage(errorList);
1587
+ }
1588
+ if (unmatchedLines.length && DEBUG) {
1589
+ commandLog.warning("Unmatched lines:");
1590
+ unmatchedLines.forEach(function(line) {
1591
+ return console.log(" ".concat(line));
1592
+ });
1593
+ }
1594
+ }
1595
+ function parseCommandOutput(output) {
1596
+ try {
1597
+ var results = JSON.parse(output);
1598
+ var errorList = [];
1599
+ results.forEach(function(param) {
1600
+ var filePath = param.filePath, messages = param.messages;
1601
+ messages.forEach(function(param) {
1602
+ var severity = param.severity, line = param.line, column = param.column, ruleId = param.ruleId, message = param.message;
1603
+ errorList.push({
1604
+ type: severity === 2 ? "error" /* Error */ : "warning" /* Warning */ ,
1605
+ file: filePath,
1606
+ position: "".concat(line, ":").concat(column),
1607
+ rule: ruleId,
1608
+ message: message
1609
+ });
1610
+ });
1611
+ });
1612
+ if (errorList.length) {
1613
+ saveErrorListToStorage(errorList);
1614
+ }
1615
+ } catch (e) {
1616
+ parseTextErrors(output);
1617
+ }
1618
+ }
1619
+ function executeCommand(command) {
1620
+ return _executeCommand.apply(this, arguments);
1621
+ }
1622
+ function _executeCommand() {
1623
+ _executeCommand = _async_to_generator(function(command) {
1624
+ var parser, controller, _ref, stdout, stderr, error, stdout1, stderr1, message;
1625
+ var _arguments = arguments;
1626
+ return _ts_generator(this, function(_state) {
1627
+ switch(_state.label){
1628
+ case 0:
1629
+ parser = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : parseCommandOutput;
1630
+ controller = new AbortController();
1631
+ import_node_process2.default.on("SIGINT", function() {
1632
+ commandLog.warning("Process interrupted. Terminating...");
1633
+ controller.abort();
1634
+ import_node_process2.default.exit();
1635
+ });
1636
+ _state.label = 1;
1637
+ case 1:
1638
+ _state.trys.push([
1639
+ 1,
1640
+ 3,
1641
+ ,
1642
+ 4
1643
+ ]);
1644
+ return [
1645
+ 4,
1646
+ execPromise(command, {
1647
+ maxBuffer: 1024 * 1024 * 100,
1648
+ signal: controller.signal
1649
+ })
1650
+ ];
1651
+ case 2:
1652
+ _ref = _state.sent(), stdout = _ref.stdout, stderr = _ref.stderr;
1653
+ [
1654
+ stdout,
1655
+ stderr
1656
+ ].forEach(function(output) {
1657
+ return output && parser(output);
1658
+ });
1659
+ return [
1660
+ 3,
1661
+ 4
1662
+ ];
1663
+ case 3:
1664
+ error = _state.sent();
1665
+ stdout1 = error.stdout, stderr1 = error.stderr, message = error.message;
1666
+ [
1667
+ stdout1,
1668
+ stderr1
1669
+ ].forEach(function(output) {
1670
+ return output && parser(output);
1671
+ });
1672
+ if (!stderr1 && !stdout1) {
1673
+ commandLog.error("Command failed: ".concat(message));
1674
+ }
1675
+ return [
1676
+ 3,
1677
+ 4
1678
+ ];
1679
+ case 4:
1680
+ return [
1681
+ 2
1682
+ ];
1683
+ }
1684
+ });
1685
+ });
1686
+ return _executeCommand.apply(this, arguments);
1687
+ }
1688
+ var commandFormatter = {
1689
+ raw: function(cmd) {
1690
+ return {
1691
+ raw: true,
1692
+ cmd: cmd
1693
+ };
1694
+ },
1695
+ isRaw: function isRaw(cmd) {
1696
+ return (typeof cmd === "undefined" ? "undefined" : _type_of(cmd)) === "object" && cmd !== null && cmd.raw === true;
1697
+ },
1698
+ format: function format(command, context) {
1699
+ if (typeof command === "function") {
1700
+ return commandFormatter.formatCLI(command(context), context);
1701
+ }
1702
+ if (commandFormatter.isRaw(command)) {
1703
+ return command.cmd;
1704
+ }
1705
+ return commandFormatter.formatCLI(command, context);
1706
+ },
1707
+ formatCLI: function formatCLI(command, context) {
1708
+ if (context === null || context === void 0 ? void 0 : context.isRemote) {
1709
+ return "".concat(PNPM_DLX_CLI, " ").concat(CYBERSKILL_PACKAGE_NAME, " ").concat(command);
1710
+ }
1711
+ if (context === null || context === void 0 ? void 0 : context.isCurrentProject) {
1712
+ return "".concat(PNPM_EXEC_CLI, " ").concat(TSX_CLI, " src/cli.ts ").concat(command);
1713
+ }
1714
+ return "".concat(PNPM_EXEC_CLI, " ").concat(CYBERSKILL_CLI, " ").concat(command);
1715
+ }
1716
+ };
1717
+ function resolveCommands(input) {
1718
+ return _resolveCommands.apply(this, arguments);
1719
+ }
1720
+ function _resolveCommands() {
1721
+ _resolveCommands = _async_to_generator(function(input) {
1722
+ var context, _context_isRemote, isRemote, isCurrentProject, _tmp, ctx, commands;
1723
+ var _arguments = arguments;
1724
+ return _ts_generator(this, function(_state) {
1725
+ switch(_state.label){
1726
+ case 0:
1727
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
1728
+ isRemote = (_context_isRemote = context === null || context === void 0 ? void 0 : context.isRemote) !== null && _context_isRemote !== void 0 ? _context_isRemote : false;
1729
+ if (!isRemote) return [
1730
+ 3,
1731
+ 1
1732
+ ];
1733
+ _tmp = false;
1734
+ return [
1735
+ 3,
1736
+ 3
1737
+ ];
1738
+ case 1:
1739
+ return [
1740
+ 4,
1741
+ checkPackage(CYBERSKILL_PACKAGE_NAME)
1742
+ ];
1743
+ case 2:
1744
+ _tmp = _state.sent().isCurrentProject;
1745
+ _state.label = 3;
1746
+ case 3:
1747
+ isCurrentProject = _tmp;
1748
+ ctx = {
1749
+ isRemote: isRemote,
1750
+ isCurrentProject: isCurrentProject
1751
+ };
1752
+ commands = typeof input === "function" ? input(ctx) : input;
1753
+ return [
1754
+ 2,
1755
+ Object.fromEntries(Object.entries(commands).map(function(param) {
1756
+ var _param = _sliced_to_array(param, 2), key = _param[0], cmd = _param[1];
1757
+ return [
1758
+ key,
1759
+ commandFormatter.format(cmd, ctx)
1760
+ ];
1761
+ }))
1762
+ ];
1763
+ }
1764
+ });
1765
+ });
1766
+ return _resolveCommands.apply(this, arguments);
1767
+ }
1768
+ // src/constants/path.ts
1769
+ var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
1770
+ var __dirname = dirname2(__filename2);
1771
+ var CYBERSKILL_DIRECTORY = resolve2(__dirname, "../../");
1772
+ var WORKING_DIRECTORY = import_node_process3.default.env.INIT_CWD || import_node_process3.default.cwd();
1773
+ var CYBERSKILL_PACKAGE_NAME = "@cyberskill/shared";
1774
+ var CYBERSKILL_STORAGE = ".cyberskill-storage";
1775
+ var NODE_MODULES = "node_modules";
1776
+ var BUILD_DIRECTORY = "dist";
1777
+ var PACKAGE_JSON = "package.json";
1778
+ var PACKAGE_LOCK_JSON = "package-lock.json";
1779
+ var TSCONFIG_JSON = "tsconfig.json";
1780
+ var GIT_IGNORE = ".gitignore";
1781
+ var SIMPLE_GIT_HOOK_JSON = ".simple-git-hooks.json";
1782
+ var PNPM_LOCK_YAML = "pnpm-lock.yaml";
1783
+ var GIT_HOOK = ".git/hooks";
1784
+ var GIT_COMMIT_EDITMSG = ".git/COMMIT_EDITMSG";
1785
+ var CYBERSKILL_CLI = "cyberskill";
1786
+ var ESLINT_CLI = "eslint";
1787
+ var VITEST_CLI = "vitest";
1788
+ var COMMIT_LINT_CLI = "commitlint";
1789
+ var LINT_STAGED_CLI = "lint-staged";
1790
+ var RIMRAF_CLI = "rimraf";
1791
+ var TSC_CLI = "tsc";
1792
+ var TSX_CLI = "tsx";
1793
+ var GIT_CLI = "git";
1794
+ var PNPM_CLI = "pnpm";
1795
+ var PNPM_DLX_CLI = "pnpm dlx";
1796
+ var PNPM_EXEC_CLI = "pnpm exec";
1797
+ var SIMPLE_GIT_HOOK_CLI = "simple-git-hooks";
1798
+ var ESLINT_INSPECT_CLI = "@eslint/config-inspector";
1799
+ var NODE_MODULES_INSPECT_CLI = "node_modules-inspect";
1800
+ var PATH = {
1801
+ CYBERSKILL_DIRECTORY: CYBERSKILL_DIRECTORY,
1802
+ WORKING_DIRECTORY: WORKING_DIRECTORY,
1803
+ TS_CONFIG: resolveWorkingPath(TSCONFIG_JSON),
1804
+ GIT_IGNORE: resolveWorkingPath(GIT_IGNORE),
1805
+ GIT_HOOK: resolveWorkingPath(GIT_HOOK),
1806
+ GIT_COMMIT_MSG: resolveWorkingPath(GIT_COMMIT_EDITMSG),
1807
+ SIMPLE_GIT_HOOKS: resolveWorkingPath(SIMPLE_GIT_HOOK_JSON),
1808
+ PACKAGE_JSON: resolveWorkingPath(PACKAGE_JSON),
1809
+ PACKAGE_LOCK_JSON: resolveWorkingPath(PACKAGE_LOCK_JSON),
1810
+ PNPM_LOCK_YAML: resolveWorkingPath(PNPM_LOCK_YAML),
1811
+ NODE_MODULES: resolveWorkingPath(NODE_MODULES),
1812
+ CYBERSKILL: {
1813
+ LINT_STAGED_CONFIG: resolveCyberSkillPath("./configs/lint-staged/base.js"),
1814
+ COMMITLINT_CONFIG: resolveCyberSkillPath("./configs/commitlint/base.js"),
1815
+ UNIT_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/unit.js"),
1816
+ E2E_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/e2e.js")
1817
+ }
1818
+ };
1819
+ function HOOK(param) {
1820
+ var isCurrentProject = param.isCurrentProject;
1821
+ return _object_spread({
1822
+ "postinstall": "setup",
1823
+ "pre-commit": LINT_STAGED_CLI,
1824
+ "commit-msg": COMMIT_LINT_CLI
1825
+ }, isCurrentProject && {
1826
+ "pre-push": commandFormatter.raw("".concat(GIT_CLI, " pull"))
1827
+ });
1828
+ }
1829
+ var COMMAND = {
1830
+ SIMPLE_GIT_HOOKS: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(SIMPLE_GIT_HOOK_CLI)),
1831
+ ESLINT_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_INSPECT_CLI)),
1832
+ NODE_MODULES_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(NODE_MODULES_INSPECT_CLI)),
1833
+ RESET: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(RIMRAF_CLI, " ").concat(NODE_MODULES, " ").concat(PNPM_LOCK_YAML)),
1834
+ ESLINT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY)),
1835
+ ESLINT_FIX: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY, " --fix")),
1836
+ TYPESCRIPT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(TSC_CLI, " -p ").concat(PATH.TS_CONFIG, " --noEmit")),
1837
+ CYBERSKILL: {
1838
+ TEST_UNIT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.UNIT_TEST_CONFIG)),
1839
+ TEST_E2E: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.E2E_TEST_CONFIG)),
1840
+ COMMIT_LINT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(COMMIT_LINT_CLI, " --edit ").concat(PATH.GIT_COMMIT_MSG, " --config ").concat(PATH.CYBERSKILL.COMMITLINT_CONFIG)),
1841
+ LINT_STAGED: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(LINT_STAGED_CLI, " --config ").concat(PATH.CYBERSKILL.LINT_STAGED_CONFIG))
1842
+ },
1843
+ CONFIGURE_GIT_HOOK: commandFormatter.raw("".concat(GIT_CLI, " config core.hooksPath ").concat(PATH.GIT_HOOK)),
1844
+ BUILD: commandFormatter.raw("".concat(PNPM_CLI, " run build")),
1845
+ STAGE_BUILD_DIRECTORY: commandFormatter.raw("".concat(GIT_CLI, " add ").concat(BUILD_DIRECTORY)),
1846
+ PNPM_INSTALL_STANDARD: commandFormatter.raw("".concat(PNPM_CLI, " install")),
1847
+ PNPM_INSTALL_LEGACY: commandFormatter.raw("".concat(PNPM_CLI, " install --legacy-peer-deps")),
1848
+ PNPM_INSTALL_FORCE: commandFormatter.raw("".concat(PNPM_CLI, " install --force"))
1849
+ };
1850
+ // src/constants/response-status.ts
1851
+ var RESPONSE_STATUS = {
1852
+ GRAPHQL_PARSE_FAILED: {
1853
+ CODE: "GRAPHQL_PARSE_FAILED",
1854
+ MESSAGE: "The GraphQL operation string contains a syntax error."
1855
+ },
1856
+ GRAPHQL_VALIDATION_FAILED: {
1857
+ CODE: "GRAPHQL_VALIDATION_FAILED",
1858
+ MESSAGE: "The GraphQL operation is not valid against the server's schema."
1859
+ },
1860
+ BAD_USER_INPUT: {
1861
+ CODE: "BAD_USER_INPUT",
1862
+ MESSAGE: "The GraphQL operation includes an invalid value for a field argument."
1863
+ },
1864
+ PERSISTED_QUERY_NOT_FOUND: {
1865
+ CODE: "PERSISTED_QUERY_NOT_FOUND",
1866
+ 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."
1867
+ },
1868
+ PERSISTED_QUERY_NOT_SUPPORTED: {
1869
+ CODE: "PERSISTED_QUERY_NOT_SUPPORTED",
1870
+ MESSAGE: "A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."
1871
+ },
1872
+ OPERATION_RESOLUTION_FAILURE: {
1873
+ CODE: "OPERATION_RESOLUTION_FAILURE",
1874
+ 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."
1875
+ },
1876
+ CONTINUE: {
1877
+ CODE: 100,
1878
+ MESSAGE: "Continue"
1879
+ },
1880
+ SWITCHING_PROTOCOLS: {
1881
+ CODE: 101,
1882
+ MESSAGE: "Switching Protocols"
1883
+ },
1884
+ PROCESSING: {
1885
+ CODE: 102,
1886
+ MESSAGE: "Processing"
1887
+ },
1888
+ OK: {
1889
+ CODE: 200,
1890
+ MESSAGE: "OK"
1891
+ },
1892
+ CREATED: {
1893
+ CODE: 201,
1894
+ MESSAGE: "Created"
1895
+ },
1896
+ ACCEPTED: {
1897
+ CODE: 202,
1898
+ MESSAGE: "Accepted"
1899
+ },
1900
+ NON_AUTHORITATIVE_INFORMATION: {
1901
+ CODE: 203,
1902
+ MESSAGE: "Non Authoritative Information"
1903
+ },
1904
+ NO_CONTENT: {
1905
+ CODE: 204,
1906
+ MESSAGE: "No Content"
1907
+ },
1908
+ RESET_CONTENT: {
1909
+ CODE: 205,
1910
+ MESSAGE: "Reset Content"
1911
+ },
1912
+ PARTIAL_CONTENT: {
1913
+ CODE: 206,
1914
+ MESSAGE: "Partial Content"
1915
+ },
1916
+ MULTI_STATUS: {
1917
+ CODE: 207,
1918
+ MESSAGE: "Multi-Status"
1919
+ },
1920
+ MULTIPLE_CHOICES: {
1921
+ CODE: 300,
1922
+ MESSAGE: "Multiple Choices"
1923
+ },
1924
+ MOVED_PERMANENTLY: {
1925
+ CODE: 301,
1926
+ MESSAGE: "Moved Permanently"
1927
+ },
1928
+ MOVED_TEMPORARILY: {
1929
+ CODE: 302,
1930
+ MESSAGE: "Moved Temporarily"
1931
+ },
1932
+ SEE_OTHER: {
1933
+ CODE: 303,
1934
+ MESSAGE: "See Other"
1935
+ },
1936
+ NOT_MODIFIED: {
1937
+ CODE: 304,
1938
+ MESSAGE: "Not Modified"
1939
+ },
1940
+ USE_PROXY: {
1941
+ CODE: 305,
1942
+ MESSAGE: "Use Proxy"
1943
+ },
1944
+ TEMPORARY_REDIRECT: {
1945
+ CODE: 307,
1946
+ MESSAGE: "Temporary Redirect"
1947
+ },
1948
+ PERMANENT_REDIRECT: {
1949
+ CODE: 308,
1950
+ MESSAGE: "Permanent Redirect"
1951
+ },
1952
+ BAD_REQUEST: {
1953
+ CODE: 400,
1954
+ MESSAGE: "Bad Request"
1955
+ },
1956
+ UNAUTHORIZED: {
1957
+ CODE: 401,
1958
+ MESSAGE: "Unauthorized"
1959
+ },
1960
+ PAYMENT_REQUIRED: {
1961
+ CODE: 402,
1962
+ MESSAGE: "Payment Required"
1963
+ },
1964
+ FORBIDDEN: {
1965
+ CODE: 403,
1966
+ MESSAGE: "Forbidden"
1967
+ },
1968
+ NOT_FOUND: {
1969
+ CODE: 404,
1970
+ MESSAGE: "Not Found"
1971
+ },
1972
+ METHOD_NOT_ALLOWED: {
1973
+ CODE: 405,
1974
+ MESSAGE: "Method Not Allowed"
1975
+ },
1976
+ NOT_ACCEPTABLE: {
1977
+ CODE: 406,
1978
+ MESSAGE: "Not Acceptable"
1979
+ },
1980
+ PROXY_AUTHENTICATION_REQUIRED: {
1981
+ CODE: 407,
1982
+ MESSAGE: "Proxy Authentication Required"
1983
+ },
1984
+ REQUEST_TIMEOUT: {
1985
+ CODE: 408,
1986
+ MESSAGE: "Request Timeout"
1987
+ },
1988
+ CONFLICT: {
1989
+ CODE: 409,
1990
+ MESSAGE: "Conflict"
1991
+ },
1992
+ GONE: {
1993
+ CODE: 410,
1994
+ MESSAGE: "Gone"
1995
+ },
1996
+ LENGTH_REQUIRED: {
1997
+ CODE: 411,
1998
+ MESSAGE: "Length Required"
1999
+ },
2000
+ PRECONDITION_FAILED: {
2001
+ CODE: 412,
2002
+ MESSAGE: "Precondition Failed"
2003
+ },
2004
+ REQUEST_TOO_LONG: {
2005
+ CODE: 413,
2006
+ MESSAGE: "Request Entity Too Large"
2007
+ },
2008
+ REQUEST_URI_TOO_LONG: {
2009
+ CODE: 414,
2010
+ MESSAGE: "Request-URI Too Long"
2011
+ },
2012
+ UNSUPPORTED_MEDIA_TYPE: {
2013
+ CODE: 415,
2014
+ MESSAGE: "Unsupported Media Type"
2015
+ },
2016
+ REQUESTED_RANGE_NOT_SATISFIABLE: {
2017
+ CODE: 416,
2018
+ MESSAGE: "Requested Range Not Satisfiable"
2019
+ },
2020
+ EXPECTATION_FAILED: {
2021
+ CODE: 417,
2022
+ MESSAGE: "Expectation Failed"
2023
+ },
2024
+ IM_A_TEAPOT: {
2025
+ CODE: 418,
2026
+ MESSAGE: "I'm a teapot"
2027
+ },
2028
+ INSUFFICIENT_SPACE_ON_RESOURCE: {
2029
+ CODE: 419,
2030
+ MESSAGE: "Insufficient Space on Resource"
2031
+ },
2032
+ METHOD_FAILURE: {
2033
+ CODE: 420,
2034
+ MESSAGE: "Method Failure"
2035
+ },
2036
+ MISDIRECTED_REQUEST: {
2037
+ CODE: 421,
2038
+ MESSAGE: "Misdirected Request"
2039
+ },
2040
+ UNPROCESSABLE_ENTITY: {
2041
+ CODE: 422,
2042
+ MESSAGE: "Unprocessable Entity"
2043
+ },
2044
+ LOCKED: {
2045
+ CODE: 423,
2046
+ MESSAGE: "Locked"
2047
+ },
2048
+ FAILED_DEPENDENCY: {
2049
+ CODE: 424,
2050
+ MESSAGE: "Failed Dependency"
2051
+ },
2052
+ PRECONDITION_REQUIRED: {
2053
+ CODE: 428,
2054
+ MESSAGE: "Precondition Required"
2055
+ },
2056
+ TOO_MANY_REQUESTS: {
2057
+ CODE: 429,
2058
+ MESSAGE: "Too Many Requests"
2059
+ },
2060
+ REQUEST_HEADER_FIELDS_TOO_LARGE: {
2061
+ CODE: 431,
2062
+ MESSAGE: "Request Header Fields Too Large"
2063
+ },
2064
+ UNAVAILABLE_FOR_LEGAL_REASONS: {
2065
+ CODE: 451,
2066
+ MESSAGE: "Unavailable For Legal Reasons"
2067
+ },
2068
+ INTERNAL_SERVER_ERROR: {
2069
+ CODE: 500,
2070
+ MESSAGE: "Internal Server Error"
2071
+ },
2072
+ NOT_IMPLEMENTED: {
2073
+ CODE: 501,
2074
+ MESSAGE: "Not Implemented"
2075
+ },
2076
+ BAD_GATEWAY: {
2077
+ CODE: 502,
2078
+ MESSAGE: "Bad Gateway"
2079
+ },
2080
+ SERVICE_UNAVAILABLE: {
2081
+ CODE: 503,
2082
+ MESSAGE: "Service Unavailable"
2083
+ },
2084
+ GATEWAY_TIMEOUT: {
2085
+ CODE: 504,
2086
+ MESSAGE: "Gateway Timeout"
2087
+ },
2088
+ HTTP_VERSION_NOT_SUPPORTED: {
2089
+ CODE: 505,
2090
+ MESSAGE: "HTTP Version Not Supported"
2091
+ },
2092
+ INSUFFICIENT_STORAGE: {
2093
+ CODE: 507,
2094
+ MESSAGE: "Insufficient Storage"
2095
+ },
2096
+ NETWORK_AUTHENTICATION_REQUIRED: {
2097
+ CODE: 511,
2098
+ MESSAGE: "Network Authentication Required"
2099
+ }
2100
+ };
2101
+ // src/nodejs/mongo.ts
2102
+ var import_date_fns = require("date-fns");
2103
+ var import_mongoose = require("mongoose");
2104
+ var import_mongoose_aggregate_paginate_v2 = __toESM(require("mongoose-aggregate-paginate-v2"), 1);
2105
+ var import_mongoose_paginate_v2 = __toESM(require("mongoose-paginate-v2"), 1);
2106
+ var import_uuid = require("uuid");
2107
+ // src/utils/string.ts
2108
+ var import_crypto_js = __toESM(require("crypto-js"), 1);
2109
+ var import_slugify = __toESM(require("slugify"), 1);
2110
+ var slugify = import_slugify.default.default || import_slugify.default;
2111
+ function generateSlug() {
2112
+ var str = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", options = arguments.length > 1 ? arguments[1] : void 0;
2113
+ var _ref = options || {}, _ref_lower = _ref.lower, lower = _ref_lower === void 0 ? true : _ref_lower, _ref_locale = _ref.locale, locale = _ref_locale === void 0 ? "vi" : _ref_locale, rest = _object_without_properties(_ref, [
2114
+ "lower",
2115
+ "locale"
2116
+ ]);
2117
+ return slugify(str, _object_spread({
2118
+ lower: lower,
2119
+ locale: locale
2120
+ }, rest));
2121
+ }
2122
+ function generateShortId(uuid) {
2123
+ var length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
2124
+ return import_crypto_js.default.SHA256(uuid).toString(import_crypto_js.default.enc.Hex).slice(0, length);
2125
+ }
2126
+ // src/utils/validate.ts
2127
+ var validate = {
2128
+ isEmpty: function isEmpty(value) {
2129
+ if (value === null || value === void 0) {
2130
+ return true;
2131
+ }
2132
+ if (Array.isArray(value)) {
2133
+ return value.length === 0;
2134
+ }
2135
+ if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
2136
+ if (_instanceof(value, Date)) {
2137
+ return false;
2138
+ }
2139
+ return Object.keys(value).length === 0;
2140
+ }
2141
+ if (typeof value === "string") {
2142
+ return value.trim().length === 0;
2143
+ }
2144
+ return false;
2145
+ }
2146
+ };
2147
+ // src/nodejs/mongo.ts
2148
+ var mongo = {
2149
+ getDateTime: function getDateTime() {
2150
+ var now = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : /* @__PURE__ */ new Date();
2151
+ return (0, import_date_fns.format)(now, "yyyy-MM-dd HH:mm:ss.SSS");
2152
+ },
2153
+ createGenericFields: function createGenericFields() {
2154
+ var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref_returnDateAs = _ref.returnDateAs, returnDateAs = _ref_returnDateAs === void 0 ? "string" : _ref_returnDateAs;
2155
+ var now = returnDateAs === "string" ? mongo.getDateTime() : /* @__PURE__ */ new Date();
2156
+ return {
2157
+ id: (0, import_uuid.v4)(),
2158
+ isDel: false,
2159
+ createdAt: now,
2160
+ updatedAt: now
2161
+ };
2162
+ },
2163
+ applyPlugins: function applyPlugins(schema, plugins) {
2164
+ plugins.filter(function(plugin) {
2165
+ return typeof plugin === "function";
2166
+ }).forEach(function(plugin) {
2167
+ return schema.plugin(plugin);
2168
+ });
2169
+ },
2170
+ applyMiddlewares: function applyMiddlewares(schema, middlewares) {
2171
+ middlewares.forEach(function(param) {
2172
+ var method = param.method, pre = param.pre, post = param.post;
2173
+ if (method && pre) {
2174
+ schema.pre(method, pre);
2175
+ }
2176
+ if (method && post) {
2177
+ schema.post(method, post);
2178
+ }
2179
+ });
2180
+ },
2181
+ createGenericSchema: function createGenericSchema(mongoose) {
2182
+ return new mongoose.Schema({
2183
+ id: {
2184
+ type: String,
2185
+ default: import_uuid.v4,
2186
+ required: true,
2187
+ unique: true
2188
+ },
2189
+ isDel: {
2190
+ type: Boolean,
2191
+ default: false,
2192
+ required: true
2193
+ }
2194
+ }, {
2195
+ timestamps: true
2196
+ });
2197
+ },
2198
+ createSchema: function createSchema(param) {
2199
+ var mongoose = param.mongoose, schema = param.schema, _param_virtuals = param.virtuals, virtuals = _param_virtuals === void 0 ? [] : _param_virtuals, _param_standalone = param.standalone, standalone = _param_standalone === void 0 ? false : _param_standalone;
2200
+ var createdSchema = new mongoose.Schema(schema, {
2201
+ strict: true
2202
+ });
2203
+ virtuals.forEach(function(param) {
2204
+ var name = param.name, options = param.options, get = param.get;
2205
+ var virtualInstance = createdSchema.virtual(name, options);
2206
+ if (get) virtualInstance.get(get);
2207
+ });
2208
+ if (!standalone) {
2209
+ createdSchema.add(mongo.createGenericSchema(mongoose));
2210
+ }
2211
+ return createdSchema;
2212
+ },
2213
+ createModel: function createModel(param) {
2214
+ var currentMongooseInstance = param.mongoose, name = param.name, schema = param.schema, _param_pagination = param.pagination, pagination = _param_pagination === void 0 ? false : _param_pagination, _param_aggregate = param.aggregate, aggregate = _param_aggregate === void 0 ? false : _param_aggregate, _param_virtuals = param.virtuals, virtuals = _param_virtuals === void 0 ? [] : _param_virtuals, _param_middlewares = param.middlewares, middlewares = _param_middlewares === void 0 ? [] : _param_middlewares;
2215
+ if (!name) {
2216
+ throw new Error("Model name is required.");
2217
+ }
2218
+ if (currentMongooseInstance.models[name]) {
2219
+ return currentMongooseInstance.models[name];
2220
+ }
2221
+ var createdSchema = mongo.createSchema({
2222
+ mongoose: currentMongooseInstance,
2223
+ schema: schema,
2224
+ virtuals: virtuals
2225
+ });
2226
+ mongo.applyPlugins(createdSchema, [
2227
+ pagination && import_mongoose_paginate_v2.default,
2228
+ aggregate && import_mongoose_aggregate_paginate_v2.default
2229
+ ]);
2230
+ mongo.applyMiddlewares(createdSchema, middlewares);
2231
+ return currentMongooseInstance.model(name, createdSchema);
2232
+ },
2233
+ createSlugQuery: function createSlugQuery(slug) {
2234
+ var filters = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, id = arguments.length > 2 ? arguments[2] : void 0;
2235
+ return _object_spread_props(_object_spread({}, filters, id && {
2236
+ id: {
2237
+ $ne: id
2238
+ }
2239
+ }), {
2240
+ $or: [
2241
+ {
2242
+ slug: slug
2243
+ },
2244
+ {
2245
+ slugHistory: slug
2246
+ }
2247
+ ]
2248
+ });
2249
+ },
2250
+ validator: {
2251
+ isEmpty: function isEmpty() {
2252
+ return /*#__PURE__*/ function() {
2253
+ var _ref = _async_to_generator(function(value) {
2254
+ return _ts_generator(this, function(_state) {
2255
+ return [
2256
+ 2,
2257
+ !validate.isEmpty(value)
2258
+ ];
2259
+ });
2260
+ });
2261
+ return function(value) {
2262
+ return _ref.apply(this, arguments);
2263
+ };
2264
+ }();
2265
+ },
2266
+ isUnique: function isUnique(fields) {
2267
+ return /*#__PURE__*/ function() {
2268
+ var _ref = _async_to_generator(function(value) {
2269
+ var query, existingDocument;
2270
+ return _ts_generator(this, function(_state) {
2271
+ switch(_state.label){
2272
+ case 0:
2273
+ if (!Array.isArray(fields) || fields.length === 0) {
2274
+ throw new Error("Fields must be a non-empty array of strings.");
2275
+ }
2276
+ query = {
2277
+ $or: fields.map(function(field) {
2278
+ return _define_property({}, field, value);
2279
+ })
2280
+ };
2281
+ return [
2282
+ 4,
2283
+ this.constructor.findOne(query)
2284
+ ];
2285
+ case 1:
2286
+ existingDocument = _state.sent();
2287
+ return [
2288
+ 2,
2289
+ !existingDocument
2290
+ ];
2291
+ }
2292
+ });
2293
+ });
2294
+ return function(value) {
2295
+ return _ref.apply(this, arguments);
2296
+ };
2297
+ }();
2298
+ },
2299
+ matchesRegex: function matchesRegex(regexArray) {
2300
+ return /*#__PURE__*/ function() {
2301
+ var _ref = _async_to_generator(function(value) {
2302
+ return _ts_generator(this, function(_state) {
2303
+ if (!Array.isArray(regexArray) || regexArray.some(function(r) {
2304
+ return !_instanceof(r, RegExp);
2305
+ })) {
2306
+ throw new Error("regexArray must be an array of valid RegExp objects.");
2307
+ }
2308
+ return [
2309
+ 2,
2310
+ regexArray.every(function(regex) {
2311
+ return regex.test(value);
2312
+ })
2313
+ ];
2314
+ });
2315
+ });
2316
+ return function(value) {
2317
+ return _ref.apply(this, arguments);
2318
+ };
2319
+ }();
2320
+ }
2321
+ }
2322
+ };
2323
+ var MongoController = /*#__PURE__*/ function() {
2324
+ function MongoController(db, collectionName) {
2325
+ _class_call_check(this, MongoController);
2326
+ this.collection = db.collection(collectionName);
2327
+ }
2328
+ _create_class(MongoController, [
2329
+ {
2330
+ key: "createOne",
2331
+ value: function createOne(document2) {
2332
+ var _this = this;
2333
+ return _async_to_generator(function() {
2334
+ var finalDocument, result, error;
2335
+ return _ts_generator(this, function(_state) {
2336
+ switch(_state.label){
2337
+ case 0:
2338
+ _state.trys.push([
2339
+ 0,
2340
+ 2,
2341
+ ,
2342
+ 3
2343
+ ]);
2344
+ finalDocument = _object_spread({}, mongo.createGenericFields(), document2);
2345
+ return [
2346
+ 4,
2347
+ _this.collection.insertOne(finalDocument)
2348
+ ];
2349
+ case 1:
2350
+ result = _state.sent();
2351
+ return [
2352
+ 2,
2353
+ {
2354
+ success: true,
2355
+ message: "Document created successfully",
2356
+ result: result
2357
+ }
2358
+ ];
2359
+ case 2:
2360
+ error = _state.sent();
2361
+ return [
2362
+ 2,
2363
+ {
2364
+ success: false,
2365
+ message: error.message
2366
+ }
2367
+ ];
2368
+ case 3:
2369
+ return [
2370
+ 2
2371
+ ];
2372
+ }
2373
+ });
2374
+ })();
2375
+ }
2376
+ },
2377
+ {
2378
+ key: "createMany",
2379
+ value: function createMany(documents) {
2380
+ var _this = this;
2381
+ return _async_to_generator(function() {
2382
+ var finalDocuments, result, error;
2383
+ return _ts_generator(this, function(_state) {
2384
+ switch(_state.label){
2385
+ case 0:
2386
+ _state.trys.push([
2387
+ 0,
2388
+ 2,
2389
+ ,
2390
+ 3
2391
+ ]);
2392
+ finalDocuments = documents.map(function(document2) {
2393
+ return _object_spread({}, mongo.createGenericFields(), document2);
2394
+ });
2395
+ return [
2396
+ 4,
2397
+ _this.collection.insertMany(finalDocuments)
2398
+ ];
2399
+ case 1:
2400
+ result = _state.sent();
2401
+ if (result.insertedCount === 0) {
2402
+ return [
2403
+ 2,
2404
+ {
2405
+ success: false,
2406
+ message: "No documents were inserted"
2407
+ }
2408
+ ];
2409
+ }
2410
+ return [
2411
+ 2,
2412
+ {
2413
+ success: true,
2414
+ message: "".concat(result.insertedCount, " documents created successfully"),
2415
+ result: result
2416
+ }
2417
+ ];
2418
+ case 2:
2419
+ error = _state.sent();
2420
+ return [
2421
+ 2,
2422
+ {
2423
+ success: false,
2424
+ message: error.message
2425
+ }
2426
+ ];
2427
+ case 3:
2428
+ return [
2429
+ 2
2430
+ ];
2431
+ }
2432
+ });
2433
+ })();
2434
+ }
2435
+ },
2436
+ {
2437
+ key: "findOne",
2438
+ value: function findOne(filter) {
2439
+ var _this = this;
2440
+ return _async_to_generator(function() {
2441
+ var result, error;
2442
+ return _ts_generator(this, function(_state) {
2443
+ switch(_state.label){
2444
+ case 0:
2445
+ _state.trys.push([
2446
+ 0,
2447
+ 2,
2448
+ ,
2449
+ 3
2450
+ ]);
2451
+ return [
2452
+ 4,
2453
+ _this.collection.findOne(filter)
2454
+ ];
2455
+ case 1:
2456
+ result = _state.sent();
2457
+ if (!result) {
2458
+ return [
2459
+ 2,
2460
+ {
2461
+ success: false,
2462
+ message: "Document not found"
2463
+ }
2464
+ ];
2465
+ }
2466
+ return [
2467
+ 2,
2468
+ {
2469
+ success: true,
2470
+ message: "Document found",
2471
+ result: result
2472
+ }
2473
+ ];
2474
+ case 2:
2475
+ error = _state.sent();
2476
+ return [
2477
+ 2,
2478
+ {
2479
+ success: false,
2480
+ message: error.message
2481
+ }
2482
+ ];
2483
+ case 3:
2484
+ return [
2485
+ 2
2486
+ ];
2487
+ }
2488
+ });
2489
+ })();
2490
+ }
2491
+ },
2492
+ {
2493
+ key: "findAll",
2494
+ value: function findAll() {
2495
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2496
+ var _this = this;
2497
+ return _async_to_generator(function() {
2498
+ var result, error;
2499
+ return _ts_generator(this, function(_state) {
2500
+ switch(_state.label){
2501
+ case 0:
2502
+ _state.trys.push([
2503
+ 0,
2504
+ 2,
2505
+ ,
2506
+ 3
2507
+ ]);
2508
+ return [
2509
+ 4,
2510
+ _this.collection.find(filter).toArray()
2511
+ ];
2512
+ case 1:
2513
+ result = _state.sent();
2514
+ return [
2515
+ 2,
2516
+ {
2517
+ success: true,
2518
+ message: "Documents retrieved successfully",
2519
+ result: result
2520
+ }
2521
+ ];
2522
+ case 2:
2523
+ error = _state.sent();
2524
+ return [
2525
+ 2,
2526
+ {
2527
+ success: false,
2528
+ message: error.message
2529
+ }
2530
+ ];
2531
+ case 3:
2532
+ return [
2533
+ 2
2534
+ ];
2535
+ }
2536
+ });
2537
+ })();
2538
+ }
2539
+ },
2540
+ {
2541
+ key: "count",
2542
+ value: function count() {
2543
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2544
+ var _this = this;
2545
+ return _async_to_generator(function() {
2546
+ var result, error;
2547
+ return _ts_generator(this, function(_state) {
2548
+ switch(_state.label){
2549
+ case 0:
2550
+ _state.trys.push([
2551
+ 0,
2552
+ 2,
2553
+ ,
2554
+ 3
2555
+ ]);
2556
+ return [
2557
+ 4,
2558
+ _this.collection.countDocuments(filter)
2559
+ ];
2560
+ case 1:
2561
+ result = _state.sent();
2562
+ return [
2563
+ 2,
2564
+ {
2565
+ success: true,
2566
+ message: "Count retrieved successfully",
2567
+ result: result
2568
+ }
2569
+ ];
2570
+ case 2:
2571
+ error = _state.sent();
2572
+ return [
2573
+ 2,
2574
+ {
2575
+ success: false,
2576
+ message: error.message
2577
+ }
2578
+ ];
2579
+ case 3:
2580
+ return [
2581
+ 2
2582
+ ];
2583
+ }
2584
+ });
2585
+ })();
2586
+ }
2587
+ },
2588
+ {
2589
+ key: "updateOne",
2590
+ value: function updateOne(filter, update) {
2591
+ var _this = this;
2592
+ return _async_to_generator(function() {
2593
+ var result, error;
2594
+ return _ts_generator(this, function(_state) {
2595
+ switch(_state.label){
2596
+ case 0:
2597
+ _state.trys.push([
2598
+ 0,
2599
+ 2,
2600
+ ,
2601
+ 3
2602
+ ]);
2603
+ return [
2604
+ 4,
2605
+ _this.collection.updateOne(filter, {
2606
+ $set: update
2607
+ })
2608
+ ];
2609
+ case 1:
2610
+ result = _state.sent();
2611
+ if (result.matchedCount === 0) {
2612
+ return [
2613
+ 2,
2614
+ {
2615
+ success: false,
2616
+ message: "No documents matched the filter"
2617
+ }
2618
+ ];
2619
+ }
2620
+ return [
2621
+ 2,
2622
+ {
2623
+ success: true,
2624
+ message: "Document updated successfully",
2625
+ result: result
2626
+ }
2627
+ ];
2628
+ case 2:
2629
+ error = _state.sent();
2630
+ return [
2631
+ 2,
2632
+ {
2633
+ success: false,
2634
+ message: error.message
2635
+ }
2636
+ ];
2637
+ case 3:
2638
+ return [
2639
+ 2
2640
+ ];
2641
+ }
2642
+ });
2643
+ })();
2644
+ }
2645
+ },
2646
+ {
2647
+ key: "updateMany",
2648
+ value: function updateMany(filter, update) {
2649
+ var _this = this;
2650
+ return _async_to_generator(function() {
2651
+ var result, error;
2652
+ return _ts_generator(this, function(_state) {
2653
+ switch(_state.label){
2654
+ case 0:
2655
+ _state.trys.push([
2656
+ 0,
2657
+ 2,
2658
+ ,
2659
+ 3
2660
+ ]);
2661
+ return [
2662
+ 4,
2663
+ _this.collection.updateMany(filter, {
2664
+ $set: update
2665
+ })
2666
+ ];
2667
+ case 1:
2668
+ result = _state.sent();
2669
+ if (result.matchedCount === 0) {
2670
+ return [
2671
+ 2,
2672
+ {
2673
+ success: false,
2674
+ message: "No documents matched the filter"
2675
+ }
2676
+ ];
2677
+ }
2678
+ return [
2679
+ 2,
2680
+ {
2681
+ success: true,
2682
+ message: "Documents updated successfully",
2683
+ result: result
2684
+ }
2685
+ ];
2686
+ case 2:
2687
+ error = _state.sent();
2688
+ return [
2689
+ 2,
2690
+ {
2691
+ success: false,
2692
+ message: error.message
2693
+ }
2694
+ ];
2695
+ case 3:
2696
+ return [
2697
+ 2
2698
+ ];
2699
+ }
2700
+ });
2701
+ })();
2702
+ }
2703
+ },
2704
+ {
2705
+ key: "deleteOne",
2706
+ value: function deleteOne(filter) {
2707
+ var _this = this;
2708
+ return _async_to_generator(function() {
2709
+ var result, error;
2710
+ return _ts_generator(this, function(_state) {
2711
+ switch(_state.label){
2712
+ case 0:
2713
+ _state.trys.push([
2714
+ 0,
2715
+ 2,
2716
+ ,
2717
+ 3
2718
+ ]);
2719
+ return [
2720
+ 4,
2721
+ _this.collection.deleteOne(filter)
2722
+ ];
2723
+ case 1:
2724
+ result = _state.sent();
2725
+ if (result.deletedCount === 0) {
2726
+ return [
2727
+ 2,
2728
+ {
2729
+ success: false,
2730
+ message: "No documents matched the filter"
2731
+ }
2732
+ ];
2733
+ }
2734
+ return [
2735
+ 2,
2736
+ {
2737
+ success: true,
2738
+ message: "Document deleted successfully",
2739
+ result: result
2740
+ }
2741
+ ];
2742
+ case 2:
2743
+ error = _state.sent();
2744
+ return [
2745
+ 2,
2746
+ {
2747
+ success: false,
2748
+ message: error.message
2749
+ }
2750
+ ];
2751
+ case 3:
2752
+ return [
2753
+ 2
2754
+ ];
2755
+ }
2756
+ });
2757
+ })();
2758
+ }
2759
+ },
2760
+ {
2761
+ key: "deleteMany",
2762
+ value: function deleteMany(filter) {
2763
+ var _this = this;
2764
+ return _async_to_generator(function() {
2765
+ var result, error;
2766
+ return _ts_generator(this, function(_state) {
2767
+ switch(_state.label){
2768
+ case 0:
2769
+ _state.trys.push([
2770
+ 0,
2771
+ 2,
2772
+ ,
2773
+ 3
2774
+ ]);
2775
+ return [
2776
+ 4,
2777
+ _this.collection.deleteMany(filter)
2778
+ ];
2779
+ case 1:
2780
+ result = _state.sent();
2781
+ if (result.deletedCount === 0) {
2782
+ return [
2783
+ 2,
2784
+ {
2785
+ success: false,
2786
+ message: "No documents matched the filter"
2787
+ }
2788
+ ];
2789
+ }
2790
+ return [
2791
+ 2,
2792
+ {
2793
+ success: true,
2794
+ message: "Documents deleted successfully",
2795
+ result: result
2796
+ }
2797
+ ];
2798
+ case 2:
2799
+ error = _state.sent();
2800
+ return [
2801
+ 2,
2802
+ {
2803
+ success: false,
2804
+ message: error.message
2805
+ }
2806
+ ];
2807
+ case 3:
2808
+ return [
2809
+ 2
2810
+ ];
2811
+ }
2812
+ });
2813
+ })();
2814
+ }
2815
+ }
2816
+ ]);
2817
+ return MongoController;
2818
+ }();
2819
+ var MongooseController = /*#__PURE__*/ function() {
2820
+ function MongooseController(model) {
2821
+ _class_call_check(this, MongooseController);
2822
+ this.model = model;
2823
+ }
2824
+ _create_class(MongooseController, [
2825
+ {
2826
+ key: "getModelName",
2827
+ value: function getModelName() {
2828
+ return this.model.modelName;
2829
+ }
2830
+ },
2831
+ {
2832
+ key: "findOne",
2833
+ value: function findOne() {
2834
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, projection = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, populate = arguments.length > 3 ? arguments[3] : void 0;
2835
+ var _this = this;
2836
+ return _async_to_generator(function() {
2837
+ var query, result, error;
2838
+ return _ts_generator(this, function(_state) {
2839
+ switch(_state.label){
2840
+ case 0:
2841
+ _state.trys.push([
2842
+ 0,
2843
+ 2,
2844
+ ,
2845
+ 3
2846
+ ]);
2847
+ query = _this.model.findOne(filter, projection, options);
2848
+ if (populate) {
2849
+ query.populate(populate);
2850
+ }
2851
+ return [
2852
+ 4,
2853
+ query.exec()
2854
+ ];
2855
+ case 1:
2856
+ result = _state.sent();
2857
+ if (!result) {
2858
+ return [
2859
+ 2,
2860
+ {
2861
+ success: false,
2862
+ message: "No ".concat(_this.getModelName(), " found."),
2863
+ code: RESPONSE_STATUS.NOT_FOUND.CODE
2864
+ }
2865
+ ];
2866
+ }
2867
+ return [
2868
+ 2,
2869
+ {
2870
+ success: true,
2871
+ result: result
2872
+ }
2873
+ ];
2874
+ case 2:
2875
+ error = _state.sent();
2876
+ return [
2877
+ 2,
2878
+ {
2879
+ success: false,
2880
+ message: error.message,
2881
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
2882
+ }
2883
+ ];
2884
+ case 3:
2885
+ return [
2886
+ 2
2887
+ ];
2888
+ }
2889
+ });
2890
+ })();
2891
+ }
2892
+ },
2893
+ {
2894
+ key: "findAll",
2895
+ value: function findAll() {
2896
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, projection = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, populate = arguments.length > 3 ? arguments[3] : void 0;
2897
+ var _this = this;
2898
+ return _async_to_generator(function() {
2899
+ var query, result, error;
2900
+ return _ts_generator(this, function(_state) {
2901
+ switch(_state.label){
2902
+ case 0:
2903
+ _state.trys.push([
2904
+ 0,
2905
+ 2,
2906
+ ,
2907
+ 3
2908
+ ]);
2909
+ query = _this.model.find(filter, projection, options);
2910
+ if (populate) {
2911
+ query.populate(populate);
2912
+ }
2913
+ return [
2914
+ 4,
2915
+ query.exec()
2916
+ ];
2917
+ case 1:
2918
+ result = _state.sent();
2919
+ return [
2920
+ 2,
2921
+ {
2922
+ success: true,
2923
+ result: result
2924
+ }
2925
+ ];
2926
+ case 2:
2927
+ error = _state.sent();
2928
+ return [
2929
+ 2,
2930
+ {
2931
+ success: false,
2932
+ message: error.message,
2933
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
2934
+ }
2935
+ ];
2936
+ case 3:
2937
+ return [
2938
+ 2
2939
+ ];
2940
+ }
2941
+ });
2942
+ })();
2943
+ }
2944
+ },
2945
+ {
2946
+ key: "findPaging",
2947
+ value: function findPaging() {
2948
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2949
+ var _this = this;
2950
+ return _async_to_generator(function() {
2951
+ var result, error;
2952
+ return _ts_generator(this, function(_state) {
2953
+ switch(_state.label){
2954
+ case 0:
2955
+ _state.trys.push([
2956
+ 0,
2957
+ 2,
2958
+ ,
2959
+ 3
2960
+ ]);
2961
+ return [
2962
+ 4,
2963
+ _this.model.paginate(filter, options)
2964
+ ];
2965
+ case 1:
2966
+ result = _state.sent();
2967
+ return [
2968
+ 2,
2969
+ {
2970
+ success: true,
2971
+ result: result
2972
+ }
2973
+ ];
2974
+ case 2:
2975
+ error = _state.sent();
2976
+ return [
2977
+ 2,
2978
+ {
2979
+ success: false,
2980
+ message: error.message,
2981
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
2982
+ }
2983
+ ];
2984
+ case 3:
2985
+ return [
2986
+ 2
2987
+ ];
2988
+ }
2989
+ });
2990
+ })();
2991
+ }
2992
+ },
2993
+ {
2994
+ key: "findPagingAggregate",
2995
+ value: function findPagingAggregate(pipeline) {
2996
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2997
+ var _this = this;
2998
+ return _async_to_generator(function() {
2999
+ var result, error;
3000
+ return _ts_generator(this, function(_state) {
3001
+ switch(_state.label){
3002
+ case 0:
3003
+ _state.trys.push([
3004
+ 0,
3005
+ 2,
3006
+ ,
3007
+ 3
3008
+ ]);
3009
+ return [
3010
+ 4,
3011
+ _this.model.aggregatePaginate(_this.model.aggregate(pipeline), options)
3012
+ ];
3013
+ case 1:
3014
+ result = _state.sent();
3015
+ return [
3016
+ 2,
3017
+ {
3018
+ success: true,
3019
+ result: result
3020
+ }
3021
+ ];
3022
+ case 2:
3023
+ error = _state.sent();
3024
+ return [
3025
+ 2,
3026
+ {
3027
+ success: false,
3028
+ message: error.message,
3029
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3030
+ }
3031
+ ];
3032
+ case 3:
3033
+ return [
3034
+ 2
3035
+ ];
3036
+ }
3037
+ });
3038
+ })();
3039
+ }
3040
+ },
3041
+ {
3042
+ key: "count",
3043
+ value: function count() {
3044
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3045
+ var _this = this;
3046
+ return _async_to_generator(function() {
3047
+ var result, error;
3048
+ return _ts_generator(this, function(_state) {
3049
+ switch(_state.label){
3050
+ case 0:
3051
+ _state.trys.push([
3052
+ 0,
3053
+ 2,
3054
+ ,
3055
+ 3
3056
+ ]);
3057
+ return [
3058
+ 4,
3059
+ _this.model.countDocuments(filter)
3060
+ ];
3061
+ case 1:
3062
+ result = _state.sent();
3063
+ return [
3064
+ 2,
3065
+ {
3066
+ success: true,
3067
+ result: result
3068
+ }
3069
+ ];
3070
+ case 2:
3071
+ error = _state.sent();
3072
+ return [
3073
+ 2,
3074
+ {
3075
+ success: false,
3076
+ message: error.message,
3077
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3078
+ }
3079
+ ];
3080
+ case 3:
3081
+ return [
3082
+ 2
3083
+ ];
3084
+ }
3085
+ });
3086
+ })();
3087
+ }
3088
+ },
3089
+ {
3090
+ key: "createOne",
3091
+ value: function createOne(doc) {
3092
+ var _this = this;
3093
+ return _async_to_generator(function() {
3094
+ var result, error;
3095
+ return _ts_generator(this, function(_state) {
3096
+ switch(_state.label){
3097
+ case 0:
3098
+ _state.trys.push([
3099
+ 0,
3100
+ 2,
3101
+ ,
3102
+ 3
3103
+ ]);
3104
+ return [
3105
+ 4,
3106
+ _this.model.create(doc)
3107
+ ];
3108
+ case 1:
3109
+ result = _state.sent();
3110
+ return [
3111
+ 2,
3112
+ {
3113
+ success: true,
3114
+ result: result
3115
+ }
3116
+ ];
3117
+ case 2:
3118
+ error = _state.sent();
3119
+ return [
3120
+ 2,
3121
+ {
3122
+ success: false,
3123
+ message: error.message,
3124
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3125
+ }
3126
+ ];
3127
+ case 3:
3128
+ return [
3129
+ 2
3130
+ ];
3131
+ }
3132
+ });
3133
+ })();
3134
+ }
3135
+ },
3136
+ {
3137
+ key: "createMany",
3138
+ value: function createMany(docs) {
3139
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3140
+ var _this = this;
3141
+ return _async_to_generator(function() {
3142
+ var createdDocuments, result, error;
3143
+ return _ts_generator(this, function(_state) {
3144
+ switch(_state.label){
3145
+ case 0:
3146
+ _state.trys.push([
3147
+ 0,
3148
+ 2,
3149
+ ,
3150
+ 3
3151
+ ]);
3152
+ return [
3153
+ 4,
3154
+ _this.model.insertMany(docs, options)
3155
+ ];
3156
+ case 1:
3157
+ createdDocuments = _state.sent();
3158
+ result = createdDocuments.map(function(doc) {
3159
+ if (_instanceof(doc, import_mongoose.Document)) {
3160
+ return doc.toObject();
3161
+ }
3162
+ return null;
3163
+ }).filter(function(doc) {
3164
+ return doc !== null;
3165
+ });
3166
+ return [
3167
+ 2,
3168
+ {
3169
+ success: true,
3170
+ result: result
3171
+ }
3172
+ ];
3173
+ case 2:
3174
+ error = _state.sent();
3175
+ return [
3176
+ 2,
3177
+ {
3178
+ success: false,
3179
+ message: error.message,
3180
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3181
+ }
3182
+ ];
3183
+ case 3:
3184
+ return [
3185
+ 2
3186
+ ];
3187
+ }
3188
+ });
3189
+ })();
3190
+ }
3191
+ },
3192
+ {
3193
+ key: "updateOne",
3194
+ value: function updateOne() {
3195
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, update = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3196
+ var _this = this;
3197
+ return _async_to_generator(function() {
3198
+ var result, error;
3199
+ return _ts_generator(this, function(_state) {
3200
+ switch(_state.label){
3201
+ case 0:
3202
+ _state.trys.push([
3203
+ 0,
3204
+ 2,
3205
+ ,
3206
+ 3
3207
+ ]);
3208
+ return [
3209
+ 4,
3210
+ _this.model.findOneAndUpdate(filter, update, _object_spread({
3211
+ new: true
3212
+ }, options)).exec()
3213
+ ];
3214
+ case 1:
3215
+ result = _state.sent();
3216
+ if (!result) {
3217
+ return [
3218
+ 2,
3219
+ {
3220
+ success: false,
3221
+ message: "Failed to update ".concat(_this.getModelName(), "."),
3222
+ code: RESPONSE_STATUS.NOT_FOUND.CODE
3223
+ }
3224
+ ];
3225
+ }
3226
+ return [
3227
+ 2,
3228
+ {
3229
+ success: true,
3230
+ result: result
3231
+ }
3232
+ ];
3233
+ case 2:
3234
+ error = _state.sent();
3235
+ return [
3236
+ 2,
3237
+ {
3238
+ success: false,
3239
+ message: error.message,
3240
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3241
+ }
3242
+ ];
3243
+ case 3:
3244
+ return [
3245
+ 2
3246
+ ];
3247
+ }
3248
+ });
3249
+ })();
3250
+ }
3251
+ },
3252
+ {
3253
+ key: "updateMany",
3254
+ value: function updateMany() {
3255
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, update = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3256
+ var _this = this;
3257
+ return _async_to_generator(function() {
3258
+ var result, error;
3259
+ return _ts_generator(this, function(_state) {
3260
+ switch(_state.label){
3261
+ case 0:
3262
+ _state.trys.push([
3263
+ 0,
3264
+ 2,
3265
+ ,
3266
+ 3
3267
+ ]);
3268
+ return [
3269
+ 4,
3270
+ _this.model.updateMany(filter, update, options).exec()
3271
+ ];
3272
+ case 1:
3273
+ result = _state.sent();
3274
+ return [
3275
+ 2,
3276
+ {
3277
+ success: true,
3278
+ result: result
3279
+ }
3280
+ ];
3281
+ case 2:
3282
+ error = _state.sent();
3283
+ return [
3284
+ 2,
3285
+ {
3286
+ success: false,
3287
+ message: error.message,
3288
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3289
+ }
3290
+ ];
3291
+ case 3:
3292
+ return [
3293
+ 2
3294
+ ];
3295
+ }
3296
+ });
3297
+ })();
3298
+ }
3299
+ },
3300
+ {
3301
+ key: "deleteOne",
3302
+ value: function deleteOne() {
3303
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3304
+ var _this = this;
3305
+ return _async_to_generator(function() {
3306
+ var result, error;
3307
+ return _ts_generator(this, function(_state) {
3308
+ switch(_state.label){
3309
+ case 0:
3310
+ _state.trys.push([
3311
+ 0,
3312
+ 2,
3313
+ ,
3314
+ 3
3315
+ ]);
3316
+ return [
3317
+ 4,
3318
+ _this.model.findOneAndDelete(filter, options).exec()
3319
+ ];
3320
+ case 1:
3321
+ result = _state.sent();
3322
+ if (!result) {
3323
+ return [
3324
+ 2,
3325
+ {
3326
+ success: false,
3327
+ message: "No ".concat(_this.getModelName(), " found to delete."),
3328
+ code: RESPONSE_STATUS.NOT_FOUND.CODE
3329
+ }
3330
+ ];
3331
+ }
3332
+ return [
3333
+ 2,
3334
+ {
3335
+ success: true,
3336
+ result: result
3337
+ }
3338
+ ];
3339
+ case 2:
3340
+ error = _state.sent();
3341
+ return [
3342
+ 2,
3343
+ {
3344
+ success: false,
3345
+ message: error.message,
3346
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3347
+ }
3348
+ ];
3349
+ case 3:
3350
+ return [
3351
+ 2
3352
+ ];
3353
+ }
3354
+ });
3355
+ })();
3356
+ }
3357
+ },
3358
+ {
3359
+ key: "deleteMany",
3360
+ value: function deleteMany() {
3361
+ var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3362
+ var _this = this;
3363
+ return _async_to_generator(function() {
3364
+ var result, error;
3365
+ return _ts_generator(this, function(_state) {
3366
+ switch(_state.label){
3367
+ case 0:
3368
+ _state.trys.push([
3369
+ 0,
3370
+ 2,
3371
+ ,
3372
+ 3
3373
+ ]);
3374
+ return [
3375
+ 4,
3376
+ _this.model.deleteMany(filter, options).exec()
3377
+ ];
3378
+ case 1:
3379
+ result = _state.sent();
3380
+ if (result.deletedCount === 0) {
3381
+ return [
3382
+ 2,
3383
+ {
3384
+ success: false,
3385
+ message: "No documents found to delete.",
3386
+ code: RESPONSE_STATUS.NOT_FOUND.CODE
3387
+ }
3388
+ ];
3389
+ }
3390
+ return [
3391
+ 2,
3392
+ {
3393
+ success: true,
3394
+ result: result
3395
+ }
3396
+ ];
3397
+ case 2:
3398
+ error = _state.sent();
3399
+ return [
3400
+ 2,
3401
+ {
3402
+ success: false,
3403
+ message: error.message,
3404
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3405
+ }
3406
+ ];
3407
+ case 3:
3408
+ return [
3409
+ 2
3410
+ ];
3411
+ }
3412
+ });
3413
+ })();
3414
+ }
3415
+ },
3416
+ {
3417
+ key: "createShortId",
3418
+ value: function createShortId(id) {
3419
+ var length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
3420
+ var _this = this;
3421
+ return _async_to_generator(function() {
3422
+ var maxRetries, existingShortIds, retries, shortId, shortIdExists;
3423
+ return _ts_generator(this, function(_state) {
3424
+ switch(_state.label){
3425
+ case 0:
3426
+ maxRetries = 10;
3427
+ existingShortIds = /* @__PURE__ */ new Set();
3428
+ retries = 0;
3429
+ _state.label = 1;
3430
+ case 1:
3431
+ if (!(retries < maxRetries)) return [
3432
+ 3,
3433
+ 4
3434
+ ];
3435
+ shortId = generateShortId(id, retries + length);
3436
+ if (!!existingShortIds.has(shortId)) return [
3437
+ 3,
3438
+ 3
3439
+ ];
3440
+ existingShortIds.add(shortId);
3441
+ return [
3442
+ 4,
3443
+ _this.model.exists({
3444
+ shortId: shortId
3445
+ })
3446
+ ];
3447
+ case 2:
3448
+ shortIdExists = _state.sent();
3449
+ if (!shortIdExists) {
3450
+ return [
3451
+ 2,
3452
+ {
3453
+ success: true,
3454
+ result: shortId
3455
+ }
3456
+ ];
3457
+ }
3458
+ _state.label = 3;
3459
+ case 3:
3460
+ retries++;
3461
+ return [
3462
+ 3,
3463
+ 1
3464
+ ];
3465
+ case 4:
3466
+ return [
3467
+ 2,
3468
+ {
3469
+ success: false,
3470
+ message: "Failed to create a unique shortId",
3471
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3472
+ }
3473
+ ];
3474
+ }
3475
+ });
3476
+ })();
3477
+ }
3478
+ },
3479
+ {
3480
+ key: "createSlug",
3481
+ value: function createSlug(fieldName, fields) {
3482
+ var filters = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3483
+ var _this = this;
3484
+ return _async_to_generator(function() {
3485
+ var fieldValue, createUniqueSlug, slugResults, _tmp, _tmp1, _i, lang, slug, slug1, uniqueSlug, error;
3486
+ return _ts_generator(this, function(_state) {
3487
+ switch(_state.label){
3488
+ case 0:
3489
+ _state.trys.push([
3490
+ 0,
3491
+ 8,
3492
+ ,
3493
+ 9
3494
+ ]);
3495
+ fieldValue = fields[fieldName];
3496
+ createUniqueSlug = /*#__PURE__*/ function() {
3497
+ var _ref = _async_to_generator(function(slug) {
3498
+ var existingDoc, suffix, uniqueSlug;
3499
+ return _ts_generator(this, function(_state) {
3500
+ switch(_state.label){
3501
+ case 0:
3502
+ return [
3503
+ 4,
3504
+ _this.model.findOne(mongo.createSlugQuery(slug, filters, fields.id))
3505
+ ];
3506
+ case 1:
3507
+ existingDoc = _state.sent();
3508
+ if (!existingDoc) return [
3509
+ 2,
3510
+ slug
3511
+ ];
3512
+ suffix = 1;
3513
+ _state.label = 2;
3514
+ case 2:
3515
+ uniqueSlug = "".concat(slug, "-").concat(suffix);
3516
+ return [
3517
+ 4,
3518
+ _this.model.findOne(mongo.createSlugQuery(uniqueSlug, filters, fields.id))
3519
+ ];
3520
+ case 3:
3521
+ existingDoc = _state.sent();
3522
+ suffix++;
3523
+ _state.label = 4;
3524
+ case 4:
3525
+ if (existingDoc) return [
3526
+ 3,
3527
+ 2
3528
+ ];
3529
+ _state.label = 5;
3530
+ case 5:
3531
+ return [
3532
+ 2,
3533
+ uniqueSlug
3534
+ ];
3535
+ }
3536
+ });
3537
+ });
3538
+ return function createUniqueSlug(slug) {
3539
+ return _ref.apply(this, arguments);
3540
+ };
3541
+ }();
3542
+ if (!((typeof fieldValue === "undefined" ? "undefined" : _type_of(fieldValue)) === "object")) return [
3543
+ 3,
3544
+ 5
3545
+ ];
3546
+ slugResults = {};
3547
+ _tmp = [];
3548
+ for(_tmp1 in fieldValue)_tmp.push(_tmp1);
3549
+ _i = 0;
3550
+ _state.label = 1;
3551
+ case 1:
3552
+ if (!(_i < _tmp.length)) return [
3553
+ 3,
3554
+ 4
3555
+ ];
3556
+ lang = _tmp[_i];
3557
+ slug = generateSlug(fieldValue[lang]);
3558
+ return [
3559
+ 4,
3560
+ createUniqueSlug(slug)
3561
+ ];
3562
+ case 2:
3563
+ slugResults[lang] = _state.sent();
3564
+ _state.label = 3;
3565
+ case 3:
3566
+ _i++;
3567
+ return [
3568
+ 3,
3569
+ 1
3570
+ ];
3571
+ case 4:
3572
+ return [
3573
+ 2,
3574
+ {
3575
+ success: true,
3576
+ result: slugResults
3577
+ }
3578
+ ];
3579
+ case 5:
3580
+ slug1 = generateSlug(fieldValue);
3581
+ return [
3582
+ 4,
3583
+ createUniqueSlug(slug1)
3584
+ ];
3585
+ case 6:
3586
+ uniqueSlug = _state.sent();
3587
+ return [
3588
+ 2,
3589
+ {
3590
+ success: true,
3591
+ result: uniqueSlug
3592
+ }
3593
+ ];
3594
+ case 7:
3595
+ return [
3596
+ 3,
3597
+ 9
3598
+ ];
3599
+ case 8:
3600
+ error = _state.sent();
3601
+ return [
3602
+ 2,
3603
+ {
3604
+ success: false,
3605
+ message: "Failed to create a unique slug: ".concat(error.message),
3606
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3607
+ }
3608
+ ];
3609
+ case 9:
3610
+ return [
3611
+ 2
3612
+ ];
3613
+ }
3614
+ });
3615
+ })();
3616
+ }
3617
+ },
3618
+ {
3619
+ key: "aggregate",
3620
+ value: function aggregate(pipeline) {
3621
+ var _this = this;
3622
+ return _async_to_generator(function() {
3623
+ var result, error;
3624
+ return _ts_generator(this, function(_state) {
3625
+ switch(_state.label){
3626
+ case 0:
3627
+ _state.trys.push([
3628
+ 0,
3629
+ 2,
3630
+ ,
3631
+ 3
3632
+ ]);
3633
+ return [
3634
+ 4,
3635
+ _this.model.aggregate(pipeline)
3636
+ ];
3637
+ case 1:
3638
+ result = _state.sent();
3639
+ return [
3640
+ 2,
3641
+ {
3642
+ success: true,
3643
+ result: result
3644
+ }
3645
+ ];
3646
+ case 2:
3647
+ error = _state.sent();
3648
+ return [
3649
+ 2,
3650
+ {
3651
+ success: false,
3652
+ message: error.message,
3653
+ code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE
3654
+ }
3655
+ ];
3656
+ case 3:
3657
+ return [
3658
+ 2
3659
+ ];
3660
+ }
3661
+ });
3662
+ })();
3663
+ }
3664
+ }
3665
+ ]);
3666
+ return MongooseController;
3667
+ }();
3668
+ // src/react/apollo-client.tsx
3669
+ var import_client = require("@apollo/client");
3670
+ var import_error = require("@apollo/client/link/error");
3671
+ var import_subscriptions = require("@apollo/client/link/subscriptions");
3672
+ var import_utilities = require("@apollo/client/utilities");
3673
+ var import_graphql_ws = require("graphql-ws");
3674
+ var import_jsx_runtime = require("react/jsx-runtime");
3675
+ function createLinks(options) {
3676
+ var errorLink = (0, import_error.onError)(function(param) {
3677
+ var graphQLErrors = param.graphQLErrors, networkError = param.networkError;
3678
+ graphQLErrors === null || graphQLErrors === void 0 ? void 0 : graphQLErrors.forEach(function(param) {
3679
+ var message = param.message, locations = param.locations, path3 = param.path;
3680
+ return console.error("[GraphQL error]: Message: ".concat(message, ", Location: ").concat(locations, ", Path: ").concat(path3));
3681
+ });
3682
+ if (networkError) {
3683
+ console.error("[Network error]: ".concat(networkError));
3684
+ }
3685
+ });
3686
+ var httpLink = new import_client.HttpLink({
3687
+ uri: options === null || options === void 0 ? void 0 : options.uri,
3688
+ credentials: "include"
3689
+ });
3690
+ var wsLink = (options === null || options === void 0 ? void 0 : options.wsUrl) ? new import_subscriptions.GraphQLWsLink((0, import_graphql_ws.createClient)({
3691
+ url: options.wsUrl
3692
+ })) : null;
3693
+ var splitLink = wsLink ? (0, import_client.split)(function(param) {
3694
+ var query = param.query;
3695
+ var mainDefinition = (0, import_utilities.getMainDefinition)(query);
3696
+ if (mainDefinition.kind === "OperationDefinition") {
3697
+ var operation = mainDefinition.operation;
3698
+ return operation === "subscription";
3699
+ }
3700
+ return false;
3701
+ }, wsLink, httpLink) : httpLink;
3702
+ var cleanTypeName = new import_client.ApolloLink(function(operation, forward) {
3703
+ if (operation.variables) {
3704
+ operation.variables = JSON.parse(JSON.stringify(operation.variables), function(key, value) {
3705
+ return key === "__typename" ? void 0 : value;
3706
+ });
3707
+ }
3708
+ return forward(operation);
3709
+ });
3710
+ return {
3711
+ errorLink: errorLink,
3712
+ httpLink: httpLink,
3713
+ wsLink: wsLink,
3714
+ splitLink: splitLink,
3715
+ cleanTypeName: cleanTypeName
3716
+ };
3717
+ }
3718
+ function ApolloProvider(param) {
3719
+ var isNextJS = param.isNextJS, options = param.options, children = param.children, CustomClient = param.client, CustomProvider = param.provider, CustomCache = param.cache;
3720
+ var Client = CustomClient !== null && CustomClient !== void 0 ? CustomClient : import_client.ApolloClient;
3721
+ if (typeof Client !== "function") {
3722
+ throw new TypeError("Invalid ApolloClient provided. Ensure CustomClient is a class.");
3723
+ }
3724
+ var Provider = CustomProvider || import_client.ApolloProvider;
3725
+ var Cache = CustomCache || import_client.InMemoryCache;
3726
+ var _createLinks = createLinks(options), cleanTypeName = _createLinks.cleanTypeName, errorLink = _createLinks.errorLink, splitLink = _createLinks.splitLink;
3727
+ var client = new Client(_object_spread({
3728
+ cache: _instanceof(Cache, import_client.InMemoryCache) ? Cache : new import_client.InMemoryCache(),
3729
+ link: import_client.ApolloLink.from([
3730
+ cleanTypeName,
3731
+ errorLink,
3732
+ splitLink
3733
+ ].filter(Boolean))
3734
+ }, options));
3735
+ if (isNextJS) {
3736
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Provider, {
3737
+ makeClient: function() {
3738
+ return client;
3739
+ },
3740
+ children: children
3741
+ });
3742
+ }
3743
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Provider, {
3744
+ client: client,
3745
+ children: children
3746
+ });
3747
+ }
3748
+ // src/react/loading.tsx
3749
+ var import_classnames = __toESM(require("classnames"), 1);
3750
+ var import_react = require("react");
3751
+ var import_loading_module = __toESM(require("./react/loading.module.scss"), 1);
3752
+ var import_jsx_runtime2 = require("react/jsx-runtime");
3753
+ var LoadingContext = (0, import_react.createContext)(void 0);
3754
+ function useLoading() {
3755
+ var context = (0, import_react.use)(LoadingContext);
3756
+ if (!context) {
3757
+ throw new Error("useLoading must be used within a LoadingProvider");
3758
+ }
3759
+ return context;
3760
+ }
3761
+ function Loading(_param) {
3762
+ var _param_full = _param.full, full = _param_full === void 0 ? false : _param_full, _param_block = _param.block, block = _param_block === void 0 ? false : _param_block, _param_className = _param.className, className = _param_className === void 0 ? "" : _param_className, _param_message = _param.message, message = _param_message === void 0 ? "Loading" : _param_message, rest = _object_without_properties(_param, [
3763
+ "full",
3764
+ "block",
3765
+ "className",
3766
+ "message"
3767
+ ]);
3768
+ function _renderLoading() {
3769
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", _object_spread_props(_object_spread({
3770
+ className: import_loading_module.default.container
3771
+ }, rest), {
3772
+ children: [
3773
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
3774
+ className: import_loading_module.default.ring
3775
+ }),
3776
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
3777
+ className: import_loading_module.default.ring
3778
+ }),
3779
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
3780
+ className: import_loading_module.default.ring
3781
+ }),
3782
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
3783
+ className: import_loading_module.default.ring
3784
+ }),
3785
+ message && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
3786
+ className: import_loading_module.default.message,
3787
+ children: message
3788
+ })
3789
+ ]
3790
+ }));
3791
+ }
3792
+ if (full) {
3793
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
3794
+ className: (0, import_classnames.default)(import_loading_module.default.fullscreen, className),
3795
+ children: _renderLoading()
3796
+ });
3797
+ } else if (block) {
3798
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
3799
+ className: (0, import_classnames.default)(import_loading_module.default.block, className),
3800
+ children: _renderLoading()
3801
+ });
3802
+ }
3803
+ return _renderLoading();
3804
+ }
3805
+ function LoadingProvider(param) {
3806
+ var children = param.children;
3807
+ var _ref = _sliced_to_array((0, import_react.useState)(false), 2), isLoading = _ref[0], setIsLoading = _ref[1];
3808
+ var _ref1 = _sliced_to_array((0, import_react.useState)(false), 2), isGlobalLoading = _ref1[0], setIsGlobalLoading = _ref1[1];
3809
+ var showLoading = (0, import_react.useCallback)(function() {
3810
+ var global = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
3811
+ setIsLoading(true);
3812
+ setIsGlobalLoading(global);
3813
+ }, []);
3814
+ var hideLoading = (0, import_react.useCallback)(function() {
3815
+ setIsLoading(false);
3816
+ setIsGlobalLoading(false);
3817
+ }, []);
3818
+ var contextValue = (0, import_react.useMemo)(function() {
3819
+ return {
3820
+ isLoading: isLoading,
3821
+ isGlobalLoading: isGlobalLoading,
3822
+ showLoading: showLoading,
3823
+ hideLoading: hideLoading
3824
+ };
3825
+ }, [
3826
+ isLoading,
3827
+ isGlobalLoading,
3828
+ showLoading,
3829
+ hideLoading
3830
+ ]);
3831
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingContext, {
3832
+ value: contextValue,
3833
+ children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loading, {
3834
+ full: isGlobalLoading
3835
+ }) : children
3836
+ });
3837
+ }
3838
+ // src/react/next-intl.tsx
3839
+ var import_next_intl = require("next-intl");
3840
+ var import_react3 = require("react");
3841
+ // src/react/storage.tsx
3842
+ var import_react2 = require("react");
3843
+ // src/utils/serializer.ts
3844
+ var serializer = {
3845
+ serialize: function(value) {
3846
+ return JSON.stringify(value, function(_, v) {
3847
+ if (_instanceof(v, Date)) {
3848
+ return {
3849
+ __type: "Date",
3850
+ value: v.toISOString()
3851
+ };
3852
+ }
3853
+ return v;
3854
+ });
3855
+ },
3856
+ deserialize: function(value) {
3857
+ return JSON.parse(value, function(_, v) {
3858
+ if ((v === null || v === void 0 ? void 0 : v.__type) === "Date") {
3859
+ return new Date(v.value);
3860
+ }
3861
+ return v;
3862
+ });
3863
+ }
3864
+ };
3865
+ // src/utils/storage-client.ts
3866
+ var import_localforage = __toESM(require("localforage"), 1);
3867
+ var storageClient = {
3868
+ get: function get(key) {
3869
+ return _async_to_generator(function() {
3870
+ var error;
3871
+ return _ts_generator(this, function(_state) {
3872
+ switch(_state.label){
3873
+ case 0:
3874
+ _state.trys.push([
3875
+ 0,
3876
+ 2,
3877
+ ,
3878
+ 3
3879
+ ]);
3880
+ return [
3881
+ 4,
3882
+ import_localforage.default.getItem(key)
3883
+ ];
3884
+ case 1:
3885
+ return [
3886
+ 2,
3887
+ _state.sent()
3888
+ ];
3889
+ case 2:
3890
+ error = _state.sent();
3891
+ console.error('❌ [Storage:get] Error getting key "'.concat(key, '":'), error);
3892
+ return [
3893
+ 2,
3894
+ null
3895
+ ];
3896
+ case 3:
3897
+ return [
3898
+ 2
3899
+ ];
3900
+ }
3901
+ });
3902
+ })();
3903
+ },
3904
+ set: function set(key, value) {
3905
+ return _async_to_generator(function() {
3906
+ var error;
3907
+ return _ts_generator(this, function(_state) {
3908
+ switch(_state.label){
3909
+ case 0:
3910
+ _state.trys.push([
3911
+ 0,
3912
+ 2,
3913
+ ,
3914
+ 3
3915
+ ]);
3916
+ return [
3917
+ 4,
3918
+ import_localforage.default.setItem(key, value)
3919
+ ];
3920
+ case 1:
3921
+ _state.sent();
3922
+ return [
3923
+ 3,
3924
+ 3
3925
+ ];
3926
+ case 2:
3927
+ error = _state.sent();
3928
+ console.error('❌ [Storage:set] Error setting key "'.concat(key, '":'), error);
3929
+ return [
3930
+ 3,
3931
+ 3
3932
+ ];
3933
+ case 3:
3934
+ return [
3935
+ 2
3936
+ ];
3937
+ }
3938
+ });
3939
+ })();
3940
+ },
3941
+ remove: function remove(key) {
3942
+ return _async_to_generator(function() {
3943
+ var error;
3944
+ return _ts_generator(this, function(_state) {
3945
+ switch(_state.label){
3946
+ case 0:
3947
+ _state.trys.push([
3948
+ 0,
3949
+ 2,
3950
+ ,
3951
+ 3
3952
+ ]);
3953
+ return [
3954
+ 4,
3955
+ import_localforage.default.removeItem(key)
3956
+ ];
3957
+ case 1:
3958
+ _state.sent();
3959
+ return [
3960
+ 3,
3961
+ 3
3962
+ ];
3963
+ case 2:
3964
+ error = _state.sent();
3965
+ console.error('❌ [Storage:remove] Error removing key "'.concat(key, '":'), error);
3966
+ return [
3967
+ 3,
3968
+ 3
3969
+ ];
3970
+ case 3:
3971
+ return [
3972
+ 2
3973
+ ];
3974
+ }
3975
+ });
3976
+ })();
3977
+ },
3978
+ keys: function keys() {
3979
+ return _async_to_generator(function() {
3980
+ var keys, error;
3981
+ return _ts_generator(this, function(_state) {
3982
+ switch(_state.label){
3983
+ case 0:
3984
+ _state.trys.push([
3985
+ 0,
3986
+ 2,
3987
+ ,
3988
+ 3
3989
+ ]);
3990
+ return [
3991
+ 4,
3992
+ import_localforage.default.keys()
3993
+ ];
3994
+ case 1:
3995
+ keys = _state.sent();
3996
+ return [
3997
+ 2,
3998
+ keys !== null && keys !== void 0 ? keys : []
3999
+ ];
4000
+ case 2:
4001
+ error = _state.sent();
4002
+ console.error("❌ [Storage:keys] Error getting keys:", error);
4003
+ return [
4004
+ 2,
4005
+ []
4006
+ ];
4007
+ case 3:
4008
+ return [
4009
+ 2
4010
+ ];
4011
+ }
4012
+ });
4013
+ })();
4014
+ }
4015
+ };
4016
+ // src/react/storage.tsx
4017
+ function useStorage(key, initialValue) {
4018
+ var serializer2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : serializer;
4019
+ var _ref = _sliced_to_array((0, import_react2.useState)(initialValue), 2), value = _ref[0], setValue = _ref[1];
4020
+ var _ref1 = _sliced_to_array((0, import_react2.useState)(false), 2), isLoaded = _ref1[0], setIsLoaded = _ref1[1];
4021
+ (0, import_react2.useEffect)(function() {
4022
+ var isMounted = true;
4023
+ var loadValue = /*#__PURE__*/ function() {
4024
+ var _ref = _async_to_generator(function() {
4025
+ var valueFound, parsedValue, serialized, error;
4026
+ return _ts_generator(this, function(_state) {
4027
+ switch(_state.label){
4028
+ case 0:
4029
+ _state.trys.push([
4030
+ 0,
4031
+ 6,
4032
+ 7,
4033
+ 8
4034
+ ]);
4035
+ return [
4036
+ 4,
4037
+ storageClient.get(key)
4038
+ ];
4039
+ case 1:
4040
+ valueFound = _state.sent();
4041
+ if (!isMounted) return [
4042
+ 3,
4043
+ 5
4044
+ ];
4045
+ if (!(valueFound !== null)) return [
4046
+ 3,
4047
+ 2
4048
+ ];
4049
+ parsedValue = serializer2.deserialize(valueFound);
4050
+ setValue(parsedValue);
4051
+ return [
4052
+ 3,
4053
+ 5
4054
+ ];
4055
+ case 2:
4056
+ if (!(initialValue !== void 0)) return [
4057
+ 3,
4058
+ 4
4059
+ ];
4060
+ serialized = serializer2.serialize(initialValue);
4061
+ return [
4062
+ 4,
4063
+ storageClient.set(key, serialized)
4064
+ ];
4065
+ case 3:
4066
+ _state.sent();
4067
+ setValue(initialValue);
4068
+ return [
4069
+ 3,
4070
+ 5
4071
+ ];
4072
+ case 4:
4073
+ setValue(void 0);
4074
+ _state.label = 5;
4075
+ case 5:
4076
+ return [
4077
+ 3,
4078
+ 8
4079
+ ];
4080
+ case 6:
4081
+ error = _state.sent();
4082
+ console.error('Error loading value for key "'.concat(key, '":'), error);
4083
+ if (isMounted) {
4084
+ setValue(initialValue);
4085
+ }
4086
+ return [
4087
+ 3,
4088
+ 8
4089
+ ];
4090
+ case 7:
4091
+ if (isMounted) setIsLoaded(true);
4092
+ return [
4093
+ 7
4094
+ ];
4095
+ case 8:
4096
+ return [
4097
+ 2
4098
+ ];
4099
+ }
4100
+ });
4101
+ });
4102
+ return function loadValue() {
4103
+ return _ref.apply(this, arguments);
4104
+ };
4105
+ }();
4106
+ loadValue();
4107
+ return function() {
4108
+ isMounted = false;
4109
+ setIsLoaded(false);
4110
+ };
4111
+ }, [
4112
+ key,
4113
+ initialValue,
4114
+ serializer2
4115
+ ]);
4116
+ (0, import_react2.useEffect)(function() {
4117
+ if (!isLoaded) return;
4118
+ var saveValue = /*#__PURE__*/ function() {
4119
+ var _ref = _async_to_generator(function() {
4120
+ var serialized, error;
4121
+ return _ts_generator(this, function(_state) {
4122
+ switch(_state.label){
4123
+ case 0:
4124
+ _state.trys.push([
4125
+ 0,
4126
+ 3,
4127
+ ,
4128
+ 4
4129
+ ]);
4130
+ if (!(value !== void 0)) return [
4131
+ 3,
4132
+ 2
4133
+ ];
4134
+ serialized = serializer2.serialize(value);
4135
+ return [
4136
+ 4,
4137
+ storageClient.set(key, serialized)
4138
+ ];
4139
+ case 1:
4140
+ _state.sent();
4141
+ _state.label = 2;
4142
+ case 2:
4143
+ return [
4144
+ 3,
4145
+ 4
4146
+ ];
4147
+ case 3:
4148
+ error = _state.sent();
4149
+ console.error('Error saving value for key "'.concat(key, '":'), error);
4150
+ return [
4151
+ 3,
4152
+ 4
4153
+ ];
4154
+ case 4:
4155
+ return [
4156
+ 2
4157
+ ];
4158
+ }
4159
+ });
4160
+ });
4161
+ return function saveValue() {
4162
+ return _ref.apply(this, arguments);
4163
+ };
4164
+ }();
4165
+ saveValue();
4166
+ }, [
4167
+ value,
4168
+ key,
4169
+ serializer2,
4170
+ isLoaded
4171
+ ]);
4172
+ var set = (0, import_react2.useCallback)(function(newValue) {
4173
+ setValue(function(prev) {
4174
+ return typeof newValue === "function" ? newValue(prev) : newValue;
4175
+ });
4176
+ }, []);
4177
+ var remove = (0, import_react2.useCallback)(/*#__PURE__*/ _async_to_generator(function() {
4178
+ var error;
4179
+ return _ts_generator(this, function(_state) {
4180
+ switch(_state.label){
4181
+ case 0:
4182
+ _state.trys.push([
4183
+ 0,
4184
+ 2,
4185
+ ,
4186
+ 3
4187
+ ]);
4188
+ return [
4189
+ 4,
4190
+ storageClient.remove(key)
4191
+ ];
4192
+ case 1:
4193
+ _state.sent();
4194
+ setValue(void 0);
4195
+ return [
4196
+ 3,
4197
+ 3
4198
+ ];
4199
+ case 2:
4200
+ error = _state.sent();
4201
+ console.error('Error removing key "'.concat(key, '":'), error);
4202
+ return [
4203
+ 3,
4204
+ 3
4205
+ ];
4206
+ case 3:
4207
+ return [
4208
+ 2
4209
+ ];
4210
+ }
4211
+ });
4212
+ }), [
4213
+ key
4214
+ ]);
4215
+ return {
4216
+ value: value,
4217
+ set: set,
4218
+ remove: remove
4219
+ };
4220
+ }
4221
+ // src/react/next-intl.tsx
4222
+ var import_jsx_runtime3 = require("react/jsx-runtime");
4223
+ var NextIntlContext = (0, import_react3.createContext)(void 0);
4224
+ function useNextIntl() {
4225
+ var context = (0, import_react3.use)(NextIntlContext);
4226
+ if (!context) {
4227
+ throw new Error("useNextIntl must be used within a NextIntlProvider");
4228
+ }
4229
+ return context;
4230
+ }
4231
+ var useTranslateNextIntl = import_next_intl.useTranslations;
4232
+ function withNextIntl(Component) {
4233
+ var PageWithI18n = function(props) {
4234
+ var _languages_find;
4235
+ var currentLanguage = useNextIntl().currentLanguage;
4236
+ var messages = props.messages, languages = props.languages;
4237
+ var defaultLang = "en";
4238
+ var defaultMessages = messages[(currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang];
4239
+ var timeZone = (_languages_find = languages.find(function(lang) {
4240
+ return lang.value === (currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value);
4241
+ })) === null || _languages_find === void 0 ? void 0 : _languages_find.timezone;
4242
+ if (!messages) {
4243
+ console.warn("Missing messages for language: ".concat((currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang));
4244
+ return null;
4245
+ }
4246
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_next_intl.NextIntlClientProvider, {
4247
+ locale: (currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang,
4248
+ messages: defaultMessages,
4249
+ timeZone: timeZone,
4250
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, _object_spread({}, props))
4251
+ });
4252
+ };
4253
+ PageWithI18n.displayName = "withNextIntl(".concat(Component.displayName || Component.name || "Component", ")");
4254
+ return PageWithI18n;
4255
+ }
4256
+ function LanguageWrapperBase(param) {
4257
+ var children = param.children;
4258
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {
4259
+ children: children
4260
+ });
4261
+ }
4262
+ var LanguageWrapper = withNextIntl(LanguageWrapperBase);
4263
+ function NextIntlProvider(param) {
4264
+ var children = param.children, languages = param.languages, messages = param.messages;
4265
+ var _languages_;
4266
+ var _useStorage = useStorage("lang", (_languages_ = languages === null || languages === void 0 ? void 0 : languages[0]) !== null && _languages_ !== void 0 ? _languages_ : {}), value = _useStorage.value, set = _useStorage.set;
4267
+ var contextValue = (0, import_react3.useMemo)(function() {
4268
+ return {
4269
+ languages: languages,
4270
+ currentLanguage: value,
4271
+ setCurrentLanguage: set
4272
+ };
4273
+ }, [
4274
+ languages,
4275
+ set,
4276
+ value
4277
+ ]);
4278
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NextIntlContext, {
4279
+ value: contextValue,
4280
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LanguageWrapper, {
4281
+ languages: languages,
4282
+ messages: messages,
4283
+ children: children
4284
+ })
4285
+ });
4286
+ }
4287
+ // src/typescript/mongo.ts
4288
+ var import_mongodb = require("mongodb");
4289
+ var import_mongoose2 = require("mongoose");
4290
+ var C_Db = /*#__PURE__*/ function(_import_mongodb_Db) {
4291
+ _inherits(C_Db, _import_mongodb_Db);
4292
+ function C_Db() {
4293
+ _class_call_check(this, C_Db);
4294
+ return _call_super(this, C_Db, arguments);
4295
+ }
4296
+ return C_Db;
4297
+ }(import_mongodb.Db);
4298
+ var C_Document = /*#__PURE__*/ function(_import_mongoose2_Document) {
4299
+ _inherits(C_Document, _import_mongoose2_Document);
4300
+ function C_Document() {
4301
+ _class_call_check(this, C_Document);
4302
+ return _call_super(this, C_Document, arguments);
4303
+ }
4304
+ return C_Document;
4305
+ }(import_mongoose2.Document);
4306
+ var C_Model = /*#__PURE__*/ function(_import_mongoose2_Model) {
4307
+ _inherits(C_Model, _import_mongoose2_Model);
4308
+ function C_Model() {
4309
+ _class_call_check(this, C_Model);
4310
+ return _call_super(this, C_Model, arguments);
4311
+ }
4312
+ return C_Model;
4313
+ }(import_mongoose2.Model);
4314
+ var C_Collection = /*#__PURE__*/ function(_import_mongodb_Collection) {
4315
+ _inherits(C_Collection, _import_mongodb_Collection);
4316
+ function C_Collection() {
4317
+ _class_call_check(this, C_Collection);
4318
+ return _call_super(this, C_Collection, arguments);
4319
+ }
4320
+ return C_Collection;
4321
+ }(import_mongodb.Collection);
4322
+ // src/utils/log.ts
4323
+ var import_graphql = require("graphql");
4324
+ function throwResponse(param) {
4325
+ var message = param.message, _param_status = param.status, status = _param_status === void 0 ? RESPONSE_STATUS.INTERNAL_SERVER_ERROR : _param_status, _param_type = param.type, type = _param_type === void 0 ? "graphql" : _param_type;
4326
+ var _ref;
4327
+ var responseMessage = (_ref = message !== null && message !== void 0 ? message : status.MESSAGE) !== null && _ref !== void 0 ? _ref : "Internal server error";
4328
+ if (type === "graphql") {
4329
+ throw new import_graphql.GraphQLError(responseMessage, {
4330
+ extensions: {
4331
+ code: status.CODE
4332
+ }
4333
+ });
4334
+ } else {
4335
+ throw new Error(responseMessage);
4336
+ }
4337
+ }
4338
+ // src/utils/common.ts
4339
+ var import_unorm = __toESM(require("unorm"), 1);
4340
+ function isJson(str) {
4341
+ try {
4342
+ JSON.parse(str);
4343
+ return true;
4344
+ } catch (e) {
4345
+ return false;
4346
+ }
4347
+ }
4348
+ var charMap = {
4349
+ a: [
4350
+ "\xE0",
4351
+ "\xE1",
4352
+ "\u1EA1",
4353
+ "\u1EA3",
4354
+ "\xE3",
4355
+ "\xE2",
4356
+ "\u1EA7",
4357
+ "\u1EA5",
4358
+ "\u1EAD",
4359
+ "\u1EA9",
4360
+ "\u1EAB",
4361
+ "\u0103",
4362
+ "\u1EB1",
4363
+ "\u1EAF",
4364
+ "\u1EB7",
4365
+ "\u1EB3",
4366
+ "\u1EB5"
4367
+ ],
4368
+ e: [
4369
+ "\xE8",
4370
+ "\xE9",
4371
+ "\u1EB9",
4372
+ "\u1EBB",
4373
+ "\u1EBD",
4374
+ "\xEA",
4375
+ "\u1EC1",
4376
+ "\u1EBF",
4377
+ "\u1EC7",
4378
+ "\u1EC3",
4379
+ "\u1EC5"
4380
+ ],
4381
+ i: [
4382
+ "\xEC",
4383
+ "\xED",
4384
+ "\u1ECB",
4385
+ "\u1EC9",
4386
+ "\u0129"
4387
+ ],
4388
+ o: [
4389
+ "\xF2",
4390
+ "\xF3",
4391
+ "\u1ECD",
4392
+ "\u1ECF",
4393
+ "\xF5",
4394
+ "\xF4",
4395
+ "\u1ED3",
4396
+ "\u1ED1",
4397
+ "\u1ED9",
4398
+ "\u1ED5",
4399
+ "\u1ED7",
4400
+ "\u01A1",
4401
+ "\u1EDD",
4402
+ "\u1EDB",
4403
+ "\u1EE3",
4404
+ "\u1EDF",
4405
+ "\u1EE1"
4406
+ ],
4407
+ u: [
4408
+ "\xF9",
4409
+ "\xFA",
4410
+ "\u1EE5",
4411
+ "\u1EE7",
4412
+ "\u0169",
4413
+ "\u01B0",
4414
+ "\u1EEB",
4415
+ "\u1EE9",
4416
+ "\u1EF1",
4417
+ "\u1EED",
4418
+ "\u1EEF"
4419
+ ],
4420
+ y: [
4421
+ "\u1EF3",
4422
+ "\xFD",
4423
+ "\u1EF5",
4424
+ "\u1EF7",
4425
+ "\u1EF9"
4426
+ ],
4427
+ d: [
4428
+ "\u0111"
4429
+ ]
4430
+ };
4431
+ var upperCharMap = Object.entries(charMap).reduce(function(map, param) {
4432
+ var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
4433
+ map[key.toUpperCase()] = value.map(function(char) {
4434
+ return char.toUpperCase();
4435
+ });
4436
+ return map;
4437
+ }, {});
4438
+ function regexSearchMapper(str) {
4439
+ str = import_unorm.default.nfkc(str);
4440
+ var combinedMap = _object_spread({}, charMap, upperCharMap);
4441
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4442
+ try {
4443
+ for(var _iterator = Object.entries(combinedMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4444
+ var _step_value = _sliced_to_array(_step.value, 2), baseChar = _step_value[0], variations = _step_value[1];
4445
+ var pattern = "[".concat(baseChar).concat(variations.join(""), "]");
4446
+ var replacement = "(".concat([
4447
+ baseChar
4448
+ ].concat(_to_consumable_array(variations)).join("|"), ")");
4449
+ str = str.replace(new RegExp(pattern, "g"), replacement);
4450
+ }
4451
+ } catch (err) {
4452
+ _didIteratorError = true;
4453
+ _iteratorError = err;
4454
+ } finally{
4455
+ try {
4456
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
4457
+ _iterator.return();
4458
+ }
4459
+ } finally{
4460
+ if (_didIteratorError) {
4461
+ throw _iteratorError;
4462
+ }
4463
+ }
4464
+ }
4465
+ return str;
4466
+ }
4467
+ function removeAccent(str) {
4468
+ return str.normalize("NFD").replace(RegExp("\\p{Diacritic}", "gu"), "");
4469
+ }
4470
+ // Annotate the CommonJS export names for ESM import in node:
4471
+ 0 && (module.exports = {
4472
+ ApolloProvider: ApolloProvider,
4473
+ BUILD_DIRECTORY: BUILD_DIRECTORY,
4474
+ COMMAND: COMMAND,
4475
+ COMMIT_LINT_CLI: COMMIT_LINT_CLI,
4476
+ CYBERSKILL_CLI: CYBERSKILL_CLI,
4477
+ CYBERSKILL_DIRECTORY: CYBERSKILL_DIRECTORY,
4478
+ CYBERSKILL_PACKAGE_NAME: CYBERSKILL_PACKAGE_NAME,
4479
+ CYBERSKILL_STORAGE: CYBERSKILL_STORAGE,
4480
+ C_Collection: C_Collection,
4481
+ C_Db: C_Db,
4482
+ C_Document: C_Document,
4483
+ C_Model: C_Model,
4484
+ ESLINT_CLI: ESLINT_CLI,
4485
+ ESLINT_INSPECT_CLI: ESLINT_INSPECT_CLI,
4486
+ E_ErrorType: E_ErrorType,
4487
+ GIT_CLI: GIT_CLI,
4488
+ GIT_COMMIT_EDITMSG: GIT_COMMIT_EDITMSG,
4489
+ GIT_HOOK: GIT_HOOK,
4490
+ GIT_IGNORE: GIT_IGNORE,
4491
+ HOOK: HOOK,
4492
+ LINT_STAGED_CLI: LINT_STAGED_CLI,
4493
+ Loading: Loading,
4494
+ LoadingContext: LoadingContext,
4495
+ LoadingProvider: LoadingProvider,
4496
+ MongoController: MongoController,
4497
+ MongooseController: MongooseController,
4498
+ NODE_MODULES: NODE_MODULES,
4499
+ NODE_MODULES_INSPECT_CLI: NODE_MODULES_INSPECT_CLI,
4500
+ NextIntlContext: NextIntlContext,
4501
+ NextIntlProvider: NextIntlProvider,
4502
+ PACKAGE_JSON: PACKAGE_JSON,
4503
+ PACKAGE_LOCK_JSON: PACKAGE_LOCK_JSON,
4504
+ PATH: PATH,
4505
+ PNPM_CLI: PNPM_CLI,
4506
+ PNPM_DLX_CLI: PNPM_DLX_CLI,
4507
+ PNPM_EXEC_CLI: PNPM_EXEC_CLI,
4508
+ PNPM_LOCK_YAML: PNPM_LOCK_YAML,
4509
+ RESPONSE_STATUS: RESPONSE_STATUS,
4510
+ RIMRAF_CLI: RIMRAF_CLI,
4511
+ SIMPLE_GIT_HOOK_CLI: SIMPLE_GIT_HOOK_CLI,
4512
+ SIMPLE_GIT_HOOK_JSON: SIMPLE_GIT_HOOK_JSON,
4513
+ TSCONFIG_JSON: TSCONFIG_JSON,
4514
+ TSC_CLI: TSC_CLI,
4515
+ TSX_CLI: TSX_CLI,
4516
+ VITEST_CLI: VITEST_CLI,
4517
+ WORKING_DIRECTORY: WORKING_DIRECTORY,
4518
+ aggregatePaginate: aggregatePaginate,
4519
+ appendFileSync: appendFileSync,
4520
+ checkPackage: checkPackage,
4521
+ clearAllErrorLists: clearAllErrorLists,
4522
+ commandFormatter: commandFormatter,
4523
+ commandLog: commandLog,
4524
+ deepMerge: deepMerge,
4525
+ dirname: dirname,
4526
+ executeCommand: executeCommand,
4527
+ existsSync: existsSync,
4528
+ generateShortId: generateShortId,
4529
+ generateSlug: generateSlug,
4530
+ getLatestPackageVersion: getLatestPackageVersion,
4531
+ getPackageJson: getPackageJson,
4532
+ getStorageDir: getStorageDir,
4533
+ getStoredErrorLists: getStoredErrorLists,
4534
+ initNodePersist: initNodePersist,
4535
+ isJson: isJson,
4536
+ join: join,
4537
+ mongo: mongo,
4538
+ mongoosePaginate: mongoosePaginate,
4539
+ readFileSync: readFileSync,
4540
+ regexSearchMapper: regexSearchMapper,
4541
+ removeAccent: removeAccent,
4542
+ require: require,
4543
+ resolve: resolve,
4544
+ resolveCommands: resolveCommands,
4545
+ resolveCyberSkillPath: resolveCyberSkillPath,
4546
+ resolveWorkingPath: resolveWorkingPath,
4547
+ rmSync: rmSync,
4548
+ saveErrorListToStorage: saveErrorListToStorage,
4549
+ serializer: serializer,
4550
+ storageClient: storageClient,
4551
+ storageServer: storageServer,
4552
+ throwResponse: throwResponse,
4553
+ useLoading: useLoading,
4554
+ useNextIntl: useNextIntl,
4555
+ useStorage: useStorage,
4556
+ useTranslateNextIntl: useTranslateNextIntl,
4557
+ validate: validate,
4558
+ withNextIntl: withNextIntl,
4559
+ writeFileSync: writeFileSync
4560
+ });