vimcord 1.0.47 → 1.0.49
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/index.cjs +28 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +32 -34
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +8 -3
package/dist/index.d.mts
CHANGED
|
@@ -2460,7 +2460,7 @@ declare class MongoSchemaBuilder<Definition extends object = any> {
|
|
|
2460
2460
|
execute<T extends (model: Model<Definition>) => any>(fn: T, maxRetries?: number): Promise<ExtractReturn<T>>;
|
|
2461
2461
|
startSession(options?: ClientSessionOptions): Promise<mongo.ClientSession>;
|
|
2462
2462
|
useTransaction(fn: (session: ClientSession, model: Model<Definition>) => any): Promise<void>;
|
|
2463
|
-
|
|
2463
|
+
createUniqueId(collisionPath: keyof Require_id<Definition>, fn: () => string, maxRetries?: number): Promise<string>;
|
|
2464
2464
|
count(filter?: RootFilterQuery<Definition>, options?: mongo.CountOptions & MongooseBaseQueryOptions<Definition> & mongo.Abortable): Promise<number>;
|
|
2465
2465
|
exists(filter: RootFilterQuery<Definition>): Promise<boolean>;
|
|
2466
2466
|
create(query: Partial<Require_id<Definition>>[], options?: CreateOptions): Promise<(Document<unknown, {}, Definition, {}, {}> & (Require_id<Definition> extends infer T ? T extends Require_id<Definition> ? T extends {
|
|
@@ -2468,15 +2468,20 @@ declare class MongoSchemaBuilder<Definition extends object = any> {
|
|
|
2468
2468
|
} ? T : T & {
|
|
2469
2469
|
__v: number;
|
|
2470
2470
|
} : never : never))[]>;
|
|
2471
|
-
upsert(filter: RootFilterQuery<Definition>, query: Partial<Require_id<Definition>>, options?: QueryOptions<Definition>): Promise<Document<unknown, {}, Definition, {}, {}> & (Require_id<Definition> extends infer T ? T extends Require_id<Definition> ? T extends {
|
|
2471
|
+
upsert(filter: RootFilterQuery<Definition>, query: Partial<Require_id<Definition>>, options?: Exclude<QueryOptions<Definition>, "upsert">): Promise<(Document<unknown, {}, Definition, {}, {}> & (Require_id<Definition> extends infer T ? T extends Require_id<Definition> ? T extends {
|
|
2472
2472
|
__v?: infer U;
|
|
2473
2473
|
} ? T : T & {
|
|
2474
2474
|
__v: number;
|
|
2475
|
-
} : never : never)>;
|
|
2475
|
+
} : never : never)) | null>;
|
|
2476
2476
|
delete(filter: RootFilterQuery<Definition>, options?: mongo.DeleteOptions & MongooseBaseQueryOptions<Definition>): Promise<mongo.DeleteResult>;
|
|
2477
2477
|
deleteAll(filter: RootFilterQuery<Definition>, options?: mongo.DeleteOptions & MongooseBaseQueryOptions<Definition>): Promise<mongo.DeleteResult>;
|
|
2478
2478
|
distinct<K extends keyof Require_id<Definition> & string>(key: K, filter?: RootFilterQuery<Definition>, options?: QueryOptions<Definition>): Promise<(K extends keyof Definition | mongoose.NestedPaths<Required<Definition>, keyof Definition> ? mongoose.WithoutUndefined<mongoose.Unpacked<mongoose.WithLevel1NestedPaths<Definition, keyof Definition>[K]>> : unknown)[]>;
|
|
2479
|
-
fetch<Options extends QueryOptions<Definition>>(filter?: RootFilterQuery<Definition>, projection?: ProjectionType<Definition>, options?: Options
|
|
2479
|
+
fetch<Options extends QueryOptions<Definition>>(filter?: RootFilterQuery<Definition>, projection?: ProjectionType<Definition>, options?: Options & {
|
|
2480
|
+
required?: boolean;
|
|
2481
|
+
}): Promise<LeanOrHydratedDocument<Definition, Options> | null | undefined>;
|
|
2482
|
+
fetch<Options extends QueryOptions<Definition>>(filter?: RootFilterQuery<Definition>, projection?: ProjectionType<Definition>, options?: Options & {
|
|
2483
|
+
required: true;
|
|
2484
|
+
}): Promise<LeanOrHydratedDocument<Definition, Options>>;
|
|
2480
2485
|
fetchAll<Options extends QueryOptions<Definition>>(filter?: RootFilterQuery<Definition>, projection?: ProjectionType<Definition>, options?: Options): Promise<LeanOrHydratedDocument<Definition, Options>[]>;
|
|
2481
2486
|
update<Options extends QueryOptions<Definition>>(filter: RootFilterQuery<Definition>, update: UpdateQuery<Definition>, options?: Options): Promise<LeanOrHydratedDocument<Definition, Options> | null | undefined>;
|
|
2482
2487
|
updateAll(filter: RootFilterQuery<Definition>, update: UpdateQuery<Definition>, options?: mongo.UpdateOptions & MongooseUpdateQueryOptions<Definition>): Promise<mongoose.UpdateWriteOpResult>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2460,7 +2460,7 @@ declare class MongoSchemaBuilder<Definition extends object = any> {
|
|
|
2460
2460
|
execute<T extends (model: Model<Definition>) => any>(fn: T, maxRetries?: number): Promise<ExtractReturn<T>>;
|
|
2461
2461
|
startSession(options?: ClientSessionOptions): Promise<mongo.ClientSession>;
|
|
2462
2462
|
useTransaction(fn: (session: ClientSession, model: Model<Definition>) => any): Promise<void>;
|
|
2463
|
-
|
|
2463
|
+
createUniqueId(collisionPath: keyof Require_id<Definition>, fn: () => string, maxRetries?: number): Promise<string>;
|
|
2464
2464
|
count(filter?: RootFilterQuery<Definition>, options?: mongo.CountOptions & MongooseBaseQueryOptions<Definition> & mongo.Abortable): Promise<number>;
|
|
2465
2465
|
exists(filter: RootFilterQuery<Definition>): Promise<boolean>;
|
|
2466
2466
|
create(query: Partial<Require_id<Definition>>[], options?: CreateOptions): Promise<(Document<unknown, {}, Definition, {}, {}> & (Require_id<Definition> extends infer T ? T extends Require_id<Definition> ? T extends {
|
|
@@ -2468,15 +2468,20 @@ declare class MongoSchemaBuilder<Definition extends object = any> {
|
|
|
2468
2468
|
} ? T : T & {
|
|
2469
2469
|
__v: number;
|
|
2470
2470
|
} : never : never))[]>;
|
|
2471
|
-
upsert(filter: RootFilterQuery<Definition>, query: Partial<Require_id<Definition>>, options?: QueryOptions<Definition>): Promise<Document<unknown, {}, Definition, {}, {}> & (Require_id<Definition> extends infer T ? T extends Require_id<Definition> ? T extends {
|
|
2471
|
+
upsert(filter: RootFilterQuery<Definition>, query: Partial<Require_id<Definition>>, options?: Exclude<QueryOptions<Definition>, "upsert">): Promise<(Document<unknown, {}, Definition, {}, {}> & (Require_id<Definition> extends infer T ? T extends Require_id<Definition> ? T extends {
|
|
2472
2472
|
__v?: infer U;
|
|
2473
2473
|
} ? T : T & {
|
|
2474
2474
|
__v: number;
|
|
2475
|
-
} : never : never)>;
|
|
2475
|
+
} : never : never)) | null>;
|
|
2476
2476
|
delete(filter: RootFilterQuery<Definition>, options?: mongo.DeleteOptions & MongooseBaseQueryOptions<Definition>): Promise<mongo.DeleteResult>;
|
|
2477
2477
|
deleteAll(filter: RootFilterQuery<Definition>, options?: mongo.DeleteOptions & MongooseBaseQueryOptions<Definition>): Promise<mongo.DeleteResult>;
|
|
2478
2478
|
distinct<K extends keyof Require_id<Definition> & string>(key: K, filter?: RootFilterQuery<Definition>, options?: QueryOptions<Definition>): Promise<(K extends keyof Definition | mongoose.NestedPaths<Required<Definition>, keyof Definition> ? mongoose.WithoutUndefined<mongoose.Unpacked<mongoose.WithLevel1NestedPaths<Definition, keyof Definition>[K]>> : unknown)[]>;
|
|
2479
|
-
fetch<Options extends QueryOptions<Definition>>(filter?: RootFilterQuery<Definition>, projection?: ProjectionType<Definition>, options?: Options
|
|
2479
|
+
fetch<Options extends QueryOptions<Definition>>(filter?: RootFilterQuery<Definition>, projection?: ProjectionType<Definition>, options?: Options & {
|
|
2480
|
+
required?: boolean;
|
|
2481
|
+
}): Promise<LeanOrHydratedDocument<Definition, Options> | null | undefined>;
|
|
2482
|
+
fetch<Options extends QueryOptions<Definition>>(filter?: RootFilterQuery<Definition>, projection?: ProjectionType<Definition>, options?: Options & {
|
|
2483
|
+
required: true;
|
|
2484
|
+
}): Promise<LeanOrHydratedDocument<Definition, Options>>;
|
|
2480
2485
|
fetchAll<Options extends QueryOptions<Definition>>(filter?: RootFilterQuery<Definition>, projection?: ProjectionType<Definition>, options?: Options): Promise<LeanOrHydratedDocument<Definition, Options>[]>;
|
|
2481
2486
|
update<Options extends QueryOptions<Definition>>(filter: RootFilterQuery<Definition>, update: UpdateQuery<Definition>, options?: Options): Promise<LeanOrHydratedDocument<Definition, Options> | null | undefined>;
|
|
2482
2487
|
updateAll(filter: RootFilterQuery<Definition>, update: UpdateQuery<Definition>, options?: mongo.UpdateOptions & MongooseUpdateQueryOptions<Definition>): Promise<mongoose.UpdateWriteOpResult>;
|
package/dist/index.js
CHANGED
|
@@ -1693,7 +1693,7 @@ var VimcordErrorHandler = class {
|
|
|
1693
1693
|
import chalk2 from "chalk";
|
|
1694
1694
|
|
|
1695
1695
|
// package.json
|
|
1696
|
-
var version = "1.0.
|
|
1696
|
+
var version = "1.0.48";
|
|
1697
1697
|
|
|
1698
1698
|
// src/client/vimcord.logger.ts
|
|
1699
1699
|
var clientLoggerFactory = (client) => new Logger({ prefixEmoji: "\u26A1", prefix: `vimcord (i${client.clientId})` }).extend({
|
|
@@ -2980,8 +2980,7 @@ var MongoDatabase = class _MongoDatabase {
|
|
|
2980
2980
|
import {
|
|
2981
2981
|
Schema
|
|
2982
2982
|
} from "mongoose";
|
|
2983
|
-
import {
|
|
2984
|
-
import { $ as $6 } from "qznt";
|
|
2983
|
+
import { retry } from "qznt";
|
|
2985
2984
|
try {
|
|
2986
2985
|
import("mongoose");
|
|
2987
2986
|
} catch {
|
|
@@ -3067,7 +3066,7 @@ var MongoSchemaBuilder = class _MongoSchemaBuilder {
|
|
|
3067
3066
|
* @param maxRetries [default: 3]
|
|
3068
3067
|
*/
|
|
3069
3068
|
async execute(fn, maxRetries = 3) {
|
|
3070
|
-
return
|
|
3069
|
+
return retry(
|
|
3071
3070
|
async () => {
|
|
3072
3071
|
const model = await this.getModel();
|
|
3073
3072
|
return await fn(model);
|
|
@@ -3076,82 +3075,81 @@ var MongoSchemaBuilder = class _MongoSchemaBuilder {
|
|
|
3076
3075
|
);
|
|
3077
3076
|
}
|
|
3078
3077
|
async startSession(options) {
|
|
3079
|
-
return
|
|
3078
|
+
return this.execute(async () => {
|
|
3080
3079
|
if (!this.db) throw new Error("No database instance found");
|
|
3081
3080
|
return await this.db.startSession(options);
|
|
3082
3081
|
});
|
|
3083
3082
|
}
|
|
3084
3083
|
async useTransaction(fn) {
|
|
3085
|
-
return
|
|
3084
|
+
return this.execute(async (model) => {
|
|
3086
3085
|
if (!this.db) throw new Error("No database instance found");
|
|
3087
3086
|
return await this.db.useTransaction((session) => fn(session, model));
|
|
3088
3087
|
});
|
|
3089
3088
|
}
|
|
3090
|
-
async
|
|
3091
|
-
return
|
|
3092
|
-
|
|
3093
|
-
let id = createHex();
|
|
3089
|
+
async createUniqueId(collisionPath, fn, maxRetries = 10) {
|
|
3090
|
+
return this.execute(async (model) => {
|
|
3091
|
+
let id;
|
|
3094
3092
|
let tries = 0;
|
|
3095
|
-
|
|
3096
|
-
if (tries >= maxRetries) throw Error(`Failed to generate a unique
|
|
3097
|
-
id =
|
|
3093
|
+
do {
|
|
3094
|
+
if (tries >= maxRetries) throw new Error(`Failed to generate a unique ID after ${tries} attempt(s)`);
|
|
3095
|
+
id = fn();
|
|
3098
3096
|
tries++;
|
|
3099
|
-
}
|
|
3097
|
+
} while (await model.exists({ [collisionPath]: id }));
|
|
3100
3098
|
return id;
|
|
3101
3099
|
});
|
|
3102
3100
|
}
|
|
3103
3101
|
async count(filter, options) {
|
|
3104
|
-
return
|
|
3102
|
+
return this.execute(async (model) => model.countDocuments(filter, options));
|
|
3105
3103
|
}
|
|
3106
3104
|
async exists(filter) {
|
|
3107
|
-
return
|
|
3105
|
+
return this.execute(async (model) => !!await model.exists(filter));
|
|
3108
3106
|
}
|
|
3109
3107
|
async create(query, options) {
|
|
3110
|
-
return
|
|
3108
|
+
return this.execute(async (model) => model.create(query, options));
|
|
3111
3109
|
}
|
|
3112
3110
|
async upsert(filter, query, options) {
|
|
3113
|
-
return
|
|
3114
|
-
async (model) => model.findOneAndUpdate(filter, query, { ...options, upsert: true
|
|
3111
|
+
return this.execute(
|
|
3112
|
+
async (model) => model.findOneAndUpdate(filter, query, { returnDocument: "after", ...options, upsert: true })
|
|
3115
3113
|
);
|
|
3116
3114
|
}
|
|
3117
3115
|
async delete(filter, options) {
|
|
3118
|
-
return
|
|
3116
|
+
return this.execute(async (model) => model.deleteOne(filter, options));
|
|
3119
3117
|
}
|
|
3120
3118
|
async deleteAll(filter, options) {
|
|
3121
|
-
return
|
|
3119
|
+
return this.execute(async (model) => model.deleteMany(filter, options));
|
|
3122
3120
|
}
|
|
3123
3121
|
async distinct(key, filter, options) {
|
|
3124
|
-
return
|
|
3122
|
+
return this.execute(async (model) => model.distinct(key, filter, options));
|
|
3125
3123
|
}
|
|
3126
3124
|
async fetch(filter, projection, options) {
|
|
3127
|
-
|
|
3125
|
+
const result = await this.execute(
|
|
3128
3126
|
async (model) => model.findOne(filter, projection, { ...options, lean: options?.lean ?? true })
|
|
3129
3127
|
);
|
|
3128
|
+
if (options?.required && !result) throw new Error("Document not found");
|
|
3129
|
+
return result;
|
|
3130
3130
|
}
|
|
3131
3131
|
async fetchAll(filter = {}, projection, options) {
|
|
3132
|
-
return
|
|
3133
|
-
async (model) => model.find(filter, projection, { ...options, lean: options?.lean ?? true })
|
|
3134
|
-
);
|
|
3132
|
+
return this.execute(async (model) => model.find(filter, projection, { ...options, lean: options?.lean ?? true }));
|
|
3135
3133
|
}
|
|
3136
3134
|
async update(filter, update, options) {
|
|
3137
|
-
return
|
|
3135
|
+
return this.execute(
|
|
3138
3136
|
async (model) => model.findOneAndUpdate(filter, update, { ...options, lean: options?.lean ?? true })
|
|
3139
3137
|
);
|
|
3140
3138
|
}
|
|
3141
3139
|
async updateAll(filter, update, options) {
|
|
3142
|
-
return
|
|
3140
|
+
return this.execute(async (model) => model.updateMany(filter, update, options));
|
|
3143
3141
|
}
|
|
3144
3142
|
async aggregate(pipeline, options) {
|
|
3145
|
-
return
|
|
3143
|
+
return this.execute(async (model) => {
|
|
3146
3144
|
const result = await model.aggregate(pipeline, options);
|
|
3147
3145
|
return result?.length ? result : [];
|
|
3148
3146
|
});
|
|
3149
3147
|
}
|
|
3150
3148
|
async bulkWrite(ops, options) {
|
|
3151
|
-
return
|
|
3149
|
+
return this.execute(async (model) => model.bulkWrite(ops, options));
|
|
3152
3150
|
}
|
|
3153
3151
|
async bulkSave(docs, options) {
|
|
3154
|
-
return
|
|
3152
|
+
return this.execute(async (model) => model.bulkSave(docs, options));
|
|
3155
3153
|
}
|
|
3156
3154
|
};
|
|
3157
3155
|
|
|
@@ -3484,7 +3482,7 @@ import {
|
|
|
3484
3482
|
TextInputStyle,
|
|
3485
3483
|
UserSelectMenuBuilder
|
|
3486
3484
|
} from "discord.js";
|
|
3487
|
-
import { $ as $
|
|
3485
|
+
import { $ as $6 } from "qznt";
|
|
3488
3486
|
var BetterModal = class {
|
|
3489
3487
|
id;
|
|
3490
3488
|
options;
|
|
@@ -3504,10 +3502,10 @@ var BetterModal = class {
|
|
|
3504
3502
|
}
|
|
3505
3503
|
}
|
|
3506
3504
|
createModalId() {
|
|
3507
|
-
return `modal:${$
|
|
3505
|
+
return `modal:${$6.rnd.str(10, "alpha", { casing: "mixed" })}-${Date.now()}`;
|
|
3508
3506
|
}
|
|
3509
3507
|
createComponentId() {
|
|
3510
|
-
return `modal-component:${this.id}-${$
|
|
3508
|
+
return `modal-component:${this.id}-${$6.rnd.str(4, "alpha", { casing: "mixed" })}-${Date.now().toString().slice(-4)}`;
|
|
3511
3509
|
}
|
|
3512
3510
|
validateComponentLength() {
|
|
3513
3511
|
if (this.components.size >= 5) throw new Error("Modal can only have 5 components");
|