@cyberskill/shared 1.5.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands.cjs +2 -0
- package/dist/commands.d.cts +1 -0
- package/dist/commands.d.ts +1 -0
- package/dist/commands.js +2 -0
- package/dist/components/react/index.cjs +1 -0
- package/dist/components/react/index.d.cts +2 -0
- package/dist/components/react/index.d.ts +2 -0
- package/dist/components/react/index.js +1 -0
- package/dist/components/react/loading/index.cjs +1 -0
- package/dist/components/react/loading/index.d.cts +11 -0
- package/dist/components/react/loading/index.d.ts +11 -0
- package/dist/components/react/loading/index.js +1 -0
- package/dist/components/react/loading/loading.module.d.cts +2 -0
- package/dist/components/react/loading/loading.module.d.ts +2 -0
- package/dist/components/react/loading/loading.module.scss +137 -0
- package/dist/configs/commitlint/commitlint.base.cjs +1 -0
- package/dist/configs/commitlint/commitlint.base.d.cts +5 -0
- package/dist/configs/commitlint/commitlint.base.d.ts +5 -0
- package/dist/configs/commitlint/commitlint.base.js +1 -0
- package/dist/configs/eslint/eslint.base.cjs +1 -0
- package/dist/configs/eslint/eslint.base.d.cts +1154 -0
- package/dist/configs/eslint/eslint.base.d.ts +1154 -0
- package/dist/configs/eslint/eslint.base.js +1 -0
- package/dist/configs/eslint/eslint.nestjs.cjs +1 -0
- package/dist/configs/eslint/eslint.nestjs.d.cts +1156 -0
- package/dist/configs/eslint/eslint.nestjs.d.ts +1156 -0
- package/dist/configs/eslint/eslint.nestjs.js +1 -0
- package/dist/configs/eslint/eslint.nextjs.cjs +1 -0
- package/dist/configs/eslint/eslint.nextjs.d.cts +1156 -0
- package/dist/configs/eslint/eslint.nextjs.d.ts +1156 -0
- package/dist/configs/eslint/eslint.nextjs.js +1 -0
- package/dist/configs/eslint/eslint.nodejs.cjs +1 -0
- package/dist/configs/eslint/eslint.nodejs.d.cts +1156 -0
- package/dist/configs/eslint/eslint.nodejs.d.ts +1156 -0
- package/dist/configs/eslint/eslint.nodejs.js +1 -0
- package/dist/configs/eslint/vite-react.cjs +1 -0
- package/dist/configs/eslint/vite-react.d.cts +1157 -0
- package/dist/configs/eslint/vite-react.d.ts +1157 -0
- package/dist/configs/eslint/vite-react.js +1 -0
- package/dist/configs/graphql/graphql-codegen.cjs +1 -0
- package/dist/configs/graphql/graphql-codegen.d.cts +8 -0
- package/dist/configs/graphql/graphql-codegen.d.ts +8 -0
- package/dist/configs/graphql/graphql-codegen.js +1 -0
- package/dist/configs/graphql/index.cjs +1 -0
- package/dist/configs/graphql/index.d.cts +5 -0
- package/dist/configs/graphql/index.d.ts +5 -0
- package/dist/configs/graphql/index.js +1 -0
- package/dist/configs/i18n/react/i18next.cjs +1 -0
- package/dist/configs/i18n/react/i18next.d.cts +6 -0
- package/dist/configs/i18n/react/i18next.d.ts +6 -0
- package/dist/configs/i18n/react/i18next.js +1 -0
- package/dist/configs/i18n/react/index.cjs +1 -0
- package/dist/configs/i18n/react/index.d.cts +2 -0
- package/dist/configs/i18n/react/index.d.ts +2 -0
- package/dist/configs/i18n/react/index.js +1 -0
- package/dist/configs/index.cjs +1 -0
- package/dist/configs/index.d.cts +9 -0
- package/dist/configs/index.d.ts +9 -0
- package/dist/configs/index.js +1 -0
- package/dist/configs/vitest/react/e2e.cjs +1 -0
- package/dist/configs/vitest/react/e2e.d.cts +6 -0
- package/dist/configs/vitest/react/e2e.d.ts +6 -0
- package/dist/configs/vitest/react/e2e.js +1 -0
- package/dist/configs/vitest/react/unit.cjs +1 -0
- package/dist/configs/vitest/react/unit.d.cts +6 -0
- package/dist/configs/vitest/react/unit.d.ts +6 -0
- package/dist/configs/vitest/react/unit.js +1 -0
- package/dist/configs/vitest/react/unit.setup.cjs +1 -0
- package/dist/configs/vitest/react/unit.setup.d.cts +2 -0
- package/dist/configs/vitest/react/unit.setup.d.ts +2 -0
- package/dist/configs/vitest/react/unit.setup.js +1 -0
- package/dist/constants/dirname.cjs +1 -0
- package/dist/constants/dirname.d.cts +3 -0
- package/dist/constants/dirname.d.ts +3 -0
- package/dist/constants/dirname.js +1 -0
- package/dist/constants/index.cjs +1 -0
- package/dist/constants/index.d.cts +2 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/response-status.cjs +1 -0
- package/dist/constants/response-status.d.cts +252 -0
- package/dist/constants/response-status.d.ts +252 -0
- package/dist/constants/response-status.js +1 -0
- package/dist/contexts/react/index.cjs +1 -0
- package/dist/contexts/react/index.d.cts +4 -0
- package/dist/contexts/react/index.d.ts +4 -0
- package/dist/contexts/react/index.js +1 -0
- package/dist/contexts/react/loading.cjs +1 -0
- package/dist/contexts/react/loading.d.cts +7 -0
- package/dist/contexts/react/loading.d.ts +7 -0
- package/dist/contexts/react/loading.js +1 -0
- package/dist/controllers/index.cjs +1 -0
- package/dist/controllers/index.d.cts +5 -0
- package/dist/controllers/index.d.ts +5 -0
- package/dist/controllers/index.js +1 -0
- package/dist/controllers/migration.cjs +1 -0
- package/dist/controllers/migration.d.cts +55 -0
- package/dist/controllers/migration.d.ts +55 -0
- package/dist/controllers/migration.js +1 -0
- package/dist/controllers/mongoose.cjs +1 -0
- package/dist/controllers/mongoose.d.cts +25 -0
- package/dist/controllers/mongoose.d.ts +25 -0
- package/dist/controllers/mongoose.js +1 -0
- package/dist/hooks/react/index.cjs +1 -0
- package/dist/hooks/react/index.d.cts +6 -0
- package/dist/hooks/react/index.d.ts +6 -0
- package/dist/hooks/react/index.js +1 -0
- package/dist/hooks/react/useLoading.cjs +1 -0
- package/dist/hooks/react/useLoading.d.cts +7 -0
- package/dist/hooks/react/useLoading.d.ts +7 -0
- package/dist/hooks/react/useLoading.js +1 -0
- package/dist/hooks/react/useLocalStorage.cjs +1 -0
- package/dist/hooks/react/useLocalStorage.d.cts +5 -0
- package/dist/hooks/react/useLocalStorage.d.ts +5 -0
- package/dist/hooks/react/useLocalStorage.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1 -0
- package/dist/providers/react/apollo-client.cjs +1 -0
- package/dist/providers/react/apollo-client.d.cts +11 -0
- package/dist/providers/react/apollo-client.d.ts +11 -0
- package/dist/providers/react/apollo-client.js +1 -0
- package/dist/providers/react/index.cjs +1 -0
- package/dist/providers/react/index.d.cts +6 -0
- package/dist/providers/react/index.d.ts +6 -0
- package/dist/providers/react/index.js +1 -0
- package/dist/providers/react/loading.cjs +1 -0
- package/dist/providers/react/loading.d.cts +10 -0
- package/dist/providers/react/loading.d.ts +10 -0
- package/dist/providers/react/loading.js +1 -0
- package/dist/typescript/command.cjs +1 -0
- package/dist/typescript/command.d.cts +41 -0
- package/dist/typescript/command.d.ts +41 -0
- package/dist/typescript/command.js +1 -0
- package/dist/typescript/config.cjs +1 -0
- package/dist/typescript/config.d.cts +5 -0
- package/dist/typescript/config.d.ts +5 -0
- package/dist/typescript/config.js +0 -0
- package/dist/typescript/index.cjs +1 -0
- package/dist/typescript/index.d.cts +10 -0
- package/dist/typescript/index.d.ts +10 -0
- package/dist/typescript/index.js +1 -0
- package/dist/typescript/log.cjs +1 -0
- package/dist/typescript/log.d.cts +10 -0
- package/dist/typescript/log.d.ts +10 -0
- package/dist/typescript/log.js +0 -0
- package/dist/typescript/mongoose.cjs +1 -0
- package/dist/typescript/mongoose.d.cts +163 -0
- package/dist/typescript/mongoose.d.ts +163 -0
- package/dist/typescript/mongoose.js +1 -0
- package/dist/typescript/react.cjs +1 -0
- package/dist/typescript/react.d.cts +26 -0
- package/dist/typescript/react.d.ts +26 -0
- package/dist/typescript/react.js +0 -0
- package/dist/typescript/serializer.cjs +1 -0
- package/dist/typescript/serializer.d.cts +6 -0
- package/dist/typescript/serializer.d.ts +6 -0
- package/dist/typescript/serializer.js +0 -0
- package/dist/utils/command-error.cjs +1 -0
- package/dist/utils/command-error.d.cts +18 -0
- package/dist/utils/command-error.d.ts +18 -0
- package/dist/utils/command-error.js +1 -0
- package/dist/utils/command-log.cjs +1 -0
- package/dist/utils/command-log.d.cts +3 -0
- package/dist/utils/command-log.d.ts +3 -0
- package/dist/utils/command-log.js +1 -0
- package/dist/utils/command-spinner.cjs +1 -0
- package/dist/utils/command-spinner.d.cts +11 -0
- package/dist/utils/command-spinner.d.ts +11 -0
- package/dist/utils/command-spinner.js +1 -0
- package/dist/utils/command.cjs +1 -0
- package/dist/utils/command.d.cts +5 -0
- package/dist/utils/command.d.ts +5 -0
- package/dist/utils/command.js +1 -0
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.cts +25 -0
- package/dist/utils/index.d.ts +25 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/local-storage.cjs +1 -0
- package/dist/utils/local-storage.d.cts +50 -0
- package/dist/utils/local-storage.d.ts +50 -0
- package/dist/utils/local-storage.js +1 -0
- package/dist/utils/log.cjs +1 -0
- package/dist/utils/log.d.cts +5 -0
- package/dist/utils/log.d.ts +5 -0
- package/dist/utils/log.js +1 -0
- package/dist/utils/mongoose.cjs +1 -0
- package/dist/utils/mongoose.d.cts +34 -0
- package/dist/utils/mongoose.d.ts +34 -0
- package/dist/utils/mongoose.js +1 -0
- package/dist/utils/npm-package.cjs +1 -0
- package/dist/utils/npm-package.d.cts +15 -0
- package/dist/utils/npm-package.d.ts +15 -0
- package/dist/utils/npm-package.js +1 -0
- package/dist/utils/serializer.cjs +1 -0
- package/dist/utils/serializer.d.cts +7 -0
- package/dist/utils/serializer.d.ts +7 -0
- package/dist/utils/serializer.js +1 -0
- package/dist/utils/validate.cjs +1 -0
- package/dist/utils/validate.d.cts +33 -0
- package/dist/utils/validate.d.ts +33 -0
- package/dist/utils/validate.js +1 -0
- package/package.json +2 -12
- package/dist/.gitignore +0 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare const localStorage: {
|
|
2
|
+
/**
|
|
3
|
+
* Get the value of a key.
|
|
4
|
+
* @param key The key to retrieve.
|
|
5
|
+
* @returns A promise that resolves to the value associated with the key, or `null` if the key doesn't exist.
|
|
6
|
+
*/
|
|
7
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
8
|
+
/**
|
|
9
|
+
* Set the value for a key.
|
|
10
|
+
* @param key The key to set.
|
|
11
|
+
* @param value The value to store. Can be any serializable type.
|
|
12
|
+
* @returns A promise that resolves once the value is stored.
|
|
13
|
+
*/
|
|
14
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Remove the value associated with a key.
|
|
17
|
+
* @param key The key to remove.
|
|
18
|
+
* @returns A promise that resolves once the key is removed.
|
|
19
|
+
*/
|
|
20
|
+
remove(key: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Clear all keys and values in the storage.
|
|
23
|
+
* @returns A promise that resolves once the storage is cleared.
|
|
24
|
+
*/
|
|
25
|
+
clear(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the name of the key at a specific index.
|
|
28
|
+
* @param index The index of the key.
|
|
29
|
+
* @returns A promise that resolves to the key name or `null` if the index is out of bounds.
|
|
30
|
+
*/
|
|
31
|
+
key(index: number): Promise<string | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Get all keys in the storage.
|
|
34
|
+
* @returns A promise that resolves to an array of all keys.
|
|
35
|
+
*/
|
|
36
|
+
keys(): Promise<string[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Get the number of items in the storage.
|
|
39
|
+
* @returns A promise that resolves to the number of keys stored.
|
|
40
|
+
*/
|
|
41
|
+
length(): Promise<number>;
|
|
42
|
+
/**
|
|
43
|
+
* Iterates over all key-value pairs in the storage.
|
|
44
|
+
* @param iteratee A callback function that receives the value, key, and iteration number.
|
|
45
|
+
* @returns A promise that resolves once iteration is complete.
|
|
46
|
+
*/
|
|
47
|
+
iterate<T = unknown>(iteratee: (value: T, key: string, iterationNumber: number) => void): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { localStorage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r,e,t,n,s,u,o){try{var c=r[u](o);var a=c.value}catch(r){t(r);return}if(c.done){e(a)}else{Promise.resolve(a).then(n,s)}}function e(e){return function(){var t=this,n=arguments;return new Promise(function(s,u){var o=e.apply(t,n);function c(e){r(o,s,u,c,a,"next",e)}function a(e){r(o,s,u,c,a,"throw",e)}c(undefined)})}}function t(r,e){var t,n,s,u,o={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]};return u={next:c(0),"throw":c(1),"return":c(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(r){return function(e){return a([r,e])}}function a(u){if(t)throw new TypeError("Generator is already executing.");while(o)try{if(t=1,n&&(s=u[0]&2?n["return"]:u[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;if(n=0,s)u=[u[0]&2,s.value];switch(u[0]){case 0:case 1:s=u;break;case 4:o.label++;return{value:u[1],done:false};case 5:o.label++;n=u[1];u=[0];continue;case 7:u=o.ops.pop();o.trys.pop();continue;default:if(!(s=o.trys,s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){o=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){o.label=u[1];break}if(u[0]===6&&o.label<s[1]){o.label=s[1];s=u;break}if(s&&o.label<s[2]){o.label=s[2];o.ops.push(u);break}if(s[2])o.ops.pop();o.trys.pop();continue}u=e.call(r,o)}catch(r){u=[6,r];n=0}finally{t=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}import n from"localforage";var s={get:function r(r){return e(function(){var e;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.getItem(r)];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error('Error getting key "'.concat(r,'":'),e),null)];case 3:return[2]}})})()},set:function r(r,s){return e(function(){var e;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.setItem(r,s)];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error('Error setting key "'.concat(r,'":'),e);return[3,3];case 3:return[2]}})})()},remove:function r(r){return e(function(){var e;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.removeItem(r)];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error('Error removing key "'.concat(r,'":'),e);return[3,3];case 3:return[2]}})})()},clear:function r(){return e(function(){var r;return t(this,function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,n.clear()];case 1:e.sent();return[3,3];case 2:r=e.sent();console.error("Error clearing storage:",r);return[3,3];case 3:return[2]}})})()},key:function r(r){return e(function(){var e;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.key(r)];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error("Error getting key at index ".concat(r,":"),e),null)];case 3:return[2]}})})()},keys:function r(){return e(function(){var r;return t(this,function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,n.keys()];case 1:return[2,e.sent()];case 2:r=e.sent();return[2,(console.error("Error getting keys:",r),[])];case 3:return[2]}})})()},length:function r(){return e(function(){var r;return t(this,function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,n.length()];case 1:return[2,e.sent()];case 2:r=e.sent();return[2,(console.error("Error getting storage length:",r),0)];case 3:return[2]}})})()},iterate:function r(r){return e(function(){var e;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.iterate(r)];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error("Error iterating storage:",e);return[3,3];case 3:return[2]}})})()}};export{s as localStorage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function E(E){"@swc/helpers - typeof";return E&&typeof Symbol!=="undefined"&&E.constructor===Symbol?"symbol":typeof E}var e=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var n=function(E,t){for(var S in t)e(E,S,{get:t[S],enumerable:!0})},o=function(n,o,O,A){var a=true,i=false,T=undefined;if(o&&(typeof o==="undefined"?"undefined":E(o))=="object"||typeof o=="function")try{var R=function(){var E=u.value;!r.call(n,E)&&E!==O&&e(n,E,{get:function(){return o[E]},enumerable:!(A=t(o,E))||A.enumerable})};for(var D=S(o)[Symbol.iterator](),u;!(a=(u=D.next()).done);a=true)R()}catch(E){i=true;T=E}finally{try{if(!a&&D.return!=null){D.return()}}finally{if(i){throw T}}}return n};var O=function(E){return o(e({},"__esModule",{value:!0}),E)};var A={};n(A,{throwResponse:function(){return _}});module.exports=O(A);var a=function(){return(typeof document==="undefined"?"undefined":E(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},i=a();var T=require("graphql");var R=require("path"),D=require("url"),u=(0,D.fileURLToPath)(i),s=(0,R.dirname)(u);var C={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 _(E){var e=E.message,t=E.status,S=t===void 0?C.INTERNAL_SERVER_ERROR:t,r=E.type,n=r===void 0?"graphql":r;var o;var O=(o=e!==null&&e!==void 0?e:S.MESSAGE)!==null&&o!==void 0?o:"Internal server error";throw n==="graphql"?new T.GraphQLError(O,{extensions:{code:S.CODE}}):new Error(O)}0&&(module.exports={throwResponse:throwResponse});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GraphQLError as E}from"graphql";import{dirname as e}from"node:path";import{fileURLToPath as S}from"node:url";var O=S(import.meta.url),t=e(O);var A={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 o(e){var S=e.message,O=e.status,t=O===void 0?A.INTERNAL_SERVER_ERROR:O,o=e.type,r=o===void 0?"graphql":o;var T;var D=(T=S!==null&&S!==void 0?S:t.MESSAGE)!==null&&T!==void 0?T:"Internal server error";throw r==="graphql"?new E(D,{extensions:{code:t.CODE}}):new Error(D)}export{o as throwResponse};
|
|
@@ -0,0 +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 p=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)},y=function(e){return v(l({},"__esModule",{value:!0}),e)};var m={};s(m,{aggregatePaginate:function(){return O.default},generateModel:function(){return E},generateSchema:function(){return D},generateShortId:function(){return I},generateSlug:function(){return M},generateSlugQuery:function(){return _},mongoosePaginate:function(){return h.default}});module.exports=y(m);var b=p(require("crypto-js"),1),O=p(require("mongoose-aggregate-paginate-v2"),1),h=p(require("mongoose-paginate-v2"),1),j=p(require("slugify"),1),S=require("uuid");function w(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function P(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:S.v4,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function D(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 E(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=D({mongoose:r,schema:n,virtuals:c});return w(d,[u&&h.default,i&&O.default]),P(d,g),r.model(t,d)}var x=j.default.default||j.default;function M(){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 x(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}]})}0&&(module.exports={aggregatePaginate:aggregatePaginate,generateModel:generateModel,generateSchema:generateSchema,generateShortId:generateShortId,generateSlug:generateSlug,generateSlugQuery:generateSlugQuery,mongoosePaginate:mongoosePaginate});
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Generate a mongoose schema with optional virtuals and generic fields.
|
|
9
|
+
* @param options - Schema generation options.
|
|
10
|
+
* @param options.mongoose - The mongoose instance.
|
|
11
|
+
* @param options.schema - The schema definition.
|
|
12
|
+
* @param options.virtuals - List of virtual fields.
|
|
13
|
+
* @param options.standalone - Whether to include generic fields.
|
|
14
|
+
* @returns Enhanced schema.
|
|
15
|
+
*/
|
|
16
|
+
declare function generateSchema<D extends Partial<C_Document>>({ mongoose, schema, virtuals, standalone, }: I_GenerateSchemaOptions<D>): T_MongooseShema<D>;
|
|
17
|
+
/**
|
|
18
|
+
* Generate a mongoose model with optional pagination, aggregation, and middleware.
|
|
19
|
+
* @param options - Model generation options.
|
|
20
|
+
* @param options.mongoose - The mongoose instance.
|
|
21
|
+
* @param options.name - The name of the model.
|
|
22
|
+
* @param options.schema - The schema definition.
|
|
23
|
+
* @param options.pagination - Whether to enable pagination plugin.
|
|
24
|
+
* @param options.aggregate - Whether to enable aggregate pagination plugin.
|
|
25
|
+
* @param options.virtuals - List of virtual fields.
|
|
26
|
+
* @param options.middlewares - Middleware functions to add.
|
|
27
|
+
* @returns Mongoose model.
|
|
28
|
+
*/
|
|
29
|
+
declare function generateModel<D extends Partial<C_Document>>({ mongoose, name, schema, pagination, aggregate, virtuals, middlewares, }: I_GenerateModelOptions<D>): I_ExtendedModel<D>;
|
|
30
|
+
declare function generateSlug(str?: string, options?: I_SlugifyOptions): string;
|
|
31
|
+
declare function generateShortId(uuid: string, length?: number): string;
|
|
32
|
+
declare function generateSlugQuery<D>(slug: string, filters?: T_FilterQuery<D>, id?: string): T_GenerateSlugQueryResponse<D>;
|
|
33
|
+
|
|
34
|
+
export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery };
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Generate a mongoose schema with optional virtuals and generic fields.
|
|
9
|
+
* @param options - Schema generation options.
|
|
10
|
+
* @param options.mongoose - The mongoose instance.
|
|
11
|
+
* @param options.schema - The schema definition.
|
|
12
|
+
* @param options.virtuals - List of virtual fields.
|
|
13
|
+
* @param options.standalone - Whether to include generic fields.
|
|
14
|
+
* @returns Enhanced schema.
|
|
15
|
+
*/
|
|
16
|
+
declare function generateSchema<D extends Partial<C_Document>>({ mongoose, schema, virtuals, standalone, }: I_GenerateSchemaOptions<D>): T_MongooseShema<D>;
|
|
17
|
+
/**
|
|
18
|
+
* Generate a mongoose model with optional pagination, aggregation, and middleware.
|
|
19
|
+
* @param options - Model generation options.
|
|
20
|
+
* @param options.mongoose - The mongoose instance.
|
|
21
|
+
* @param options.name - The name of the model.
|
|
22
|
+
* @param options.schema - The schema definition.
|
|
23
|
+
* @param options.pagination - Whether to enable pagination plugin.
|
|
24
|
+
* @param options.aggregate - Whether to enable aggregate pagination plugin.
|
|
25
|
+
* @param options.virtuals - List of virtual fields.
|
|
26
|
+
* @param options.middlewares - Middleware functions to add.
|
|
27
|
+
* @returns Mongoose model.
|
|
28
|
+
*/
|
|
29
|
+
declare function generateModel<D extends Partial<C_Document>>({ mongoose, name, schema, pagination, aggregate, virtuals, middlewares, }: I_GenerateModelOptions<D>): I_ExtendedModel<D>;
|
|
30
|
+
declare function generateSlug(str?: string, options?: I_SlugifyOptions): string;
|
|
31
|
+
declare function generateShortId(uuid: string, length?: number): string;
|
|
32
|
+
declare function generateSlugQuery<D>(slug: string, filters?: T_FilterQuery<D>, id?: string): T_GenerateSlugQueryResponse<D>;
|
|
33
|
+
|
|
34
|
+
export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery };
|
|
@@ -0,0 +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 l from"slugify";import{v4 as f}from"uuid";function s(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function g(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: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(v(r)),u}function m(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,v=f===void 0?[]:f,m=e.middlewares,d=m===void 0?[]:m;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:v});return s(y,[i&&c,l&&u]),g(y,d),r.model(t,y)}var d=l.default||l;function y(){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 d(e,r({lower:a,locale:c},l))}function O(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 b(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}]})}export{u as aggregatePaginate,m as generateModel,p as generateSchema,O as generateShortId,y as generateSlug,b as generateSlugQuery,c as mongoosePaginate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e,t,r,n,o,a,c){try{var s=e[a](c);var i=s.value}catch(e){r(e);return}if(s.done){t(i)}else{Promise.resolve(i).then(n,o)}}function t(t){return function(){var r=this,n=arguments;return new Promise(function(o,a){var c=t.apply(r,n);function s(t){e(c,o,a,s,i,"next",t)}function i(t){e(c,o,a,s,i,"throw",t)}s(undefined)})}}function r(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function n(e){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){r(e,t,n[t])})}return e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function a(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{o(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function c(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function s(e,t){var r,n,o,a,c={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(t){return i([e,t])}}function i(a){if(r)throw new TypeError("Generator is already executing.");while(c)try{if(r=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:c.label++;return{value:a[1],done:false};case 5:c.label++;n=a[1];a=[0];continue;case 7:a=c.ops.pop();c.trys.pop();continue;default:if(!(o=c.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){c=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(a[0]===6&&c.label<o[1]){c.label=o[1];o=a;break}if(o&&c.label<o[2]){c.label=o[2];c.ops.push(a);break}if(o[2])c.ops.pop();c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e];n=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var i=Object.create;var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var h=function(e,t){for(var r in t)u(e,r,{get:t[r],enumerable:!0})},g=function(e,t,r,n){var o=true,a=false,s=undefined;if(t&&(typeof t==="undefined"?"undefined":c(t))=="object"||typeof t=="function")try{var i=function(){var o=h.value;!d.call(e,o)&&o!==r&&u(e,o,{get:function(){return t[o]},enumerable:!(n=l(t,o))||n.enumerable})};for(var p=f(t)[Symbol.iterator](),h;!(o=(h=p.next()).done);o=true)i()}catch(e){a=true;s=e}finally{try{if(!o&&p.return!=null){p.return()}}finally{if(a){throw s}}}return e};var v=function(e,t,r){return r=e!=null?i(p(e)):{},g(t||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)},y=function(e){return g(u({},"__esModule",{value:!0}),e)};var b={};h(b,{getLatestPackageVersion:function(){return B},isPackageOutdated:function(){return K},updatePackage:function(){return R}});module.exports=y(b);var m=v(require("node-fetch"),1),w=v(require("fs"),1),O=v(require("path"),1),k=v(require("process"),1);var P=v(require("chalk"),1),j=require("child_process"),S=v(require("process"),1),x=v(require("util"),1);var E=v(require("localforage"),1),D={get:function e(e){return t(function(){var t;return s(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,E.default.getItem(e)];case 1:return[2,r.sent()];case 2:t=r.sent();return[2,(console.error('Error getting key "'.concat(e,'":'),t),null)];case 3:return[2]}})})()},set:function e(e,r){return t(function(){var t;return s(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,E.default.setItem(e,r)];case 1:n.sent();return[3,3];case 2:t=n.sent();console.error('Error setting key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},remove:function e(e){return t(function(){var t;return s(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,E.default.removeItem(e)];case 1:r.sent();return[3,3];case 2:t=r.sent();console.error('Error removing key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},clear:function e(){return t(function(){var e;return s(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,E.default.clear()];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error("Error clearing storage:",e);return[3,3];case 3:return[2]}})})()},key:function e(e){return t(function(){var t;return s(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,E.default.key(e)];case 1:return[2,r.sent()];case 2:t=r.sent();return[2,(console.error("Error getting key at index ".concat(e,":"),t),null)];case 3:return[2]}})})()},keys:function e(){return t(function(){var e;return s(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,E.default.keys()];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error("Error getting keys:",e),[])];case 3:return[2]}})})()},length:function e(){return t(function(){var e;return s(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,E.default.length()];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error("Error getting storage length:",e),0)];case 3:return[2]}})})()},iterate:function e(e){return t(function(){var t;return s(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,E.default.iterate(e)];case 1:r.sent();return[3,3];case 2:t=r.sent();console.error("Error iterating storage:",t);return[3,3];case 3:return[2]}})})()}};var F=function(e){return"error_list:".concat(e)},I=24*60*60*1e3;function q(e){return _.apply(this,arguments)}function _(){_=t(function(e){var t,r,n;return s(this,function(o){switch(o.label){case 0:if(!e.length)return[2];t=Date.now(),r=F(t);o.label=1;case 1:o.trys.push([1,3,,4]);return[4,D.set(r,{errors:e,timestamp:t})];case 2:o.sent(),console.log("✅ Saved ".concat(e.length," errors to storage with key: ").concat(r));return[3,4];case 3:n=o.sent();console.error("❌ Failed to save errors: ".concat(n.message));return[3,4];case 4:return[2]}})});return _.apply(this,arguments)}var M=x.promisify(j.exec),N=P.default,L=N.gray,T=N.white,C=[];function J(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";var r=new Date().toLocaleString();console.log("".concat(t," [").concat(r,"] ").concat(T(e)))}function U(e){var t=/^\s*(\d+):(\d+)\s+(error|warning)\s+(\S+)\s+(\S+)$/,r=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,n=/^✖\s+(.*?)\s+\[(.*?)\]$/,o=[],a="";e.split("\n").forEach(function(e){if(e.startsWith("/"))a=e.trim();else{var c=t.exec(e);if(c&&a)C.push({file:a,position:"".concat(c[1],":").concat(c[2]),type:c[3]==="error"?"error":"warning",message:c[4].trim(),rule:c[5].trim()});else{var s=r.exec(e);if(s)C.push({file:s[1],position:"".concat(s[2],":").concat(s[3]),type:s[4],message:s[5].trim()});else{var i=n.exec(e);i?C.push({file:"commitlint",type:"error",message:i[1].trim(),rule:i[2].trim()}):o.push(e.trim())}}}}),o.length>0&&(console.log(L("Unmatched lines:")),o.forEach(function(e){return console.info(e)}))}function V(e){try{JSON.parse(e).forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,n=e.line,o=e.column,a=e.ruleId,c=e.message;C.push({type:r===2?"error":"warning",file:t,position:"".concat(n,":").concat(o),rule:a,message:c})})})}catch(t){U(e)}}function $(e,t){return G.apply(this,arguments)}function G(){G=t(function(e,t){var r,n,o,a,c,i,u;var l=arguments;return s(this,function(s){switch(s.label){case 0:r=l.length>2&&l[2]!==void 0?l[2]:V;J(t);n=new AbortController;S.default.on("SIGINT",function(){console.log("Terminating process..."),n.abort(),S.default.exit()});s.label=1;case 1:s.trys.push([1,5,,6]);return[4,M(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:o=s.sent(),a=o.stdout,c=o.stderr;[a,c].forEach(function(e){return e&&r(e)});i=C.length;if(!i)return[3,4];return[4,q(C)];case 3:i=s.sent();s.label=4;case 4:i;return[3,6];case 5:u=s.sent();console.error("Command failed: ".concat(u.message));return[3,6];case 6:return[2]}})});return G.apply(this,arguments)}var A=24*60*60*1e3;function B(e){return W.apply(this,arguments)}function W(){W=t(function(e){var t,r,n,o,a,c,i,u,l,f;var p=arguments;return s(this,function(s){switch(s.label){case 0:t=p.length>1&&p[1]!==void 0?p[1]:!1;r="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,D.get(r)];case 1:o=s.sent();return[4,D.get(n)];case 2:a=s.sent(),c=o&&Date.now()-o.timestamp<A;if(!t&&c)return[2,(console.log("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];i={};(a===null||a===void 0?void 0:a.etag)&&(i["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(i["If-Modified-Since"]=a.lastModified);s.label=3;case 3:s.trys.push([3,8,,9]);console.log("Fetching latest version for ".concat(e,"..."));return[4,(0,m.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:i})];case 4:u=s.sent();if(u.status===304&&o)return[2,(console.log("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=s.sent().version;return[4,D.set(r,{version:l,timestamp:Date.now()})];case 6:s.sent();return[4,D.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(s.sent(),console.log("Cached latest version for ".concat(e,": ").concat(l)),l)];case 8:f=s.sent();if(console.error("Error fetching latest version for ".concat(e,": ").concat(f.message)),o)return[2,(console.warn("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw f;case 9:return[2]}})});return W.apply(this,arguments)}function z(e){return O.default.join(k.default.cwd(),"node_modules",e,"package.json")}function H(){return O.default.join(k.default.cwd(),"package.json")}function K(e){return Q.apply(this,arguments)}function Q(){Q=t(function(e){var t,r,n,o,a;var c=arguments;return s(this,function(s){switch(s.label){case 0:t=c.length>1&&c[1]!==void 0?c[1]:!0;s.label=1;case 1:s.trys.push([1,3,,4]);r=z(e);if(!w.default.existsSync(r))return[2,(console.log("".concat(e," is not installed.")),!0)];n=JSON.parse(w.default.readFileSync(r,"utf-8")).version;return[4,B(e,t)];case 2:o=s.sent();return[2,(console.log("Installed version of ".concat(e,": ").concat(n)),console.log("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=s.sent();return[2,(console.warn("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return Q.apply(this,arguments)}function R(e){return X.apply(this,arguments)}function X(){X=t(function(e){var t,o,c,i;return s(this,function(s){switch(s.label){case 0:s.trys.push([0,4,,5]);return[4,B(e,!0)];case 1:t=s.sent(),o=H(),c=JSON.parse(w.default.readFileSync(o,"utf-8"));c.dependencies=a(n({},c.dependencies),r({},e,t)),w.default.writeFileSync(o,JSON.stringify(c,null,2)),console.log("Updated ".concat(e," to version ").concat(t));return[4,$("npm i -f","Installing all dependencies with updated ".concat(e,"..."))];case 2:s.sent();return[4,$("npm run lint:fix","Fixing lint issues for ".concat(e,"..."))];case 3:s.sent(),console.log("".concat(e," updated successfully."));return[3,5];case 4:i=s.sent();throw console.error("Failed to update ".concat(e,": ").concat(i.message)),i;case 5:return[2]}})});return X.apply(this,arguments)}0&&(module.exports={getLatestPackageVersion:getLatestPackageVersion,isPackageOutdated:isPackageOutdated,updatePackage:updatePackage});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare function getLatestPackageVersion(packageName: string, forceRefresh?: boolean): Promise<string>;
|
|
2
|
+
/**
|
|
3
|
+
* Check if the installed package is outdated.
|
|
4
|
+
* @param packageName Name of the package.
|
|
5
|
+
* @param forceRefresh Whether to bypass cache and force refresh.
|
|
6
|
+
* @returns True if the installed version is different from the latest version.
|
|
7
|
+
*/
|
|
8
|
+
declare function isPackageOutdated(packageName: string, forceRefresh?: boolean): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Update the specified package to the latest version.
|
|
11
|
+
* @param packageName Name of the package.
|
|
12
|
+
*/
|
|
13
|
+
declare function updatePackage(packageName: string): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export { getLatestPackageVersion, isPackageOutdated, updatePackage };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare function getLatestPackageVersion(packageName: string, forceRefresh?: boolean): Promise<string>;
|
|
2
|
+
/**
|
|
3
|
+
* Check if the installed package is outdated.
|
|
4
|
+
* @param packageName Name of the package.
|
|
5
|
+
* @param forceRefresh Whether to bypass cache and force refresh.
|
|
6
|
+
* @returns True if the installed version is different from the latest version.
|
|
7
|
+
*/
|
|
8
|
+
declare function isPackageOutdated(packageName: string, forceRefresh?: boolean): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Update the specified package to the latest version.
|
|
11
|
+
* @param packageName Name of the package.
|
|
12
|
+
*/
|
|
13
|
+
declare function updatePackage(packageName: string): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export { getLatestPackageVersion, isPackageOutdated, updatePackage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,r,n,o,s,c){try{var a=e[s](c);var i=a.value}catch(e){r(e);return}if(a.done){t(i)}else{Promise.resolve(i).then(n,o)}}function t(t){return function(){var r=this,n=arguments;return new Promise(function(o,s){var c=t.apply(r,n);function a(t){e(c,o,s,a,i,"next",t)}function i(t){e(c,o,s,a,i,"throw",t)}a(undefined)})}}function r(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function n(e){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){r(e,t,n[t])})}return e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function s(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{o(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function c(e,t){var r,n,o,s,c={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(e){return function(t){return i([e,t])}}function i(s){if(r)throw new TypeError("Generator is already executing.");while(c)try{if(r=1,n&&(o=s[0]&2?n["return"]:s[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;if(n=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:c.label++;return{value:s[1],done:false};case 5:c.label++;n=s[1];s=[0];continue;case 7:s=c.ops.pop();c.trys.pop();continue;default:if(!(o=c.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){c=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){c.label=s[1];break}if(s[0]===6&&c.label<o[1]){c.label=o[1];o=s;break}if(o&&c.label<o[2]){c.label=o[2];c.ops.push(s);break}if(o[2])c.ops.pop();c.trys.pop();continue}s=t.call(e,c)}catch(e){s=[6,e];n=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}}import a from"node-fetch";import i from"node:fs";import u from"node:path";import l from"node:process";import f from"chalk";import{exec as p}from"node:child_process";import h from"node:process";import*as g from"node:util";import d from"localforage";var v={get:function e(e){return t(function(){var t;return c(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,d.getItem(e)];case 1:return[2,r.sent()];case 2:t=r.sent();return[2,(console.error('Error getting key "'.concat(e,'":'),t),null)];case 3:return[2]}})})()},set:function e(e,r){return t(function(){var t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,d.setItem(e,r)];case 1:n.sent();return[3,3];case 2:t=n.sent();console.error('Error setting key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},remove:function e(e){return t(function(){var t;return c(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,d.removeItem(e)];case 1:r.sent();return[3,3];case 2:t=r.sent();console.error('Error removing key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},clear:function e(){return t(function(){var e;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,d.clear()];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error("Error clearing storage:",e);return[3,3];case 3:return[2]}})})()},key:function e(e){return t(function(){var t;return c(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,d.key(e)];case 1:return[2,r.sent()];case 2:t=r.sent();return[2,(console.error("Error getting key at index ".concat(e,":"),t),null)];case 3:return[2]}})})()},keys:function e(){return t(function(){var e;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,d.keys()];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error("Error getting keys:",e),[])];case 3:return[2]}})})()},length:function e(){return t(function(){var e;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,d.length()];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error("Error getting storage length:",e),0)];case 3:return[2]}})})()},iterate:function e(e){return t(function(){var t;return c(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,d.iterate(e)];case 1:r.sent();return[3,3];case 2:t=r.sent();console.error("Error iterating storage:",t);return[3,3];case 3:return[2]}})})()}};var y=function(e){return"error_list:".concat(e)},m=24*60*60*1e3;function b(e){return w.apply(this,arguments)}function w(){w=t(function(e){var t,r,n;return c(this,function(o){switch(o.label){case 0:if(!e.length)return[2];t=Date.now(),r=y(t);o.label=1;case 1:o.trys.push([1,3,,4]);return[4,v.set(r,{errors:e,timestamp:t})];case 2:o.sent(),console.log("✅ Saved ".concat(e.length," errors to storage with key: ").concat(r));return[3,4];case 3:n=o.sent();console.error("❌ Failed to save errors: ".concat(n.message));return[3,4];case 4:return[2]}})});return w.apply(this,arguments)}var O=g.promisify(p),k=f.gray,S=f.white,j=[];function E(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";var r=new Date().toLocaleString();console.log("".concat(t," [").concat(r,"] ").concat(S(e)))}function P(e){var t=/^\s*(\d+):(\d+)\s+(error|warning)\s+(\S+)\s+(\S+)$/,r=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,n=/^✖\s+(.*?)\s+\[(.*?)\]$/,o=[],s="";e.split("\n").forEach(function(e){if(e.startsWith("/"))s=e.trim();else{var c=t.exec(e);if(c&&s)j.push({file:s,position:"".concat(c[1],":").concat(c[2]),type:c[3]==="error"?"error":"warning",message:c[4].trim(),rule:c[5].trim()});else{var a=r.exec(e);if(a)j.push({file:a[1],position:"".concat(a[2],":").concat(a[3]),type:a[4],message:a[5].trim()});else{var i=n.exec(e);i?j.push({file:"commitlint",type:"error",message:i[1].trim(),rule:i[2].trim()}):o.push(e.trim())}}}}),o.length>0&&(console.log(k("Unmatched lines:")),o.forEach(function(e){return console.info(e)}))}function x(e){try{JSON.parse(e).forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,n=e.line,o=e.column,s=e.ruleId,c=e.message;j.push({type:r===2?"error":"warning",file:t,position:"".concat(n,":").concat(o),rule:s,message:c})})})}catch(t){P(e)}}function F(e,t){return I.apply(this,arguments)}function I(){I=t(function(e,t){var r,n,o,s,a,i,u;var l=arguments;return c(this,function(c){switch(c.label){case 0:r=l.length>2&&l[2]!==void 0?l[2]:x;E(t);n=new AbortController;h.on("SIGINT",function(){console.log("Terminating process..."),n.abort(),h.exit()});c.label=1;case 1:c.trys.push([1,5,,6]);return[4,O(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:o=c.sent(),s=o.stdout,a=o.stderr;[s,a].forEach(function(e){return e&&r(e)});i=j.length;if(!i)return[3,4];return[4,b(j)];case 3:i=c.sent();c.label=4;case 4:i;return[3,6];case 5:u=c.sent();console.error("Command failed: ".concat(u.message));return[3,6];case 6:return[2]}})});return I.apply(this,arguments)}var D=24*60*60*1e3;function M(e){return N.apply(this,arguments)}function N(){N=t(function(e){var t,r,n,o,s,i,u,l,f,p;var h=arguments;return c(this,function(c){switch(c.label){case 0:t=h.length>1&&h[1]!==void 0?h[1]:!1;r="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,v.get(r)];case 1:o=c.sent();return[4,v.get(n)];case 2:s=c.sent(),i=o&&Date.now()-o.timestamp<D;if(!t&&i)return[2,(console.log("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];u={};(s===null||s===void 0?void 0:s.etag)&&(u["If-None-Match"]=s.etag),(s===null||s===void 0?void 0:s.lastModified)&&(u["If-Modified-Since"]=s.lastModified);c.label=3;case 3:c.trys.push([3,8,,9]);console.log("Fetching latest version for ".concat(e,"..."));return[4,a("https://registry.npmjs.org/".concat(e,"/latest"),{headers:u})];case 4:l=c.sent();if(l.status===304&&o)return[2,(console.log("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!l.ok)throw new Error("Failed to fetch latest version: ".concat(l.statusText));return[4,l.json()];case 5:f=c.sent().version;return[4,v.set(r,{version:f,timestamp:Date.now()})];case 6:c.sent();return[4,v.set(n,{etag:l.headers.get("ETag")||void 0,lastModified:l.headers.get("Last-Modified")||void 0})];case 7:return[2,(c.sent(),console.log("Cached latest version for ".concat(e,": ").concat(f)),f)];case 8:p=c.sent();if(console.error("Error fetching latest version for ".concat(e,": ").concat(p.message)),o)return[2,(console.warn("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw p;case 9:return[2]}})});return N.apply(this,arguments)}function T(e){return u.join(l.cwd(),"node_modules",e,"package.json")}function _(){return u.join(l.cwd(),"package.json")}function C(e){return J.apply(this,arguments)}function J(){J=t(function(e){var t,r,n,o,s;var a=arguments;return c(this,function(c){switch(c.label){case 0:t=a.length>1&&a[1]!==void 0?a[1]:!0;c.label=1;case 1:c.trys.push([1,3,,4]);r=T(e);if(!i.existsSync(r))return[2,(console.log("".concat(e," is not installed.")),!0)];n=JSON.parse(i.readFileSync(r,"utf-8")).version;return[4,M(e,t)];case 2:o=c.sent();return[2,(console.log("Installed version of ".concat(e,": ").concat(n)),console.log("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:s=c.sent();return[2,(console.warn("Failed to check version for ".concat(e,": ").concat(s.message)),!0)];case 4:return[2]}})});return J.apply(this,arguments)}function L(e){return U.apply(this,arguments)}function U(){U=t(function(e){var t,o,a,u;return c(this,function(c){switch(c.label){case 0:c.trys.push([0,4,,5]);return[4,M(e,!0)];case 1:t=c.sent(),o=_(),a=JSON.parse(i.readFileSync(o,"utf-8"));a.dependencies=s(n({},a.dependencies),r({},e,t)),i.writeFileSync(o,JSON.stringify(a,null,2)),console.log("Updated ".concat(e," to version ").concat(t));return[4,F("npm i -f","Installing all dependencies with updated ".concat(e,"..."))];case 2:c.sent();return[4,F("npm run lint:fix","Fixing lint issues for ".concat(e,"..."))];case 3:c.sent(),console.log("".concat(e," updated successfully."));return[3,5];case 4:u=c.sent();throw console.error("Failed to update ".concat(e,": ").concat(u.message)),u;case 5:return[2]}})});return U.apply(this,arguments)}export{M as getLatestPackageVersion,C as isPackageOutdated,L as updatePackage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function r(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}var t=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var i=function(e,r){for(var n in r)t(e,n,{get:r[n],enumerable:!0})},a=function(e,i,a,l){var f=true,c=false,s=undefined;if(i&&(typeof i==="undefined"?"undefined":r(i))=="object"||typeof i=="function")try{var y=function(){var r=v.value;!u.call(e,r)&&r!==a&&t(e,r,{get:function(){return i[r]},enumerable:!(l=n(i,r))||l.enumerable})};for(var p=o(i)[Symbol.iterator](),v;!(f=(v=p.next()).done);f=true)y()}catch(e){c=true;s=e}finally{try{if(!f&&p.return!=null){p.return()}}finally{if(c){throw s}}}return e};var l=function(e){return a(t({},"__esModule",{value:!0}),e)};var f={};i(f,{serializer:function(){return c}});module.exports=l(f);var c={serialize:function(r){return JSON.stringify(r,function(r,t){return e(t,Date)?{__type:"Date",value:t.toISOString()}:t})},deserialize:function(e){return JSON.parse(e,function(e,r){return(r===null||r===void 0?void 0:r.__type)==="Date"?new Date(r.value):r})}};0&&(module.exports={serializer:serializer});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,n){if(n!=null&&typeof Symbol!=="undefined"&&n[Symbol.hasInstance]){return!!n[Symbol.hasInstance](e)}else{return e instanceof n}}var n={serialize:function(n){return JSON.stringify(n,function(n,t){return e(t,Date)?{__type:"Date",value:t.toISOString()}:t})},deserialize:function(e){return JSON.parse(e,function(e,n){return(n===null||n===void 0?void 0:n.__type)==="Date"?new Date(n.value):n})}};export{n as serializer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e,r,n,t,o,u,i){try{var a=e[u](i);var f=a.value}catch(e){n(e);return}if(a.done){r(f)}else{Promise.resolve(f).then(t,o)}}function r(r){return function(){var n=this,t=arguments;return new Promise(function(o,u){var i=r.apply(n,t);function a(r){e(i,o,u,a,f,"next",r)}function f(r){e(i,o,u,a,f,"throw",r)}a(undefined)})}}function n(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}function t(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function o(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function u(e,r){var n,t,o,u,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(e){return function(r){return f([e,r])}}function f(u){if(n)throw new TypeError("Generator is already executing.");while(i)try{if(n=1,t&&(o=u[0]&2?t["return"]:u[0]?t["throw"]||((o=t["return"])&&o.call(t),0):t.next)&&!(o=o.call(t,u[1])).done)return o;if(t=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:i.label++;return{value:u[1],done:false};case 5:i.label++;t=u[1];u=[0];continue;case 7:u=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(u[0]===6&&i.label<o[1]){i.label=o[1];o=u;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(u);break}if(o[2])i.ops.pop();i.trys.pop();continue}u=r.call(e,i)}catch(e){u=[6,e];t=0}finally{n=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var c=function(e,r){for(var n in r)i(e,n,{get:r[n],enumerable:!0})},s=function(e,r,n,t){var u=true,c=false,s=undefined;if(r&&(typeof r==="undefined"?"undefined":o(r))=="object"||typeof r=="function")try{var y=function(){var o=b.value;!l.call(e,o)&&o!==n&&i(e,o,{get:function(){return r[o]},enumerable:!(t=a(r,o))||t.enumerable})};for(var p=f(r)[Symbol.iterator](),b;!(u=(b=p.next()).done);u=true)y()}catch(e){c=true;s=e}finally{try{if(!u&&p.return!=null){p.return()}}finally{if(c){throw s}}}return e};var y=function(e){return s(i({},"__esModule",{value:!0}),e)};var p={};c(p,{validate:function(){return b}});module.exports=y(p);var b={common:{isEmpty:function e(e){return e==null?!0:Array.isArray(e)?e.length===0:(typeof e==="undefined"?"undefined":o(e))=="object"?t(e,Date)?!1:Object.keys(e).length===0:typeof e=="string"?e.trim().length===0:!1},isEmptyValidator:function e(){return /*#__PURE__*/function(){var e=r(function(e){return u(this,function(r){return[2,!b.common.isEmpty(e)]})});return function(r){return e.apply(this,arguments)}}()},isUniqueValidator:function e(e){return /*#__PURE__*/function(){var t=r(function(r){var t;return u(this,function(o){switch(o.label){case 0:if(!Array.isArray(e)||e.length===0)throw new Error("Fields must be a non-empty array of strings.");t={$or:e.map(function(e){return n({},e,r)})};return[4,this.constructor.findOne(t)];case 1:return[2,!o.sent()]}})});return function(e){return t.apply(this,arguments)}}()},matchesRegexValidator:function e(e){return /*#__PURE__*/function(){var n=r(function(r){return u(this,function(n){if(!Array.isArray(e)||e.some(function(e){return!t(e,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,e.every(function(e){return e.test(r)})]})});return function(e){return n.apply(this,arguments)}}()}}};0&&(module.exports={validate:validate});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const validate: {
|
|
2
|
+
common: {
|
|
3
|
+
/**
|
|
4
|
+
* Check if a value is empty (null, undefined, empty string, empty array, or empty object).
|
|
5
|
+
* @param {unknown} value - The value to check.
|
|
6
|
+
* @returns {boolean} - True if the value is empty; otherwise, false.
|
|
7
|
+
*/
|
|
8
|
+
isEmpty(value: unknown): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Validator to check if a value is not empty.
|
|
11
|
+
* @returns {(value: unknown) => Promise<boolean>} - The validation function.
|
|
12
|
+
*/
|
|
13
|
+
isEmptyValidator<T>(): (this: T, value: unknown) => Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Validator to check if a value is unique in specified fields.
|
|
16
|
+
* @param {string[]} fields - Fields to check for uniqueness.
|
|
17
|
+
* @returns {(value: unknown) => Promise<boolean>} - The validation function.
|
|
18
|
+
*/
|
|
19
|
+
isUniqueValidator<T extends {
|
|
20
|
+
constructor: {
|
|
21
|
+
findOne: (query: Record<string, unknown>) => Promise<unknown>;
|
|
22
|
+
};
|
|
23
|
+
}>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Validator to check if a value matches all regex patterns in an array.
|
|
26
|
+
* @param {RegExp[]} regexArray - Array of regex patterns.
|
|
27
|
+
* @returns {(value: string) => Promise<boolean>} - The validation function.
|
|
28
|
+
*/
|
|
29
|
+
matchesRegexValidator(regexArray: RegExp[]): (value: string) => Promise<boolean>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { validate };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const validate: {
|
|
2
|
+
common: {
|
|
3
|
+
/**
|
|
4
|
+
* Check if a value is empty (null, undefined, empty string, empty array, or empty object).
|
|
5
|
+
* @param {unknown} value - The value to check.
|
|
6
|
+
* @returns {boolean} - True if the value is empty; otherwise, false.
|
|
7
|
+
*/
|
|
8
|
+
isEmpty(value: unknown): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Validator to check if a value is not empty.
|
|
11
|
+
* @returns {(value: unknown) => Promise<boolean>} - The validation function.
|
|
12
|
+
*/
|
|
13
|
+
isEmptyValidator<T>(): (this: T, value: unknown) => Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Validator to check if a value is unique in specified fields.
|
|
16
|
+
* @param {string[]} fields - Fields to check for uniqueness.
|
|
17
|
+
* @returns {(value: unknown) => Promise<boolean>} - The validation function.
|
|
18
|
+
*/
|
|
19
|
+
isUniqueValidator<T extends {
|
|
20
|
+
constructor: {
|
|
21
|
+
findOne: (query: Record<string, unknown>) => Promise<unknown>;
|
|
22
|
+
};
|
|
23
|
+
}>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Validator to check if a value matches all regex patterns in an array.
|
|
26
|
+
* @param {RegExp[]} regexArray - Array of regex patterns.
|
|
27
|
+
* @returns {(value: string) => Promise<boolean>} - The validation function.
|
|
28
|
+
*/
|
|
29
|
+
matchesRegexValidator(regexArray: RegExp[]): (value: string) => Promise<boolean>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { validate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(n,e,r,t,o,u,i){try{var a=n[u](i);var c=a.value}catch(n){r(n);return}if(a.done){e(c)}else{Promise.resolve(c).then(t,o)}}function e(e){return function(){var r=this,t=arguments;return new Promise(function(o,u){var i=e.apply(r,t);function a(e){n(i,o,u,a,c,"next",e)}function c(e){n(i,o,u,a,c,"throw",e)}a(undefined)})}}function r(n,e,r){if(e in n){Object.defineProperty(n,e,{value:r,enumerable:true,configurable:true,writable:true})}else{n[e]=r}return n}function t(n,e){if(e!=null&&typeof Symbol!=="undefined"&&e[Symbol.hasInstance]){return!!e[Symbol.hasInstance](n)}else{return n instanceof e}}function o(n){"@swc/helpers - typeof";return n&&typeof Symbol!=="undefined"&&n.constructor===Symbol?"symbol":typeof n}function u(n,e){var r,t,o,u,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(n){return function(e){return c([n,e])}}function c(u){if(r)throw new TypeError("Generator is already executing.");while(i)try{if(r=1,t&&(o=u[0]&2?t["return"]:u[0]?t["throw"]||((o=t["return"])&&o.call(t),0):t.next)&&!(o=o.call(t,u[1])).done)return o;if(t=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:i.label++;return{value:u[1],done:false};case 5:i.label++;t=u[1];u=[0];continue;case 7:u=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(u[0]===6&&i.label<o[1]){i.label=o[1];o=u;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(u);break}if(o[2])i.ops.pop();i.trys.pop();continue}u=e.call(n,i)}catch(n){u=[6,n];t=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var i={common:{isEmpty:function n(n){return n==null?!0:Array.isArray(n)?n.length===0:(typeof n==="undefined"?"undefined":o(n))=="object"?t(n,Date)?!1:Object.keys(n).length===0:typeof n=="string"?n.trim().length===0:!1},isEmptyValidator:function n(){return /*#__PURE__*/function(){var n=e(function(n){return u(this,function(e){return[2,!i.common.isEmpty(n)]})});return function(e){return n.apply(this,arguments)}}()},isUniqueValidator:function n(n){return /*#__PURE__*/function(){var t=e(function(e){var t;return u(this,function(o){switch(o.label){case 0:if(!Array.isArray(n)||n.length===0)throw new Error("Fields must be a non-empty array of strings.");t={$or:n.map(function(n){return r({},n,e)})};return[4,this.constructor.findOne(t)];case 1:return[2,!o.sent()]}})});return function(n){return t.apply(this,arguments)}}()},matchesRegexValidator:function n(n){return /*#__PURE__*/function(){var r=e(function(e){return u(this,function(r){if(!Array.isArray(n)||n.some(function(n){return!t(n,RegExp)}))throw new Error("regexArray must be an array of valid RegExp objects.");return[2,n.every(function(n){return n.test(e)})]})});return function(n){return r.apply(this,arguments)}}()}}};export{i as validate};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"description": "CyberSkill Shared",
|
|
6
6
|
"author": "Stephen Cheng",
|
|
7
7
|
"license": "MIT",
|
|
@@ -145,7 +145,6 @@
|
|
|
145
145
|
"lint": "npx tsx src/commands.ts lint",
|
|
146
146
|
"lint:fix": "npx tsx src/commands.ts lint:fix",
|
|
147
147
|
"lint:inspect": "npx @eslint/config-inspector",
|
|
148
|
-
"release": "semantic-release",
|
|
149
148
|
"reset": "npx tsx src/commands.ts reset",
|
|
150
149
|
"setup": "npx tsx src/commands.ts setup"
|
|
151
150
|
},
|
|
@@ -166,6 +165,7 @@
|
|
|
166
165
|
"@types/mongoose-aggregate-paginate-v2": "1.0.12",
|
|
167
166
|
"@types/react": "19.0.10",
|
|
168
167
|
"@types/react-dom": "19.0.4",
|
|
168
|
+
"@types/unorm": "1.3.31",
|
|
169
169
|
"@types/uuid": "10.0.0",
|
|
170
170
|
"@types/yargs": "17.0.33",
|
|
171
171
|
"@vitejs/plugin-react-swc": "3.8.0",
|
|
@@ -208,16 +208,6 @@
|
|
|
208
208
|
"vitest-browser-react": "0.1.1",
|
|
209
209
|
"yargs": "17.7.2"
|
|
210
210
|
},
|
|
211
|
-
"devDependencies": {
|
|
212
|
-
"@semantic-release/changelog": "6.0.3",
|
|
213
|
-
"@semantic-release/commit-analyzer": "13.0.1",
|
|
214
|
-
"@semantic-release/git": "10.0.1",
|
|
215
|
-
"@semantic-release/github": "11.0.1",
|
|
216
|
-
"@semantic-release/npm": "12.0.1",
|
|
217
|
-
"@semantic-release/release-notes-generator": "14.0.3",
|
|
218
|
-
"@types/unorm": "1.3.31",
|
|
219
|
-
"semantic-release": "24.2.3"
|
|
220
|
-
},
|
|
221
211
|
"publishConfig": {
|
|
222
212
|
"access": "public",
|
|
223
213
|
"registry": "https://registry.npmjs.org/"
|
package/dist/.gitignore
DELETED