@cyberskill/shared 1.127.0 → 1.128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/_tsup-dts-rollup.d.cts +50 -44
- package/dist/_tsup-dts-rollup.d.ts +50 -44
- package/dist/configs/config.util.cjs +1 -1
- package/dist/configs/config.util.js +1 -1
- package/dist/configs/index.cjs +1 -1
- package/dist/configs/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/{nodejs → node}/apollo-server/apollo-server.util.cjs +1 -1
- package/dist/{nodejs → node}/apollo-server/apollo-server.util.js +1 -1
- package/dist/{nodejs → node}/apollo-server/index.cjs +1 -1
- package/dist/{nodejs → node}/apollo-server/index.js +1 -1
- package/dist/node/cli/cli.util.cjs +2 -0
- package/dist/node/cli/cli.util.js +2 -0
- package/dist/node/cli/index.cjs +1 -0
- package/dist/node/cli/index.js +1 -0
- package/dist/node/command/command.util.cjs +1 -0
- package/dist/node/command/command.util.js +1 -0
- package/dist/node/command/index.cjs +1 -0
- package/dist/node/command/index.js +1 -0
- package/dist/{nodejs → node}/express/express.util.cjs +1 -1
- package/dist/{nodejs → node}/express/express.util.js +1 -1
- package/dist/{nodejs → node}/express/index.cjs +1 -1
- package/dist/{nodejs → node}/express/index.js +1 -1
- package/dist/node/fs/fs.util.cjs +1 -0
- package/dist/node/fs/fs.util.js +1 -0
- package/dist/node/fs/index.cjs +1 -0
- package/dist/node/fs/index.js +1 -0
- package/dist/node/index.cjs +1 -0
- package/dist/{nodejs → node}/index.d.cts +5 -5
- package/dist/{nodejs → node}/index.d.ts +5 -5
- package/dist/node/index.js +1 -0
- package/dist/node/mongo/index.cjs +1 -0
- package/dist/node/mongo/index.js +1 -0
- package/dist/node/mongo/mongo.util.cjs +1 -0
- package/dist/node/mongo/mongo.util.js +1 -0
- package/dist/node/package/index.cjs +1 -0
- package/dist/{nodejs → node}/package/index.d.cts +5 -5
- package/dist/{nodejs → node}/package/index.d.ts +5 -5
- package/dist/node/package/index.js +1 -0
- package/dist/node/package/package.type.cjs +1 -0
- package/dist/node/package/package.type.d.cts +4 -0
- package/dist/node/package/package.type.d.ts +4 -0
- package/dist/node/package/package.type.js +1 -0
- package/dist/node/package/package.util.cjs +1 -0
- package/dist/{nodejs → node}/package/package.util.d.cts +2 -2
- package/dist/{nodejs → node}/package/package.util.d.ts +2 -2
- package/dist/node/package/package.util.js +1 -0
- package/dist/node/path/index.cjs +1 -0
- package/dist/node/path/index.js +1 -0
- package/dist/node/path/path.constant.cjs +1 -0
- package/dist/node/path/path.constant.js +1 -0
- package/dist/node/storage/index.cjs +1 -0
- package/dist/node/storage/index.js +1 -0
- package/dist/node/storage/storage.util.cjs +1 -0
- package/dist/node/storage/storage.util.js +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/next-intl/index.cjs +1 -1
- package/dist/react/next-intl/index.js +1 -1
- package/dist/react/next-intl/next-intl.provider.cjs +1 -1
- package/dist/react/next-intl/next-intl.provider.js +1 -1
- package/dist/react/storage/index.cjs +1 -1
- package/dist/react/storage/index.js +1 -1
- package/dist/react/storage/storage.hook.cjs +1 -1
- package/dist/react/storage/storage.hook.js +1 -1
- package/dist/react/storage/storage.util.cjs +1 -1
- package/dist/react/storage/storage.util.js +1 -1
- package/dist/react/vitest/index.cjs +1 -1
- package/dist/react/vitest/index.js +1 -1
- package/dist/react/vitest/vitest.unit.cjs +1 -1
- package/dist/react/vitest/vitest.unit.js +1 -1
- package/package.json +74 -74
- package/public/wiki/convention.md +1 -1
- package/dist/nodejs/cli/cli.util.cjs +0 -2
- package/dist/nodejs/cli/cli.util.js +0 -2
- package/dist/nodejs/cli/index.cjs +0 -1
- package/dist/nodejs/cli/index.js +0 -1
- package/dist/nodejs/command/command.util.cjs +0 -1
- package/dist/nodejs/command/command.util.js +0 -1
- package/dist/nodejs/command/index.cjs +0 -1
- package/dist/nodejs/command/index.js +0 -1
- package/dist/nodejs/fs/fs.util.cjs +0 -1
- package/dist/nodejs/fs/fs.util.js +0 -1
- package/dist/nodejs/fs/index.cjs +0 -1
- package/dist/nodejs/fs/index.js +0 -1
- package/dist/nodejs/index.cjs +0 -1
- package/dist/nodejs/index.js +0 -1
- package/dist/nodejs/mongo/index.cjs +0 -1
- package/dist/nodejs/mongo/index.js +0 -1
- package/dist/nodejs/mongo/mongo.util.cjs +0 -1
- package/dist/nodejs/mongo/mongo.util.js +0 -1
- package/dist/nodejs/package/index.cjs +0 -1
- package/dist/nodejs/package/index.js +0 -1
- package/dist/nodejs/package/package.constant.cjs +0 -1
- package/dist/nodejs/package/package.constant.d.cts +0 -1
- package/dist/nodejs/package/package.constant.d.ts +0 -1
- package/dist/nodejs/package/package.constant.js +0 -1
- package/dist/nodejs/package/package.type.cjs +0 -1
- package/dist/nodejs/package/package.type.d.cts +0 -3
- package/dist/nodejs/package/package.type.d.ts +0 -3
- package/dist/nodejs/package/package.type.js +0 -0
- package/dist/nodejs/package/package.util.cjs +0 -1
- package/dist/nodejs/package/package.util.js +0 -1
- package/dist/nodejs/path/index.cjs +0 -1
- package/dist/nodejs/path/index.js +0 -1
- package/dist/nodejs/path/path.constant.cjs +0 -1
- package/dist/nodejs/path/path.constant.js +0 -1
- package/dist/nodejs/storage/index.cjs +0 -1
- package/dist/nodejs/storage/index.js +0 -1
- package/dist/nodejs/storage/storage.util.cjs +0 -1
- package/dist/nodejs/storage/storage.util.js +0 -1
- /package/dist/{nodejs → node}/apollo-server/apollo-server.type.cjs +0 -0
- /package/dist/{nodejs → node}/apollo-server/apollo-server.type.d.cts +0 -0
- /package/dist/{nodejs → node}/apollo-server/apollo-server.type.d.ts +0 -0
- /package/dist/{nodejs → node}/apollo-server/apollo-server.type.js +0 -0
- /package/dist/{nodejs → node}/apollo-server/apollo-server.util.d.cts +0 -0
- /package/dist/{nodejs → node}/apollo-server/apollo-server.util.d.ts +0 -0
- /package/dist/{nodejs → node}/apollo-server/index.d.cts +0 -0
- /package/dist/{nodejs → node}/apollo-server/index.d.ts +0 -0
- /package/dist/{nodejs → node}/cli/cli.util.d.cts +0 -0
- /package/dist/{nodejs → node}/cli/cli.util.d.ts +0 -0
- /package/dist/{nodejs → node}/cli/index.d.cts +0 -0
- /package/dist/{nodejs → node}/cli/index.d.ts +0 -0
- /package/dist/{nodejs → node}/command/command.type.cjs +0 -0
- /package/dist/{nodejs → node}/command/command.type.d.cts +0 -0
- /package/dist/{nodejs → node}/command/command.type.d.ts +0 -0
- /package/dist/{nodejs → node}/command/command.type.js +0 -0
- /package/dist/{nodejs → node}/command/command.util.d.cts +0 -0
- /package/dist/{nodejs → node}/command/command.util.d.ts +0 -0
- /package/dist/{nodejs → node}/command/index.d.cts +0 -0
- /package/dist/{nodejs → node}/command/index.d.ts +0 -0
- /package/dist/{nodejs → node}/express/express.type.cjs +0 -0
- /package/dist/{nodejs → node}/express/express.type.d.cts +0 -0
- /package/dist/{nodejs → node}/express/express.type.d.ts +0 -0
- /package/dist/{nodejs → node}/express/express.type.js +0 -0
- /package/dist/{nodejs → node}/express/express.util.d.cts +0 -0
- /package/dist/{nodejs → node}/express/express.util.d.ts +0 -0
- /package/dist/{nodejs → node}/express/index.d.cts +0 -0
- /package/dist/{nodejs → node}/express/index.d.ts +0 -0
- /package/dist/{nodejs → node}/fs/fs.type.cjs +0 -0
- /package/dist/{nodejs → node}/fs/fs.type.d.cts +0 -0
- /package/dist/{nodejs → node}/fs/fs.type.d.ts +0 -0
- /package/dist/{nodejs → node}/fs/fs.type.js +0 -0
- /package/dist/{nodejs → node}/fs/fs.util.d.cts +0 -0
- /package/dist/{nodejs → node}/fs/fs.util.d.ts +0 -0
- /package/dist/{nodejs → node}/fs/index.d.cts +0 -0
- /package/dist/{nodejs → node}/fs/index.d.ts +0 -0
- /package/dist/{nodejs → node}/log/index.cjs +0 -0
- /package/dist/{nodejs → node}/log/index.d.cts +0 -0
- /package/dist/{nodejs → node}/log/index.d.ts +0 -0
- /package/dist/{nodejs → node}/log/index.js +0 -0
- /package/dist/{nodejs → node}/log/log.type.cjs +0 -0
- /package/dist/{nodejs → node}/log/log.type.d.cts +0 -0
- /package/dist/{nodejs → node}/log/log.type.d.ts +0 -0
- /package/dist/{nodejs → node}/log/log.type.js +0 -0
- /package/dist/{nodejs → node}/log/log.util.cjs +0 -0
- /package/dist/{nodejs → node}/log/log.util.d.cts +0 -0
- /package/dist/{nodejs → node}/log/log.util.d.ts +0 -0
- /package/dist/{nodejs → node}/log/log.util.js +0 -0
- /package/dist/{nodejs → node}/mongo/index.d.cts +0 -0
- /package/dist/{nodejs → node}/mongo/index.d.ts +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.constant.cjs +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.constant.d.cts +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.constant.d.ts +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.constant.js +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.type.cjs +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.type.d.cts +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.type.d.ts +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.type.js +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.util.d.cts +0 -0
- /package/dist/{nodejs → node}/mongo/mongo.util.d.ts +0 -0
- /package/dist/{nodejs → node}/path/index.d.cts +0 -0
- /package/dist/{nodejs → node}/path/index.d.ts +0 -0
- /package/dist/{nodejs → node}/path/path.constant.d.cts +0 -0
- /package/dist/{nodejs → node}/path/path.constant.d.ts +0 -0
- /package/dist/{nodejs → node}/path/path.util.cjs +0 -0
- /package/dist/{nodejs → node}/path/path.util.d.cts +0 -0
- /package/dist/{nodejs → node}/path/path.util.d.ts +0 -0
- /package/dist/{nodejs → node}/path/path.util.js +0 -0
- /package/dist/{nodejs → node}/storage/index.d.cts +0 -0
- /package/dist/{nodejs → node}/storage/index.d.ts +0 -0
- /package/dist/{nodejs → node}/storage/storage.util.d.cts +0 -0
- /package/dist/{nodejs → node}/storage/storage.util.d.ts +0 -0
- /package/dist/{nodejs → node}/ws/index.cjs +0 -0
- /package/dist/{nodejs → node}/ws/index.d.cts +0 -0
- /package/dist/{nodejs → node}/ws/index.d.ts +0 -0
- /package/dist/{nodejs → node}/ws/index.js +0 -0
- /package/dist/{nodejs → node}/ws/ts.util.cjs +0 -0
- /package/dist/{nodejs → node}/ws/ts.util.d.cts +0 -0
- /package/dist/{nodejs → node}/ws/ts.util.d.ts +0 -0
- /package/dist/{nodejs → node}/ws/ts.util.js +0 -0
- /package/dist/{nodejs → node}/ws/ws.type.cjs +0 -0
- /package/dist/{nodejs → node}/ws/ws.type.d.cts +0 -0
- /package/dist/{nodejs → node}/ws/ws.type.d.ts +0 -0
- /package/dist/{nodejs → node}/ws/ws.type.js +0 -0
package/dist/nodejs/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function s(e,t,n,r,s,i,o){try{var a=e[i](o);var c=a.value}catch(e){n(e);return}if(a.done){t(c)}else{Promise.resolve(c).then(r,s)}}function i(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function a(e){s(o,r,i,a,c,"next",e)}function c(e){s(o,r,i,a,c,"throw",e)}a(undefined)})}}function o(e,t,n){t=d(t);return I(e,N()?Reflect.construct(t,n||[],d(e).constructor):t.apply(e,n))}function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}function u(e,t,n){if(t)c(e.prototype,t);if(n)c(e,n);return e}function l(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function d(e){d=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return d(e)}function f(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)C(e,t)}function p(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function m(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function g(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var s=true;var i=false;var o,a;try{for(n=n.call(e);!(s=(o=n.next()).done);s=true){r.push(o.value);if(t&&r.length===t)break}}catch(e){i=true;a=e}finally{try{if(!s&&n["return"]!=null)n["return"]()}finally{if(i)throw a}}return r}function E(){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 h(){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 v(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var r=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}r.forEach(function(t){l(e,t,n[t])})}return e}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}n.push.apply(n,r)}return n}function S(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{y(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function O(e,t){if(e==null)return{};var n=_(e,t);var r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++){r=i[s];if(t.indexOf(r)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;n[r]=e[r]}}return n}function _(e,t){if(e==null)return{};var n={};var r=Object.keys(e);var s,i;for(i=0;i<r.length;i++){s=r[i];if(t.indexOf(s)>=0)continue;n[s]=e[s]}return n}function I(e,t){if(t&&(T(t)==="object"||typeof t==="function")){return t}return r(e)}function C(e,t){C=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return C(e,t)}function R(e,n){return t(e)||g(e,n)||b(e,n)||E()}function A(e){return n(e)||m(e)||b(e)||h()}function T(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function b(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function N(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(N=function(){return!!e})()}function D(e,t){var n,r,s,i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},o=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return o.next=a(0),o["throw"]=a(1),o["return"]=a(2),typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return c([e,t])}}function c(a){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(i=0)),i)try{if(n=1,r&&(s=a[0]&2?r["return"]:a[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,a[1])).done)return s;if(r=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;r=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(a[0]===6&&i.label<s[1]){i.label=s[1];s=a;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(a);break}if(s[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];r=0}finally{n=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var x=Object.defineProperty;var G=function(e,t,n){return t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n};var M=function(e,t){return x(e,"name",{value:t,configurable:!0})};var w=function(e,t,n){return G(e,(typeof t==="undefined"?"undefined":T(t))!="symbol"?t+"":t,n)};import{ApolloServer as j}from"@apollo/server";import{expressMiddleware as L}from"@apollo/server/express4";import{ApolloServerPluginDrainHttpServer as P}from"@apollo/server/plugin/drainHttpServer";import{ApolloServerPluginLandingPageLocalDefault as k,ApolloServerPluginLandingPageProductionDefault as U}from"@apollo/server/plugin/landingPage/default";var F=function(e){return e.Error="error",e.Warning="warning",e}({});import q from"chalk";import K from"consola";import{GraphQLError as B}from"graphql";var H=".cyberskill-storage";import Y from"@dotenvx/dotenvx";import{bool as W,cleanEnv as V,str as Q}from"envalid";import J from"node:os";import $ from"node:path";import X from"node:process";var z=!1;function Z(){z||(Y.config(),z=!0)}M(Z,"loadEnvFile");function ee(){Z();var e=V(X.env,{CWD:Q({default:X.cwd()}),DEBUG:W({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:Q({default:$.join(J.homedir(),H)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}M(ee,"getEnv");var et={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 en=ee();function er(e){var t=e.message,n=e.status,r=n===void 0?et.INTERNAL_SERVER_ERROR:n,s=e.type,i=s===void 0?"graphql":s;var o;var a=(o=t!==null&&t!==void 0?t:r.MESSAGE)!==null&&o!==void 0?o:"Internal server error";throw i==="graphql"?new B(a,{extensions:{code:r.CODE}}):new Error(a)}M(er,"throwError");en.DEBUG||(K.level=4);function es(e){var t=q[e];return typeof t=="function"?t:q.green}M(es,"chalkKeyword");var ei={silent:K.silent,level:K.level,fatal:K.fatal,error:K.error,warn:K.warn,log:K.log,info:K.info,success:K.success,ready:K.ready,start:K.start,box:K.box,debug:K.debug,trace:K.trace,verbose:K.verbose,printBoxedLog:function e(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){K.box(q.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,s=e.rule,i=e.message;K.log("".concat(q.gray("File:")," ").concat(q.blue("".concat(t).concat(r?":".concat(r):"")))),s&&K.log(" ".concat(es(n)("Rule:")," ").concat(s)),K.log(" ".concat(es(n)("Message:")," ").concat(i))}),K.box(es(n)("".concat(e," : ").concat(t.length))),K.log(q.gray("─".repeat(40)))}};function eo(e){return new j(v({schema:e.schema,plugins:[e.isDev?k():U(),P({httpServer:e.server})].concat(A(e.drainServer?[{serverWillStart:function t(){return i(function(){return D(this,function(t){return[2,{drainServer:function t(){return i(function(){var t;return D(this,function(n){(t=e.drainServer)===null||t===void 0?void 0:t.call(e),ei.info("Apollo Server drainServer hook called");return[2]})})()}}]})})()}}]:[]))},e.isDev&&{introspection:!0,includeStacktraceInErrorResponses:!0}))}M(eo,"createApolloServer");import ea from"node:process";import{hideBin as ec}from"yargs/helpers";import eu from"yargs/yargs";var el={name:"@cyberskill/shared",type:"module",version:"1.126.0",description:"CyberSkill Shared",author:"Stephen Cheng",license:"MIT",homepage:"https://github.com/cyberskill-world/shared#readme",repository:{type:"git",url:"git+https://github.com/cyberskill-world/shared.git"},bugs:{url:"https://github.com/cyberskill-world/shared/issues"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./configs":{types:"./dist/configs/index.d.ts",import:"./dist/configs/index.js",require:"./dist/configs/index.cjs"},"./configs/commitlint":{types:"./dist/configs/commitlint/index.d.ts",import:"./dist/configs/commitlint/index.js",require:"./dist/configs/commitlint/index.cjs"},"./configs/env":{types:"./dist/configs/env/index.d.ts",import:"./dist/configs/env/index.js",require:"./dist/configs/env/index.cjs"},"./configs/eslint":{types:"./dist/configs/eslint/index.d.ts",import:"./dist/configs/eslint/index.js",require:"./dist/configs/eslint/index.cjs"},"./configs/graphql-codegen":{types:"./dist/configs/graphql-codegen/index.d.ts",import:"./dist/configs/graphql-codegen/index.js",require:"./dist/configs/graphql-codegen/index.cjs"},"./configs/lint-staged":{types:"./dist/configs/lint-staged/index.d.ts",import:"./dist/configs/lint-staged/index.js",require:"./dist/configs/lint-staged/index.cjs"},"./constants":{types:"./dist/constants/index.d.ts",import:"./dist/constants/index.js",require:"./dist/constants/index.cjs"},"./nodejs":{types:"./dist/nodejs/index.d.ts",import:"./dist/nodejs/index.js",require:"./dist/nodejs/index.cjs"},"./nodejs/apollo-server":{types:"./dist/nodejs/apollo-server/index.d.ts",import:"./dist/nodejs/apollo-server/index.js",require:"./dist/nodejs/apollo-server/index.cjs"},"./nodejs/cli":{types:"./dist/nodejs/cli/index.d.ts",import:"./dist/nodejs/cli/index.js",require:"./dist/nodejs/cli/index.cjs"},"./nodejs/command":{types:"./dist/nodejs/command/index.d.ts",import:"./dist/nodejs/command/index.js",require:"./dist/nodejs/command/index.cjs"},"./nodejs/express":{types:"./dist/nodejs/express/index.d.ts",import:"./dist/nodejs/express/index.js",require:"./dist/nodejs/express/index.cjs"},"./nodejs/fs":{types:"./dist/nodejs/fs/index.d.ts",import:"./dist/nodejs/fs/index.js",require:"./dist/nodejs/fs/index.cjs"},"./nodejs/log":{types:"./dist/nodejs/log/index.d.ts",import:"./dist/nodejs/log/index.js",require:"./dist/nodejs/log/index.cjs"},"./nodejs/mongo":{types:"./dist/nodejs/mongo/index.d.ts",import:"./dist/nodejs/mongo/index.js",require:"./dist/nodejs/mongo/index.cjs"},"./nodejs/package":{types:"./dist/nodejs/package/index.d.ts",import:"./dist/nodejs/package/index.js",require:"./dist/nodejs/package/index.cjs"},"./nodejs/path":{types:"./dist/nodejs/path/index.d.ts",import:"./dist/nodejs/path/index.js",require:"./dist/nodejs/path/index.cjs"},"./nodejs/storage":{types:"./dist/nodejs/storage/index.d.ts",import:"./dist/nodejs/storage/index.js",require:"./dist/nodejs/storage/index.cjs"},"./nodejs/ws":{types:"./dist/nodejs/ws/index.d.ts",import:"./dist/nodejs/ws/index.js",require:"./dist/nodejs/ws/index.cjs"},"./react":{types:"./dist/react/index.d.ts",import:"./dist/react/index.js",require:"./dist/react/index.cjs"},"./react/apollo-client":{types:"./dist/react/apollo-client/index.d.ts",import:"./dist/react/apollo-client/index.js",require:"./dist/react/apollo-client/index.cjs"},"./react/apollo-error":{types:"./dist/react/apollo-error/index.d.ts",import:"./dist/react/apollo-error/index.js",require:"./dist/react/apollo-error/index.cjs"},"./react/i18next":{types:"./dist/react/i18next/index.d.ts",import:"./dist/react/i18next/index.js",require:"./dist/react/i18next/index.cjs"},"./react/loading":{types:"./dist/react/loading/index.d.ts",import:"./dist/react/loading/index.js",require:"./dist/react/loading/index.cjs"},"./react/log":{types:"./dist/react/log/index.d.ts",import:"./dist/react/log/index.js",require:"./dist/react/log/index.cjs"},"./react/next-intl":{types:"./dist/react/next-intl/index.d.ts",import:"./dist/react/next-intl/index.js",require:"./dist/react/next-intl/index.cjs"},"./react/storage":{types:"./dist/react/storage/index.d.ts",import:"./dist/react/storage/index.js",require:"./dist/react/storage/index.cjs"},"./react/toast":{types:"./dist/react/toast/index.d.ts",import:"./dist/react/toast/index.js",require:"./dist/react/toast/index.cjs"},"./react/vitest":{types:"./dist/react/vitest/index.d.ts",import:"./dist/react/vitest/index.js",require:"./dist/react/vitest/index.cjs"},"./styles/reset.css":{import:"./dist/styles/reset.css",require:"./dist/styles/reset.css"},"./typescript":{types:"./dist/typescript/index.d.ts",import:"./dist/typescript/index.js",require:"./dist/typescript/index.cjs"},"./utils":{types:"./dist/utils/index.d.ts",import:"./dist/utils/index.js",require:"./dist/utils/index.cjs"}},main:"./dist/index.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",bin:{cyberskill:"./dist/nodejs/cli/index.js"},files:["dist","public"],scripts:{build:"tsup",dev:"tsup --watch",lint:"tsx src/nodejs/cli/index.ts lint","lint:fix":"tsx src/nodejs/cli/index.ts lint:fix","lint:inspect":"tsx src/nodejs/cli/index.ts lint:inspect",reset:"tsx src/nodejs/cli/index.ts reset",setup:"tsx src/nodejs/cli/index.ts setup",inspect:"tsx src/nodejs/cli/index.ts inspect","test:unit":"tsx src/nodejs/cli/index.ts test:unit","test:e2e":"tsx src/nodejs/cli/index.ts test:e2e",commitlint:"tsx src/nodejs/cli/index.ts commitlint","lint-staged":"tsx src/nodejs/cli/index.ts lint-staged"},dependencies:{"@antfu/eslint-config":"4.12.0","@apollo/client":"3.13.8","@apollo/server":"4.12.0","@dotenvx/dotenvx":"1.41.0","@eddeee888/gcg-typescript-resolver-files":"0.12.0","@eslint-react/eslint-plugin":"1.48.5","@graphql-codegen/cli":"5.0.5","@graphql-codegen/client-preset":"4.8.0","@microsoft/api-extractor":"7.52.5","@nestjs/common":"11.1.0","@nestjs/core":"11.1.0","@next/eslint-plugin-next":"15.3.1","@testing-library/jest-dom":"6.6.3","@testing-library/react":"16.3.0","@vitejs/plugin-react-swc":"3.9.0","@vitest/browser":"3.1.2","body-parser":"2.2.0",chalk:"5.4.1",classnames:"2.5.1",compression:"1.8.0",consola:"3.4.2","cookie-parser":"1.4.7",cors:"2.8.5","crypto-js":"4.2.0","date-fns":"4.1.0","dotenv-cli":"8.0.0",envalid:"8.0.0","eslint-config-next":"15.3.1","eslint-plugin-format":"1.0.1","eslint-plugin-react-hooks":"5.2.0","eslint-plugin-react-refresh":"0.4.20",express:"4.21.2","express-session":"1.18.1","express-useragent":"1.0.15","fs-extra":"11.3.0",globals:"16.0.0",graphql:"16.11.0","graphql-ws":"6.0.4",i18next:"25.0.2",jsdom:"26.1.0",localforage:"1.10.0","migrate-mongo":"12.1.3","modern-normalize":"3.0.1",mongodb:"6.16.0",mongoose:"8.14.1","mongoose-aggregate-paginate-v2":"1.1.4","mongoose-paginate-v2":"1.9.0","next-intl":"4.1.0","node-fetch":"3.3.2","node-persist":"4.0.4",playwright:"1.52.0","postcss-modules":"6.0.1",qs:"6.14.0",react:"19.1.0","react-dom":"19.1.0","react-hot-toast":"2.5.2","react-i18next":"15.5.1","react-icons":"5.5.0",sass:"1.87.0",slugify:"1.6.6",tsup:"8.4.0",tsx:"4.19.4",typescript:"5.8.3",unorm:"1.6.0",uuid:"11.1.0",vite:"6.3.3",vitest:"3.1.2","vitest-browser-react":"0.1.1",ws:"8.18.1",yargs:"17.7.2"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},devDependencies:{"@commitlint/cli":"19.8.0","@eslint/config-inspector":"1.0.2","@types/body-parser":"1.19.5","@types/compression":"1.7.5","@types/cookie-parser":"1.4.8","@types/cors":"2.8.17","@types/crypto-js":"4.2.2","@types/express":"4.17.21","@types/express-session":"1.18.1","@types/express-useragent":"1.0.5","@types/fs-extra":"11.0.4","@types/migrate-mongo":"10.0.5","@types/mongoose-aggregate-paginate-v2":"1.0.12","@types/node":"22.15.3","@types/node-persist":"3.1.8","@types/react":"19.1.2","@types/react-dom":"19.1.2","@types/unorm":"1.3.31","@types/uuid":"10.0.0","@types/ws":"8.18.1","@types/yargs":"17.0.33",eslint:"9.25.1","lint-staged":"15.5.1","node-modules-inspector":"0.6.7","simple-git-hooks":"2.13.0"}};var ed=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});import{exec as ef}from"node:child_process";import ep from"node:process";import*as em from"node:util";var eg={isCurrentProject:!1,installedPath:"",file:{},isUpToDate:!1};import eE from"node-fetch";import eh from"fs-extra";import ev from"node:path";var ey=ee(),eS=ev;function eO(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=eS).resolve.apply(r,[ey.CWD].concat(A(t)))}M(eO,"resolveWorkingPath");function e_(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=eS).resolve.apply(r,A(t))}M(e_,"resolve");function eI(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=eS).join.apply(r,A(t))}M(eI,"join");var eC=ee(),eR=eC.CWD,eA="@cyberskill/shared",eT="node_modules",eb="dist",eN="package.json",eD="package-lock.json",ex="tsconfig.json",eG=".gitignore",eM=".simple-git-hooks.json",ew="pnpm-lock.yaml",ej=".git/hooks/",eL=".git/COMMIT_EDITMSG",eP=".migrate-mongo.config.js",ek=eI(eR,eT,eA,eb),eU="cyberskill",eF="src/nodejs/cli/index.ts",eq="eslint",eK="eslint",eB="vitest",eH="playwright",eY="vitest",eW="@commitlint/cli",eV="commitlint",eQ="lint-staged",eJ="lint-staged",e$="typescript",eX="tsc",ez="tsx",eZ="git",e0="pnpm",e1="pnpm exec",e2="simple-git-hooks",e4="simple-git-hooks",e3="@eslint/config-inspector",e5="eslint-config-inspector",e8="node-modules-inspector",e6="node-modules-inspector",e7="migrate-mongo",e9="./node_modules/migrate-mongo/bin/migrate-mongo",te={CYBERSKILL_DIRECTORY:ek,WORKING_DIRECTORY:eR,TS_CONFIG:eO(ex),GIT_IGNORE:eO(eG),GIT_HOOK:eO(ej),GIT_COMMIT_MSG:eO(eL),SIMPLE_GIT_HOOKS_JSON:eO(eM),PACKAGE_JSON:eO(eN),PACKAGE_LOCK_JSON:eO(eD),PNPM_LOCK_YAML:eO(ew),NODE_MODULES:eO(eT),MIGRATE_MONGO_CONFIG:eO(eP),LINT_STAGED_CONFIG:eO("".concat(ek,"/configs/lint-staged/index.js")),COMMITLINT_CONFIG:eO("".concat(ek,"/configs/commitlint/index.js")),UNIT_TEST_CONFIG:eO("".concat(ek,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:eO("".concat(ek,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:eO("".concat(ek,"/react/vitest/vitest.e2e.js"))};function tt(e){var t=e.isCurrentProject;return v({"pre-commit":eJ,"commit-msg":eV},t&&{"pre-push":tP("".concat(eZ," pull"))})}M(tt,"createGitHooksConfig");function tn(e,t,n){return i(function(){return D(this,function(r){switch(r.label){case 0:if(!t)throw new Error("'first' argument is undefined");switch(e){case ed.CLI:return[3,1];case ed.STRING:return[3,3]}return[3,4];case 1:return[4,tI(t.split(" "),{update:!0})];case 2:return[2,(r.sent(),tU(tP("".concat(e1," ").concat(n))))];case 3:return[2,tU(tP(t))];case 4:throw new Error("Unsupported command type");case 5:return[2]}})})()}M(tn,"buildCommand");function tr(e,t,n){return function(){return i(function(){return D(this,function(r){return[2,tn(e,t,n)]})})()}}M(tr,"commandFactory");var ts={simpleGitHooks:tr(ed.CLI,e2,e4),eslintInspect:tr(ed.CLI,e3,e5),nodeModulesInspect:tr(ed.CLI,e8,e6),eslintCheck:tr(ed.CLI,eq,"".concat(eK," ").concat(te.WORKING_DIRECTORY," --no-cache")),eslintFix:tr(ed.CLI,eq,"".concat(eK," ").concat(te.WORKING_DIRECTORY," --fix --no-cache")),typescriptCheck:tr(ed.CLI,e$,"".concat(eX," -p ").concat(te.TS_CONFIG," --noEmit")),configureGitHook:tr(ed.STRING,"".concat(eZ," config core.hooksPath ").concat(te.GIT_HOOK)),testUnit:tr(ed.CLI,eB,"".concat(eY," --config ").concat(te.UNIT_TEST_CONFIG)),testE2e:tr(ed.CLI,"".concat(eB," ").concat(eH),"".concat(eY," --config ").concat(te.E2E_TEST_CONFIG)),mongoMigrateCreate:M(function(e){return tr(ed.CLI,e7,"".concat(ez," ").concat(e9," create ").concat(e," -f ").concat(te.MIGRATE_MONGO_CONFIG))()},"mongoMigrateCreate"),mongoMigrateUp:tr(ed.CLI,e7,"".concat(ez," ").concat(e9," up -f ").concat(te.MIGRATE_MONGO_CONFIG)),mongoMigrateDown:tr(ed.CLI,e7,"".concat(ez," ").concat(e9," down -f ").concat(te.MIGRATE_MONGO_CONFIG)),commitLint:tr(ed.CLI,eW,"".concat(eV," --edit ").concat(te.GIT_COMMIT_MSG," --config ").concat(te.COMMITLINT_CONFIG)),lintStaged:tr(ed.CLI,eQ,"".concat(eJ," --config ").concat(te.LINT_STAGED_CONFIG)),stageBuildDirectory:tr(ed.STRING,"".concat(eZ," add ").concat(eb)),build:tr(ed.STRING,"".concat(e0," run build")),pnpmInstallStandard:tr(ed.STRING,"".concat(e0," install")),pnpmInstallLegacy:tr(ed.STRING,"".concat(e0," install --legacy-peer-deps")),pnpmInstallForce:tr(ed.STRING,"".concat(e0," install --force"))};var ti=eh,to=eh.lstatSync,ta=eh.readdirSync,tc=eh.mkdirSync,tu=eh.readFileSync,tl=eh.unlinkSync,td=eh.statSync,tf=eh.readJsonSync;function tp(e,t,n){eh.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}M(tp,"writeFileSync");function tm(e,t,n){eh.appendFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}M(tm,"appendFileSync");function tg(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return eh.pathExistsSync(e)})}M(tg,"pathExistsSync");function tE(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}t.forEach(function(e){tg(e)&&eh.removeSync(e)})}M(tE,"removeSync");function th(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r=n.extensions,s=O(n,["extensions"]);eh.copySync(e,t,v({filter:M(function(e){return td(e).isDirectory()||!r||r.length===0?!0:r.includes(eS.extname(e))},"filter")},s))}M(th,"copySync");var tv=ee();function ty(e){var t=eI(tv.CWD,eN);if(!tg(t))return!1;try{var n=tf(t),r=n.name,s=n.dependencies,i=s===void 0?{}:s,o=n.devDependencies,a=o===void 0?{}:o,c=r===e,u=e in i,l=e in a;return c||u||l?{path:t,file:n,isCurrentProject:c,isDepend:u,isDevDepend:l}:!1}catch(e){return ei.warn("Failed to read package.json: ".concat(e.message)),!1}}M(ty,"getPackage");function tS(e){return i(function(){var t,n,r,s;return D(this,function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);return[4,eE("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=i.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:n=i.sent(),r=n.version;return[2,r];case 3:s=i.sent();throw ei.error('Failed to fetch version for "'.concat(e,'": ').concat(s.message)),s;case 4:return[2]}})})()}M(tS,"getLatestPackageVersion");function tO(e,t){return i(function(){var n,r,s,i,o,a,c,u,l,d,f,p,m,g,E,h,y,S,O,_,I;return D(this,function(C){switch(C.label){case 0:C.trys.push([0,4,,5]);n=ty(e);if(!n)return[2,v({},eg)];c=n.path,u=n.file,l=n.isCurrentProject,d=n.isDepend,f=n.isDevDepend,p=(r=u.dependencies)!==null&&r!==void 0?r:{},m=(s=u.devDependencies)!==null&&s!==void 0?s:{},g=l?(i=u.version)!==null&&i!==void 0?i:"0.0.0":d?(o=p[e])!==null&&o!==void 0?o:"0.0.0":f?(a=m[e])!==null&&a!==void 0?a:"0.0.0":"0.0.0";if(!l)return[3,1];y=g;return[3,3];case 1:return[4,tS(e)];case 2:y=C.sent();C.label=3;case 3:E=y,h=l||g===E;if(!h&&(t===null||t===void 0?void 0:t.update)){;O=d?"dependencies":f?"devDependencies":null;O&&((S=u[O])===null||S===void 0?void 0:S[e])!==E&&(u[O]=(_=u[O])!==null&&_!==void 0?_:{},u[O][e]=E,tp(c,JSON.stringify(u,null,4)),ei.info('Updated "'.concat(e,'" to version ').concat(E)))}return[2,{isCurrentProject:l,installedPath:c,file:u,isUpToDate:h}];case 4:I=C.sent();return[2,(ei.error('Error checking package "'.concat(e,'": ').concat(I.message)),v({},eg))];case 5:return[2]}})})()}M(tO,"checkPackage");function t_(){return i(function(){var e,t,n,r,s,i,o,a,c,u,l,d;return D(this,function(f){switch(f.label){case 0:e=[{command:M(function(){return ts.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:M(function(){return ts.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:M(function(){return ts.pnpmInstallForce()},"command"),message:"Retrying with force install"}];t=true,n=false,r=undefined;f.label=1;case 1:f.trys.push([1,9,10,11]);s=e[Symbol.iterator]();f.label=2;case 2:if(!!(t=(i=s.next()).done))return[3,8];o=i.value,a=o.command,c=o.message;f.label=3;case 3:f.trys.push([3,6,,7]);return[4,a()];case 4:u=f.sent();return[4,tq("".concat(c," using: ").concat(u),u)];case 5:f.sent();return[2];case 6:l=f.sent();ei.warn("Installation attempt failed: ".concat(c)),ei.error("Details: ".concat(l.message));return[3,7];case 7:t=true;return[3,2];case 8:return[3,11];case 9:d=f.sent();n=true;r=d;return[3,11];case 10:try{if(!t&&s.return!=null){s.return()}}finally{if(n){throw r}}return[7];case 11:throw new Error("All dependency installation strategies failed.")}})})()}M(t_,"installDependencies");function tI(e,t){return i(function(){var n,r,s,i,o,a,c,u,l,d,f;return D(this,function(p){switch(p.label){case 0:if(!tg(te.PACKAGE_JSON)){ei.error("package.json not found. Aborting setup.");return[2]}p.label=1;case 1:p.trys.push([1,13,,14]);n=A(new Set(e)).sort();return[4,Promise.all(n.map(function(e){return tO(e,v({},(t===null||t===void 0?void 0:t.update)&&{update:t.update}))}))];case 2:r=p.sent().every(function(e){return e.isUpToDate});if(r)return[3,4];return[4,t_()];case 3:r=p.sent();p.label=4;case 4:r;i=true,o=false,a=undefined;p.label=5;case 5:p.trys.push([5,10,11,12]);c=((s=t===null||t===void 0?void 0:t.postInstallActions)!==null&&s!==void 0?s:[])[Symbol.iterator]();p.label=6;case 6:if(!!(i=(u=c.next()).done))return[3,9];l=u.value;return[4,l()];case 7:p.sent();p.label=8;case 8:i=true;return[3,6];case 9:return[3,12];case 10:d=p.sent();o=true;a=d;return[3,12];case 11:try{if(!i&&c.return!=null){c.return()}}finally{if(o){throw a}}return[7];case 12:return[3,14];case 13:f=p.sent();throw ei.error('Failed to setup "'.concat(e.join(", "),'": ').concat(f.message)),f;case 14:return[2]}})})()}M(tI,"setupPackages");import tC from"node-persist";var tR=ee();function tA(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:e=tC.defaultInstance;if(e)return[3,2];return[4,tC.init({dir:tR.CYBERSKILL_STORAGE_DIRECTORY,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}M(tA,"initNodePersist");var tT={get:function e(e){return i(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tA()];case 1:r.sent();return[4,tC.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,(ei.error('[Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 4:return[2]}})})()},set:function e(e,t){return i(function(){var n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tA()];case 1:r.sent();return[4,tC.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();ei.error('[Storage:set] Error setting key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return i(function(){var t;return D(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tA()];case 1:n.sent();return[4,tC.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();ei.error('[Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return i(function(){var e,t;return D(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tA()];case 1:n.sent();return[4,tC.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(ei.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,(ei.error("[Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return i(function(){return D(this,function(t){try{return[2,"".concat(tR.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,(ei.error("[Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var tb=ee(),tN=em.promisify(ef);function tD(e){return"error_list:".concat(e)}M(tD,"getErrorListKey");function tx(e){return i(function(){var t,n,r;return D(this,function(s){switch(s.label){case 0:if(e.length===0)return[2];t=Date.now(),n=tD(t);s.label=1;case 1:s.trys.push([1,3,,4]);return[4,tT.set(n,{errors:e,timestamp:t})];case 2:s.sent(),setTimeout(function(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:return[4,tT.getLogLink(n)];case 1:e=t.sent();e&&ei.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},10);return[3,4];case 3:r=s.sent();ei.error("Failed to save errors: ".concat(r.message));return[3,4];case 4:return[2]}})})()}M(tx,"saveErrorListToStorage");function tG(){return i(function(){var e,t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tT.keys()];case 1:e=r.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(function(e){return i(function(){var t;return D(this,function(n){switch(n.label){case 0:return[4,tT.get(e)];case 1:return[2,((t=n.sent())===null||t===void 0?void 0:t.errors)||[]]}})})()}))];case 2:return[2,r.sent().flat()];case 3:n=r.sent();return[2,(ei.error("Failed to retrieve stored errors: ".concat(n.message)),[])];case 4:return[2]}})})()}M(tG,"getStoredErrorLists");function tM(){return i(function(){var e,t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tT.keys()];case 1:e=r.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(function(e){return tT.remove(e)}))];case 2:r.sent();return[3,4];case 3:n=r.sent();ei.error("Failed to clear error lists: ".concat(n.message));return[3,4];case 4:return[2]}})})()}M(tM,"clearAllErrorLists");function tw(e){var t=[],n=[],r="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,i=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,o=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var a,c,u,l,d;var f=s.exec(e)||[],p=i.exec(e)||[],m=o.exec(e)||[];var g,E,h,v,y,S;f.length&&r?t.push({file:r,position:"".concat(f[1],":").concat(f[2]),type:f[3]===F.Error?F.Error:F.Warning,message:(g=f===null||f===void 0?void 0:(a=f[4])===null||a===void 0?void 0:a.trim())!==null&&g!==void 0?g:"",rule:(E=f===null||f===void 0?void 0:(c=f[5])===null||c===void 0?void 0:c.trim())!==null&&E!==void 0?E:""}):p.length?t.push({file:(h=p===null||p===void 0?void 0:p[1])!==null&&h!==void 0?h:"",position:"".concat(p[2],":").concat(p[3]),type:p[4]===F.Error?F.Error:F.Warning,message:(v=p===null||p===void 0?void 0:(u=p[5])===null||u===void 0?void 0:u.trim())!==null&&v!==void 0?v:""}):m.length?t.push({file:"commitlint",type:F.Error,message:(y=m===null||m===void 0?void 0:(l=m[1])===null||l===void 0?void 0:l.trim())!==null&&y!==void 0?y:"",rule:(S=m===null||m===void 0?void 0:(d=m[2])===null||d===void 0?void 0:d.trim())!==null&&S!==void 0?S:""}):n.push(e.trim())}}),t.length&&tx(t),tb.DEBUG&&n.length&&(ei.warn("Unmatched lines:"),n.forEach(function(e){return ei.info(" ".concat(e))}))}M(tw,"parseTextErrors");function tj(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,s=e.line,i=e.column,o=e.ruleId,a=e.message;n.push({type:r===2?F.Error:F.Warning,file:t,position:"".concat(s,":").concat(i),rule:o,message:a})})}),n.length&&tx(n)}catch(t){tw(e)}}M(tj,"parseCommandOutput");function tL(e){return i(function(e){var t,n,r,s,i,o,a,c,u;var l=arguments;return D(this,function(d){switch(d.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:tj;n=new AbortController;ep.on("SIGINT",function(){ei.warn("Process interrupted. Terminating..."),n.abort(),ep.exit()});d.label=1;case 1:d.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,tN(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=d.sent(),s=r.stdout,i=r.stderr;[s,i].forEach(function(e){return e&&t(e)});d.label=3;case 3:return[3,5];case 4:o=d.sent();a=o.stdout,c=o.stderr,u=o.message;[a,c].forEach(function(e){return e&&t(e)}),!c&&!a&&ei.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}M(tL,"executeCommand");function tP(e){return{raw:!0,cmd:e}}M(tP,"rawCommand");function tk(e,t){return(t===null||t===void 0?void 0:t.isRemote)?"".concat(e1," ").concat(eA," ").concat(e):(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(e1," ").concat(ez," ").concat(eF," ").concat(e):"".concat(e1," ").concat(eU," ").concat(e)}M(tk,"formatCLI");function tU(e,t){return typeof e=="function"?tk(e(t),t):(typeof e==="undefined"?"undefined":T(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?tk(e,t):e}M(tU,"formatCommand");function tF(e){return i(function(e){var t,n,r,s,i,o,a;var c=arguments;return D(this,function(u){switch(u.label){case 0:t=c.length>1&&c[1]!==void 0?c[1]:{};r=(n=t===null||t===void 0?void 0:t.isRemote)!==null&&n!==void 0?n:!1;if(!r)return[3,1];a=!1;return[3,3];case 1:return[4,tO(eA)];case 2:a=u.sent().isCurrentProject;u.label=3;case 3:s=a,i={isRemote:r,isCurrentProject:s},o=typeof e=="function"?e(i):e;return[2,Object.fromEntries(Object.entries(o).map(function(e){var t=R(e,2),n=t[0],r=t[1];return[n,tU(r,i)]}))]}})}).apply(this,arguments)}M(tF,"resolveCommands");function tq(e,t){return i(function(){var n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);ei.start("".concat(e)),tb.DEBUG&&ei.info("→ ".concat(t));return[4,tL(t)];case 1:r.sent(),ei.success("".concat(e," done."));return[3,3];case 2:n=r.sent();throw ei.error("".concat(e," failed: ").concat(n.message)),n;case 3:return[2]}})})()}M(tq,"runCommand");function tK(){return i(function(){var e,t;return D(this,function(n){switch(n.label){case 0:if(!tg(te.TS_CONFIG))return[3,3];t=["Performing TypeScript validation"];return[4,ts.typescriptCheck()];case 1:return[4,tq.apply(void 0,t.concat([n.sent()]))];case 2:e=n.sent();return[3,4];case 3:e=ei.warn("No TypeScript configuration found. Skipping type check.");n.label=4;case 4:e;return[2]}})})()}M(tK,"checkTypescript");function tB(){return i(function(){var e,t,n,r;var s=arguments;return D(this,function(i){switch(i.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:!1;if(!e)return[3,3];n=["Running ESLint with auto-fix"];return[4,ts.eslintFix()];case 1:return[4,tq.apply(void 0,n.concat([i.sent()]))];case 2:t=i.sent();return[3,6];case 3:r=["Running ESLint check"];return[4,ts.eslintCheck()];case 4:return[4,tq.apply(void 0,r.concat([i.sent()]))];case 5:t=i.sent();i.label=6;case 6:t;return[2]}})}).apply(this,arguments)}M(tB,"checkEslint");function tH(e,t){if(!t.length)return;var n=e==="Errors"?"red":"yellow";ei.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",t,n)}M(tH,"printIssues");function tY(){return i(function(){var e,t,n;return D(this,function(r){switch(r.label){case 0:return[4,tG()];case 1:e=r.sent(),t=e.filter(function(e){return e.type===F.Error}),n=e.filter(function(e){return e.type===F.Warning});!t.length&&!n.length?ei.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(tH("Warnings",n),tH("Errors",t),(t.length>0||n.length>0)&&ea.exit(1));return[2]}})})()}M(tY,"showCheckResult");function tW(){return i(function(){var e,t,n,r,s,i;return D(this,function(o){switch(o.label){case 0:return[4,tM()];case 1:o.sent();return[4,tO(eA)];case 2:e=o.sent(),t=e.isCurrentProject;if(!t)return[3,9];o.label=3;case 3:o.trys.push([3,8,,9]);n=["Building package: ".concat(eA)];return[4,ts.build()];case 4:return[4,tq.apply(void 0,n.concat([o.sent()]))];case 5:o.sent();r=["Staging build artifacts"];return[4,ts.stageBuildDirectory()];case 6:return[4,tq.apply(void 0,r.concat([o.sent()]))];case 7:o.sent();return[3,9];case 8:s=o.sent();throw ei.error("Error building and staging ".concat(eA,": ").concat(s.message)),s;case 9:i=["Executing lint-staged"];return[4,ts.lintStaged()];case 10:return[4,tq.apply(void 0,i.concat([o.sent()]))];case 11:o.sent(),tY();return[2]}})})()}M(tW,"lintStaged");function tV(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:e=["Inspecting ESLint configuration"];return[4,ts.eslintInspect()];case 1:return[4,tq.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}M(tV,"inspectLint");function tQ(){return i(function(){return D(this,function(e){switch(e.label){case 0:return[4,tM()];case 1:e.sent();return[4,Promise.all([tK(),tB()])];case 2:e.sent(),tY();return[2]}})})()}M(tQ,"lintCheck");function tJ(){return i(function(){return D(this,function(e){switch(e.label){case 0:return[4,tM()];case 1:e.sent();return[4,Promise.all([tK(),tB(!0)])];case 2:e.sent(),tY();return[2]}})})()}M(tJ,"lintFix");function t$(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:return[4,tM()];case 1:t.sent();e=["Validating commit message"];return[4,ts.commitLint()];case 2:return[4,tq.apply(void 0,e.concat([t.sent()]))];case 3:t.sent(),tY();return[2]}})})()}M(t$,"commitLint");function tX(){return i(function(){var e,t,n,r;return D(this,function(s){switch(s.label){case 0:e=["Configuring Git hooks"];return[4,ts.configureGitHook()];case 1:return[4,tq.apply(void 0,e.concat([s.sent()]))];case 2:s.sent(),tE(te.GIT_HOOK);return[4,tF(tt)];case 3:t=s.sent();tp(te.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(t,null,4));n="\n".concat(eM,"\n");tg(te.GIT_IGNORE)?tu(te.GIT_IGNORE,"utf-8").split("\n").includes(eM)||tm(te.GIT_IGNORE,n):tp(te.GIT_IGNORE,n);r=["Setting up simple-git-hooks"];return[4,ts.simpleGitHooks()];case 4:return[4,tq.apply(void 0,r.concat([s.sent()]))];case 5:s.sent();return[2]}})})()}M(tX,"setupGitHook");function tz(){return i(function(){return D(this,function(e){switch(e.label){case 0:return[4,tI([eA],{update:!0,postInstallActions:[tX]})];case 1:e.sent();return[2]}})})()}M(tz,"setup");function tZ(){return i(function(){return D(this,function(e){switch(e.label){case 0:tE(te.NODE_MODULES,te.PNPM_LOCK_YAML);return[4,t_()];case 1:e.sent();return[4,tX()];case 2:e.sent();return[2]}})})()}M(tZ,"reset");function t0(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:e=["Inspecting project dependencies"];return[4,ts.nodeModulesInspect()];case 1:return[4,tq.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}M(t0,"inspect");function t1(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:e=["Running unit tests"];return[4,ts.testUnit()];case 1:return[4,tq.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}M(t1,"testUnit");function t2(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:e=["Running end-to-end tests"];return[4,ts.testE2e()];case 1:return[4,tq.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}M(t2,"testE2E");function t4(e){return i(function(){var t;return D(this,function(n){switch(n.label){case 0:t=["Creating MongoDB migration"];return[4,ts.mongoMigrateCreate(e)];case 1:return[4,tq.apply(void 0,t.concat([n.sent()]))];case 2:n.sent();return[2]}})})()}M(t4,"mongoMigrateCreate");function t3(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:e=["Running MongoDB migrations"];return[4,ts.mongoMigrateUp()];case 1:return[4,tq.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}M(t3,"mongoMigrateUp");function t5(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:e=["Rolling back MongoDB migration"];return[4,ts.mongoMigrateDown()];case 1:return[4,tq.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}M(t5,"mongoMigrateDown");(function(){return i(function(){var e;return D(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,eu(ec(ea.argv)).scriptName(eU).usage("$0 <command> [options]").command("lint","Check code for linting issues",tQ).command("lint:fix","Fix linting issues automatically",tJ).command("lint:inspect","View active ESLint configuration",tV).command("lint-staged","Run lint checks on staged files",tW).command("commitlint","Validate commit message format",t$).command("setup","Initialize project setup and dependencies",tz).command("reset","Reset the project and reinstall dependencies",tZ).command("inspect","Analyze installed project dependencies",t0).command("test:unit","Run unit test suite",t1).command("test:e2e","Run end-to-end test suite",t2).command("mongo:migrate:create <name>","Create a MongoDB migration",function(e){return e.positional("name",{describe:"Migration name",type:"string"})},function(e){return i(function(){return D(this,function(t){switch(t.label){case 0:if(!e.name){ei.error("Migration name is required.");return[2]}return[4,t4(e.name)];case 1:t.sent();return[2]}})})()}).command("mongo:migrate:up","Apply all MongoDB migrations",t3).command("mongo:migrate:down","Rollback last MongoDB migration",t5).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(el.version).epilog('\uD83D\uDCA1 Tip: Use "--help" with any command to see options\n').parse()];case 1:t.sent();return[3,3];case 2:e=t.sent();ei.error("Fatal: ".concat(e.message)),ea.exit(1);return[3,3];case 3:return[2]}})})()})();import{Router as t8}from"express";import{NestFactory as t6}from"@nestjs/core";import t7 from"body-parser";import t9 from"compression";import ne from"cookie-parser";import nt from"cors";import nn from"express";import nr from"express-session";import ns from"express-useragent";function ni(e){var t=e.isDev,n=e.whiteList,r=O(e,["isDev","whiteList"]);return v({origin:M(function(e,r){t||(n===null||n===void 0?void 0:n.includes(e!==null&&e!==void 0?e:""))?r(null,!0):r(new Error("Not allowed by CORS"),!1)},"origin"),credentials:!0},r)}M(ni,"createCorsOptions");function no(e){return nt(ni(e))}M(no,"createCors");function na(e){return nr(e)}M(na,"createSession");function nc(e){var t=nn();return t.set("trust proxy",1),t.use(ne()),t.use(nn.urlencoded({extended:!0})),t.use(t9()),t.use(ns.express()),(e===null||e===void 0?void 0:e.staticFolder)&&t.use(nn.static(e.staticFolder)),t}M(nc,"createExpress");function nu(e){return i(function(){var t,n,r;return D(this,function(s){switch(s.label){case 0:return[4,t6.create(e.module)];case 1:r=s.sent();return[2,(r.getHttpAdapter().getInstance().set("trust proxy",1),r.use(nn.urlencoded({extended:!0})),r.use(ne()),r.use(t9()),r.use(ns.express()),e.staticFolder&&r.use(nn.static(e.staticFolder)),e.filters&&(t=r).useGlobalFilters.apply(t,A(e.filters)),e.pipes&&(n=r).useGlobalPipes.apply(n,A(e.pipes)),r)]}})})()}M(nu,"createNest");var nl="MONGO_MIGRATE_OPTIONS";import{Collection as nd,Db as nf}from"mongodb";import{Document as np,Model as nm}from"mongoose";var ng=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(nf);M(ng,"C_Db");var nE=ng,nh=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(np);M(nh,"C_Document");var nv=nh,ny=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(nm);M(ny,"C_Model");var nS=ny,nO=/*#__PURE__*/function(e){"use strict";f(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(nd);M(nO,"C_Collection");var n_=nO;import{format as nI}from"date-fns";import nC from"migrate-mongo";import{Document as nR}from"mongoose";import nA from"mongoose-aggregate-paginate-v2";import nT from"mongoose-paginate-v2";import{v4 as nb}from"uuid";import nN from"unorm";var nD={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},nx=Object.entries(nD).reduce(function(e,t){var n=R(t,2),r=n[0],s=n[1];return e[r.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function nG(e){return(typeof e==="undefined"?"undefined":T(e))=="object"&&e!==null&&!Array.isArray(e)}M(nG,"isObject");import nM from"crypto-js";import nw from"slugify";var nj=nw.default||nw;function nL(e,t){var n=M(function(e){var n,r;return nj(e!==null&&e!==void 0?e:"",v({lower:(n=t===null||t===void 0?void 0:t.lower)!==null&&n!==void 0?n:!0,locale:(r=t===null||t===void 0?void 0:t.locale)!==null&&r!==void 0?r:"vi"},t))},"slugifyWithOptions");if(nG(e)){var r={};var s=true,i=false,o=undefined;try{for(var a=Object.entries(e)[Symbol.iterator](),c;!(s=(c=a.next()).done);s=true){var u=R(c.value,2),l=u[0],d=u[1];r[l]=n(d)}}catch(e){i=true;o=e}finally{try{if(!s&&a.return!=null){a.return()}}finally{if(i){throw o}}}return r}return n(e)}M(nL,"generateSlug");function nP(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return nM.SHA256(e).toString(nM.enc.Hex).slice(0,t)}M(nP,"generateShortId");var nk={isEmpty:function e(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":T(e))=="object"?p(e,Date)?!1:p(e,Map)||p(e,Set)?e.size===0:p(e,WeakMap)||p(e,WeakSet)?!0:ArrayBuffer.isView(e)?e.byteLength===0:Object.keys(e).length===0:!1},isValidIP:function e(e){var t=e.split(".");return t.length===4&&t.every(function(e){return/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255})?!0:/^(([a-f\d]{1,4}:){7}[a-f\d]{1,4}|((?:[a-f\d]{1,4}:){1,7}:)|((?:[a-f\d]{1,4}:){1,6}:[a-f\d]{1,4})|::)$/i.test(e)}};var nU={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return nI(e,"yyyy-MM-dd HH:mm:ss.SSS")},createGenericFields:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.returnDateAs,n=t===void 0?"string":t;var r=n==="string"?nU.getDateTime():new Date;return{id:nb(),isDel:!1,createdAt:r,updatedAt:r}},applyPlugins:function e(e,t){t.filter(function(e){return typeof e=="function"}).forEach(function(t){return e.plugin(t)})},applyMiddlewares:function e(e,t){t.forEach(function(t){var n=t.method,r=t.pre,s=t.post;n&&r&&e.pre(n,r),n&&s&&e.post(n,s)})},createGenericSchema:function e(e){return new e.Schema({id:{type:String,default:nb,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})},createSchema:function e(e){var t=e.mongoose,n=e.schema,r=e.virtuals,s=r===void 0?[]:r,i=e.standalone,o=i===void 0?!1:i;var a=new t.Schema(n,{strict:!0});return s.forEach(function(e){var t=e.name,n=e.options,r=e.get;var s=a.virtual(t,n);r&&s.get(r)}),o||a.add(nU.createGenericSchema(t)),a},createModel:function e(e){var t=e.mongoose,n=e.name,r=e.schema,s=e.pagination,i=s===void 0?!1:s,o=e.aggregate,a=o===void 0?!1:o,c=e.virtuals,u=c===void 0?[]:c,l=e.middlewares,d=l===void 0?[]:l;if(!n)throw new Error("Model name is required.");if(t.models[n])return t.models[n];var f=nU.createSchema({mongoose:t,schema:r,virtuals:u});return nU.applyPlugins(f,[i&&nT,a&&nA]),nU.applyMiddlewares(f,d),t.model(n,f)},validator:{isEmpty:function e(){return function(e){return i(function(){return D(this,function(t){return[2,!nk.isEmpty(e)]})})()}},isUnique:function e(e){return function(t){return i(function(){var n;return D(this,function(r){switch(r.label){case 0:if(!Array.isArray(e)||e.length===0)throw new Error("Fields must be a non-empty array of strings.");n={$or:e.map(function(e){return l({},e,t)})};return[4,this.constructor.exists(n)];case 1:return[2,!r.sent()]}})}).call(this)}},matchesRegex:function e(e){return function(t){return i(function(){return D(this,function(n){if(!Array.isArray(e)||e.some(function(e){return!p(e,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,e.every(function(e){return e.test(t)})]})})()}}},migrate:S(v({},nC),{setConfig:M(function(e){var t="// This file is automatically generated by the Cyberskill CLI.\nmodule.exports = ".concat(JSON.stringify(e,null,4));tp(te.MIGRATE_MONGO_CONFIG,t);var n="\n".concat(eP,"\n");tg(te.GIT_IGNORE)?tu(te.GIT_IGNORE,"utf-8").split("\n").includes(eP)||tm(te.GIT_IGNORE,n):tp(te.GIT_IGNORE,n)},"setConfig")})},nF=/*#__PURE__*/function(){"use strict";function e(t,n){a(this,e);w(this,"collection");this.collection=t.collection(n)}u(e,[{key:"createOne",value:function e(e){return i(function(){var t,n,r;return D(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=v({},nU.createGenericFields(),e);n={success:!0,message:"Document created successfully"};return[4,this.collection.insertOne(t)];case 1:return[2,(n.result=s.sent(),n)];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return i(function(){var t,n,r;return D(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=e.map(function(e){return v({},nU.createGenericFields(),e)});return[4,this.collection.insertMany(t)];case 1:n=s.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:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"findOne",value:function e(e){return i(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.findOne(e)];case 1:t=r.sent();return[2,t?{success:!0,message:"Document found",result:t}:{success:!1,message:"Document not found"}];case 2:n=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}},{key:"findAll",value:function e(){return i(function(){var e,t,n;var r=arguments;return D(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0,message:"Documents retrieved successfully"};return[4,this.collection.find(e).toArray()];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message}];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return i(function(){var e,t,n;var r=arguments;return D(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0,message:"Count retrieved successfully"};return[4,this.collection.countDocuments(e)];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(e,t){return i(function(){var n,r;return D(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,this.collection.updateOne(e,{$set:t})];case 1:n=s.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document updated successfully",result:n}];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"updateMany",value:function e(e,t){return i(function(){var n,r;return D(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,this.collection.updateMany(e,{$set:t})];case 1:n=s.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents updated successfully",result:n}];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"deleteOne",value:function e(e){return i(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.deleteOne(e)];case 1:t=r.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=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}},{key:"deleteMany",value:function e(e){return i(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.deleteMany(e)];case 1:t=r.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=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}}]);return e}();M(nF,"MongoController");var nq=nF,nK=/*#__PURE__*/function(){"use strict";function e(t){a(this,e);w(this,"model");this.model=t}u(e,[{key:"getModelName",value:function e(){return this.model.modelName}},{key:"findOne",value:function e(e){return i(function(){var e,t,n,r,s,i,o;var a=arguments;return D(this,function(c){switch(c.label){case 0:e=a.length>0&&a[0]!==void 0?a[0]:{},t=a.length>1&&a[1]!==void 0?a[1]:{},n=a.length>2&&a[2]!==void 0?a[2]:{},r=a.length>3?a[3]:void 0;c.label=1;case 1:c.trys.push([1,3,,4]);s=this.model.findOne(e,t,n);r&&s.populate(r);return[4,s.exec()];case 2:i=c.sent();return[2,i?{success:!0,result:i}:{success:!1,message:"No ".concat(this.getModelName()," found."),code:et.NOT_FOUND.CODE}];case 3:o=c.sent();return[2,{success:!1,message:o.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findAll",value:function e(e){return i(function(){var e,t,n,r,s,i,o;var a=arguments;return D(this,function(c){switch(c.label){case 0:e=a.length>0&&a[0]!==void 0?a[0]:{},t=a.length>1&&a[1]!==void 0?a[1]:{},n=a.length>2&&a[2]!==void 0?a[2]:{},r=a.length>3?a[3]:void 0;c.label=1;case 1:c.trys.push([1,3,,4]);s=this.model.find(e,t,n);r&&s.populate(r);i={success:!0};return[4,s.exec()];case 2:return[2,(i.result=c.sent(),i)];case 3:o=c.sent();return[2,{success:!1,message:o.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPaging",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return D(this,function(i){switch(i.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};i.label=1;case 1:i.trys.push([1,3,,4]);n={success:!0};return[4,this.model.paginate(e,t)];case 2:return[2,(n.result=i.sent(),n)];case 3:r=i.sent();return[2,{success:!1,message:r.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPagingAggregate",value:function e(e){return i(function(e){var t,n,r;var s=arguments;return D(this,function(i){switch(i.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};i.label=1;case 1:i.trys.push([1,3,,4]);n={success:!0};return[4,this.model.aggregatePaginate(this.model.aggregate(e),t)];case 2:return[2,(n.result=i.sent(),n)];case 3:r=i.sent();return[2,{success:!1,message:r.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return i(function(){var e,t,n;var r=arguments;return D(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0};return[4,this.model.countDocuments(e)];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"createOne",value:function e(e){return i(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);t={success:!0};return[4,this.model.create(e)];case 1:return[2,(t.result=r.sent(),t)];case 2:n=r.sent();return[2,{success:!1,message:n.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return i(function(e){var t,n,r;var s=arguments;return D(this,function(i){switch(i.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};i.label=1;case 1:i.trys.push([1,3,,4]);n={success:!0};return[4,this.model.insertMany(e,t)];case 2:return[2,(n.result=i.sent().map(function(e){return p(e,nR)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 3:r=i.sent();return[2,{success:!1,message:r.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(){return i(function(){var e,t,n,r,s;var i=arguments;return D(this,function(o){switch(o.label){case 0:e=i.length>0&&i[0]!==void 0?i[0]:{},t=i.length>1&&i[1]!==void 0?i[1]:{},n=i.length>2&&i[2]!==void 0?i[2]:{};o.label=1;case 1:o.trys.push([1,3,,4]);return[4,this.model.findOneAndUpdate(e,t,v({new:!0},n)).exec()];case 2:r=o.sent();return[2,r?{success:!0,result:r}:{success:!1,message:"Failed to update ".concat(this.getModelName(),"."),code:et.NOT_FOUND.CODE}];case 3:s=o.sent();return[2,{success:!1,message:s.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateMany",value:function e(){return i(function(){var e,t,n,r,s;var i=arguments;return D(this,function(o){switch(o.label){case 0:e=i.length>0&&i[0]!==void 0?i[0]:{},t=i.length>1&&i[1]!==void 0?i[1]:{},n=i.length>2&&i[2]!==void 0?i[2]:{};o.label=1;case 1:o.trys.push([1,3,,4]);r={success:!0};return[4,this.model.updateMany(e,t,n).exec()];case 2:return[2,(r.result=o.sent(),r)];case 3:s=o.sent();return[2,{success:!1,message:s.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteOne",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return D(this,function(i){switch(i.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};i.label=1;case 1:i.trys.push([1,3,,4]);return[4,this.model.findOneAndDelete(e,t).exec()];case 2:n=i.sent();return[2,n?{success:!0,result:n}:{success:!1,message:"No ".concat(this.getModelName()," found to delete."),code:et.NOT_FOUND.CODE}];case 3:r=i.sent();return[2,{success:!1,message:r.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteMany",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return D(this,function(i){switch(i.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};i.label=1;case 1:i.trys.push([1,3,,4]);return[4,this.model.deleteMany(e,t).exec()];case 2:n=i.sent();return[2,n.deletedCount===0?{success:!1,message:"No documents found to delete.",code:et.NOT_FOUND.CODE}:{success:!0,result:n}];case 3:r=i.sent();return[2,{success:!1,message:r.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"createShortId",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return i(function(){var n,r,s,i;return D(this,function(o){switch(o.label){case 0:n=new Set;r=0;o.label=1;case 1:if(!(r<10))return[3,5];s=nP(e,r+t);i=!n.has(s);if(!i)return[3,3];n.add(s);return[4,this.model.exists({shortId:s})];case 2:i=!o.sent();o.label=3;case 3:if(i)return[2,{success:!0,result:s}];o.label=4;case 4:r++;return[3,1];case 5:return[2,{success:!1,message:"Failed to create a unique shortId",code:et.INTERNAL_SERVER_ERROR.CODE}]}})}).call(this)}},{key:"createSlug",value:function e(e,t,n){return i(function(){var r,s,o,a,c,u,d,f,p,m;return D(this,function(g){switch(g.label){case 0:r=this;g.label=1;case 1:g.trys.push([1,5,,6]);s=t[e],o=nG(s),a=M(function(t){var r=v({},n!==null&&n!==void 0?n:{});return o?S(v({},r),{$or:[l({},"slug.".concat(e),t),{slugHistory:{$elemMatch:l({},"slug.".concat(e),t)}}]}):S(v({},r),{$or:[{slug:t},{slugHistory:t}]})},"generateSlugQuery"),c=M(function(e){return i(function(){var t,n;return D(this,function(r){switch(r.label){case 0:t=e,n=1;r.label=1;case 1:return[4,this.model.exists(a(t))];case 2:if(!r.sent())return[3,4];t="".concat(e,"-").concat(n++);r.label=3;case 3:return[3,1];case 4:return[2,t]}})}).call(r)},"generateUniqueSlug");if(!o)return[3,3];u={success:!0};d=Object.fromEntries;return[4,Promise.all(Object.entries(s).map(function(e){var t=R(e,2),n=t[0],r=t[1];return i(function(){var e,t;return D(this,function(s){switch(s.label){case 0:e=nL(r);t=[n];return[4,c(e)];case 1:return[2,t.concat([s.sent()])]}})})()}))];case 2:return[2,(u.result=d.apply(Object,[g.sent()]),u)];case 3:f=nL(s);p={success:!0};return[4,c(f)];case 4:return[2,(p.result=g.sent(),p)];case 5:m=g.sent();return[2,{success:!1,message:"Failed to create a unique slug: ".concat(m.message),code:et.INTERNAL_SERVER_ERROR.CODE}];case 6:return[2]}})}).call(this)}},{key:"aggregate",value:function e(e){return i(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);t={success:!0};return[4,this.model.aggregate(e)];case 1:return[2,(t.result=r.sent(),t)];case 2:n=r.sent();return[2,{success:!1,message:n.message,code:et.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})}).call(this)}}]);return e}();M(nK,"MongooseController");var nB=nK;import{useServer as nH}from"graphql-ws/use/ws";import{WebSocketServer as nY}from"ws";function nW(e){return new nY({server:e.server,path:e.path})}M(nW,"createWSServer");function nV(e){return nH({schema:e.schema},e.server)}M(nV,"initGraphQLWS");export{eb as BUILD_DIRECTORY,eg as CHECK_PACKAGE_EMPTY_RESULT,eV as COMMIT_LINT_CLI,eW as COMMIT_LINT_PACKAGE_NAME,eU as CYBERSKILL_CLI,eF as CYBERSKILL_CLI_PATH,ek as CYBERSKILL_DIRECTORY,eA as CYBERSKILL_PACKAGE_NAME,n_ as C_Collection,nE as C_Db,nv as C_Document,nS as C_Model,eK as ESLINT_CLI,e5 as ESLINT_INSPECT_CLI,e3 as ESLINT_INSPECT_PACKAGE_NAME,eq as ESLINT_PACKAGE_NAME,ed as E_CommandType,F as E_IssueType,eZ as GIT_CLI,eL as GIT_COMMIT_EDITMSG,ej as GIT_HOOK,eG as GIT_IGNORE,eJ as LINT_STAGED_CLI,eQ as LINT_STAGED_PACKAGE_NAME,e9 as MIGRATE_MONGO_CLI,eP as MIGRATE_MONGO_CONFIG,e7 as MIGRATE_MONGO_PACKAGE_NAME,nl as MONGO_MIGRATE_OPTIONS,nq as MongoController,nB as MongooseController,eT as NODE_MODULES,e6 as NODE_MODULES_INSPECT_CLI,e8 as NODE_MODULES_INSPECT_PACKAGE_NAME,eN as PACKAGE_JSON,eD as PACKAGE_LOCK_JSON,te as PATH,eH as PLAYWRIGHT_PACKAGE_NAME,e0 as PNPM_CLI,e1 as PNPM_EXEC_CLI,ew as PNPM_LOCK_YAML,t8 as Router,e2 as SIMPLE_GIT_HOOKS_PACKAGE_NAME,e4 as SIMPLE_GIT_HOOK_CLI,eM as SIMPLE_GIT_HOOK_JSON,ex as TSCONFIG_JSON,eX as TSC_CLI,e$ as TSC_PACKAGE_NAME,ez as TSX_CLI,eY as VITEST_CLI,eB as VITEST_PACKAGE_NAME,eR as WORKING_DIRECTORY,nA as aggregatePaginate,tm as appendFileSync,t7 as bodyParser,tO as checkPackage,tM as clearAllErrorLists,ts as command,th as copySync,eo as createApolloServer,no as createCors,ni as createCorsOptions,nc as createExpress,tt as createGitHooksConfig,nu as createNest,na as createSession,nW as createWSServer,nn as express,L as expressMiddleware,tU as formatCommand,ti as fs,tS as getLatestPackageVersion,ty as getPackage,tG as getStoredErrorLists,nV as initGraphQLWS,t_ as installDependencies,eI as join,ei as logNodeJS,to as lstatSync,tc as mkdirSync,nU as mongo,nT as mongoosePaginate,eS as path,tg as pathExistsSync,tP as rawCommand,tu as readFileSync,tf as readJsonSync,ta as readdirSync,tE as removeSync,e_ as resolve,tF as resolveCommands,eO as resolveWorkingPath,tq as runCommand,tI as setupPackages,td as statSync,tT as storageNodeJS,er as throwError,tl as unlinkSync,tp as writeFileSync};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function s(e,t,n,r,s,a,o){try{var c=e[a](o);var u=c.value}catch(e){n(e);return}if(c.done){t(u)}else{Promise.resolve(u).then(r,s)}}function a(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var o=e.apply(t,n);function c(e){s(o,r,a,c,u,"next",e)}function u(e){s(o,r,a,c,u,"throw",e)}c(undefined)})}}function o(e,t,n){t=f(t);return S(e,b()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}function c(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}function i(e,t,n){if(t)u(e.prototype,t);if(n)u(e,n);return e}function l(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}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,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)R(e,t)}function E(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function h(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function g(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var s=true;var a=false;var o,c;try{for(n=n.call(e);!(s=(o=n.next()).done);s=true){r.push(o.value);if(t&&r.length===t)break}}catch(e){a=true;c=e}finally{try{if(!s&&n["return"]!=null)n["return"]()}finally{if(a)throw c}}return r}function v(){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 t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var r=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}r.forEach(function(t){l(e,t,n[t])})}return e}function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}n.push.apply(n,r)}return n}function y(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{O(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function S(e,t){if(t&&(I(t)==="object"||typeof t==="function")){return t}return r(e)}function R(e,t){R=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return R(e,t)}function _(e,n){return t(e)||g(e,n)||T(e,n)||v()}function C(e){return n(e)||h(e)||T(e)||p()}function I(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function T(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(b=function(){return!!e})()}function A(e,t){var n,r,s,a={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},o=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return o.next=c(0),o["throw"]=c(1),o["return"]=c(2),typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(e){return function(t){return u([e,t])}}function u(c){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,c[0]&&(a=0)),a)try{if(n=1,r&&(s=c[0]&2?r["return"]:c[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;if(r=0,s)c=[c[0]&2,s.value];switch(c[0]){case 0:case 1:s=c;break;case 4:a.label++;return{value:c[1],done:false};case 5:a.label++;r=c[1];c=[0];continue;case 7:c=a.ops.pop();a.trys.pop();continue;default:if(!(s=a.trys,s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){a=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){a.label=c[1];break}if(c[0]===6&&a.label<s[1]){a.label=s[1];s=c;break}if(s&&a.label<s[2]){a.label=s[2];a.ops.push(c);break}if(s[2])a.ops.pop();a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e];r=0}finally{n=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}}var D=Object.create;var N=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var L=function(e,t,n){return t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n};var U=function(e,t){return N(e,"name",{value:t,configurable:!0})};var k=function(e,t){for(var n in t)N(e,n,{get:t[n],enumerable:!0})},F=function(e,t,n,r){var s=true,a=false,o=undefined;if(t&&(typeof t==="undefined"?"undefined":I(t))=="object"||typeof t=="function")try{var c=function(){var s=i.value;!P.call(e,s)&&s!==n&&N(e,s,{get:function(){return t[s]},enumerable:!(r=M(t,s))||r.enumerable})};for(var u=G(t)[Symbol.iterator](),i;!(s=(i=u.next()).done);s=true)c()}catch(e){a=true;o=e}finally{try{if(!s&&u.return!=null){u.return()}}finally{if(a){throw o}}}return e};var j=function(e,t,n){return n=e!=null?D(w(e)):{},F(t||!e||!e.__esModule?N(n,"default",{value:e,enumerable:!0}):n,e)},x=function(e){return F(N({},"__esModule",{value:!0}),e)};var q=function(e,t,n){return L(e,(typeof t==="undefined"?"undefined":I(t))!="symbol"?t+"":t,n)};var Y={};k(Y,{C_Collection:function(){return Z},C_Db:function(){return K},C_Document:function(){return $},C_Model:function(){return X},MONGO_MIGRATE_OPTIONS:function(){return B},MongoController:function(){return t5},MongooseController:function(){return t7},aggregatePaginate:function(){return er.default},mongo:function(){return t4},mongoosePaginate:function(){return es.default}});module.exports=x(Y);var B="MONGO_MIGRATE_OPTIONS";var H=require("mongodb"),V=require("mongoose");var Q=/*#__PURE__*/function(e){d(t,e);function t(){c(this,t);return o(this,t,arguments)}return t}(H.Db);U(Q,"C_Db");var K=Q,W=/*#__PURE__*/function(e){d(t,e);function t(){c(this,t);return o(this,t,arguments)}return t}(V.Document);U(W,"C_Document");var $=W,J=/*#__PURE__*/function(e){d(t,e);function t(){c(this,t);return o(this,t,arguments)}return t}(V.Model);U(J,"C_Model");var X=J,z=/*#__PURE__*/function(e){d(t,e);function t(){c(this,t);return o(this,t,arguments)}return t}(H.Collection);U(z,"C_Collection");var Z=z;var ee=require("date-fns"),et=j(require("migrate-mongo"),1),en=require("mongoose"),er=j(require("mongoose-aggregate-paginate-v2"),1),es=j(require("mongoose-paginate-v2"),1),ea=require("uuid");var eo={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 ec=j(require("unorm"),1);var eu={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},ei=Object.entries(eu).reduce(function(e,t){var n=_(t,2),r=n[0],s=n[1];return e[r.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function el(e){return(typeof e==="undefined"?"undefined":I(e))=="object"&&e!==null&&!Array.isArray(e)}U(el,"isObject");var ef=j(require("crypto-js"),1),ed=j(require("slugify"),1);var eE=ed.default.default||ed.default;function eh(e,t){var n=U(function(e){var n,r;return eE(e!==null&&e!==void 0?e:"",m({lower:(n=t===null||t===void 0?void 0:t.lower)!==null&&n!==void 0?n:!0,locale:(r=t===null||t===void 0?void 0:t.locale)!==null&&r!==void 0?r:"vi"},t))},"slugifyWithOptions");if(el(e)){var r={};var s=true,a=false,o=undefined;try{for(var c=Object.entries(e)[Symbol.iterator](),u;!(s=(u=c.next()).done);s=true){var i=_(u.value,2),l=i[0],f=i[1];r[l]=n(f)}}catch(e){a=true;o=e}finally{try{if(!s&&c.return!=null){c.return()}}finally{if(a){throw o}}}return r}return n(e)}U(eh,"generateSlug");function eg(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return ef.default.SHA256(e).toString(ef.default.enc.Hex).slice(0,t)}U(eg,"generateShortId");var ev={isEmpty:function e(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":I(e))=="object"?E(e,Date)?!1:E(e,Map)||E(e,Set)?e.size===0:E(e,WeakMap)||E(e,WeakSet)?!0:ArrayBuffer.isView(e)?e.byteLength===0:Object.keys(e).length===0:!1},isValidIP:function e(e){var t=e.split(".");return t.length===4&&t.every(function(e){return/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255})?!0:/^(([a-f\d]{1,4}:){7}[a-f\d]{1,4}|((?:[a-f\d]{1,4}:){1,7}:)|((?:[a-f\d]{1,4}:){1,6}:[a-f\d]{1,4})|::)$/i.test(e)}};var ep=j(require("fs-extra"),1);var em=".cyberskill-storage";var eO=j(require("@dotenvx/dotenvx"),1),ey=require("envalid"),eS=j(require("os"),1),eR=j(require("path"),1),e_=j(require("process"),1);var eC=!1;function eI(){eC||(eO.default.config(),eC=!0)}U(eI,"loadEnvFile");function eT(){eI();var e=(0,ey.cleanEnv)(e_.default.env,{CWD:(0,ey.str)({default:e_.default.cwd()}),DEBUG:(0,ey.bool)({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:(0,ey.str)({default:eR.default.join(eS.default.homedir(),em)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}U(eT,"getEnv");var eb=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});var eA=require("child_process"),eD=j(require("process"),1),eN=j(require("util"),1);var eM=function(e){return e.Error="error",e.Warning="warning",e}({});var eG=j(require("chalk"),1),ew=j(require("consola"),1),eP=require("graphql");var eL=eT();eL.DEBUG||(ew.default.level=4);function eU(e){var t=eG.default[e];return typeof t=="function"?t:eG.default.green}U(eU,"chalkKeyword");var ek={silent:ew.default.silent,level:ew.default.level,fatal:ew.default.fatal,error:ew.default.error,warn:ew.default.warn,log:ew.default.log,info:ew.default.info,success:ew.default.success,ready:ew.default.ready,start:ew.default.start,box:ew.default.box,debug:ew.default.debug,trace:ew.default.trace,verbose:ew.default.verbose,printBoxedLog:function e(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){ew.default.box(eG.default.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,s=e.rule,a=e.message;ew.default.log("".concat(eG.default.gray("File:")," ").concat(eG.default.blue("".concat(t).concat(r?":".concat(r):"")))),s&&ew.default.log(" ".concat(eU(n)("Rule:")," ").concat(s)),ew.default.log(" ".concat(eU(n)("Message:")," ").concat(a))}),ew.default.box(eU(n)("".concat(e," : ").concat(t.length))),ew.default.log(eG.default.gray("─".repeat(40)))}};var eF={isCurrentProject:!1,installedPath:"",file:{},isUpToDate:!1};var ej=j(require("node-fetch"),1);var ex=eT();function eq(e){var t=tt(ex.CWD,tc);if(!t2(t))return!1;try{var n=tZ(t),r=n.name,s=n.dependencies,a=s===void 0?{}:s,o=n.devDependencies,c=o===void 0?{}:o,u=r===e,i=e in a,l=e in c;return u||i||l?{path:t,file:n,isCurrentProject:u,isDepend:i,isDevDepend:l}:!1}catch(e){return ek.warn("Failed to read package.json: ".concat(e.message)),!1}}U(eq,"getPackage");function eY(e){return a(function(){var t,n,r,s;return A(this,function(a){switch(a.label){case 0:a.trys.push([0,3,,4]);return[4,(0,ej.default)("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=a.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:n=a.sent(),r=n.version;return[2,r];case 3:s=a.sent();throw ek.error('Failed to fetch version for "'.concat(e,'": ').concat(s.message)),s;case 4:return[2]}})})()}U(eY,"getLatestPackageVersion");function eB(e,t){return a(function(){var n,r,s,a,o,c,u,i,l,f,d,E,h,g,v,p,O,y,S,R,_;return A(this,function(C){switch(C.label){case 0:C.trys.push([0,4,,5]);n=eq(e);if(!n)return[2,m({},eF)];u=n.path,i=n.file,l=n.isCurrentProject,f=n.isDepend,d=n.isDevDepend,E=(r=i.dependencies)!==null&&r!==void 0?r:{},h=(s=i.devDependencies)!==null&&s!==void 0?s:{},g=l?(a=i.version)!==null&&a!==void 0?a:"0.0.0":f?(o=E[e])!==null&&o!==void 0?o:"0.0.0":d?(c=h[e])!==null&&c!==void 0?c:"0.0.0":"0.0.0";if(!l)return[3,1];O=g;return[3,3];case 1:return[4,eY(e)];case 2:O=C.sent();C.label=3;case 3:v=O,p=l||g===v;if(!p&&(t===null||t===void 0?void 0:t.update)){;S=f?"dependencies":d?"devDependencies":null;S&&((y=i[S])===null||y===void 0?void 0:y[e])!==v&&(i[S]=(R=i[S])!==null&&R!==void 0?R:{},i[S][e]=v,t0(u,JSON.stringify(i,null,4)),ek.info('Updated "'.concat(e,'" to version ').concat(v)))}return[2,{isCurrentProject:l,installedPath:u,file:i,isUpToDate:p}];case 4:_=C.sent();return[2,(ek.error('Error checking package "'.concat(e,'": ').concat(_.message)),m({},eF))];case 5:return[2]}})})()}U(eB,"checkPackage");function eH(){return a(function(){var e,t,n,r,s,a,o,c,u,i,l,f;return A(this,function(d){switch(d.label){case 0:e=[{command:U(function(){return tV.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:U(function(){return tV.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:U(function(){return tV.pnpmInstallForce()},"command"),message:"Retrying with force install"}];t=true,n=false,r=undefined;d.label=1;case 1:d.trys.push([1,9,10,11]);s=e[Symbol.iterator]();d.label=2;case 2:if(!!(t=(a=s.next()).done))return[3,8];o=a.value,c=o.command,u=o.message;d.label=3;case 3:d.trys.push([3,6,,7]);return[4,c()];case 4:i=d.sent();return[4,e6("".concat(u," using: ").concat(i),i)];case 5:d.sent();return[2];case 6:l=d.sent();ek.warn("Installation attempt failed: ".concat(u)),ek.error("Details: ".concat(l.message));return[3,7];case 7:t=true;return[3,2];case 8:return[3,11];case 9:f=d.sent();n=true;r=f;return[3,11];case 10:try{if(!t&&s.return!=null){s.return()}}finally{if(n){throw r}}return[7];case 11:throw new Error("All dependency installation strategies failed.")}})})()}U(eH,"installDependencies");function eV(e,t){return a(function(){var n,r,s,a,o,c,u,i,l,f,d;return A(this,function(E){switch(E.label){case 0:if(!t2(tY.PACKAGE_JSON)){ek.error("package.json not found. Aborting setup.");return[2]}E.label=1;case 1:E.trys.push([1,13,,14]);n=C(new Set(e)).sort();return[4,Promise.all(n.map(function(e){return eB(e,m({},(t===null||t===void 0?void 0:t.update)&&{update:t.update}))}))];case 2:r=E.sent().every(function(e){return e.isUpToDate});if(r)return[3,4];return[4,eH()];case 3:r=E.sent();E.label=4;case 4:r;a=true,o=false,c=undefined;E.label=5;case 5:E.trys.push([5,10,11,12]);u=((s=t===null||t===void 0?void 0:t.postInstallActions)!==null&&s!==void 0?s:[])[Symbol.iterator]();E.label=6;case 6:if(!!(a=(i=u.next()).done))return[3,9];l=i.value;return[4,l()];case 7:E.sent();E.label=8;case 8:a=true;return[3,6];case 9:return[3,12];case 10:f=E.sent();o=true;c=f;return[3,12];case 11:try{if(!a&&u.return!=null){u.return()}}finally{if(o){throw c}}return[7];case 12:return[3,14];case 13:d=E.sent();throw ek.error('Failed to setup "'.concat(e.join(", "),'": ').concat(d.message)),d;case 14:return[2]}})})()}U(eV,"setupPackages");var eQ=j(require("node-persist"),1);var eK=eT();function eW(){return a(function(){var e;return A(this,function(t){switch(t.label){case 0:e=eQ.default.defaultInstance;if(e)return[3,2];return[4,eQ.default.init({dir:eK.CYBERSKILL_STORAGE_DIRECTORY,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}U(eW,"initNodePersist");var e$={get:function e(e){return a(function(){var t,n;return A(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,eW()];case 1:r.sent();return[4,eQ.default.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,(ek.error('[Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 4:return[2]}})})()},set:function e(e,t){return a(function(){var n;return A(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,eW()];case 1:r.sent();return[4,eQ.default.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();ek.error('[Storage:set] Error setting key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return a(function(){var t;return A(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,eW()];case 1:n.sent();return[4,eQ.default.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();ek.error('[Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return a(function(){var e,t;return A(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,eW()];case 1:n.sent();return[4,eQ.default.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(ek.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,(ek.error("[Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return a(function(){return A(this,function(t){try{return[2,"".concat(eK.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,(ek.error("[Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var eJ=eT(),eX=eN.promisify(eA.exec);function ez(e){return"error_list:".concat(e)}U(ez,"getErrorListKey");function eZ(e){return a(function(){var t,n,r;return A(this,function(s){switch(s.label){case 0:if(e.length===0)return[2];t=Date.now(),n=ez(t);s.label=1;case 1:s.trys.push([1,3,,4]);return[4,e$.set(n,{errors:e,timestamp:t})];case 2:s.sent(),setTimeout(function(){return a(function(){var e;return A(this,function(t){switch(t.label){case 0:return[4,e$.getLogLink(n)];case 1:e=t.sent();e&&ek.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},10);return[3,4];case 3:r=s.sent();ek.error("Failed to save errors: ".concat(r.message));return[3,4];case 4:return[2]}})})()}U(eZ,"saveErrorListToStorage");function e0(e){var t=[],n=[],r="",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("/"))r=e.trim();else{var c,u,i,l,f;var d=s.exec(e)||[],E=a.exec(e)||[],h=o.exec(e)||[];var g,v,p,m,O,y;d.length&&r?t.push({file:r,position:"".concat(d[1],":").concat(d[2]),type:d[3]===eM.Error?eM.Error:eM.Warning,message:(g=d===null||d===void 0?void 0:(c=d[4])===null||c===void 0?void 0:c.trim())!==null&&g!==void 0?g:"",rule:(v=d===null||d===void 0?void 0:(u=d[5])===null||u===void 0?void 0:u.trim())!==null&&v!==void 0?v:""}):E.length?t.push({file:(p=E===null||E===void 0?void 0:E[1])!==null&&p!==void 0?p:"",position:"".concat(E[2],":").concat(E[3]),type:E[4]===eM.Error?eM.Error:eM.Warning,message:(m=E===null||E===void 0?void 0:(i=E[5])===null||i===void 0?void 0:i.trim())!==null&&m!==void 0?m:""}):h.length?t.push({file:"commitlint",type:eM.Error,message:(O=h===null||h===void 0?void 0:(l=h[1])===null||l===void 0?void 0:l.trim())!==null&&O!==void 0?O:"",rule:(y=h===null||h===void 0?void 0:(f=h[2])===null||f===void 0?void 0:f.trim())!==null&&y!==void 0?y:""}):n.push(e.trim())}}),t.length&&eZ(t),eJ.DEBUG&&n.length&&(ek.warn("Unmatched lines:"),n.forEach(function(e){return ek.info(" ".concat(e))}))}U(e0,"parseTextErrors");function e1(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,s=e.line,a=e.column,o=e.ruleId,c=e.message;n.push({type:r===2?eM.Error:eM.Warning,file:t,position:"".concat(s,":").concat(a),rule:o,message:c})})}),n.length&&eZ(n)}catch(t){e0(e)}}U(e1,"parseCommandOutput");function e2(e){return a(function(e){var t,n,r,s,a,o,c,u,i;var l=arguments;return A(this,function(f){switch(f.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:e1;n=new AbortController;eD.default.on("SIGINT",function(){ek.warn("Process interrupted. Terminating..."),n.abort(),eD.default.exit()});f.label=1;case 1:f.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,eX(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=f.sent(),s=r.stdout,a=r.stderr;[s,a].forEach(function(e){return e&&t(e)});f.label=3;case 3:return[3,5];case 4:o=f.sent();c=o.stdout,u=o.stderr,i=o.message;[c,u].forEach(function(e){return e&&t(e)}),!u&&!c&&ek.error("Command failed: ".concat(i));return[3,5];case 5:return[2]}})}).apply(this,arguments)}U(e2,"executeCommand");function e4(e){return{raw:!0,cmd:e}}U(e4,"rawCommand");function e3(e,t){return(t===null||t===void 0?void 0:t.isRemote)?"".concat(tw," ").concat(ts," ").concat(e):(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(tw," ").concat(tN," ").concat(tm," ").concat(e):"".concat(tw," ").concat(tp," ").concat(e)}U(e3,"formatCLI");function e5(e,t){return typeof e=="function"?e3(e(t),t):(typeof e==="undefined"?"undefined":I(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?e3(e,t):e}U(e5,"formatCommand");function e6(e,t){return a(function(){var n;return A(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);ek.start("".concat(e)),eJ.DEBUG&&ek.info("→ ".concat(t));return[4,e2(t)];case 1:r.sent(),ek.success("".concat(e," done."));return[3,3];case 2:n=r.sent();throw ek.error("".concat(e," failed: ").concat(n.message)),n;case 3:return[2]}})})()}U(e6,"runCommand");var e7=j(require("path"),1);var e8=eT(),e9=e7.default;function te(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=e9).resolve.apply(r,[e8.CWD].concat(C(t)))}U(te,"resolveWorkingPath");function tt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=e9).join.apply(r,C(t))}U(tt,"join");var tn=eT(),tr=tn.CWD,ts="@cyberskill/shared",ta="node_modules",to="dist",tc="package.json",tu="package-lock.json",ti="tsconfig.json",tl=".gitignore",tf=".simple-git-hooks.json",td="pnpm-lock.yaml",tE=".git/hooks/",th=".git/COMMIT_EDITMSG",tg=".migrate-mongo.config.js",tv=tt(tr,ta,ts,to),tp="cyberskill",tm="src/nodejs/cli/index.ts",tO="eslint",ty="eslint",tS="vitest",tR="playwright",t_="vitest",tC="@commitlint/cli",tI="commitlint",tT="lint-staged",tb="lint-staged",tA="typescript",tD="tsc",tN="tsx",tM="git",tG="pnpm",tw="pnpm exec",tP="simple-git-hooks",tL="simple-git-hooks",tU="@eslint/config-inspector",tk="eslint-config-inspector",tF="node-modules-inspector",tj="node-modules-inspector",tx="migrate-mongo",tq="./node_modules/migrate-mongo/bin/migrate-mongo",tY={CYBERSKILL_DIRECTORY:tv,WORKING_DIRECTORY:tr,TS_CONFIG:te(ti),GIT_IGNORE:te(tl),GIT_HOOK:te(tE),GIT_COMMIT_MSG:te(th),SIMPLE_GIT_HOOKS_JSON:te(tf),PACKAGE_JSON:te(tc),PACKAGE_LOCK_JSON:te(tu),PNPM_LOCK_YAML:te(td),NODE_MODULES:te(ta),MIGRATE_MONGO_CONFIG:te(tg),LINT_STAGED_CONFIG:te("".concat(tv,"/configs/lint-staged/index.js")),COMMITLINT_CONFIG:te("".concat(tv,"/configs/commitlint/index.js")),UNIT_TEST_CONFIG:te("".concat(tv,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:te("".concat(tv,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:te("".concat(tv,"/react/vitest/vitest.e2e.js"))};function tB(e,t,n){return a(function(){return A(this,function(r){switch(r.label){case 0:if(!t)throw new Error("'first' argument is undefined");switch(e){case eb.CLI:return[3,1];case eb.STRING:return[3,3]}return[3,4];case 1:return[4,eV(t.split(" "),{update:!0})];case 2:return[2,(r.sent(),e5(e4("".concat(tw," ").concat(n))))];case 3:return[2,e5(e4(t))];case 4:throw new Error("Unsupported command type");case 5:return[2]}})})()}U(tB,"buildCommand");function tH(e,t,n){return function(){return a(function(){return A(this,function(r){return[2,tB(e,t,n)]})})()}}U(tH,"commandFactory");var tV={simpleGitHooks:tH(eb.CLI,tP,tL),eslintInspect:tH(eb.CLI,tU,tk),nodeModulesInspect:tH(eb.CLI,tF,tj),eslintCheck:tH(eb.CLI,tO,"".concat(ty," ").concat(tY.WORKING_DIRECTORY," --no-cache")),eslintFix:tH(eb.CLI,tO,"".concat(ty," ").concat(tY.WORKING_DIRECTORY," --fix --no-cache")),typescriptCheck:tH(eb.CLI,tA,"".concat(tD," -p ").concat(tY.TS_CONFIG," --noEmit")),configureGitHook:tH(eb.STRING,"".concat(tM," config core.hooksPath ").concat(tY.GIT_HOOK)),testUnit:tH(eb.CLI,tS,"".concat(t_," --config ").concat(tY.UNIT_TEST_CONFIG)),testE2e:tH(eb.CLI,"".concat(tS," ").concat(tR),"".concat(t_," --config ").concat(tY.E2E_TEST_CONFIG)),mongoMigrateCreate:U(function(e){return tH(eb.CLI,tx,"".concat(tN," ").concat(tq," create ").concat(e," -f ").concat(tY.MIGRATE_MONGO_CONFIG))()},"mongoMigrateCreate"),mongoMigrateUp:tH(eb.CLI,tx,"".concat(tN," ").concat(tq," up -f ").concat(tY.MIGRATE_MONGO_CONFIG)),mongoMigrateDown:tH(eb.CLI,tx,"".concat(tN," ").concat(tq," down -f ").concat(tY.MIGRATE_MONGO_CONFIG)),commitLint:tH(eb.CLI,tC,"".concat(tI," --edit ").concat(tY.GIT_COMMIT_MSG," --config ").concat(tY.COMMITLINT_CONFIG)),lintStaged:tH(eb.CLI,tT,"".concat(tb," --config ").concat(tY.LINT_STAGED_CONFIG)),stageBuildDirectory:tH(eb.STRING,"".concat(tM," add ").concat(to)),build:tH(eb.STRING,"".concat(tG," run build")),pnpmInstallStandard:tH(eb.STRING,"".concat(tG," install")),pnpmInstallLegacy:tH(eb.STRING,"".concat(tG," install --legacy-peer-deps")),pnpmInstallForce:tH(eb.STRING,"".concat(tG," install --force"))};var tQ=ep.default,tK=tQ.lstatSync,tW=tQ.readdirSync,t$=tQ.mkdirSync,tJ=tQ.readFileSync,tX=tQ.unlinkSync,tz=tQ.statSync,tZ=ep.default.readJsonSync;function t0(e,t,n){ep.default.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}U(t0,"writeFileSync");function t1(e,t,n){ep.default.appendFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}U(t1,"appendFileSync");function t2(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return ep.default.pathExistsSync(e)})}U(t2,"pathExistsSync");var t4={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return(0,ee.format)(e,"yyyy-MM-dd HH:mm:ss.SSS")},createGenericFields:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.returnDateAs,n=t===void 0?"string":t;var r=n==="string"?t4.getDateTime():new Date;return{id:(0,ea.v4)(),isDel:!1,createdAt:r,updatedAt:r}},applyPlugins:function e(e,t){t.filter(function(e){return typeof e=="function"}).forEach(function(t){return e.plugin(t)})},applyMiddlewares:function e(e,t){t.forEach(function(t){var n=t.method,r=t.pre,s=t.post;n&&r&&e.pre(n,r),n&&s&&e.post(n,s)})},createGenericSchema:function e(e){return new e.Schema({id:{type:String,default:ea.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})},createSchema:function e(e){var t=e.mongoose,n=e.schema,r=e.virtuals,s=r===void 0?[]:r,a=e.standalone,o=a===void 0?!1:a;var c=new t.Schema(n,{strict:!0});return s.forEach(function(e){var t=e.name,n=e.options,r=e.get;var s=c.virtual(t,n);r&&s.get(r)}),o||c.add(t4.createGenericSchema(t)),c},createModel:function e(e){var t=e.mongoose,n=e.name,r=e.schema,s=e.pagination,a=s===void 0?!1:s,o=e.aggregate,c=o===void 0?!1:o,u=e.virtuals,i=u===void 0?[]:u,l=e.middlewares,f=l===void 0?[]:l;if(!n)throw new Error("Model name is required.");if(t.models[n])return t.models[n];var d=t4.createSchema({mongoose:t,schema:r,virtuals:i});return t4.applyPlugins(d,[a&&es.default,c&&er.default]),t4.applyMiddlewares(d,f),t.model(n,d)},validator:{isEmpty:function e(){return function(e){return a(function(){return A(this,function(t){return[2,!ev.isEmpty(e)]})})()}},isUnique:function e(e){return function(t){return a(function(){var n;return A(this,function(r){switch(r.label){case 0:if(!Array.isArray(e)||e.length===0)throw new Error("Fields must be a non-empty array of strings.");n={$or:e.map(function(e){return l({},e,t)})};return[4,this.constructor.exists(n)];case 1:return[2,!r.sent()]}})}).call(this)}},matchesRegex:function e(e){return function(t){return a(function(){return A(this,function(n){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(t)})]})})()}}},migrate:y(m({},et.default),{setConfig:U(function(e){var t="// This file is automatically generated by the Cyberskill CLI.\nmodule.exports = ".concat(JSON.stringify(e,null,4));t0(tY.MIGRATE_MONGO_CONFIG,t);var n="\n".concat(tg,"\n");t2(tY.GIT_IGNORE)?tJ(tY.GIT_IGNORE,"utf-8").split("\n").includes(tg)||t1(tY.GIT_IGNORE,n):t0(tY.GIT_IGNORE,n)},"setConfig")})},t3=/*#__PURE__*/function(){function e(t,n){c(this,e);q(this,"collection");this.collection=t.collection(n)}i(e,[{key:"createOne",value:function e(e){return a(function(){var t,n,r;return A(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=m({},t4.createGenericFields(),e);n={success:!0,message:"Document created successfully"};return[4,this.collection.insertOne(t)];case 1:return[2,(n.result=s.sent(),n)];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return a(function(){var t,n,r;return A(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=e.map(function(e){return m({},t4.createGenericFields(),e)});return[4,this.collection.insertMany(t)];case 1:n=s.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:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"findOne",value:function e(e){return a(function(){var t,n;return A(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.findOne(e)];case 1:t=r.sent();return[2,t?{success:!0,message:"Document found",result:t}:{success:!1,message:"Document not found"}];case 2:n=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}},{key:"findAll",value:function e(){return a(function(){var e,t,n;var r=arguments;return A(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0,message:"Documents retrieved successfully"};return[4,this.collection.find(e).toArray()];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message}];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return a(function(){var e,t,n;var r=arguments;return A(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0,message:"Count retrieved successfully"};return[4,this.collection.countDocuments(e)];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(e,t){return a(function(){var n,r;return A(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,this.collection.updateOne(e,{$set:t})];case 1:n=s.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document updated successfully",result:n}];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"updateMany",value:function e(e,t){return a(function(){var n,r;return A(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,this.collection.updateMany(e,{$set:t})];case 1:n=s.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents updated successfully",result:n}];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"deleteOne",value:function e(e){return a(function(){var t,n;return A(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.deleteOne(e)];case 1:t=r.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=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}},{key:"deleteMany",value:function e(e){return a(function(){var t,n;return A(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.deleteMany(e)];case 1:t=r.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=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}}]);return e}();U(t3,"MongoController");var t5=t3,t6=/*#__PURE__*/function(){function e(t){c(this,e);q(this,"model");this.model=t}i(e,[{key:"getModelName",value:function e(){return this.model.modelName}},{key:"findOne",value:function e(e){return a(function(){var e,t,n,r,s,a,o;var c=arguments;return A(this,function(u){switch(u.label){case 0:e=c.length>0&&c[0]!==void 0?c[0]:{},t=c.length>1&&c[1]!==void 0?c[1]:{},n=c.length>2&&c[2]!==void 0?c[2]:{},r=c.length>3?c[3]:void 0;u.label=1;case 1:u.trys.push([1,3,,4]);s=this.model.findOne(e,t,n);r&&s.populate(r);return[4,s.exec()];case 2:a=u.sent();return[2,a?{success:!0,result:a}:{success:!1,message:"No ".concat(this.getModelName()," found."),code:eo.NOT_FOUND.CODE}];case 3:o=u.sent();return[2,{success:!1,message:o.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findAll",value:function e(e){return a(function(){var e,t,n,r,s,a,o;var c=arguments;return A(this,function(u){switch(u.label){case 0:e=c.length>0&&c[0]!==void 0?c[0]:{},t=c.length>1&&c[1]!==void 0?c[1]:{},n=c.length>2&&c[2]!==void 0?c[2]:{},r=c.length>3?c[3]:void 0;u.label=1;case 1:u.trys.push([1,3,,4]);s=this.model.find(e,t,n);r&&s.populate(r);a={success:!0};return[4,s.exec()];case 2:return[2,(a.result=u.sent(),a)];case 3:o=u.sent();return[2,{success:!1,message:o.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPaging",value:function e(){return a(function(){var e,t,n,r;var s=arguments;return A(this,function(a){switch(a.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);n={success:!0};return[4,this.model.paginate(e,t)];case 2:return[2,(n.result=a.sent(),n)];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPagingAggregate",value:function e(e){return a(function(e){var t,n,r;var s=arguments;return A(this,function(a){switch(a.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);n={success:!0};return[4,this.model.aggregatePaginate(this.model.aggregate(e),t)];case 2:return[2,(n.result=a.sent(),n)];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return a(function(){var e,t,n;var r=arguments;return A(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0};return[4,this.model.countDocuments(e)];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"createOne",value:function e(e){return a(function(){var t,n;return A(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);t={success:!0};return[4,this.model.create(e)];case 1:return[2,(t.result=r.sent(),t)];case 2:n=r.sent();return[2,{success:!1,message:n.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return a(function(e){var t,n,r;var s=arguments;return A(this,function(a){switch(a.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);n={success:!0};return[4,this.model.insertMany(e,t)];case 2:return[2,(n.result=a.sent().map(function(e){return E(e,en.Document)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(){return a(function(){var e,t,n,r,s;var a=arguments;return A(this,function(o){switch(o.label){case 0:e=a.length>0&&a[0]!==void 0?a[0]:{},t=a.length>1&&a[1]!==void 0?a[1]:{},n=a.length>2&&a[2]!==void 0?a[2]:{};o.label=1;case 1:o.trys.push([1,3,,4]);return[4,this.model.findOneAndUpdate(e,t,m({new:!0},n)).exec()];case 2:r=o.sent();return[2,r?{success:!0,result:r}:{success:!1,message:"Failed to update ".concat(this.getModelName(),"."),code:eo.NOT_FOUND.CODE}];case 3:s=o.sent();return[2,{success:!1,message:s.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateMany",value:function e(){return a(function(){var e,t,n,r,s;var a=arguments;return A(this,function(o){switch(o.label){case 0:e=a.length>0&&a[0]!==void 0?a[0]:{},t=a.length>1&&a[1]!==void 0?a[1]:{},n=a.length>2&&a[2]!==void 0?a[2]:{};o.label=1;case 1:o.trys.push([1,3,,4]);r={success:!0};return[4,this.model.updateMany(e,t,n).exec()];case 2:return[2,(r.result=o.sent(),r)];case 3:s=o.sent();return[2,{success:!1,message:s.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteOne",value:function e(){return a(function(){var e,t,n,r;var s=arguments;return A(this,function(a){switch(a.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);return[4,this.model.findOneAndDelete(e,t).exec()];case 2:n=a.sent();return[2,n?{success:!0,result:n}:{success:!1,message:"No ".concat(this.getModelName()," found to delete."),code:eo.NOT_FOUND.CODE}];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteMany",value:function e(){return a(function(){var e,t,n,r;var s=arguments;return A(this,function(a){switch(a.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);return[4,this.model.deleteMany(e,t).exec()];case 2:n=a.sent();return[2,n.deletedCount===0?{success:!1,message:"No documents found to delete.",code:eo.NOT_FOUND.CODE}:{success:!0,result:n}];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"createShortId",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return a(function(){var n,r,s,a;return A(this,function(o){switch(o.label){case 0:n=new Set;r=0;o.label=1;case 1:if(!(r<10))return[3,5];s=eg(e,r+t);a=!n.has(s);if(!a)return[3,3];n.add(s);return[4,this.model.exists({shortId:s})];case 2:a=!o.sent();o.label=3;case 3:if(a)return[2,{success:!0,result:s}];o.label=4;case 4:r++;return[3,1];case 5:return[2,{success:!1,message:"Failed to create a unique shortId",code:eo.INTERNAL_SERVER_ERROR.CODE}]}})}).call(this)}},{key:"createSlug",value:function e(e,t,n){return a(function(){var r,s,o,c,u,i,f,d,E,h;return A(this,function(g){switch(g.label){case 0:r=this;g.label=1;case 1:g.trys.push([1,5,,6]);s=t[e],o=el(s),c=U(function(t){var r=m({},n!==null&&n!==void 0?n:{});return o?y(m({},r),{$or:[l({},"slug.".concat(e),t),{slugHistory:{$elemMatch:l({},"slug.".concat(e),t)}}]}):y(m({},r),{$or:[{slug:t},{slugHistory:t}]})},"generateSlugQuery"),u=U(function(e){return a(function(){var t,n;return A(this,function(r){switch(r.label){case 0:t=e,n=1;r.label=1;case 1:return[4,this.model.exists(c(t))];case 2:if(!r.sent())return[3,4];t="".concat(e,"-").concat(n++);r.label=3;case 3:return[3,1];case 4:return[2,t]}})}).call(r)},"generateUniqueSlug");if(!o)return[3,3];i={success:!0};f=Object.fromEntries;return[4,Promise.all(Object.entries(s).map(function(e){var t=_(e,2),n=t[0],r=t[1];return a(function(){var e,t;return A(this,function(s){switch(s.label){case 0:e=eh(r);t=[n];return[4,u(e)];case 1:return[2,t.concat([s.sent()])]}})})()}))];case 2:return[2,(i.result=f.apply(Object,[g.sent()]),i)];case 3:d=eh(s);E={success:!0};return[4,u(d)];case 4:return[2,(E.result=g.sent(),E)];case 5:h=g.sent();return[2,{success:!1,message:"Failed to create a unique slug: ".concat(h.message),code:eo.INTERNAL_SERVER_ERROR.CODE}];case 6:return[2]}})}).call(this)}},{key:"aggregate",value:function e(e){return a(function(){var t,n;return A(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);t={success:!0};return[4,this.model.aggregate(e)];case 1:return[2,(t.result=r.sent(),t)];case 2:n=r.sent();return[2,{success:!1,message:n.message,code:eo.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})}).call(this)}}]);return e}();U(t6,"MongooseController");var t7=t6;0&&(module.exports={C_Collection:C_Collection,C_Db:C_Db,C_Document:C_Document,C_Model:C_Model,MONGO_MIGRATE_OPTIONS:MONGO_MIGRATE_OPTIONS,MongoController:MongoController,MongooseController:MongooseController,aggregatePaginate:aggregatePaginate,mongo:mongo,mongoosePaginate:mongoosePaginate});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function s(e,t,n,r,s,o,a){try{var c=e[o](a);var i=c.value}catch(e){n(e);return}if(c.done){t(i)}else{Promise.resolve(i).then(r,s)}}function o(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function c(e){s(a,r,o,c,i,"next",e)}function i(e){s(a,r,o,c,i,"throw",e)}c(undefined)})}}function a(e,t,n){t=f(t);return S(e,A()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}function c(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}function u(e,t,n){if(t)i(e.prototype,t);if(n)i(e,n);return e}function l(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}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,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)R(e,t)}function E(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function h(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function m(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var s=true;var o=false;var a,c;try{for(n=n.call(e);!(s=(a=n.next()).done);s=true){r.push(a.value);if(t&&r.length===t)break}}catch(e){o=true;c=e}finally{try{if(!s&&n["return"]!=null)n["return"]()}finally{if(o)throw c}}return r}function p(){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 g(){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 v(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var r=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}r.forEach(function(t){l(e,t,n[t])})}return e}function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}n.push.apply(n,r)}return n}function y(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{O(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function S(e,t){if(t&&(C(t)==="object"||typeof t==="function")){return t}return r(e)}function R(e,t){R=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return R(e,t)}function _(e,n){return t(e)||m(e,n)||T(e,n)||p()}function I(e){return n(e)||h(e)||T(e)||g()}function C(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function T(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(A=function(){return!!e})()}function D(e,t){var n,r,s,o={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=c(0),a["throw"]=c(1),a["return"]=c(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(e){return function(t){return i([e,t])}}function i(c){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,c[0]&&(o=0)),o)try{if(n=1,r&&(s=c[0]&2?r["return"]:c[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;if(r=0,s)c=[c[0]&2,s.value];switch(c[0]){case 0:case 1:s=c;break;case 4:o.label++;return{value:c[1],done:false};case 5:o.label++;r=c[1];c=[0];continue;case 7:c=o.ops.pop();o.trys.pop();continue;default:if(!(s=o.trys,s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){o=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){o.label=c[1];break}if(c[0]===6&&o.label<s[1]){o.label=s[1];s=c;break}if(s&&o.label<s[2]){o.label=s[2];o.ops.push(c);break}if(s[2])o.ops.pop();o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e];r=0}finally{n=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}}var b=Object.defineProperty;var N=function(e,t,n){return t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n};var G=function(e,t){return b(e,"name",{value:t,configurable:!0})};var M=function(e,t,n){return N(e,(typeof t==="undefined"?"undefined":C(t))!="symbol"?t+"":t,n)};var w="MONGO_MIGRATE_OPTIONS";import{Collection as L,Db as P}from"mongodb";import{Document as U,Model as k}from"mongoose";var F=/*#__PURE__*/function(e){"use strict";d(t,e);function t(){c(this,t);return a(this,t,arguments)}return t}(P);G(F,"C_Db");var j=F,x=/*#__PURE__*/function(e){"use strict";d(t,e);function t(){c(this,t);return a(this,t,arguments)}return t}(U);G(x,"C_Document");var Y=x,B=/*#__PURE__*/function(e){"use strict";d(t,e);function t(){c(this,t);return a(this,t,arguments)}return t}(k);G(B,"C_Model");var q=B,H=/*#__PURE__*/function(e){"use strict";d(t,e);function t(){c(this,t);return a(this,t,arguments)}return t}(L);G(H,"C_Collection");var Q=H;import{format as V}from"date-fns";import K from"migrate-mongo";import{Document as W}from"mongoose";import $ from"mongoose-aggregate-paginate-v2";import J from"mongoose-paginate-v2";import{v4 as X}from"uuid";var z={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"}};import Z from"unorm";var ee={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},et=Object.entries(ee).reduce(function(e,t){var n=_(t,2),r=n[0],s=n[1];return e[r.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function en(e){return(typeof e==="undefined"?"undefined":C(e))=="object"&&e!==null&&!Array.isArray(e)}G(en,"isObject");import er from"crypto-js";import es from"slugify";var eo=es.default||es;function ea(e,t){var n=G(function(e){var n,r;return eo(e!==null&&e!==void 0?e:"",v({lower:(n=t===null||t===void 0?void 0:t.lower)!==null&&n!==void 0?n:!0,locale:(r=t===null||t===void 0?void 0:t.locale)!==null&&r!==void 0?r:"vi"},t))},"slugifyWithOptions");if(en(e)){var r={};var s=true,o=false,a=undefined;try{for(var c=Object.entries(e)[Symbol.iterator](),i;!(s=(i=c.next()).done);s=true){var u=_(i.value,2),l=u[0],f=u[1];r[l]=n(f)}}catch(e){o=true;a=e}finally{try{if(!s&&c.return!=null){c.return()}}finally{if(o){throw a}}}return r}return n(e)}G(ea,"generateSlug");function ec(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return er.SHA256(e).toString(er.enc.Hex).slice(0,t)}G(ec,"generateShortId");var ei={isEmpty:function e(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":C(e))=="object"?E(e,Date)?!1:E(e,Map)||E(e,Set)?e.size===0:E(e,WeakMap)||E(e,WeakSet)?!0:ArrayBuffer.isView(e)?e.byteLength===0:Object.keys(e).length===0:!1},isValidIP:function e(e){var t=e.split(".");return t.length===4&&t.every(function(e){return/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255})?!0:/^(([a-f\d]{1,4}:){7}[a-f\d]{1,4}|((?:[a-f\d]{1,4}:){1,7}:)|((?:[a-f\d]{1,4}:){1,6}:[a-f\d]{1,4})|::)$/i.test(e)}};import eu from"fs-extra";var el=".cyberskill-storage";import ef from"@dotenvx/dotenvx";import{bool as ed,cleanEnv as eE,str as eh}from"envalid";import em from"node:os";import ep from"node:path";import eg from"node:process";var ev=!1;function eO(){ev||(ef.config(),ev=!0)}G(eO,"loadEnvFile");function ey(){eO();var e=eE(eg.env,{CWD:eh({default:eg.cwd()}),DEBUG:ed({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:eh({default:ep.join(em.homedir(),el)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}G(ey,"getEnv");var eS=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});import{exec as eR}from"node:child_process";import e_ from"node:process";import*as eI from"node:util";var eC=function(e){return e.Error="error",e.Warning="warning",e}({});import eT from"chalk";import eA from"consola";import{GraphQLError as eD}from"graphql";var eb=ey();eb.DEBUG||(eA.level=4);function eN(e){var t=eT[e];return typeof t=="function"?t:eT.green}G(eN,"chalkKeyword");var eG={silent:eA.silent,level:eA.level,fatal:eA.fatal,error:eA.error,warn:eA.warn,log:eA.log,info:eA.info,success:eA.success,ready:eA.ready,start:eA.start,box:eA.box,debug:eA.debug,trace:eA.trace,verbose:eA.verbose,printBoxedLog:function e(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){eA.box(eT.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,s=e.rule,o=e.message;eA.log("".concat(eT.gray("File:")," ").concat(eT.blue("".concat(t).concat(r?":".concat(r):"")))),s&&eA.log(" ".concat(eN(n)("Rule:")," ").concat(s)),eA.log(" ".concat(eN(n)("Message:")," ").concat(o))}),eA.box(eN(n)("".concat(e," : ").concat(t.length))),eA.log(eT.gray("─".repeat(40)))}};var eM={isCurrentProject:!1,installedPath:"",file:{},isUpToDate:!1};import ew from"node-fetch";var eL=ey();function eP(e){var t=e5(eL.CWD,tt);if(!t$(t))return!1;try{var n=tV(t),r=n.name,s=n.dependencies,o=s===void 0?{}:s,a=n.devDependencies,c=a===void 0?{}:a,i=r===e,u=e in o,l=e in c;return i||u||l?{path:t,file:n,isCurrentProject:i,isDepend:u,isDevDepend:l}:!1}catch(e){return eG.warn("Failed to read package.json: ".concat(e.message)),!1}}G(eP,"getPackage");function eU(e){return o(function(){var t,n,r,s;return D(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,ew("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=o.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:n=o.sent(),r=n.version;return[2,r];case 3:s=o.sent();throw eG.error('Failed to fetch version for "'.concat(e,'": ').concat(s.message)),s;case 4:return[2]}})})()}G(eU,"getLatestPackageVersion");function ek(e,t){return o(function(){var n,r,s,o,a,c,i,u,l,f,d,E,h,m,p,g,O,y,S,R,_;return D(this,function(I){switch(I.label){case 0:I.trys.push([0,4,,5]);n=eP(e);if(!n)return[2,v({},eM)];i=n.path,u=n.file,l=n.isCurrentProject,f=n.isDepend,d=n.isDevDepend,E=(r=u.dependencies)!==null&&r!==void 0?r:{},h=(s=u.devDependencies)!==null&&s!==void 0?s:{},m=l?(o=u.version)!==null&&o!==void 0?o:"0.0.0":f?(a=E[e])!==null&&a!==void 0?a:"0.0.0":d?(c=h[e])!==null&&c!==void 0?c:"0.0.0":"0.0.0";if(!l)return[3,1];O=m;return[3,3];case 1:return[4,eU(e)];case 2:O=I.sent();I.label=3;case 3:p=O,g=l||m===p;if(!g&&(t===null||t===void 0?void 0:t.update)){;S=f?"dependencies":d?"devDependencies":null;S&&((y=u[S])===null||y===void 0?void 0:y[e])!==p&&(u[S]=(R=u[S])!==null&&R!==void 0?R:{},u[S][e]=p,tK(i,JSON.stringify(u,null,4)),eG.info('Updated "'.concat(e,'" to version ').concat(p)))}return[2,{isCurrentProject:l,installedPath:i,file:u,isUpToDate:g}];case 4:_=I.sent();return[2,(eG.error('Error checking package "'.concat(e,'": ').concat(_.message)),v({},eM))];case 5:return[2]}})})()}G(ek,"checkPackage");function eF(){return o(function(){var e,t,n,r,s,o,a,c,i,u,l,f;return D(this,function(d){switch(d.label){case 0:e=[{command:G(function(){return tj.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:G(function(){return tj.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:G(function(){return tj.pnpmInstallForce()},"command"),message:"Retrying with force install"}];t=true,n=false,r=undefined;d.label=1;case 1:d.trys.push([1,9,10,11]);s=e[Symbol.iterator]();d.label=2;case 2:if(!!(t=(o=s.next()).done))return[3,8];a=o.value,c=a.command,i=a.message;d.label=3;case 3:d.trys.push([3,6,,7]);return[4,c()];case 4:u=d.sent();return[4,e0("".concat(i," using: ").concat(u),u)];case 5:d.sent();return[2];case 6:l=d.sent();eG.warn("Installation attempt failed: ".concat(i)),eG.error("Details: ".concat(l.message));return[3,7];case 7:t=true;return[3,2];case 8:return[3,11];case 9:f=d.sent();n=true;r=f;return[3,11];case 10:try{if(!t&&s.return!=null){s.return()}}finally{if(n){throw r}}return[7];case 11:throw new Error("All dependency installation strategies failed.")}})})()}G(eF,"installDependencies");function ej(e,t){return o(function(){var n,r,s,o,a,c,i,u,l,f,d;return D(this,function(E){switch(E.label){case 0:if(!t$(tU.PACKAGE_JSON)){eG.error("package.json not found. Aborting setup.");return[2]}E.label=1;case 1:E.trys.push([1,13,,14]);n=I(new Set(e)).sort();return[4,Promise.all(n.map(function(e){return ek(e,v({},(t===null||t===void 0?void 0:t.update)&&{update:t.update}))}))];case 2:r=E.sent().every(function(e){return e.isUpToDate});if(r)return[3,4];return[4,eF()];case 3:r=E.sent();E.label=4;case 4:r;o=true,a=false,c=undefined;E.label=5;case 5:E.trys.push([5,10,11,12]);i=((s=t===null||t===void 0?void 0:t.postInstallActions)!==null&&s!==void 0?s:[])[Symbol.iterator]();E.label=6;case 6:if(!!(o=(u=i.next()).done))return[3,9];l=u.value;return[4,l()];case 7:E.sent();E.label=8;case 8:o=true;return[3,6];case 9:return[3,12];case 10:f=E.sent();a=true;c=f;return[3,12];case 11:try{if(!o&&i.return!=null){i.return()}}finally{if(a){throw c}}return[7];case 12:return[3,14];case 13:d=E.sent();throw eG.error('Failed to setup "'.concat(e.join(", "),'": ').concat(d.message)),d;case 14:return[2]}})})()}G(ej,"setupPackages");import ex from"node-persist";var eY=ey();function eB(){return o(function(){var e;return D(this,function(t){switch(t.label){case 0:e=ex.defaultInstance;if(e)return[3,2];return[4,ex.init({dir:eY.CYBERSKILL_STORAGE_DIRECTORY,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}G(eB,"initNodePersist");var eq={get:function e(e){return o(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,eB()];case 1:r.sent();return[4,ex.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,(eG.error('[Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 4:return[2]}})})()},set:function e(e,t){return o(function(){var n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,eB()];case 1:r.sent();return[4,ex.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();eG.error('[Storage:set] Error setting key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return o(function(){var t;return D(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,eB()];case 1:n.sent();return[4,ex.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();eG.error('[Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return o(function(){var e,t;return D(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,eB()];case 1:n.sent();return[4,ex.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(eG.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,(eG.error("[Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return o(function(){return D(this,function(t){try{return[2,"".concat(eY.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,(eG.error("[Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var eH=ey(),eQ=eI.promisify(eR);function eV(e){return"error_list:".concat(e)}G(eV,"getErrorListKey");function eK(e){return o(function(){var t,n,r;return D(this,function(s){switch(s.label){case 0:if(e.length===0)return[2];t=Date.now(),n=eV(t);s.label=1;case 1:s.trys.push([1,3,,4]);return[4,eq.set(n,{errors:e,timestamp:t})];case 2:s.sent(),setTimeout(function(){return o(function(){var e;return D(this,function(t){switch(t.label){case 0:return[4,eq.getLogLink(n)];case 1:e=t.sent();e&&eG.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},10);return[3,4];case 3:r=s.sent();eG.error("Failed to save errors: ".concat(r.message));return[3,4];case 4:return[2]}})})()}G(eK,"saveErrorListToStorage");function eW(e){var t=[],n=[],r="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,o=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,a=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var c,i,u,l,f;var d=s.exec(e)||[],E=o.exec(e)||[],h=a.exec(e)||[];var m,p,g,v,O,y;d.length&&r?t.push({file:r,position:"".concat(d[1],":").concat(d[2]),type:d[3]===eC.Error?eC.Error:eC.Warning,message:(m=d===null||d===void 0?void 0:(c=d[4])===null||c===void 0?void 0:c.trim())!==null&&m!==void 0?m:"",rule:(p=d===null||d===void 0?void 0:(i=d[5])===null||i===void 0?void 0:i.trim())!==null&&p!==void 0?p:""}):E.length?t.push({file:(g=E===null||E===void 0?void 0:E[1])!==null&&g!==void 0?g:"",position:"".concat(E[2],":").concat(E[3]),type:E[4]===eC.Error?eC.Error:eC.Warning,message:(v=E===null||E===void 0?void 0:(u=E[5])===null||u===void 0?void 0:u.trim())!==null&&v!==void 0?v:""}):h.length?t.push({file:"commitlint",type:eC.Error,message:(O=h===null||h===void 0?void 0:(l=h[1])===null||l===void 0?void 0:l.trim())!==null&&O!==void 0?O:"",rule:(y=h===null||h===void 0?void 0:(f=h[2])===null||f===void 0?void 0:f.trim())!==null&&y!==void 0?y:""}):n.push(e.trim())}}),t.length&&eK(t),eH.DEBUG&&n.length&&(eG.warn("Unmatched lines:"),n.forEach(function(e){return eG.info(" ".concat(e))}))}G(eW,"parseTextErrors");function e$(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,s=e.line,o=e.column,a=e.ruleId,c=e.message;n.push({type:r===2?eC.Error:eC.Warning,file:t,position:"".concat(s,":").concat(o),rule:a,message:c})})}),n.length&&eK(n)}catch(t){eW(e)}}G(e$,"parseCommandOutput");function eJ(e){return o(function(e){var t,n,r,s,o,a,c,i,u;var l=arguments;return D(this,function(f){switch(f.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:e$;n=new AbortController;e_.on("SIGINT",function(){eG.warn("Process interrupted. Terminating..."),n.abort(),e_.exit()});f.label=1;case 1:f.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,eQ(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=f.sent(),s=r.stdout,o=r.stderr;[s,o].forEach(function(e){return e&&t(e)});f.label=3;case 3:return[3,5];case 4:a=f.sent();c=a.stdout,i=a.stderr,u=a.message;[c,i].forEach(function(e){return e&&t(e)}),!i&&!c&&eG.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}G(eJ,"executeCommand");function eX(e){return{raw:!0,cmd:e}}G(eX,"rawCommand");function ez(e,t){return(t===null||t===void 0?void 0:t.isRemote)?"".concat(tA," ").concat(e8," ").concat(e):(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(tA," ").concat(tI," ").concat(td," ").concat(e):"".concat(tA," ").concat(tf," ").concat(e)}G(ez,"formatCLI");function eZ(e,t){return typeof e=="function"?ez(e(t),t):(typeof e==="undefined"?"undefined":C(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?ez(e,t):e}G(eZ,"formatCommand");function e0(e,t){return o(function(){var n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);eG.start("".concat(e)),eH.DEBUG&&eG.info("→ ".concat(t));return[4,eJ(t)];case 1:r.sent(),eG.success("".concat(e," done."));return[3,3];case 2:n=r.sent();throw eG.error("".concat(e," failed: ").concat(n.message)),n;case 3:return[2]}})})()}G(e0,"runCommand");import e1 from"node:path";var e2=ey(),e4=e1;function e3(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=e4).resolve.apply(r,[e2.CWD].concat(I(t)))}G(e3,"resolveWorkingPath");function e5(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=e4).join.apply(r,I(t))}G(e5,"join");var e6=ey(),e7=e6.CWD,e8="@cyberskill/shared",e9="node_modules",te="dist",tt="package.json",tn="package-lock.json",tr="tsconfig.json",ts=".gitignore",to=".simple-git-hooks.json",ta="pnpm-lock.yaml",tc=".git/hooks/",ti=".git/COMMIT_EDITMSG",tu=".migrate-mongo.config.js",tl=e5(e7,e9,e8,te),tf="cyberskill",td="src/nodejs/cli/index.ts",tE="eslint",th="eslint",tm="vitest",tp="playwright",tg="vitest",tv="@commitlint/cli",tO="commitlint",ty="lint-staged",tS="lint-staged",tR="typescript",t_="tsc",tI="tsx",tC="git",tT="pnpm",tA="pnpm exec",tD="simple-git-hooks",tb="simple-git-hooks",tN="@eslint/config-inspector",tG="eslint-config-inspector",tM="node-modules-inspector",tw="node-modules-inspector",tL="migrate-mongo",tP="./node_modules/migrate-mongo/bin/migrate-mongo",tU={CYBERSKILL_DIRECTORY:tl,WORKING_DIRECTORY:e7,TS_CONFIG:e3(tr),GIT_IGNORE:e3(ts),GIT_HOOK:e3(tc),GIT_COMMIT_MSG:e3(ti),SIMPLE_GIT_HOOKS_JSON:e3(to),PACKAGE_JSON:e3(tt),PACKAGE_LOCK_JSON:e3(tn),PNPM_LOCK_YAML:e3(ta),NODE_MODULES:e3(e9),MIGRATE_MONGO_CONFIG:e3(tu),LINT_STAGED_CONFIG:e3("".concat(tl,"/configs/lint-staged/index.js")),COMMITLINT_CONFIG:e3("".concat(tl,"/configs/commitlint/index.js")),UNIT_TEST_CONFIG:e3("".concat(tl,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:e3("".concat(tl,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:e3("".concat(tl,"/react/vitest/vitest.e2e.js"))};function tk(e,t,n){return o(function(){return D(this,function(r){switch(r.label){case 0:if(!t)throw new Error("'first' argument is undefined");switch(e){case eS.CLI:return[3,1];case eS.STRING:return[3,3]}return[3,4];case 1:return[4,ej(t.split(" "),{update:!0})];case 2:return[2,(r.sent(),eZ(eX("".concat(tA," ").concat(n))))];case 3:return[2,eZ(eX(t))];case 4:throw new Error("Unsupported command type");case 5:return[2]}})})()}G(tk,"buildCommand");function tF(e,t,n){return function(){return o(function(){return D(this,function(r){return[2,tk(e,t,n)]})})()}}G(tF,"commandFactory");var tj={simpleGitHooks:tF(eS.CLI,tD,tb),eslintInspect:tF(eS.CLI,tN,tG),nodeModulesInspect:tF(eS.CLI,tM,tw),eslintCheck:tF(eS.CLI,tE,"".concat(th," ").concat(tU.WORKING_DIRECTORY," --no-cache")),eslintFix:tF(eS.CLI,tE,"".concat(th," ").concat(tU.WORKING_DIRECTORY," --fix --no-cache")),typescriptCheck:tF(eS.CLI,tR,"".concat(t_," -p ").concat(tU.TS_CONFIG," --noEmit")),configureGitHook:tF(eS.STRING,"".concat(tC," config core.hooksPath ").concat(tU.GIT_HOOK)),testUnit:tF(eS.CLI,tm,"".concat(tg," --config ").concat(tU.UNIT_TEST_CONFIG)),testE2e:tF(eS.CLI,"".concat(tm," ").concat(tp),"".concat(tg," --config ").concat(tU.E2E_TEST_CONFIG)),mongoMigrateCreate:G(function(e){return tF(eS.CLI,tL,"".concat(tI," ").concat(tP," create ").concat(e," -f ").concat(tU.MIGRATE_MONGO_CONFIG))()},"mongoMigrateCreate"),mongoMigrateUp:tF(eS.CLI,tL,"".concat(tI," ").concat(tP," up -f ").concat(tU.MIGRATE_MONGO_CONFIG)),mongoMigrateDown:tF(eS.CLI,tL,"".concat(tI," ").concat(tP," down -f ").concat(tU.MIGRATE_MONGO_CONFIG)),commitLint:tF(eS.CLI,tv,"".concat(tO," --edit ").concat(tU.GIT_COMMIT_MSG," --config ").concat(tU.COMMITLINT_CONFIG)),lintStaged:tF(eS.CLI,ty,"".concat(tS," --config ").concat(tU.LINT_STAGED_CONFIG)),stageBuildDirectory:tF(eS.STRING,"".concat(tC," add ").concat(te)),build:tF(eS.STRING,"".concat(tT," run build")),pnpmInstallStandard:tF(eS.STRING,"".concat(tT," install")),pnpmInstallLegacy:tF(eS.STRING,"".concat(tT," install --legacy-peer-deps")),pnpmInstallForce:tF(eS.STRING,"".concat(tT," install --force"))};var tx=eu.lstatSync,tY=eu.readdirSync,tB=eu.mkdirSync,tq=eu.readFileSync,tH=eu.unlinkSync,tQ=eu.statSync,tV=eu.readJsonSync;function tK(e,t,n){eu.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}G(tK,"writeFileSync");function tW(e,t,n){eu.appendFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}G(tW,"appendFileSync");function t$(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return eu.pathExistsSync(e)})}G(t$,"pathExistsSync");var tJ={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return V(e,"yyyy-MM-dd HH:mm:ss.SSS")},createGenericFields:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.returnDateAs,n=t===void 0?"string":t;var r=n==="string"?tJ.getDateTime():new Date;return{id:X(),isDel:!1,createdAt:r,updatedAt:r}},applyPlugins:function e(e,t){t.filter(function(e){return typeof e=="function"}).forEach(function(t){return e.plugin(t)})},applyMiddlewares:function e(e,t){t.forEach(function(t){var n=t.method,r=t.pre,s=t.post;n&&r&&e.pre(n,r),n&&s&&e.post(n,s)})},createGenericSchema:function e(e){return new e.Schema({id:{type:String,default:X,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})},createSchema:function e(e){var t=e.mongoose,n=e.schema,r=e.virtuals,s=r===void 0?[]:r,o=e.standalone,a=o===void 0?!1:o;var c=new t.Schema(n,{strict:!0});return s.forEach(function(e){var t=e.name,n=e.options,r=e.get;var s=c.virtual(t,n);r&&s.get(r)}),a||c.add(tJ.createGenericSchema(t)),c},createModel:function e(e){var t=e.mongoose,n=e.name,r=e.schema,s=e.pagination,o=s===void 0?!1:s,a=e.aggregate,c=a===void 0?!1:a,i=e.virtuals,u=i===void 0?[]:i,l=e.middlewares,f=l===void 0?[]:l;if(!n)throw new Error("Model name is required.");if(t.models[n])return t.models[n];var d=tJ.createSchema({mongoose:t,schema:r,virtuals:u});return tJ.applyPlugins(d,[o&&J,c&&$]),tJ.applyMiddlewares(d,f),t.model(n,d)},validator:{isEmpty:function e(){return function(e){return o(function(){return D(this,function(t){return[2,!ei.isEmpty(e)]})})()}},isUnique:function e(e){return function(t){return o(function(){var n;return D(this,function(r){switch(r.label){case 0:if(!Array.isArray(e)||e.length===0)throw new Error("Fields must be a non-empty array of strings.");n={$or:e.map(function(e){return l({},e,t)})};return[4,this.constructor.exists(n)];case 1:return[2,!r.sent()]}})}).call(this)}},matchesRegex:function e(e){return function(t){return o(function(){return D(this,function(n){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(t)})]})})()}}},migrate:y(v({},K),{setConfig:G(function(e){var t="// This file is automatically generated by the Cyberskill CLI.\nmodule.exports = ".concat(JSON.stringify(e,null,4));tK(tU.MIGRATE_MONGO_CONFIG,t);var n="\n".concat(tu,"\n");t$(tU.GIT_IGNORE)?tq(tU.GIT_IGNORE,"utf-8").split("\n").includes(tu)||tW(tU.GIT_IGNORE,n):tK(tU.GIT_IGNORE,n)},"setConfig")})},tX=/*#__PURE__*/function(){"use strict";function e(t,n){c(this,e);M(this,"collection");this.collection=t.collection(n)}u(e,[{key:"createOne",value:function e(e){return o(function(){var t,n,r;return D(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=v({},tJ.createGenericFields(),e);n={success:!0,message:"Document created successfully"};return[4,this.collection.insertOne(t)];case 1:return[2,(n.result=s.sent(),n)];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return o(function(){var t,n,r;return D(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=e.map(function(e){return v({},tJ.createGenericFields(),e)});return[4,this.collection.insertMany(t)];case 1:n=s.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:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"findOne",value:function e(e){return o(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.findOne(e)];case 1:t=r.sent();return[2,t?{success:!0,message:"Document found",result:t}:{success:!1,message:"Document not found"}];case 2:n=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}},{key:"findAll",value:function e(){return o(function(){var e,t,n;var r=arguments;return D(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0,message:"Documents retrieved successfully"};return[4,this.collection.find(e).toArray()];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message}];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return o(function(){var e,t,n;var r=arguments;return D(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0,message:"Count retrieved successfully"};return[4,this.collection.countDocuments(e)];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(e,t){return o(function(){var n,r;return D(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,this.collection.updateOne(e,{$set:t})];case 1:n=s.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document updated successfully",result:n}];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"updateMany",value:function e(e,t){return o(function(){var n,r;return D(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,this.collection.updateMany(e,{$set:t})];case 1:n=s.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents updated successfully",result:n}];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"deleteOne",value:function e(e){return o(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.deleteOne(e)];case 1:t=r.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=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}},{key:"deleteMany",value:function e(e){return o(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.deleteMany(e)];case 1:t=r.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=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}}]);return e}();G(tX,"MongoController");var tz=tX,tZ=/*#__PURE__*/function(){"use strict";function e(t){c(this,e);M(this,"model");this.model=t}u(e,[{key:"getModelName",value:function e(){return this.model.modelName}},{key:"findOne",value:function e(e){return o(function(){var e,t,n,r,s,o,a;var c=arguments;return D(this,function(i){switch(i.label){case 0:e=c.length>0&&c[0]!==void 0?c[0]:{},t=c.length>1&&c[1]!==void 0?c[1]:{},n=c.length>2&&c[2]!==void 0?c[2]:{},r=c.length>3?c[3]:void 0;i.label=1;case 1:i.trys.push([1,3,,4]);s=this.model.findOne(e,t,n);r&&s.populate(r);return[4,s.exec()];case 2:o=i.sent();return[2,o?{success:!0,result:o}:{success:!1,message:"No ".concat(this.getModelName()," found."),code:z.NOT_FOUND.CODE}];case 3:a=i.sent();return[2,{success:!1,message:a.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findAll",value:function e(e){return o(function(){var e,t,n,r,s,o,a;var c=arguments;return D(this,function(i){switch(i.label){case 0:e=c.length>0&&c[0]!==void 0?c[0]:{},t=c.length>1&&c[1]!==void 0?c[1]:{},n=c.length>2&&c[2]!==void 0?c[2]:{},r=c.length>3?c[3]:void 0;i.label=1;case 1:i.trys.push([1,3,,4]);s=this.model.find(e,t,n);r&&s.populate(r);o={success:!0};return[4,s.exec()];case 2:return[2,(o.result=i.sent(),o)];case 3:a=i.sent();return[2,{success:!1,message:a.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPaging",value:function e(){return o(function(){var e,t,n,r;var s=arguments;return D(this,function(o){switch(o.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};o.label=1;case 1:o.trys.push([1,3,,4]);n={success:!0};return[4,this.model.paginate(e,t)];case 2:return[2,(n.result=o.sent(),n)];case 3:r=o.sent();return[2,{success:!1,message:r.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPagingAggregate",value:function e(e){return o(function(e){var t,n,r;var s=arguments;return D(this,function(o){switch(o.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};o.label=1;case 1:o.trys.push([1,3,,4]);n={success:!0};return[4,this.model.aggregatePaginate(this.model.aggregate(e),t)];case 2:return[2,(n.result=o.sent(),n)];case 3:r=o.sent();return[2,{success:!1,message:r.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return o(function(){var e,t,n;var r=arguments;return D(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0};return[4,this.model.countDocuments(e)];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"createOne",value:function e(e){return o(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);t={success:!0};return[4,this.model.create(e)];case 1:return[2,(t.result=r.sent(),t)];case 2:n=r.sent();return[2,{success:!1,message:n.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return o(function(e){var t,n,r;var s=arguments;return D(this,function(o){switch(o.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};o.label=1;case 1:o.trys.push([1,3,,4]);n={success:!0};return[4,this.model.insertMany(e,t)];case 2:return[2,(n.result=o.sent().map(function(e){return E(e,W)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 3:r=o.sent();return[2,{success:!1,message:r.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(){return o(function(){var e,t,n,r,s;var o=arguments;return D(this,function(a){switch(a.label){case 0:e=o.length>0&&o[0]!==void 0?o[0]:{},t=o.length>1&&o[1]!==void 0?o[1]:{},n=o.length>2&&o[2]!==void 0?o[2]:{};a.label=1;case 1:a.trys.push([1,3,,4]);return[4,this.model.findOneAndUpdate(e,t,v({new:!0},n)).exec()];case 2:r=a.sent();return[2,r?{success:!0,result:r}:{success:!1,message:"Failed to update ".concat(this.getModelName(),"."),code:z.NOT_FOUND.CODE}];case 3:s=a.sent();return[2,{success:!1,message:s.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateMany",value:function e(){return o(function(){var e,t,n,r,s;var o=arguments;return D(this,function(a){switch(a.label){case 0:e=o.length>0&&o[0]!==void 0?o[0]:{},t=o.length>1&&o[1]!==void 0?o[1]:{},n=o.length>2&&o[2]!==void 0?o[2]:{};a.label=1;case 1:a.trys.push([1,3,,4]);r={success:!0};return[4,this.model.updateMany(e,t,n).exec()];case 2:return[2,(r.result=a.sent(),r)];case 3:s=a.sent();return[2,{success:!1,message:s.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteOne",value:function e(){return o(function(){var e,t,n,r;var s=arguments;return D(this,function(o){switch(o.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};o.label=1;case 1:o.trys.push([1,3,,4]);return[4,this.model.findOneAndDelete(e,t).exec()];case 2:n=o.sent();return[2,n?{success:!0,result:n}:{success:!1,message:"No ".concat(this.getModelName()," found to delete."),code:z.NOT_FOUND.CODE}];case 3:r=o.sent();return[2,{success:!1,message:r.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteMany",value:function e(){return o(function(){var e,t,n,r;var s=arguments;return D(this,function(o){switch(o.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};o.label=1;case 1:o.trys.push([1,3,,4]);return[4,this.model.deleteMany(e,t).exec()];case 2:n=o.sent();return[2,n.deletedCount===0?{success:!1,message:"No documents found to delete.",code:z.NOT_FOUND.CODE}:{success:!0,result:n}];case 3:r=o.sent();return[2,{success:!1,message:r.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"createShortId",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return o(function(){var n,r,s,o;return D(this,function(a){switch(a.label){case 0:n=new Set;r=0;a.label=1;case 1:if(!(r<10))return[3,5];s=ec(e,r+t);o=!n.has(s);if(!o)return[3,3];n.add(s);return[4,this.model.exists({shortId:s})];case 2:o=!a.sent();a.label=3;case 3:if(o)return[2,{success:!0,result:s}];a.label=4;case 4:r++;return[3,1];case 5:return[2,{success:!1,message:"Failed to create a unique shortId",code:z.INTERNAL_SERVER_ERROR.CODE}]}})}).call(this)}},{key:"createSlug",value:function e(e,t,n){return o(function(){var r,s,a,c,i,u,f,d,E,h;return D(this,function(m){switch(m.label){case 0:r=this;m.label=1;case 1:m.trys.push([1,5,,6]);s=t[e],a=en(s),c=G(function(t){var r=v({},n!==null&&n!==void 0?n:{});return a?y(v({},r),{$or:[l({},"slug.".concat(e),t),{slugHistory:{$elemMatch:l({},"slug.".concat(e),t)}}]}):y(v({},r),{$or:[{slug:t},{slugHistory:t}]})},"generateSlugQuery"),i=G(function(e){return o(function(){var t,n;return D(this,function(r){switch(r.label){case 0:t=e,n=1;r.label=1;case 1:return[4,this.model.exists(c(t))];case 2:if(!r.sent())return[3,4];t="".concat(e,"-").concat(n++);r.label=3;case 3:return[3,1];case 4:return[2,t]}})}).call(r)},"generateUniqueSlug");if(!a)return[3,3];u={success:!0};f=Object.fromEntries;return[4,Promise.all(Object.entries(s).map(function(e){var t=_(e,2),n=t[0],r=t[1];return o(function(){var e,t;return D(this,function(s){switch(s.label){case 0:e=ea(r);t=[n];return[4,i(e)];case 1:return[2,t.concat([s.sent()])]}})})()}))];case 2:return[2,(u.result=f.apply(Object,[m.sent()]),u)];case 3:d=ea(s);E={success:!0};return[4,i(d)];case 4:return[2,(E.result=m.sent(),E)];case 5:h=m.sent();return[2,{success:!1,message:"Failed to create a unique slug: ".concat(h.message),code:z.INTERNAL_SERVER_ERROR.CODE}];case 6:return[2]}})}).call(this)}},{key:"aggregate",value:function e(e){return o(function(){var t,n;return D(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);t={success:!0};return[4,this.model.aggregate(e)];case 1:return[2,(t.result=r.sent(),t)];case 2:n=r.sent();return[2,{success:!1,message:n.message,code:z.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})}).call(this)}}]);return e}();G(tZ,"MongooseController");var t0=tZ;export{Q as C_Collection,j as C_Db,Y as C_Document,q as C_Model,w as MONGO_MIGRATE_OPTIONS,tz as MongoController,t0 as MongooseController,$ as aggregatePaginate,tJ as mongo,J as mongoosePaginate};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e,t,n,r,s,a,c){try{var o=e[a](c);var u=o.value}catch(e){n(e);return}if(o.done){t(u)}else{Promise.resolve(u).then(r,s)}}function s(e){return function(){var t=this,n=arguments;return new Promise(function(s,a){var c=e.apply(t,n);function o(e){r(c,s,a,o,u,"next",e)}function u(e){r(c,s,a,o,u,"throw",e)}o(undefined)})}}function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}function o(e,t,n){if(t)c(e.prototype,t);if(n)c(e,n);return e}function u(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function i(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function l(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function f(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var s=true;var a=false;var c,o;try{for(n=n.call(e);!(s=(c=n.next()).done);s=true){r.push(c.value);if(t&&r.length===t)break}}catch(e){a=true;o=e}finally{try{if(!s&&n["return"]!=null)n["return"]()}finally{if(a)throw o}}return r}function d(){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 E(){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 g(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var r=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}r.forEach(function(t){u(e,t,n[t])})}return e}function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}n.push.apply(n,r)}return n}function v(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{h(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function m(e,n){return t(e)||f(e,n)||O(e,n)||d()}function p(e){return n(e)||l(e)||O(e)||E()}function y(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function O(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function S(e,t){var n,r,s,a={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},c=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return c.next=o(0),c["throw"]=o(1),c["return"]=o(2),typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(e){return function(t){return u([e,t])}}function u(o){if(n)throw new TypeError("Generator is already executing.");while(c&&(c=0,o[0]&&(a=0)),a)try{if(n=1,r&&(s=o[0]&2?r["return"]:o[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;if(r=0,s)o=[o[0]&2,s.value];switch(o[0]){case 0:case 1:s=o;break;case 4:a.label++;return{value:o[1],done:false};case 5:a.label++;r=o[1];o=[0];continue;case 7:o=a.ops.pop();a.trys.pop();continue;default:if(!(s=a.trys,s=s.length>0&&s[s.length-1])&&(o[0]===6||o[0]===2)){a=0;continue}if(o[0]===3&&(!s||o[1]>s[0]&&o[1]<s[3])){a.label=o[1];break}if(o[0]===6&&a.label<s[1]){a.label=s[1];s=o;break}if(s&&a.label<s[2]){a.label=s[2];a.ops.push(o);break}if(s[2])a.ops.pop();a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e];r=0}finally{n=s=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}}var R=Object.create;var I=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var _=function(e,t,n){return t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n};var b=function(e,t){return I(e,"name",{value:t,configurable:!0})};var N=function(e,t){for(var n in t)I(e,n,{get:t[n],enumerable:!0})},G=function(e,t,n,r){var s=true,a=false,c=undefined;if(t&&(typeof t==="undefined"?"undefined":y(t))=="object"||typeof t=="function")try{var o=function(){var s=i.value;!D.call(e,s)&&s!==n&&I(e,s,{get:function(){return t[s]},enumerable:!(r=C(t,s))||r.enumerable})};for(var u=T(t)[Symbol.iterator](),i;!(s=(i=u.next()).done);s=true)o()}catch(e){a=true;c=e}finally{try{if(!s&&u.return!=null){u.return()}}finally{if(a){throw c}}}return e};var M=function(e,t,n){return n=e!=null?R(A(e)):{},G(t||!e||!e.__esModule?I(n,"default",{value:e,enumerable:!0}):n,e)},w=function(e){return G(I({},"__esModule",{value:!0}),e)};var L=function(e,t,n){return _(e,(typeof t==="undefined"?"undefined":y(t))!="symbol"?t+"":t,n)};var P={};N(P,{MongoController:function(){return tq},MongooseController:function(){return tB},aggregatePaginate:function(){return j.default},mongo:function(){return tj},mongoosePaginate:function(){return x.default}});module.exports=w(P);var U=require("date-fns"),k=M(require("migrate-mongo"),1),F=require("mongoose"),j=M(require("mongoose-aggregate-paginate-v2"),1),x=M(require("mongoose-paginate-v2"),1),q=require("uuid");var Y={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};var B=M(require("unorm"),1);var H={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},V=Object.entries(H).reduce(function(e,t){var n=m(t,2),r=n[0],s=n[1];return e[r.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function Q(e){return(typeof e==="undefined"?"undefined":y(e))=="object"&&e!==null&&!Array.isArray(e)}b(Q,"isObject");var K=M(require("crypto-js"),1),W=M(require("slugify"),1);var $=W.default.default||W.default;function J(e,t){var n=b(function(e){var n,r;return $(e!==null&&e!==void 0?e:"",g({lower:(n=t===null||t===void 0?void 0:t.lower)!==null&&n!==void 0?n:!0,locale:(r=t===null||t===void 0?void 0:t.locale)!==null&&r!==void 0?r:"vi"},t))},"slugifyWithOptions");if(Q(e)){var r={};var s=true,a=false,c=undefined;try{for(var o=Object.entries(e)[Symbol.iterator](),u;!(s=(u=o.next()).done);s=true){var i=m(u.value,2),l=i[0],f=i[1];r[l]=n(f)}}catch(e){a=true;c=e}finally{try{if(!s&&o.return!=null){o.return()}}finally{if(a){throw c}}}return r}return n(e)}b(J,"generateSlug");function X(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return K.default.SHA256(e).toString(K.default.enc.Hex).slice(0,t)}b(X,"generateShortId");var z={isEmpty:function e(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":y(e))=="object"?i(e,Date)?!1:i(e,Map)||i(e,Set)?e.size===0:i(e,WeakMap)||i(e,WeakSet)?!0:ArrayBuffer.isView(e)?e.byteLength===0:Object.keys(e).length===0:!1},isValidIP:function e(e){var t=e.split(".");return t.length===4&&t.every(function(e){return/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255})?!0:/^(([a-f\d]{1,4}:){7}[a-f\d]{1,4}|((?:[a-f\d]{1,4}:){1,7}:)|((?:[a-f\d]{1,4}:){1,6}:[a-f\d]{1,4})|::)$/i.test(e)}};var Z=M(require("fs-extra"),1);var ee=".cyberskill-storage";var et=M(require("@dotenvx/dotenvx"),1),en=require("envalid"),er=M(require("os"),1),es=M(require("path"),1),ea=M(require("process"),1);var ec=!1;function eo(){ec||(et.default.config(),ec=!0)}b(eo,"loadEnvFile");function eu(){eo();var e=(0,en.cleanEnv)(ea.default.env,{CWD:(0,en.str)({default:ea.default.cwd()}),DEBUG:(0,en.bool)({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:(0,en.str)({default:es.default.join(er.default.homedir(),ee)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}b(eu,"getEnv");var ei=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});var el=require("child_process"),ef=M(require("process"),1),ed=M(require("util"),1);var eE=function(e){return e.Error="error",e.Warning="warning",e}({});var eg=M(require("chalk"),1),eh=M(require("consola"),1),ev=require("graphql");var em=eu();em.DEBUG||(eh.default.level=4);function ep(e){var t=eg.default[e];return typeof t=="function"?t:eg.default.green}b(ep,"chalkKeyword");var ey={silent:eh.default.silent,level:eh.default.level,fatal:eh.default.fatal,error:eh.default.error,warn:eh.default.warn,log:eh.default.log,info:eh.default.info,success:eh.default.success,ready:eh.default.ready,start:eh.default.start,box:eh.default.box,debug:eh.default.debug,trace:eh.default.trace,verbose:eh.default.verbose,printBoxedLog:function e(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){eh.default.box(eg.default.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,s=e.rule,a=e.message;eh.default.log("".concat(eg.default.gray("File:")," ").concat(eg.default.blue("".concat(t).concat(r?":".concat(r):"")))),s&&eh.default.log(" ".concat(ep(n)("Rule:")," ").concat(s)),eh.default.log(" ".concat(ep(n)("Message:")," ").concat(a))}),eh.default.box(ep(n)("".concat(e," : ").concat(t.length))),eh.default.log(eg.default.gray("─".repeat(40)))}};var eO={isCurrentProject:!1,installedPath:"",file:{},isUpToDate:!1};var eS=M(require("node-fetch"),1);var eR=eu();function eI(e){var t=eK(eR.CWD,eZ);if(!tF(t))return!1;try{var n=tP(t),r=n.name,s=n.dependencies,a=s===void 0?{}:s,c=n.devDependencies,o=c===void 0?{}:c,u=r===e,i=e in a,l=e in o;return u||i||l?{path:t,file:n,isCurrentProject:u,isDepend:i,isDevDepend:l}:!1}catch(e){return ey.warn("Failed to read package.json: ".concat(e.message)),!1}}b(eI,"getPackage");function eC(e){return s(function(){var t,n,r,s;return S(this,function(a){switch(a.label){case 0:a.trys.push([0,3,,4]);return[4,(0,eS.default)("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=a.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:n=a.sent(),r=n.version;return[2,r];case 3:s=a.sent();throw ey.error('Failed to fetch version for "'.concat(e,'": ').concat(s.message)),s;case 4:return[2]}})})()}b(eC,"getLatestPackageVersion");function eT(e,t){return s(function(){var n,r,s,a,c,o,u,i,l,f,d,E,h,v,m,p,y,O,R,I,C;return S(this,function(S){switch(S.label){case 0:S.trys.push([0,4,,5]);n=eI(e);if(!n)return[2,g({},eO)];u=n.path,i=n.file,l=n.isCurrentProject,f=n.isDepend,d=n.isDevDepend,E=(r=i.dependencies)!==null&&r!==void 0?r:{},h=(s=i.devDependencies)!==null&&s!==void 0?s:{},v=l?(a=i.version)!==null&&a!==void 0?a:"0.0.0":f?(c=E[e])!==null&&c!==void 0?c:"0.0.0":d?(o=h[e])!==null&&o!==void 0?o:"0.0.0":"0.0.0";if(!l)return[3,1];y=v;return[3,3];case 1:return[4,eC(e)];case 2:y=S.sent();S.label=3;case 3:m=y,p=l||v===m;if(!p&&(t===null||t===void 0?void 0:t.update)){;R=f?"dependencies":d?"devDependencies":null;R&&((O=i[R])===null||O===void 0?void 0:O[e])!==m&&(i[R]=(I=i[R])!==null&&I!==void 0?I:{},i[R][e]=m,tU(u,JSON.stringify(i,null,4)),ey.info('Updated "'.concat(e,'" to version ').concat(m)))}return[2,{isCurrentProject:l,installedPath:u,file:i,isUpToDate:p}];case 4:C=S.sent();return[2,(ey.error('Error checking package "'.concat(e,'": ').concat(C.message)),g({},eO))];case 5:return[2]}})})()}b(eT,"checkPackage");function eA(){return s(function(){var e,t,n,r,s,a,c,o,u,i,l,f;return S(this,function(d){switch(d.label){case 0:e=[{command:b(function(){return tD.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:b(function(){return tD.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:b(function(){return tD.pnpmInstallForce()},"command"),message:"Retrying with force install"}];t=true,n=false,r=undefined;d.label=1;case 1:d.trys.push([1,9,10,11]);s=e[Symbol.iterator]();d.label=2;case 2:if(!!(t=(a=s.next()).done))return[3,8];c=a.value,o=c.command,u=c.message;d.label=3;case 3:d.trys.push([3,6,,7]);return[4,o()];case 4:i=d.sent();return[4,eY("".concat(u," using: ").concat(i),i)];case 5:d.sent();return[2];case 6:l=d.sent();ey.warn("Installation attempt failed: ".concat(u)),ey.error("Details: ".concat(l.message));return[3,7];case 7:t=true;return[3,2];case 8:return[3,11];case 9:f=d.sent();n=true;r=f;return[3,11];case 10:try{if(!t&&s.return!=null){s.return()}}finally{if(n){throw r}}return[7];case 11:throw new Error("All dependency installation strategies failed.")}})})()}b(eA,"installDependencies");function eD(e,t){return s(function(){var n,r,s,a,c,o,u,i,l,f,d;return S(this,function(E){switch(E.label){case 0:if(!tF(tC.PACKAGE_JSON)){ey.error("package.json not found. Aborting setup.");return[2]}E.label=1;case 1:E.trys.push([1,13,,14]);n=p(new Set(e)).sort();return[4,Promise.all(n.map(function(e){return eT(e,g({},(t===null||t===void 0?void 0:t.update)&&{update:t.update}))}))];case 2:r=E.sent().every(function(e){return e.isUpToDate});if(r)return[3,4];return[4,eA()];case 3:r=E.sent();E.label=4;case 4:r;a=true,c=false,o=undefined;E.label=5;case 5:E.trys.push([5,10,11,12]);u=((s=t===null||t===void 0?void 0:t.postInstallActions)!==null&&s!==void 0?s:[])[Symbol.iterator]();E.label=6;case 6:if(!!(a=(i=u.next()).done))return[3,9];l=i.value;return[4,l()];case 7:E.sent();E.label=8;case 8:a=true;return[3,6];case 9:return[3,12];case 10:f=E.sent();c=true;o=f;return[3,12];case 11:try{if(!a&&u.return!=null){u.return()}}finally{if(c){throw o}}return[7];case 12:return[3,14];case 13:d=E.sent();throw ey.error('Failed to setup "'.concat(e.join(", "),'": ').concat(d.message)),d;case 14:return[2]}})})()}b(eD,"setupPackages");var e_=M(require("node-persist"),1);var eb=eu();function eN(){return s(function(){var e;return S(this,function(t){switch(t.label){case 0:e=e_.default.defaultInstance;if(e)return[3,2];return[4,e_.default.init({dir:eb.CYBERSKILL_STORAGE_DIRECTORY,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}b(eN,"initNodePersist");var eG={get:function e(e){return s(function(){var t,n;return S(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,eN()];case 1:r.sent();return[4,e_.default.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,(ey.error('[Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 4:return[2]}})})()},set:function e(e,t){return s(function(){var n;return S(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,eN()];case 1:r.sent();return[4,e_.default.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();ey.error('[Storage:set] Error setting key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return s(function(){var t;return S(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,eN()];case 1:n.sent();return[4,e_.default.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();ey.error('[Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return s(function(){var e,t;return S(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,eN()];case 1:n.sent();return[4,e_.default.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(ey.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,(ey.error("[Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return s(function(){return S(this,function(t){try{return[2,"".concat(eb.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,(ey.error("[Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var eM=eu(),ew=ed.promisify(el.exec);function eL(e){return"error_list:".concat(e)}b(eL,"getErrorListKey");function eP(e){return s(function(){var t,n,r;return S(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];t=Date.now(),n=eL(t);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,eG.set(n,{errors:e,timestamp:t})];case 2:a.sent(),setTimeout(function(){return s(function(){var e;return S(this,function(t){switch(t.label){case 0:return[4,eG.getLogLink(n)];case 1:e=t.sent();e&&ey.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},10);return[3,4];case 3:r=a.sent();ey.error("Failed to save errors: ".concat(r.message));return[3,4];case 4:return[2]}})})()}b(eP,"saveErrorListToStorage");function eU(e){var t=[],n=[],r="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,c=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var o,u,i,l,f;var d=s.exec(e)||[],E=a.exec(e)||[],g=c.exec(e)||[];var h,v,m,p,y,O;d.length&&r?t.push({file:r,position:"".concat(d[1],":").concat(d[2]),type:d[3]===eE.Error?eE.Error:eE.Warning,message:(h=d===null||d===void 0?void 0:(o=d[4])===null||o===void 0?void 0:o.trim())!==null&&h!==void 0?h:"",rule:(v=d===null||d===void 0?void 0:(u=d[5])===null||u===void 0?void 0:u.trim())!==null&&v!==void 0?v:""}):E.length?t.push({file:(m=E===null||E===void 0?void 0:E[1])!==null&&m!==void 0?m:"",position:"".concat(E[2],":").concat(E[3]),type:E[4]===eE.Error?eE.Error:eE.Warning,message:(p=E===null||E===void 0?void 0:(i=E[5])===null||i===void 0?void 0:i.trim())!==null&&p!==void 0?p:""}):g.length?t.push({file:"commitlint",type:eE.Error,message:(y=g===null||g===void 0?void 0:(l=g[1])===null||l===void 0?void 0:l.trim())!==null&&y!==void 0?y:"",rule:(O=g===null||g===void 0?void 0:(f=g[2])===null||f===void 0?void 0:f.trim())!==null&&O!==void 0?O:""}):n.push(e.trim())}}),t.length&&eP(t),eM.DEBUG&&n.length&&(ey.warn("Unmatched lines:"),n.forEach(function(e){return ey.info(" ".concat(e))}))}b(eU,"parseTextErrors");function ek(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,s=e.line,a=e.column,c=e.ruleId,o=e.message;n.push({type:r===2?eE.Error:eE.Warning,file:t,position:"".concat(s,":").concat(a),rule:c,message:o})})}),n.length&&eP(n)}catch(t){eU(e)}}b(ek,"parseCommandOutput");function eF(e){return s(function(e){var t,n,r,s,a,c,o,u,i;var l=arguments;return S(this,function(f){switch(f.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:ek;n=new AbortController;ef.default.on("SIGINT",function(){ey.warn("Process interrupted. Terminating..."),n.abort(),ef.default.exit()});f.label=1;case 1:f.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,ew(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=f.sent(),s=r.stdout,a=r.stderr;[s,a].forEach(function(e){return e&&t(e)});f.label=3;case 3:return[3,5];case 4:c=f.sent();o=c.stdout,u=c.stderr,i=c.message;[o,u].forEach(function(e){return e&&t(e)}),!u&&!o&&ey.error("Command failed: ".concat(i));return[3,5];case 5:return[2]}})}).apply(this,arguments)}b(eF,"executeCommand");function ej(e){return{raw:!0,cmd:e}}b(ej,"rawCommand");function ex(e,t){return(t===null||t===void 0?void 0:t.isRemote)?"".concat(th," ").concat(eJ," ").concat(e):(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(th," ").concat(td," ").concat(te," ").concat(e):"".concat(th," ").concat(e9," ").concat(e)}b(ex,"formatCLI");function eq(e,t){return typeof e=="function"?ex(e(t),t):(typeof e==="undefined"?"undefined":y(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?ex(e,t):e}b(eq,"formatCommand");function eY(e,t){return s(function(){var n;return S(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);ey.start("".concat(e)),eM.DEBUG&&ey.info("→ ".concat(t));return[4,eF(t)];case 1:r.sent(),ey.success("".concat(e," done."));return[3,3];case 2:n=r.sent();throw ey.error("".concat(e," failed: ").concat(n.message)),n;case 3:return[2]}})})()}b(eY,"runCommand");var eB=M(require("path"),1);var eH=eu(),eV=eB.default;function eQ(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=eV).resolve.apply(r,[eH.CWD].concat(p(t)))}b(eQ,"resolveWorkingPath");function eK(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=eV).join.apply(r,p(t))}b(eK,"join");var eW=eu(),e$=eW.CWD,eJ="@cyberskill/shared",eX="node_modules",ez="dist",eZ="package.json",e0="package-lock.json",e1="tsconfig.json",e2=".gitignore",e4=".simple-git-hooks.json",e3="pnpm-lock.yaml",e5=".git/hooks/",e6=".git/COMMIT_EDITMSG",e7=".migrate-mongo.config.js",e8=eK(e$,eX,eJ,ez),e9="cyberskill",te="src/nodejs/cli/index.ts",tt="eslint",tn="eslint",tr="vitest",ts="playwright",ta="vitest",tc="@commitlint/cli",to="commitlint",tu="lint-staged",ti="lint-staged",tl="typescript",tf="tsc",td="tsx",tE="git",tg="pnpm",th="pnpm exec",tv="simple-git-hooks",tm="simple-git-hooks",tp="@eslint/config-inspector",ty="eslint-config-inspector",tO="node-modules-inspector",tS="node-modules-inspector",tR="migrate-mongo",tI="./node_modules/migrate-mongo/bin/migrate-mongo",tC={CYBERSKILL_DIRECTORY:e8,WORKING_DIRECTORY:e$,TS_CONFIG:eQ(e1),GIT_IGNORE:eQ(e2),GIT_HOOK:eQ(e5),GIT_COMMIT_MSG:eQ(e6),SIMPLE_GIT_HOOKS_JSON:eQ(e4),PACKAGE_JSON:eQ(eZ),PACKAGE_LOCK_JSON:eQ(e0),PNPM_LOCK_YAML:eQ(e3),NODE_MODULES:eQ(eX),MIGRATE_MONGO_CONFIG:eQ(e7),LINT_STAGED_CONFIG:eQ("".concat(e8,"/configs/lint-staged/index.js")),COMMITLINT_CONFIG:eQ("".concat(e8,"/configs/commitlint/index.js")),UNIT_TEST_CONFIG:eQ("".concat(e8,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:eQ("".concat(e8,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:eQ("".concat(e8,"/react/vitest/vitest.e2e.js"))};function tT(e,t,n){return s(function(){return S(this,function(r){switch(r.label){case 0:if(!t)throw new Error("'first' argument is undefined");switch(e){case ei.CLI:return[3,1];case ei.STRING:return[3,3]}return[3,4];case 1:return[4,eD(t.split(" "),{update:!0})];case 2:return[2,(r.sent(),eq(ej("".concat(th," ").concat(n))))];case 3:return[2,eq(ej(t))];case 4:throw new Error("Unsupported command type");case 5:return[2]}})})()}b(tT,"buildCommand");function tA(e,t,n){return function(){return s(function(){return S(this,function(r){return[2,tT(e,t,n)]})})()}}b(tA,"commandFactory");var tD={simpleGitHooks:tA(ei.CLI,tv,tm),eslintInspect:tA(ei.CLI,tp,ty),nodeModulesInspect:tA(ei.CLI,tO,tS),eslintCheck:tA(ei.CLI,tt,"".concat(tn," ").concat(tC.WORKING_DIRECTORY," --no-cache")),eslintFix:tA(ei.CLI,tt,"".concat(tn," ").concat(tC.WORKING_DIRECTORY," --fix --no-cache")),typescriptCheck:tA(ei.CLI,tl,"".concat(tf," -p ").concat(tC.TS_CONFIG," --noEmit")),configureGitHook:tA(ei.STRING,"".concat(tE," config core.hooksPath ").concat(tC.GIT_HOOK)),testUnit:tA(ei.CLI,tr,"".concat(ta," --config ").concat(tC.UNIT_TEST_CONFIG)),testE2e:tA(ei.CLI,"".concat(tr," ").concat(ts),"".concat(ta," --config ").concat(tC.E2E_TEST_CONFIG)),mongoMigrateCreate:b(function(e){return tA(ei.CLI,tR,"".concat(td," ").concat(tI," create ").concat(e," -f ").concat(tC.MIGRATE_MONGO_CONFIG))()},"mongoMigrateCreate"),mongoMigrateUp:tA(ei.CLI,tR,"".concat(td," ").concat(tI," up -f ").concat(tC.MIGRATE_MONGO_CONFIG)),mongoMigrateDown:tA(ei.CLI,tR,"".concat(td," ").concat(tI," down -f ").concat(tC.MIGRATE_MONGO_CONFIG)),commitLint:tA(ei.CLI,tc,"".concat(to," --edit ").concat(tC.GIT_COMMIT_MSG," --config ").concat(tC.COMMITLINT_CONFIG)),lintStaged:tA(ei.CLI,tu,"".concat(ti," --config ").concat(tC.LINT_STAGED_CONFIG)),stageBuildDirectory:tA(ei.STRING,"".concat(tE," add ").concat(ez)),build:tA(ei.STRING,"".concat(tg," run build")),pnpmInstallStandard:tA(ei.STRING,"".concat(tg," install")),pnpmInstallLegacy:tA(ei.STRING,"".concat(tg," install --legacy-peer-deps")),pnpmInstallForce:tA(ei.STRING,"".concat(tg," install --force"))};var t_=Z.default,tb=t_.lstatSync,tN=t_.readdirSync,tG=t_.mkdirSync,tM=t_.readFileSync,tw=t_.unlinkSync,tL=t_.statSync,tP=Z.default.readJsonSync;function tU(e,t,n){Z.default.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}b(tU,"writeFileSync");function tk(e,t,n){Z.default.appendFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}b(tk,"appendFileSync");function tF(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return Z.default.pathExistsSync(e)})}b(tF,"pathExistsSync");var tj={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return(0,U.format)(e,"yyyy-MM-dd HH:mm:ss.SSS")},createGenericFields:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.returnDateAs,n=t===void 0?"string":t;var r=n==="string"?tj.getDateTime():new Date;return{id:(0,q.v4)(),isDel:!1,createdAt:r,updatedAt:r}},applyPlugins:function e(e,t){t.filter(function(e){return typeof e=="function"}).forEach(function(t){return e.plugin(t)})},applyMiddlewares:function e(e,t){t.forEach(function(t){var n=t.method,r=t.pre,s=t.post;n&&r&&e.pre(n,r),n&&s&&e.post(n,s)})},createGenericSchema:function e(e){return new e.Schema({id:{type:String,default:q.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})},createSchema:function e(e){var t=e.mongoose,n=e.schema,r=e.virtuals,s=r===void 0?[]:r,a=e.standalone,c=a===void 0?!1:a;var o=new t.Schema(n,{strict:!0});return s.forEach(function(e){var t=e.name,n=e.options,r=e.get;var s=o.virtual(t,n);r&&s.get(r)}),c||o.add(tj.createGenericSchema(t)),o},createModel:function e(e){var t=e.mongoose,n=e.name,r=e.schema,s=e.pagination,a=s===void 0?!1:s,c=e.aggregate,o=c===void 0?!1:c,u=e.virtuals,i=u===void 0?[]:u,l=e.middlewares,f=l===void 0?[]:l;if(!n)throw new Error("Model name is required.");if(t.models[n])return t.models[n];var d=tj.createSchema({mongoose:t,schema:r,virtuals:i});return tj.applyPlugins(d,[a&&x.default,o&&j.default]),tj.applyMiddlewares(d,f),t.model(n,d)},validator:{isEmpty:function e(){return function(e){return s(function(){return S(this,function(t){return[2,!z.isEmpty(e)]})})()}},isUnique:function e(e){return function(t){return s(function(){var n;return S(this,function(r){switch(r.label){case 0:if(!Array.isArray(e)||e.length===0)throw new Error("Fields must be a non-empty array of strings.");n={$or:e.map(function(e){return u({},e,t)})};return[4,this.constructor.exists(n)];case 1:return[2,!r.sent()]}})}).call(this)}},matchesRegex:function e(e){return function(t){return s(function(){return S(this,function(n){if(!Array.isArray(e)||e.some(function(e){return!i(e,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,e.every(function(e){return e.test(t)})]})})()}}},migrate:v(g({},k.default),{setConfig:b(function(e){var t="// This file is automatically generated by the Cyberskill CLI.\nmodule.exports = ".concat(JSON.stringify(e,null,4));tU(tC.MIGRATE_MONGO_CONFIG,t);var n="\n".concat(e7,"\n");tF(tC.GIT_IGNORE)?tM(tC.GIT_IGNORE,"utf-8").split("\n").includes(e7)||tk(tC.GIT_IGNORE,n):tU(tC.GIT_IGNORE,n)},"setConfig")})},tx=/*#__PURE__*/function(){function e(t,n){a(this,e);L(this,"collection");this.collection=t.collection(n)}o(e,[{key:"createOne",value:function e(e){return s(function(){var t,n,r;return S(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=g({},tj.createGenericFields(),e);n={success:!0,message:"Document created successfully"};return[4,this.collection.insertOne(t)];case 1:return[2,(n.result=s.sent(),n)];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return s(function(){var t,n,r;return S(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=e.map(function(e){return g({},tj.createGenericFields(),e)});return[4,this.collection.insertMany(t)];case 1:n=s.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:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"findOne",value:function e(e){return s(function(){var t,n;return S(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.findOne(e)];case 1:t=r.sent();return[2,t?{success:!0,message:"Document found",result:t}:{success:!1,message:"Document not found"}];case 2:n=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}},{key:"findAll",value:function e(){return s(function(){var e,t,n;var r=arguments;return S(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0,message:"Documents retrieved successfully"};return[4,this.collection.find(e).toArray()];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message}];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return s(function(){var e,t,n;var r=arguments;return S(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0,message:"Count retrieved successfully"};return[4,this.collection.countDocuments(e)];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(e,t){return s(function(){var n,r;return S(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,this.collection.updateOne(e,{$set:t})];case 1:n=s.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Document updated successfully",result:n}];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"updateMany",value:function e(e,t){return s(function(){var n,r;return S(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);return[4,this.collection.updateMany(e,{$set:t})];case 1:n=s.sent();return[2,n.matchedCount===0?{success:!1,message:"No documents matched the filter"}:{success:!0,message:"Documents updated successfully",result:n}];case 2:r=s.sent();return[2,{success:!1,message:r.message}];case 3:return[2]}})}).call(this)}},{key:"deleteOne",value:function e(e){return s(function(){var t,n;return S(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.deleteOne(e)];case 1:t=r.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=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}},{key:"deleteMany",value:function e(e){return s(function(){var t,n;return S(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,this.collection.deleteMany(e)];case 1:t=r.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=r.sent();return[2,{success:!1,message:n.message}];case 3:return[2]}})}).call(this)}}]);return e}();b(tx,"MongoController");var tq=tx,tY=/*#__PURE__*/function(){function e(t){a(this,e);L(this,"model");this.model=t}o(e,[{key:"getModelName",value:function e(){return this.model.modelName}},{key:"findOne",value:function e(e){return s(function(){var e,t,n,r,s,a,c;var o=arguments;return S(this,function(u){switch(u.label){case 0:e=o.length>0&&o[0]!==void 0?o[0]:{},t=o.length>1&&o[1]!==void 0?o[1]:{},n=o.length>2&&o[2]!==void 0?o[2]:{},r=o.length>3?o[3]:void 0;u.label=1;case 1:u.trys.push([1,3,,4]);s=this.model.findOne(e,t,n);r&&s.populate(r);return[4,s.exec()];case 2:a=u.sent();return[2,a?{success:!0,result:a}:{success:!1,message:"No ".concat(this.getModelName()," found."),code:Y.NOT_FOUND.CODE}];case 3:c=u.sent();return[2,{success:!1,message:c.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findAll",value:function e(e){return s(function(){var e,t,n,r,s,a,c;var o=arguments;return S(this,function(u){switch(u.label){case 0:e=o.length>0&&o[0]!==void 0?o[0]:{},t=o.length>1&&o[1]!==void 0?o[1]:{},n=o.length>2&&o[2]!==void 0?o[2]:{},r=o.length>3?o[3]:void 0;u.label=1;case 1:u.trys.push([1,3,,4]);s=this.model.find(e,t,n);r&&s.populate(r);a={success:!0};return[4,s.exec()];case 2:return[2,(a.result=u.sent(),a)];case 3:c=u.sent();return[2,{success:!1,message:c.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPaging",value:function e(){return s(function(){var e,t,n,r;var s=arguments;return S(this,function(a){switch(a.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);n={success:!0};return[4,this.model.paginate(e,t)];case 2:return[2,(n.result=a.sent(),n)];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPagingAggregate",value:function e(e){return s(function(e){var t,n,r;var s=arguments;return S(this,function(a){switch(a.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);n={success:!0};return[4,this.model.aggregatePaginate(this.model.aggregate(e),t)];case 2:return[2,(n.result=a.sent(),n)];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return s(function(){var e,t,n;var r=arguments;return S(this,function(s){switch(s.label){case 0:e=r.length>0&&r[0]!==void 0?r[0]:{};s.label=1;case 1:s.trys.push([1,3,,4]);t={success:!0};return[4,this.model.countDocuments(e)];case 2:return[2,(t.result=s.sent(),t)];case 3:n=s.sent();return[2,{success:!1,message:n.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"createOne",value:function e(e){return s(function(){var t,n;return S(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);t={success:!0};return[4,this.model.create(e)];case 1:return[2,(t.result=r.sent(),t)];case 2:n=r.sent();return[2,{success:!1,message:n.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return s(function(e){var t,n,r;var s=arguments;return S(this,function(a){switch(a.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);n={success:!0};return[4,this.model.insertMany(e,t)];case 2:return[2,(n.result=a.sent().map(function(e){return i(e,F.Document)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(){return s(function(){var e,t,n,r,s;var a=arguments;return S(this,function(c){switch(c.label){case 0:e=a.length>0&&a[0]!==void 0?a[0]:{},t=a.length>1&&a[1]!==void 0?a[1]:{},n=a.length>2&&a[2]!==void 0?a[2]:{};c.label=1;case 1:c.trys.push([1,3,,4]);return[4,this.model.findOneAndUpdate(e,t,g({new:!0},n)).exec()];case 2:r=c.sent();return[2,r?{success:!0,result:r}:{success:!1,message:"Failed to update ".concat(this.getModelName(),"."),code:Y.NOT_FOUND.CODE}];case 3:s=c.sent();return[2,{success:!1,message:s.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateMany",value:function e(){return s(function(){var e,t,n,r,s;var a=arguments;return S(this,function(c){switch(c.label){case 0:e=a.length>0&&a[0]!==void 0?a[0]:{},t=a.length>1&&a[1]!==void 0?a[1]:{},n=a.length>2&&a[2]!==void 0?a[2]:{};c.label=1;case 1:c.trys.push([1,3,,4]);r={success:!0};return[4,this.model.updateMany(e,t,n).exec()];case 2:return[2,(r.result=c.sent(),r)];case 3:s=c.sent();return[2,{success:!1,message:s.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteOne",value:function e(){return s(function(){var e,t,n,r;var s=arguments;return S(this,function(a){switch(a.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);return[4,this.model.findOneAndDelete(e,t).exec()];case 2:n=a.sent();return[2,n?{success:!0,result:n}:{success:!1,message:"No ".concat(this.getModelName()," found to delete."),code:Y.NOT_FOUND.CODE}];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteMany",value:function e(){return s(function(){var e,t,n,r;var s=arguments;return S(this,function(a){switch(a.label){case 0:e=s.length>0&&s[0]!==void 0?s[0]:{},t=s.length>1&&s[1]!==void 0?s[1]:{};a.label=1;case 1:a.trys.push([1,3,,4]);return[4,this.model.deleteMany(e,t).exec()];case 2:n=a.sent();return[2,n.deletedCount===0?{success:!1,message:"No documents found to delete.",code:Y.NOT_FOUND.CODE}:{success:!0,result:n}];case 3:r=a.sent();return[2,{success:!1,message:r.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 4:return[2]}})}).apply(this,arguments)}},{key:"createShortId",value:function e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return s(function(){var n,r,s,a;return S(this,function(c){switch(c.label){case 0:n=new Set;r=0;c.label=1;case 1:if(!(r<10))return[3,5];s=X(e,r+t);a=!n.has(s);if(!a)return[3,3];n.add(s);return[4,this.model.exists({shortId:s})];case 2:a=!c.sent();c.label=3;case 3:if(a)return[2,{success:!0,result:s}];c.label=4;case 4:r++;return[3,1];case 5:return[2,{success:!1,message:"Failed to create a unique shortId",code:Y.INTERNAL_SERVER_ERROR.CODE}]}})}).call(this)}},{key:"createSlug",value:function e(e,t,n){return s(function(){var r,a,c,o,i,l,f,d,E,h;return S(this,function(p){switch(p.label){case 0:r=this;p.label=1;case 1:p.trys.push([1,5,,6]);a=t[e],c=Q(a),o=b(function(t){var r=g({},n!==null&&n!==void 0?n:{});return c?v(g({},r),{$or:[u({},"slug.".concat(e),t),{slugHistory:{$elemMatch:u({},"slug.".concat(e),t)}}]}):v(g({},r),{$or:[{slug:t},{slugHistory:t}]})},"generateSlugQuery"),i=b(function(e){return s(function(){var t,n;return S(this,function(r){switch(r.label){case 0:t=e,n=1;r.label=1;case 1:return[4,this.model.exists(o(t))];case 2:if(!r.sent())return[3,4];t="".concat(e,"-").concat(n++);r.label=3;case 3:return[3,1];case 4:return[2,t]}})}).call(r)},"generateUniqueSlug");if(!c)return[3,3];l={success:!0};f=Object.fromEntries;return[4,Promise.all(Object.entries(a).map(function(e){var t=m(e,2),n=t[0],r=t[1];return s(function(){var e,t;return S(this,function(s){switch(s.label){case 0:e=J(r);t=[n];return[4,i(e)];case 1:return[2,t.concat([s.sent()])]}})})()}))];case 2:return[2,(l.result=f.apply(Object,[p.sent()]),l)];case 3:d=J(a);E={success:!0};return[4,i(d)];case 4:return[2,(E.result=p.sent(),E)];case 5:h=p.sent();return[2,{success:!1,message:"Failed to create a unique slug: ".concat(h.message),code:Y.INTERNAL_SERVER_ERROR.CODE}];case 6:return[2]}})}).call(this)}},{key:"aggregate",value:function e(e){return s(function(){var t,n;return S(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);t={success:!0};return[4,this.model.aggregate(e)];case 1:return[2,(t.result=r.sent(),t)];case 2:n=r.sent();return[2,{success:!1,message:n.message,code:Y.INTERNAL_SERVER_ERROR.CODE}];case 3:return[2]}})}).call(this)}}]);return e}();b(tY,"MongooseController");var tB=tY;0&&(module.exports={MongoController:MongoController,MongooseController:MongooseController,aggregatePaginate:aggregatePaginate,mongo:mongo,mongoosePaginate:mongoosePaginate});
|