@sfxcode/nuxt-mongocamp-server 1.4.4 → 1.5.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/README.md +63 -0
- package/dist/module.d.mts +16 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +20 -642
- package/dist/runtime/composables/mongocampApi.d.ts +11 -22
- package/dist/runtime/composables/mongocampApi.js +4 -37
- package/dist/runtime/composables/mongocampApiAdmin.d.ts +15 -0
- package/dist/runtime/composables/mongocampApiAdmin.js +41 -0
- package/dist/runtime/composables/mongocampApiCollection.d.ts +26 -0
- package/dist/runtime/composables/mongocampApiCollection.js +40 -0
- package/dist/runtime/composables/mongocampApiCollections.d.ts +8 -0
- package/dist/runtime/composables/mongocampApiCollections.js +23 -0
- package/dist/runtime/composables/mongocampApiFiles.d.ts +14 -0
- package/dist/runtime/composables/mongocampApiFiles.js +38 -0
- package/dist/runtime/composables/mongocampApiJobs.d.ts +9 -0
- package/dist/runtime/composables/mongocampApiJobs.js +23 -0
- package/dist/runtime/composables/mongocampAuth.js +30 -22
- package/dist/runtime/composables/mongocampSearch.d.ts +23 -1
- package/dist/runtime/composables/mongocampSearch.js +34 -1
- package/dist/runtime/composables/mongocampStorage.d.ts +3 -2
- package/dist/runtime/composables/mongocampStorage.js +4 -3
- package/dist/runtime/composables/mongocampUser.js +1 -1
- package/dist/runtime/server/composables/mongocampApi.d.ts +14 -0
- package/dist/runtime/server/composables/mongocampApi.js +8 -0
- package/dist/runtime/server/composables/mongocampServerApi.d.ts +11 -12
- package/dist/runtime/server/composables/mongocampServerApi.js +4 -39
- package/dist/runtime/utils/buildFieldFilterExpression.d.ts +2 -0
- package/dist/runtime/utils/buildFieldFilterExpression.js +7 -0
- package/dist/runtime/utils/createMongocampApis.d.ts +15 -0
- package/dist/runtime/utils/createMongocampApis.js +28 -0
- package/dist/runtime/utils/toMongocampError.d.ts +7 -0
- package/dist/runtime/utils/toMongocampError.js +19 -0
- package/dist/types.d.mts +1 -1
- package/package.json +9 -3
package/dist/module.mjs
CHANGED
|
@@ -1,638 +1,10 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addImportsDir, addServerImportsDir } from '@nuxt/kit';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (value === null || typeof value !== "object") {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
const prototype = Object.getPrototypeOf(value);
|
|
9
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
if (Symbol.iterator in value) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
if (Symbol.toStringTag in value) {
|
|
16
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function _defu$1(baseObject, defaults, namespace = ".", merger) {
|
|
22
|
-
if (!isPlainObject$2(defaults)) {
|
|
23
|
-
return _defu$1(baseObject, {}, namespace, merger);
|
|
24
|
-
}
|
|
25
|
-
const object = { ...defaults };
|
|
26
|
-
for (const key of Object.keys(baseObject)) {
|
|
27
|
-
if (key === "__proto__" || key === "constructor") {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const value = baseObject[key];
|
|
31
|
-
if (value === null || value === void 0) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
38
|
-
object[key] = [...value, ...object[key]];
|
|
39
|
-
} else if (isPlainObject$2(value) && isPlainObject$2(object[key])) {
|
|
40
|
-
object[key] = _defu$1(
|
|
41
|
-
value,
|
|
42
|
-
object[key],
|
|
43
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
44
|
-
merger
|
|
45
|
-
);
|
|
46
|
-
} else {
|
|
47
|
-
object[key] = value;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return object;
|
|
51
|
-
}
|
|
52
|
-
function createDefu$1(merger) {
|
|
53
|
-
return (...arguments_) => (
|
|
54
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
55
|
-
arguments_.reduce((p, c) => _defu$1(p, c, "", merger), {})
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
const defu$1 = createDefu$1();
|
|
59
|
-
|
|
60
|
-
const LogLevels = {
|
|
61
|
-
fatal: 0,
|
|
62
|
-
error: 0,
|
|
63
|
-
warn: 1,
|
|
64
|
-
log: 2,
|
|
65
|
-
info: 3,
|
|
66
|
-
success: 3,
|
|
67
|
-
fail: 3,
|
|
68
|
-
debug: 4,
|
|
69
|
-
trace: 5,
|
|
70
|
-
verbose: Number.POSITIVE_INFINITY
|
|
71
|
-
};
|
|
72
|
-
const LogTypes = {
|
|
73
|
-
// Silent
|
|
74
|
-
silent: {
|
|
75
|
-
level: -1
|
|
76
|
-
},
|
|
77
|
-
// Level 0
|
|
78
|
-
fatal: {
|
|
79
|
-
level: LogLevels.fatal
|
|
80
|
-
},
|
|
81
|
-
error: {
|
|
82
|
-
level: LogLevels.error
|
|
83
|
-
},
|
|
84
|
-
// Level 1
|
|
85
|
-
warn: {
|
|
86
|
-
level: LogLevels.warn
|
|
87
|
-
},
|
|
88
|
-
// Level 2
|
|
89
|
-
log: {
|
|
90
|
-
level: LogLevels.log
|
|
91
|
-
},
|
|
92
|
-
// Level 3
|
|
93
|
-
info: {
|
|
94
|
-
level: LogLevels.info
|
|
95
|
-
},
|
|
96
|
-
success: {
|
|
97
|
-
level: LogLevels.success
|
|
98
|
-
},
|
|
99
|
-
fail: {
|
|
100
|
-
level: LogLevels.fail
|
|
101
|
-
},
|
|
102
|
-
ready: {
|
|
103
|
-
level: LogLevels.info
|
|
104
|
-
},
|
|
105
|
-
start: {
|
|
106
|
-
level: LogLevels.info
|
|
107
|
-
},
|
|
108
|
-
box: {
|
|
109
|
-
level: LogLevels.info
|
|
110
|
-
},
|
|
111
|
-
// Level 4
|
|
112
|
-
debug: {
|
|
113
|
-
level: LogLevels.debug
|
|
114
|
-
},
|
|
115
|
-
// Level 5
|
|
116
|
-
trace: {
|
|
117
|
-
level: LogLevels.trace
|
|
118
|
-
},
|
|
119
|
-
// Verbose
|
|
120
|
-
verbose: {
|
|
121
|
-
level: LogLevels.verbose
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
function isPlainObject$1(value) {
|
|
126
|
-
if (value === null || typeof value !== "object") {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
const prototype = Object.getPrototypeOf(value);
|
|
130
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
if (Symbol.iterator in value) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
if (Symbol.toStringTag in value) {
|
|
137
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
143
|
-
if (!isPlainObject$1(defaults)) {
|
|
144
|
-
return _defu(baseObject, {}, namespace);
|
|
145
|
-
}
|
|
146
|
-
const object = Object.assign({}, defaults);
|
|
147
|
-
for (const key in baseObject) {
|
|
148
|
-
if (key === "__proto__" || key === "constructor") {
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const value = baseObject[key];
|
|
152
|
-
if (value === null || value === void 0) {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
156
|
-
object[key] = [...value, ...object[key]];
|
|
157
|
-
} else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
|
|
158
|
-
object[key] = _defu(
|
|
159
|
-
value,
|
|
160
|
-
object[key],
|
|
161
|
-
(namespace ? `${namespace}.` : "") + key.toString());
|
|
162
|
-
} else {
|
|
163
|
-
object[key] = value;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return object;
|
|
167
|
-
}
|
|
168
|
-
function createDefu(merger) {
|
|
169
|
-
return (...arguments_) => (
|
|
170
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
171
|
-
arguments_.reduce((p, c) => _defu(p, c, ""), {})
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
const defu = createDefu();
|
|
175
|
-
|
|
176
|
-
function isPlainObject(obj) {
|
|
177
|
-
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
178
|
-
}
|
|
179
|
-
function isLogObj(arg) {
|
|
180
|
-
if (!isPlainObject(arg)) {
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
if (!arg.message && !arg.args) {
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
if (arg.stack) {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
let paused = false;
|
|
193
|
-
const queue = [];
|
|
194
|
-
class Consola {
|
|
195
|
-
options;
|
|
196
|
-
_lastLog;
|
|
197
|
-
_mockFn;
|
|
198
|
-
/**
|
|
199
|
-
* Creates an instance of Consola with specified options or defaults.
|
|
200
|
-
*
|
|
201
|
-
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
202
|
-
*/
|
|
203
|
-
constructor(options = {}) {
|
|
204
|
-
const types = options.types || LogTypes;
|
|
205
|
-
this.options = defu(
|
|
206
|
-
{
|
|
207
|
-
...options,
|
|
208
|
-
defaults: { ...options.defaults },
|
|
209
|
-
level: _normalizeLogLevel(options.level, types),
|
|
210
|
-
reporters: [...options.reporters || []]
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
types: LogTypes,
|
|
214
|
-
throttle: 1e3,
|
|
215
|
-
throttleMin: 5,
|
|
216
|
-
formatOptions: {
|
|
217
|
-
date: true,
|
|
218
|
-
colors: false,
|
|
219
|
-
compact: true
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
);
|
|
223
|
-
for (const type in types) {
|
|
224
|
-
const defaults = {
|
|
225
|
-
type,
|
|
226
|
-
...this.options.defaults,
|
|
227
|
-
...types[type]
|
|
228
|
-
};
|
|
229
|
-
this[type] = this._wrapLogFn(defaults);
|
|
230
|
-
this[type].raw = this._wrapLogFn(
|
|
231
|
-
defaults,
|
|
232
|
-
true
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
if (this.options.mockFn) {
|
|
236
|
-
this.mockTypes();
|
|
237
|
-
}
|
|
238
|
-
this._lastLog = {};
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Gets the current log level of the Consola instance.
|
|
242
|
-
*
|
|
243
|
-
* @returns {number} The current log level.
|
|
244
|
-
*/
|
|
245
|
-
get level() {
|
|
246
|
-
return this.options.level;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Sets the minimum log level that will be output by the instance.
|
|
250
|
-
*
|
|
251
|
-
* @param {number} level - The new log level to set.
|
|
252
|
-
*/
|
|
253
|
-
set level(level) {
|
|
254
|
-
this.options.level = _normalizeLogLevel(
|
|
255
|
-
level,
|
|
256
|
-
this.options.types,
|
|
257
|
-
this.options.level
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Displays a prompt to the user and returns the response.
|
|
262
|
-
* Throw an error if `prompt` is not supported by the current configuration.
|
|
263
|
-
*
|
|
264
|
-
* @template T
|
|
265
|
-
* @param {string} message - The message to display in the prompt.
|
|
266
|
-
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
267
|
-
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
268
|
-
*/
|
|
269
|
-
prompt(message, opts) {
|
|
270
|
-
if (!this.options.prompt) {
|
|
271
|
-
throw new Error("prompt is not supported!");
|
|
272
|
-
}
|
|
273
|
-
return this.options.prompt(message, opts);
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
277
|
-
*
|
|
278
|
-
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
279
|
-
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
280
|
-
*/
|
|
281
|
-
create(options) {
|
|
282
|
-
const instance = new Consola({
|
|
283
|
-
...this.options,
|
|
284
|
-
...options
|
|
285
|
-
});
|
|
286
|
-
if (this._mockFn) {
|
|
287
|
-
instance.mockTypes(this._mockFn);
|
|
288
|
-
}
|
|
289
|
-
return instance;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Creates a new Consola instance with the specified default log object properties.
|
|
293
|
-
*
|
|
294
|
-
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
295
|
-
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
296
|
-
*/
|
|
297
|
-
withDefaults(defaults) {
|
|
298
|
-
return this.create({
|
|
299
|
-
...this.options,
|
|
300
|
-
defaults: {
|
|
301
|
-
...this.options.defaults,
|
|
302
|
-
...defaults
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
308
|
-
*
|
|
309
|
-
* @param {string} tag - The tag to include in each log of the new instance.
|
|
310
|
-
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
311
|
-
*/
|
|
312
|
-
withTag(tag) {
|
|
313
|
-
return this.withDefaults({
|
|
314
|
-
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Adds a custom reporter to the Consola instance.
|
|
319
|
-
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
320
|
-
*
|
|
321
|
-
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
322
|
-
* @returns {Consola} The current Consola instance.
|
|
323
|
-
*/
|
|
324
|
-
addReporter(reporter) {
|
|
325
|
-
this.options.reporters.push(reporter);
|
|
326
|
-
return this;
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Removes a custom reporter from the Consola instance.
|
|
330
|
-
* If no reporter is specified, all reporters will be removed.
|
|
331
|
-
*
|
|
332
|
-
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
333
|
-
* @returns {Consola} The current Consola instance.
|
|
334
|
-
*/
|
|
335
|
-
removeReporter(reporter) {
|
|
336
|
-
if (reporter) {
|
|
337
|
-
const i = this.options.reporters.indexOf(reporter);
|
|
338
|
-
if (i !== -1) {
|
|
339
|
-
return this.options.reporters.splice(i, 1);
|
|
340
|
-
}
|
|
341
|
-
} else {
|
|
342
|
-
this.options.reporters.splice(0);
|
|
343
|
-
}
|
|
344
|
-
return this;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
348
|
-
*
|
|
349
|
-
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
350
|
-
* @returns {Consola} The current Consola instance.
|
|
351
|
-
*/
|
|
352
|
-
setReporters(reporters) {
|
|
353
|
-
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
354
|
-
return this;
|
|
355
|
-
}
|
|
356
|
-
wrapAll() {
|
|
357
|
-
this.wrapConsole();
|
|
358
|
-
this.wrapStd();
|
|
359
|
-
}
|
|
360
|
-
restoreAll() {
|
|
361
|
-
this.restoreConsole();
|
|
362
|
-
this.restoreStd();
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Overrides console methods with Consola logging methods for consistent logging.
|
|
366
|
-
*/
|
|
367
|
-
wrapConsole() {
|
|
368
|
-
for (const type in this.options.types) {
|
|
369
|
-
if (!console["__" + type]) {
|
|
370
|
-
console["__" + type] = console[type];
|
|
371
|
-
}
|
|
372
|
-
console[type] = this[type].raw;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Restores the original console methods, removing Consola overrides.
|
|
377
|
-
*/
|
|
378
|
-
restoreConsole() {
|
|
379
|
-
for (const type in this.options.types) {
|
|
380
|
-
if (console["__" + type]) {
|
|
381
|
-
console[type] = console["__" + type];
|
|
382
|
-
delete console["__" + type];
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Overrides standard output and error streams to redirect them through Consola.
|
|
388
|
-
*/
|
|
389
|
-
wrapStd() {
|
|
390
|
-
this._wrapStream(this.options.stdout, "log");
|
|
391
|
-
this._wrapStream(this.options.stderr, "log");
|
|
392
|
-
}
|
|
393
|
-
_wrapStream(stream, type) {
|
|
394
|
-
if (!stream) {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
if (!stream.__write) {
|
|
398
|
-
stream.__write = stream.write;
|
|
399
|
-
}
|
|
400
|
-
stream.write = (data) => {
|
|
401
|
-
this[type].raw(String(data).trim());
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
406
|
-
*/
|
|
407
|
-
restoreStd() {
|
|
408
|
-
this._restoreStream(this.options.stdout);
|
|
409
|
-
this._restoreStream(this.options.stderr);
|
|
410
|
-
}
|
|
411
|
-
_restoreStream(stream) {
|
|
412
|
-
if (!stream) {
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
if (stream.__write) {
|
|
416
|
-
stream.write = stream.__write;
|
|
417
|
-
delete stream.__write;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Pauses logging, queues incoming logs until resumed.
|
|
422
|
-
*/
|
|
423
|
-
pauseLogs() {
|
|
424
|
-
paused = true;
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Resumes logging, processing any queued logs.
|
|
428
|
-
*/
|
|
429
|
-
resumeLogs() {
|
|
430
|
-
paused = false;
|
|
431
|
-
const _queue = queue.splice(0);
|
|
432
|
-
for (const item of _queue) {
|
|
433
|
-
item[0]._logFn(item[1], item[2]);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Replaces logging methods with mocks if a mock function is provided.
|
|
438
|
-
*
|
|
439
|
-
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
440
|
-
*/
|
|
441
|
-
mockTypes(mockFn) {
|
|
442
|
-
const _mockFn = mockFn || this.options.mockFn;
|
|
443
|
-
this._mockFn = _mockFn;
|
|
444
|
-
if (typeof _mockFn !== "function") {
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
for (const type in this.options.types) {
|
|
448
|
-
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
449
|
-
this[type].raw = this[type];
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
_wrapLogFn(defaults, isRaw) {
|
|
453
|
-
return (...args) => {
|
|
454
|
-
if (paused) {
|
|
455
|
-
queue.push([this, defaults, args, isRaw]);
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
return this._logFn(defaults, args, isRaw);
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
_logFn(defaults, args, isRaw) {
|
|
462
|
-
if ((defaults.level || 0) > this.level) {
|
|
463
|
-
return false;
|
|
464
|
-
}
|
|
465
|
-
const logObj = {
|
|
466
|
-
date: /* @__PURE__ */ new Date(),
|
|
467
|
-
args: [],
|
|
468
|
-
...defaults,
|
|
469
|
-
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
470
|
-
};
|
|
471
|
-
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
472
|
-
Object.assign(logObj, args[0]);
|
|
473
|
-
} else {
|
|
474
|
-
logObj.args = [...args];
|
|
475
|
-
}
|
|
476
|
-
if (logObj.message) {
|
|
477
|
-
logObj.args.unshift(logObj.message);
|
|
478
|
-
delete logObj.message;
|
|
479
|
-
}
|
|
480
|
-
if (logObj.additional) {
|
|
481
|
-
if (!Array.isArray(logObj.additional)) {
|
|
482
|
-
logObj.additional = logObj.additional.split("\n");
|
|
483
|
-
}
|
|
484
|
-
logObj.args.push("\n" + logObj.additional.join("\n"));
|
|
485
|
-
delete logObj.additional;
|
|
486
|
-
}
|
|
487
|
-
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
488
|
-
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
489
|
-
const resolveLog = (newLog = false) => {
|
|
490
|
-
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
491
|
-
if (this._lastLog.object && repeated > 0) {
|
|
492
|
-
const args2 = [...this._lastLog.object.args];
|
|
493
|
-
if (repeated > 1) {
|
|
494
|
-
args2.push(`(repeated ${repeated} times)`);
|
|
495
|
-
}
|
|
496
|
-
this._log({ ...this._lastLog.object, args: args2 });
|
|
497
|
-
this._lastLog.count = 1;
|
|
498
|
-
}
|
|
499
|
-
if (newLog) {
|
|
500
|
-
this._lastLog.object = logObj;
|
|
501
|
-
this._log(logObj);
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
clearTimeout(this._lastLog.timeout);
|
|
505
|
-
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
506
|
-
this._lastLog.time = logObj.date;
|
|
507
|
-
if (diffTime < this.options.throttle) {
|
|
508
|
-
try {
|
|
509
|
-
const serializedLog = JSON.stringify([
|
|
510
|
-
logObj.type,
|
|
511
|
-
logObj.tag,
|
|
512
|
-
logObj.args
|
|
513
|
-
]);
|
|
514
|
-
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
515
|
-
this._lastLog.serialized = serializedLog;
|
|
516
|
-
if (isSameLog) {
|
|
517
|
-
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
518
|
-
if (this._lastLog.count > this.options.throttleMin) {
|
|
519
|
-
this._lastLog.timeout = setTimeout(
|
|
520
|
-
resolveLog,
|
|
521
|
-
this.options.throttle
|
|
522
|
-
);
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
} catch {
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
resolveLog(true);
|
|
530
|
-
}
|
|
531
|
-
_log(logObj) {
|
|
532
|
-
for (const reporter of this.options.reporters) {
|
|
533
|
-
reporter.log(logObj, {
|
|
534
|
-
options: this.options
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
540
|
-
if (input === void 0) {
|
|
541
|
-
return defaultLevel;
|
|
542
|
-
}
|
|
543
|
-
if (typeof input === "number") {
|
|
544
|
-
return input;
|
|
545
|
-
}
|
|
546
|
-
if (types[input] && types[input].level !== void 0) {
|
|
547
|
-
return types[input].level;
|
|
548
|
-
}
|
|
549
|
-
return defaultLevel;
|
|
550
|
-
}
|
|
551
|
-
Consola.prototype.add = Consola.prototype.addReporter;
|
|
552
|
-
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
553
|
-
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
554
|
-
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
555
|
-
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
556
|
-
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
557
|
-
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
558
|
-
function createConsola$1(options = {}) {
|
|
559
|
-
return new Consola(options);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
class BrowserReporter {
|
|
563
|
-
options;
|
|
564
|
-
defaultColor;
|
|
565
|
-
levelColorMap;
|
|
566
|
-
typeColorMap;
|
|
567
|
-
constructor(options) {
|
|
568
|
-
this.options = { ...options };
|
|
569
|
-
this.defaultColor = "#7f8c8d";
|
|
570
|
-
this.levelColorMap = {
|
|
571
|
-
0: "#c0392b",
|
|
572
|
-
// Red
|
|
573
|
-
1: "#f39c12",
|
|
574
|
-
// Yellow
|
|
575
|
-
3: "#00BCD4"
|
|
576
|
-
// Cyan
|
|
577
|
-
};
|
|
578
|
-
this.typeColorMap = {
|
|
579
|
-
success: "#2ecc71"
|
|
580
|
-
// Green
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
_getLogFn(level) {
|
|
584
|
-
if (level < 1) {
|
|
585
|
-
return console.__error || console.error;
|
|
586
|
-
}
|
|
587
|
-
if (level === 1) {
|
|
588
|
-
return console.__warn || console.warn;
|
|
589
|
-
}
|
|
590
|
-
return console.__log || console.log;
|
|
591
|
-
}
|
|
592
|
-
log(logObj) {
|
|
593
|
-
const consoleLogFn = this._getLogFn(logObj.level);
|
|
594
|
-
const type = logObj.type === "log" ? "" : logObj.type;
|
|
595
|
-
const tag = logObj.tag || "";
|
|
596
|
-
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
|
|
597
|
-
const style = `
|
|
598
|
-
background: ${color};
|
|
599
|
-
border-radius: 0.5em;
|
|
600
|
-
color: white;
|
|
601
|
-
font-weight: bold;
|
|
602
|
-
padding: 2px 0.5em;
|
|
603
|
-
`;
|
|
604
|
-
const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
|
|
605
|
-
if (typeof logObj.args[0] === "string") {
|
|
606
|
-
consoleLogFn(
|
|
607
|
-
`${badge}%c ${logObj.args[0]}`,
|
|
608
|
-
style,
|
|
609
|
-
// Empty string as style resets to default console style
|
|
610
|
-
"",
|
|
611
|
-
...logObj.args.slice(1)
|
|
612
|
-
);
|
|
613
|
-
} else {
|
|
614
|
-
consoleLogFn(badge, style, ...logObj.args);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
function createConsola(options = {}) {
|
|
620
|
-
const consola2 = createConsola$1({
|
|
621
|
-
reporters: options.reporters || [new BrowserReporter({})],
|
|
622
|
-
prompt(message, options2 = {}) {
|
|
623
|
-
if (options2.type === "confirm") {
|
|
624
|
-
return Promise.resolve(confirm(message));
|
|
625
|
-
}
|
|
626
|
-
return Promise.resolve(prompt(message));
|
|
627
|
-
},
|
|
628
|
-
...options
|
|
629
|
-
});
|
|
630
|
-
return consola2;
|
|
631
|
-
}
|
|
632
|
-
const consola = createConsola();
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
import { consola } from 'consola';
|
|
4
|
+
export * from '../dist/runtime/api/index.js';
|
|
633
5
|
|
|
634
6
|
const name = "@sfxcode/nuxt-mongocamp-server";
|
|
635
|
-
const version = "1.
|
|
7
|
+
const version = "1.5.0";
|
|
636
8
|
|
|
637
9
|
const module$1 = defineNuxtModule({
|
|
638
10
|
meta: {
|
|
@@ -644,24 +16,30 @@ const module$1 = defineNuxtModule({
|
|
|
644
16
|
}
|
|
645
17
|
},
|
|
646
18
|
setup(options, nuxt) {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
19
|
+
nuxt.hook("ready", () => {
|
|
20
|
+
if (nuxt.options._prepare)
|
|
21
|
+
return;
|
|
22
|
+
if (!options.url || options.url.length === 0)
|
|
23
|
+
throw new Error('[mongocamp] Missing required "url" module option.');
|
|
24
|
+
});
|
|
25
|
+
if (options.paginationSize !== void 0 && options.paginationSize < 10)
|
|
26
|
+
consola.warn(`[mongocamp] paginationSize of ${options.paginationSize} is below the minimum of 10, falling back to 500`);
|
|
27
|
+
if (!options.paginationSize || options.paginationSize < 10)
|
|
651
28
|
options.paginationSize = 500;
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
nuxt.options.runtimeConfig.public.mongocamp = defu
|
|
29
|
+
if (options.tokenRefreshInterval !== void 0 && options.tokenRefreshInterval < 5e3)
|
|
30
|
+
consola.warn(`[mongocamp] tokenRefreshInterval of ${options.tokenRefreshInterval} is below the minimum of 5000, falling back to 5000`);
|
|
31
|
+
if (!options.tokenRefreshInterval || options.tokenRefreshInterval < 5e3)
|
|
32
|
+
options.tokenRefreshInterval = 5e3;
|
|
33
|
+
nuxt.options.runtimeConfig.public.mongocamp = defu(
|
|
657
34
|
nuxt.options.runtimeConfig.public.mongocamp,
|
|
658
35
|
{
|
|
659
36
|
url: options.url,
|
|
660
37
|
paginationSize: options.paginationSize,
|
|
661
38
|
refreshToken: options.refreshToken,
|
|
662
|
-
|
|
39
|
+
tokenRefreshInterval: options.tokenRefreshInterval
|
|
663
40
|
}
|
|
664
41
|
);
|
|
42
|
+
nuxt.options.runtimeConfig.mongocampApiKey = nuxt.options.runtimeConfig.mongocampApiKey ?? options.apiKey ?? "";
|
|
665
43
|
const { resolve } = createResolver(import.meta.url);
|
|
666
44
|
const runtimeDir = resolve("./runtime");
|
|
667
45
|
addImportsDir(resolve(runtimeDir, "composables"));
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
import { AdminApi } from '../api/apis/AdminApi.js';
|
|
2
|
-
import { ApplicationApi } from '../api/apis/ApplicationApi.js';
|
|
3
|
-
import { AuthApi } from '../api/apis/AuthApi.js';
|
|
4
|
-
import { BucketApi } from '../api/apis/BucketApi.js';
|
|
5
|
-
import { CollectionApi } from '../api/apis/CollectionApi.js';
|
|
6
|
-
import { DatabaseApi } from '../api/apis/DatabaseApi.js';
|
|
7
|
-
import { DocumentApi } from '../api/apis/DocumentApi.js';
|
|
8
|
-
import { FileApi } from '../api/apis/FileApi.js';
|
|
9
|
-
import { IndexApi } from '../api/apis/IndexApi.js';
|
|
10
|
-
import { InformationApi } from '../api/apis/InformationApi.js';
|
|
11
|
-
import { JobsApi } from '../api/apis/JobsApi.js';
|
|
12
1
|
export declare function useMongocampApi(): {
|
|
13
|
-
adminApi: AdminApi;
|
|
14
|
-
applicationApi: ApplicationApi;
|
|
15
|
-
authApi: AuthApi;
|
|
16
|
-
bucketApi: BucketApi;
|
|
17
|
-
collectionApi: CollectionApi;
|
|
18
|
-
databaseApi: DatabaseApi;
|
|
19
|
-
documentApi: DocumentApi;
|
|
20
|
-
fileApi: FileApi;
|
|
21
|
-
indexApi: IndexApi;
|
|
22
|
-
informationApi: InformationApi;
|
|
23
|
-
jobApi: JobsApi;
|
|
2
|
+
adminApi: import("../api/index.js").AdminApi;
|
|
3
|
+
applicationApi: import("../api/index.js").ApplicationApi;
|
|
4
|
+
authApi: import("../api/index.js").AuthApi;
|
|
5
|
+
bucketApi: import("../api/index.js").BucketApi;
|
|
6
|
+
collectionApi: import("../api/index.js").CollectionApi;
|
|
7
|
+
databaseApi: import("../api/index.js").DatabaseApi;
|
|
8
|
+
documentApi: import("../api/index.js").DocumentApi;
|
|
9
|
+
fileApi: import("../api/index.js").FileApi;
|
|
10
|
+
indexApi: import("../api/index.js").IndexApi;
|
|
11
|
+
informationApi: import("../api/index.js").InformationApi;
|
|
12
|
+
jobApi: import("../api/index.js").JobsApi;
|
|
24
13
|
};
|