@cyberskill/shared 2.19.0 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/eslint/index.d.ts +5 -0
- package/dist/config/storybook/index.cjs +1 -0
- package/dist/config/storybook/index.d.ts +2 -0
- package/dist/config/storybook/index.js +6 -0
- package/dist/config/storybook/storybook.main.cjs +1 -0
- package/dist/config/storybook/storybook.main.d.ts +17 -0
- package/dist/config/storybook/storybook.main.js +18 -0
- package/dist/config/storybook/storybook.preview.cjs +1 -0
- package/dist/config/storybook/storybook.preview.d.ts +18 -0
- package/dist/config/storybook/storybook.preview.js +39 -0
- package/dist/config/vitest/vitest.e2e.cjs +1 -1
- package/dist/config/vitest/vitest.e2e.js +1 -1
- package/dist/config/vitest/vitest.unit.cjs +1 -1
- package/dist/config/vitest/vitest.unit.js +1 -1
- package/dist/node/cli/index.cjs +2 -2
- package/dist/node/cli/index.js +51 -41
- package/dist/node/express/express.util.cjs +1 -1
- package/dist/node/express/express.util.js +21 -21
- package/dist/node/mongo/mongo.type.d.ts +3 -3
- package/dist/node/mongo/mongo.util.cjs +1 -1
- package/dist/node/mongo/mongo.util.d.ts +1019 -125
- package/dist/node/mongo/mongo.util.js +1 -1
- package/dist/node/path/index.cjs +1 -1
- package/dist/node/path/index.js +27 -25
- package/dist/node/path/path.constant.cjs +1 -1
- package/dist/node/path/path.constant.d.ts +6 -0
- package/dist/node/path/path.constant.js +152 -128
- package/dist/node/storage/index.cjs +1 -1
- package/dist/node/storage/index.d.ts +2 -0
- package/dist/node/storage/index.js +7 -2
- package/dist/node/storage/storage.constant.cjs +1 -0
- package/dist/node/storage/storage.constant.d.ts +4 -0
- package/dist/node/storage/storage.constant.js +7 -0
- package/dist/node/storage/storage.type.d.ts +14 -0
- package/dist/node/storage/storage.util.cjs +1 -1
- package/dist/node/storage/storage.util.d.ts +1 -1
- package/dist/node/storage/storage.util.js +160 -50
- package/dist/react/apollo-client/apollo-client.component.cjs +1 -1
- package/dist/react/apollo-client/apollo-client.component.d.ts +3 -2
- package/dist/react/apollo-client/apollo-client.component.js +12 -12
- package/dist/react/apollo-client/apollo-client.type.d.ts +6 -0
- package/dist/react/apollo-client/apollo-client.util.cjs +1 -1
- package/dist/react/apollo-client/apollo-client.util.js +32 -34
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.d.ts +3 -2
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +10 -10
- package/dist/react/apollo-error/apollo-error.provider.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.provider.d.ts +5 -4
- package/dist/react/apollo-error/apollo-error.provider.js +21 -15
- package/dist/react/apollo-error/apollo-error.type.d.ts +5 -0
- package/dist/react/apollo-error/apollo-error.util.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.util.d.ts +13 -1
- package/dist/react/apollo-error/apollo-error.util.js +15 -7
- package/dist/react/apollo-error/index.cjs +1 -1
- package/dist/react/apollo-error/index.js +8 -6
- package/package.json +45 -41
- /package/dist/node_modules/.pnpm/{vitest@4.0.6_@types_debug@4.1.12_@types_node@24.9.2_jiti@2.6.1_jsdom@27.1.0_sass@1.93.3_tsx@4.20.6_yaml@2.8.1 → vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1}/node_modules/vitest/dist/config.cjs +0 -0
- /package/dist/node_modules/.pnpm/{vitest@4.0.6_@types_debug@4.1.12_@types_node@24.9.2_jiti@2.6.1_jsdom@27.1.0_sass@1.93.3_tsx@4.20.6_yaml@2.8.1 → vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1}/node_modules/vitest/dist/config.js +0 -0
|
@@ -207,6 +207,7 @@ declare const _default: {
|
|
|
207
207
|
DeviceOrientationEvent: false;
|
|
208
208
|
devicePixelRatio: false;
|
|
209
209
|
DevicePosture: false;
|
|
210
|
+
DigitalCredential: false;
|
|
210
211
|
dispatchEvent: false;
|
|
211
212
|
DisposableStack: false;
|
|
212
213
|
document: false;
|
|
@@ -434,6 +435,7 @@ declare const _default: {
|
|
|
434
435
|
IDBKeyRange: false;
|
|
435
436
|
IDBObjectStore: false;
|
|
436
437
|
IDBOpenDBRequest: false;
|
|
438
|
+
IDBRecord: false;
|
|
437
439
|
IDBRequest: false;
|
|
438
440
|
IDBTransaction: false;
|
|
439
441
|
IDBVersionChangeEvent: false;
|
|
@@ -459,6 +461,7 @@ declare const _default: {
|
|
|
459
461
|
InputDeviceInfo: false;
|
|
460
462
|
InputEvent: false;
|
|
461
463
|
IntegrityViolationReportBody: false;
|
|
464
|
+
InterestEvent: false;
|
|
462
465
|
IntersectionObserver: false;
|
|
463
466
|
IntersectionObserverEntry: false;
|
|
464
467
|
isSecureContext: false;
|
|
@@ -548,6 +551,7 @@ declare const _default: {
|
|
|
548
551
|
NavigationCurrentEntryChangeEvent: false;
|
|
549
552
|
NavigationDestination: false;
|
|
550
553
|
NavigationHistoryEntry: false;
|
|
554
|
+
NavigationPrecommitController: false;
|
|
551
555
|
NavigationPreloadManager: false;
|
|
552
556
|
NavigationTransition: false;
|
|
553
557
|
navigator: false;
|
|
@@ -878,6 +882,7 @@ declare const _default: {
|
|
|
878
882
|
SpeechRecognition: false;
|
|
879
883
|
SpeechRecognitionErrorEvent: false;
|
|
880
884
|
SpeechRecognitionEvent: false;
|
|
885
|
+
SpeechRecognitionPhrase: false;
|
|
881
886
|
speechSynthesis: false;
|
|
882
887
|
SpeechSynthesis: false;
|
|
883
888
|
SpeechSynthesisErrorEvent: false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./storybook.main.cjs"),e=require("./storybook.preview.cjs");exports.storybookMain=o.storybookMain;exports.storybookPreview=e.storybookPreview;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("lodash-es");function r(o){const s={stories:["../src/**/*.stories.@(js|jsx|mjs|ts|tsx|mdx)"],addons:["@storybook/addon-essentials","@storybook/addon-interactions","@storybook/addon-links"],framework:{name:"@storybook/react-vite",options:{}}};return t.merge(s,o)}exports.storybookMain=r;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StorybookConfig } from '@storybook/react-vite';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Storybook main configuration for React projects using Vite.
|
|
4
|
+
* This function generates a Storybook configuration specifically designed for React applications
|
|
5
|
+
* with Vite as the build tool. It includes essential addons and framework settings.
|
|
6
|
+
*
|
|
7
|
+
* The configuration includes:
|
|
8
|
+
* - React Vite framework integration
|
|
9
|
+
* - Essential Storybook addons (docs, controls, actions, viewport, backgrounds)
|
|
10
|
+
* - Story file pattern matching
|
|
11
|
+
* - Vite configuration support
|
|
12
|
+
* - Configurable options merging
|
|
13
|
+
*
|
|
14
|
+
* @param options - Additional Storybook configuration options to merge with the base config.
|
|
15
|
+
* @returns A Storybook configuration object optimized for React with Vite.
|
|
16
|
+
*/
|
|
17
|
+
export declare function storybookMain(options?: Partial<StorybookConfig>): StorybookConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { merge as s } from "lodash-es";
|
|
2
|
+
function n(o) {
|
|
3
|
+
return s({
|
|
4
|
+
stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx|mdx)"],
|
|
5
|
+
addons: [
|
|
6
|
+
"@storybook/addon-essentials",
|
|
7
|
+
"@storybook/addon-interactions",
|
|
8
|
+
"@storybook/addon-links"
|
|
9
|
+
],
|
|
10
|
+
framework: {
|
|
11
|
+
name: "@storybook/react-vite",
|
|
12
|
+
options: {}
|
|
13
|
+
}
|
|
14
|
+
}, o);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
n as storybookMain
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var l=Object.defineProperty,n=Object.defineProperties,p=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,s=(e,r,t)=>r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,a=(e,r)=>{for(var t in r||(r={}))c.call(r,t)&&s(e,t,r[t]);if(o)for(var t of o(r))f.call(r,t)&&s(e,t,r[t]);return e},i=(e,r)=>n(e,p(r));function u(e){const r={parameters:{controls:{matchers:{color:/(background|color)$/i,date:/Date$/i}},backgrounds:{default:"light",values:[{name:"light",value:"#ffffff"},{name:"dark",value:"#333333"}]}}};return i(a(a({},r),e),{parameters:a(a({},r.parameters),e==null?void 0:e.parameters)})}exports.storybookPreview=u;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Preview } from '@storybook/react';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Storybook preview configuration for React projects.
|
|
4
|
+
* This function generates a preview configuration that provides default parameters
|
|
5
|
+
* and decorators for Storybook stories. It sets up common controls, backgrounds,
|
|
6
|
+
* and viewport settings for consistent story rendering.
|
|
7
|
+
*
|
|
8
|
+
* The configuration includes:
|
|
9
|
+
* - Default control parameters for common props
|
|
10
|
+
* - Background color options
|
|
11
|
+
* - Viewport presets for responsive testing
|
|
12
|
+
* - Actions configuration for event handlers
|
|
13
|
+
* - Configurable options merging
|
|
14
|
+
*
|
|
15
|
+
* @param options - Additional preview configuration options to merge with the base config.
|
|
16
|
+
* @returns A Storybook preview configuration object.
|
|
17
|
+
*/
|
|
18
|
+
export declare function storybookPreview(options?: Partial<Preview>): Preview;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var s = Object.defineProperty, n = Object.defineProperties, l = Object.getOwnPropertyDescriptors, o = Object.getOwnPropertySymbols, f = Object.prototype.hasOwnProperty, c = Object.prototype.propertyIsEnumerable, p = (e, r, a) => r in e ? s(e, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[r] = a, t = (e, r) => {
|
|
2
|
+
for (var a in r || (r = {}))
|
|
3
|
+
f.call(r, a) && p(e, a, r[a]);
|
|
4
|
+
if (o)
|
|
5
|
+
for (var a of o(r))
|
|
6
|
+
c.call(r, a) && p(e, a, r[a]);
|
|
7
|
+
return e;
|
|
8
|
+
}, _ = (e, r) => n(e, l(r));
|
|
9
|
+
function i(e) {
|
|
10
|
+
const r = {
|
|
11
|
+
parameters: {
|
|
12
|
+
controls: {
|
|
13
|
+
matchers: {
|
|
14
|
+
color: /(background|color)$/i,
|
|
15
|
+
date: /Date$/i
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
backgrounds: {
|
|
19
|
+
default: "light",
|
|
20
|
+
values: [
|
|
21
|
+
{
|
|
22
|
+
name: "light",
|
|
23
|
+
value: "#ffffff"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "dark",
|
|
27
|
+
value: "#333333"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return _(t(t({}, r), e), {
|
|
34
|
+
parameters: t(t({}, r.parameters), e == null ? void 0 : e.parameters)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
i as storybookPreview
|
|
39
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("lodash-es"),o=require("../../node_modules/.pnpm/vitest@4.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("lodash-es"),o=require("../../node_modules/.pnpm/vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/config.cjs");function s(e){const r={plugins:[t()],test:{include:["**/*.test.e2e.?(c|m)[jt]s?(x)"],browser:{enabled:!0,provider:"playwright",instances:[{browser:"chromium"},{browser:"firefox"},{browser:"webkit"}]}}};return o.defineConfig(i.merge(r,e))}exports.vitestE2E=s;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import t from "@vitejs/plugin-react-swc";
|
|
2
2
|
import { merge as o } from "lodash-es";
|
|
3
|
-
import { defineConfig as i } from "../../node_modules/.pnpm/vitest@4.0.
|
|
3
|
+
import { defineConfig as i } from "../../node_modules/.pnpm/vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/config.js";
|
|
4
4
|
function f(r) {
|
|
5
5
|
const e = {
|
|
6
6
|
plugins: [t()],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("lodash-es"),s=require("../../node_modules/.pnpm/vitest@4.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("lodash-es"),s=require("../../node_modules/.pnpm/vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/config.cjs");function r(e){const t={plugins:[i()],test:{globals:!0,environment:"jsdom",pool:"vmThreads",include:["**/*.test.unit.?(c|m)[jt]s?(x)"],setupFiles:["./vitest.unit.setup.ts"]}};return s.defineConfig(n.merge(t,e))}exports.vitestUnit=r;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import i from "@vitejs/plugin-react-swc";
|
|
2
2
|
import { merge as o } from "lodash-es";
|
|
3
|
-
import { defineConfig as n } from "../../node_modules/.pnpm/vitest@4.0.
|
|
3
|
+
import { defineConfig as n } from "../../node_modules/.pnpm/vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1/node_modules/vitest/dist/config.js";
|
|
4
4
|
function u(t) {
|
|
5
5
|
const e = {
|
|
6
6
|
plugins: [i()],
|
package/dist/node/cli/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";const g=require("node:process"),
|
|
2
|
+
"use strict";const g=require("node:process"),I=require("yargs/helpers"),v=require("yargs/yargs"),i=require("../command/command.util.cjs"),y=require("../package/package.util.cjs"),l=require("../fs/fs.util.cjs"),L=require("../path/path.util.cjs"),n=require("../path/path.constant.cjs"),s=require("../log/log.util.cjs"),f=require("../log/log.type.cjs");var t=(e,o,r)=>new Promise((c,p)=>{var k=a=>{try{m(r.next(a))}catch(d){p(d)}},_=a=>{try{m(r.throw(a))}catch(d){p(d)}},m=a=>a.done?c(a.value):Promise.resolve(a.value).then(k,_);m((r=r.apply(e,o)).next())});function P(){try{return JSON.parse(l.readFileSync(L.resolve(__dirname,"../../../package.json"),"utf-8")).version}catch(e){return"1.0.0"}}function C(){return t(this,null,function*(){l.pathExistsSync(n.PATH.TS_CONFIG)?yield i.runCommand("Performing TypeScript validation",yield n.command.typescriptCheck()):s.log.warn("No TypeScript configuration found. Skipping type check.")})}function S(e=!1){return t(this,null,function*(){e?yield i.runCommand("Running ESLint with auto-fix",yield n.command.eslintFix()):yield i.runCommand("Running ESLint check",yield n.command.eslintCheck())})}function h(e,o){if(!o.length)return;const r=e==="Errors"?"red":"yellow";s.log.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",o,r)}function u(){return t(this,null,function*(){setTimeout(()=>t(null,null,function*(){const e=yield i.getStoredErrorLists(),o=e.filter(c=>c.type===f.E_IssueType.Error),r=e.filter(c=>c.type===f.E_IssueType.Warning);!o.length&&!r.length?s.log.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(h("Warnings",r),h("Errors",o),o.length>0&&g.exit(1))}),0)})}function T(){return t(this,null,function*(){yield i.clearAllErrorLists();const e=yield y.getPackage({name:n.CYBERSKILL_PACKAGE_NAME});if(!e.success){s.log.error("Failed to retrieve package information. Aborting lint-staged.");return}e.result.isCurrentProject&&(yield i.runCommand(`Building package: ${n.CYBERSKILL_PACKAGE_NAME}`,yield n.command.build())),yield i.runCommand("Executing lint-staged",yield n.command.lintStaged()),u()})}function A(){return t(this,null,function*(){yield i.runCommand("Inspecting ESLint configuration",yield n.command.eslintInspect())})}function M(){return t(this,null,function*(){yield i.clearAllErrorLists(),yield Promise.all([C(),S()]),u()})}function O(){return t(this,null,function*(){yield i.clearAllErrorLists(),yield Promise.all([C(),S(!0)]),u()})}function G(){return t(this,null,function*(){yield i.clearAllErrorLists(),yield i.runCommand("Validating commit message",yield n.command.commitLint()),u()})}function E(){return t(this,null,function*(){yield i.runCommand("Configuring Git hooks",yield n.command.configureGitHook()),l.removeSync(n.PATH.GIT_HOOK);const e=yield i.resolveCommands(n.createGitHooksConfig);l.writeFileSync(n.PATH.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(e,null,4));const o=`
|
|
3
3
|
${n.SIMPLE_GIT_HOOK_JSON}
|
|
4
4
|
`;l.pathExistsSync(n.PATH.GIT_IGNORE)?l.readFileSync(n.PATH.GIT_IGNORE,"utf-8").split(`
|
|
5
|
-
`).includes(n.SIMPLE_GIT_HOOK_JSON)||l.appendFileSync(n.PATH.GIT_IGNORE,o):l.writeFileSync(n.PATH.GIT_IGNORE,o),yield i.runCommand("Setting up simple-git-hooks",yield n.command.simpleGitHooks())})}function R(){return t(this,null,function*(){yield
|
|
5
|
+
`).includes(n.SIMPLE_GIT_HOOK_JSON)||l.appendFileSync(n.PATH.GIT_IGNORE,o):l.writeFileSync(n.PATH.GIT_IGNORE,o),yield i.runCommand("Setting up simple-git-hooks",yield n.command.simpleGitHooks())})}function R(){return t(this,null,function*(){yield y.installDependencies(),yield E()})}function N(){return t(this,null,function*(){l.removeSync(n.PATH.NODE_MODULES,n.PATH.PNPM_LOCK_YAML),yield i.runCommand("Pruning pnpm store",yield n.command.pnpmPruneStore()),yield i.runCommand("Clearing pnpm cache",yield n.command.pnpmCleanCache()),yield y.installDependencies(),yield E()})}function b(){return t(this,null,function*(){yield i.runCommand("Inspecting project dependencies",yield n.command.nodeModulesInspect())})}function B(){return t(this,null,function*(){yield i.runCommand("Running unit tests",yield n.command.testUnit())})}function H(){return t(this,null,function*(){yield i.runCommand("Running end-to-end tests",yield n.command.testE2e())})}function D(e){return t(this,null,function*(){yield i.runCommand("Creating MongoDB migration",yield n.command.mongoMigrateCreate(e))})}function w(){return t(this,null,function*(){yield i.runCommand("Running MongoDB migrations",yield n.command.mongoMigrateUp())})}function x(){return t(this,null,function*(){yield i.runCommand("Rolling back MongoDB migration",yield n.command.mongoMigrateDown())})}function q(){return t(this,null,function*(){yield i.runCommand("Starting Storybook development server",yield n.command.storybookDev())})}function F(){return t(this,null,function*(){yield i.runCommand("Building Storybook",yield n.command.storybookBuild())})}t(null,null,function*(){try{yield v(I.hideBin(g.argv)).scriptName(n.CYBERSKILL_CLI).usage("$0 <command> [options]").command("lint","Check code for linting issues",M).command("lint:fix","Fix linting issues automatically",O).command("lint:inspect","View active ESLint configuration",A).command("lint-staged","Run lint checks on staged files",T).command("commitlint","Validate commit message format",G).command("ready","Initialize project and dependencies",R).command("reset","Reset the project and reinstall dependencies",N).command("inspect","Analyze installed project dependencies",b).command("test:unit","Run unit test suite",B).command("test:e2e","Run end-to-end test suite",H).command("mongo:migrate:create <name>","Create a MongoDB migration",e=>e.positional("name",{describe:"Migration name",type:"string"}),e=>t(null,null,function*(){if(!e.name){s.log.error("Migration name is required.");return}yield D(e.name)})).command("mongo:migrate:up","Apply all MongoDB migrations",w).command("mongo:migrate:down","Rollback last MongoDB migration",x).command("storybook:dev","Start Storybook development server",q).command("storybook:build","Build Storybook for production",F).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(P()).epilog(`💡 Tip: Use "--help" with any command to see options
|
|
6
6
|
`).parse()}catch(e){s.catchError(e),g.exit(1)}});
|
package/dist/node/cli/index.js
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import { hideBin as
|
|
4
|
-
import
|
|
5
|
-
import { clearAllErrorLists as
|
|
6
|
-
import { getPackage as D, installDependencies as
|
|
7
|
-
import { removeSync as
|
|
8
|
-
import { resolve as
|
|
9
|
-
import { CYBERSKILL_CLI as
|
|
10
|
-
import { log as
|
|
2
|
+
import y from "node:process";
|
|
3
|
+
import { hideBin as b } from "yargs/helpers";
|
|
4
|
+
import B from "yargs/yargs";
|
|
5
|
+
import { clearAllErrorLists as a, runCommand as i, getStoredErrorLists as N, resolveCommands as P } from "../command/command.util.js";
|
|
6
|
+
import { getPackage as D, installDependencies as v } from "../package/package.util.js";
|
|
7
|
+
import { removeSync as I, readFileSync as C, pathExistsSync as _, writeFileSync as f, appendFileSync as T } from "../fs/fs.util.js";
|
|
8
|
+
import { resolve as w } from "../path/path.util.js";
|
|
9
|
+
import { CYBERSKILL_CLI as x, command as t, CYBERSKILL_PACKAGE_NAME as h, PATH as l, SIMPLE_GIT_HOOK_JSON as k, createGitHooksConfig as A } from "../path/path.constant.js";
|
|
10
|
+
import { log as u, catchError as F } from "../log/log.util.js";
|
|
11
11
|
import { E_IssueType as S } from "../log/log.type.js";
|
|
12
|
-
var e = (n, o, r) => new Promise((c,
|
|
12
|
+
var e = (n, o, r) => new Promise((c, p) => {
|
|
13
13
|
var R = (s) => {
|
|
14
14
|
try {
|
|
15
15
|
m(r.next(s));
|
|
16
16
|
} catch (g) {
|
|
17
|
-
|
|
17
|
+
p(g);
|
|
18
18
|
}
|
|
19
19
|
}, G = (s) => {
|
|
20
20
|
try {
|
|
21
21
|
m(r.throw(s));
|
|
22
22
|
} catch (g) {
|
|
23
|
-
|
|
23
|
+
p(g);
|
|
24
24
|
}
|
|
25
25
|
}, m = (s) => s.done ? c(s.value) : Promise.resolve(s.value).then(R, G);
|
|
26
26
|
m((r = r.apply(n, o)).next());
|
|
27
27
|
});
|
|
28
|
-
function
|
|
28
|
+
function H() {
|
|
29
29
|
try {
|
|
30
30
|
return JSON.parse(
|
|
31
|
-
|
|
31
|
+
C(w(__dirname, "../../../package.json"), "utf-8")
|
|
32
32
|
).version;
|
|
33
33
|
} catch (n) {
|
|
34
34
|
return "1.0.0";
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function L() {
|
|
38
38
|
return e(this, null, function* () {
|
|
39
|
-
|
|
39
|
+
_(l.TS_CONFIG) ? yield i("Performing TypeScript validation", yield t.typescriptCheck()) : u.warn("No TypeScript configuration found. Skipping type check.");
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function M(n = !1) {
|
|
43
43
|
return e(this, null, function* () {
|
|
44
44
|
n ? yield i("Running ESLint with auto-fix", yield t.eslintFix()) : yield i("Running ESLint check", yield t.eslintCheck());
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function E(n, o) {
|
|
48
48
|
if (!o.length)
|
|
49
49
|
return;
|
|
50
50
|
const r = n === "Errors" ? "red" : "yellow";
|
|
51
|
-
|
|
51
|
+
u.printBoxedLog(n === "Errors" ? "✖ Errors" : "⚠ Warnings", o, r);
|
|
52
52
|
}
|
|
53
53
|
function d() {
|
|
54
54
|
return e(this, null, function* () {
|
|
55
55
|
setTimeout(() => e(null, null, function* () {
|
|
56
|
-
const n = yield
|
|
57
|
-
!o.length && !r.length ?
|
|
56
|
+
const n = yield N(), o = n.filter((c) => c.type === S.Error), r = n.filter((c) => c.type === S.Warning);
|
|
57
|
+
!o.length && !r.length ? u.printBoxedLog("✔ NO ISSUES FOUND", [], "green") : (E("Warnings", r), E("Errors", o), o.length > 0 && y.exit(1));
|
|
58
58
|
}), 0);
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function U() {
|
|
62
62
|
return e(this, null, function* () {
|
|
63
|
-
yield
|
|
63
|
+
yield a();
|
|
64
64
|
const n = yield D({ name: h });
|
|
65
65
|
if (!n.success) {
|
|
66
|
-
|
|
66
|
+
u.error("Failed to retrieve package information. Aborting lint-staged.");
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
n.result.isCurrentProject && (yield i(`Building package: ${h}`, yield t.build())), yield i("Executing lint-staged", yield t.lintStaged()), d();
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function K() {
|
|
73
73
|
return e(this, null, function* () {
|
|
74
74
|
yield i("Inspecting ESLint configuration", yield t.eslintInspect());
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
function j() {
|
|
78
78
|
return e(this, null, function* () {
|
|
79
|
-
yield
|
|
79
|
+
yield a(), yield Promise.all([L(), M()]), d();
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
function J() {
|
|
83
83
|
return e(this, null, function* () {
|
|
84
|
-
yield
|
|
84
|
+
yield a(), yield Promise.all([L(), M(!0)]), d();
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
function V() {
|
|
88
88
|
return e(this, null, function* () {
|
|
89
|
-
yield
|
|
89
|
+
yield a(), yield i("Validating commit message", yield t.commitLint()), d();
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function O() {
|
|
93
93
|
return e(this, null, function* () {
|
|
94
|
-
yield i("Configuring Git hooks", yield t.configureGitHook()),
|
|
95
|
-
const n = yield
|
|
96
|
-
|
|
94
|
+
yield i("Configuring Git hooks", yield t.configureGitHook()), I(l.GIT_HOOK);
|
|
95
|
+
const n = yield P(A);
|
|
96
|
+
f(l.SIMPLE_GIT_HOOKS_JSON, JSON.stringify(n, null, 4));
|
|
97
97
|
const o = `
|
|
98
|
-
${
|
|
98
|
+
${k}
|
|
99
99
|
`;
|
|
100
|
-
|
|
101
|
-
`).includes(
|
|
100
|
+
_(l.GIT_IGNORE) ? C(l.GIT_IGNORE, "utf-8").split(`
|
|
101
|
+
`).includes(k) || T(l.GIT_IGNORE, o) : f(l.GIT_IGNORE, o), yield i("Setting up simple-git-hooks", yield t.simpleGitHooks());
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
function W() {
|
|
105
105
|
return e(this, null, function* () {
|
|
106
|
-
yield
|
|
106
|
+
yield v(), yield O();
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
function Y() {
|
|
110
110
|
return e(this, null, function* () {
|
|
111
|
-
|
|
111
|
+
I(l.NODE_MODULES, l.PNPM_LOCK_YAML), yield i("Pruning pnpm store", yield t.pnpmPruneStore()), yield i("Clearing pnpm cache", yield t.pnpmCleanCache()), yield v(), yield O();
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
function $() {
|
|
@@ -141,20 +141,30 @@ function Z() {
|
|
|
141
141
|
yield i("Rolling back MongoDB migration", yield t.mongoMigrateDown());
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
+
function nn() {
|
|
145
|
+
return e(this, null, function* () {
|
|
146
|
+
yield i("Starting Storybook development server", yield t.storybookDev());
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function en() {
|
|
150
|
+
return e(this, null, function* () {
|
|
151
|
+
yield i("Building Storybook", yield t.storybookBuild());
|
|
152
|
+
});
|
|
153
|
+
}
|
|
144
154
|
e(null, null, function* () {
|
|
145
155
|
try {
|
|
146
|
-
yield
|
|
156
|
+
yield B(b(y.argv)).scriptName(x).usage("$0 <command> [options]").command("lint", "Check code for linting issues", j).command("lint:fix", "Fix linting issues automatically", J).command("lint:inspect", "View active ESLint configuration", K).command("lint-staged", "Run lint checks on staged files", U).command("commitlint", "Validate commit message format", V).command("ready", "Initialize project and dependencies", W).command("reset", "Reset the project and reinstall dependencies", Y).command("inspect", "Analyze installed project dependencies", $).command("test:unit", "Run unit test suite", z).command("test:e2e", "Run end-to-end test suite", q).command("mongo:migrate:create <name>", "Create a MongoDB migration", (n) => n.positional("name", {
|
|
147
157
|
describe: "Migration name",
|
|
148
158
|
type: "string"
|
|
149
159
|
}), (n) => e(null, null, function* () {
|
|
150
160
|
if (!n.name) {
|
|
151
|
-
|
|
161
|
+
u.error("Migration name is required.");
|
|
152
162
|
return;
|
|
153
163
|
}
|
|
154
164
|
yield Q(n.name);
|
|
155
|
-
})).command("mongo:migrate:up", "Apply all MongoDB migrations", X).command("mongo:migrate:down", "Rollback last MongoDB migration", Z).demandCommand(1, "Please specify a valid command.").strict().help().alias("h", "help").alias("v", "version").version(
|
|
165
|
+
})).command("mongo:migrate:up", "Apply all MongoDB migrations", X).command("mongo:migrate:down", "Rollback last MongoDB migration", Z).command("storybook:dev", "Start Storybook development server", nn).command("storybook:build", "Build Storybook for production", en).demandCommand(1, "Please specify a valid command.").strict().help().alias("h", "help").alias("v", "version").version(H()).epilog(`💡 Tip: Use "--help" with any command to see options
|
|
156
166
|
`).parse();
|
|
157
167
|
} catch (n) {
|
|
158
|
-
|
|
168
|
+
F(n), y.exit(1);
|
|
159
169
|
}
|
|
160
170
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@nestjs/core"),P=require("compression"),h=require("cookie-parser"),m=require("cors"),c=require("express"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@nestjs/core"),P=require("compression"),h=require("cookie-parser"),m=require("cors"),c=require("express"),x=require("express-session"),q=require("express-useragent"),b=require("graphql-upload/graphqlUploadExpress.mjs");var g=Object.defineProperty,l=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,p=(e,r,t)=>r in e?g(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,S=(e,r)=>{for(var t in r||(r={}))v.call(r,t)&&p(e,t,r[t]);if(l)for(var t of l(r))d.call(r,t)&&p(e,t,r[t]);return e},E=(e,r)=>{var t={};for(var s in e)v.call(e,s)&&r.indexOf(s)<0&&(t[s]=e[s]);if(e!=null&&l)for(var s of l(e))r.indexOf(s)<0&&d.call(e,s)&&(t[s]=e[s]);return t},C=(e,r,t)=>new Promise((s,a)=>{var i=n=>{try{o(t.next(n))}catch(f){a(f)}},u=n=>{try{o(t.throw(n))}catch(f){a(f)}},o=n=>n.done?s(n.value):Promise.resolve(n.value).then(i,u);o((t=t.apply(e,r)).next())});function y(e){var r=e,{isDev:t,whiteList:s}=r,a=E(r,["isDev","whiteList"]);return S({origin:(i,u)=>{t||!i||s!=null&&s.includes(i!=null?i:"")?u(null,!0):u(new Error("Not allowed by CORS"),!1)},credentials:!0},a)}function N(e){return m(y(e))}function j(e){return x(e)}function _(e){e.set("trust proxy",1),e.use(h()),e.use(c.urlencoded({extended:!0})),e.use(P()),e.use(q.express())}function O(e,r){r&&(Array.isArray(r)?r:[r]).forEach(s=>{e.use(`/${s}`,c.static(s))})}function A(e){const r=c();return _(r),O(r,e==null?void 0:e.static),r.use(b()),r}function I(e){return C(this,null,function*(){const r=yield w.NestFactory.create(e.module);return _(r.getHttpAdapter().getInstance()),O(r.getHttpAdapter().getInstance(),e.static),e.filters&&r.useGlobalFilters(...e.filters),e.pipes&&r.useGlobalPipes(...e.pipes),r})}exports.express=c;exports.createCors=N;exports.createCorsOptions=y;exports.createExpress=A;exports.createNest=I;exports.createSession=j;
|
|
@@ -4,10 +4,10 @@ import O from "cookie-parser";
|
|
|
4
4
|
import h from "cors";
|
|
5
5
|
import c from "express";
|
|
6
6
|
import { default as B } from "express";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import x from "express-session";
|
|
8
|
+
import { express as P } from "express-useragent";
|
|
9
9
|
import b from "graphql-upload/graphqlUploadExpress.mjs";
|
|
10
|
-
var
|
|
10
|
+
var E = Object.defineProperty, l = Object.getOwnPropertySymbols, m = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable, p = (e, r, t) => r in e ? E(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, g = (e, r) => {
|
|
11
11
|
for (var t in r || (r = {}))
|
|
12
12
|
m.call(r, t) && p(e, t, r[t]);
|
|
13
13
|
if (l)
|
|
@@ -23,59 +23,59 @@ var g = Object.defineProperty, l = Object.getOwnPropertySymbols, m = Object.prot
|
|
|
23
23
|
r.indexOf(s) < 0 && v.call(e, s) && (t[s] = e[s]);
|
|
24
24
|
return t;
|
|
25
25
|
}, A = (e, r, t) => new Promise((s, a) => {
|
|
26
|
-
var
|
|
26
|
+
var n = (i) => {
|
|
27
27
|
try {
|
|
28
|
-
f(t.next(
|
|
28
|
+
f(t.next(i));
|
|
29
29
|
} catch (u) {
|
|
30
30
|
a(u);
|
|
31
31
|
}
|
|
32
|
-
}, o = (
|
|
32
|
+
}, o = (i) => {
|
|
33
33
|
try {
|
|
34
|
-
f(t.throw(
|
|
34
|
+
f(t.throw(i));
|
|
35
35
|
} catch (u) {
|
|
36
36
|
a(u);
|
|
37
37
|
}
|
|
38
|
-
}, f = (
|
|
38
|
+
}, f = (i) => i.done ? s(i.value) : Promise.resolve(i.value).then(n, o);
|
|
39
39
|
f((t = t.apply(e, r)).next());
|
|
40
40
|
});
|
|
41
41
|
function I(e) {
|
|
42
42
|
var r = e, { isDev: t, whiteList: s } = r, a = S(r, ["isDev", "whiteList"]);
|
|
43
|
-
return
|
|
44
|
-
origin: (
|
|
45
|
-
t || !
|
|
43
|
+
return g({
|
|
44
|
+
origin: (n, o) => {
|
|
45
|
+
t || !n || s != null && s.includes(n != null ? n : "") ? o(null, !0) : o(new Error("Not allowed by CORS"), !1);
|
|
46
46
|
},
|
|
47
47
|
credentials: !0
|
|
48
48
|
}, a);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function $(e) {
|
|
51
51
|
return h(I(e));
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
53
|
+
function q(e) {
|
|
54
|
+
return x(e);
|
|
55
55
|
}
|
|
56
56
|
function d(e) {
|
|
57
|
-
e.set("trust proxy", 1), e.use(O()), e.use(c.urlencoded({ extended: !0 })), e.use(w()), e.use(
|
|
57
|
+
e.set("trust proxy", 1), e.use(O()), e.use(c.urlencoded({ extended: !0 })), e.use(w()), e.use(P());
|
|
58
58
|
}
|
|
59
59
|
function _(e, r) {
|
|
60
60
|
r && (Array.isArray(r) ? r : [r]).forEach((s) => {
|
|
61
61
|
e.use(`/${s}`, c.static(s));
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function M(e) {
|
|
65
65
|
const r = c();
|
|
66
66
|
return d(r), _(r, e == null ? void 0 : e.static), r.use(b()), r;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function U(e) {
|
|
69
69
|
return A(this, null, function* () {
|
|
70
70
|
const r = yield y.create(e.module);
|
|
71
71
|
return d(r.getHttpAdapter().getInstance()), _(r.getHttpAdapter().getInstance(), e.static), e.filters && r.useGlobalFilters(...e.filters), e.pipes && r.useGlobalPipes(...e.pipes), r;
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
export {
|
|
75
|
-
|
|
75
|
+
$ as createCors,
|
|
76
76
|
I as createCorsOptions,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
M as createExpress,
|
|
78
|
+
U as createNest,
|
|
79
|
+
q as createSession,
|
|
80
80
|
B as express
|
|
81
81
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DeleteResult, Filter, InsertManyResult, InsertOneResult, OptionalUnlessRequiredId, UpdateResult, WithId, Collection, Db } from 'mongodb';
|
|
2
|
-
import { AggregatePaginateModel, AggregatePaginateResult, ClientSession, ErrorHandlingMiddlewareFunction, ErrorHandlingMiddlewareWithOption,
|
|
2
|
+
import { AggregatePaginateModel, AggregatePaginateResult, ClientSession, ErrorHandlingMiddlewareFunction, ErrorHandlingMiddlewareWithOption, InsertManyOptions, PaginateModel, PaginateOptions, PaginateResult, PipelineStage, PopulateOption, PopulateOptions, PostMiddlewareFunction, PreMiddlewareFunction, PreSaveMiddlewareFunction, ProjectionType, QueryFilter, QueryOptions, QueryWithHelpers, Schema, SchemaDefinition, UpdateQuery, UpdateWriteOpResult, default as mongoose, Document, Model } from 'mongoose';
|
|
3
3
|
export declare class C_Db extends Db {
|
|
4
4
|
}
|
|
5
5
|
export type T_Filter<T> = Filter<T>;
|
|
6
6
|
export type T_InsertOneResult<T> = InsertOneResult<T>;
|
|
7
7
|
export type T_InsertManyResult<T> = InsertManyResult<T>;
|
|
8
|
-
export type T_UpdateResult = UpdateResult;
|
|
8
|
+
export type T_UpdateResult = UpdateResult | UpdateWriteOpResult;
|
|
9
9
|
export type T_DeleteResult = DeleteResult;
|
|
10
10
|
export type T_WithId<T> = WithId<T>;
|
|
11
11
|
export type T_OptionalUnlessRequiredId<T> = OptionalUnlessRequiredId<T>;
|
|
@@ -17,7 +17,7 @@ export declare class C_Collection<T extends Partial<C_Document>> extends Collect
|
|
|
17
17
|
}
|
|
18
18
|
export interface I_ExtendedModel<T extends Partial<C_Document>> extends Model<T>, PaginateModel<T>, AggregatePaginateModel<T> {
|
|
19
19
|
}
|
|
20
|
-
export type T_FilterQuery<T> =
|
|
20
|
+
export type T_FilterQuery<T> = QueryFilter<T>;
|
|
21
21
|
export type T_ProjectionType<T> = ProjectionType<T>;
|
|
22
22
|
export type T_QueryOptions<T> = QueryOptions<T>;
|
|
23
23
|
export type T_PaginateOptions = PaginateOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("lodash-es"),J=require("migrate-mongo"),X=require("mongoose-aggregate-paginate-v2"),Y=require("mongoose-paginate-v2"),k=require("uuid"),Z=require("./mongo.constant.cjs"),F=require("../../util/object/object.util.cjs"),tt=require("../../util/common/common.util.cjs"),$=require("../fs/fs.util.cjs"),T=require("../path/path.constant.cjs"),et=require("../../util/validate/validate.util.cjs"),C=require("../../util/string/string.util.cjs"),V=require("../../constant/response-status.cjs"),N=require("../log/log.util.cjs");var rt=Object.defineProperty,st=Object.defineProperties,nt=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,L=(n,e,t)=>e in n?rt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,A=(n,e)=>{for(var t in e||(e={}))it.call(e,t)&&L(n,t,e[t]);if(B)for(var t of B(e))ot.call(e,t)&&L(n,t,e[t]);return n},x=(n,e)=>st(n,nt(e)),lt=(n,e,t)=>L(n,typeof e!="symbol"?e+"":e,t),v=(n,e,t)=>new Promise((r,s)=>{var i=c=>{try{l(t.next(c))}catch(a){s(a)}},o=c=>{try{l(t.throw(c))}catch(a){s(a)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);l((t=t.apply(n,e)).next())});function M(n){return n===n.toUpperCase()?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():n}const P={createGenericFields(){return{id:k.v4(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(n,e){e.filter(t=>typeof t=="function").forEach(t=>n.plugin(t))},applyMiddlewares(n,e){e.forEach(({method:t,pre:r,post:s})=>{t&&r&&n.pre(t,r),t&&s&&n.post(t,s)})},createGenericSchema(n){return new n.Schema({id:{type:String,default:k.v4,unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:n,schema:e,virtuals:t=[],standalone:r=!1}){const s=new n.Schema(e,{toJSON:{virtuals:!0},toObject:{virtuals:!0}});return t.forEach(({name:i,options:o,get:l})=>{if(P.isDynamicVirtual(o)){const c=s.statics;c._dynamicVirtuals||(c._dynamicVirtuals=[]),c._dynamicVirtuals.push({name:i,options:o});const a=s.virtual(i);l?a.get(l):a.get(function(){var u;return((u=this._populated)==null?void 0:u[i])||(o!=null&&o.count?0:o!=null&&o.justOne?null:[])})}else{const c=s.virtual(i,o);l&&c.get(l)}}),r||s.add(P.createGenericSchema(n)),s},createModel({mongoose:n,name:e,schema:t,virtuals:r=[],pagination:s=!0,aggregate:i=!0,middlewares:o=[]}){if(!e)throw new Error("Model name is required.");if(n.models[e])return n.models[e];const l=P.createSchema({mongoose:n,schema:t,virtuals:r});(s||i)&&P.applyPlugins(l,[s&&Y,i&&X]),P.applyMiddlewares(l,o);const c=n.model(e,l);return r.length>0&&(c._virtualConfigs=r),c},validator:{isRequired(){return function(n){return v(this,null,function*(){return!et.validate.isEmpty(n)})}},isUnique(n){return function(e){return v(this,null,function*(){if(!Array.isArray(n)||n.length===0)throw new Error("Fields must be a non-empty array of strings.");const t={$or:n.map(s=>({[s]:e}))};return!(yield this.constructor.exists(t))})}},matchesRegex(n){return e=>v(null,null,function*(){if(!Array.isArray(n)||n.some(t=>!(t instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return n.every(t=>t.test(e))})}},migrate:x(A({},J),{setConfig:n=>{const e=`// This file is automatically generated by the Cyberskill CLI.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("lodash-es"),J=require("migrate-mongo"),X=require("mongoose-aggregate-paginate-v2"),Y=require("mongoose-paginate-v2"),k=require("uuid"),Z=require("./mongo.constant.cjs"),F=require("../../util/object/object.util.cjs"),tt=require("../../util/common/common.util.cjs"),$=require("../fs/fs.util.cjs"),T=require("../path/path.constant.cjs"),et=require("../../util/validate/validate.util.cjs"),C=require("../../util/string/string.util.cjs"),V=require("../../constant/response-status.cjs"),N=require("../log/log.util.cjs");var rt=Object.defineProperty,st=Object.defineProperties,nt=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,L=(n,e,t)=>e in n?rt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,A=(n,e)=>{for(var t in e||(e={}))it.call(e,t)&&L(n,t,e[t]);if(B)for(var t of B(e))ot.call(e,t)&&L(n,t,e[t]);return n},x=(n,e)=>st(n,nt(e)),lt=(n,e,t)=>L(n,typeof e!="symbol"?e+"":e,t),v=(n,e,t)=>new Promise((r,s)=>{var i=c=>{try{l(t.next(c))}catch(a){s(a)}},o=c=>{try{l(t.throw(c))}catch(a){s(a)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);l((t=t.apply(n,e)).next())});function M(n){return n===n.toUpperCase()?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():n}const P={createGenericFields(){return{id:k.v4(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(n,e){e.filter(t=>typeof t=="function").forEach(t=>n.plugin(t))},applyMiddlewares(n,e){e.forEach(({method:t,pre:r,post:s})=>{t&&r&&n.pre(t,r),t&&s&&n.post(t,s)})},createGenericSchema(n){return new n.Schema({id:{type:String,default:()=>k.v4(),unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:n,schema:e,virtuals:t=[],standalone:r=!1}){const s=new n.Schema(e,{toJSON:{virtuals:!0},toObject:{virtuals:!0}});return t.forEach(({name:i,options:o,get:l})=>{if(P.isDynamicVirtual(o)){const c=s.statics;c._dynamicVirtuals||(c._dynamicVirtuals=[]),c._dynamicVirtuals.push({name:i,options:o});const a=s.virtual(i);l?a.get(l):a.get(function(){var u;return((u=this._populated)==null?void 0:u[i])||(o!=null&&o.count?0:o!=null&&o.justOne?null:[])})}else{const c=s.virtual(i,o);l&&c.get(l)}}),r||s.add(P.createGenericSchema(n)),s},createModel({mongoose:n,name:e,schema:t,virtuals:r=[],pagination:s=!0,aggregate:i=!0,middlewares:o=[]}){if(!e)throw new Error("Model name is required.");if(n.models[e])return n.models[e];const l=P.createSchema({mongoose:n,schema:t,virtuals:r});(s||i)&&P.applyPlugins(l,[s&&Y,i&&X]),P.applyMiddlewares(l,o);const c=n.model(e,l);return r.length>0&&(c._virtualConfigs=r),c},validator:{isRequired(){return function(n){return v(this,null,function*(){return!et.validate.isEmpty(n)})}},isUnique(n){return function(e){return v(this,null,function*(){if(!Array.isArray(n)||n.length===0)throw new Error("Fields must be a non-empty array of strings.");const t={$or:n.map(s=>({[s]:e}))};return!(yield this.constructor.exists(t))})}},matchesRegex(n){return e=>v(null,null,function*(){if(!Array.isArray(n)||n.some(t=>!(t instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return n.every(t=>t.test(e))})}},migrate:x(A({},J),{setConfig:n=>{const e=`// This file is automatically generated by the Cyberskill CLI.
|
|
2
2
|
module.exports = ${JSON.stringify(n,null,4)}`;$.writeFileSync(T.PATH.MIGRATE_MONGO_CONFIG,e);const t=`
|
|
3
3
|
${T.MIGRATE_MONGO_CONFIG}
|
|
4
4
|
`;$.pathExistsSync(T.PATH.GIT_IGNORE)?$.readFileSync(T.PATH.GIT_IGNORE,"utf-8").split(`
|