@cyberskill/shared 1.33.0 → 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/commands.d.cts +1 -0
  2. package/dist/commands.d.ts +1 -0
  3. package/dist/configs/commitlint/base.d.cts +5 -0
  4. package/dist/configs/commitlint/base.d.ts +5 -0
  5. package/dist/configs/eslint/base.d.cts +1154 -0
  6. package/dist/configs/eslint/base.d.ts +1154 -0
  7. package/dist/configs/eslint/nestjs.d.cts +1156 -0
  8. package/dist/configs/eslint/nestjs.d.ts +1156 -0
  9. package/dist/configs/eslint/nextjs.d.cts +1156 -0
  10. package/dist/configs/eslint/nextjs.d.ts +1156 -0
  11. package/dist/configs/eslint/nodejs.d.cts +1156 -0
  12. package/dist/configs/eslint/nodejs.d.ts +1156 -0
  13. package/dist/configs/eslint/vite-react.d.cts +1157 -0
  14. package/dist/configs/eslint/vite-react.d.ts +1157 -0
  15. package/dist/configs/graphql/graphql-codegen.d.cts +6 -0
  16. package/dist/configs/graphql/graphql-codegen.d.ts +6 -0
  17. package/dist/configs/graphql/index.d.cts +3 -0
  18. package/dist/configs/graphql/index.d.ts +3 -0
  19. package/dist/configs/i18n/react/i18next.d.cts +6 -0
  20. package/dist/configs/i18n/react/i18next.d.ts +6 -0
  21. package/dist/configs/i18n/react/index.d.cts +2 -0
  22. package/dist/configs/i18n/react/index.d.ts +2 -0
  23. package/dist/configs/index.d.cts +9 -0
  24. package/dist/configs/index.d.ts +9 -0
  25. package/dist/configs/lint-staged/base.d.cts +5 -0
  26. package/dist/configs/lint-staged/base.d.ts +5 -0
  27. package/dist/configs/vitest/react/e2e.d.cts +5 -0
  28. package/dist/configs/vitest/react/e2e.d.ts +5 -0
  29. package/dist/configs/vitest/react/unit.d.cts +5 -0
  30. package/dist/configs/vitest/react/unit.d.ts +5 -0
  31. package/dist/configs/vitest/react/unit.setup.d.cts +2 -0
  32. package/dist/configs/vitest/react/unit.setup.d.ts +2 -0
  33. package/dist/constants/index.d.cts +2 -0
  34. package/dist/constants/index.d.ts +2 -0
  35. package/dist/constants/path.d.cts +4 -0
  36. package/dist/constants/path.d.ts +4 -0
  37. package/dist/constants/response-status.d.cts +252 -0
  38. package/dist/constants/response-status.d.ts +252 -0
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.d.cts +40 -0
  41. package/dist/index.d.ts +40 -0
  42. package/dist/index.js +1 -1
  43. package/dist/nodejs/index.cjs +1 -1
  44. package/dist/nodejs/index.d.cts +5 -0
  45. package/dist/nodejs/index.d.ts +5 -0
  46. package/dist/nodejs/index.js +1 -1
  47. package/dist/nodejs/mongo.cjs +1 -1
  48. package/dist/nodejs/mongo.d.cts +55 -0
  49. package/dist/nodejs/mongo.d.ts +55 -0
  50. package/dist/nodejs/mongo.js +1 -1
  51. package/dist/nodejs/mongoose.d.cts +25 -0
  52. package/dist/nodejs/mongoose.d.ts +25 -0
  53. package/dist/react/apollo-client.d.cts +9 -0
  54. package/dist/react/apollo-client.d.ts +9 -0
  55. package/dist/react/index.d.cts +15 -0
  56. package/dist/react/index.d.ts +15 -0
  57. package/dist/react/loading.d.cts +13 -0
  58. package/dist/react/loading.d.ts +13 -0
  59. package/dist/react/loading.module.d.cts +2 -0
  60. package/dist/react/loading.module.d.ts +2 -0
  61. package/dist/react/next-intl.d.cts +28 -0
  62. package/dist/react/next-intl.d.ts +28 -0
  63. package/dist/react/storage.d.cts +5 -0
  64. package/dist/react/storage.d.ts +5 -0
  65. package/dist/styles/reset.d.cts +2 -0
  66. package/dist/styles/reset.d.ts +2 -0
  67. package/dist/typescript/apollo.d.cts +21 -0
  68. package/dist/typescript/apollo.d.ts +21 -0
  69. package/dist/typescript/command.d.cts +30 -0
  70. package/dist/typescript/command.d.ts +30 -0
  71. package/dist/typescript/config.d.cts +5 -0
  72. package/dist/typescript/config.d.ts +5 -0
  73. package/dist/typescript/graphql-codegen.d.cts +12 -0
  74. package/dist/typescript/graphql-codegen.d.ts +12 -0
  75. package/dist/typescript/index.d.cts +16 -0
  76. package/dist/typescript/index.d.ts +16 -0
  77. package/dist/typescript/loading.d.cts +8 -0
  78. package/dist/typescript/loading.d.ts +8 -0
  79. package/dist/typescript/log.d.cts +10 -0
  80. package/dist/typescript/log.d.ts +10 -0
  81. package/dist/typescript/mongoose.d.cts +163 -0
  82. package/dist/typescript/mongoose.d.ts +163 -0
  83. package/dist/typescript/next-intl.d.cts +23 -0
  84. package/dist/typescript/next-intl.d.ts +23 -0
  85. package/dist/typescript/react.d.cts +11 -0
  86. package/dist/typescript/react.d.ts +11 -0
  87. package/dist/typescript/serializer.d.cts +6 -0
  88. package/dist/typescript/serializer.d.ts +6 -0
  89. package/dist/utils/command.d.cts +17 -0
  90. package/dist/utils/command.d.ts +17 -0
  91. package/dist/utils/common.d.cts +5 -0
  92. package/dist/utils/common.d.ts +5 -0
  93. package/dist/utils/config.d.cts +5 -0
  94. package/dist/utils/config.d.ts +5 -0
  95. package/dist/utils/datetime.d.cts +3 -0
  96. package/dist/utils/datetime.d.ts +3 -0
  97. package/dist/utils/fs.d.cts +3 -0
  98. package/dist/utils/fs.d.ts +3 -0
  99. package/dist/utils/index-nodejs.cjs +1 -1
  100. package/dist/utils/index-nodejs.d.cts +13 -0
  101. package/dist/utils/index-nodejs.d.ts +13 -0
  102. package/dist/utils/index-nodejs.js +1 -1
  103. package/dist/utils/index.d.cts +8 -0
  104. package/dist/utils/index.d.ts +8 -0
  105. package/dist/utils/log.d.cts +5 -0
  106. package/dist/utils/log.d.ts +5 -0
  107. package/dist/utils/mongoose.cjs +1 -1
  108. package/dist/utils/mongoose.d.cts +22 -0
  109. package/dist/utils/mongoose.d.ts +22 -0
  110. package/dist/utils/mongoose.js +1 -1
  111. package/dist/utils/npm-package.d.cts +6 -0
  112. package/dist/utils/npm-package.d.ts +6 -0
  113. package/dist/utils/serializer.d.cts +5 -0
  114. package/dist/utils/serializer.d.ts +5 -0
  115. package/dist/utils/storage-client.d.cts +8 -0
  116. package/dist/utils/storage-client.d.ts +8 -0
  117. package/dist/utils/storage-server.d.cts +11 -0
  118. package/dist/utils/storage-server.d.ts +11 -0
  119. package/dist/utils/validate.d.cts +14 -0
  120. package/dist/utils/validate.d.ts +14 -0
  121. package/package.json +1 -1
