@sfxcode/nuxt-mongocamp-server 1.2.3 → 1.2.4

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/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-mongocamp-server",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "configKey": "mongocamp",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.0.0"
package/dist/module.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
2
2
 
3
- function isPlainObject$1(value) {
3
+ function isPlainObject$2(value) {
4
4
  if (value === null || typeof value !== "object") {
5
5
  return false;
6
6
  }
@@ -18,7 +18,7 @@ function isPlainObject$1(value) {
18
18
  }
19
19
 
20
20
  function _defu$1(baseObject, defaults, namespace = ".", merger) {
21
- if (!isPlainObject$1(defaults)) {
21
+ if (!isPlainObject$2(defaults)) {
22
22
  return _defu$1(baseObject, {}, namespace, merger);
23
23
  }
24
24
  const object = Object.assign({}, defaults);
@@ -35,7 +35,7 @@ function _defu$1(baseObject, defaults, namespace = ".", merger) {
35
35
  }
36
36
  if (Array.isArray(value) && Array.isArray(object[key])) {
37
37
  object[key] = [...value, ...object[key]];
38
- } else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
38
+ } else if (isPlainObject$2(value) && isPlainObject$2(object[key])) {
39
39
  object[key] = _defu$1(
40
40
  value,
41
41
  object[key],
@@ -125,11 +125,25 @@ const LogTypes = {
125
125
  }
126
126
  };
127
127
 
128
- function isObject(value) {
129
- return value !== null && typeof value === "object";
128
+ function isPlainObject$1(value) {
129
+ if (value === null || typeof value !== "object") {
130
+ return false;
131
+ }
132
+ const prototype = Object.getPrototypeOf(value);
133
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
134
+ return false;
135
+ }
136
+ if (Symbol.iterator in value) {
137
+ return false;
138
+ }
139
+ if (Symbol.toStringTag in value) {
140
+ return Object.prototype.toString.call(value) === "[object Module]";
141
+ }
142
+ return true;
130
143
  }
144
+
131
145
  function _defu(baseObject, defaults, namespace = ".", merger) {
132
- if (!isObject(defaults)) {
146
+ if (!isPlainObject$1(defaults)) {
133
147
  return _defu(baseObject, {}, namespace, merger);
134
148
  }
135
149
  const object = Object.assign({}, defaults);
@@ -138,7 +152,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
138
152
  continue;
139
153
  }
140
154
  const value = baseObject[key];
141
- if (value === null || value === void 0) {
155
+ if (value === null || value === undefined) {
142
156
  continue;
143
157
  }
144
158
  if (merger && merger(object, key, value, namespace)) {
@@ -146,7 +160,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
146
160
  }
147
161
  if (Array.isArray(value) && Array.isArray(object[key])) {
148
162
  object[key] = [...value, ...object[key]];
149
- } else if (isObject(value) && isObject(object[key])) {
163
+ } else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
150
164
  object[key] = _defu(
151
165
  value,
152
166
  object[key],
@@ -186,6 +200,14 @@ function isLogObj(arg) {
186
200
  let paused = false;
187
201
  const queue = [];
188
202
  class Consola {
203
+ options;
204
+ _lastLog;
205
+ _mockFn;
206
+ /**
207
+ * Creates an instance of Consola with specified options or defaults.
208
+ *
209
+ * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
210
+ */
189
211
  constructor(options = {}) {
190
212
  const types = options.types || LogTypes;
191
213
  this.options = defu(
@@ -223,9 +245,19 @@ class Consola {
223
245
  }
224
246
  this._lastLog = {};
225
247
  }
248
+ /**
249
+ * Gets the current log level of the Consola instance.
250
+ *
251
+ * @returns {number} The current log level.
252
+ */
226
253
  get level() {
227
254
  return this.options.level;
228
255
  }
256
+ /**
257
+ * Sets the minimum log level that will be output by the instance.
258
+ *
259
+ * @param {number} level - The new log level to set.
260
+ */
229
261
  set level(level) {
230
262
  this.options.level = _normalizeLogLevel(
231
263
  level,
@@ -233,12 +265,27 @@ class Consola {
233
265
  this.options.level
234
266
  );
235
267
  }
268
+ /**
269
+ * Displays a prompt to the user and returns the response.
270
+ * Throw an error if `prompt` is not supported by the current configuration.
271
+ *
272
+ * @template T
273
+ * @param {string} message - The message to display in the prompt.
274
+ * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
275
+ * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
276
+ */
236
277
  prompt(message, opts) {
237
278
  if (!this.options.prompt) {
238
279
  throw new Error("prompt is not supported!");
239
280
  }
240
281
  return this.options.prompt(message, opts);
241
282
  }
283
+ /**
284
+ * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
285
+ *
286
+ * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
287
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
288
+ */
242
289
  create(options) {
243
290
  const instance = new Consola({
244
291
  ...this.options,
@@ -249,6 +296,12 @@ class Consola {
249
296
  }
250
297
  return instance;
251
298
  }
299
+ /**
300
+ * Creates a new Consola instance with the specified default log object properties.
301
+ *
302
+ * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
303
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
304
+ */
252
305
  withDefaults(defaults) {
253
306
  return this.create({
254
307
  ...this.options,
@@ -258,19 +311,39 @@ class Consola {
258
311
  }
259
312
  });
260
313
  }
314
+ /**
315
+ * Creates a new Consola instance with a specified tag, which will be included in every log.
316
+ *
317
+ * @param {string} tag - The tag to include in each log of the new instance.
318
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
319
+ */
261
320
  withTag(tag) {
262
321
  return this.withDefaults({
263
322
  tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
264
323
  });
265
324
  }
325
+ /**
326
+ * Adds a custom reporter to the Consola instance.
327
+ * Reporters will be called for each log message, depending on their implementation and log level.
328
+ *
329
+ * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
330
+ * @returns {Consola} The current Consola instance.
331
+ */
266
332
  addReporter(reporter) {
267
333
  this.options.reporters.push(reporter);
268
334
  return this;
269
335
  }
336
+ /**
337
+ * Removes a custom reporter from the Consola instance.
338
+ * If no reporter is specified, all reporters will be removed.
339
+ *
340
+ * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
341
+ * @returns {Consola} The current Consola instance.
342
+ */
270
343
  removeReporter(reporter) {
271
344
  if (reporter) {
272
345
  const i = this.options.reporters.indexOf(reporter);
273
- if (i >= 0) {
346
+ if (i !== -1) {
274
347
  return this.options.reporters.splice(i, 1);
275
348
  }
276
349
  } else {
@@ -278,6 +351,12 @@ class Consola {
278
351
  }
279
352
  return this;
280
353
  }
354
+ /**
355
+ * Replaces all reporters of the Consola instance with the specified array of reporters.
356
+ *
357
+ * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
358
+ * @returns {Consola} The current Consola instance.
359
+ */
281
360
  setReporters(reporters) {
282
361
  this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
283
362
  return this;
@@ -290,6 +369,9 @@ class Consola {
290
369
  this.restoreConsole();
291
370
  this.restoreStd();
292
371
  }
372
+ /**
373
+ * Overrides console methods with Consola logging methods for consistent logging.
374
+ */
293
375
  wrapConsole() {
294
376
  for (const type in this.options.types) {
295
377
  if (!console["__" + type]) {
@@ -298,6 +380,9 @@ class Consola {
298
380
  console[type] = this[type].raw;
299
381
  }
300
382
  }
383
+ /**
384
+ * Restores the original console methods, removing Consola overrides.
385
+ */
301
386
  restoreConsole() {
302
387
  for (const type in this.options.types) {
303
388
  if (console["__" + type]) {
@@ -306,6 +391,9 @@ class Consola {
306
391
  }
307
392
  }
308
393
  }
394
+ /**
395
+ * Overrides standard output and error streams to redirect them through Consola.
396
+ */
309
397
  wrapStd() {
310
398
  this._wrapStream(this.options.stdout, "log");
311
399
  this._wrapStream(this.options.stderr, "log");
@@ -321,6 +409,9 @@ class Consola {
321
409
  this[type].raw(String(data).trim());
322
410
  };
323
411
  }
412
+ /**
413
+ * Restores the original standard output and error streams, removing the Consola redirection.
414
+ */
324
415
  restoreStd() {
325
416
  this._restoreStream(this.options.stdout);
326
417
  this._restoreStream(this.options.stderr);
@@ -334,9 +425,15 @@ class Consola {
334
425
  delete stream.__write;
335
426
  }
336
427
  }
428
+ /**
429
+ * Pauses logging, queues incoming logs until resumed.
430
+ */
337
431
  pauseLogs() {
338
432
  paused = true;
339
433
  }
434
+ /**
435
+ * Resumes logging, processing any queued logs.
436
+ */
340
437
  resumeLogs() {
341
438
  paused = false;
342
439
  const _queue = queue.splice(0);
@@ -344,6 +441,11 @@ class Consola {
344
441
  item[0]._logFn(item[1], item[2]);
345
442
  }
346
443
  }
444
+ /**
445
+ * Replaces logging methods with mocks if a mock function is provided.
446
+ *
447
+ * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
448
+ */
347
449
  mockTypes(mockFn) {
348
450
  const _mockFn = mockFn || this.options.mockFn;
349
451
  this._mockFn = _mockFn;
@@ -443,13 +545,13 @@ class Consola {
443
545
  }
444
546
  }
445
547
  function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
446
- if (input === void 0) {
548
+ if (input === undefined) {
447
549
  return defaultLevel;
448
550
  }
449
551
  if (typeof input === "number") {
450
552
  return input;
451
553
  }
452
- if (types[input] && types[input].level !== void 0) {
554
+ if (types[input] && types[input].level !== undefined) {
453
555
  return types[input].level;
454
556
  }
455
557
  return defaultLevel;
@@ -466,6 +568,10 @@ function createConsola$1(options = {}) {
466
568
  }
467
569
 
468
570
  class BrowserReporter {
571
+ options;
572
+ defaultColor;
573
+ levelColorMap;
574
+ typeColorMap;
469
575
  constructor(options) {
470
576
  this.options = { ...options };
471
577
  this.defaultColor = "#7f8c8d";
@@ -534,7 +640,7 @@ function createConsola(options = {}) {
534
640
  const consola = createConsola();
535
641
 
536
642
  const name = "@sfxcode/nuxt-mongocamp-server";
537
- const version = "1.2.3";
643
+ const version = "1.2.4";
538
644
 
539
645
  const module = defineNuxtModule({
540
646
  meta: {
@@ -0,0 +1,14 @@
1
+ import { AdminApi, ApplicationApi, AuthApi, BucketApi, CollectionApi, DatabaseApi, DocumentApi, FileApi, IndexApi, InformationApi, JobsApi } from '../../api/index.js';
2
+ export declare function useMongocampServerApi(url: string, key?: string, token?: string): {
3
+ adminApi: AdminApi;
4
+ applicationApi: ApplicationApi;
5
+ authApi: AuthApi;
6
+ bucketApi: BucketApi;
7
+ collectionApi: CollectionApi;
8
+ databaseApi: DatabaseApi;
9
+ documentApi: DocumentApi;
10
+ fileApi: FileApi;
11
+ indexApi: IndexApi;
12
+ informationApi: InformationApi;
13
+ jobApi: JobsApi;
14
+ };
@@ -0,0 +1,46 @@
1
+ import {
2
+ AdminApi,
3
+ ApplicationApi,
4
+ AuthApi,
5
+ BucketApi,
6
+ CollectionApi,
7
+ Configuration,
8
+ DatabaseApi,
9
+ DocumentApi,
10
+ FileApi,
11
+ IndexApi,
12
+ InformationApi,
13
+ JobsApi
14
+ } from "../../api/index.js";
15
+ export function useMongocampServerApi(url, key, token) {
16
+ let configuration = new Configuration();
17
+ if (key && key.length > 0)
18
+ configuration = new Configuration({ basePath: url, apiKey: key });
19
+ else if (token && token.length > 0)
20
+ configuration = new Configuration({ basePath: url, accessToken: token });
21
+ console.log(configuration);
22
+ const adminApi = new AdminApi(configuration);
23
+ const applicationApi = new ApplicationApi(configuration);
24
+ const authApi = new AuthApi(configuration);
25
+ const bucketApi = new BucketApi(configuration);
26
+ const collectionApi = new CollectionApi(configuration);
27
+ const databaseApi = new DatabaseApi(configuration);
28
+ const documentApi = new DocumentApi(configuration);
29
+ const fileApi = new FileApi(configuration);
30
+ const indexApi = new IndexApi(configuration);
31
+ const informationApi = new InformationApi(configuration);
32
+ const jobApi = new JobsApi(configuration);
33
+ return {
34
+ adminApi,
35
+ applicationApi,
36
+ authApi,
37
+ bucketApi,
38
+ collectionApi,
39
+ databaseApi,
40
+ documentApi,
41
+ fileApi,
42
+ indexApi,
43
+ informationApi,
44
+ jobApi
45
+ };
46
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-mongocamp-server",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -33,21 +33,22 @@
33
33
  "api-codegen": "openapi-generator-cli generate -i ./openapi/docs.yaml -g typescript-fetch -o src/runtime/api --additional-properties=typescriptThreePlus=true,supportsES6=true"
34
34
  },
35
35
  "dependencies": {
36
- "@nuxt/kit": "^3.13.2",
37
- "@vueuse/nuxt": "^10.11.1"
36
+ "@nuxt/kit": "^3.15.4",
37
+ "@vueuse/nuxt": "^12.7.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@nuxt/devtools": "^1.5.2",
41
- "@nuxt/eslint-config": "^0.4.0",
40
+ "@nuxt/devtools": "^2.1.3",
41
+ "@nuxt/eslint-config": "^1.1.0",
42
42
  "@nuxt/module-builder": "^0.8.4",
43
- "@nuxt/schema": "^3.13.2",
44
- "@nuxt/test-utils": "^3.14.3",
45
- "@openapitools/openapi-generator-cli": "^2.14.0",
46
- "@types/node": "^22.7.5",
47
- "@unocss/nuxt": "^0.61.9",
48
- "changelogen": "^0.5.7",
49
- "eslint": "^9.12.0",
50
- "nuxt": "^3.13.2",
51
- "vitest": "^2.1.2"
52
- }
43
+ "@nuxt/schema": "^3.15.4",
44
+ "@nuxt/test-utils": "^3.17.1",
45
+ "@openapitools/openapi-generator-cli": "^2.17.0",
46
+ "@types/node": "^22.13.9",
47
+ "@unocss/nuxt": "^66.0.0",
48
+ "changelogen": "^0.6.1",
49
+ "eslint": "^9.21.0",
50
+ "nuxt": "^3.15.4",
51
+ "vitest": "^3.0.7"
52
+ },
53
+ "packageManager": "pnpm@10.4.1+sha512.c753b6c3ad7afa13af388fa6d808035a008e30ea9993f58c6663e2bc5ff21679aa834db094987129aa4d488b86df57f7b634981b2f827cdcacc698cc0cfb88af"
53
54
  }