@cyberskill/shared 2.21.0 → 2.26.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.cjs +1 -1
- package/dist/config/eslint/index.d.ts +2 -7
- package/dist/config/eslint/index.js +1 -1
- 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/config/vitest/vitest.unit.setup.d.ts +0 -1
- package/dist/node/cli/index.cjs +4 -4
- package/dist/node/cli/index.js +56 -51
- package/dist/node/command/command.util.cjs +2 -2
- package/dist/node/command/command.util.d.ts +4 -1
- package/dist/node/command/command.util.js +125 -112
- package/dist/node/express/express.type.d.ts +2 -0
- package/dist/node/express/express.util.cjs +1 -1
- package/dist/node/express/express.util.js +53 -47
- package/dist/node/mongo/index.cjs +1 -1
- package/dist/node/mongo/index.d.ts +1 -0
- package/dist/node/mongo/index.js +15 -12
- package/dist/node/mongo/mongo.controller.cjs +1 -0
- package/dist/node/mongo/mongo.controller.d.ts +317 -0
- package/dist/node/mongo/mongo.controller.js +956 -0
- package/dist/node/mongo/mongo.type.d.ts +9 -10
- package/dist/node/mongo/mongo.util.cjs +5 -5
- package/dist/node/mongo/mongo.util.d.ts +26 -315
- package/dist/node/mongo/mongo.util.js +314 -1241
- package/dist/node/path/path.constant.cjs +1 -1
- package/dist/node/path/path.constant.d.ts +2 -2
- package/dist/node/path/path.constant.js +43 -43
- package/dist/util/common/common.util.cjs +1 -1
- package/dist/util/common/common.util.d.ts +3 -0
- package/dist/util/common/common.util.js +36 -35
- package/dist/util/object/object.util.cjs +1 -1
- package/dist/util/object/object.util.js +49 -45
- package/dist/util/validate/validate.util.cjs +1 -1
- package/dist/util/validate/validate.util.js +1 -1
- package/package.json +25 -24
- /package/dist/node/mongo/{mongo-controller.test.unit.d.ts → mongo.controller.test.unit.d.ts} +0 -0
- /package/dist/node/mongo/{mongo.test.unit.d.ts → mongo.util.test.unit.d.ts} +0 -0
- /package/dist/node_modules/.pnpm/{vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.cjs +0 -0
- /package/dist/node_modules/.pnpm/{vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
|
@@ -1,175 +1,188 @@
|
|
|
1
|
-
import { exec as
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import { storage as
|
|
5
|
-
import { getPackage as
|
|
6
|
-
import { CYBERSKILL_PACKAGE_NAME as
|
|
7
|
-
import { E_IssueType as
|
|
8
|
-
import { catchError as
|
|
9
|
-
import { getEnv as
|
|
10
|
-
var
|
|
11
|
-
var
|
|
1
|
+
import { exec as A } from "node:child_process";
|
|
2
|
+
import p from "node:process";
|
|
3
|
+
import * as K from "node:util";
|
|
4
|
+
import { storage as y } from "../storage/storage.util.js";
|
|
5
|
+
import { getPackage as B } from "../package/package.util.js";
|
|
6
|
+
import { CYBERSKILL_PACKAGE_NAME as M, PNPM_EXEC_CLI as T, TSX_CLI as O, CYBERSKILL_CLI_PATH as R, CYBERSKILL_CLI as b } from "../path/path.constant.js";
|
|
7
|
+
import { E_IssueType as f } from "../log/log.type.js";
|
|
8
|
+
import { catchError as E, log as h } from "../log/log.util.js";
|
|
9
|
+
import { getEnv as N } from "../../config/env/env.util.js";
|
|
10
|
+
var a = (r, t, e) => new Promise((s, i) => {
|
|
11
|
+
var o = (u) => {
|
|
12
12
|
try {
|
|
13
|
-
n(e.next(
|
|
14
|
-
} catch (
|
|
15
|
-
|
|
13
|
+
n(e.next(u));
|
|
14
|
+
} catch (c) {
|
|
15
|
+
i(c);
|
|
16
16
|
}
|
|
17
|
-
},
|
|
17
|
+
}, l = (u) => {
|
|
18
18
|
try {
|
|
19
|
-
n(e.throw(
|
|
20
|
-
} catch (
|
|
21
|
-
|
|
19
|
+
n(e.throw(u));
|
|
20
|
+
} catch (c) {
|
|
21
|
+
i(c);
|
|
22
22
|
}
|
|
23
|
-
}, n = (
|
|
23
|
+
}, n = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(o, l);
|
|
24
24
|
n((e = e.apply(r, t)).next());
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
return
|
|
29
|
-
const r = yield
|
|
26
|
+
const G = K.promisify(A);
|
|
27
|
+
function v() {
|
|
28
|
+
return a(this, null, function* () {
|
|
29
|
+
const r = yield B();
|
|
30
30
|
return r.success ? r.result.name : Date.now().toString();
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function j(r) {
|
|
34
|
+
return a(this, null, function* () {
|
|
35
35
|
if (r.length === 0)
|
|
36
36
|
return;
|
|
37
|
-
const t = yield
|
|
37
|
+
const t = yield v();
|
|
38
38
|
try {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const s = [...yield W(), ...r];
|
|
40
|
+
yield y.set(t, s), setTimeout(() => a(null, null, function* () {
|
|
41
|
+
const i = yield y.getLogLink(t);
|
|
42
|
+
i && h.info(`📂 Open the error list manually: ${i}`);
|
|
42
43
|
}), 0);
|
|
43
44
|
} catch (e) {
|
|
44
|
-
|
|
45
|
+
E(e);
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
49
|
+
function W() {
|
|
50
|
+
return a(this, null, function* () {
|
|
50
51
|
try {
|
|
51
|
-
const r = yield
|
|
52
|
+
const r = yield v(), t = yield y.get(r);
|
|
52
53
|
return t != null ? t : [];
|
|
53
54
|
} catch (r) {
|
|
54
|
-
return
|
|
55
|
+
return E(r, {
|
|
55
56
|
returnValue: []
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
-
return
|
|
61
|
+
function rr() {
|
|
62
|
+
return a(this, null, function* () {
|
|
62
63
|
try {
|
|
63
|
-
const r = yield
|
|
64
|
-
yield
|
|
64
|
+
const r = yield v();
|
|
65
|
+
yield y.remove(r);
|
|
65
66
|
} catch (r) {
|
|
66
|
-
|
|
67
|
+
E(r);
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
function U(r) {
|
|
72
|
+
return a(this, null, function* () {
|
|
73
|
+
const t = [], e = [];
|
|
74
|
+
let s = "";
|
|
75
|
+
const i = /^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/, o = /^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/, l = /^✖\s+(.*?)\s+\[(.*?)\]$/;
|
|
76
|
+
r.split(`
|
|
75
77
|
`).forEach((n) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
78
|
+
var u, c, _, $, C, w, L, P, x, I, S;
|
|
79
|
+
if (n.startsWith("/"))
|
|
80
|
+
s = n.trim();
|
|
81
|
+
else {
|
|
82
|
+
const m = i.exec(n) || [], d = o.exec(n) || [], g = l.exec(n) || [];
|
|
83
|
+
m.length && s ? t.push({
|
|
84
|
+
file: s,
|
|
85
|
+
position: `${m[1]}:${m[2]}`,
|
|
86
|
+
type: m[3] === f.Error ? f.Error : f.Warning,
|
|
87
|
+
message: (c = (u = m == null ? void 0 : m[4]) == null ? void 0 : u.trim()) != null ? c : "",
|
|
88
|
+
rule: ($ = (_ = m == null ? void 0 : m[5]) == null ? void 0 : _.trim()) != null ? $ : ""
|
|
89
|
+
}) : d.length ? t.push({
|
|
90
|
+
file: (C = d == null ? void 0 : d[1]) != null ? C : "",
|
|
91
|
+
position: `${d[2]}:${d[3]}`,
|
|
92
|
+
type: d[4] === f.Error ? f.Error : f.Warning,
|
|
93
|
+
message: (L = (w = d == null ? void 0 : d[5]) == null ? void 0 : w.trim()) != null ? L : ""
|
|
94
|
+
}) : g.length ? t.push({
|
|
95
|
+
file: "commitlint",
|
|
96
|
+
type: f.Error,
|
|
97
|
+
message: (x = (P = g == null ? void 0 : g[1]) == null ? void 0 : P.trim()) != null ? x : "",
|
|
98
|
+
rule: (S = (I = g == null ? void 0 : g[2]) == null ? void 0 : I.trim()) != null ? S : ""
|
|
99
|
+
}) : e.push(n.trim());
|
|
100
|
+
}
|
|
101
|
+
}), t.length && (yield j(t)), N().DEBUG && e.length && (h.warn("Unmatched lines:"), e.forEach((n) => h.info(` ${n}`)));
|
|
102
|
+
});
|
|
100
103
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
function D(r) {
|
|
105
|
+
return a(this, null, function* () {
|
|
106
|
+
try {
|
|
107
|
+
const t = JSON.parse(r), e = [];
|
|
108
|
+
t.forEach(({ filePath: s, messages: i }) => {
|
|
109
|
+
i.forEach(({ severity: o, line: l, column: n, ruleId: u, message: c }) => {
|
|
110
|
+
e.push({
|
|
111
|
+
type: o === 2 ? f.Error : f.Warning,
|
|
112
|
+
file: s,
|
|
113
|
+
position: `${l}:${n}`,
|
|
114
|
+
rule: u,
|
|
115
|
+
message: c
|
|
116
|
+
});
|
|
112
117
|
});
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
+
}), e.length && (yield j(e));
|
|
119
|
+
} catch (t) {
|
|
120
|
+
yield U(r);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
118
123
|
}
|
|
119
124
|
function Y(r) {
|
|
120
|
-
return
|
|
125
|
+
return a(this, arguments, function* (t, e = D, s = {}) {
|
|
121
126
|
const i = new AbortController();
|
|
122
|
-
|
|
123
|
-
h.warn("Process interrupted. Terminating..."), i.abort(),
|
|
127
|
+
p.on("SIGINT", () => {
|
|
128
|
+
h.warn("Process interrupted. Terminating..."), i.abort(), p.exit();
|
|
124
129
|
});
|
|
125
130
|
try {
|
|
126
131
|
if (typeof t == "string") {
|
|
127
|
-
const { stdout:
|
|
132
|
+
const { stdout: o, stderr: l } = yield G(t, {
|
|
128
133
|
maxBuffer: 104857600,
|
|
129
|
-
signal: i.signal
|
|
134
|
+
signal: i.signal,
|
|
135
|
+
timeout: s.timeout
|
|
130
136
|
});
|
|
131
|
-
[
|
|
137
|
+
yield Promise.all([o, l].map((n) => n && e(n)));
|
|
132
138
|
}
|
|
133
|
-
} catch (
|
|
134
|
-
const { stdout: l, stderr:
|
|
135
|
-
[l,
|
|
139
|
+
} catch (o) {
|
|
140
|
+
const { stdout: l, stderr: n, message: u } = o;
|
|
141
|
+
yield Promise.all([l, n].map((c) => c && e(c))), !n && !l && h.error(`Command failed: ${u}`);
|
|
136
142
|
}
|
|
137
143
|
});
|
|
138
144
|
}
|
|
139
|
-
function
|
|
145
|
+
function tr(r) {
|
|
140
146
|
return { raw: !0, cmd: r };
|
|
141
147
|
}
|
|
142
|
-
function
|
|
143
|
-
return t != null && t.isCurrentProject ? `${
|
|
148
|
+
function k(r, t) {
|
|
149
|
+
return t != null && t.isCurrentProject ? `${T} ${O} ${R} ${r}` : `${T} ${b} ${r}`;
|
|
144
150
|
}
|
|
145
151
|
function X(r, t) {
|
|
146
|
-
return typeof r == "function" ?
|
|
152
|
+
return typeof r == "function" ? k(r(t), t) : typeof r == "object" && (r == null ? void 0 : r.raw) === !0 ? r.cmd : typeof r == "string" ? k(r, t) : r;
|
|
147
153
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
150
|
-
const t = yield
|
|
154
|
+
function er(r) {
|
|
155
|
+
return a(this, null, function* () {
|
|
156
|
+
const t = yield B({ name: M });
|
|
151
157
|
if (t.success) {
|
|
152
|
-
const e = { isCurrentProject: t.result.isCurrentProject },
|
|
158
|
+
const e = { isCurrentProject: t.result.isCurrentProject }, s = typeof r == "function" ? r(e) : r;
|
|
153
159
|
return Object.fromEntries(
|
|
154
|
-
Object.entries(
|
|
160
|
+
Object.entries(s).map(([i, o]) => [i, X(o, e)])
|
|
155
161
|
);
|
|
156
162
|
}
|
|
157
163
|
});
|
|
158
164
|
}
|
|
159
|
-
function
|
|
160
|
-
return
|
|
165
|
+
function nr(r, t) {
|
|
166
|
+
return a(this, arguments, function* (e, s, i = {}) {
|
|
167
|
+
let o;
|
|
161
168
|
try {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
const l = Date.now();
|
|
170
|
+
h.start(`${e}`), N().DEBUG ? h.info(`→ ${s}`) : o = setInterval(() => {
|
|
171
|
+
const n = Math.floor((Date.now() - l) / 1e3);
|
|
172
|
+
n > 0 && p.stdout.write(`\r⏳ ${e}... ${n}s`);
|
|
173
|
+
}, 100), yield Y(s, D, i), o && (clearInterval(o), p.stdout.write("\r\x1B[K")), h.success(`${e} done.`);
|
|
174
|
+
} catch (l) {
|
|
175
|
+
if (o && (clearInterval(o), p.stdout.write("\r\x1B[K")), i.throwOnError)
|
|
176
|
+
throw l;
|
|
177
|
+
E(l);
|
|
165
178
|
}
|
|
166
179
|
});
|
|
167
180
|
}
|
|
168
181
|
export {
|
|
169
|
-
|
|
182
|
+
rr as clearAllErrorLists,
|
|
170
183
|
X as formatCommand,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
184
|
+
W as getStoredErrorLists,
|
|
185
|
+
tr as rawCommand,
|
|
186
|
+
er as resolveCommands,
|
|
187
|
+
nr as runCommand
|
|
175
188
|
};
|
|
@@ -4,10 +4,12 @@ import { CorsOptions, CorsOptionsDelegate, CorsRequest } from 'cors';
|
|
|
4
4
|
export type { NextFunction, Request, Response } from 'express';
|
|
5
5
|
export { Router } from 'express';
|
|
6
6
|
export interface I_ExpressOptions {
|
|
7
|
+
isDev?: boolean;
|
|
7
8
|
static?: string | string[];
|
|
8
9
|
}
|
|
9
10
|
export interface I_NestOptions {
|
|
10
11
|
module: Type<object>;
|
|
12
|
+
isDev?: boolean;
|
|
11
13
|
static?: string | string[];
|
|
12
14
|
filters?: ExceptionFilter[];
|
|
13
15
|
pipes?: ValidationPipe[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("@nestjs/core"),m=require("compression"),h=require("cookie-parser"),w=require("cors"),c=require("express"),q=require("express-session"),x=require("express-useragent"),b=require("graphql-upload/graphqlUploadExpress.mjs"),g=require("helmet");var S=Object.defineProperty,u=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,r,t)=>r in e?S(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,E=(e,r)=>{for(var t in r||(r={}))v.call(r,t)&&d(e,t,r[t]);if(u)for(var t of u(r))p.call(r,t)&&d(e,t,r[t]);return e},C=(e,r)=>{var t={};for(var s in e)v.call(e,s)&&r.indexOf(s)<0&&(t[s]=e[s]);if(e!=null&&u)for(var s of u(e))r.indexOf(s)<0&&p.call(e,s)&&(t[s]=e[s]);return t},N=(e,r,t)=>new Promise((s,a)=>{var n=i=>{try{o(t.next(i))}catch(f){a(f)}},l=i=>{try{o(t.throw(i))}catch(f){a(f)}},o=i=>i.done?s(i.value):Promise.resolve(i.value).then(n,l);o((t=t.apply(e,r)).next())});function y(e){var r=e,{isDev:t,whiteList:s}=r,a=C(r,["isDev","whiteList"]);return E({origin:(n,l)=>{t||!n||s!=null&&s.includes(n!=null?n:"")?l(null,!0):l(new Error("Not allowed by CORS"),!1)},credentials:!0},a)}function j(e){return w(y(e))}function A(e){return q(e)}function _(e,r=!1){e.set("trust proxy",1),e.use(g({crossOriginEmbedderPolicy:r?!1:void 0,contentSecurityPolicy:r?!1:void 0})),e.use(h()),e.use(c.urlencoded({extended:!0})),e.use(m()),e.use(x.express())}function O(e,r){r&&(Array.isArray(r)?r:[r]).forEach(s=>{e.use(`/${s}`,c.static(s))})}function I(e){const r=c();return _(r,e==null?void 0:e.isDev),O(r,e==null?void 0:e.static),r.use(b()),r}function D(e){return N(this,null,function*(){const r=yield P.NestFactory.create(e.module);return _(r.getHttpAdapter().getInstance(),e.isDev),O(r.getHttpAdapter().getInstance(),e.static),e.filters&&r.useGlobalFilters(...e.filters),e.pipes&&r.useGlobalPipes(...e.pipes),r})}exports.express=c;exports.createCors=j;exports.createCorsOptions=y;exports.createExpress=I;exports.createNest=D;exports.createSession=A;
|
|
@@ -1,81 +1,87 @@
|
|
|
1
|
-
import { NestFactory as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { NestFactory as _ } from "@nestjs/core";
|
|
2
|
+
import O from "compression";
|
|
3
|
+
import P from "cookie-parser";
|
|
4
4
|
import h from "cors";
|
|
5
5
|
import c from "express";
|
|
6
|
-
import { default as
|
|
7
|
-
import
|
|
8
|
-
import { express as
|
|
6
|
+
import { default as J } from "express";
|
|
7
|
+
import w from "express-session";
|
|
8
|
+
import { express as x } from "express-useragent";
|
|
9
9
|
import b from "graphql-upload/graphqlUploadExpress.mjs";
|
|
10
|
-
|
|
10
|
+
import E from "helmet";
|
|
11
|
+
var g = Object.defineProperty, o = Object.getOwnPropertySymbols, p = Object.prototype.hasOwnProperty, d = Object.prototype.propertyIsEnumerable, m = (e, r, t) => r in e ? g(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, S = (e, r) => {
|
|
11
12
|
for (var t in r || (r = {}))
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
for (var t of
|
|
15
|
-
|
|
13
|
+
p.call(r, t) && m(e, t, r[t]);
|
|
14
|
+
if (o)
|
|
15
|
+
for (var t of o(r))
|
|
16
|
+
d.call(r, t) && m(e, t, r[t]);
|
|
16
17
|
return e;
|
|
17
|
-
},
|
|
18
|
+
}, A = (e, r) => {
|
|
18
19
|
var t = {};
|
|
19
20
|
for (var s in e)
|
|
20
|
-
|
|
21
|
-
if (e != null &&
|
|
22
|
-
for (var s of
|
|
23
|
-
r.indexOf(s) < 0 &&
|
|
21
|
+
p.call(e, s) && r.indexOf(s) < 0 && (t[s] = e[s]);
|
|
22
|
+
if (e != null && o)
|
|
23
|
+
for (var s of o(e))
|
|
24
|
+
r.indexOf(s) < 0 && d.call(e, s) && (t[s] = e[s]);
|
|
24
25
|
return t;
|
|
25
|
-
},
|
|
26
|
-
var
|
|
26
|
+
}, I = (e, r, t) => new Promise((s, n) => {
|
|
27
|
+
var a = (i) => {
|
|
27
28
|
try {
|
|
28
29
|
f(t.next(i));
|
|
29
30
|
} catch (u) {
|
|
30
|
-
|
|
31
|
+
n(u);
|
|
31
32
|
}
|
|
32
|
-
},
|
|
33
|
+
}, l = (i) => {
|
|
33
34
|
try {
|
|
34
35
|
f(t.throw(i));
|
|
35
36
|
} catch (u) {
|
|
36
|
-
|
|
37
|
+
n(u);
|
|
37
38
|
}
|
|
38
|
-
}, f = (i) => i.done ? s(i.value) : Promise.resolve(i.value).then(
|
|
39
|
+
}, f = (i) => i.done ? s(i.value) : Promise.resolve(i.value).then(a, l);
|
|
39
40
|
f((t = t.apply(e, r)).next());
|
|
40
41
|
});
|
|
41
|
-
function
|
|
42
|
-
var r = e, { isDev: t, whiteList: s } = r,
|
|
43
|
-
return
|
|
44
|
-
origin: (
|
|
45
|
-
t || !
|
|
42
|
+
function N(e) {
|
|
43
|
+
var r = e, { isDev: t, whiteList: s } = r, n = A(r, ["isDev", "whiteList"]);
|
|
44
|
+
return S({
|
|
45
|
+
origin: (a, l) => {
|
|
46
|
+
t || !a || s != null && s.includes(a != null ? a : "") ? l(null, !0) : l(new Error("Not allowed by CORS"), !1);
|
|
46
47
|
},
|
|
47
48
|
credentials: !0
|
|
48
|
-
},
|
|
49
|
+
}, n);
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
return h(
|
|
51
|
+
function M(e) {
|
|
52
|
+
return h(N(e));
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
54
|
+
function U(e) {
|
|
55
|
+
return w(e);
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
-
e.set("trust proxy", 1), e.use(
|
|
57
|
+
function v(e, r = !1) {
|
|
58
|
+
e.set("trust proxy", 1), e.use(
|
|
59
|
+
E({
|
|
60
|
+
crossOriginEmbedderPolicy: r ? !1 : void 0,
|
|
61
|
+
contentSecurityPolicy: r ? !1 : void 0
|
|
62
|
+
})
|
|
63
|
+
), e.use(P()), e.use(c.urlencoded({ extended: !0 })), e.use(O()), e.use(x());
|
|
58
64
|
}
|
|
59
|
-
function
|
|
65
|
+
function y(e, r) {
|
|
60
66
|
r && (Array.isArray(r) ? r : [r]).forEach((s) => {
|
|
61
67
|
e.use(`/${s}`, c.static(s));
|
|
62
68
|
});
|
|
63
69
|
}
|
|
64
|
-
function
|
|
70
|
+
function V(e) {
|
|
65
71
|
const r = c();
|
|
66
|
-
return
|
|
72
|
+
return v(r, e == null ? void 0 : e.isDev), y(r, e == null ? void 0 : e.static), r.use(b()), r;
|
|
67
73
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
70
|
-
const r = yield
|
|
71
|
-
return
|
|
74
|
+
function z(e) {
|
|
75
|
+
return I(this, null, function* () {
|
|
76
|
+
const r = yield _.create(e.module);
|
|
77
|
+
return v(r.getHttpAdapter().getInstance(), e.isDev), y(r.getHttpAdapter().getInstance(), e.static), e.filters && r.useGlobalFilters(...e.filters), e.pipes && r.useGlobalPipes(...e.pipes), r;
|
|
72
78
|
});
|
|
73
79
|
}
|
|
74
80
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
M as createCors,
|
|
82
|
+
N as createCorsOptions,
|
|
83
|
+
V as createExpress,
|
|
84
|
+
z as createNest,
|
|
85
|
+
U as createSession,
|
|
86
|
+
J as express
|
|
81
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./mongo.constant.cjs"),o=require("./mongo.type.cjs"),e=require("./mongo.util.cjs");exports.MONGO_MIGRATE_OPTIONS=n.MONGO_MIGRATE_OPTIONS;exports.MONGO_SLUG_MAX_ATTEMPTS=n.MONGO_SLUG_MAX_ATTEMPTS;exports.C_Collection=o.C_Collection;exports.C_Db=o.C_Db;exports.C_Document=o.C_Document;exports.C_Model=o.C_Model;exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./mongo.constant.cjs"),l=require("./mongo.controller.cjs"),o=require("./mongo.type.cjs"),e=require("./mongo.util.cjs");exports.MONGO_MIGRATE_OPTIONS=n.MONGO_MIGRATE_OPTIONS;exports.MONGO_SLUG_MAX_ATTEMPTS=n.MONGO_SLUG_MAX_ATTEMPTS;exports.MongoController=l.MongoController;exports.MongooseController=l.MongooseController;exports.C_Collection=o.C_Collection;exports.C_Db=o.C_Db;exports.C_Document=o.C_Document;exports.C_Model=o.C_Model;exports.applyNestedPopulate=e.applyNestedPopulate;exports.convertEnumToModelName=e.convertEnumToModelName;exports.mongo=e.mongo;
|
package/dist/node/mongo/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { MONGO_MIGRATE_OPTIONS as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { MONGO_MIGRATE_OPTIONS as r, MONGO_SLUG_MAX_ATTEMPTS as t } from "./mongo.constant.js";
|
|
2
|
+
import { MongoController as n, MongooseController as M } from "./mongo.controller.js";
|
|
3
|
+
import { C_Collection as m, C_Db as p, C_Document as C, C_Model as O } from "./mongo.type.js";
|
|
4
|
+
import { applyNestedPopulate as N, convertEnumToModelName as f, mongo as x } from "./mongo.util.js";
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
m as C_Collection,
|
|
7
|
+
p as C_Db,
|
|
8
|
+
C as C_Document,
|
|
9
|
+
O as C_Model,
|
|
10
|
+
r as MONGO_MIGRATE_OPTIONS,
|
|
11
|
+
t as MONGO_SLUG_MAX_ATTEMPTS,
|
|
12
|
+
n as MongoController,
|
|
13
|
+
M as MongooseController,
|
|
14
|
+
N as applyNestedPopulate,
|
|
15
|
+
f as convertEnumToModelName,
|
|
16
|
+
x as mongo
|
|
14
17
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./mongo.constant.cjs"),$=require("./mongo.util.cjs"),M=require("../../util/object/object.util.cjs"),x=require("../../util/string/string.util.cjs"),N=require("../../constant/response-status.cjs"),m=require("../log/log.util.cjs");var W=Object.defineProperty,B=Object.defineProperties,G=Object.getOwnPropertyDescriptors,U=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,w=(l,r,e)=>r in l?W(l,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[r]=e,V=(l,r)=>{for(var e in r||(r={}))K.call(r,e)&&w(l,e,r[e]);if(U)for(var e of U(r))Q.call(r,e)&&w(l,e,r[e]);return l},A=(l,r)=>B(l,G(r)),k=(l,r,e)=>w(l,typeof r!="symbol"?r+"":r,e),f=(l,r,e)=>new Promise((t,s)=>{var n=a=>{try{o(e.next(a))}catch(u){s(u)}},c=a=>{try{o(e.throw(a))}catch(u){s(u)}},o=a=>a.done?t(a.value):Promise.resolve(a.value).then(n,c);o((e=e.apply(l,r)).next())});function z(l){return l!=null&&typeof l=="object"}function C(l,r){if(!l||!r||r.length===0)return l;const e=new Set(r.map(t=>t.name));if(Array.isArray(l)){const t=l.filter(s=>{if(typeof s=="string")return!Array.from(e).some(n=>s===n||s.startsWith(`${n}.`));if(typeof s=="object"&&s!==null){const n=s,c=n.path||n.populate||"";return!Array.from(e).some(o=>c===o||c.startsWith(`${o}.`))}return!0});return t.length>0?t:void 0}if(typeof l=="string")return Array.from(e).some(t=>l===t||l.startsWith(`${t}.`))?void 0:l;if(typeof l=="object"&&l!==null){const t=l,s=t.path||t.populate||"";return Array.from(e).some(n=>s===n||s.startsWith(`${n}.`))?void 0:l}return l}function X(l,r,e){if(!l.length||!r||!(e!=null&&e.ref))return[];const t=new Map;return l.forEach(s=>{try{const n=e.ref(s);if(n==null)return;const c=typeof n=="string"?n:String(n);if(c&&c.trim()!==""){const o=$.convertEnumToModelName(c);t.has(o)||t.set(o,[]),t.get(o).push(s)}}catch(n){m.catchError(new Error(`Dynamic ref function failed for virtual "${r}": ${n instanceof Error?n.message:String(n)}`))}}),Array.from(t.entries()).map(([s,n])=>({model:s,docs:n}))}function J(l){return l!==null&&typeof l=="object"&&"toObject"in l&&typeof l.toObject=="function"}function q(l,r,e,t,s,n){return f(this,null,function*(){if(!r.length||!e.length||!t)return r;const c=e.filter(u=>{if(Array.isArray(t))return t.length>0&&t.some(d=>{if(typeof d=="string")return d===u.name||d.startsWith(`${u.name}.`);if(d&&typeof d=="object"){const i=d,p=i.path||i.populate||"";return p===u.name||p.startsWith(`${u.name}.`)}return!1});if(typeof t=="string")return t===u.name||t.startsWith(`${u.name}.`);if(typeof t=="object"&&t!==null){const d=t,i=d.path||d.populate||"";return i===u.name||i.startsWith(`${u.name}.`)}return!1});if(c.length===0)return r;const o=M.deepClone(r.map(u=>J(u)?u.toObject():u));o.forEach(u=>{c.forEach(({name:d,options:i})=>{d in u||(u[d]=i.count?0:i.justOne?null:[])})});const a=new Map;for(const u of c){const{name:d,options:i}=u,p=X(o,d,i);for(const y of p){a.has(y.model)||a.set(y.model,{virtuals:[],localValueSets:new Map,docsByLocalValue:new Map});const E=a.get(y.model);E.virtuals.find(S=>S.name===d)||(E.virtuals.push(u),E.localValueSets.set(d,new Set));const j=E.localValueSets.get(d);y.docs.forEach(S=>{const O=S[i.localField];if(O!=null){const g=String(O);j.add(g);let h=-1;const D=S;D.id!==void 0?h=o.findIndex(P=>P.id===D.id):D._id!==void 0&&(h=o.findIndex(P=>{var b,_,R,v;return((_=(b=P._id)==null?void 0:b.toString)==null?void 0:_.call(b))===((v=(R=D._id)==null?void 0:R.toString)==null?void 0:v.call(R))})),h!==-1&&(E.docsByLocalValue.has(g)||E.docsByLocalValue.set(g,[]),E.docsByLocalValue.get(g).push(h))}})}}if(yield Promise.all(Array.from(a.entries()).map(u=>f(null,[u],function*([d,i]){const p=l.models[d];if(!p)return;const y=new Set;if(i.localValueSets.forEach(g=>{g.forEach(h=>y.add(h))}),y.size===0)return;const E=[...new Set(i.virtuals.map(g=>g.options.foreignField))],j=Array.from(y);let S;E.length===1?S={[String(E[0])]:{$in:j}}:S={$or:E.map(g=>({[g]:{$in:j}}))};const O=yield p.find(S,s).lean();for(const g of i.virtuals){const{name:h,options:D}=g,P=O.filter(b=>{const _=b[D.foreignField];return _!=null&&y.has(String(_))});if(D.count){const b=new Map;P.forEach(_=>{var R;const v=(R=_[D.foreignField])==null?void 0:R.toString();v&&b.set(v,(b.get(v)||0)+1)}),i.localValueSets.get(h).forEach(_=>{const R=i.docsByLocalValue.get(_)||[],v=b.get(_)||0;R.forEach(T=>{const F=o[T];F[h]===void 0&&(F[h]=v)})})}else{const b=new Map;P.forEach(_=>{var R;const v=(R=_[D.foreignField])==null?void 0:R.toString();v&&(b.has(v)||b.set(v,[]),b.get(v).push(_))}),i.localValueSets.get(h).forEach(_=>{const R=i.docsByLocalValue.get(_)||[],v=b.get(_)||[],T=D.justOne?v[0]||null:v;R.forEach(F=>{const I=o[F];I[h]=T})})}}}))),t){const d=(i=>{const p=Array.isArray(i)?i:[i],y=new Map,E=[];for(const S of p)if(typeof S=="string")if(S.includes(".")){const O=S.split("."),g=O[0]||"",h=O.slice(1).join(".");g&&(y.has(g)||y.set(g,[]),h&&y.get(g).push(h))}else E.push(S);else if(S&&typeof S=="object"){const O=S;if(O.path&&O.path.includes(".")){const g=O.path.split("."),h=g[0]||"",D=g.slice(1).join(".");h&&(y.has(h)||y.set(h,[]),D&&y.get(h).push(D),O.populate&&y.get(h).push(O.populate))}else E.push(S)}const j=[...E];return y.forEach((S,O)=>{const g=[];for(const h of S)(typeof h=="string"||h&&typeof h=="object")&&g.push(h);g.length>0?j.push({path:O,populate:g}):j.push(O)}),j})(t);yield $.applyNestedPopulate(l,o,d,e,n)}return o})}class Y{constructor(r,e){k(this,"collection"),this.collection=r.collection(e)}createOne(r){return f(this,null,function*(){try{const e=V(V({},$.mongo.createGenericFields()),r);return(yield this.collection.insertOne(e)).acknowledged?{success:!0,message:"Document created successfully",result:e}:{success:!1,message:"Document creation failed",code:N.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(e){return m.catchError(e)}})}createMany(r){return f(this,null,function*(){try{const e=r.map(s=>V(V({},$.mongo.createGenericFields()),s)),t=yield this.collection.insertMany(e);return t.insertedCount===0?{success:!1,message:"No documents were inserted",code:N.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:`${t.insertedCount} documents created successfully`,result:e}}catch(e){return m.catchError(e)}})}findOne(r){return f(this,null,function*(){try{const e=yield this.collection.findOne(r);return e?{success:!0,message:"Document found",result:e}:{success:!1,message:"Document not found",code:N.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(e){return m.catchError(e)}})}findAll(){return f(this,arguments,function*(r={}){try{return{success:!0,message:"Documents retrieved successfully",result:yield this.collection.find(r).toArray()}}catch(e){return m.catchError(e)}})}count(){return f(this,arguments,function*(r={}){try{const e=yield this.collection.countDocuments(r);return{success:!0,message:`${e} documents counted successfully`,result:e}}catch(e){return m.catchError(e)}})}updateOne(r,e){return f(this,null,function*(){try{const t=yield this.collection.updateOne(r,{$set:e});return t.matchedCount===0?{success:!1,message:"No documents matched the filter",code:N.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document updated successfully",result:t}}catch(t){return m.catchError(t)}})}updateMany(r,e){return f(this,null,function*(){try{const t=yield this.collection.updateMany(r,{$set:e});return t.matchedCount===0?{success:!1,message:"No documents matched the filter",code:N.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents updated successfully",result:t}}catch(t){return m.catchError(t)}})}deleteOne(r){return f(this,null,function*(){try{const e=yield this.collection.deleteOne(r);return e.deletedCount===0?{success:!1,message:"No documents matched the filter",code:N.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document deleted successfully",result:e}}catch(e){return m.catchError(e)}})}deleteMany(r){return f(this,null,function*(){try{const e=yield this.collection.deleteMany(r);return e.deletedCount===0?{success:!1,message:"No documents matched the filter",code:N.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents deleted successfully",result:e}}catch(e){return m.catchError(e)}})}}class Z{constructor(r){this.model=r}getModelName(){return this.model.modelName}getDynamicVirtuals(){if(this.model._virtualConfigs){const t=this.model._virtualConfigs.filter(s=>{var n;return typeof((n=s.options)==null?void 0:n.ref)=="function"});if(t.length>0)return t}return this.model.schema.statics._dynamicVirtuals}populateDynamicVirtualsForDocument(r,e){return f(this,null,function*(){const t=this.getDynamicVirtuals();if(t&&t.length>0){const s=yield q(this.model.base,[r],t,e,void 0,this.model);return s&&s[0]?s[0]:r}return r})}populateDynamicVirtualsForDocuments(r,e){return f(this,null,function*(){const t=this.getDynamicVirtuals();return t&&t.length>0&&r.length>0?yield q(this.model.base,r,t,e,void 0,this.model):r})}findOne(){return f(this,arguments,function*(r={},e={},t={},s){var n,c;try{const o=M.normalizeMongoFilter(r),a=this.model.findOne(o,e,t),u=this.getDynamicVirtuals(),d=C(s,u);d&&a.populate(d);const i=yield a.exec();if(!i)return{success:!1,message:`No ${this.getModelName()} found.`,code:N.RESPONSE_STATUS.NOT_FOUND.CODE};const p=yield this.populateDynamicVirtualsForDocument(i,s);return{success:!0,result:(c=(n=p==null?void 0:p.toObject)==null?void 0:n.call(p))!=null?c:p}}catch(o){return m.catchError(o)}})}findAll(){return f(this,arguments,function*(r={},e={},t={},s){try{const n=M.normalizeMongoFilter(r),c=this.model.find(n,e,t),o=this.getDynamicVirtuals(),a=C(s,o);a&&c.populate(a);const u=yield c.exec();return{success:!0,result:(yield this.populateDynamicVirtualsForDocuments(u,s)).map(i=>{var p,y;return(y=(p=i==null?void 0:i.toObject)==null?void 0:p.call(i))!=null?y:i})}}catch(n){return m.catchError(n)}})}findPaging(){return f(this,arguments,function*(r={},e={}){try{const t=M.normalizeMongoFilter(r),s=this.getDynamicVirtuals(),n=V({},e);e.populate&&(n.populate=C(e.populate,s));const c=yield this.model.paginate(t,n);if(s&&s.length>0){const o=yield this.populateDynamicVirtualsForDocuments(c.docs,e.populate);return{success:!0,result:A(V({},c),{docs:o.map(a=>{var u,d;return(d=(u=a==null?void 0:a.toObject)==null?void 0:u.call(a))!=null?d:a})})}}return{success:!0,result:A(V({},c),{docs:c.docs.map(o=>{var a,u;return(u=(a=o==null?void 0:o.toObject)==null?void 0:a.call(o))!=null?u:o})})}}catch(t){return m.catchError(t)}})}findPagingAggregate(r){return f(this,arguments,function*(e,t={}){try{const s=this.getDynamicVirtuals(),n=V({},t);t.populate&&(n.populate=C(t.populate,s));const c=yield this.model.aggregatePaginate(this.model.aggregate(e),n),o=yield this.populateDynamicVirtualsForDocuments(c.docs,t.populate);return{success:!0,result:A(V({},c),{docs:o.map(a=>{var u,d;return(d=(u=a==null?void 0:a.toObject)==null?void 0:u.call(a))!=null?d:a})})}}catch(s){return m.catchError(s)}})}count(){return f(this,arguments,function*(r={}){try{const e=M.normalizeMongoFilter(r);return{success:!0,result:yield this.model.countDocuments(e)}}catch(e){return m.catchError(e)}})}createOne(r){return f(this,null,function*(){var e,t;try{const s=yield this.model.create(r);return{success:!0,result:(t=(e=s==null?void 0:s.toObject)==null?void 0:e.call(s))!=null?t:s}}catch(s){return m.catchError(s)}})}createMany(r){return f(this,arguments,function*(e,t={}){try{return{success:!0,result:(yield this.model.insertMany(e,t)).map(n=>{var c,o;return(o=(c=n==null?void 0:n.toObject)==null?void 0:c.call(n))!=null?o:n})}}catch(s){return m.catchError(s)}})}updateOne(){return f(this,arguments,function*(r={},e={},t={}){var s,n;try{const c=M.normalizeMongoFilter(r),o=yield this.model.findOneAndUpdate(c,e,V({new:!0},t)).exec();return o?{success:!0,result:(n=(s=o==null?void 0:o.toObject)==null?void 0:s.call(o))!=null?n:o}:{success:!1,message:`Failed to update ${this.getModelName()}.`,code:N.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(c){return m.catchError(c)}})}updateMany(){return f(this,arguments,function*(r={},e={},t={}){try{const s=M.normalizeMongoFilter(r);return{success:!0,result:yield this.model.updateMany(s,e,t).exec()}}catch(s){return m.catchError(s)}})}deleteOne(){return f(this,arguments,function*(r={},e={}){var t,s;try{const n=M.normalizeMongoFilter(r),c=yield this.model.findOneAndDelete(n,e).exec();return c?{success:!0,result:(s=(t=c==null?void 0:c.toObject)==null?void 0:t.call(c))!=null?s:c}:{success:!1,message:`No ${this.getModelName()} found to delete.`,code:N.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(n){return m.catchError(n)}})}deleteMany(){return f(this,arguments,function*(r={},e={}){try{const t=M.normalizeMongoFilter(r),s=yield this.model.deleteMany(t,e).exec();return s.deletedCount===0?{success:!1,message:"No documents found to delete.",code:N.RESPONSE_STATUS.NOT_FOUND.CODE}:{success:!0,result:s}}catch(t){return m.catchError(t)}})}createShortId(r,e=4){return f(this,null,function*(){try{const s=Array.from({length:10},(o,a)=>x.generateShortId(r,a+e)),c=(yield Promise.all(s.map(o=>this.model.exists({shortId:o})))).findIndex(o=>!o);if(c!==-1){const o=s[c];if(o)return{success:!0,result:o}}return{success:!1,message:"Failed to create a unique shortId",code:N.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(t){return m.catchError(t)}})}createSlugQuery({slug:r,field:e,isObject:t,haveHistory:s=!1,filter:n}){const c=V({},n!=null?n:{});return t?A(V({},c),{$or:[{[`slug.${e}`]:r},...s?[{slugHistory:{$elemMatch:{[`slug.${e}`]:r}}}]:[]]}):A(V({},c),{$or:[{slug:r},...s?[{slugHistory:r}]:[]]})}createUniqueSlug(r){return f(this,arguments,function*({slug:e,field:t,isObject:s,haveHistory:n,filter:c}){if(!e||typeof e!="string")throw new Error("Invalid slug provided: must be a non-empty string");const o=x.generateSlug(e);if(!(yield this.model.exists(this.createSlugQuery({slug:o,field:t,isObject:s,haveHistory:n,filter:c}))))return o;for(let i=1;i<=L.MONGO_SLUG_MAX_ATTEMPTS;i++){const p=`${o}-${i}`;if(!(yield this.model.exists(this.createSlugQuery({slug:p,field:t,isObject:s,haveHistory:n,filter:c}))))return p}const u=Date.now(),d=Math.random().toString(36).substring(2,8);return`${o}-${u}-${d}`})}createSlug(r){return f(this,arguments,function*({field:e,from:t,filter:s,haveHistory:n}){try{const c=t[e];return z(c)?{success:!0,result:Object.fromEntries(yield Promise.all(Object.entries(c).map(d=>f(this,[d],function*([i,p]){const y=yield this.createUniqueSlug({slug:p,field:i,isObject:!0,haveHistory:n,filter:s});return[i,y]}))))}:{success:!0,result:yield this.createUniqueSlug({slug:c,field:e,isObject:!1,haveHistory:n,filter:s})}}catch(c){return m.catchError(c)}})}checkSlug(r){return f(this,arguments,function*({slug:e,field:t,from:s,filter:n,haveHistory:c}){try{const o=s[t];if(z(o)){const p=Object.values(o).map(E=>x.generateSlug(E));return(yield Promise.all(p.map(E=>this.model.exists(this.createSlugQuery({slug:E,field:t,isObject:!0,haveHistory:c,filter:n}))))).some(E=>E)?{success:!0,result:!0}:{success:!0,result:!1}}const u=x.generateSlug(e);return{success:!0,result:(yield this.model.exists(this.createSlugQuery({slug:u,field:t,isObject:!1,filter:n})))!==null}}catch(o){return m.catchError(o)}})}aggregate(r){return f(this,null,function*(){try{return{success:!0,result:yield this.model.aggregate(r)}}catch(e){return m.catchError(e)}})}distinct(r){return f(this,arguments,function*(e,t={},s={}){try{return{success:!0,result:yield this.model.distinct(e,t,s)}}catch(n){return m.catchError(n)}})}}exports.MongoController=Y;exports.MongooseController=Z;
|