@@ -0,0 +1,11 @@
1
+ import { ReactNode, ReactElement, JSX } from 'react';
2
+
3
+ type T_Children = ReactNode | ReactNode[] | ReactElement | JSX.Element | null;
4
+ interface I_LoadingContext {
5
+ isLoading: boolean;
6
+ isGlobalLoading: boolean;
7
+ showLoading: (global?: boolean) => void;
8
+ hideLoading: () => void;
9
+ }
10
+
11
+ export type { I_LoadingContext, T_Children };
@@ -0,0 +1,6 @@
1
+ interface I_Serializer<T> {
2
+ serialize: (value: T) => string;
3
+ deserialize: (value: string) => T;
4
+ }
5
+
6
+ export type { I_Serializer };
@@ -0,0 +1,6 @@
1
+ interface I_Serializer<T> {
2
+ serialize: (value: T) => string;
3
+ deserialize: (value: string) => T;
4
+ }
5
+
6
+ export type { I_Serializer };
@@ -0,0 +1,17 @@
1
+ import { I_ErrorEntry, I_BoxedLogOptions } from '../typescript/command.cjs';
2
+
3
+ declare function printBoxedLog<T extends string | I_ErrorEntry[]>(title: string, content: T, { color, padding, margin, borderStyle, titleColor, }?: I_BoxedLogOptions): void;
4
+ declare const commandLog: {
5
+ success: (message: string) => void;
6
+ error: (message: string) => void;
7
+ warning: (message: string) => void;
8
+ info: (message: string) => void;
9
+ printBoxedLog: typeof printBoxedLog;
10
+ };
11
+ declare function saveErrorListToStorage(errorList: I_ErrorEntry[]): Promise<void>;
12
+ declare function getStoredErrorLists(): Promise<I_ErrorEntry[]>;
13
+ declare function clearAllErrorLists(): Promise<void>;
14
+ declare function parseCommandOutput(output: string): void;
15
+ declare function executeCommand(command: string, parser?: typeof parseCommandOutput): Promise<void>;
16
+
17
+ export { clearAllErrorLists, commandLog, executeCommand, getStoredErrorLists, saveErrorListToStorage };
@@ -0,0 +1,17 @@
1
+ import { I_ErrorEntry, I_BoxedLogOptions } from '../typescript/command.js';
2
+
3
+ declare function printBoxedLog<T extends string | I_ErrorEntry[]>(title: string, content: T, { color, padding, margin, borderStyle, titleColor, }?: I_BoxedLogOptions): void;
4
+ declare const commandLog: {
5
+ success: (message: string) => void;
6
+ error: (message: string) => void;
7
+ warning: (message: string) => void;
8
+ info: (message: string) => void;
9
+ printBoxedLog: typeof printBoxedLog;
10
+ };
11
+ declare function saveErrorListToStorage(errorList: I_ErrorEntry[]): Promise<void>;
12
+ declare function getStoredErrorLists(): Promise<I_ErrorEntry[]>;
13
+ declare function clearAllErrorLists(): Promise<void>;
14
+ declare function parseCommandOutput(output: string): void;
15
+ declare function executeCommand(command: string, parser?: typeof parseCommandOutput): Promise<void>;
16
+
17
+ export { clearAllErrorLists, commandLog, executeCommand, getStoredErrorLists, saveErrorListToStorage };
@@ -0,0 +1,5 @@
1
+ declare function isJson(str: string): boolean;
2
+ declare function regexSearchMapper(str: string): string;
3
+ declare function removeAccent(str: string): string;
4
+
5
+ export { isJson, regexSearchMapper, removeAccent };
@@ -0,0 +1,5 @@
1
+ declare function isJson(str: string): boolean;
2
+ declare function regexSearchMapper(str: string): string;
3
+ declare function removeAccent(str: string): string;
4
+
5
+ export { isJson, regexSearchMapper, removeAccent };
@@ -0,0 +1,5 @@
1
+ import { I_Config } from '../typescript/config.cjs';
2
+
3
+ declare function deepMerge(...configs: (I_Config | I_Config[])[]): I_Config;
4
+
5
+ export { deepMerge };
@@ -0,0 +1,5 @@
1
+ import { I_Config } from '../typescript/config.js';
2
+
3
+ declare function deepMerge(...configs: (I_Config | I_Config[])[]): I_Config;
4
+
5
+ export { deepMerge };
@@ -0,0 +1,3 @@
1
+ declare function getMongoDateTime(): string;
2
+
3
+ export { getMongoDateTime };
@@ -0,0 +1,3 @@
1
+ declare function getMongoDateTime(): string;
2
+
3
+ export { getMongoDateTime };
@@ -0,0 +1,3 @@
1
+ declare const fileExists: (filePath: string) => boolean;
2
+
3
+ export { fileExists };
@@ -0,0 +1,3 @@
1
+ declare const fileExists: (filePath: string) => boolean;
2
+
3
+ export { fileExists };
@@ -1 +1 @@
1
- "use strict";function e(e,r,t,n,o,a,i){try{var s=e[a](i);var u=s.value}catch(e){t(e);return}if(s.done){r(u)}else{Promise.resolve(u).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,a){var i=r.apply(t,n);function s(r){e(i,o,a,s,u,"next",r)}function u(r){e(i,o,a,s,u,"throw",r)}s(undefined)})}}function t(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(r){t(e,r,n[r])})}return e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function a(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,r){if(e==null)return{};var t=s(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function s(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,a;for(a=0;a<n.length;a++){o=n[a];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function u(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function c(e,r){var t,n,o,a,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(a){if(t)throw new TypeError("Generator is already executing.");while(i)try{if(t=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=r.call(e,i)}catch(e){a=[6,e];n=0}finally{t=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var l=Object.create;var E=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var p=function(e,r){for(var t in r)E(e,t,{get:r[t],enumerable:!0})},h=function(e,r,t,n){var o=true,a=false,i=undefined;if(r&&(typeof r==="undefined"?"undefined":u(r))=="object"||typeof r=="function")try{var s=function(){var o=l.value;!g.call(e,o)&&o!==t&&E(e,o,{get:function(){return r[o]},enumerable:!(n=f(r,o))||n.enumerable})};for(var c=d(r)[Symbol.iterator](),l;!(o=(l=c.next()).done);o=true)s()}catch(e){a=true;i=e}finally{try{if(!o&&c.return!=null){c.return()}}finally{if(a){throw i}}}return e};var v=function(e,r,t){return t=e!=null?l(S(e)):{},h(r||!e||!e.__esModule?E(t,"default",{value:e,enumerable:!0}):t,e)},O=function(e){return h(E({},"__esModule",{value:!0}),e)};var y={};p(y,{aggregatePaginate:function(){return ec.default},clearAllErrorLists:function(){return X},commandLog:function(){return Y},executeCommand:function(){return er},fileExists:function(){return eo},generateModel:function(){return eO},generateSchema:function(){return ev},generateShortId:function(){return em},generateSlug:function(){return eA},generateSlugQuery:function(){return eD},getLatestPackageVersion:function(){return eU},getMongoGenericFields:function(){return eT},getStoredErrorLists:function(){return K},initNodePersist:function(){return G},isCurrentProject:function(){return eQ},isPackageOutdated:function(){return eF},mongoosePaginate:function(){return el.default},saveErrorListToStorage:function(){return W},storageDir:function(){return b},storageServer:function(){return L},throwResponse:function(){return es},updatePackage:function(){return ej}});module.exports=O(y);var A=function(){return(typeof document==="undefined"?"undefined":u(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},m=A();var D=v(require("boxen"),1),T=v(require("chalk"),1),R=require("child_process"),_=v(require("process"),1),C=v(require("util"),1);var I=v(require("node-persist"),1),M=v(require("os"),1),N=v(require("path"),1),P=v(require("process"),1),b=P.default.env.CYBERSKILL_STORAGE_DIR||N.default.join(M.default.homedir(),".cyberskill-storage");function G(){return w.apply(this,arguments)}function w(){w=r(function(){var e;return c(this,function(r){switch(r.label){case 0:e=I.default.defaultInstance;if(e)return[3,2];return[4,I.default.init({dir:b,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return w.apply(this,arguments)}var L={get:function e(e){return r(function(){var r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,G()];case 1:n.sent();return[4,I.default.getItem(e)];case 2:return[2,(r=n.sent())!==null&&r!==void 0?r:null];case 3:t=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return r(function(){var r;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,G()];case 1:n.sent();return[4,I.default.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,G()];case 1:t.sent();return[4,I.default.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,G()];case 1:t.sent();return[4,I.default.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return c(this,function(r){try{return[2,"".concat(b," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var U=_.default.env.DEBUG==="true",q=C.promisify(R.exec),F=T.default,k=F.gray,j=F.blue,x=function(){return k("[".concat(new Date().toLocaleTimeString(),"]"))};function Q(e){var r=T.default[e];return typeof r=="function"?r:T.default.green}function H(e,r,t,n){var o=Q(r);console.log("".concat(x()," ").concat(o("".concat(t," ").concat(e))," ").concat(n))}function B(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,o=n===void 0?"green":n,a=t.padding,i=a===void 0?1:a,s=t.margin,u=s===void 0?1:s,c=t.borderStyle,l=c===void 0?"round":c,E=t.titleColor,f=E===void 0?"bold":E;var d=Q(o),S=Q(f);if(typeof r=="string"){console.log((0,D.default)(S(d("".concat(e,"\n").concat(r))),{padding:i,margin:u,borderStyle:l,borderColor:o}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,o=e.message;console.log("".concat(x()," ").concat(d("File:")," ").concat(j("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(d("Rule:")," ").concat(d(n))),console.log(" ".concat(d("Message:")," ").concat(d(o)))}),console.log((0,D.default)(S(d("".concat(e,": ").concat(r.length))),{padding:i,margin:u,borderStyle:l,borderColor:o})),console.log(k("─".repeat(40))))}var Y={success:function(e){return H("SUCCESS","green","✔",e)},error:function(e){return H("ERROR","red","✖",e)},warning:function(e){return H("WARNING","yellow","⚠",e)},info:function(e){return H("INFO","blue","ℹ",e)},printBoxedLog:B},V=function(e){return"error_list:".concat(e)};function W(e){return J.apply(this,arguments)}function J(){J=r(function(e){var t,n,o;return c(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];t=Date.now(),n=V(t);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,L.set(n,{errors:e,timestamp:t})];case 2:a.sent(),setTimeout(/*#__PURE__*/r(function(){var e;return c(this,function(r){switch(r.label){case 0:return[4,L.getLogLink(n)];case 1:e=r.sent();e&&Y.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=a.sent();Y.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return J.apply(this,arguments)}function K(){return $.apply(this,arguments)}function $(){$=r(function(){var e,t,n;return c(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,L.keys()];case 1:e=o.sent(),t=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=r(function(e){var r;return c(this,function(t){switch(t.label){case 0:return[4,L.get(e)];case 1:return[2,((r=t.sent())===null||r===void 0?void 0:r.errors)||[]]}})});return function(r){return e.apply(this,arguments)}}()))];case 2:return[2,o.sent().flat()];case 3:n=o.sent();return[2,(Y.error("Failed to retrieve stored errors: ".concat(n.message)),[])];case 4:return[2]}})});return $.apply(this,arguments)}function X(){return z.apply(this,arguments)}function z(){z=r(function(){var e,r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,L.keys()];case 1:e=n.sent(),r=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(r.map(function(e){return L.remove(e)}))];case 2:n.sent();return[3,4];case 3:t=n.sent();Y.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return z.apply(this,arguments)}function Z(e){var r=[],t=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,i=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var s=o.exec(e)||[],u=a.exec(e)||[],c=i.exec(e)||[];s.length&&n?r.push({file:n,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()}):u.length?r.push({file:u[1],position:"".concat(u[2],":").concat(u[3]),type:u[4]==="error"?"error":"warning",message:u[5].trim()}):c.length?r.push({file:"commitlint",type:"error",message:c[1].trim(),rule:c[2].trim()}):t.push(e.trim())}}),r.length&&W(r),t.length&&U&&(Y.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function ee(e){try{var r=JSON.parse(e),t=[];r.forEach(function(e){var r=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,a=e.column,i=e.ruleId,s=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(o,":").concat(a),rule:i,message:s})})}),t.length&&W(t)}catch(r){Z(e)}}function er(e){return et.apply(this,arguments)}function et(){et=r(function(e){var r,t,n,o,a,i,s,u,l;var E=arguments;return c(this,function(c){switch(c.label){case 0:r=E.length>1&&E[1]!==void 0?E[1]:ee;t=new AbortController;_.default.on("SIGINT",function(){Y.warning("Process interrupted. Terminating..."),t.abort(),_.default.exit()});c.label=1;case 1:c.trys.push([1,3,,4]);return[4,q(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=c.sent(),o=n.stdout,a=n.stderr;[o,a].forEach(function(e){return e&&r(e)});return[3,4];case 3:i=c.sent();s=i.stdout,u=i.stderr,l=i.message;[s,u].forEach(function(e){return e&&r(e)}),!u&&!s&&Y.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return et.apply(this,arguments)}var en=v(require("fs"),1),eo=function(e){return en.existsSync(e)};var ea=require("graphql");var ei={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function es(e){var r=e.message,t=e.status,n=t===void 0?ei.INTERNAL_SERVER_ERROR:t,o=e.type,a=o===void 0?"graphql":o;var i;var s=(i=r!==null&&r!==void 0?r:n.MESSAGE)!==null&&i!==void 0?i:"Internal server error";throw a==="graphql"?new ea.GraphQLError(s,{extensions:{code:n.CODE}}):new Error(s)}var eu=v(require("crypto-js"),1),ec=v(require("mongoose-aggregate-paginate-v2"),1),el=v(require("mongoose-paginate-v2"),1),eE=v(require("slugify"),1),ef=require("uuid");var ed=require("date-fns");function eS(){return(0,ed.format)(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function eg(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function ep(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function eh(e){return new e.Schema({id:{type:String,default:ef.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function ev(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,a=e.standalone,i=a===void 0?!1:a;var s=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=s.virtual(r,t);n&&o.get(n)}),i||s.add(eh(r)),s}function eO(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,a=o===void 0?!1:o,i=e.aggregate,s=i===void 0?!1:i,u=e.virtuals,c=u===void 0?[]:u,l=e.middlewares,E=l===void 0?[]:l;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var f=ev({mongoose:r,schema:n,virtuals:c});return eg(f,[a&&el.default,s&&ec.default]),ep(f,E),r.model(t,f)}var ey=eE.default.default||eE.default;function eA(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;var t=r||{},o=t.lower,a=o===void 0?!0:o,s=t.locale,u=s===void 0?"vi":s,c=i(t,["lower","locale"]);return ey(e,n({lower:a,locale:u},c))}function em(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return eu.default.SHA256(e).toString(eu.default.enc.Hex).slice(0,r)}function eD(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;return a(n({},r,t&&{id:{$ne:t}}),{$or:[{slug:e},{slugHistory:e}]})}function eT(e){var r=e.isNew,t=r===void 0?!0:r;return a(n({},t&&{id:(0,ef.v4)()}),{isDel:!1,createdAt:eS(),updatedAt:eS()})}var eR=v(require("node-fetch"),1),e_=v(require("fs"),1),eC=v(require("path"),1);var eI=require("path"),eM=v(require("process"),1),eN=require("url"),eP=(0,eN.fileURLToPath)(m),eb=(0,eI.dirname)(eP),eG=eM.default.env.INIT_CWD||eM.default.cwd();var ew=24*60*60*1e3;function eL(e){return e?eC.default.join(eG,"node_modules",e,"package.json"):eC.default.join(eG,"package.json")}function eU(e){return eq.apply(this,arguments)}function eq(){eq=r(function(e){var r,t,n,o,a,i,s,u,l,E;var f=arguments;return c(this,function(c){switch(c.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:!1;t="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,L.get(t)];case 1:o=c.sent();return[4,L.get(n)];case 2:a=c.sent(),i=o&&Date.now()-o.timestamp<ew;if(!r&&i)return[2,(Y.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];s={};(a===null||a===void 0?void 0:a.etag)&&(s["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(s["If-Modified-Since"]=a.lastModified);c.label=3;case 3:c.trys.push([3,8,,9]);Y.info("Fetching latest version for ".concat(e,"..."));return[4,(0,eR.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:s})];case 4:u=c.sent();if(u.status===304&&o)return[2,(Y.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:l=c.sent().version;return[4,L.set(t,{version:l,timestamp:Date.now()})];case 6:c.sent();return[4,L.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(c.sent(),Y.success("Cached latest version for ".concat(e,": ").concat(l)),l)];case 8:E=c.sent();if(Y.error("Error fetching latest version for ".concat(e,": ").concat(E.message)),o)return[2,(Y.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw E;case 9:return[2]}})});return eq.apply(this,arguments)}function eF(e){return ek.apply(this,arguments)}function ek(){ek=r(function(e){var r,t,n,o,a;var i=arguments;return c(this,function(s){switch(s.label){case 0:r=i.length>1&&i[1]!==void 0?i[1]:!0;s.label=1;case 1:s.trys.push([1,3,,4]);t=eL(e);if(!e_.default.existsSync(t))return[2,(Y.info("".concat(e," is not installed.")),!0)];n=JSON.parse(e_.default.readFileSync(t,"utf-8")).version;return[4,eU(e,r)];case 2:o=s.sent();return[2,(Y.info("Installed version of ".concat(e,": ").concat(n)),Y.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=s.sent();return[2,(Y.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return ek.apply(this,arguments)}function ej(e){return ex.apply(this,arguments)}function ex(){ex=r(function(e){var r,o,i,s;return c(this,function(u){switch(u.label){case 0:u.trys.push([0,4,,5]);return[4,eU(e,!0)];case 1:r=u.sent(),o=eL();if(!e_.default.existsSync(o)){Y.error("package.json not found. Cannot update ".concat(e));return[2]}i=JSON.parse(e_.default.readFileSync(o,"utf-8"));i.dependencies=a(n({},i.dependencies),t({},e,r)),e_.default.writeFileSync(o,JSON.stringify(i,null,2)),Y.info("Updated ".concat(e," to version ").concat(r));return[4,er("npm i -f")];case 2:u.sent();return[4,er("npm run lint:fix")];case 3:u.sent(),Y.success("".concat(e," updated successfully."));return[3,5];case 4:s=u.sent();throw Y.error("Failed to update ".concat(e,": ").concat(s.message)),s;case 5:return[2]}})});return ex.apply(this,arguments)}function eQ(e,r){try{var t=eC.default.join(e,"package.json");return e_.default.existsSync(t)?JSON.parse(e_.default.readFileSync(t,"utf-8")).name===r:!1}catch(e){return Y.error("Error reading package.json: ".concat(e.message)),!1}}0&&(module.exports={aggregatePaginate:aggregatePaginate,clearAllErrorLists:clearAllErrorLists,commandLog:commandLog,executeCommand:executeCommand,fileExists:fileExists,generateModel:generateModel,generateSchema:generateSchema,generateShortId:generateShortId,generateSlug:generateSlug,generateSlugQuery:generateSlugQuery,getLatestPackageVersion:getLatestPackageVersion,getMongoGenericFields:getMongoGenericFields,getStoredErrorLists:getStoredErrorLists,initNodePersist:initNodePersist,isCurrentProject:isCurrentProject,isPackageOutdated:isPackageOutdated,mongoosePaginate:mongoosePaginate,saveErrorListToStorage:saveErrorListToStorage,storageDir:storageDir,storageServer:storageServer,throwResponse:throwResponse,updatePackage:updatePackage});
1
+ "use strict";function e(e,r,t,n,o,a,i){try{var s=e[a](i);var u=s.value}catch(e){t(e);return}if(s.done){r(u)}else{Promise.resolve(u).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,a){var i=r.apply(t,n);function s(r){e(i,o,a,s,u,"next",r)}function u(r){e(i,o,a,s,u,"throw",r)}s(undefined)})}}function t(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(r){t(e,r,n[r])})}return e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function a(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,r){if(e==null)return{};var t=s(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function s(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,a;for(a=0;a<n.length;a++){o=n[a];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function u(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function c(e,r){var t,n,o,a,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(a){if(t)throw new TypeError("Generator is already executing.");while(i)try{if(t=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=r.call(e,i)}catch(e){a=[6,e];n=0}finally{t=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var l=Object.create;var E=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var p=function(e,r){for(var t in r)E(e,t,{get:r[t],enumerable:!0})},v=function(e,r,t,n){var o=true,a=false,i=undefined;if(r&&(typeof r==="undefined"?"undefined":u(r))=="object"||typeof r=="function")try{var s=function(){var o=l.value;!g.call(e,o)&&o!==t&&E(e,o,{get:function(){return r[o]},enumerable:!(n=f(r,o))||n.enumerable})};for(var c=d(r)[Symbol.iterator](),l;!(o=(l=c.next()).done);o=true)s()}catch(e){a=true;i=e}finally{try{if(!o&&c.return!=null){c.return()}}finally{if(a){throw i}}}return e};var h=function(e,r,t){return t=e!=null?l(S(e)):{},v(r||!e||!e.__esModule?E(t,"default",{value:e,enumerable:!0}):t,e)},O=function(e){return v(E({},"__esModule",{value:!0}),e)};var y={};p(y,{aggregatePaginate:function(){return ec.default},clearAllErrorLists:function(){return X},commandLog:function(){return Y},executeCommand:function(){return er},fileExists:function(){return eo},generateModel:function(){return eO},generateSchema:function(){return eh},generateShortId:function(){return em},generateSlug:function(){return eA},generateSlugQuery:function(){return eD},getLatestPackageVersion:function(){return eU},getMongoGenericFields:function(){return eT},getStoredErrorLists:function(){return K},initNodePersist:function(){return G},isCurrentProject:function(){return eQ},isPackageOutdated:function(){return eF},mongoosePaginate:function(){return el.default},saveErrorListToStorage:function(){return W},storageDir:function(){return b},storageServer:function(){return L},throwResponse:function(){return es},updatePackage:function(){return ej}});module.exports=O(y);var A=function(){return(typeof document==="undefined"?"undefined":u(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},m=A();var D=h(require("boxen"),1),T=h(require("chalk"),1),R=require("child_process"),_=h(require("process"),1),C=h(require("util"),1);var I=h(require("node-persist"),1),M=h(require("os"),1),N=h(require("path"),1),P=h(require("process"),1),b=P.default.env.CYBERSKILL_STORAGE_DIR||N.default.join(M.default.homedir(),".cyberskill-storage");function G(){return w.apply(this,arguments)}function w(){w=r(function(){var e;return c(this,function(r){switch(r.label){case 0:e=I.default.defaultInstance;if(e)return[3,2];return[4,I.default.init({dir:b,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return w.apply(this,arguments)}var L={get:function e(e){return r(function(){var r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,G()];case 1:n.sent();return[4,I.default.getItem(e)];case 2:return[2,(r=n.sent())!==null&&r!==void 0?r:null];case 3:t=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return r(function(){var r;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,G()];case 1:n.sent();return[4,I.default.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,G()];case 1:t.sent();return[4,I.default.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,G()];case 1:t.sent();return[4,I.default.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return c(this,function(r){try{return[2,"".concat(b," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var U=_.default.env.DEBUG==="true",q=C.promisify(R.exec),F=T.default,k=F.gray,j=F.blue,x=function(){return k("[".concat(new Date().toLocaleTimeString(),"]"))};function Q(e){var r=T.default[e];return typeof r=="function"?r:T.default.green}function H(e,r,t,n){var o=Q(r);console.log("".concat(x()," ").concat(o("".concat(t," ").concat(e))," ").concat(n))}function B(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,o=n===void 0?"green":n,a=t.padding,i=a===void 0?1:a,s=t.margin,u=s===void 0?1:s,c=t.borderStyle,l=c===void 0?"round":c,E=t.titleColor,f=E===void 0?"bold":E;var d=Q(o),S=Q(f);if(typeof r=="string"){console.log((0,D.default)(S(d("".concat(e,"\n").concat(r))),{padding:i,margin:u,borderStyle:l,borderColor:o}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,o=e.message;console.log("".concat(x()," ").concat(d("File:")," ").concat(j("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(d("Rule:")," ").concat(d(n))),console.log(" ".concat(d("Message:")," ").concat(d(o)))}),console.log((0,D.default)(S(d("".concat(e,": ").concat(r.length))),{padding:i,margin:u,borderStyle:l,borderColor:o})),console.log(k("─".repeat(40))))}var Y={success:function(e){return H("SUCCESS","green","✔",e)},error:function(e){return H("ERROR","red","✖",e)},warning:function(e){return H("WARNING","yellow","⚠",e)},info:function(e){return H("INFO","blue","ℹ",e)},printBoxedLog:B},V=function(e){return"error_list:".concat(e)};function W(e){return J.apply(this,arguments)}function J(){J=r(function(e){var t,n,o;return c(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];t=Date.now(),n=V(t);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,L.set(n,{errors:e,timestamp:t})];case 2:a.sent(),setTimeout(/*#__PURE__*/r(function(){var e;return c(this,function(r){switch(r.label){case 0:return[4,L.getLogLink(n)];case 1:e=r.sent();e&&Y.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=a.sent();Y.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return J.apply(this,arguments)}function K(){return $.apply(this,arguments)}function $(){$=r(function(){var e,t,n;return c(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,L.keys()];case 1:e=o.sent(),t=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=r(function(e){var r;return c(this,function(t){switch(t.label){case 0:return[4,L.get(e)];case 1:return[2,((r=t.sent())===null||r===void 0?void 0:r.errors)||[]]}})});return function(r){return e.apply(this,arguments)}}()))];case 2:return[2,o.sent().flat()];case 3:n=o.sent();return[2,(Y.error("Failed to retrieve stored errors: ".concat(n.message)),[])];case 4:return[2]}})});return $.apply(this,arguments)}function X(){return z.apply(this,arguments)}function z(){z=r(function(){var e,r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,L.keys()];case 1:e=n.sent(),r=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(r.map(function(e){return L.remove(e)}))];case 2:n.sent();return[3,4];case 3:t=n.sent();Y.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return z.apply(this,arguments)}function Z(e){var r=[],t=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,i=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var s=o.exec(e)||[],u=a.exec(e)||[],c=i.exec(e)||[];s.length&&n?r.push({file:n,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()}):u.length?r.push({file:u[1],position:"".concat(u[2],":").concat(u[3]),type:u[4]==="error"?"error":"warning",message:u[5].trim()}):c.length?r.push({file:"commitlint",type:"error",message:c[1].trim(),rule:c[2].trim()}):t.push(e.trim())}}),r.length&&W(r),t.length&&U&&(Y.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function ee(e){try{var r=JSON.parse(e),t=[];r.forEach(function(e){var r=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,a=e.column,i=e.ruleId,s=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(o,":").concat(a),rule:i,message:s})})}),t.length&&W(t)}catch(r){Z(e)}}function er(e){return et.apply(this,arguments)}function et(){et=r(function(e){var r,t,n,o,a,i,s,u,l;var E=arguments;return c(this,function(c){switch(c.label){case 0:r=E.length>1&&E[1]!==void 0?E[1]:ee;t=new AbortController;_.default.on("SIGINT",function(){Y.warning("Process interrupted. Terminating..."),t.abort(),_.default.exit()});c.label=1;case 1:c.trys.push([1,3,,4]);return[4,q(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=c.sent(),o=n.stdout,a=n.stderr;[o,a].forEach(function(e){return e&&r(e)});return[3,4];case 3:i=c.sent();s=i.stdout,u=i.stderr,l=i.message;[s,u].forEach(function(e){return e&&r(e)}),!u&&!s&&Y.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return et.apply(this,arguments)}var en=h(require("fs"),1),eo=function(e){return en.existsSync(e)};var ea=require("graphql");var ei={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function es(e){var r=e.message,t=e.status,n=t===void 0?ei.INTERNAL_SERVER_ERROR:t,o=e.type,a=o===void 0?"graphql":o;var i;var s=(i=r!==null&&r!==void 0?r:n.MESSAGE)!==null&&i!==void 0?i:"Internal server error";throw a==="graphql"?new ea.GraphQLError(s,{extensions:{code:n.CODE}}):new Error(s)}var eu=h(require("crypto-js"),1),ec=h(require("mongoose-aggregate-paginate-v2"),1),el=h(require("mongoose-paginate-v2"),1),eE=h(require("slugify"),1),ef=require("uuid");var ed=require("date-fns");function eS(){return(0,ed.format)(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function eg(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function ep(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function ev(e){return new e.Schema({id:{type:String,default:ef.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function eh(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,a=e.standalone,i=a===void 0?!1:a;var s=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=s.virtual(r,t);n&&o.get(n)}),i||s.add(ev(r)),s}function eO(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,a=o===void 0?!1:o,i=e.aggregate,s=i===void 0?!1:i,u=e.virtuals,c=u===void 0?[]:u,l=e.middlewares,E=l===void 0?[]:l;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var f=eh({mongoose:r,schema:n,virtuals:c});return eg(f,[a&&el.default,s&&ec.default]),ep(f,E),r.model(t,f)}var ey=eE.default.default||eE.default;function eA(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;var t=r||{},o=t.lower,a=o===void 0?!0:o,s=t.locale,u=s===void 0?"vi":s,c=i(t,["lower","locale"]);return ey(e,n({lower:a,locale:u},c))}function em(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return eu.default.SHA256(e).toString(eu.default.enc.Hex).slice(0,r)}function eD(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;return a(n({},r,t&&{id:{$ne:t}}),{$or:[{slug:e},{slugHistory:e}]})}function eT(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.isNew,t=r===void 0?!0:r,o=e.returnDateAs,i=o===void 0?"string":o;var s=i==="string"?eS():new Date;return a(n({},t&&{id:(0,ef.v4)()}),{isDel:!1,createdAt:s,updatedAt:s})}var eR=h(require("node-fetch"),1),e_=h(require("fs"),1),eC=h(require("path"),1);var eI=require("path"),eM=h(require("process"),1),eN=require("url"),eP=(0,eN.fileURLToPath)(m),eb=(0,eI.dirname)(eP),eG=eM.default.env.INIT_CWD||eM.default.cwd();var ew=24*60*60*1e3;function eL(e){return e?eC.default.join(eG,"node_modules",e,"package.json"):eC.default.join(eG,"package.json")}function eU(e){return eq.apply(this,arguments)}function eq(){eq=r(function(e){var r,t,n,o,a,i,s,u,l,E;var f=arguments;return c(this,function(c){switch(c.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:!1;t="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,L.get(t)];case 1:o=c.sent();return[4,L.get(n)];case 2:a=c.sent(),i=o&&Date.now()-o.timestamp<ew;if(!r&&i)return[2,(Y.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];s={};(a===null||a===void 0?void 0:a.etag)&&(s["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(s["If-Modified-Since"]=a.lastModified);c.label=3;case 3:c.trys.push([3,8,,9]);Y.info("Fetching latest version for ".concat(e,"..."));return[4,(0,eR.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:s})];case 4:u=c.sent();if(u.status===304&&o)return[2,(Y.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:l=c.sent().version;return[4,L.set(t,{version:l,timestamp:Date.now()})];case 6:c.sent();return[4,L.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(c.sent(),Y.success("Cached latest version for ".concat(e,": ").concat(l)),l)];case 8:E=c.sent();if(Y.error("Error fetching latest version for ".concat(e,": ").concat(E.message)),o)return[2,(Y.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw E;case 9:return[2]}})});return eq.apply(this,arguments)}function eF(e){return ek.apply(this,arguments)}function ek(){ek=r(function(e){var r,t,n,o,a;var i=arguments;return c(this,function(s){switch(s.label){case 0:r=i.length>1&&i[1]!==void 0?i[1]:!0;s.label=1;case 1:s.trys.push([1,3,,4]);t=eL(e);if(!e_.default.existsSync(t))return[2,(Y.info("".concat(e," is not installed.")),!0)];n=JSON.parse(e_.default.readFileSync(t,"utf-8")).version;return[4,eU(e,r)];case 2:o=s.sent();return[2,(Y.info("Installed version of ".concat(e,": ").concat(n)),Y.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=s.sent();return[2,(Y.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return ek.apply(this,arguments)}function ej(e){return ex.apply(this,arguments)}function ex(){ex=r(function(e){var r,o,i,s;return c(this,function(u){switch(u.label){case 0:u.trys.push([0,4,,5]);return[4,eU(e,!0)];case 1:r=u.sent(),o=eL();if(!e_.default.existsSync(o)){Y.error("package.json not found. Cannot update ".concat(e));return[2]}i=JSON.parse(e_.default.readFileSync(o,"utf-8"));i.dependencies=a(n({},i.dependencies),t({},e,r)),e_.default.writeFileSync(o,JSON.stringify(i,null,2)),Y.info("Updated ".concat(e," to version ").concat(r));return[4,er("npm i -f")];case 2:u.sent();return[4,er("npm run lint:fix")];case 3:u.sent(),Y.success("".concat(e," updated successfully."));return[3,5];case 4:s=u.sent();throw Y.error("Failed to update ".concat(e,": ").concat(s.message)),s;case 5:return[2]}})});return ex.apply(this,arguments)}function eQ(e,r){try{var t=eC.default.join(e,"package.json");return e_.default.existsSync(t)?JSON.parse(e_.default.readFileSync(t,"utf-8")).name===r:!1}catch(e){return Y.error("Error reading package.json: ".concat(e.message)),!1}}0&&(module.exports={aggregatePaginate:aggregatePaginate,clearAllErrorLists:clearAllErrorLists,commandLog:commandLog,executeCommand:executeCommand,fileExists:fileExists,generateModel:generateModel,generateSchema:generateSchema,generateShortId:generateShortId,generateSlug:generateSlug,generateSlugQuery:generateSlugQuery,getLatestPackageVersion:getLatestPackageVersion,getMongoGenericFields:getMongoGenericFields,getStoredErrorLists:getStoredErrorLists,initNodePersist:initNodePersist,isCurrentProject:isCurrentProject,isPackageOutdated:isPackageOutdated,mongoosePaginate:mongoosePaginate,saveErrorListToStorage:saveErrorListToStorage,storageDir:storageDir,storageServer:storageServer,throwResponse:throwResponse,updatePackage:updatePackage});
@@ -0,0 +1,13 @@
1
+ export { clearAllErrorLists, commandLog, executeCommand, getStoredErrorLists, saveErrorListToStorage } from './command.cjs';
2
+ export { fileExists } from './fs.cjs';
3
+ export { throwResponse } from './log.cjs';
4
+ export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getMongoGenericFields } from './mongoose.cjs';
5
+ export { getLatestPackageVersion, isCurrentProject, isPackageOutdated, updatePackage } from './npm-package.cjs';
6
+ export { initNodePersist, storageDir, storageServer } from './storage-server.cjs';
7
+ export { default as aggregatePaginate } from 'mongoose-aggregate-paginate-v2';
8
+ export { default as mongoosePaginate } from 'mongoose-paginate-v2';
9
+ import '../typescript/command.cjs';
10
+ import '../typescript/log.cjs';
11
+ import '../typescript/mongoose.cjs';
12
+ import 'mongodb';
13
+ import 'mongoose';
@@ -0,0 +1,13 @@
1
+ export { clearAllErrorLists, commandLog, executeCommand, getStoredErrorLists, saveErrorListToStorage } from './command.js';
2
+ export { fileExists } from './fs.js';
3
+ export { throwResponse } from './log.js';
4
+ export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getMongoGenericFields } from './mongoose.js';
5
+ export { getLatestPackageVersion, isCurrentProject, isPackageOutdated, updatePackage } from './npm-package.js';
6
+ export { initNodePersist, storageDir, storageServer } from './storage-server.js';
7
+ export { default as aggregatePaginate } from 'mongoose-aggregate-paginate-v2';
8
+ export { default as mongoosePaginate } from 'mongoose-paginate-v2';
9
+ import '../typescript/command.js';
10
+ import '../typescript/log.js';
11
+ import '../typescript/mongoose.js';
12
+ import 'mongodb';
13
+ import 'mongoose';
@@ -1 +1 @@
1
- function e(e,r,t,n,o,a,i){try{var s=e[a](i);var c=s.value}catch(e){t(e);return}if(s.done){r(c)}else{Promise.resolve(c).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,a){var i=r.apply(t,n);function s(r){e(i,o,a,s,c,"next",r)}function c(r){e(i,o,a,s,c,"throw",r)}s(undefined)})}}function t(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(r){t(e,r,n[r])})}return e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function a(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,r){if(e==null)return{};var t=s(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function s(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,a;for(a=0;a<n.length;a++){o=n[a];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function c(e,r){var t,n,o,a,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return c([e,r])}}function c(a){if(t)throw new TypeError("Generator is already executing.");while(i)try{if(t=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=r.call(e,i)}catch(e){a=[6,e];n=0}finally{t=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}import u from"boxen";import E from"chalk";import{exec as l}from"node:child_process";import f from"node:process";import*as S from"node:util";import d from"node-persist";import p from"node:os";import g from"node:path";import h from"node:process";var O=h.env.CYBERSKILL_STORAGE_DIR||g.join(p.homedir(),".cyberskill-storage");function v(){return m.apply(this,arguments)}function m(){m=r(function(){var e;return c(this,function(r){switch(r.label){case 0:e=d.defaultInstance;if(e)return[3,2];return[4,d.init({dir:O,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return m.apply(this,arguments)}var A={get:function e(e){return r(function(){var r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,v()];case 1:n.sent();return[4,d.getItem(e)];case 2:return[2,(r=n.sent())!==null&&r!==void 0?r:null];case 3:t=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return r(function(){var r;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,v()];case 1:n.sent();return[4,d.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,v()];case 1:t.sent();return[4,d.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,v()];case 1:t.sent();return[4,d.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return c(this,function(r){try{return[2,"".concat(O," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var y=f.env.DEBUG==="true",D=S.promisify(l),T=E.gray,R=E.blue,C=function(){return T("[".concat(new Date().toLocaleTimeString(),"]"))};function _(e){var r=E[e];return typeof r=="function"?r:E.green}function I(e,r,t,n){var o=_(r);console.log("".concat(C()," ").concat(o("".concat(t," ").concat(e))," ").concat(n))}function M(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,o=n===void 0?"green":n,a=t.padding,i=a===void 0?1:a,s=t.margin,c=s===void 0?1:s,E=t.borderStyle,l=E===void 0?"round":E,f=t.titleColor,S=f===void 0?"bold":f;var d=_(o),p=_(S);if(typeof r=="string"){console.log(u(p(d("".concat(e,"\n").concat(r))),{padding:i,margin:c,borderStyle:l,borderColor:o}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,o=e.message;console.log("".concat(C()," ").concat(d("File:")," ").concat(R("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(d("Rule:")," ").concat(d(n))),console.log(" ".concat(d("Message:")," ").concat(d(o)))}),console.log(u(p(d("".concat(e,": ").concat(r.length))),{padding:i,margin:c,borderStyle:l,borderColor:o})),console.log(T("─".repeat(40))))}var N={success:function(e){return I("SUCCESS","green","✔",e)},error:function(e){return I("ERROR","red","✖",e)},warning:function(e){return I("WARNING","yellow","⚠",e)},info:function(e){return I("INFO","blue","ℹ",e)},printBoxedLog:M},G=function(e){return"error_list:".concat(e)};function P(e){return b.apply(this,arguments)}function b(){b=r(function(e){var t,n,o;return c(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];t=Date.now(),n=G(t);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,A.set(n,{errors:e,timestamp:t})];case 2:a.sent(),setTimeout(/*#__PURE__*/r(function(){var e;return c(this,function(r){switch(r.label){case 0:return[4,A.getLogLink(n)];case 1:e=r.sent();e&&N.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=a.sent();N.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return b.apply(this,arguments)}function w(){return L.apply(this,arguments)}function L(){L=r(function(){var e,t,n;return c(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,A.keys()];case 1:e=o.sent(),t=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=r(function(e){var r;return c(this,function(t){switch(t.label){case 0:return[4,A.get(e)];case 1:return[2,((r=t.sent())===null||r===void 0?void 0:r.errors)||[]]}})});return function(r){return e.apply(this,arguments)}}()))];case 2:return[2,o.sent().flat()];case 3:n=o.sent();return[2,(N.error("Failed to retrieve stored errors: ".concat(n.message)),[])];case 4:return[2]}})});return L.apply(this,arguments)}function U(){return F.apply(this,arguments)}function F(){F=r(function(){var e,r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,A.keys()];case 1:e=n.sent(),r=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(r.map(function(e){return A.remove(e)}))];case 2:n.sent();return[3,4];case 3:t=n.sent();N.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return F.apply(this,arguments)}function k(e){var r=[],t=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,i=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var s=o.exec(e)||[],c=a.exec(e)||[],u=i.exec(e)||[];s.length&&n?r.push({file:n,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()}):c.length?r.push({file:c[1],position:"".concat(c[2],":").concat(c[3]),type:c[4]==="error"?"error":"warning",message:c[5].trim()}):u.length?r.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):t.push(e.trim())}}),r.length&&P(r),t.length&&y&&(N.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function j(e){try{var r=JSON.parse(e),t=[];r.forEach(function(e){var r=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,a=e.column,i=e.ruleId,s=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(o,":").concat(a),rule:i,message:s})})}),t.length&&P(t)}catch(r){k(e)}}function x(e){return q.apply(this,arguments)}function q(){q=r(function(e){var r,t,n,o,a,i,s,u,E;var l=arguments;return c(this,function(c){switch(c.label){case 0:r=l.length>1&&l[1]!==void 0?l[1]:j;t=new AbortController;f.on("SIGINT",function(){N.warning("Process interrupted. Terminating..."),t.abort(),f.exit()});c.label=1;case 1:c.trys.push([1,3,,4]);return[4,D(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=c.sent(),o=n.stdout,a=n.stderr;[o,a].forEach(function(e){return e&&r(e)});return[3,4];case 3:i=c.sent();s=i.stdout,u=i.stderr,E=i.message;[s,u].forEach(function(e){return e&&r(e)}),!u&&!s&&N.error("Command failed: ".concat(E));return[3,4];case 4:return[2]}})});return q.apply(this,arguments)}import*as Q from"node:fs";var H=function(e){return Q.existsSync(e)};import{GraphQLError as B}from"graphql";var Y={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function V(e){var r=e.message,t=e.status,n=t===void 0?Y.INTERNAL_SERVER_ERROR:t,o=e.type,a=o===void 0?"graphql":o;var i;var s=(i=r!==null&&r!==void 0?r:n.MESSAGE)!==null&&i!==void 0?i:"Internal server error";throw a==="graphql"?new B(s,{extensions:{code:n.CODE}}):new Error(s)}import W from"crypto-js";import J from"mongoose-aggregate-paginate-v2";import K from"mongoose-paginate-v2";import $ from"slugify";import{v4 as X}from"uuid";import{format as z}from"date-fns";function Z(){return z(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function ee(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function er(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function et(e){return new e.Schema({id:{type:String,default:X,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function en(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,a=e.standalone,i=a===void 0?!1:a;var s=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=s.virtual(r,t);n&&o.get(n)}),i||s.add(et(r)),s}function eo(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,a=o===void 0?!1:o,i=e.aggregate,s=i===void 0?!1:i,c=e.virtuals,u=c===void 0?[]:c,E=e.middlewares,l=E===void 0?[]:E;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var f=en({mongoose:r,schema:n,virtuals:u});return ee(f,[a&&K,s&&J]),er(f,l),r.model(t,f)}var ea=$.default||$;function ei(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;var t=r||{},o=t.lower,a=o===void 0?!0:o,s=t.locale,c=s===void 0?"vi":s,u=i(t,["lower","locale"]);return ea(e,n({lower:a,locale:c},u))}function es(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return W.SHA256(e).toString(W.enc.Hex).slice(0,r)}function ec(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;return a(n({},r,t&&{id:{$ne:t}}),{$or:[{slug:e},{slugHistory:e}]})}function eu(e){var r=e.isNew,t=r===void 0?!0:r;return a(n({},t&&{id:X()}),{isDel:!1,createdAt:Z(),updatedAt:Z()})}import eE from"node-fetch";import el from"node:fs";import ef from"node:path";import{dirname as eS}from"node:path";import ed from"node:process";import{fileURLToPath as ep}from"node:url";var eg=ep(import.meta.url),eh=eS(eg),eO=ed.env.INIT_CWD||ed.cwd();var ev=24*60*60*1e3;function em(e){return e?ef.join(eO,"node_modules",e,"package.json"):ef.join(eO,"package.json")}function eA(e){return ey.apply(this,arguments)}function ey(){ey=r(function(e){var r,t,n,o,a,i,s,u,E,l;var f=arguments;return c(this,function(c){switch(c.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:!1;t="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,A.get(t)];case 1:o=c.sent();return[4,A.get(n)];case 2:a=c.sent(),i=o&&Date.now()-o.timestamp<ev;if(!r&&i)return[2,(N.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];s={};(a===null||a===void 0?void 0:a.etag)&&(s["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(s["If-Modified-Since"]=a.lastModified);c.label=3;case 3:c.trys.push([3,8,,9]);N.info("Fetching latest version for ".concat(e,"..."));return[4,eE("https://registry.npmjs.org/".concat(e,"/latest"),{headers:s})];case 4:u=c.sent();if(u.status===304&&o)return[2,(N.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:E=c.sent().version;return[4,A.set(t,{version:E,timestamp:Date.now()})];case 6:c.sent();return[4,A.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(c.sent(),N.success("Cached latest version for ".concat(e,": ").concat(E)),E)];case 8:l=c.sent();if(N.error("Error fetching latest version for ".concat(e,": ").concat(l.message)),o)return[2,(N.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw l;case 9:return[2]}})});return ey.apply(this,arguments)}function eD(e){return eT.apply(this,arguments)}function eT(){eT=r(function(e){var r,t,n,o,a;var i=arguments;return c(this,function(s){switch(s.label){case 0:r=i.length>1&&i[1]!==void 0?i[1]:!0;s.label=1;case 1:s.trys.push([1,3,,4]);t=em(e);if(!el.existsSync(t))return[2,(N.info("".concat(e," is not installed.")),!0)];n=JSON.parse(el.readFileSync(t,"utf-8")).version;return[4,eA(e,r)];case 2:o=s.sent();return[2,(N.info("Installed version of ".concat(e,": ").concat(n)),N.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=s.sent();return[2,(N.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return eT.apply(this,arguments)}function eR(e){return eC.apply(this,arguments)}function eC(){eC=r(function(e){var r,o,i,s;return c(this,function(c){switch(c.label){case 0:c.trys.push([0,4,,5]);return[4,eA(e,!0)];case 1:r=c.sent(),o=em();if(!el.existsSync(o)){N.error("package.json not found. Cannot update ".concat(e));return[2]}i=JSON.parse(el.readFileSync(o,"utf-8"));i.dependencies=a(n({},i.dependencies),t({},e,r)),el.writeFileSync(o,JSON.stringify(i,null,2)),N.info("Updated ".concat(e," to version ").concat(r));return[4,x("npm i -f")];case 2:c.sent();return[4,x("npm run lint:fix")];case 3:c.sent(),N.success("".concat(e," updated successfully."));return[3,5];case 4:s=c.sent();throw N.error("Failed to update ".concat(e,": ").concat(s.message)),s;case 5:return[2]}})});return eC.apply(this,arguments)}function e_(e,r){try{var t=ef.join(e,"package.json");return el.existsSync(t)?JSON.parse(el.readFileSync(t,"utf-8")).name===r:!1}catch(e){return N.error("Error reading package.json: ".concat(e.message)),!1}}export{J as aggregatePaginate,U as clearAllErrorLists,N as commandLog,x as executeCommand,H as fileExists,eo as generateModel,en as generateSchema,es as generateShortId,ei as generateSlug,ec as generateSlugQuery,eA as getLatestPackageVersion,eu as getMongoGenericFields,w as getStoredErrorLists,v as initNodePersist,e_ as isCurrentProject,eD as isPackageOutdated,K as mongoosePaginate,P as saveErrorListToStorage,O as storageDir,A as storageServer,V as throwResponse,eR as updatePackage};
1
+ function e(e,r,t,n,o,a,i){try{var s=e[a](i);var c=s.value}catch(e){t(e);return}if(s.done){r(c)}else{Promise.resolve(c).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,a){var i=r.apply(t,n);function s(r){e(i,o,a,s,c,"next",r)}function c(r){e(i,o,a,s,c,"throw",r)}s(undefined)})}}function t(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(r){t(e,r,n[r])})}return e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function a(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,r){if(e==null)return{};var t=s(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function s(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,a;for(a=0;a<n.length;a++){o=n[a];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function c(e,r){var t,n,o,a,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return c([e,r])}}function c(a){if(t)throw new TypeError("Generator is already executing.");while(i)try{if(t=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=r.call(e,i)}catch(e){a=[6,e];n=0}finally{t=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}import u from"boxen";import E from"chalk";import{exec as l}from"node:child_process";import f from"node:process";import*as d from"node:util";import S from"node-persist";import p from"node:os";import g from"node:path";import h from"node:process";var O=h.env.CYBERSKILL_STORAGE_DIR||g.join(p.homedir(),".cyberskill-storage");function v(){return m.apply(this,arguments)}function m(){m=r(function(){var e;return c(this,function(r){switch(r.label){case 0:e=S.defaultInstance;if(e)return[3,2];return[4,S.init({dir:O,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return m.apply(this,arguments)}var A={get:function e(e){return r(function(){var r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,v()];case 1:n.sent();return[4,S.getItem(e)];case 2:return[2,(r=n.sent())!==null&&r!==void 0?r:null];case 3:t=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return r(function(){var r;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,v()];case 1:n.sent();return[4,S.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,v()];case 1:t.sent();return[4,S.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,v()];case 1:t.sent();return[4,S.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return c(this,function(r){try{return[2,"".concat(O," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var y=f.env.DEBUG==="true",D=d.promisify(l),T=E.gray,R=E.blue,_=function(){return T("[".concat(new Date().toLocaleTimeString(),"]"))};function C(e){var r=E[e];return typeof r=="function"?r:E.green}function I(e,r,t,n){var o=C(r);console.log("".concat(_()," ").concat(o("".concat(t," ").concat(e))," ").concat(n))}function M(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,o=n===void 0?"green":n,a=t.padding,i=a===void 0?1:a,s=t.margin,c=s===void 0?1:s,E=t.borderStyle,l=E===void 0?"round":E,f=t.titleColor,d=f===void 0?"bold":f;var S=C(o),p=C(d);if(typeof r=="string"){console.log(u(p(S("".concat(e,"\n").concat(r))),{padding:i,margin:c,borderStyle:l,borderColor:o}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,o=e.message;console.log("".concat(_()," ").concat(S("File:")," ").concat(R("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(S("Rule:")," ").concat(S(n))),console.log(" ".concat(S("Message:")," ").concat(S(o)))}),console.log(u(p(S("".concat(e,": ").concat(r.length))),{padding:i,margin:c,borderStyle:l,borderColor:o})),console.log(T("─".repeat(40))))}var N={success:function(e){return I("SUCCESS","green","✔",e)},error:function(e){return I("ERROR","red","✖",e)},warning:function(e){return I("WARNING","yellow","⚠",e)},info:function(e){return I("INFO","blue","ℹ",e)},printBoxedLog:M},G=function(e){return"error_list:".concat(e)};function P(e){return b.apply(this,arguments)}function b(){b=r(function(e){var t,n,o;return c(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];t=Date.now(),n=G(t);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,A.set(n,{errors:e,timestamp:t})];case 2:a.sent(),setTimeout(/*#__PURE__*/r(function(){var e;return c(this,function(r){switch(r.label){case 0:return[4,A.getLogLink(n)];case 1:e=r.sent();e&&N.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=a.sent();N.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return b.apply(this,arguments)}function w(){return L.apply(this,arguments)}function L(){L=r(function(){var e,t,n;return c(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,A.keys()];case 1:e=o.sent(),t=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=r(function(e){var r;return c(this,function(t){switch(t.label){case 0:return[4,A.get(e)];case 1:return[2,((r=t.sent())===null||r===void 0?void 0:r.errors)||[]]}})});return function(r){return e.apply(this,arguments)}}()))];case 2:return[2,o.sent().flat()];case 3:n=o.sent();return[2,(N.error("Failed to retrieve stored errors: ".concat(n.message)),[])];case 4:return[2]}})});return L.apply(this,arguments)}function U(){return F.apply(this,arguments)}function F(){F=r(function(){var e,r,t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,A.keys()];case 1:e=n.sent(),r=Array.isArray(e)?e.filter(function(e){var r;return e===null||e===void 0?void 0:(r=e.startsWith)===null||r===void 0?void 0:r.call(e,"error_list:")}):[];return[4,Promise.all(r.map(function(e){return A.remove(e)}))];case 2:n.sent();return[3,4];case 3:t=n.sent();N.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return F.apply(this,arguments)}function k(e){var r=[],t=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,i=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var s=o.exec(e)||[],c=a.exec(e)||[],u=i.exec(e)||[];s.length&&n?r.push({file:n,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()}):c.length?r.push({file:c[1],position:"".concat(c[2],":").concat(c[3]),type:c[4]==="error"?"error":"warning",message:c[5].trim()}):u.length?r.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):t.push(e.trim())}}),r.length&&P(r),t.length&&y&&(N.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function j(e){try{var r=JSON.parse(e),t=[];r.forEach(function(e){var r=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,a=e.column,i=e.ruleId,s=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(o,":").concat(a),rule:i,message:s})})}),t.length&&P(t)}catch(r){k(e)}}function x(e){return q.apply(this,arguments)}function q(){q=r(function(e){var r,t,n,o,a,i,s,u,E;var l=arguments;return c(this,function(c){switch(c.label){case 0:r=l.length>1&&l[1]!==void 0?l[1]:j;t=new AbortController;f.on("SIGINT",function(){N.warning("Process interrupted. Terminating..."),t.abort(),f.exit()});c.label=1;case 1:c.trys.push([1,3,,4]);return[4,D(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=c.sent(),o=n.stdout,a=n.stderr;[o,a].forEach(function(e){return e&&r(e)});return[3,4];case 3:i=c.sent();s=i.stdout,u=i.stderr,E=i.message;[s,u].forEach(function(e){return e&&r(e)}),!u&&!s&&N.error("Command failed: ".concat(E));return[3,4];case 4:return[2]}})});return q.apply(this,arguments)}import*as Q from"node:fs";var H=function(e){return Q.existsSync(e)};import{GraphQLError as B}from"graphql";var Y={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function V(e){var r=e.message,t=e.status,n=t===void 0?Y.INTERNAL_SERVER_ERROR:t,o=e.type,a=o===void 0?"graphql":o;var i;var s=(i=r!==null&&r!==void 0?r:n.MESSAGE)!==null&&i!==void 0?i:"Internal server error";throw a==="graphql"?new B(s,{extensions:{code:n.CODE}}):new Error(s)}import W from"crypto-js";import J from"mongoose-aggregate-paginate-v2";import K from"mongoose-paginate-v2";import $ from"slugify";import{v4 as X}from"uuid";import{format as z}from"date-fns";function Z(){return z(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function ee(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function er(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function et(e){return new e.Schema({id:{type:String,default:X,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function en(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,a=e.standalone,i=a===void 0?!1:a;var s=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=s.virtual(r,t);n&&o.get(n)}),i||s.add(et(r)),s}function eo(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,a=o===void 0?!1:o,i=e.aggregate,s=i===void 0?!1:i,c=e.virtuals,u=c===void 0?[]:c,E=e.middlewares,l=E===void 0?[]:E;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var f=en({mongoose:r,schema:n,virtuals:u});return ee(f,[a&&K,s&&J]),er(f,l),r.model(t,f)}var ea=$.default||$;function ei(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;var t=r||{},o=t.lower,a=o===void 0?!0:o,s=t.locale,c=s===void 0?"vi":s,u=i(t,["lower","locale"]);return ea(e,n({lower:a,locale:c},u))}function es(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return W.SHA256(e).toString(W.enc.Hex).slice(0,r)}function ec(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;return a(n({},r,t&&{id:{$ne:t}}),{$or:[{slug:e},{slugHistory:e}]})}function eu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.isNew,t=r===void 0?!0:r,o=e.returnDateAs,i=o===void 0?"string":o;var s=i==="string"?Z():new Date;return a(n({},t&&{id:X()}),{isDel:!1,createdAt:s,updatedAt:s})}import eE from"node-fetch";import el from"node:fs";import ef from"node:path";import{dirname as ed}from"node:path";import eS from"node:process";import{fileURLToPath as ep}from"node:url";var eg=ep(import.meta.url),eh=ed(eg),eO=eS.env.INIT_CWD||eS.cwd();var ev=24*60*60*1e3;function em(e){return e?ef.join(eO,"node_modules",e,"package.json"):ef.join(eO,"package.json")}function eA(e){return ey.apply(this,arguments)}function ey(){ey=r(function(e){var r,t,n,o,a,i,s,u,E,l;var f=arguments;return c(this,function(c){switch(c.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:!1;t="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,A.get(t)];case 1:o=c.sent();return[4,A.get(n)];case 2:a=c.sent(),i=o&&Date.now()-o.timestamp<ev;if(!r&&i)return[2,(N.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];s={};(a===null||a===void 0?void 0:a.etag)&&(s["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(s["If-Modified-Since"]=a.lastModified);c.label=3;case 3:c.trys.push([3,8,,9]);N.info("Fetching latest version for ".concat(e,"..."));return[4,eE("https://registry.npmjs.org/".concat(e,"/latest"),{headers:s})];case 4:u=c.sent();if(u.status===304&&o)return[2,(N.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:E=c.sent().version;return[4,A.set(t,{version:E,timestamp:Date.now()})];case 6:c.sent();return[4,A.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(c.sent(),N.success("Cached latest version for ".concat(e,": ").concat(E)),E)];case 8:l=c.sent();if(N.error("Error fetching latest version for ".concat(e,": ").concat(l.message)),o)return[2,(N.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw l;case 9:return[2]}})});return ey.apply(this,arguments)}function eD(e){return eT.apply(this,arguments)}function eT(){eT=r(function(e){var r,t,n,o,a;var i=arguments;return c(this,function(s){switch(s.label){case 0:r=i.length>1&&i[1]!==void 0?i[1]:!0;s.label=1;case 1:s.trys.push([1,3,,4]);t=em(e);if(!el.existsSync(t))return[2,(N.info("".concat(e," is not installed.")),!0)];n=JSON.parse(el.readFileSync(t,"utf-8")).version;return[4,eA(e,r)];case 2:o=s.sent();return[2,(N.info("Installed version of ".concat(e,": ").concat(n)),N.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=s.sent();return[2,(N.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return eT.apply(this,arguments)}function eR(e){return e_.apply(this,arguments)}function e_(){e_=r(function(e){var r,o,i,s;return c(this,function(c){switch(c.label){case 0:c.trys.push([0,4,,5]);return[4,eA(e,!0)];case 1:r=c.sent(),o=em();if(!el.existsSync(o)){N.error("package.json not found. Cannot update ".concat(e));return[2]}i=JSON.parse(el.readFileSync(o,"utf-8"));i.dependencies=a(n({},i.dependencies),t({},e,r)),el.writeFileSync(o,JSON.stringify(i,null,2)),N.info("Updated ".concat(e," to version ").concat(r));return[4,x("npm i -f")];case 2:c.sent();return[4,x("npm run lint:fix")];case 3:c.sent(),N.success("".concat(e," updated successfully."));return[3,5];case 4:s=c.sent();throw N.error("Failed to update ".concat(e,": ").concat(s.message)),s;case 5:return[2]}})});return e_.apply(this,arguments)}function eC(e,r){try{var t=ef.join(e,"package.json");return el.existsSync(t)?JSON.parse(el.readFileSync(t,"utf-8")).name===r:!1}catch(e){return N.error("Error reading package.json: ".concat(e.message)),!1}}export{J as aggregatePaginate,U as clearAllErrorLists,N as commandLog,x as executeCommand,H as fileExists,eo as generateModel,en as generateSchema,es as generateShortId,ei as generateSlug,ec as generateSlugQuery,eA as getLatestPackageVersion,eu as getMongoGenericFields,w as getStoredErrorLists,v as initNodePersist,eC as isCurrentProject,eD as isPackageOutdated,K as mongoosePaginate,P as saveErrorListToStorage,O as storageDir,A as storageServer,V as throwResponse,eR as updatePackage};
@@ -0,0 +1,8 @@
1
+ export { isJson, regexSearchMapper, removeAccent } from './common.cjs';
2
+ export { deepMerge } from './config.cjs';
3
+ export { getMongoDateTime } from './datetime.cjs';
4
+ export { serializer } from './serializer.cjs';
5
+ export { storageClient } from './storage-client.cjs';
6
+ export { validate } from './validate.cjs';
7
+ import '../typescript/config.cjs';
8
+ import '../typescript/serializer.cjs';
@@ -0,0 +1,8 @@
1
+ export { isJson, regexSearchMapper, removeAccent } from './common.js';
2
+ export { deepMerge } from './config.js';
3
+ export { getMongoDateTime } from './datetime.js';
4
+ export { serializer } from './serializer.js';
5
+ export { storageClient } from './storage-client.js';
6
+ export { validate } from './validate.js';
7
+ import '../typescript/config.js';
8
+ import '../typescript/serializer.js';
@@ -0,0 +1,5 @@
1
+ import { T_ThrowResponseArgs } from '../typescript/log.cjs';
2
+
3
+ declare function throwResponse({ message, status, type, }: T_ThrowResponseArgs): never;
4
+
5
+ export { throwResponse };
@@ -0,0 +1,5 @@
1
+ import { T_ThrowResponseArgs } from '../typescript/log.js';
2
+
3
+ declare function throwResponse({ message, status, type, }: T_ThrowResponseArgs): never;
4
+
5
+ export { throwResponse };
@@ -1 +1 @@
1
- "use strict";function e(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function r(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){e(r,t,n[t])})}return r}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function n(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{t(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,r){if(e==null)return{};var t=u(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function u(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,u;for(u=0;u<n.length;u++){o=n[u];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function a(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}var i=Object.create;var l=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var s=function(e,r){for(var t in r)l(e,t,{get:r[t],enumerable:!0})},v=function(e,r,t,n){var o=true,u=false,i=undefined;if(r&&(typeof r==="undefined"?"undefined":a(r))=="object"||typeof r=="function")try{var g=function(){var o=v.value;!d.call(e,o)&&o!==t&&l(e,o,{get:function(){return r[o]},enumerable:!(n=c(r,o))||n.enumerable})};for(var s=f(r)[Symbol.iterator](),v;!(o=(v=s.next()).done);o=true)g()}catch(e){u=true;i=e}finally{try{if(!o&&s.return!=null){s.return()}}finally{if(u){throw i}}}return e};var y=function(e,r,t){return t=e!=null?i(g(e)):{},v(r||!e||!e.__esModule?l(t,"default",{value:e,enumerable:!0}):t,e)},p=function(e){return v(l({},"__esModule",{value:!0}),e)};var m={};s(m,{aggregatePaginate:function(){return O.default},generateModel:function(){return x},generateSchema:function(){return E},generateShortId:function(){return _},generateSlug:function(){return I},generateSlugQuery:function(){return k},getMongoGenericFields:function(){return A},mongoosePaginate:function(){return h.default}});module.exports=p(m);var b=y(require("crypto-js"),1),O=y(require("mongoose-aggregate-paginate-v2"),1),h=y(require("mongoose-paginate-v2"),1),S=y(require("slugify"),1),j=require("uuid");var w=require("date-fns");function P(){return(0,w.format)(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function M(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function q(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function D(e){return new e.Schema({id:{type:String,default:j.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function E(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,u=e.standalone,a=u===void 0?!1:u;var i=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=i.virtual(r,t);n&&o.get(n)}),a||i.add(D(r)),i}function x(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,u=o===void 0?!1:o,a=e.aggregate,i=a===void 0?!1:a,l=e.virtuals,c=l===void 0?[]:l,f=e.middlewares,g=f===void 0?[]:f;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var d=E({mongoose:r,schema:n,virtuals:c});return M(d,[u&&h.default,i&&O.default]),q(d,g),r.model(t,d)}var H=S.default.default||S.default;function I(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var n=t||{},u=n.lower,a=u===void 0?!0:u,i=n.locale,l=i===void 0?"vi":i,c=o(n,["lower","locale"]);return H(e,r({lower:a,locale:l},c))}function _(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return b.default.SHA256(e).toString(b.default.enc.Hex).slice(0,r)}function k(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;return n(r({},t,o&&{id:{$ne:o}}),{$or:[{slug:e},{slugHistory:e}]})}function A(e){var t=e.isNew,o=t===void 0?!0:t;return n(r({},o&&{id:(0,j.v4)()}),{isDel:!1,createdAt:P(),updatedAt:P()})}0&&(module.exports={aggregatePaginate:aggregatePaginate,generateModel:generateModel,generateSchema:generateSchema,generateShortId:generateShortId,generateSlug:generateSlug,generateSlugQuery:generateSlugQuery,getMongoGenericFields:getMongoGenericFields,mongoosePaginate:mongoosePaginate});
1
+ "use strict";function e(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function r(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){e(r,t,n[t])})}return r}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function n(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{t(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,r){if(e==null)return{};var t=u(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function u(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,u;for(u=0;u<n.length;u++){o=n[u];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}function a(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}var i=Object.create;var l=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var s=function(e,r){for(var t in r)l(e,t,{get:r[t],enumerable:!0})},v=function(e,r,t,n){var o=true,u=false,i=undefined;if(r&&(typeof r==="undefined"?"undefined":a(r))=="object"||typeof r=="function")try{var g=function(){var o=v.value;!d.call(e,o)&&o!==t&&l(e,o,{get:function(){return r[o]},enumerable:!(n=c(r,o))||n.enumerable})};for(var s=f(r)[Symbol.iterator](),v;!(o=(v=s.next()).done);o=true)g()}catch(e){u=true;i=e}finally{try{if(!o&&s.return!=null){s.return()}}finally{if(u){throw i}}}return e};var y=function(e,r,t){return t=e!=null?i(g(e)):{},v(r||!e||!e.__esModule?l(t,"default",{value:e,enumerable:!0}):t,e)},p=function(e){return v(l({},"__esModule",{value:!0}),e)};var m={};s(m,{aggregatePaginate:function(){return O.default},generateModel:function(){return x},generateSchema:function(){return E},generateShortId:function(){return I},generateSlug:function(){return A},generateSlugQuery:function(){return _},getMongoGenericFields:function(){return k},mongoosePaginate:function(){return h.default}});module.exports=p(m);var b=y(require("crypto-js"),1),O=y(require("mongoose-aggregate-paginate-v2"),1),h=y(require("mongoose-paginate-v2"),1),S=y(require("slugify"),1),w=require("uuid");var j=require("date-fns");function P(){return(0,j.format)(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function D(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function M(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function q(e){return new e.Schema({id:{type:String,default:w.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function E(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,u=e.standalone,a=u===void 0?!1:u;var i=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=i.virtual(r,t);n&&o.get(n)}),a||i.add(q(r)),i}function x(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,u=o===void 0?!1:o,a=e.aggregate,i=a===void 0?!1:a,l=e.virtuals,c=l===void 0?[]:l,f=e.middlewares,g=f===void 0?[]:f;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var d=E({mongoose:r,schema:n,virtuals:c});return D(d,[u&&h.default,i&&O.default]),M(d,g),r.model(t,d)}var H=S.default.default||S.default;function A(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var n=t||{},u=n.lower,a=u===void 0?!0:u,i=n.locale,l=i===void 0?"vi":i,c=o(n,["lower","locale"]);return H(e,r({lower:a,locale:l},c))}function I(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return b.default.SHA256(e).toString(b.default.enc.Hex).slice(0,r)}function _(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;return n(r({},t,o&&{id:{$ne:o}}),{$or:[{slug:e},{slugHistory:e}]})}function k(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.isNew,o=t===void 0?!0:t,u=e.returnDateAs,a=u===void 0?"string":u;var i=a==="string"?P():new Date;return n(r({},o&&{id:(0,w.v4)()}),{isDel:!1,createdAt:i,updatedAt:i})}0&&(module.exports={aggregatePaginate:aggregatePaginate,generateModel:generateModel,generateSchema:generateSchema,generateShortId:generateShortId,generateSlug:generateSlug,generateSlugQuery:generateSlugQuery,getMongoGenericFields:getMongoGenericFields,mongoosePaginate:mongoosePaginate});
@@ -0,0 +1,22 @@
1
+ export { default as aggregatePaginate } from 'mongoose-aggregate-paginate-v2';
2
+ export { default as mongoosePaginate } from 'mongoose-paginate-v2';
3
+ import { C_Document, I_GenerateSchemaOptions, T_MongooseShema, I_GenerateModelOptions, I_ExtendedModel, I_SlugifyOptions, T_FilterQuery, T_GenerateSlugQueryResponse } from '../typescript/mongoose.cjs';
4
+ import 'mongodb';
5
+ import 'mongoose';
6
+
7
+ declare function generateSchema<D extends Partial<C_Document>>({ mongoose, schema, virtuals, standalone, }: I_GenerateSchemaOptions<D>): T_MongooseShema<D>;
8
+ declare function generateModel<D extends Partial<C_Document>>({ mongoose, name, schema, pagination, aggregate, virtuals, middlewares, }: I_GenerateModelOptions<D>): I_ExtendedModel<D>;
9
+ declare function generateSlug(str?: string, options?: I_SlugifyOptions): string;
10
+ declare function generateShortId(uuid: string, length?: number): string;
11
+ declare function generateSlugQuery<D>(slug: string, filters?: T_FilterQuery<D>, id?: string): T_GenerateSlugQueryResponse<D>;
12
+ declare function getMongoGenericFields<T extends 'date' | 'string'>({ isNew, returnDateAs, }?: {
13
+ isNew?: boolean;
14
+ returnDateAs?: T;
15
+ }): {
16
+ id?: string;
17
+ isDel: boolean;
18
+ createdAt: T extends 'string' ? string : Date;
19
+ updatedAt: T extends 'string' ? string : Date;
20
+ };
21
+
22
+ export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getMongoGenericFields };
@@ -0,0 +1,22 @@
1
+ export { default as aggregatePaginate } from 'mongoose-aggregate-paginate-v2';
2
+ export { default as mongoosePaginate } from 'mongoose-paginate-v2';
3
+ import { C_Document, I_GenerateSchemaOptions, T_MongooseShema, I_GenerateModelOptions, I_ExtendedModel, I_SlugifyOptions, T_FilterQuery, T_GenerateSlugQueryResponse } from '../typescript/mongoose.js';
4
+ import 'mongodb';
5
+ import 'mongoose';
6
+
7
+ declare function generateSchema<D extends Partial<C_Document>>({ mongoose, schema, virtuals, standalone, }: I_GenerateSchemaOptions<D>): T_MongooseShema<D>;
8
+ declare function generateModel<D extends Partial<C_Document>>({ mongoose, name, schema, pagination, aggregate, virtuals, middlewares, }: I_GenerateModelOptions<D>): I_ExtendedModel<D>;
9
+ declare function generateSlug(str?: string, options?: I_SlugifyOptions): string;
10
+ declare function generateShortId(uuid: string, length?: number): string;
11
+ declare function generateSlugQuery<D>(slug: string, filters?: T_FilterQuery<D>, id?: string): T_GenerateSlugQueryResponse<D>;
12
+ declare function getMongoGenericFields<T extends 'date' | 'string'>({ isNew, returnDateAs, }?: {
13
+ isNew?: boolean;
14
+ returnDateAs?: T;
15
+ }): {
16
+ id?: string;
17
+ isDel: boolean;
18
+ createdAt: T extends 'string' ? string : Date;
19
+ updatedAt: T extends 'string' ? string : Date;
20
+ };
21
+
22
+ export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getMongoGenericFields };
@@ -1 +1 @@
1
- function e(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function r(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){e(r,t,n[t])})}return r}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function n(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{t(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,r){if(e==null)return{};var t=i(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function i(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,i;for(i=0;i<n.length;i++){o=n[i];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}import a from"crypto-js";import u from"mongoose-aggregate-paginate-v2";import c from"mongoose-paginate-v2";import f from"slugify";import{v4 as l}from"uuid";import{format as s}from"date-fns";function g(){return s(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function d(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function m(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function v(e){return new e.Schema({id:{type:String,default:l,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function p(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,i=e.standalone,a=i===void 0?!1:i;var u=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=u.virtual(r,t);n&&o.get(n)}),a||u.add(v(r)),u}function y(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,i=o===void 0?!1:o,a=e.aggregate,f=a===void 0?!1:a,l=e.virtuals,s=l===void 0?[]:l,g=e.middlewares,v=g===void 0?[]:g;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var y=p({mongoose:r,schema:n,virtuals:s});return d(y,[i&&c,f&&u]),m(y,v),r.model(t,y)}var O=f.default||f;function b(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var n=t||{},i=n.lower,a=i===void 0?!0:i,u=n.locale,c=u===void 0?"vi":u,f=o(n,["lower","locale"]);return O(e,r({lower:a,locale:c},f))}function h(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return a.SHA256(e).toString(a.enc.Hex).slice(0,r)}function w(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;return n(r({},t,o&&{id:{$ne:o}}),{$or:[{slug:e},{slugHistory:e}]})}function j(e){var t=e.isNew,o=t===void 0?!0:t;return n(r({},o&&{id:l()}),{isDel:!1,createdAt:g(),updatedAt:g()})}export{u as aggregatePaginate,y as generateModel,p as generateSchema,h as generateShortId,b as generateSlug,w as generateSlugQuery,j as getMongoGenericFields,c as mongoosePaginate};
1
+ function e(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function r(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){e(r,t,n[t])})}return r}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function n(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{t(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,r){if(e==null)return{};var t=i(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function i(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,i;for(i=0;i<n.length;i++){o=n[i];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}import a from"crypto-js";import u from"mongoose-aggregate-paginate-v2";import c from"mongoose-paginate-v2";import l from"slugify";import{v4 as f}from"uuid";import{format as s}from"date-fns";function g(){return s(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function v(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function d(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function m(e){return new e.Schema({id:{type:String,default:f,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function p(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,i=e.standalone,a=i===void 0?!1:i;var u=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=u.virtual(r,t);n&&o.get(n)}),a||u.add(m(r)),u}function y(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,i=o===void 0?!1:o,a=e.aggregate,l=a===void 0?!1:a,f=e.virtuals,s=f===void 0?[]:f,g=e.middlewares,m=g===void 0?[]:g;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var y=p({mongoose:r,schema:n,virtuals:s});return v(y,[i&&c,l&&u]),d(y,m),r.model(t,y)}var O=l.default||l;function b(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var n=t||{},i=n.lower,a=i===void 0?!0:i,u=n.locale,c=u===void 0?"vi":u,l=o(n,["lower","locale"]);return O(e,r({lower:a,locale:c},l))}function h(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return a.SHA256(e).toString(a.enc.Hex).slice(0,r)}function w(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;return n(r({},t,o&&{id:{$ne:o}}),{$or:[{slug:e},{slugHistory:e}]})}function j(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.isNew,o=t===void 0?!0:t,i=e.returnDateAs,a=i===void 0?"string":i;var u=a==="string"?g():new Date;return n(r({},o&&{id:f()}),{isDel:!1,createdAt:u,updatedAt:u})}export{u as aggregatePaginate,y as generateModel,p as generateSchema,h as generateShortId,b as generateSlug,w as generateSlugQuery,j as getMongoGenericFields,c as mongoosePaginate};
@@ -0,0 +1,6 @@
1
+ declare function getLatestPackageVersion(packageName: string, forceRefresh?: boolean): Promise<string>;
2
+ declare function isPackageOutdated(packageName: string, forceRefresh?: boolean): Promise<boolean>;
3
+ declare function updatePackage(packageName: string): Promise<void>;
4
+ declare function isCurrentProject(WORKING_DIRECTORY: string, PACKAGE_NAME: string): boolean;
5
+
6
+ export { getLatestPackageVersion, isCurrentProject, isPackageOutdated, updatePackage };
@@ -0,0 +1,6 @@
1
+ declare function getLatestPackageVersion(packageName: string, forceRefresh?: boolean): Promise<string>;
2
+ declare function isPackageOutdated(packageName: string, forceRefresh?: boolean): Promise<boolean>;
3
+ declare function updatePackage(packageName: string): Promise<void>;
4
+ declare function isCurrentProject(WORKING_DIRECTORY: string, PACKAGE_NAME: string): boolean;
5
+
6
+ export { getLatestPackageVersion, isCurrentProject, isPackageOutdated, updatePackage };
@@ -0,0 +1,5 @@
1
+ import { I_Serializer } from '../typescript/serializer.cjs';
2
+
3
+ declare const serializer: I_Serializer<unknown>;
4
+
5
+ export { serializer };
@@ -0,0 +1,5 @@
1
+ import { I_Serializer } from '../typescript/serializer.js';
2
+
3
+ declare const serializer: I_Serializer<unknown>;
4
+
5
+ export { serializer };
@@ -0,0 +1,8 @@
1
+ declare const storageClient: {
2
+ get<T = unknown>(key: string): Promise<T | null>;
3
+ set<T = unknown>(key: string, value: T): Promise<void>;
4
+ remove(key: string): Promise<void>;
5
+ keys(): Promise<string[]>;
6
+ };
7
+
8
+ export { storageClient };
@@ -0,0 +1,8 @@
1
+ declare const storageClient: {
2
+ get<T = unknown>(key: string): Promise<T | null>;
3
+ set<T = unknown>(key: string, value: T): Promise<void>;
4
+ remove(key: string): Promise<void>;
5
+ keys(): Promise<string[]>;
6
+ };
7
+
8
+ export { storageClient };
@@ -0,0 +1,11 @@
1
+ declare const storageDir: string;
2
+ declare function initNodePersist(): Promise<void>;
3
+ declare const storageServer: {
4
+ get<T = unknown>(key: string): Promise<T | null>;
5
+ set<T = unknown>(key: string, value: T): Promise<void>;
6
+ remove(key: string): Promise<void>;
7
+ keys(): Promise<string[]>;
8
+ getLogLink(key: string): Promise<string | null>;
9
+ };
10
+
11
+ export { initNodePersist, storageDir, storageServer };
@@ -0,0 +1,11 @@
1
+ declare const storageDir: string;
2
+ declare function initNodePersist(): Promise<void>;
3
+ declare const storageServer: {
4
+ get<T = unknown>(key: string): Promise<T | null>;
5
+ set<T = unknown>(key: string, value: T): Promise<void>;
6
+ remove(key: string): Promise<void>;
7
+ keys(): Promise<string[]>;
8
+ getLogLink(key: string): Promise<string | null>;
9
+ };
10
+
11
+ export { initNodePersist, storageDir, storageServer };
@@ -0,0 +1,14 @@
1
+ declare const validate: {
2
+ common: {
3
+ isEmpty(value: unknown): boolean;
4
+ isEmptyValidator<T>(): (this: T, value: unknown) => Promise<boolean>;
5
+ isUniqueValidator<T extends {
6
+ constructor: {
7
+ findOne: (query: Record<string, unknown>) => Promise<unknown>;
8
+ };
9
+ }>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
10
+ matchesRegexValidator(regexArray: RegExp[]): (value: string) => Promise<boolean>;
11
+ };
12
+ };
13
+
14
+ export { validate };