@cyberskill/shared 1.210.0 → 1.211.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/commitlint/index.cjs +1 -0
- package/dist/config/config.type.cjs +1 -0
- package/dist/config/config.util.cjs +1 -0
- package/dist/config/config.util.js +35 -26
- package/dist/config/env/env.constant.cjs +1 -0
- package/dist/config/env/env.util.cjs +1 -0
- package/dist/config/env/index.cjs +1 -0
- package/dist/config/eslint/index.cjs +1 -0
- package/dist/config/eslint/index.js +12 -4
- package/dist/config/graphql-codegen/graphql-codegen.util.cjs +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js +33 -28
- package/dist/config/graphql-codegen/index.cjs +1 -0
- package/dist/config/index.cjs +1 -0
- package/dist/config/lint-staged/index.cjs +1 -0
- package/dist/config/vitest/index.cjs +1 -0
- package/dist/config/vitest/vitest.e2e.cjs +1 -0
- package/dist/config/vitest/vitest.e2e.js +16 -9
- package/dist/config/vitest/vitest.unit.cjs +1 -0
- package/dist/config/vitest/vitest.unit.js +18 -11
- package/dist/constant/common.cjs +1 -0
- package/dist/constant/common.js +1 -1
- package/dist/constant/index.cjs +1 -0
- package/dist/constant/response-status.cjs +1 -0
- package/dist/node/apollo-server/apollo-server.util.cjs +1 -0
- package/dist/node/apollo-server/apollo-server.util.js +48 -21
- package/dist/node/apollo-server/index.cjs +1 -0
- package/dist/node/cli/index.cjs +6 -0
- package/dist/node/cli/index.js +140 -90
- package/dist/node/command/command.type.cjs +1 -0
- package/dist/node/command/command.util.cjs +2 -0
- package/dist/node/command/command.util.js +148 -117
- package/dist/node/command/index.cjs +1 -0
- package/dist/node/express/express.util.cjs +1 -0
- package/dist/node/express/express.util.js +70 -37
- package/dist/node/express/index.cjs +1 -0
- package/dist/node/fs/fs.util.cjs +1 -0
- package/dist/node/fs/fs.util.js +55 -40
- package/dist/node/fs/index.cjs +1 -0
- package/dist/node/log/index.cjs +1 -0
- package/dist/node/log/log.type.cjs +1 -0
- package/dist/node/log/log.util.cjs +1 -0
- package/dist/node/log/log.util.js +31 -30
- package/dist/node/mongo/index.cjs +1 -0
- package/dist/node/mongo/mongo.constant.cjs +1 -0
- package/dist/node/mongo/mongo.type.cjs +1 -0
- package/dist/node/mongo/mongo.util.cjs +5 -0
- package/dist/node/mongo/mongo.util.js +433 -365
- package/dist/node/package/index.cjs +1 -0
- package/dist/node/package/package.type.cjs +1 -0
- package/dist/node/package/package.util.cjs +1 -0
- package/dist/node/package/package.util.js +224 -195
- package/dist/node/path/index.cjs +1 -0
- package/dist/node/path/path.constant.cjs +1 -0
- package/dist/node/path/path.constant.js +205 -183
- package/dist/node/path/path.util.cjs +1 -0
- package/dist/node/storage/index.cjs +1 -0
- package/dist/node/storage/storage.util.cjs +1 -0
- package/dist/node/storage/storage.util.js +70 -40
- package/dist/node/upload/index.cjs +1 -0
- package/dist/node/upload/upload.type.cjs +1 -0
- package/dist/node/upload/upload.util.cjs +1 -0
- package/dist/node/upload/upload.util.js +119 -91
- package/dist/node/ws/index.cjs +1 -0
- package/dist/node/ws/ts.util.cjs +1 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.13_@vitest_browser@3.2.4_jiti@2.4.2_j_cac3da623d5688a51c0b1a2270e144db/node_modules/vitest/dist/config.cjs +1 -0
- package/dist/react/apollo-client/apollo-client.component.cjs +1 -0
- package/dist/react/apollo-client/apollo-client.constant.cjs +1 -0
- package/dist/react/apollo-client/apollo-client.context.cjs +1 -0
- package/dist/react/apollo-client/apollo-client.util.cjs +1 -0
- package/dist/react/apollo-client/apollo-client.util.js +74 -64
- package/dist/react/apollo-client/index.cjs +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +18 -11
- package/dist/react/apollo-client-nextjs/index.cjs +1 -0
- package/dist/react/apollo-error/apollo-error.component.cjs +1 -0
- package/dist/react/apollo-error/apollo-error.component.js +6 -6
- package/dist/react/apollo-error/apollo-error.context.cjs +1 -0
- package/dist/react/apollo-error/apollo-error.hook.cjs +1 -0
- package/dist/react/apollo-error/apollo-error.module.scss.cjs +1 -0
- package/dist/react/apollo-error/apollo-error.provider.cjs +1 -0
- package/dist/react/apollo-error/apollo-error.util.cjs +1 -0
- package/dist/react/apollo-error/apollo-error.util.js +1 -1
- package/dist/react/apollo-error/index.cjs +1 -0
- package/dist/react/i18next/i18next.hook.cjs +1 -0
- package/dist/react/i18next/i18next.util.cjs +1 -0
- package/dist/react/i18next/index.cjs +1 -0
- package/dist/react/loading/index.cjs +1 -0
- package/dist/react/loading/loading.component.cjs +6 -0
- package/dist/react/loading/loading.component.js +36 -19
- package/dist/react/loading/loading.context.cjs +1 -0
- package/dist/react/loading/loading.hook.cjs +1 -0
- package/dist/react/loading/loading.module.scss.cjs +1 -0
- package/dist/react/loading/loading.provider.cjs +1 -0
- package/dist/react/log/index.cjs +1 -0
- package/dist/react/log/log.util.cjs +1 -0
- package/dist/react/log/log.util.js +4 -4
- package/dist/react/next-intl/index.cjs +1 -0
- package/dist/react/next-intl/next-intl.constant.cjs +1 -0
- package/dist/react/next-intl/next-intl.context.cjs +1 -0
- package/dist/react/next-intl/next-intl.hoc.cjs +1 -0
- package/dist/react/next-intl/next-intl.hoc.js +23 -14
- package/dist/react/next-intl/next-intl.hook.cjs +1 -0
- package/dist/react/next-intl/next-intl.provider.cjs +1 -0
- package/dist/react/next-intl/next-intl.provider.js +7 -7
- package/dist/react/storage/index.cjs +1 -0
- package/dist/react/storage/storage.hook.cjs +1 -0
- package/dist/react/storage/storage.hook.js +57 -41
- package/dist/react/storage/storage.util.cjs +1 -0
- package/dist/react/storage/storage.util.js +50 -25
- package/dist/react/toast/index.cjs +1 -0
- package/dist/react/userback/index.cjs +1 -0
- package/dist/react/userback/userback.component.cjs +1 -0
- package/dist/react/userback/userback.component.js +42 -18
- package/dist/style.css +1 -1
- package/dist/typescript/common.type.cjs +1 -0
- package/dist/typescript/index.cjs +1 -0
- package/dist/util/common/common.util.cjs +1 -0
- package/dist/util/common/common.util.js +37 -29
- package/dist/util/common/index.cjs +1 -0
- package/dist/util/index.cjs +1 -0
- package/dist/util/object/index.cjs +1 -0
- package/dist/util/object/object.util.cjs +1 -0
- package/dist/util/object/object.util.js +55 -49
- package/dist/util/serializer/index.cjs +1 -0
- package/dist/util/serializer/serializer.util.cjs +1 -0
- package/dist/util/string/index.cjs +1 -0
- package/dist/util/string/string.util.cjs +1 -0
- package/dist/util/string/string.util.js +46 -36
- package/dist/util/validate/index.cjs +1 -0
- package/dist/util/validate/validate.util.cjs +1 -0
- package/package.json +69 -35
|
@@ -1,22 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Document as
|
|
3
|
-
import
|
|
4
|
-
import { default as
|
|
5
|
-
import
|
|
6
|
-
import { default as
|
|
7
|
-
import { v4 as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { catchError as
|
|
16
|
-
|
|
1
|
+
import v from "migrate-mongo";
|
|
2
|
+
import { Document as w } from "mongoose";
|
|
3
|
+
import C from "mongoose-aggregate-paginate-v2";
|
|
4
|
+
import { default as le } from "mongoose-aggregate-paginate-v2";
|
|
5
|
+
import I from "mongoose-paginate-v2";
|
|
6
|
+
import { default as de } from "mongoose-paginate-v2";
|
|
7
|
+
import { v4 as S } from "uuid";
|
|
8
|
+
import { deepClone as P, getNestedValue as M, setNestedValue as A, isObject as N } from "../../util/object/object.util.js";
|
|
9
|
+
import { regexSearchMapper as T } from "../../util/common/common.util.js";
|
|
10
|
+
import { writeFileSync as D, pathExistsSync as j, readFileSync as F, appendFileSync as G } from "../fs/fs.util.js";
|
|
11
|
+
import { PATH as g, MIGRATE_MONGO_CONFIG as x } from "../path/path.constant.js";
|
|
12
|
+
import { validate as $ } from "../../util/validate/validate.util.js";
|
|
13
|
+
import { generateShortId as q, generateSlug as O } from "../../util/string/string.util.js";
|
|
14
|
+
import { RESPONSE_STATUS as d } from "../../constant/response-status.js";
|
|
15
|
+
import { catchError as i } from "../log/log.util.js";
|
|
16
|
+
var V = Object.defineProperty, U = Object.defineProperties, L = Object.getOwnPropertyDescriptors, b = Object.getOwnPropertySymbols, Q = Object.prototype.hasOwnProperty, H = Object.prototype.propertyIsEnumerable, E = (n, t, e) => t in n ? V(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, f = (n, t) => {
|
|
17
|
+
for (var e in t || (t = {}))
|
|
18
|
+
Q.call(t, e) && E(n, e, t[e]);
|
|
19
|
+
if (b)
|
|
20
|
+
for (var e of b(t))
|
|
21
|
+
H.call(t, e) && E(n, e, t[e]);
|
|
22
|
+
return n;
|
|
23
|
+
}, R = (n, t) => U(n, L(t)), J = (n, t, e) => E(n, typeof t != "symbol" ? t + "" : t, e), o = (n, t, e) => new Promise((r, s) => {
|
|
24
|
+
var u = (a) => {
|
|
25
|
+
try {
|
|
26
|
+
l(e.next(a));
|
|
27
|
+
} catch (m) {
|
|
28
|
+
s(m);
|
|
29
|
+
}
|
|
30
|
+
}, c = (a) => {
|
|
31
|
+
try {
|
|
32
|
+
l(e.throw(a));
|
|
33
|
+
} catch (m) {
|
|
34
|
+
s(m);
|
|
35
|
+
}
|
|
36
|
+
}, l = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(u, c);
|
|
37
|
+
l((e = e.apply(n, t)).next());
|
|
38
|
+
});
|
|
39
|
+
const h = {
|
|
17
40
|
createGenericFields() {
|
|
18
41
|
return {
|
|
19
|
-
id:
|
|
42
|
+
id: S(),
|
|
20
43
|
isDel: !1,
|
|
21
44
|
createdAt: /* @__PURE__ */ new Date(),
|
|
22
45
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -33,7 +56,7 @@ const l = {
|
|
|
33
56
|
createGenericSchema(n) {
|
|
34
57
|
return new n.Schema(
|
|
35
58
|
{
|
|
36
|
-
id: { type: String, default:
|
|
59
|
+
id: { type: String, default: S, unique: !0 },
|
|
37
60
|
isDel: { type: Boolean, default: !1 }
|
|
38
61
|
},
|
|
39
62
|
{ timestamps: !0 }
|
|
@@ -46,10 +69,10 @@ const l = {
|
|
|
46
69
|
standalone: r = !1
|
|
47
70
|
}) {
|
|
48
71
|
const s = new n.Schema(t);
|
|
49
|
-
return e.forEach(({ name:
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
}), r || s.add(
|
|
72
|
+
return e.forEach(({ name: u, options: c, get: l }) => {
|
|
73
|
+
const a = s.virtual(u, c);
|
|
74
|
+
l && a.get(l);
|
|
75
|
+
}), r || s.add(h.createGenericSchema(n)), s;
|
|
53
76
|
},
|
|
54
77
|
createModel({
|
|
55
78
|
mongoose: n,
|
|
@@ -57,432 +80,477 @@ const l = {
|
|
|
57
80
|
schema: e,
|
|
58
81
|
pagination: r = !1,
|
|
59
82
|
aggregate: s = !1,
|
|
60
|
-
virtuals:
|
|
61
|
-
middlewares:
|
|
83
|
+
virtuals: u = [],
|
|
84
|
+
middlewares: c = []
|
|
62
85
|
}) {
|
|
63
86
|
if (!t)
|
|
64
87
|
throw new Error("Model name is required.");
|
|
65
88
|
if (n.models[t])
|
|
66
89
|
return n.models[t];
|
|
67
|
-
const
|
|
68
|
-
return
|
|
69
|
-
r &&
|
|
70
|
-
s &&
|
|
71
|
-
]),
|
|
90
|
+
const l = h.createSchema({ mongoose: n, schema: e, virtuals: u });
|
|
91
|
+
return h.applyPlugins(l, [
|
|
92
|
+
r && I,
|
|
93
|
+
s && C
|
|
94
|
+
]), h.applyMiddlewares(l, c), n.model(t, l);
|
|
72
95
|
},
|
|
73
96
|
validator: {
|
|
74
97
|
isRequired() {
|
|
75
|
-
return
|
|
76
|
-
return
|
|
98
|
+
return function(n) {
|
|
99
|
+
return o(this, null, function* () {
|
|
100
|
+
return !$.isEmpty(n);
|
|
101
|
+
});
|
|
77
102
|
};
|
|
78
103
|
},
|
|
79
104
|
isUnique(n) {
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
105
|
+
return function(t) {
|
|
106
|
+
return o(this, null, function* () {
|
|
107
|
+
if (!Array.isArray(n) || n.length === 0)
|
|
108
|
+
throw new Error("Fields must be a non-empty array of strings.");
|
|
109
|
+
const e = { $or: n.map((s) => ({ [s]: t })) };
|
|
110
|
+
return !(yield this.constructor.exists(e));
|
|
111
|
+
});
|
|
85
112
|
};
|
|
86
113
|
},
|
|
87
114
|
matchesRegex(n) {
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
115
|
+
return function(t) {
|
|
116
|
+
return o(this, null, function* () {
|
|
117
|
+
if (!Array.isArray(n) || n.some((e) => !(e instanceof RegExp)))
|
|
118
|
+
throw new Error("regexArray must be an array of valid RegExp objects.");
|
|
119
|
+
return n.every((e) => e.test(t));
|
|
120
|
+
});
|
|
92
121
|
};
|
|
93
122
|
}
|
|
94
123
|
},
|
|
95
|
-
migrate: {
|
|
96
|
-
...R,
|
|
124
|
+
migrate: R(f({}, v), {
|
|
97
125
|
setConfig: (n) => {
|
|
98
126
|
const t = `// This file is automatically generated by the Cyberskill CLI.
|
|
99
127
|
module.exports = ${JSON.stringify(n, null, 4)}`;
|
|
100
|
-
|
|
128
|
+
D(g.MIGRATE_MONGO_CONFIG, t);
|
|
101
129
|
const e = `
|
|
102
|
-
${
|
|
130
|
+
${x}
|
|
103
131
|
`;
|
|
104
|
-
|
|
105
|
-
`).includes(
|
|
132
|
+
j(g.GIT_IGNORE) ? F(g.GIT_IGNORE, "utf-8").split(`
|
|
133
|
+
`).includes(x) || G(g.GIT_IGNORE, e) : D(g.GIT_IGNORE, e);
|
|
106
134
|
}
|
|
107
|
-
},
|
|
135
|
+
}),
|
|
108
136
|
regexify(n, t) {
|
|
109
137
|
if (!n)
|
|
110
138
|
return {};
|
|
111
|
-
let e =
|
|
139
|
+
let e = P(n);
|
|
112
140
|
if (!t || t.length === 0)
|
|
113
141
|
return e;
|
|
114
142
|
for (const r of t) {
|
|
115
|
-
const s = r.toString().split("."),
|
|
116
|
-
if (typeof
|
|
117
|
-
const
|
|
118
|
-
$regex: `.*${
|
|
143
|
+
const s = r.toString().split("."), u = M(e, s);
|
|
144
|
+
if (typeof u == "string" && u.length > 0) {
|
|
145
|
+
const c = {
|
|
146
|
+
$regex: `.*${T(u)}.*`,
|
|
119
147
|
$options: "i"
|
|
120
148
|
};
|
|
121
|
-
e =
|
|
149
|
+
e = A(e, s, c);
|
|
122
150
|
}
|
|
123
151
|
}
|
|
124
152
|
return e;
|
|
125
153
|
}
|
|
126
154
|
};
|
|
127
|
-
class
|
|
128
|
-
collection;
|
|
155
|
+
class ue {
|
|
129
156
|
constructor(t, e) {
|
|
130
|
-
this.collection = t.collection(e);
|
|
157
|
+
J(this, "collection"), this.collection = t.collection(e);
|
|
131
158
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
159
|
+
createOne(t) {
|
|
160
|
+
return o(this, null, function* () {
|
|
161
|
+
try {
|
|
162
|
+
const e = f(f({}, h.createGenericFields()), t);
|
|
163
|
+
return (yield this.collection.insertOne(e)).acknowledged ? {
|
|
164
|
+
success: !0,
|
|
165
|
+
message: "Document created successfully",
|
|
166
|
+
result: e
|
|
167
|
+
} : {
|
|
168
|
+
success: !1,
|
|
169
|
+
message: "Document creation failed",
|
|
170
|
+
code: d.INTERNAL_SERVER_ERROR.CODE
|
|
171
|
+
};
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return i(e);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
150
176
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
177
|
+
createMany(t) {
|
|
178
|
+
return o(this, null, function* () {
|
|
179
|
+
try {
|
|
180
|
+
const e = t.map((s) => f(f({}, h.createGenericFields()), s)), r = yield this.collection.insertMany(e);
|
|
181
|
+
return r.insertedCount === 0 ? {
|
|
182
|
+
success: !1,
|
|
183
|
+
message: "No documents were inserted",
|
|
184
|
+
code: d.INTERNAL_SERVER_ERROR.CODE
|
|
185
|
+
} : {
|
|
186
|
+
success: !0,
|
|
187
|
+
message: `${r.insertedCount} documents created successfully`,
|
|
188
|
+
result: e
|
|
189
|
+
};
|
|
190
|
+
} catch (e) {
|
|
191
|
+
return i(e);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
169
194
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
195
|
+
findOne(t) {
|
|
196
|
+
return o(this, null, function* () {
|
|
197
|
+
try {
|
|
198
|
+
const e = yield this.collection.findOne(t);
|
|
199
|
+
return e ? { success: !0, message: "Document found", result: e } : { success: !1, message: "Document not found", code: d.NOT_FOUND.CODE };
|
|
200
|
+
} catch (e) {
|
|
201
|
+
return i(e);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
177
204
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
205
|
+
findAll() {
|
|
206
|
+
return o(this, arguments, function* (t = {}) {
|
|
207
|
+
try {
|
|
208
|
+
return {
|
|
209
|
+
success: !0,
|
|
210
|
+
message: "Documents retrieved successfully",
|
|
211
|
+
result: yield this.collection.find(t).toArray()
|
|
212
|
+
};
|
|
213
|
+
} catch (e) {
|
|
214
|
+
return i(e);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
188
217
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
218
|
+
count() {
|
|
219
|
+
return o(this, arguments, function* (t = {}) {
|
|
220
|
+
try {
|
|
221
|
+
return {
|
|
222
|
+
success: !0,
|
|
223
|
+
message: "Count retrieved successfully",
|
|
224
|
+
result: yield this.collection.countDocuments(t)
|
|
225
|
+
};
|
|
226
|
+
} catch (e) {
|
|
227
|
+
return i(e);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
199
230
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
231
|
+
updateOne(t, e) {
|
|
232
|
+
return o(this, null, function* () {
|
|
233
|
+
try {
|
|
234
|
+
const r = yield this.collection.updateOne(t, {
|
|
235
|
+
$set: e
|
|
236
|
+
});
|
|
237
|
+
return r.matchedCount === 0 ? {
|
|
238
|
+
success: !1,
|
|
239
|
+
message: "No documents matched the filter",
|
|
240
|
+
code: d.INTERNAL_SERVER_ERROR.CODE
|
|
241
|
+
} : {
|
|
242
|
+
success: !0,
|
|
243
|
+
message: "Document updated successfully",
|
|
244
|
+
result: r
|
|
245
|
+
};
|
|
246
|
+
} catch (r) {
|
|
247
|
+
return i(r);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
217
250
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
251
|
+
updateMany(t, e) {
|
|
252
|
+
return o(this, null, function* () {
|
|
253
|
+
try {
|
|
254
|
+
const r = yield this.collection.updateMany(t, {
|
|
255
|
+
$set: e
|
|
256
|
+
});
|
|
257
|
+
return r.matchedCount === 0 ? {
|
|
258
|
+
success: !1,
|
|
259
|
+
message: "No documents matched the filter",
|
|
260
|
+
code: d.INTERNAL_SERVER_ERROR.CODE
|
|
261
|
+
} : {
|
|
262
|
+
success: !0,
|
|
263
|
+
message: "Documents updated successfully",
|
|
264
|
+
result: r
|
|
265
|
+
};
|
|
266
|
+
} catch (r) {
|
|
267
|
+
return i(r);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
235
270
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
271
|
+
deleteOne(t) {
|
|
272
|
+
return o(this, null, function* () {
|
|
273
|
+
try {
|
|
274
|
+
const e = yield this.collection.deleteOne(t);
|
|
275
|
+
return e.deletedCount === 0 ? {
|
|
276
|
+
success: !1,
|
|
277
|
+
message: "No documents matched the filter",
|
|
278
|
+
code: d.INTERNAL_SERVER_ERROR.CODE
|
|
279
|
+
} : {
|
|
280
|
+
success: !0,
|
|
281
|
+
message: "Document deleted successfully",
|
|
282
|
+
result: e
|
|
283
|
+
};
|
|
284
|
+
} catch (e) {
|
|
285
|
+
return i(e);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
251
288
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
289
|
+
deleteMany(t) {
|
|
290
|
+
return o(this, null, function* () {
|
|
291
|
+
try {
|
|
292
|
+
const e = yield this.collection.deleteMany(t);
|
|
293
|
+
return e.deletedCount === 0 ? {
|
|
294
|
+
success: !1,
|
|
295
|
+
message: "No documents matched the filter",
|
|
296
|
+
code: d.INTERNAL_SERVER_ERROR.CODE
|
|
297
|
+
} : {
|
|
298
|
+
success: !0,
|
|
299
|
+
message: "Documents deleted successfully",
|
|
300
|
+
result: e
|
|
301
|
+
};
|
|
302
|
+
} catch (e) {
|
|
303
|
+
return i(e);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
267
306
|
}
|
|
268
307
|
}
|
|
269
|
-
class
|
|
308
|
+
class ce {
|
|
270
309
|
constructor(t) {
|
|
271
310
|
this.model = t;
|
|
272
311
|
}
|
|
273
312
|
getModelName() {
|
|
274
313
|
return this.model.modelName;
|
|
275
314
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
success: !
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
315
|
+
findOne() {
|
|
316
|
+
return o(this, arguments, function* (t = {}, e = {}, r = {}, s) {
|
|
317
|
+
try {
|
|
318
|
+
const u = this.model.findOne(t, e, r);
|
|
319
|
+
s && u.populate(s);
|
|
320
|
+
const c = yield u.exec();
|
|
321
|
+
return c ? { success: !0, result: c } : {
|
|
322
|
+
success: !1,
|
|
323
|
+
message: `No ${this.getModelName()} found.`,
|
|
324
|
+
code: d.NOT_FOUND.CODE
|
|
325
|
+
};
|
|
326
|
+
} catch (u) {
|
|
327
|
+
return i(u);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
289
330
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
331
|
+
findAll() {
|
|
332
|
+
return o(this, arguments, function* (t = {}, e = {}, r = {}, s) {
|
|
333
|
+
try {
|
|
334
|
+
const u = this.model.find(t, e, r);
|
|
335
|
+
return s && u.populate(s), { success: !0, result: yield u.exec() };
|
|
336
|
+
} catch (u) {
|
|
337
|
+
return i(u);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
297
340
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
341
|
+
findPaging() {
|
|
342
|
+
return o(this, arguments, function* (t = {}, e = {}) {
|
|
343
|
+
try {
|
|
344
|
+
return { success: !0, result: yield this.model.paginate(t, e) };
|
|
345
|
+
} catch (r) {
|
|
346
|
+
return i(r);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
304
349
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
this.model.
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
350
|
+
findPagingAggregate(t) {
|
|
351
|
+
return o(this, arguments, function* (e, r = {}) {
|
|
352
|
+
try {
|
|
353
|
+
return { success: !0, result: yield this.model.aggregatePaginate(
|
|
354
|
+
this.model.aggregate(e),
|
|
355
|
+
r
|
|
356
|
+
) };
|
|
357
|
+
} catch (s) {
|
|
358
|
+
return i(s);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
314
361
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
362
|
+
count() {
|
|
363
|
+
return o(this, arguments, function* (t = {}) {
|
|
364
|
+
try {
|
|
365
|
+
return { success: !0, result: yield this.model.countDocuments(t) };
|
|
366
|
+
} catch (e) {
|
|
367
|
+
return i(e);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
321
370
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
371
|
+
createOne(t) {
|
|
372
|
+
return o(this, null, function* () {
|
|
373
|
+
try {
|
|
374
|
+
return { success: !0, result: yield this.model.create(t) };
|
|
375
|
+
} catch (e) {
|
|
376
|
+
return i(e);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
328
379
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
380
|
+
createMany(t) {
|
|
381
|
+
return o(this, arguments, function* (e, r = {}) {
|
|
382
|
+
try {
|
|
383
|
+
return { success: !0, result: (yield this.model.insertMany(e, r)).map((c) => c instanceof w ? c.toObject() : null).filter((c) => c !== null) };
|
|
384
|
+
} catch (s) {
|
|
385
|
+
return i(s);
|
|
386
|
+
}
|
|
387
|
+
});
|
|
335
388
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
389
|
+
updateOne() {
|
|
390
|
+
return o(this, arguments, function* (t = {}, e = {}, r = {}) {
|
|
391
|
+
try {
|
|
392
|
+
const s = yield this.model.findOneAndUpdate(t, e, f({
|
|
393
|
+
new: !0
|
|
394
|
+
}, r)).exec();
|
|
395
|
+
return s ? { success: !0, result: s } : {
|
|
396
|
+
success: !1,
|
|
397
|
+
message: `Failed to update ${this.getModelName()}.`,
|
|
398
|
+
code: d.NOT_FOUND.CODE
|
|
399
|
+
};
|
|
400
|
+
} catch (s) {
|
|
401
|
+
return i(s);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
350
404
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
405
|
+
updateMany() {
|
|
406
|
+
return o(this, arguments, function* (t = {}, e = {}, r = {}) {
|
|
407
|
+
try {
|
|
408
|
+
return { success: !0, result: yield this.model.updateMany(t, e, r).exec() };
|
|
409
|
+
} catch (s) {
|
|
410
|
+
return i(s);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
357
413
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
success: !
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
414
|
+
deleteOne() {
|
|
415
|
+
return o(this, arguments, function* (t = {}, e = {}) {
|
|
416
|
+
try {
|
|
417
|
+
const r = yield this.model.findOneAndDelete(t, e).exec();
|
|
418
|
+
return r ? { success: !0, result: r } : {
|
|
419
|
+
success: !1,
|
|
420
|
+
message: `No ${this.getModelName()} found to delete.`,
|
|
421
|
+
code: d.NOT_FOUND.CODE
|
|
422
|
+
};
|
|
423
|
+
} catch (r) {
|
|
424
|
+
return i(r);
|
|
425
|
+
}
|
|
426
|
+
});
|
|
369
427
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
428
|
+
deleteMany() {
|
|
429
|
+
return o(this, arguments, function* (t = {}, e = {}) {
|
|
430
|
+
try {
|
|
431
|
+
const r = yield this.model.deleteMany(t, e).exec();
|
|
432
|
+
return r.deletedCount === 0 ? {
|
|
433
|
+
success: !1,
|
|
434
|
+
message: "No documents found to delete.",
|
|
435
|
+
code: d.NOT_FOUND.CODE
|
|
436
|
+
} : { success: !0, result: r };
|
|
437
|
+
} catch (r) {
|
|
438
|
+
return i(r);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
381
441
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
442
|
+
createShortId(t, e = 4) {
|
|
443
|
+
return o(this, null, function* () {
|
|
444
|
+
try {
|
|
445
|
+
const s = /* @__PURE__ */ new Set();
|
|
446
|
+
for (let u = 0; u < 10; u++) {
|
|
447
|
+
const c = q(t, u + e);
|
|
448
|
+
if (!s.has(c) && (s.add(c), !(yield this.model.exists({ shortId: c }))))
|
|
449
|
+
return { success: !0, result: c };
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
success: !1,
|
|
453
|
+
message: "Failed to create a unique shortId",
|
|
454
|
+
code: d.INTERNAL_SERVER_ERROR.CODE
|
|
455
|
+
};
|
|
456
|
+
} catch (r) {
|
|
457
|
+
return i(r);
|
|
389
458
|
}
|
|
390
|
-
|
|
391
|
-
success: !1,
|
|
392
|
-
message: "Failed to create a unique shortId",
|
|
393
|
-
code: i.INTERNAL_SERVER_ERROR.CODE
|
|
394
|
-
};
|
|
395
|
-
} catch (r) {
|
|
396
|
-
return u(r);
|
|
397
|
-
}
|
|
459
|
+
});
|
|
398
460
|
}
|
|
399
461
|
createSlugQuery({ slug: t, field: e, isObject: r, filter: s }) {
|
|
400
|
-
const
|
|
401
|
-
return r ? {
|
|
402
|
-
...c,
|
|
462
|
+
const u = f({}, s != null ? s : {});
|
|
463
|
+
return r ? R(f({}, u), {
|
|
403
464
|
$or: [
|
|
404
465
|
{ [`slug.${e}`]: t },
|
|
405
466
|
{ slugHistory: { $elemMatch: { [`slug.${e}`]: t } } }
|
|
406
467
|
]
|
|
407
|
-
} : {
|
|
408
|
-
...c,
|
|
468
|
+
}) : R(f({}, u), {
|
|
409
469
|
$or: [
|
|
410
470
|
{ slug: t },
|
|
411
471
|
{ slugHistory: t }
|
|
412
472
|
]
|
|
413
|
-
};
|
|
473
|
+
});
|
|
414
474
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
475
|
+
createUniqueSlug(t) {
|
|
476
|
+
return o(this, arguments, function* ({ slug: e, field: r, isObject: s, filter: u }) {
|
|
477
|
+
const c = O(e);
|
|
478
|
+
let l = c, a = 1;
|
|
479
|
+
for (; yield this.model.exists(this.createSlugQuery({ slug: l, field: r, isObject: s, filter: u })); )
|
|
480
|
+
l = `${c}-${a++}`;
|
|
481
|
+
return l;
|
|
482
|
+
});
|
|
421
483
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
484
|
+
createSlug(t) {
|
|
485
|
+
return o(this, arguments, function* ({ field: e, from: r, filter: s }) {
|
|
486
|
+
try {
|
|
487
|
+
const u = r[e];
|
|
488
|
+
return N(u) ? { success: !0, result: Object.fromEntries(
|
|
489
|
+
yield Promise.all(
|
|
490
|
+
Object.entries(u).map((m) => o(this, [m], function* ([y, p]) {
|
|
491
|
+
const _ = yield this.createUniqueSlug({
|
|
492
|
+
slug: p,
|
|
493
|
+
field: y,
|
|
494
|
+
isObject: !0,
|
|
495
|
+
filter: s
|
|
496
|
+
});
|
|
497
|
+
return [y, _];
|
|
498
|
+
}))
|
|
499
|
+
)
|
|
500
|
+
) } : { success: !0, result: yield this.createUniqueSlug({
|
|
501
|
+
slug: u,
|
|
502
|
+
field: e,
|
|
503
|
+
isObject: !1,
|
|
504
|
+
filter: s
|
|
505
|
+
}) };
|
|
506
|
+
} catch (u) {
|
|
507
|
+
return i(u);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
446
510
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
511
|
+
checkSlug(t) {
|
|
512
|
+
return o(this, arguments, function* ({ slug: e, field: r, from: s, filter: u }) {
|
|
513
|
+
try {
|
|
514
|
+
const c = s[r];
|
|
515
|
+
if (N(c)) {
|
|
516
|
+
for (const y of Object.values(c)) {
|
|
517
|
+
const p = O(y);
|
|
518
|
+
if (yield this.model.exists(this.createSlugQuery({
|
|
519
|
+
slug: p,
|
|
520
|
+
field: r,
|
|
521
|
+
isObject: !0,
|
|
522
|
+
filter: u
|
|
523
|
+
})))
|
|
524
|
+
return { success: !0, result: !0 };
|
|
525
|
+
}
|
|
526
|
+
return { success: !0, result: !1 };
|
|
460
527
|
}
|
|
461
|
-
|
|
528
|
+
const a = O(e);
|
|
529
|
+
return { success: !0, result: (yield this.model.exists(this.createSlugQuery({
|
|
530
|
+
slug: a,
|
|
531
|
+
field: r,
|
|
532
|
+
isObject: !1,
|
|
533
|
+
filter: u
|
|
534
|
+
}))) !== null };
|
|
535
|
+
} catch (c) {
|
|
536
|
+
return i(c);
|
|
462
537
|
}
|
|
463
|
-
|
|
464
|
-
return { success: !0, result: await this.model.exists(this.createSlugQuery({
|
|
465
|
-
slug: o,
|
|
466
|
-
field: e,
|
|
467
|
-
isObject: !1,
|
|
468
|
-
filter: s
|
|
469
|
-
})) !== null };
|
|
470
|
-
} catch (c) {
|
|
471
|
-
return u(c);
|
|
472
|
-
}
|
|
538
|
+
});
|
|
473
539
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
540
|
+
aggregate(t) {
|
|
541
|
+
return o(this, null, function* () {
|
|
542
|
+
try {
|
|
543
|
+
return { success: !0, result: yield this.model.aggregate(t) };
|
|
544
|
+
} catch (e) {
|
|
545
|
+
return i(e);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
480
548
|
}
|
|
481
549
|
}
|
|
482
550
|
export {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
551
|
+
ue as MongoController,
|
|
552
|
+
ce as MongooseController,
|
|
553
|
+
le as aggregatePaginate,
|
|
554
|
+
h as mongo,
|
|
555
|
+
de as mongoosePaginate
|
|
488
556
|
};
|