@candlerip/shared3 0.0.152 → 0.0.153

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.152",
3
+ "version": "0.0.153",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
@@ -1,12 +1,15 @@
1
1
  import * as mongoose from 'mongoose';
2
2
  export const connectDatabase = async (url) => {
3
- try {
4
- await mongoose.connect(url);
5
- mongoose.connection.on('error', () => {
3
+ const { readyState } = mongoose.connections[0];
4
+ if (readyState === 0 || readyState === 3) {
5
+ try {
6
+ await mongoose.connect(url);
7
+ mongoose.connection.on('error', () => {
8
+ setTimeout(connectDatabase, 5000);
9
+ });
10
+ }
11
+ catch {
6
12
  setTimeout(connectDatabase, 5000);
7
- });
8
- }
9
- catch {
10
- setTimeout(connectDatabase, 5000);
13
+ }
11
14
  }
12
15
  };
@@ -14,8 +14,8 @@ export type GetCandles = <T extends keyof TypeMap = never>(props: {
14
14
  customError: CustomError;
15
15
  }>;
16
16
  type TypeMap = {
17
- candle: Candle[];
18
- candleWithPerson: Array<Candle & {
17
+ candles: Candle[];
18
+ candlesWithPerson: Array<Candle & {
19
19
  person?: Person;
20
20
  }>;
21
21
  };
@@ -1 +1,2 @@
1
- export * from './util.js';
1
+ import { ComposeDictionary } from './type.js';
2
+ export declare const composeDictionary: ComposeDictionary;
@@ -1 +1,3 @@
1
- export * from './util.js';
1
+ import { DICTIONARY_CONFIG } from '../../../dictionary/index.js';
2
+ import { getTranslationsAsDictionary } from '../../database/mutation/translation/index.js';
3
+ export const composeDictionary = async (page, language) => getTranslationsAsDictionary(language, [...DICTIONARY_CONFIG[page].translationIds]);
@@ -1,9 +1,7 @@
1
1
  import { Dictionary, Language } from '../../../dictionary/index.js';
2
2
  import { CustomError } from '../../../error/index.js';
3
3
  import { Page } from '../../../page/index.js';
4
- export type ComposeDictionary = (page: Page, language: Language, options?: {
5
- isAuthenticated: boolean;
6
- }) => Promise<{
4
+ export type ComposeDictionary = (page: Page, language: Language) => Promise<{
7
5
  data: Dictionary;
8
6
  } | {
9
7
  customError: CustomError;
@@ -1,4 +1,3 @@
1
1
  export * from './dictionary/index.js';
2
2
  export * from './language/index.js';
3
3
  export * from './translation-id/index.js';
4
- export * from './get-excluded-translation-ids/index.js';
@@ -1,4 +1,3 @@
1
1
  export * from './dictionary/index.js';
2
2
  export * from './language/index.js';
3
3
  export * from './translation-id/index.js';
4
- export * from './get-excluded-translation-ids/index.js';
@@ -1,2 +0,0 @@
1
- import { ComposeDictionary } from './type.js';
2
- export declare const composeDictionary: ComposeDictionary;
@@ -1,10 +0,0 @@
1
- import { DICTIONARY_CONFIG } from '../../../dictionary/index.js';
2
- import { getTranslationsAsDictionary } from '../../database/mutation/translation/index.js';
3
- import { getExcludedTranslationIds } from '../../../dictionary/get-excluded-translation-ids/index.js';
4
- export const composeDictionary = async (page, language, options) => {
5
- let translationIds = [...DICTIONARY_CONFIG[page].translationIds];
6
- const excludedIds = getExcludedTranslationIds(page, options);
7
- translationIds = translationIds.filter((it) => !excludedIds.includes(it));
8
- const resp = await getTranslationsAsDictionary(language, translationIds);
9
- return resp;
10
- };
@@ -1,2 +0,0 @@
1
- import { GetExcludedTranslationIds } from './type.js';
2
- export declare const getExcludedTranslationIds: GetExcludedTranslationIds;
@@ -1,10 +0,0 @@
1
- import { isUndefined } from '../../type/index.js';
2
- export const getExcludedTranslationIds = (page, options) => {
3
- const excludedIds = [`pageMenu.${page}`];
4
- if (options) {
5
- const { isAuthenticated } = options;
6
- if (!isUndefined(isAuthenticated))
7
- excludedIds.push(isAuthenticated ? 'login' : 'logout');
8
- }
9
- return excludedIds;
10
- };
@@ -1,5 +0,0 @@
1
- import { TranslationId } from '../index.js';
2
- import { Page } from '../../page/index.js';
3
- export type GetExcludedTranslationIds = (page: Page, options?: {
4
- isAuthenticated?: boolean;
5
- }) => TranslationId[];
@@ -1 +0,0 @@
1
- export {};