@cyberskill/shared 1.169.0 → 1.170.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/dist/node/cli/cli.util.cjs +1 -1
- package/dist/node/cli/cli.util.js +1 -1
- package/dist/node/cli/index.cjs +1 -1
- package/dist/node/cli/index.js +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +1 -1
- package/package.json +4 -4
- package/public/renovate.base.json +1 -6
- package/public/wiki/clone-project.md +0 -99
- package/public/wiki/convention.md +0 -185
- package/public/wiki/setup-mongo.md +0 -29
- package/public/wiki/setup-nginx.md +0 -50
- package/public/wiki/setup-node.md +0 -29
- package/public/wiki/setup-pm2.md +0 -27
- package/public/wiki/setup-redis.md +0 -17
- package/public/wiki/setup-ssl.md +0 -102
package/dist/node/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 _(e,A()?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 p(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)D(e,t)}function f(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 E(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 g(){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 y(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 v(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{v(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=C(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 C(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 _(e,t){if(t&&(b(t)==="object"||typeof t==="function")){return t}return r(e)}function D(e,t){D=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return D(e,t)}function I(e,n){return t(e)||E(e,n)||T(e,n)||g()}function N(e){return n(e)||m(e)||T(e)||h()}function b(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 R(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 P=function(e,t){return x(e,"name",{value:t,configurable:!0})};var M=function(e,t,n){return G(e,(typeof t==="undefined"?"undefined":b(t))!="symbol"?t+"":t,n)};import{ApolloServer as w}from"@apollo/server";import{expressMiddleware as L}from"@apollo/server/express4";import{ApolloServerPluginDrainHttpServer as j}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 V from"consola";import{GraphQLError as Y}from"graphql";var K=".cyberskill-storage";import H from"@dotenvx/dotenvx";import{bool as B,cleanEnv as W,str as Q}from"envalid";import J from"os";import $ from"path";import z from"process";var X=function(e){return e.PRODUCTION="production",e.STAGING="staging",e.DEVELOPMENT="development",e}({});var Z=!1;function ee(){z.env.NODE_ENV!==X.PRODUCTION&&!Z&&(H.config(),Z=!0)}P(ee,"loadEnvFile");function et(){ee();var e=W(z.env,{CWD:Q({default:z.cwd()}),DEBUG:B({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:Q({default:$.join(J.homedir(),K)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}P(et,"getEnv");var en={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 er=et();function es(e){var t=e.message,n=e.status,r=n===void 0?en.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 Y(a,{extensions:{code:r.CODE}}):new Error(a)}P(es,"throwError");er.DEBUG||(V.level=4);function ei(e){var t=q[e];return typeof t=="function"?t:q.green}P(ei,"chalkKeyword");var eo={silent:V.silent,level:V.level,fatal:V.fatal,error:V.error,warn:V.warn,log:V.log,info:V.info,success:V.success,ready:V.ready,start:V.start,box:V.box,debug:V.debug,trace:V.trace,verbose:V.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)){V.box(q.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,s=e.rule,i=e.message;V.log("".concat(q.gray("File:")," ").concat(q.blue("".concat(t).concat(r?":".concat(r):"")))),s&&V.log(" ".concat(ei(n)("Rule:")," ").concat(s)),V.log(" ".concat(ei(n)("Message:")," ").concat(i))}),V.box(ei(n)("".concat(e," : ").concat(t.length))),V.log(q.gray("─".repeat(40)))}};function ea(e,t){var n=t!==null&&t!==void 0?t:{},r=n.shouldLog,s=r===void 0?!0:r,i=n.returnValue,o=n.callback,a=f(e,Error)?e:new Error(typeof e=="string"?e:"Unknown error");return s&&eo.error(a.message),o&&typeof o=="function"&&o(a),i||{success:!1,message:a.message,code:en.INTERNAL_SERVER_ERROR.CODE}}P(ea,"catchError");function ec(e){return new w(y({schema:e.schema,plugins:[e.isDev?k():U(),j({httpServer:e.server})].concat(N(e.drainServer?[{serverWillStart:function t(){return i(function(){return R(this,function(t){return[2,{drainServer:function t(){return i(function(){var t;return R(this,function(n){(t=e.drainServer)===null||t===void 0?void 0:t.call(e),eo.info("Apollo Server drainServer hook called");return[2]})})()}}]})})()}}]:[]))},e.isDev&&{introspection:!0,includeStacktraceInErrorResponses:!0}))}P(ec,"createApolloServer");import eu from"process";import{hideBin as el}from"yargs/helpers";import ed from"yargs/yargs";var ep={name:"@cyberskill/shared",type:"module",version:"1.168.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"},"./config":{types:"./dist/config/index.d.ts",import:"./dist/config/index.js",require:"./dist/config/index.cjs"},"./config/commitlint":{types:"./dist/config/commitlint/index.d.ts",import:"./dist/config/commitlint/index.js",require:"./dist/config/commitlint/index.cjs"},"./config/env":{types:"./dist/config/env/index.d.ts",import:"./dist/config/env/index.js",require:"./dist/config/env/index.cjs"},"./config/eslint":{types:"./dist/config/eslint/index.d.ts",import:"./dist/config/eslint/index.js",require:"./dist/config/eslint/index.cjs"},"./config/graphql-codegen":{types:"./dist/config/graphql-codegen/index.d.ts",import:"./dist/config/graphql-codegen/index.js",require:"./dist/config/graphql-codegen/index.cjs"},"./config/lint-staged":{types:"./dist/config/lint-staged/index.d.ts",import:"./dist/config/lint-staged/index.js",require:"./dist/config/lint-staged/index.cjs"},"./constant":{types:"./dist/constant/index.d.ts",import:"./dist/constant/index.js",require:"./dist/constant/index.cjs"},"./node":{types:"./dist/node/index.d.ts",import:"./dist/node/index.js",require:"./dist/node/index.cjs"},"./node/apollo-server":{types:"./dist/node/apollo-server/index.d.ts",import:"./dist/node/apollo-server/index.js",require:"./dist/node/apollo-server/index.cjs"},"./node/cli":{types:"./dist/node/cli/index.d.ts",import:"./dist/node/cli/index.js",require:"./dist/node/cli/index.cjs"},"./node/command":{types:"./dist/node/command/index.d.ts",import:"./dist/node/command/index.js",require:"./dist/node/command/index.cjs"},"./node/express":{types:"./dist/node/express/index.d.ts",import:"./dist/node/express/index.js",require:"./dist/node/express/index.cjs"},"./node/fs":{types:"./dist/node/fs/index.d.ts",import:"./dist/node/fs/index.js",require:"./dist/node/fs/index.cjs"},"./node/log":{types:"./dist/node/log/index.d.ts",import:"./dist/node/log/index.js",require:"./dist/node/log/index.cjs"},"./node/mongo":{types:"./dist/node/mongo/index.d.ts",import:"./dist/node/mongo/index.js",require:"./dist/node/mongo/index.cjs"},"./node/package":{types:"./dist/node/package/index.d.ts",import:"./dist/node/package/index.js",require:"./dist/node/package/index.cjs"},"./node/path":{types:"./dist/node/path/index.d.ts",import:"./dist/node/path/index.js",require:"./dist/node/path/index.cjs"},"./node/storage":{types:"./dist/node/storage/index.d.ts",import:"./dist/node/storage/index.js",require:"./dist/node/storage/index.cjs"},"./node/ws":{types:"./dist/node/ws/index.d.ts",import:"./dist/node/ws/index.js",require:"./dist/node/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"},"./style/reset.css":{import:"./dist/style/reset.css",require:"./dist/style/reset.css"},"./typescript":{types:"./dist/typescript/index.d.ts",import:"./dist/typescript/index.js",require:"./dist/typescript/index.cjs"},"./util":{types:"./dist/util/index.d.ts",import:"./dist/util/index.js",require:"./dist/util/index.cjs"}},typesVersions:{"*":{config:["dist/config/index.d.ts"],constant:["dist/constant/index.d.ts"],node:["dist/node/index.d.ts"],react:["dist/react/index.d.ts"],typescript:["dist/typescript/index.d.ts"],util:["dist/util/index.d.ts"]}},bin:{cyberskill:"dist/node/cli/index.js"},files:["dist","public"],scripts:{build:"tsup",dev:"tsup --watch",lint:"tsx src/node/cli/index.ts lint","lint:fix":"tsx src/node/cli/index.ts lint:fix","lint:inspect":"tsx src/node/cli/index.ts lint:inspect",reset:"tsx src/node/cli/index.ts reset",prepare:"tsx src/node/cli/index.ts prepare",inspect:"tsx src/node/cli/index.ts inspect","test:unit":"tsx src/node/cli/index.ts test:unit","test:e2e":"tsx src/node/cli/index.ts test:e2e",commitlint:"tsx src/node/cli/index.ts commitlint"},dependencies:{"@antfu/eslint-config":"4.13.1","@apollo/client":"3.13.8","@apollo/server":"4.12.1","@dotenvx/dotenvx":"1.44.0","@eddeee888/gcg-typescript-resolver-files":"0.12.1","@eslint-react/eslint-plugin":"1.49.0","@graphql-codegen/cli":"5.0.6","@graphql-codegen/client-preset":"4.8.1","@microsoft/api-extractor":"7.52.8","@nestjs/common":"11.1.1","@nestjs/core":"11.1.1","@next/eslint-plugin-next":"15.3.2","@testing-library/jest-dom":"6.6.3","@testing-library/react":"16.3.0","@vitejs/plugin-react-swc":"3.9.0","@vitest/browser":"3.1.3","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.2","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.1.0",graphql:"16.11.0","graphql-ws":"6.0.5",i18next:"25.2.0",jsdom:"26.1.0",localforage:"1.10.0","migrate-mongo":"12.1.3","modern-normalize":"3.0.1",mongodb:"6.16.0",mongoose:"8.15.0","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.89.0",slugify:"1.6.6",tsup:"8.5.0",tsx:"4.19.4",typescript:"5.8.3",unorm:"1.6.0",uuid:"11.1.0",vite:"6.3.5",vitest:"3.1.3","vitest-browser-react":"0.2.0",ws:"8.18.2",yargs:"17.7.2"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},devDependencies:{"@commitlint/cli":"19.8.1","@commitlint/config-conventional":"19.8.1","@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.18","@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/node":"22.15.19","@types/node-persist":"3.1.8","@types/react":"19.1.4","@types/react-dom":"19.1.5","@types/unorm":"1.3.31","@types/uuid":"10.0.0","@types/ws":"8.18.1","@types/yargs":"17.0.33",eslint:"9.27.0","lint-staged":"16.0.0","node-modules-inspector":"0.6.8","simple-git-hooks":"2.13.0"}};var ef=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});import{exec as em}from"child_process";import eE from"process";import*as eg from"util";var eh=function(e){return e.DEPENDENCY="dependencies",e.DEV_DEPENDENCY="devDependencies",e.PEER_DEPENDENCY="peerDependencies",e.BUNDLE_DEPENDENCY="bundleDependencies",e.OPTIONAL_DEPENDENCY="optionalDependencies",e}({});import ey from"node-fetch";import ev from"fs-extra";import eS from"path";var eO=ev,eC=ev.lstatSync,e_=ev.readdirSync,eD=ev.mkdirSync,eI=ev.readFileSync,eN=ev.unlinkSync,eb=ev.statSync,eT=ev.readJsonSync;function eA(e,t,n){ev.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}P(eA,"writeFileSync");function eR(e,t,n){ev.appendFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}P(eR,"appendFileSync");function ex(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return ev.pathExistsSync(e)})}P(ex,"pathExistsSync");function eG(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}t.forEach(function(e){ex(e)&&ev.removeSync(e)})}P(eG,"removeSync");function eP(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r=n.extensions,s=O(n,["extensions"]);ev.copySync(e,t,y({filter:P(function(e){return eb(e).isDirectory()||!r||r.length===0?!0:r.includes(eS.extname(e))},"filter")},s))}P(eP,"copySync");import eM from"fs-extra";import ew from"path";var eL=et(),ej=ew;function ek(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ej).resolve.apply(r,[eL.CWD].concat(N(t)))}P(ek,"resolveWorkingPath");function eU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ej).resolve.apply(r,N(t))}P(eU,"resolve");function eF(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ej).join.apply(r,N(t))}P(eF,"join");var eq=et(),eV=eq.CWD,eY="@cyberskill/shared",eK="node_modules",eH="dist",eB="package.json",eW="package-lock.json",eQ="tsconfig.json",eJ=".gitignore",e$=".simple-git-hooks.json",ez="pnpm-lock.yaml",eX=".git/hooks/",eZ=".git/COMMIT_EDITMSG",e0=".migrate-mongo.config.js",e1=function(){var e=eM.readJsonSync(ek(eB)).name===eY?eV:eF(eV,eK,eY);return eF(e,eH)}(),e2="cyberskill",e4="src/node/cli/index.ts",e3="eslint",e5="eslint",e8="vitest",e6="playwright",e7="vitest",e9="@commitlint/cli",te="@commitlint/config-conventional",tt="commitlint",tn="lint-staged",tr="lint-staged",ts="typescript",ti="tsc",to="tsx",ta="git",tc="pnpm",tu="pnpm exec",tl="simple-git-hooks",td="simple-git-hooks",tp="@eslint/config-inspector",tf="eslint-config-inspector",tm="node-modules-inspector",tE="node-modules-inspector",tg="migrate-mongo",th="./node_modules/migrate-mongo/bin/migrate-mongo",ty={CYBERSKILL_DIRECTORY:e1,WORKING_DIRECTORY:eV,TS_CONFIG:ek(eQ),GIT_IGNORE:ek(eJ),GIT_HOOK:ek(eX),GIT_COMMIT_MSG:ek(eZ),SIMPLE_GIT_HOOKS_JSON:ek(e$),PACKAGE_JSON:ek(eB),PACKAGE_LOCK_JSON:ek(eW),PNPM_LOCK_YAML:ek(ez),NODE_MODULES:ek(eK),MIGRATE_MONGO_CONFIG:ek(e0),LINT_STAGED_CONFIG:ek("".concat(e1,"/config/lint-staged/index.js")),COMMITLINT_CONFIG:ek("".concat(e1,"/config/commitlint/index.js")),UNIT_TEST_CONFIG:ek("".concat(e1,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:ek("".concat(e1,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:ek("".concat(e1,"/react/vitest/vitest.e2e.js"))};function tv(e){var t=e.isCurrentProject;return y({"pre-commit":tr,"commit-msg":tt},t&&{"pre-push":tq("".concat(ta," pull"))})}P(tv,"createGitHooksConfig");function tS(e){var t=e.type,n=e.packages,r=e.command;var s=n===null||n===void 0?void 0:n.reduce(function(e,t){return e.some(function(e){return e.name===t.name})||e.push(t),e},[]);return function(){return i(function(){var e;return R(this,function(n){switch(n.label){case 0:switch(t){case ef.CLI:return[3,1];case ef.STRING:return[3,4]}return[3,5];case 1:e=s===null||s===void 0?void 0:s.length;if(!e)return[3,3];return[4,tb(s,{install:!0})];case 2:e=n.sent();n.label=3;case 3:return[2,(e,tY(tq("".concat(tu," ").concat(r))))];case 4:return[2,tY(tq(r))];case 5:throw new Error("Unsupported command type");case 6:return[2]}})})()}}P(tS,"buildCommand");var tO={simpleGitHooks:tS({type:ef.CLI,packages:[{name:tl,type:eh.DEV_DEPENDENCY}],command:td}),eslintInspect:tS({type:ef.CLI,packages:[{name:tp,type:eh.DEV_DEPENDENCY}],command:tf}),nodeModulesInspect:tS({type:ef.CLI,packages:[{name:tm,type:eh.DEV_DEPENDENCY}],command:tE}),eslintCheck:tS({type:ef.CLI,packages:[{name:e3,type:eh.DEV_DEPENDENCY}],command:"".concat(e5," ").concat(ty.WORKING_DIRECTORY," --no-cache")}),eslintFix:tS({type:ef.CLI,packages:[{name:e3,type:eh.DEV_DEPENDENCY}],command:"".concat(e5," ").concat(ty.WORKING_DIRECTORY," --fix --no-cache")}),typescriptCheck:tS({type:ef.CLI,packages:[{name:ts,type:eh.DEPENDENCY}],command:"".concat(ti," -p ").concat(ty.TS_CONFIG," --noEmit")}),testUnit:tS({type:ef.CLI,packages:[{name:e8,type:eh.DEV_DEPENDENCY}],command:"".concat(e7," --config ").concat(ty.UNIT_TEST_CONFIG)}),testE2e:tS({type:ef.CLI,packages:[{name:e8,type:eh.DEV_DEPENDENCY}],command:"".concat(e7," --config ").concat(ty.E2E_TEST_CONFIG)}),mongoMigrateCreate:P(function(e){return tS({type:ef.CLI,packages:[{name:tg,type:eh.DEPENDENCY}],command:"".concat(to," ").concat(th," create ").concat(e," -f ").concat(ty.MIGRATE_MONGO_CONFIG)})()},"mongoMigrateCreate"),mongoMigrateUp:tS({type:ef.CLI,packages:[{name:tg,type:eh.DEPENDENCY}],command:"".concat(to," ").concat(th," up -f ").concat(ty.MIGRATE_MONGO_CONFIG)}),mongoMigrateDown:tS({type:ef.CLI,packages:[{name:tg,type:eh.DEPENDENCY}],command:"".concat(to," ").concat(th," down -f ").concat(ty.MIGRATE_MONGO_CONFIG)}),commitLint:tS({type:ef.CLI,packages:[{name:e9,type:eh.DEV_DEPENDENCY},{name:te,type:eh.DEV_DEPENDENCY}],command:"".concat(tt," --edit ").concat(ty.GIT_COMMIT_MSG," --config ").concat(ty.COMMITLINT_CONFIG)}),lintStaged:tS({type:ef.CLI,packages:[{name:tn,type:eh.DEV_DEPENDENCY}],command:"".concat(tr," --config ").concat(ty.LINT_STAGED_CONFIG)}),configureGitHook:tS({type:ef.STRING,command:"".concat(ta," config core.hooksPath ").concat(ty.GIT_HOOK)}),build:tS({type:ef.STRING,command:"".concat(tc," run --if-present build")}),pnpmInstallStandard:tS({type:ef.STRING,command:"".concat(tc," install --ignore-scripts")}),pnpmInstallLegacy:tS({type:ef.STRING,command:"".concat(tc," install --ignore-scripts --legacy-peer-deps")}),pnpmInstallForce:tS({type:ef.STRING,command:"".concat(tc," install --ignore-scripts --force")}),pnpmPruneStore:tS({type:ef.STRING,command:"".concat(tc," store prune")}),pnpmCleanCache:tS({type:ef.STRING,command:"".concat(tc," cache delete")})};var tC=et();function t_(e){return i(function(){var t,n,r,s;return R(this,function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);return[4,ey("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,{success:!0,result:r}];case 3:s=i.sent();return[2,ea(s)];case 4:return[2]}})})()}P(t_,"getLatestPackageVersion");function tD(e){return i(function(){var t,n,r,s,i,o,a,c,u,l,d,p,f,m,E,g,h,y,v,S,O,C,_,D;return R(this,function(I){switch(I.label){case 0:I.trys.push([0,2,,3]);if(!e){if(ex(ty.PACKAGE_JSON)){t=eT(ty.PACKAGE_JSON),n=t.name,r=n===void 0?"":n,s=t.version,i=s===void 0?"":s;return[2,{success:!0,result:{name:r,currentVersion:i,latestVersion:i,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:!1,isDevDependency:!1,installedPath:ty.PACKAGE_JSON,file:t}}]}return[2,{success:!0,result:{name:"",currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:!1,isDevDependency:!1,installedPath:"",file:{}}}]}if(!ex(ty.PACKAGE_JSON))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===eh.DEPENDENCY,isDevDependency:e.type===eh.DEV_DEPENDENCY,installedPath:"",file:{}}}];o=eT(ty.PACKAGE_JSON),a=o.name,c=o.version,u=c===void 0?"":c,l=o.dependencies,d=l===void 0?{}:l,p=o.devDependencies,f=p===void 0?{}:p;if(e.name===a)return[2,{success:!0,result:{name:a,currentVersion:u,latestVersion:u,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:e.type===eh.DEPENDENCY,isDevDependency:e.type===eh.DEV_DEPENDENCY,installedPath:ty.PACKAGE_JSON,file:o}}];m=e.name in d,E=e.name in f;return[4,t_(e.name)];case 1:g=I.sent();if(!g.success)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:E,installedPath:"",file:{}}}];if(!m&&!E)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:g.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===eh.DEPENDENCY,isDevDependency:e.type===eh.DEV_DEPENDENCY,installedPath:"",file:{}}}];v=(y=(h=d[e.name])!==null&&h!==void 0?h:f[e.name])!==null&&y!==void 0?y:"",S=eF(tC.CWD,eK,e.name,eB);if(!ex(S))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:g.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:E,installedPath:"",file:{}}}];O=eT(S),C=O.version,_=C===void 0?"":C;return[2,v!==_?{success:!0,result:{name:e.name,currentVersion:_||v,latestVersion:g.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:!1,isDependency:m,isDevDependency:E,installedPath:S,file:O}}:{success:!0,result:{name:e.name,currentVersion:v,latestVersion:g.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:v===g.result,isDependency:m,isDevDependency:E,installedPath:S,file:O}}];case 2:D=I.sent();return[2,ea(D)];case 3:return[2]}})})()}P(tD,"getPackage");function tI(e){return i(function(){var t,n,r,s,i;return R(this,function(o){try{;r=eT(ty.PACKAGE_JSON),s=(t=r.dependencies)!==null&&t!==void 0?t:{},i=(n=r.devDependencies)!==null&&n!==void 0?n:{};e.isDependency?s[e.name]=e.latestVersion:e.isDevDependency&&(i[e.name]=e.latestVersion),eA(ty.PACKAGE_JSON,JSON.stringify(r,null,4)),eo.info('Updated "'.concat(e.name,'" to version ').concat(e.latestVersion))}catch(e){ea(e)}return[2]})})()}P(tI,"updatePackage");function tN(){return i(function(){var e,t,n,r,s,i,o,a,c,u,l,d,p;return R(this,function(f){switch(f.label){case 0:f.trys.push([0,12,,13]);e=[{command:P(function(){return tO.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:P(function(){return tO.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:P(function(){return tO.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,tH("".concat(c," using: ").concat(u),u)];case 5:f.sent();return[2];case 6:l=f.sent();ea(l);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:return[3,13];case 12:p=f.sent();ea(p);return[3,13];case 13:return[2]}})})()}P(tN,"installDependencies");function tb(e,t){return i(function(){var n,r,s,i,o,a,c,u,l,d,p,f,m,E,g,h,y;return R(this,function(v){switch(v.label){case 0:v.trys.push([0,15,,16]);if(!ex(ty.PACKAGE_JSON)){eo.error("package.json not found. Aborting setup.");return[2]}return[4,Promise.all(e.map(tD))];case 1:s=v.sent().filter(function(e){return e.success&&!!e.result&&!e.result.isCurrentProject}).map(function(e){return e.result}),i=s.filter(function(e){return!e.isInstalled}),o=s.filter(function(e){return!e.isUpToDate}),a=[];(t===null||t===void 0?void 0:t.install)&&i.length>0&&(n=a).push.apply(n,N(i.map(tI))),(t===null||t===void 0?void 0:t.update)&&o.length>0&&(r=a).push.apply(r,N(o.map(tI)));c=a.length>0;if(!c)return[3,6];return[4,Promise.all(a)];case 2:v.sent();return[4,tN()];case 3:v.sent();u=["Running ESLint with auto-fix"];return[4,tO.eslintFix()];case 4:return[4,tH.apply(void 0,u.concat([v.sent()]))];case 5:c=v.sent();v.label=6;case 6:c;d=true,p=false,f=undefined;v.label=7;case 7:v.trys.push([7,12,13,14]);m=((l=t===null||t===void 0?void 0:t.callbacks)!==null&&l!==void 0?l:[])[Symbol.iterator]();v.label=8;case 8:if(!!(d=(E=m.next()).done))return[3,11];g=E.value;return[4,g()];case 9:v.sent();v.label=10;case 10:d=true;return[3,8];case 11:return[3,14];case 12:h=v.sent();p=true;f=h;return[3,14];case 13:try{if(!d&&m.return!=null){m.return()}}finally{if(p){throw f}}return[7];case 14:return[3,16];case 15:y=v.sent();ea(y);return[3,16];case 16:return[2]}})})()}P(tb,"setupPackages");import tT from"node-persist";var tA=et();function tR(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=tT.defaultInstance;if(e)return[3,2];return[4,tT.init({dir:tA.CYBERSKILL_STORAGE_DIRECTORY})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}P(tR,"initNodePersist");var tx={get:function e(e){return i(function(){var t,n;return R(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tR()];case 1:r.sent();return[4,tT.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,ea(n,{returnValue:null})];case 4:return[2]}})})()},set:function e(e,t){return i(function(){var n;return R(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tR()];case 1:r.sent();return[4,tT.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();ea(n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return i(function(){var t;return R(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tR()];case 1:n.sent();return[4,tT.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();ea(t);return[3,4];case 4:return[2]}})})()},keys:function e(){return i(function(){var e,t;return R(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tR()];case 1:n.sent();return[4,tT.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(eo.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,ea(t,{returnValue:[]})];case 4:return[2]}})})()},getLogLink:function e(e){return i(function(){return R(this,function(t){try{return[2,"".concat(tA.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,ea(e,{returnValue:null})]}return[2]})})()}};var tG=et(),tP=eg.promisify(em);function tM(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:return[4,tD()];case 1:e=t.sent();return[2,e.success?e.result.name:Date.now().toString()]}})})()}P(tM,"getPackageName");function tw(e){return i(function(){var t,n;return R(this,function(r){switch(r.label){case 0:if(e.length===0)return[2];return[4,tM()];case 1:t=r.sent();r.label=2;case 2:r.trys.push([2,4,,5]);return[4,tx.set(t,e)];case 3:r.sent(),setTimeout(function(){return i(function(){var e;return R(this,function(n){switch(n.label){case 0:return[4,tx.getLogLink(t)];case 1:e=n.sent();e&&eo.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},0);return[3,5];case 4:n=r.sent();ea(n);return[3,5];case 5:return[2]}})})()}P(tw,"saveErrorListToStorage");function tL(){return i(function(){var e,t,n;return R(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tM()];case 1:e=r.sent();return[4,tx.get(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:[]];case 3:n=r.sent();return[2,ea(n,{returnValue:[]})];case 4:return[2]}})})()}P(tL,"getStoredErrorLists");function tj(){return i(function(){var e,t;return R(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tM()];case 1:e=n.sent();return[4,tx.remove(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();ea(t);return[3,4];case 4:return[2]}})})()}P(tj,"clearAllErrorLists");function tk(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 p=s.exec(e)||[],f=i.exec(e)||[],m=o.exec(e)||[];var E,g,h,y,v,S;p.length&&r?t.push({file:r,position:"".concat(p[1],":").concat(p[2]),type:p[3]===F.Error?F.Error:F.Warning,message:(E=p===null||p===void 0?void 0:(a=p[4])===null||a===void 0?void 0:a.trim())!==null&&E!==void 0?E:"",rule:(g=p===null||p===void 0?void 0:(c=p[5])===null||c===void 0?void 0:c.trim())!==null&&g!==void 0?g:""}):f.length?t.push({file:(h=f===null||f===void 0?void 0:f[1])!==null&&h!==void 0?h:"",position:"".concat(f[2],":").concat(f[3]),type:f[4]===F.Error?F.Error:F.Warning,message:(y=f===null||f===void 0?void 0:(u=f[5])===null||u===void 0?void 0:u.trim())!==null&&y!==void 0?y:""}):m.length?t.push({file:"commitlint",type:F.Error,message:(v=m===null||m===void 0?void 0:(l=m[1])===null||l===void 0?void 0:l.trim())!==null&&v!==void 0?v:"",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&&tw(t),tG.DEBUG&&n.length&&(eo.warn("Unmatched lines:"),n.forEach(function(e){return eo.info(" ".concat(e))}))}P(tk,"parseTextErrors");function tU(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&&tw(n)}catch(t){tk(e)}}P(tU,"parseCommandOutput");function tF(e){return i(function(e){var t,n,r,s,i,o,a,c,u;var l=arguments;return R(this,function(d){switch(d.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:tU;n=new AbortController;eE.on("SIGINT",function(){eo.warn("Process interrupted. Terminating..."),n.abort(),eE.exit()});d.label=1;case 1:d.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,tP(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&&eo.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}P(tF,"executeCommand");function tq(e){return{raw:!0,cmd:e}}P(tq,"rawCommand");function tV(e,t){return(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(tu," ").concat(to," ").concat(e4," ").concat(e):"".concat(tu," ").concat(e2," ").concat(e)}P(tV,"formatCLI");function tY(e,t){return typeof e=="function"?tV(e(t),t):(typeof e==="undefined"?"undefined":b(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?tV(e,t):e}P(tY,"formatCommand");function tK(e){return i(function(){var t,n,r;return R(this,function(s){switch(s.label){case 0:return[4,tD({name:eY})];case 1:t=s.sent();if(t.success){n={isCurrentProject:t.result.isCurrentProject},r=typeof e=="function"?e(n):e;return[2,Object.fromEntries(Object.entries(r).map(function(e){var t=I(e,2),r=t[0],s=t[1];return[r,tY(s,n)]}))]}return[2]}})})()}P(tK,"resolveCommands");function tH(e,t){return i(function(){var n;return R(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);eo.start("".concat(e)),tG.DEBUG&&eo.info("→ ".concat(t));return[4,tF(t)];case 1:r.sent(),eo.success("".concat(e," done."));return[3,3];case 2:n=r.sent();ea(n);return[3,3];case 3:return[2]}})})()}P(tH,"runCommand");function tB(){return i(function(){var e,t;return R(this,function(n){switch(n.label){case 0:if(!ex(ty.TS_CONFIG))return[3,3];t=["Performing TypeScript validation"];return[4,tO.typescriptCheck()];case 1:return[4,tH.apply(void 0,t.concat([n.sent()]))];case 2:e=n.sent();return[3,4];case 3:e=eo.warn("No TypeScript configuration found. Skipping type check.");n.label=4;case 4:e;return[2]}})})()}P(tB,"checkTypescript");function tW(){return i(function(){var e,t,n,r;var s=arguments;return R(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,tO.eslintFix()];case 1:return[4,tH.apply(void 0,n.concat([i.sent()]))];case 2:t=i.sent();return[3,6];case 3:r=["Running ESLint check"];return[4,tO.eslintCheck()];case 4:return[4,tH.apply(void 0,r.concat([i.sent()]))];case 5:t=i.sent();i.label=6;case 6:t;return[2]}})}).apply(this,arguments)}P(tW,"checkEslint");function tQ(e,t){if(!t.length)return;var n=e==="Errors"?"red":"yellow";eo.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",t,n)}P(tQ,"printIssues");function tJ(){return i(function(){return R(this,function(e){setTimeout(function(){return i(function(){var e,t,n;return R(this,function(r){switch(r.label){case 0:return[4,tL()];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?eo.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(tQ("Warnings",n),tQ("Errors",t),(t.length>0||n.length>0)&&eu.exit(1));return[2]}})})()},0);return[2]})})()}P(tJ,"showCheckResult");function t$(){return i(function(){var e,t,n,r;return R(this,function(s){switch(s.label){case 0:return[4,tj()];case 1:s.sent();return[4,tD({name:eY})];case 2:e=s.sent();if(!e.success){eo.error("Failed to retrieve package information. Aborting lint-staged.");return[2]}t=e.result.isCurrentProject;if(!t)return[3,5];n=["Building package: ".concat(eY)];return[4,tO.build()];case 3:return[4,tH.apply(void 0,n.concat([s.sent()]))];case 4:t=s.sent();s.label=5;case 5:t;r=["Executing lint-staged"];return[4,tO.lintStaged()];case 6:return[4,tH.apply(void 0,r.concat([s.sent()]))];case 7:s.sent(),tJ();return[2]}})})()}P(t$,"lintStaged");function tz(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Inspecting ESLint configuration"];return[4,tO.eslintInspect()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(tz,"inspectLint");function tX(){return i(function(){return R(this,function(e){switch(e.label){case 0:return[4,tj()];case 1:e.sent();return[4,Promise.all([tB(),tW()])];case 2:e.sent(),tJ();return[2]}})})()}P(tX,"lintCheck");function tZ(){return i(function(){return R(this,function(e){switch(e.label){case 0:return[4,tj()];case 1:e.sent();return[4,Promise.all([tB(),tW(!0)])];case 2:e.sent(),tJ();return[2]}})})()}P(tZ,"lintFix");function t0(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:return[4,tj()];case 1:t.sent();e=["Validating commit message"];return[4,tO.commitLint()];case 2:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 3:t.sent(),tJ();return[2]}})})()}P(t0,"commitLint");function t1(){return i(function(){var e,t,n,r;return R(this,function(s){switch(s.label){case 0:e=["Configuring Git hooks"];return[4,tO.configureGitHook()];case 1:return[4,tH.apply(void 0,e.concat([s.sent()]))];case 2:s.sent(),eG(ty.GIT_HOOK);return[4,tK(tv)];case 3:t=s.sent();eA(ty.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(t,null,4));n="\n".concat(e$,"\n");ex(ty.GIT_IGNORE)?eI(ty.GIT_IGNORE,"utf-8").split("\n").includes(e$)||eR(ty.GIT_IGNORE,n):eA(ty.GIT_IGNORE,n);r=["Setting up simple-git-hooks"];return[4,tO.simpleGitHooks()];case 4:return[4,tH.apply(void 0,r.concat([s.sent()]))];case 5:s.sent();return[2]}})})()}P(t1,"setupGitHook");function t2(){return i(function(){return R(this,function(e){switch(e.label){case 0:return[4,tN()];case 1:e.sent();return[4,t1()];case 2:e.sent();return[2]}})})()}P(t2,"prepare");function t4(){return i(function(){var e,t;return R(this,function(n){switch(n.label){case 0:eG(ty.NODE_MODULES,ty.PNPM_LOCK_YAML);e=["Pruning pnpm store"];return[4,tO.pnpmPruneStore()];case 1:return[4,tH.apply(void 0,e.concat([n.sent()]))];case 2:n.sent();t=["Clearing pnpm cache"];return[4,tO.pnpmCleanCache()];case 3:return[4,tH.apply(void 0,t.concat([n.sent()]))];case 4:n.sent();return[4,tN()];case 5:n.sent();return[4,t1()];case 6:n.sent();return[2]}})})()}P(t4,"reset");function t3(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Inspecting project dependencies"];return[4,tO.nodeModulesInspect()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t3,"inspect");function t5(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Running unit tests"];return[4,tO.testUnit()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t5,"testUnit");function t8(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Running end-to-end tests"];return[4,tO.testE2e()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t8,"testE2E");function t6(e){return i(function(){var t;return R(this,function(n){switch(n.label){case 0:t=["Creating MongoDB migration"];return[4,tO.mongoMigrateCreate(e)];case 1:return[4,tH.apply(void 0,t.concat([n.sent()]))];case 2:n.sent();return[2]}})})()}P(t6,"mongoMigrateCreate");function t7(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Running MongoDB migrations"];return[4,tO.mongoMigrateUp()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t7,"mongoMigrateUp");function t9(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Rolling back MongoDB migration"];return[4,tO.mongoMigrateDown()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t9,"mongoMigrateDown");(function(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,ed(el(eu.argv)).scriptName(e2).usage("$0 <command> [options]").command("lint","Check code for linting issues",tX).command("lint:fix","Fix linting issues automatically",tZ).command("lint:inspect","View active ESLint configuration",tz).command("lint-staged","Run lint checks on staged files",t$).command("commitlint","Validate commit message format",t0).command("prepare","Initialize project and dependencies",t2).command("reset","Reset the project and reinstall dependencies",t4).command("inspect","Analyze installed project dependencies",t3).command("test:unit","Run unit test suite",t5).command("test:e2e","Run end-to-end test suite",t8).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 R(this,function(t){switch(t.label){case 0:if(!e.name){eo.error("Migration name is required.");return[2]}return[4,t6(e.name)];case 1:t.sent();return[2]}})})()}).command("mongo:migrate:up","Apply all MongoDB migrations",t7).command("mongo:migrate:down","Rollback last MongoDB migration",t9).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(ep.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();ea(e),eu.exit(1);return[3,3];case 3:return[2]}})})()})();import{Router as ne}from"express";import{NestFactory as nt}from"@nestjs/core";import nn from"body-parser";import nr from"compression";import ns from"cookie-parser";import ni from"cors";import no from"express";import na from"express-session";import nc from"express-useragent";function nu(e){var t=e.isDev,n=e.whiteList,r=O(e,["isDev","whiteList"]);return y({origin:P(function(e,r){t||!e||(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)}P(nu,"createCorsOptions");function nl(e){return ni(nu(e))}P(nl,"createCors");function nd(e){return na(e)}P(nd,"createSession");function np(e){var t=no();return t.set("trust proxy",1),t.use(ns()),t.use(no.urlencoded({extended:!0})),t.use(nr()),t.use(nc.express()),(e===null||e===void 0?void 0:e.staticFolder)&&t.use(no.static(e.staticFolder)),t}P(np,"createExpress");function nf(e){return i(function(){var t,n,r;return R(this,function(s){switch(s.label){case 0:return[4,nt.create(e.module)];case 1:r=s.sent();return[2,(r.getHttpAdapter().getInstance().set("trust proxy",1),r.use(no.urlencoded({extended:!0})),r.use(ns()),r.use(nr()),r.use(nc.express()),e.staticFolder&&r.use(no.static(e.staticFolder)),e.filters&&(t=r).useGlobalFilters.apply(t,N(e.filters)),e.pipes&&(n=r).useGlobalPipes.apply(n,N(e.pipes)),r)]}})})()}P(nf,"createNest");var nm="MONGO_MIGRATE_OPTIONS";import{Collection as nE,Db as ng}from"mongodb";import{Document as nh,Model as ny}from"mongoose";var nv=/*#__PURE__*/function(e){"use strict";p(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(ng);P(nv,"C_Db");var nS=nv,nO=/*#__PURE__*/function(e){"use strict";p(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(nh);P(nO,"C_Document");var nC=nO,n_=/*#__PURE__*/function(e){"use strict";p(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(ny);P(n_,"C_Model");var nD=n_,nI=/*#__PURE__*/function(e){"use strict";p(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(nE);P(nI,"C_Collection");var nN=nI;import{format as nb}from"date-fns";import nT from"migrate-mongo";import{Document as nA}from"mongoose";import nR from"mongoose-aggregate-paginate-v2";import nx from"mongoose-paginate-v2";import{v4 as nG}from"uuid";import nP from"unorm";var nM={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},nw=Object.entries(nM).reduce(function(e,t){var n=I(t,2),r=n[0],s=n[1];return e[r.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function nL(e){return(typeof e==="undefined"?"undefined":b(e))=="object"&&e!==null&&!Array.isArray(e)}P(nL,"isObject");import nj from"crypto-js";import nk from"slugify";var nU=nk.default||nk;function nF(e,t){var n=P(function(e){var n,r;return nU(e!==null&&e!==void 0?e:"",y({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(nL(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=I(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)}P(nF,"generateSlug");function nq(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return nj.SHA256(e).toString(nj.enc.Hex).slice(0,t)}P(nq,"generateShortId");var nV={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":b(e))=="object"?f(e,Date)?!1:f(e,Map)||f(e,Set)?e.size===0:f(e,WeakMap)||f(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 nY={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return nb(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"?nY.getDateTime():new Date;return{id:nG(),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:nG,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(nY.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 p=nY.createSchema({mongoose:t,schema:r,virtuals:u});return nY.applyPlugins(p,[i&&nx,a&&nR]),nY.applyMiddlewares(p,d),t.model(n,p)},validator:{isEmpty:function e(){return function(e){return i(function(){return R(this,function(t){return[2,!nV.isEmpty(e)]})})()}},isUnique:function e(e){return function(t){return i(function(){var n;return R(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 R(this,function(n){if(!Array.isArray(e)||e.some(function(e){return!f(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(y({},nT),{setConfig:P(function(e){var t="// This file is automatically generated by the Cyberskill CLI.\nmodule.exports = ".concat(JSON.stringify(e,null,4));eA(ty.MIGRATE_MONGO_CONFIG,t);var n="\n".concat(e0,"\n");ex(ty.GIT_IGNORE)?eI(ty.GIT_IGNORE,"utf-8").split("\n").includes(e0)||eR(ty.GIT_IGNORE,n):eA(ty.GIT_IGNORE,n)},"setConfig")})},nK=/*#__PURE__*/function(){"use strict";function e(t,n){a(this,e);M(this,"collection");this.collection=t.collection(n)}u(e,[{key:"createOne",value:function e(e){return i(function(){var t,n,r;return R(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=y({},nY.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,ea(r)];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return i(function(){var t,n,r;return R(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=e.map(function(e){return y({},nY.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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"".concat(n.insertedCount," documents created successfully"),result:n}];case 2:r=s.sent();return[2,ea(r)];case 3:return[2]}})}).call(this)}},{key:"findOne",value:function e(e){return i(function(){var t,n;return R(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",code:en.NOT_FOUND.CODE}];case 2:n=r.sent();return[2,ea(n)];case 3:return[2]}})}).call(this)}},{key:"findAll",value:function e(){return i(function(){var e,t,n;var r=arguments;return R(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,ea(n)];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return i(function(){var e,t,n;var r=arguments;return R(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,ea(n)];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(e,t){return i(function(){var n,r;return R(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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document updated successfully",result:n}];case 2:r=s.sent();return[2,ea(r)];case 3:return[2]}})}).call(this)}},{key:"updateMany",value:function e(e,t){return i(function(){var n,r;return R(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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents updated successfully",result:n}];case 2:r=s.sent();return[2,ea(r)];case 3:return[2]}})}).call(this)}},{key:"deleteOne",value:function e(e){return i(function(){var t,n;return R(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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document deleted successfully",result:t}];case 2:n=r.sent();return[2,ea(n)];case 3:return[2]}})}).call(this)}},{key:"deleteMany",value:function e(e){return i(function(){var t,n;return R(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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents deleted successfully",result:t}];case 2:n=r.sent();return[2,ea(n)];case 3:return[2]}})}).call(this)}}]);return e}();P(nK,"MongoController");var nH=nK,nB=/*#__PURE__*/function(){"use strict";function e(t){a(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 i(function(){var e,t,n,r,s,i,o;var a=arguments;return R(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:en.NOT_FOUND.CODE}];case 3:o=c.sent();return[2,ea(o)];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 R(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,ea(o)];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPaging",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return R(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,ea(r)];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 R(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,ea(r)];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return i(function(){var e,t,n;var r=arguments;return R(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,ea(n)];case 4:return[2]}})}).apply(this,arguments)}},{key:"createOne",value:function e(e){return i(function(){var t,n;return R(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,ea(n)];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return i(function(e){var t,n,r;var s=arguments;return R(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 f(e,nA)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 3:r=i.sent();return[2,ea(r)];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 R(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,y({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:en.NOT_FOUND.CODE}];case 3:s=o.sent();return[2,ea(s)];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 R(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,ea(s)];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteOne",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return R(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:en.NOT_FOUND.CODE}];case 3:r=i.sent();return[2,ea(r)];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteMany",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return R(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:en.NOT_FOUND.CODE}:{success:!0,result:n}];case 3:r=i.sent();return[2,ea(r)];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,o;return R(this,function(a){switch(a.label){case 0:a.trys.push([0,6,,7]);n=new Set;r=0;a.label=1;case 1:if(!(r<10))return[3,5];s=nq(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=!a.sent();a.label=3;case 3:if(i)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:en.INTERNAL_SERVER_ERROR.CODE}];case 6:o=a.sent();return[2,ea(o)];case 7:return[2]}})}).call(this)}},{key:"createSlugQuery",value:function e(e){var t=e.slug,n=e.field,r=e.isObject,s=e.filter;var i=y({},s!==null&&s!==void 0?s:{});return r?S(y({},i),{$or:[l({},"slug.".concat(n),t),{slugHistory:{$elemMatch:l({},"slug.".concat(n),t)}}]}):S(y({},i),{$or:[{slug:t},{slugHistory:t}]})}},{key:"createUniqueSlug",value:function e(e){return i(function(e){var t,n,r,s,i,o,a;return R(this,function(c){switch(c.label){case 0:t=e.slug,n=e.field,r=e.isObject,s=e.filter;i=nF(t),o=i,a=1;c.label=1;case 1:return[4,this.model.exists(this.createSlugQuery({slug:o,field:n,isObject:r,filter:s}))];case 2:if(!c.sent())return[3,4];o="".concat(i,"-").concat(a++);c.label=3;case 3:return[3,1];case 4:return[2,o]}})}).apply(this,arguments)}},{key:"createSlug",value:function e(e){return i(function(e){var t,n,r,s,o,a,c,u,l,d;return R(this,function(p){switch(p.label){case 0:t=this;n=e.field,r=e.from,s=e.filter;p.label=1;case 1:p.trys.push([1,6,,7]);o=r[n];if(!nL(o))return[3,3];c={success:!0};u=Object.fromEntries;return[4,Promise.all(Object.entries(o).map(function(e){var n=I(e,2),r=n[0],o=n[1];return i(function(){var e;return R(this,function(t){switch(t.label){case 0:return[4,this.createUniqueSlug({slug:o,field:r,isObject:!0,filter:s})];case 1:e=t.sent();return[2,[r,e]]}})}).call(t)}))];case 2:a=(c.result=u.apply(Object,[p.sent()]),c);return[3,5];case 3:l={success:!0};return[4,this.createUniqueSlug({slug:o,field:n,isObject:!1,filter:s})];case 4:a=(l.result=p.sent(),l);p.label=5;case 5:return[2,a];case 6:d=p.sent();return[2,ea(d)];case 7:return[2]}})}).apply(this,arguments)}},{key:"checkSlug",value:function e(e){return i(function(e){var t,n,r,s,i,o,a,c,u,l,d,p,f,m,E,g;return R(this,function(h){switch(h.label){case 0:t=e.slug,n=e.field,r=e.from,s=e.filter;h.label=1;case 1:h.trys.push([1,12,,13]);i=r[n];if(!nL(i))return[3,10];o=true,a=false,c=undefined;h.label=2;case 2:h.trys.push([2,7,8,9]);u=Object.values(i)[Symbol.iterator]();h.label=3;case 3:if(!!(o=(l=u.next()).done))return[3,6];d=l.value;p=nF(d);return[4,this.model.exists(this.createSlugQuery({slug:p,field:n,isObject:!0,filter:s}))];case 4:if(h.sent())return[2,{success:!0,result:!0}];h.label=5;case 5:o=true;return[3,3];case 6:return[3,9];case 7:f=h.sent();a=true;c=f;return[3,9];case 8:try{if(!o&&u.return!=null){u.return()}}finally{if(a){throw c}}return[7];case 9:return[2,{success:!0,result:!1}];case 10:m=nF(t);E={success:!0};return[4,this.model.exists(this.createSlugQuery({slug:m,field:n,isObject:!1,filter:s}))];case 11:return[2,(E.result=h.sent()!==null,E)];case 12:g=h.sent();return[2,ea(g)];case 13:return[2]}})}).apply(this,arguments)}},{key:"aggregate",value:function e(e){return i(function(){var t,n;return R(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,ea(n)];case 3:return[2]}})}).call(this)}}]);return e}();P(nB,"MongooseController");var nW=nB;import{useServer as nQ}from"graphql-ws/use/ws";import{WebSocketServer as nJ}from"ws";function n$(e){return new nJ({server:e.server,path:e.path})}P(n$,"createWSServer");function nz(e){return nQ({schema:e.schema},e.server)}P(nz,"initGraphQLWS");export{eH as BUILD_DIRECTORY,tt as COMMIT_LINT_CLI,te as COMMIT_LINT_CONVENTIONAL_CONFIG_PACKAGE_NAME,e9 as COMMIT_LINT_PACKAGE_NAME,e2 as CYBERSKILL_CLI,e4 as CYBERSKILL_CLI_PATH,e1 as CYBERSKILL_DIRECTORY,eY as CYBERSKILL_PACKAGE_NAME,nN as C_Collection,nS as C_Db,nC as C_Document,nD as C_Model,e5 as ESLINT_CLI,tf as ESLINT_INSPECT_CLI,tp as ESLINT_INSPECT_PACKAGE_NAME,e3 as ESLINT_PACKAGE_NAME,ef as E_CommandType,F as E_IssueType,eh as E_PackageType,ta as GIT_CLI,eZ as GIT_COMMIT_EDITMSG,eX as GIT_HOOK,eJ as GIT_IGNORE,tr as LINT_STAGED_CLI,tn as LINT_STAGED_PACKAGE_NAME,th as MIGRATE_MONGO_CLI,e0 as MIGRATE_MONGO_CONFIG,tg as MIGRATE_MONGO_PACKAGE_NAME,nm as MONGO_MIGRATE_OPTIONS,nH as MongoController,nW as MongooseController,eK as NODE_MODULES,tE as NODE_MODULES_INSPECT_CLI,tm as NODE_MODULES_INSPECT_PACKAGE_NAME,eB as PACKAGE_JSON,eW as PACKAGE_LOCK_JSON,ty as PATH,e6 as PLAYWRIGHT_PACKAGE_NAME,tc as PNPM_CLI,tu as PNPM_EXEC_CLI,ez as PNPM_LOCK_YAML,ne as Router,tl as SIMPLE_GIT_HOOKS_PACKAGE_NAME,td as SIMPLE_GIT_HOOK_CLI,e$ as SIMPLE_GIT_HOOK_JSON,eQ as TSCONFIG_JSON,ti as TSC_CLI,ts as TSC_PACKAGE_NAME,to as TSX_CLI,e7 as VITEST_CLI,e8 as VITEST_PACKAGE_NAME,eV as WORKING_DIRECTORY,nR as aggregatePaginate,eR as appendFileSync,nn as bodyParser,ea as catchError,tj as clearAllErrorLists,tO as command,eP as copySync,ec as createApolloServer,nl as createCors,nu as createCorsOptions,np as createExpress,tv as createGitHooksConfig,nf as createNest,nd as createSession,n$ as createWSServer,no as express,L as expressMiddleware,tY as formatCommand,eO as fs,t_ as getLatestPackageVersion,tD as getPackage,tL as getStoredErrorLists,nz as initGraphQLWS,tN as installDependencies,eF as join,eo as log,eC as lstatSync,eD as mkdirSync,nY as mongo,nx as mongoosePaginate,ej as path,ex as pathExistsSync,tq as rawCommand,eI as readFileSync,eT as readJsonSync,e_ as readdirSync,eG as removeSync,eU as resolve,tK as resolveCommands,ek as resolveWorkingPath,tH as runCommand,tb as setupPackages,eb as statSync,tx as storage,es as throwError,eN as unlinkSync,tI as updatePackage,eA as writeFileSync};
|
|
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 _(e,A()?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 p(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)D(e,t)}function f(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 E(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 g(){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 y(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 v(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{v(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=C(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 C(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 _(e,t){if(t&&(b(t)==="object"||typeof t==="function")){return t}return r(e)}function D(e,t){D=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return D(e,t)}function I(e,n){return t(e)||E(e,n)||T(e,n)||g()}function N(e){return n(e)||m(e)||T(e)||h()}function b(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 R(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 P=function(e,t){return x(e,"name",{value:t,configurable:!0})};var M=function(e,t,n){return G(e,(typeof t==="undefined"?"undefined":b(t))!="symbol"?t+"":t,n)};import{ApolloServer as w}from"@apollo/server";import{expressMiddleware as L}from"@apollo/server/express4";import{ApolloServerPluginDrainHttpServer as j}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 V from"consola";import{GraphQLError as Y}from"graphql";var K=".cyberskill-storage";import H from"@dotenvx/dotenvx";import{bool as B,cleanEnv as W,str as Q}from"envalid";import J from"os";import $ from"path";import z from"process";var X=function(e){return e.PRODUCTION="production",e.STAGING="staging",e.DEVELOPMENT="development",e}({});var Z=!1;function ee(){z.env.NODE_ENV!==X.PRODUCTION&&!Z&&(H.config(),Z=!0)}P(ee,"loadEnvFile");function et(){ee();var e=W(z.env,{CWD:Q({default:z.cwd()}),DEBUG:B({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:Q({default:$.join(J.homedir(),K)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}P(et,"getEnv");var en={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 er=et();function es(e){var t=e.message,n=e.status,r=n===void 0?en.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 Y(a,{extensions:{code:r.CODE}}):new Error(a)}P(es,"throwError");er.DEBUG||(V.level=4);function ei(e){var t=q[e];return typeof t=="function"?t:q.green}P(ei,"chalkKeyword");var eo={silent:V.silent,level:V.level,fatal:V.fatal,error:V.error,warn:V.warn,log:V.log,info:V.info,success:V.success,ready:V.ready,start:V.start,box:V.box,debug:V.debug,trace:V.trace,verbose:V.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)){V.box(q.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,s=e.rule,i=e.message;V.log("".concat(q.gray("File:")," ").concat(q.blue("".concat(t).concat(r?":".concat(r):"")))),s&&V.log(" ".concat(ei(n)("Rule:")," ").concat(s)),V.log(" ".concat(ei(n)("Message:")," ").concat(i))}),V.box(ei(n)("".concat(e," : ").concat(t.length))),V.log(q.gray("─".repeat(40)))}};function ea(e,t){var n=t!==null&&t!==void 0?t:{},r=n.shouldLog,s=r===void 0?!0:r,i=n.returnValue,o=n.callback,a=f(e,Error)?e:new Error(typeof e=="string"?e:"Unknown error");return s&&eo.error(a.message),o&&typeof o=="function"&&o(a),i||{success:!1,message:a.message,code:en.INTERNAL_SERVER_ERROR.CODE}}P(ea,"catchError");function ec(e){return new w(y({schema:e.schema,plugins:[e.isDev?k():U(),j({httpServer:e.server})].concat(N(e.drainServer?[{serverWillStart:function t(){return i(function(){return R(this,function(t){return[2,{drainServer:function t(){return i(function(){var t;return R(this,function(n){(t=e.drainServer)===null||t===void 0?void 0:t.call(e),eo.info("Apollo Server drainServer hook called");return[2]})})()}}]})})()}}]:[]))},e.isDev&&{introspection:!0,includeStacktraceInErrorResponses:!0}))}P(ec,"createApolloServer");import eu from"process";import{hideBin as el}from"yargs/helpers";import ed from"yargs/yargs";var ep={name:"@cyberskill/shared",type:"module",version:"1.169.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"},"./config":{types:"./dist/config/index.d.ts",import:"./dist/config/index.js",require:"./dist/config/index.cjs"},"./config/commitlint":{types:"./dist/config/commitlint/index.d.ts",import:"./dist/config/commitlint/index.js",require:"./dist/config/commitlint/index.cjs"},"./config/env":{types:"./dist/config/env/index.d.ts",import:"./dist/config/env/index.js",require:"./dist/config/env/index.cjs"},"./config/eslint":{types:"./dist/config/eslint/index.d.ts",import:"./dist/config/eslint/index.js",require:"./dist/config/eslint/index.cjs"},"./config/graphql-codegen":{types:"./dist/config/graphql-codegen/index.d.ts",import:"./dist/config/graphql-codegen/index.js",require:"./dist/config/graphql-codegen/index.cjs"},"./config/lint-staged":{types:"./dist/config/lint-staged/index.d.ts",import:"./dist/config/lint-staged/index.js",require:"./dist/config/lint-staged/index.cjs"},"./constant":{types:"./dist/constant/index.d.ts",import:"./dist/constant/index.js",require:"./dist/constant/index.cjs"},"./node":{types:"./dist/node/index.d.ts",import:"./dist/node/index.js",require:"./dist/node/index.cjs"},"./node/apollo-server":{types:"./dist/node/apollo-server/index.d.ts",import:"./dist/node/apollo-server/index.js",require:"./dist/node/apollo-server/index.cjs"},"./node/cli":{types:"./dist/node/cli/index.d.ts",import:"./dist/node/cli/index.js",require:"./dist/node/cli/index.cjs"},"./node/command":{types:"./dist/node/command/index.d.ts",import:"./dist/node/command/index.js",require:"./dist/node/command/index.cjs"},"./node/express":{types:"./dist/node/express/index.d.ts",import:"./dist/node/express/index.js",require:"./dist/node/express/index.cjs"},"./node/fs":{types:"./dist/node/fs/index.d.ts",import:"./dist/node/fs/index.js",require:"./dist/node/fs/index.cjs"},"./node/log":{types:"./dist/node/log/index.d.ts",import:"./dist/node/log/index.js",require:"./dist/node/log/index.cjs"},"./node/mongo":{types:"./dist/node/mongo/index.d.ts",import:"./dist/node/mongo/index.js",require:"./dist/node/mongo/index.cjs"},"./node/package":{types:"./dist/node/package/index.d.ts",import:"./dist/node/package/index.js",require:"./dist/node/package/index.cjs"},"./node/path":{types:"./dist/node/path/index.d.ts",import:"./dist/node/path/index.js",require:"./dist/node/path/index.cjs"},"./node/storage":{types:"./dist/node/storage/index.d.ts",import:"./dist/node/storage/index.js",require:"./dist/node/storage/index.cjs"},"./node/ws":{types:"./dist/node/ws/index.d.ts",import:"./dist/node/ws/index.js",require:"./dist/node/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"},"./style/reset.css":{import:"./dist/style/reset.css",require:"./dist/style/reset.css"},"./typescript":{types:"./dist/typescript/index.d.ts",import:"./dist/typescript/index.js",require:"./dist/typescript/index.cjs"},"./util":{types:"./dist/util/index.d.ts",import:"./dist/util/index.js",require:"./dist/util/index.cjs"}},typesVersions:{"*":{config:["dist/config/index.d.ts"],constant:["dist/constant/index.d.ts"],node:["dist/node/index.d.ts"],react:["dist/react/index.d.ts"],typescript:["dist/typescript/index.d.ts"],util:["dist/util/index.d.ts"]}},bin:{cyberskill:"dist/node/cli/index.js"},files:["dist","public"],scripts:{build:"tsup",dev:"tsup --watch",lint:"tsx src/node/cli/index.ts lint","lint:fix":"tsx src/node/cli/index.ts lint:fix","lint:inspect":"tsx src/node/cli/index.ts lint:inspect",reset:"tsx src/node/cli/index.ts reset",prepare:"tsx src/node/cli/index.ts prepare",inspect:"tsx src/node/cli/index.ts inspect","test:unit":"tsx src/node/cli/index.ts test:unit","test:e2e":"tsx src/node/cli/index.ts test:e2e",commitlint:"tsx src/node/cli/index.ts commitlint"},dependencies:{"@antfu/eslint-config":"4.13.1","@apollo/client":"3.13.8","@apollo/server":"4.12.1","@dotenvx/dotenvx":"1.44.1","@eddeee888/gcg-typescript-resolver-files":"0.12.1","@eslint-react/eslint-plugin":"1.49.0","@graphql-codegen/cli":"5.0.6","@graphql-codegen/client-preset":"4.8.1","@microsoft/api-extractor":"7.52.8","@nestjs/common":"11.1.1","@nestjs/core":"11.1.1","@next/eslint-plugin-next":"15.3.2","@testing-library/jest-dom":"6.6.3","@testing-library/react":"16.3.0","@vitejs/plugin-react-swc":"3.9.0","@vitest/browser":"3.1.4","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.2","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.1.0",graphql:"16.11.0","graphql-ws":"6.0.5",i18next:"25.2.0",jsdom:"26.1.0",localforage:"1.10.0","migrate-mongo":"12.1.3","modern-normalize":"3.0.1",mongodb:"6.16.0",mongoose:"8.15.0","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.89.0",slugify:"1.6.6",tsup:"8.5.0",tsx:"4.19.4",typescript:"5.8.3",unorm:"1.6.0",uuid:"11.1.0",vite:"6.3.5",vitest:"3.1.4","vitest-browser-react":"0.2.0",ws:"8.18.2",yargs:"17.7.2"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},devDependencies:{"@commitlint/cli":"19.8.1","@commitlint/config-conventional":"19.8.1","@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.18","@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/node":"22.15.19","@types/node-persist":"3.1.8","@types/react":"19.1.4","@types/react-dom":"19.1.5","@types/unorm":"1.3.31","@types/uuid":"10.0.0","@types/ws":"8.18.1","@types/yargs":"17.0.33",eslint:"9.27.0","lint-staged":"16.0.0","node-modules-inspector":"0.6.8","simple-git-hooks":"2.13.0"}};var ef=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});import{exec as em}from"child_process";import eE from"process";import*as eg from"util";var eh=function(e){return e.DEPENDENCY="dependencies",e.DEV_DEPENDENCY="devDependencies",e.PEER_DEPENDENCY="peerDependencies",e.BUNDLE_DEPENDENCY="bundleDependencies",e.OPTIONAL_DEPENDENCY="optionalDependencies",e}({});import ey from"node-fetch";import ev from"fs-extra";import eS from"path";var eO=ev,eC=ev.lstatSync,e_=ev.readdirSync,eD=ev.mkdirSync,eI=ev.readFileSync,eN=ev.unlinkSync,eb=ev.statSync,eT=ev.readJsonSync;function eA(e,t,n){ev.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}P(eA,"writeFileSync");function eR(e,t,n){ev.appendFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}P(eR,"appendFileSync");function ex(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return ev.pathExistsSync(e)})}P(ex,"pathExistsSync");function eG(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}t.forEach(function(e){ex(e)&&ev.removeSync(e)})}P(eG,"removeSync");function eP(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r=n.extensions,s=O(n,["extensions"]);ev.copySync(e,t,y({filter:P(function(e){return eb(e).isDirectory()||!r||r.length===0?!0:r.includes(eS.extname(e))},"filter")},s))}P(eP,"copySync");import eM from"fs-extra";import ew from"path";var eL=et(),ej=ew;function ek(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ej).resolve.apply(r,[eL.CWD].concat(N(t)))}P(ek,"resolveWorkingPath");function eU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ej).resolve.apply(r,N(t))}P(eU,"resolve");function eF(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ej).join.apply(r,N(t))}P(eF,"join");var eq=et(),eV=eq.CWD,eY="@cyberskill/shared",eK="node_modules",eH="dist",eB="package.json",eW="package-lock.json",eQ="tsconfig.json",eJ=".gitignore",e$=".simple-git-hooks.json",ez="pnpm-lock.yaml",eX=".git/hooks/",eZ=".git/COMMIT_EDITMSG",e0=".migrate-mongo.config.js",e1=function(){var e=eM.readJsonSync(ek(eB)).name===eY?eV:eF(eV,eK,eY);return eF(e,eH)}(),e2="cyberskill",e4="src/node/cli/index.ts",e3="eslint",e5="eslint",e6="vitest",e8="playwright",e7="vitest",e9="@commitlint/cli",te="@commitlint/config-conventional",tt="commitlint",tn="lint-staged",tr="lint-staged",ts="typescript",ti="tsc",to="tsx",ta="git",tc="pnpm",tu="pnpm exec",tl="simple-git-hooks",td="simple-git-hooks",tp="@eslint/config-inspector",tf="eslint-config-inspector",tm="node-modules-inspector",tE="node-modules-inspector",tg="migrate-mongo",th="./node_modules/migrate-mongo/bin/migrate-mongo",ty={CYBERSKILL_DIRECTORY:e1,WORKING_DIRECTORY:eV,TS_CONFIG:ek(eQ),GIT_IGNORE:ek(eJ),GIT_HOOK:ek(eX),GIT_COMMIT_MSG:ek(eZ),SIMPLE_GIT_HOOKS_JSON:ek(e$),PACKAGE_JSON:ek(eB),PACKAGE_LOCK_JSON:ek(eW),PNPM_LOCK_YAML:ek(ez),NODE_MODULES:ek(eK),MIGRATE_MONGO_CONFIG:ek(e0),LINT_STAGED_CONFIG:ek("".concat(e1,"/config/lint-staged/index.js")),COMMITLINT_CONFIG:ek("".concat(e1,"/config/commitlint/index.js")),UNIT_TEST_CONFIG:ek("".concat(e1,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:ek("".concat(e1,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:ek("".concat(e1,"/react/vitest/vitest.e2e.js"))};function tv(e){var t=e.isCurrentProject;return y({"pre-commit":tr,"commit-msg":tt},t&&{"pre-push":tq("".concat(ta," pull"))})}P(tv,"createGitHooksConfig");function tS(e){var t=e.type,n=e.packages,r=e.command;var s=n===null||n===void 0?void 0:n.reduce(function(e,t){return e.some(function(e){return e.name===t.name})||e.push(t),e},[]);return function(){return i(function(){var e;return R(this,function(n){switch(n.label){case 0:switch(t){case ef.CLI:return[3,1];case ef.STRING:return[3,4]}return[3,5];case 1:e=s===null||s===void 0?void 0:s.length;if(!e)return[3,3];return[4,tb(s,{install:!0})];case 2:e=n.sent();n.label=3;case 3:return[2,(e,tY(tq("".concat(tu," ").concat(r))))];case 4:return[2,tY(tq(r))];case 5:throw new Error("Unsupported command type");case 6:return[2]}})})()}}P(tS,"buildCommand");var tO={simpleGitHooks:tS({type:ef.CLI,packages:[{name:tl,type:eh.DEV_DEPENDENCY}],command:td}),eslintInspect:tS({type:ef.CLI,packages:[{name:tp,type:eh.DEV_DEPENDENCY}],command:tf}),nodeModulesInspect:tS({type:ef.CLI,packages:[{name:tm,type:eh.DEV_DEPENDENCY}],command:tE}),eslintCheck:tS({type:ef.CLI,packages:[{name:e3,type:eh.DEV_DEPENDENCY}],command:"".concat(e5," ").concat(ty.WORKING_DIRECTORY," --no-cache")}),eslintFix:tS({type:ef.CLI,packages:[{name:e3,type:eh.DEV_DEPENDENCY}],command:"".concat(e5," ").concat(ty.WORKING_DIRECTORY," --fix --no-cache")}),typescriptCheck:tS({type:ef.CLI,packages:[{name:ts,type:eh.DEPENDENCY}],command:"".concat(ti," -p ").concat(ty.TS_CONFIG," --noEmit")}),testUnit:tS({type:ef.CLI,packages:[{name:e6,type:eh.DEV_DEPENDENCY}],command:"".concat(e7," --config ").concat(ty.UNIT_TEST_CONFIG)}),testE2e:tS({type:ef.CLI,packages:[{name:e6,type:eh.DEV_DEPENDENCY}],command:"".concat(e7," --config ").concat(ty.E2E_TEST_CONFIG)}),mongoMigrateCreate:P(function(e){return tS({type:ef.CLI,packages:[{name:tg,type:eh.DEPENDENCY}],command:"".concat(to," ").concat(th," create ").concat(e," -f ").concat(ty.MIGRATE_MONGO_CONFIG)})()},"mongoMigrateCreate"),mongoMigrateUp:tS({type:ef.CLI,packages:[{name:tg,type:eh.DEPENDENCY}],command:"".concat(to," ").concat(th," up -f ").concat(ty.MIGRATE_MONGO_CONFIG)}),mongoMigrateDown:tS({type:ef.CLI,packages:[{name:tg,type:eh.DEPENDENCY}],command:"".concat(to," ").concat(th," down -f ").concat(ty.MIGRATE_MONGO_CONFIG)}),commitLint:tS({type:ef.CLI,packages:[{name:e9,type:eh.DEV_DEPENDENCY},{name:te,type:eh.DEV_DEPENDENCY}],command:"".concat(tt," --edit ").concat(ty.GIT_COMMIT_MSG," --config ").concat(ty.COMMITLINT_CONFIG)}),lintStaged:tS({type:ef.CLI,packages:[{name:tn,type:eh.DEV_DEPENDENCY}],command:"".concat(tr," --config ").concat(ty.LINT_STAGED_CONFIG)}),configureGitHook:tS({type:ef.STRING,command:"".concat(ta," config core.hooksPath ").concat(ty.GIT_HOOK)}),build:tS({type:ef.STRING,command:"".concat(tc," run --if-present build")}),pnpmInstallStandard:tS({type:ef.STRING,command:"".concat(tc," install --ignore-scripts")}),pnpmInstallLegacy:tS({type:ef.STRING,command:"".concat(tc," install --ignore-scripts --legacy-peer-deps")}),pnpmInstallForce:tS({type:ef.STRING,command:"".concat(tc," install --ignore-scripts --force")}),pnpmPruneStore:tS({type:ef.STRING,command:"".concat(tc," store prune")}),pnpmCleanCache:tS({type:ef.STRING,command:"".concat(tc," cache delete")})};var tC=et();function t_(e){return i(function(){var t,n,r,s;return R(this,function(i){switch(i.label){case 0:i.trys.push([0,3,,4]);return[4,ey("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,{success:!0,result:r}];case 3:s=i.sent();return[2,ea(s)];case 4:return[2]}})})()}P(t_,"getLatestPackageVersion");function tD(e){return i(function(){var t,n,r,s,i,o,a,c,u,l,d,p,f,m,E,g,h,y,v,S,O,C,_,D;return R(this,function(I){switch(I.label){case 0:I.trys.push([0,2,,3]);if(!e){if(ex(ty.PACKAGE_JSON)){t=eT(ty.PACKAGE_JSON),n=t.name,r=n===void 0?"":n,s=t.version,i=s===void 0?"":s;return[2,{success:!0,result:{name:r,currentVersion:i,latestVersion:i,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:!1,isDevDependency:!1,installedPath:ty.PACKAGE_JSON,file:t}}]}return[2,{success:!0,result:{name:"",currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:!1,isDevDependency:!1,installedPath:"",file:{}}}]}if(!ex(ty.PACKAGE_JSON))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===eh.DEPENDENCY,isDevDependency:e.type===eh.DEV_DEPENDENCY,installedPath:"",file:{}}}];o=eT(ty.PACKAGE_JSON),a=o.name,c=o.version,u=c===void 0?"":c,l=o.dependencies,d=l===void 0?{}:l,p=o.devDependencies,f=p===void 0?{}:p;if(e.name===a)return[2,{success:!0,result:{name:a,currentVersion:u,latestVersion:u,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:e.type===eh.DEPENDENCY,isDevDependency:e.type===eh.DEV_DEPENDENCY,installedPath:ty.PACKAGE_JSON,file:o}}];m=e.name in d,E=e.name in f;return[4,t_(e.name)];case 1:g=I.sent();if(!g.success)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:E,installedPath:"",file:{}}}];if(!m&&!E)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:g.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===eh.DEPENDENCY,isDevDependency:e.type===eh.DEV_DEPENDENCY,installedPath:"",file:{}}}];v=(y=(h=d[e.name])!==null&&h!==void 0?h:f[e.name])!==null&&y!==void 0?y:"",S=eF(tC.CWD,eK,e.name,eB);if(!ex(S))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:g.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:E,installedPath:"",file:{}}}];O=eT(S),C=O.version,_=C===void 0?"":C;return[2,v!==_?{success:!0,result:{name:e.name,currentVersion:_||v,latestVersion:g.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:!1,isDependency:m,isDevDependency:E,installedPath:S,file:O}}:{success:!0,result:{name:e.name,currentVersion:v,latestVersion:g.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:v===g.result,isDependency:m,isDevDependency:E,installedPath:S,file:O}}];case 2:D=I.sent();return[2,ea(D)];case 3:return[2]}})})()}P(tD,"getPackage");function tI(e){return i(function(){var t,n,r,s,i;return R(this,function(o){try{;r=eT(ty.PACKAGE_JSON),s=(t=r.dependencies)!==null&&t!==void 0?t:{},i=(n=r.devDependencies)!==null&&n!==void 0?n:{};e.isDependency?s[e.name]=e.latestVersion:e.isDevDependency&&(i[e.name]=e.latestVersion),eA(ty.PACKAGE_JSON,JSON.stringify(r,null,4)),eo.info('Updated "'.concat(e.name,'" to version ').concat(e.latestVersion))}catch(e){ea(e)}return[2]})})()}P(tI,"updatePackage");function tN(){return i(function(){var e,t,n,r,s,i,o,a,c,u,l,d,p;return R(this,function(f){switch(f.label){case 0:f.trys.push([0,12,,13]);e=[{command:P(function(){return tO.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:P(function(){return tO.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:P(function(){return tO.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,tH("".concat(c," using: ").concat(u),u)];case 5:f.sent();return[2];case 6:l=f.sent();ea(l);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:return[3,13];case 12:p=f.sent();ea(p);return[3,13];case 13:return[2]}})})()}P(tN,"installDependencies");function tb(e,t){return i(function(){var n,r,s,i,o,a,c,u,l,d,p,f,m,E,g,h,y;return R(this,function(v){switch(v.label){case 0:v.trys.push([0,15,,16]);if(!ex(ty.PACKAGE_JSON)){eo.error("package.json not found. Aborting setup.");return[2]}return[4,Promise.all(e.map(tD))];case 1:s=v.sent().filter(function(e){return e.success&&!!e.result&&!e.result.isCurrentProject}).map(function(e){return e.result}),i=s.filter(function(e){return!e.isInstalled}),o=s.filter(function(e){return!e.isUpToDate}),a=[];(t===null||t===void 0?void 0:t.install)&&i.length>0&&(n=a).push.apply(n,N(i.map(tI))),(t===null||t===void 0?void 0:t.update)&&o.length>0&&(r=a).push.apply(r,N(o.map(tI)));c=a.length>0;if(!c)return[3,6];return[4,Promise.all(a)];case 2:v.sent();return[4,tN()];case 3:v.sent();u=["Running ESLint with auto-fix"];return[4,tO.eslintFix()];case 4:return[4,tH.apply(void 0,u.concat([v.sent()]))];case 5:c=v.sent();v.label=6;case 6:c;d=true,p=false,f=undefined;v.label=7;case 7:v.trys.push([7,12,13,14]);m=((l=t===null||t===void 0?void 0:t.callbacks)!==null&&l!==void 0?l:[])[Symbol.iterator]();v.label=8;case 8:if(!!(d=(E=m.next()).done))return[3,11];g=E.value;return[4,g()];case 9:v.sent();v.label=10;case 10:d=true;return[3,8];case 11:return[3,14];case 12:h=v.sent();p=true;f=h;return[3,14];case 13:try{if(!d&&m.return!=null){m.return()}}finally{if(p){throw f}}return[7];case 14:return[3,16];case 15:y=v.sent();ea(y);return[3,16];case 16:return[2]}})})()}P(tb,"setupPackages");import tT from"node-persist";var tA=et();function tR(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=tT.defaultInstance;if(e)return[3,2];return[4,tT.init({dir:tA.CYBERSKILL_STORAGE_DIRECTORY})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}P(tR,"initNodePersist");var tx={get:function e(e){return i(function(){var t,n;return R(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tR()];case 1:r.sent();return[4,tT.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,ea(n,{returnValue:null})];case 4:return[2]}})})()},set:function e(e,t){return i(function(){var n;return R(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tR()];case 1:r.sent();return[4,tT.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();ea(n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return i(function(){var t;return R(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tR()];case 1:n.sent();return[4,tT.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();ea(t);return[3,4];case 4:return[2]}})})()},keys:function e(){return i(function(){var e,t;return R(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tR()];case 1:n.sent();return[4,tT.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(eo.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,ea(t,{returnValue:[]})];case 4:return[2]}})})()},getLogLink:function e(e){return i(function(){return R(this,function(t){try{return[2,"".concat(tA.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,ea(e,{returnValue:null})]}return[2]})})()}};var tG=et(),tP=eg.promisify(em);function tM(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:return[4,tD()];case 1:e=t.sent();return[2,e.success?e.result.name:Date.now().toString()]}})})()}P(tM,"getPackageName");function tw(e){return i(function(){var t,n;return R(this,function(r){switch(r.label){case 0:if(e.length===0)return[2];return[4,tM()];case 1:t=r.sent();r.label=2;case 2:r.trys.push([2,4,,5]);return[4,tx.set(t,e)];case 3:r.sent(),setTimeout(function(){return i(function(){var e;return R(this,function(n){switch(n.label){case 0:return[4,tx.getLogLink(t)];case 1:e=n.sent();e&&eo.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},0);return[3,5];case 4:n=r.sent();ea(n);return[3,5];case 5:return[2]}})})()}P(tw,"saveErrorListToStorage");function tL(){return i(function(){var e,t,n;return R(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tM()];case 1:e=r.sent();return[4,tx.get(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:[]];case 3:n=r.sent();return[2,ea(n,{returnValue:[]})];case 4:return[2]}})})()}P(tL,"getStoredErrorLists");function tj(){return i(function(){var e,t;return R(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tM()];case 1:e=n.sent();return[4,tx.remove(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();ea(t);return[3,4];case 4:return[2]}})})()}P(tj,"clearAllErrorLists");function tk(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 p=s.exec(e)||[],f=i.exec(e)||[],m=o.exec(e)||[];var E,g,h,y,v,S;p.length&&r?t.push({file:r,position:"".concat(p[1],":").concat(p[2]),type:p[3]===F.Error?F.Error:F.Warning,message:(E=p===null||p===void 0?void 0:(a=p[4])===null||a===void 0?void 0:a.trim())!==null&&E!==void 0?E:"",rule:(g=p===null||p===void 0?void 0:(c=p[5])===null||c===void 0?void 0:c.trim())!==null&&g!==void 0?g:""}):f.length?t.push({file:(h=f===null||f===void 0?void 0:f[1])!==null&&h!==void 0?h:"",position:"".concat(f[2],":").concat(f[3]),type:f[4]===F.Error?F.Error:F.Warning,message:(y=f===null||f===void 0?void 0:(u=f[5])===null||u===void 0?void 0:u.trim())!==null&&y!==void 0?y:""}):m.length?t.push({file:"commitlint",type:F.Error,message:(v=m===null||m===void 0?void 0:(l=m[1])===null||l===void 0?void 0:l.trim())!==null&&v!==void 0?v:"",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&&tw(t),tG.DEBUG&&n.length&&(eo.warn("Unmatched lines:"),n.forEach(function(e){return eo.info(" ".concat(e))}))}P(tk,"parseTextErrors");function tU(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&&tw(n)}catch(t){tk(e)}}P(tU,"parseCommandOutput");function tF(e){return i(function(e){var t,n,r,s,i,o,a,c,u;var l=arguments;return R(this,function(d){switch(d.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:tU;n=new AbortController;eE.on("SIGINT",function(){eo.warn("Process interrupted. Terminating..."),n.abort(),eE.exit()});d.label=1;case 1:d.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,tP(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&&eo.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}P(tF,"executeCommand");function tq(e){return{raw:!0,cmd:e}}P(tq,"rawCommand");function tV(e,t){return(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(tu," ").concat(to," ").concat(e4," ").concat(e):"".concat(tu," ").concat(e2," ").concat(e)}P(tV,"formatCLI");function tY(e,t){return typeof e=="function"?tV(e(t),t):(typeof e==="undefined"?"undefined":b(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?tV(e,t):e}P(tY,"formatCommand");function tK(e){return i(function(){var t,n,r;return R(this,function(s){switch(s.label){case 0:return[4,tD({name:eY})];case 1:t=s.sent();if(t.success){n={isCurrentProject:t.result.isCurrentProject},r=typeof e=="function"?e(n):e;return[2,Object.fromEntries(Object.entries(r).map(function(e){var t=I(e,2),r=t[0],s=t[1];return[r,tY(s,n)]}))]}return[2]}})})()}P(tK,"resolveCommands");function tH(e,t){return i(function(){var n;return R(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);eo.start("".concat(e)),tG.DEBUG&&eo.info("→ ".concat(t));return[4,tF(t)];case 1:r.sent(),eo.success("".concat(e," done."));return[3,3];case 2:n=r.sent();ea(n);return[3,3];case 3:return[2]}})})()}P(tH,"runCommand");function tB(){return i(function(){var e,t;return R(this,function(n){switch(n.label){case 0:if(!ex(ty.TS_CONFIG))return[3,3];t=["Performing TypeScript validation"];return[4,tO.typescriptCheck()];case 1:return[4,tH.apply(void 0,t.concat([n.sent()]))];case 2:e=n.sent();return[3,4];case 3:e=eo.warn("No TypeScript configuration found. Skipping type check.");n.label=4;case 4:e;return[2]}})})()}P(tB,"checkTypescript");function tW(){return i(function(){var e,t,n,r;var s=arguments;return R(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,tO.eslintFix()];case 1:return[4,tH.apply(void 0,n.concat([i.sent()]))];case 2:t=i.sent();return[3,6];case 3:r=["Running ESLint check"];return[4,tO.eslintCheck()];case 4:return[4,tH.apply(void 0,r.concat([i.sent()]))];case 5:t=i.sent();i.label=6;case 6:t;return[2]}})}).apply(this,arguments)}P(tW,"checkEslint");function tQ(e,t){if(!t.length)return;var n=e==="Errors"?"red":"yellow";eo.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",t,n)}P(tQ,"printIssues");function tJ(){return i(function(){return R(this,function(e){setTimeout(function(){return i(function(){var e,t,n;return R(this,function(r){switch(r.label){case 0:return[4,tL()];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?eo.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(tQ("Warnings",n),tQ("Errors",t),(t.length>0||n.length>0)&&eu.exit(1));return[2]}})})()},0);return[2]})})()}P(tJ,"showCheckResult");function t$(){return i(function(){var e,t,n,r;return R(this,function(s){switch(s.label){case 0:return[4,tj()];case 1:s.sent();return[4,tD({name:eY})];case 2:e=s.sent();if(!e.success){eo.error("Failed to retrieve package information. Aborting lint-staged.");return[2]}t=e.result.isCurrentProject;if(!t)return[3,5];n=["Building package: ".concat(eY)];return[4,tO.build()];case 3:return[4,tH.apply(void 0,n.concat([s.sent()]))];case 4:t=s.sent();s.label=5;case 5:t;r=["Executing lint-staged"];return[4,tO.lintStaged()];case 6:return[4,tH.apply(void 0,r.concat([s.sent()]))];case 7:s.sent(),tJ();return[2]}})})()}P(t$,"lintStaged");function tz(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Inspecting ESLint configuration"];return[4,tO.eslintInspect()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(tz,"inspectLint");function tX(){return i(function(){return R(this,function(e){switch(e.label){case 0:return[4,tj()];case 1:e.sent();return[4,Promise.all([tB(),tW()])];case 2:e.sent(),tJ();return[2]}})})()}P(tX,"lintCheck");function tZ(){return i(function(){return R(this,function(e){switch(e.label){case 0:return[4,tj()];case 1:e.sent();return[4,Promise.all([tB(),tW(!0)])];case 2:e.sent(),tJ();return[2]}})})()}P(tZ,"lintFix");function t0(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:return[4,tj()];case 1:t.sent();e=["Validating commit message"];return[4,tO.commitLint()];case 2:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 3:t.sent(),tJ();return[2]}})})()}P(t0,"commitLint");function t1(){return i(function(){var e,t,n,r;return R(this,function(s){switch(s.label){case 0:e=["Configuring Git hooks"];return[4,tO.configureGitHook()];case 1:return[4,tH.apply(void 0,e.concat([s.sent()]))];case 2:s.sent(),eG(ty.GIT_HOOK);return[4,tK(tv)];case 3:t=s.sent();eA(ty.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(t,null,4));n="\n".concat(e$,"\n");ex(ty.GIT_IGNORE)?eI(ty.GIT_IGNORE,"utf-8").split("\n").includes(e$)||eR(ty.GIT_IGNORE,n):eA(ty.GIT_IGNORE,n);r=["Setting up simple-git-hooks"];return[4,tO.simpleGitHooks()];case 4:return[4,tH.apply(void 0,r.concat([s.sent()]))];case 5:s.sent();return[2]}})})()}P(t1,"setupGitHook");function t2(){return i(function(){return R(this,function(e){switch(e.label){case 0:return[4,tN()];case 1:e.sent();return[4,t1()];case 2:e.sent();return[2]}})})()}P(t2,"prepare");function t4(){return i(function(){var e,t;return R(this,function(n){switch(n.label){case 0:eG(ty.NODE_MODULES,ty.PNPM_LOCK_YAML);e=["Pruning pnpm store"];return[4,tO.pnpmPruneStore()];case 1:return[4,tH.apply(void 0,e.concat([n.sent()]))];case 2:n.sent();t=["Clearing pnpm cache"];return[4,tO.pnpmCleanCache()];case 3:return[4,tH.apply(void 0,t.concat([n.sent()]))];case 4:n.sent();return[4,tN()];case 5:n.sent();return[4,t1()];case 6:n.sent();return[2]}})})()}P(t4,"reset");function t3(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Inspecting project dependencies"];return[4,tO.nodeModulesInspect()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t3,"inspect");function t5(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Running unit tests"];return[4,tO.testUnit()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t5,"testUnit");function t6(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Running end-to-end tests"];return[4,tO.testE2e()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t6,"testE2E");function t8(e){return i(function(){var t;return R(this,function(n){switch(n.label){case 0:t=["Creating MongoDB migration"];return[4,tO.mongoMigrateCreate(e)];case 1:return[4,tH.apply(void 0,t.concat([n.sent()]))];case 2:n.sent();return[2]}})})()}P(t8,"mongoMigrateCreate");function t7(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Running MongoDB migrations"];return[4,tO.mongoMigrateUp()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t7,"mongoMigrateUp");function t9(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:e=["Rolling back MongoDB migration"];return[4,tO.mongoMigrateDown()];case 1:return[4,tH.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}P(t9,"mongoMigrateDown");(function(){return i(function(){var e;return R(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,ed(el(eu.argv)).scriptName(e2).usage("$0 <command> [options]").command("lint","Check code for linting issues",tX).command("lint:fix","Fix linting issues automatically",tZ).command("lint:inspect","View active ESLint configuration",tz).command("lint-staged","Run lint checks on staged files",t$).command("commitlint","Validate commit message format",t0).command("prepare","Initialize project and dependencies",t2).command("reset","Reset the project and reinstall dependencies",t4).command("inspect","Analyze installed project dependencies",t3).command("test:unit","Run unit test suite",t5).command("test:e2e","Run end-to-end test suite",t6).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 R(this,function(t){switch(t.label){case 0:if(!e.name){eo.error("Migration name is required.");return[2]}return[4,t8(e.name)];case 1:t.sent();return[2]}})})()}).command("mongo:migrate:up","Apply all MongoDB migrations",t7).command("mongo:migrate:down","Rollback last MongoDB migration",t9).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(ep.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();ea(e),eu.exit(1);return[3,3];case 3:return[2]}})})()})();import{Router as ne}from"express";import{NestFactory as nt}from"@nestjs/core";import nn from"body-parser";import nr from"compression";import ns from"cookie-parser";import ni from"cors";import no from"express";import na from"express-session";import nc from"express-useragent";function nu(e){var t=e.isDev,n=e.whiteList,r=O(e,["isDev","whiteList"]);return y({origin:P(function(e,r){t||!e||(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)}P(nu,"createCorsOptions");function nl(e){return ni(nu(e))}P(nl,"createCors");function nd(e){return na(e)}P(nd,"createSession");function np(e){var t=no();return t.set("trust proxy",1),t.use(ns()),t.use(no.urlencoded({extended:!0})),t.use(nr()),t.use(nc.express()),(e===null||e===void 0?void 0:e.staticFolder)&&t.use(no.static(e.staticFolder)),t}P(np,"createExpress");function nf(e){return i(function(){var t,n,r;return R(this,function(s){switch(s.label){case 0:return[4,nt.create(e.module)];case 1:r=s.sent();return[2,(r.getHttpAdapter().getInstance().set("trust proxy",1),r.use(no.urlencoded({extended:!0})),r.use(ns()),r.use(nr()),r.use(nc.express()),e.staticFolder&&r.use(no.static(e.staticFolder)),e.filters&&(t=r).useGlobalFilters.apply(t,N(e.filters)),e.pipes&&(n=r).useGlobalPipes.apply(n,N(e.pipes)),r)]}})})()}P(nf,"createNest");var nm="MONGO_MIGRATE_OPTIONS";import{Collection as nE,Db as ng}from"mongodb";import{Document as nh,Model as ny}from"mongoose";var nv=/*#__PURE__*/function(e){"use strict";p(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(ng);P(nv,"C_Db");var nS=nv,nO=/*#__PURE__*/function(e){"use strict";p(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(nh);P(nO,"C_Document");var nC=nO,n_=/*#__PURE__*/function(e){"use strict";p(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(ny);P(n_,"C_Model");var nD=n_,nI=/*#__PURE__*/function(e){"use strict";p(t,e);function t(){a(this,t);return o(this,t,arguments)}return t}(nE);P(nI,"C_Collection");var nN=nI;import{format as nb}from"date-fns";import nT from"migrate-mongo";import{Document as nA}from"mongoose";import nR from"mongoose-aggregate-paginate-v2";import nx from"mongoose-paginate-v2";import{v4 as nG}from"uuid";import nP from"unorm";var nM={a:["\xe0","\xe1","ạ","ả","\xe3","\xe2","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["\xe8","\xe9","ẹ","ẻ","ẽ","\xea","ề","ế","ệ","ể","ễ"],i:["\xec","\xed","ị","ỉ","ĩ"],o:["\xf2","\xf3","ọ","ỏ","\xf5","\xf4","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["\xf9","\xfa","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","\xfd","ỵ","ỷ","ỹ"],d:["đ"]},nw=Object.entries(nM).reduce(function(e,t){var n=I(t,2),r=n[0],s=n[1];return e[r.toUpperCase()]=s.map(function(e){return e.toUpperCase()}),e},{});function nL(e){return(typeof e==="undefined"?"undefined":b(e))=="object"&&e!==null&&!Array.isArray(e)}P(nL,"isObject");import nj from"crypto-js";import nk from"slugify";var nU=nk.default||nk;function nF(e,t){var n=P(function(e){var n,r;return nU(e!==null&&e!==void 0?e:"",y({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(nL(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=I(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)}P(nF,"generateSlug");function nq(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return nj.SHA256(e).toString(nj.enc.Hex).slice(0,t)}P(nq,"generateShortId");var nV={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":b(e))=="object"?f(e,Date)?!1:f(e,Map)||f(e,Set)?e.size===0:f(e,WeakMap)||f(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 nY={getDateTime:function e(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Date;return nb(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"?nY.getDateTime():new Date;return{id:nG(),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:nG,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(nY.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 p=nY.createSchema({mongoose:t,schema:r,virtuals:u});return nY.applyPlugins(p,[i&&nx,a&&nR]),nY.applyMiddlewares(p,d),t.model(n,p)},validator:{isEmpty:function e(){return function(e){return i(function(){return R(this,function(t){return[2,!nV.isEmpty(e)]})})()}},isUnique:function e(e){return function(t){return i(function(){var n;return R(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 R(this,function(n){if(!Array.isArray(e)||e.some(function(e){return!f(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(y({},nT),{setConfig:P(function(e){var t="// This file is automatically generated by the Cyberskill CLI.\nmodule.exports = ".concat(JSON.stringify(e,null,4));eA(ty.MIGRATE_MONGO_CONFIG,t);var n="\n".concat(e0,"\n");ex(ty.GIT_IGNORE)?eI(ty.GIT_IGNORE,"utf-8").split("\n").includes(e0)||eR(ty.GIT_IGNORE,n):eA(ty.GIT_IGNORE,n)},"setConfig")})},nK=/*#__PURE__*/function(){"use strict";function e(t,n){a(this,e);M(this,"collection");this.collection=t.collection(n)}u(e,[{key:"createOne",value:function e(e){return i(function(){var t,n,r;return R(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=y({},nY.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,ea(r)];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return i(function(){var t,n,r;return R(this,function(s){switch(s.label){case 0:s.trys.push([0,2,,3]);t=e.map(function(e){return y({},nY.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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"".concat(n.insertedCount," documents created successfully"),result:n}];case 2:r=s.sent();return[2,ea(r)];case 3:return[2]}})}).call(this)}},{key:"findOne",value:function e(e){return i(function(){var t,n;return R(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",code:en.NOT_FOUND.CODE}];case 2:n=r.sent();return[2,ea(n)];case 3:return[2]}})}).call(this)}},{key:"findAll",value:function e(){return i(function(){var e,t,n;var r=arguments;return R(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,ea(n)];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return i(function(){var e,t,n;var r=arguments;return R(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,ea(n)];case 4:return[2]}})}).apply(this,arguments)}},{key:"updateOne",value:function e(e,t){return i(function(){var n,r;return R(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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document updated successfully",result:n}];case 2:r=s.sent();return[2,ea(r)];case 3:return[2]}})}).call(this)}},{key:"updateMany",value:function e(e,t){return i(function(){var n,r;return R(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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents updated successfully",result:n}];case 2:r=s.sent();return[2,ea(r)];case 3:return[2]}})}).call(this)}},{key:"deleteOne",value:function e(e){return i(function(){var t,n;return R(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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document deleted successfully",result:t}];case 2:n=r.sent();return[2,ea(n)];case 3:return[2]}})}).call(this)}},{key:"deleteMany",value:function e(e){return i(function(){var t,n;return R(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",code:en.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents deleted successfully",result:t}];case 2:n=r.sent();return[2,ea(n)];case 3:return[2]}})}).call(this)}}]);return e}();P(nK,"MongoController");var nH=nK,nB=/*#__PURE__*/function(){"use strict";function e(t){a(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 i(function(){var e,t,n,r,s,i,o;var a=arguments;return R(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:en.NOT_FOUND.CODE}];case 3:o=c.sent();return[2,ea(o)];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 R(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,ea(o)];case 4:return[2]}})}).apply(this,arguments)}},{key:"findPaging",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return R(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,ea(r)];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 R(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,ea(r)];case 4:return[2]}})}).apply(this,arguments)}},{key:"count",value:function e(){return i(function(){var e,t,n;var r=arguments;return R(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,ea(n)];case 4:return[2]}})}).apply(this,arguments)}},{key:"createOne",value:function e(e){return i(function(){var t,n;return R(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,ea(n)];case 3:return[2]}})}).call(this)}},{key:"createMany",value:function e(e){return i(function(e){var t,n,r;var s=arguments;return R(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 f(e,nA)?e.toObject():null}).filter(function(e){return e!==null}),n)];case 3:r=i.sent();return[2,ea(r)];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 R(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,y({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:en.NOT_FOUND.CODE}];case 3:s=o.sent();return[2,ea(s)];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 R(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,ea(s)];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteOne",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return R(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:en.NOT_FOUND.CODE}];case 3:r=i.sent();return[2,ea(r)];case 4:return[2]}})}).apply(this,arguments)}},{key:"deleteMany",value:function e(){return i(function(){var e,t,n,r;var s=arguments;return R(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:en.NOT_FOUND.CODE}:{success:!0,result:n}];case 3:r=i.sent();return[2,ea(r)];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,o;return R(this,function(a){switch(a.label){case 0:a.trys.push([0,6,,7]);n=new Set;r=0;a.label=1;case 1:if(!(r<10))return[3,5];s=nq(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=!a.sent();a.label=3;case 3:if(i)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:en.INTERNAL_SERVER_ERROR.CODE}];case 6:o=a.sent();return[2,ea(o)];case 7:return[2]}})}).call(this)}},{key:"createSlugQuery",value:function e(e){var t=e.slug,n=e.field,r=e.isObject,s=e.filter;var i=y({},s!==null&&s!==void 0?s:{});return r?S(y({},i),{$or:[l({},"slug.".concat(n),t),{slugHistory:{$elemMatch:l({},"slug.".concat(n),t)}}]}):S(y({},i),{$or:[{slug:t},{slugHistory:t}]})}},{key:"createUniqueSlug",value:function e(e){return i(function(e){var t,n,r,s,i,o,a;return R(this,function(c){switch(c.label){case 0:t=e.slug,n=e.field,r=e.isObject,s=e.filter;i=nF(t),o=i,a=1;c.label=1;case 1:return[4,this.model.exists(this.createSlugQuery({slug:o,field:n,isObject:r,filter:s}))];case 2:if(!c.sent())return[3,4];o="".concat(i,"-").concat(a++);c.label=3;case 3:return[3,1];case 4:return[2,o]}})}).apply(this,arguments)}},{key:"createSlug",value:function e(e){return i(function(e){var t,n,r,s,o,a,c,u,l,d;return R(this,function(p){switch(p.label){case 0:t=this;n=e.field,r=e.from,s=e.filter;p.label=1;case 1:p.trys.push([1,6,,7]);o=r[n];if(!nL(o))return[3,3];c={success:!0};u=Object.fromEntries;return[4,Promise.all(Object.entries(o).map(function(e){var n=I(e,2),r=n[0],o=n[1];return i(function(){var e;return R(this,function(t){switch(t.label){case 0:return[4,this.createUniqueSlug({slug:o,field:r,isObject:!0,filter:s})];case 1:e=t.sent();return[2,[r,e]]}})}).call(t)}))];case 2:a=(c.result=u.apply(Object,[p.sent()]),c);return[3,5];case 3:l={success:!0};return[4,this.createUniqueSlug({slug:o,field:n,isObject:!1,filter:s})];case 4:a=(l.result=p.sent(),l);p.label=5;case 5:return[2,a];case 6:d=p.sent();return[2,ea(d)];case 7:return[2]}})}).apply(this,arguments)}},{key:"checkSlug",value:function e(e){return i(function(e){var t,n,r,s,i,o,a,c,u,l,d,p,f,m,E,g;return R(this,function(h){switch(h.label){case 0:t=e.slug,n=e.field,r=e.from,s=e.filter;h.label=1;case 1:h.trys.push([1,12,,13]);i=r[n];if(!nL(i))return[3,10];o=true,a=false,c=undefined;h.label=2;case 2:h.trys.push([2,7,8,9]);u=Object.values(i)[Symbol.iterator]();h.label=3;case 3:if(!!(o=(l=u.next()).done))return[3,6];d=l.value;p=nF(d);return[4,this.model.exists(this.createSlugQuery({slug:p,field:n,isObject:!0,filter:s}))];case 4:if(h.sent())return[2,{success:!0,result:!0}];h.label=5;case 5:o=true;return[3,3];case 6:return[3,9];case 7:f=h.sent();a=true;c=f;return[3,9];case 8:try{if(!o&&u.return!=null){u.return()}}finally{if(a){throw c}}return[7];case 9:return[2,{success:!0,result:!1}];case 10:m=nF(t);E={success:!0};return[4,this.model.exists(this.createSlugQuery({slug:m,field:n,isObject:!1,filter:s}))];case 11:return[2,(E.result=h.sent()!==null,E)];case 12:g=h.sent();return[2,ea(g)];case 13:return[2]}})}).apply(this,arguments)}},{key:"aggregate",value:function e(e){return i(function(){var t,n;return R(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,ea(n)];case 3:return[2]}})}).call(this)}}]);return e}();P(nB,"MongooseController");var nW=nB;import{useServer as nQ}from"graphql-ws/use/ws";import{WebSocketServer as nJ}from"ws";function n$(e){return new nJ({server:e.server,path:e.path})}P(n$,"createWSServer");function nz(e){return nQ({schema:e.schema},e.server)}P(nz,"initGraphQLWS");export{eH as BUILD_DIRECTORY,tt as COMMIT_LINT_CLI,te as COMMIT_LINT_CONVENTIONAL_CONFIG_PACKAGE_NAME,e9 as COMMIT_LINT_PACKAGE_NAME,e2 as CYBERSKILL_CLI,e4 as CYBERSKILL_CLI_PATH,e1 as CYBERSKILL_DIRECTORY,eY as CYBERSKILL_PACKAGE_NAME,nN as C_Collection,nS as C_Db,nC as C_Document,nD as C_Model,e5 as ESLINT_CLI,tf as ESLINT_INSPECT_CLI,tp as ESLINT_INSPECT_PACKAGE_NAME,e3 as ESLINT_PACKAGE_NAME,ef as E_CommandType,F as E_IssueType,eh as E_PackageType,ta as GIT_CLI,eZ as GIT_COMMIT_EDITMSG,eX as GIT_HOOK,eJ as GIT_IGNORE,tr as LINT_STAGED_CLI,tn as LINT_STAGED_PACKAGE_NAME,th as MIGRATE_MONGO_CLI,e0 as MIGRATE_MONGO_CONFIG,tg as MIGRATE_MONGO_PACKAGE_NAME,nm as MONGO_MIGRATE_OPTIONS,nH as MongoController,nW as MongooseController,eK as NODE_MODULES,tE as NODE_MODULES_INSPECT_CLI,tm as NODE_MODULES_INSPECT_PACKAGE_NAME,eB as PACKAGE_JSON,eW as PACKAGE_LOCK_JSON,ty as PATH,e8 as PLAYWRIGHT_PACKAGE_NAME,tc as PNPM_CLI,tu as PNPM_EXEC_CLI,ez as PNPM_LOCK_YAML,ne as Router,tl as SIMPLE_GIT_HOOKS_PACKAGE_NAME,td as SIMPLE_GIT_HOOK_CLI,e$ as SIMPLE_GIT_HOOK_JSON,eQ as TSCONFIG_JSON,ti as TSC_CLI,ts as TSC_PACKAGE_NAME,to as TSX_CLI,e7 as VITEST_CLI,e6 as VITEST_PACKAGE_NAME,eV as WORKING_DIRECTORY,nR as aggregatePaginate,eR as appendFileSync,nn as bodyParser,ea as catchError,tj as clearAllErrorLists,tO as command,eP as copySync,ec as createApolloServer,nl as createCors,nu as createCorsOptions,np as createExpress,tv as createGitHooksConfig,nf as createNest,nd as createSession,n$ as createWSServer,no as express,L as expressMiddleware,tY as formatCommand,eO as fs,t_ as getLatestPackageVersion,tD as getPackage,tL as getStoredErrorLists,nz as initGraphQLWS,tN as installDependencies,eF as join,eo as log,eC as lstatSync,eD as mkdirSync,nY as mongo,nx as mongoosePaginate,ej as path,ex as pathExistsSync,tq as rawCommand,eI as readFileSync,eT as readJsonSync,e_ as readdirSync,eG as removeSync,eU as resolve,tK as resolveCommands,ek as resolveWorkingPath,tH as runCommand,tb as setupPackages,eb as statSync,tx as storage,es as throwError,eN as unlinkSync,tI as updatePackage,eA as writeFileSync};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.170.0",
|
|
5
5
|
"description": "CyberSkill Shared",
|
|
6
6
|
"author": "Stephen Cheng",
|
|
7
7
|
"license": "MIT",
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
"@antfu/eslint-config": "4.13.1",
|
|
226
226
|
"@apollo/client": "3.13.8",
|
|
227
227
|
"@apollo/server": "4.12.1",
|
|
228
|
-
"@dotenvx/dotenvx": "1.44.
|
|
228
|
+
"@dotenvx/dotenvx": "1.44.1",
|
|
229
229
|
"@eddeee888/gcg-typescript-resolver-files": "0.12.1",
|
|
230
230
|
"@eslint-react/eslint-plugin": "1.49.0",
|
|
231
231
|
"@graphql-codegen/cli": "5.0.6",
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
"@testing-library/jest-dom": "6.6.3",
|
|
238
238
|
"@testing-library/react": "16.3.0",
|
|
239
239
|
"@vitejs/plugin-react-swc": "3.9.0",
|
|
240
|
-
"@vitest/browser": "3.1.
|
|
240
|
+
"@vitest/browser": "3.1.4",
|
|
241
241
|
"body-parser": "2.2.0",
|
|
242
242
|
"chalk": "5.4.1",
|
|
243
243
|
"classnames": "2.5.1",
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
"unorm": "1.6.0",
|
|
289
289
|
"uuid": "11.1.0",
|
|
290
290
|
"vite": "6.3.5",
|
|
291
|
-
"vitest": "3.1.
|
|
291
|
+
"vitest": "3.1.4",
|
|
292
292
|
"vitest-browser-react": "0.2.0",
|
|
293
293
|
"ws": "8.18.2",
|
|
294
294
|
"yargs": "17.7.2"
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
## ✅ Bước 1: Tạo SSH key
|
|
2
|
-
|
|
3
|
-
Mở terminal và chạy lệnh sau:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
ssh-keygen -t ed25519 -C "địa-chỉ-email"
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
- Khi được hỏi "Enter a file in which to save the key", nhấn `Enter` để dùng mặc định (`~/.ssh/id_ed25519`)
|
|
10
|
-
|
|
11
|
-
> ⚠️ Lưu ý:
|
|
12
|
-
|
|
13
|
-
- Có thể đặt passphrase để tăng độ bảo mật (hoặc để trống nếu muốn nhanh)
|
|
14
|
-
- Nên thêm hậu tố để tránh trùng lặp đối với trường hợp dùng nhiều dự án/tài khoản, ví dụ `~/.ssh/id_ed25519_stephen_cyberskill` hoặc `~/.ssh/id_ed25519_project_xxx`
|
|
15
|
-
|
|
16
|
-
## ✅ Bước 2: Khởi động SSH Agent
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
eval "$(ssh-agent -s)"
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## ✅ Bước 3: Cấu hình SSH cho GitHub
|
|
23
|
-
|
|
24
|
-
Tạo và sửa file cấu hình SSH:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
touch ~/.ssh/config
|
|
28
|
-
nano ~/.ssh/config
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Thêm nội dung sau:
|
|
32
|
-
|
|
33
|
-
```ssh
|
|
34
|
-
Host github.com
|
|
35
|
-
User git
|
|
36
|
-
UseKeychain yes
|
|
37
|
-
HostName github.com
|
|
38
|
-
AddKeysToAgent yes
|
|
39
|
-
IdentitiesOnly yes
|
|
40
|
-
IdentityFile ~/.ssh/id_ed25519
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
> ⚠️ Lưu ý:
|
|
44
|
-
|
|
45
|
-
- `User git` có thể không cần để, trừ một số trường hợp đặc biệt như kết nối với google cloud VM, ví dụ `User stephen.cheng` và `HostName xxx.xxx.xxx.xxx` là địa chỉ IP của server
|
|
46
|
-
- `UseKeychain yes` chỉ áp dụng cho macOS, nếu dùng Linux/Windows thì không cần cấu hình này.
|
|
47
|
-
- Trường hợp dùng nhiều tài khoản có thể tạo nhiều Host với IdentityFile và Host khác nhau, ví dụ `Host github.com` và `IdentityFile ~/.ssh/id_ed25519` khi dùng các dự án cá nhân, `Host github.com-cyberskill` và `IdentityFile ~/.ssh/id_ed25519_cyberskill` khi dùng các dự án cyberskill
|
|
48
|
-
|
|
49
|
-
Lưu và thoát (`Ctrl + X`, nhấn `Y`, rồi `Enter`).
|
|
50
|
-
|
|
51
|
-
## ✅ Bước 4: Thêm SSH key vào GitHub
|
|
52
|
-
|
|
53
|
-
Hiển thị public key:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
cat ~/.ssh/id_ed25519.pub
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Copy toàn bộ nội dung và vào [GitHub SSH Keys Settings](https://github.com/settings/keys):
|
|
60
|
-
|
|
61
|
-
- Bấm **"New SSH key"**
|
|
62
|
-
- Đặt **Title** dễ nhớ (có thể dùng hậu tố ở bước 1)
|
|
63
|
-
- Dán public key vào phần **Key**
|
|
64
|
-
|
|
65
|
-
## ✅ Bước 5: Kiểm tra kết nối SSH
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
ssh -T git@XXX
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
> ⚠️ Lưu ý: XXX là Host đã đặt lúc tạo file config ở bước 3, ví dụ `ssh -T git@github.com`
|
|
72
|
-
|
|
73
|
-
Nếu thành công, terminal sẽ hiển thị:
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## ✅ Bước 6: Clone dự án
|
|
80
|
-
|
|
81
|
-
Clone dự án bằng SSH:
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
git clone git@XXX:tên-người-dùng/tên-dự-án.git
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
> ⚠️ Lưu ý:
|
|
88
|
-
|
|
89
|
-
- Tạo thư mục phù hợp trên máy và mở terminal tại thư mục đó trước khi clone dự án
|
|
90
|
-
- XXX là Host đã đặt lúc tạo file config ở bước 3, ví dụ `git clone git@github.com:cyberskill-world/cyberskill-example.git`
|
|
91
|
-
|
|
92
|
-
## 🛠 Tuỳ chọn: Cấu hình tên và email
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
git config --global user.name "Tên hiển thị"
|
|
96
|
-
git config --global user.email "địa-chỉ-email"
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
> ⚠️ Lưu ý: `--global` sẽ áp dụng mặc định cho toàn bộ dự án trong máy (kể cả các dự án sau này), nếu muốn dùng riêng cho từng dự án thì mở terminal tại vị trí dự án rồi chạy lệnh nhưng không để cấu hình `--global`, ví dụ `git config user.name "Stephen Cheng"`
|