@candlerip/shared3 0.0.168 → 0.0.170

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/backend/database/model/candle/candle-db-schema.d.ts +3 -3
  3. package/src/backend/page/page-data/candles/compose-candles-page-data/index.js +1 -1
  4. package/src/backend/page/page-data/candles/type.d.ts +1 -1
  5. package/src/backend/page/page-data/home/compose-home-page-data/index.js +1 -0
  6. package/src/backend/page/page-data/home/type.d.ts +1 -0
  7. package/src/backend/page/page-data/index.d.ts +1 -0
  8. package/src/backend/page/page-data/index.js +1 -0
  9. package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/index.d.ts +2 -0
  10. package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/index.js +35 -0
  11. package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/type.d.ts +9 -0
  12. package/src/backend/page/page-data/person-candles/index.d.ts +2 -0
  13. package/src/backend/page/page-data/person-candles/index.js +2 -0
  14. package/src/backend/page/page-data/person-candles/type.d.ts +12 -0
  15. package/src/backend/page/page-data/person-candles/type.js +1 -0
  16. package/src/backend/server/server-data/candles/compose-candles-page-server-data/index.js +8 -7
  17. package/src/backend/server/server-data/candles/compose-candles-page-server-data/type.d.ts +3 -2
  18. package/src/backend/server/server-data/home/{compose-candles-page-server-data → compose-home-page-server-data}/index.js +7 -7
  19. package/src/backend/server/server-data/home/{compose-candles-page-server-data → compose-home-page-server-data}/type.d.ts +3 -2
  20. package/src/backend/server/server-data/home/compose-home-page-server-data/type.js +1 -0
  21. package/src/backend/server/server-data/home/index.d.ts +1 -1
  22. package/src/backend/server/server-data/home/index.js +1 -1
  23. package/src/backend/server/server-data/index.d.ts +1 -0
  24. package/src/backend/server/server-data/index.js +1 -0
  25. package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/index.d.ts +2 -0
  26. package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/index.js +28 -0
  27. package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/type.d.ts +13 -0
  28. package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/type.js +1 -0
  29. package/src/backend/server/server-data/person-candles/index.d.ts +2 -0
  30. package/src/backend/server/server-data/person-candles/index.js +2 -0
  31. package/src/backend/server/server-data/person-candles/type.d.ts +6 -0
  32. package/src/backend/server/server-data/person-candles/type.js +1 -0
  33. /package/src/backend/{server/server-data/home/compose-candles-page-server-data → page/page-data/person-candles/compose-person-candles-page-data}/type.js +0 -0
  34. /package/src/backend/server/server-data/home/{compose-candles-page-server-data → compose-home-page-server-data}/index.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.168",
3
+ "version": "0.0.170",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
@@ -9,8 +9,8 @@ export declare const CandleDbSchema: mongoose.Schema<any, mongoose.Model<any, an
9
9
  litName?: string | null | undefined;
10
10
  burningEndsAt?: NativeDate | null | undefined;
11
11
  personId?: mongoose.Types.ObjectId | null | undefined;
12
- burningMinutes?: number | null | undefined;
13
12
  description?: string | null | undefined;
13
+ burningMinutes?: number | null | undefined;
14
14
  userId?: string | null | undefined;
15
15
  }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
16
16
  createdAt: NativeDate;
@@ -19,8 +19,8 @@ export declare const CandleDbSchema: mongoose.Schema<any, mongoose.Model<any, an
19
19
  litName?: string | null | undefined;
20
20
  burningEndsAt?: NativeDate | null | undefined;
21
21
  personId?: mongoose.Types.ObjectId | null | undefined;
22
- burningMinutes?: number | null | undefined;
23
22
  description?: string | null | undefined;
23
+ burningMinutes?: number | null | undefined;
24
24
  userId?: string | null | undefined;
25
25
  }>> & mongoose.FlatRecord<{
26
26
  createdAt: NativeDate;
@@ -29,8 +29,8 @@ export declare const CandleDbSchema: mongoose.Schema<any, mongoose.Model<any, an
29
29
  litName?: string | null | undefined;
30
30
  burningEndsAt?: NativeDate | null | undefined;
31
31
  personId?: mongoose.Types.ObjectId | null | undefined;
32
- burningMinutes?: number | null | undefined;
33
32
  description?: string | null | undefined;
33
+ burningMinutes?: number | null | undefined;
34
34
  userId?: string | null | undefined;
35
35
  }> & {
36
36
  _id: mongoose.Types.ObjectId;
@@ -10,9 +10,9 @@ export const composeCandlesPageData = async ({ filterSort }) => {
10
10
  candlesList: {
11
11
  candles,
12
12
  candlesCount,
13
+ renderDate: new Date(),
13
14
  },
14
15
  filterSort,
15
- renderDate: new Date(),
16
16
  },
17
17
  };
18
18
  };
@@ -7,7 +7,7 @@ export interface CandlesPageData {
7
7
  person?: Person;
8
8
  }>;
9
9
  candlesCount: number;
10
+ renderDate: Date;
10
11
  };
11
12
  filterSort: CandleFilterSort;
12
- renderDate: Date;
13
13
  }
@@ -60,6 +60,7 @@ export const composeHomePageData = async () => {
60
60
  }),
61
61
  lastLitCandles: {
62
62
  candles,
63
+ renderDate: new Date(),
63
64
  },
64
65
  lastUploadedPersons: {
65
66
  persons,
@@ -8,6 +8,7 @@ export interface HomePageData {
8
8
  candles: Array<Candle & {
9
9
  person?: Person;
10
10
  }>;
11
+ renderDate: Date;
11
12
  };
12
13
  lastUploadedPersons: {
13
14
  persons: Array<Person & {
@@ -2,4 +2,5 @@ export * from './candles/index.js';
2
2
  export * from './edit-candle/index.js';
3
3
  export * from './home/index.js';
4
4
  export * from './light-candle/index.js';
5
+ export * from './person-candles/index.js';
5
6
  export * from './persons-map/index.js';
@@ -2,4 +2,5 @@ export * from './candles/index.js';
2
2
  export * from './edit-candle/index.js';
3
3
  export * from './home/index.js';
4
4
  export * from './light-candle/index.js';
5
+ export * from './person-candles/index.js';
5
6
  export * from './persons-map/index.js';
@@ -0,0 +1,2 @@
1
+ import { ComposePersonCandlesPageData } from './type.js';
2
+ export declare const composePersonCandlesPageData: ComposePersonCandlesPageData;
@@ -0,0 +1,35 @@
1
+ import { composeCustomError } from '../../../../../error/index.js';
2
+ import { getCandles, getPerson } from '../../../../database/index.js';
3
+ export const composePersonCandlesPageData = async (personId, filterSort) => {
4
+ let resp;
5
+ resp = await getPerson({ _id: personId });
6
+ if ('customError' in resp) {
7
+ return resp;
8
+ }
9
+ const { data: person } = resp;
10
+ if (!person) {
11
+ return {
12
+ customError: composeCustomError('Person not found'),
13
+ personNotFoundError: true,
14
+ };
15
+ }
16
+ resp = await getCandles({
17
+ filterSort,
18
+ });
19
+ if ('customError' in resp) {
20
+ return resp;
21
+ }
22
+ const { candles, candlesCount } = resp.data;
23
+ return {
24
+ data: {
25
+ addCandle: {
26
+ person,
27
+ },
28
+ candlesList: {
29
+ candles,
30
+ candlesCount,
31
+ renderDate: new Date(),
32
+ },
33
+ },
34
+ };
35
+ };
@@ -0,0 +1,9 @@
1
+ import { CustomError } from '../../../../../error/index.js';
2
+ import { CandleFilterSort } from '../../../../../filter-sort/index.js';
3
+ import { PersonCandlesPageData } from '../type.js';
4
+ export type ComposePersonCandlesPageData = (personId: string, filterSort: CandleFilterSort) => Promise<{
5
+ data: PersonCandlesPageData;
6
+ } | {
7
+ customError: CustomError;
8
+ personNotFoundError?: boolean;
9
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './compose-person-candles-page-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-person-candles-page-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,12 @@
1
+ import { Candle } from '../../../../candle/index.js';
2
+ import { Person } from '../../../../person/index.js';
3
+ export interface PersonCandlesPageData {
4
+ addCandle: {
5
+ person: Person;
6
+ };
7
+ candlesList: {
8
+ candles: Candle[];
9
+ candlesCount: number;
10
+ renderDate: Date;
11
+ };
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,23 +1,24 @@
1
- import { DICTIONARY_CONFIG } from '../../../../../dictionary/index.js';
2
1
  import { DEFAULT_CANDLE_FILTER_SORT } from '../../../../../filter-sort/index.js';
3
- import { getTranslationsAsDictionary } from '../../../../database/index.js';
2
+ import { composeDictionary } from '../../../../dictionary/index.js';
4
3
  import { composeCandlesPageData } from '../../../../page/index.js';
5
- export const composeCandlesPageServerData = async ({ filterSort: initFilterSort, language }) => {
4
+ export const composeCandlesPageServerData = async (language, options) => {
5
+ const excludedTranslationIdOptions = options?.excludedTranslationIdOptions;
6
+ const initFilterSort = options?.filterSort;
6
7
  const filterSort = {
7
8
  ...DEFAULT_CANDLE_FILTER_SORT,
8
9
  ...initFilterSort,
9
10
  };
10
11
  let resp;
11
- resp = await getTranslationsAsDictionary(language, DICTIONARY_CONFIG['candles-page'].translationIds);
12
+ resp = await composeCandlesPageData({ filterSort });
12
13
  if ('customError' in resp) {
13
14
  return resp;
14
15
  }
15
- const dictionary = resp.data;
16
- resp = await composeCandlesPageData({ filterSort });
16
+ const pageData = resp.data;
17
+ resp = await composeDictionary('candles-page', language, { excludedTranslationIdOptions });
17
18
  if ('customError' in resp) {
18
19
  return resp;
19
20
  }
20
- const pageData = resp.data;
21
+ const dictionary = resp.data;
21
22
  return {
22
23
  data: {
23
24
  dictionary,
@@ -1,10 +1,11 @@
1
1
  import { Language } from '../../../../../dictionary/index.js';
2
2
  import { CustomError } from '../../../../../error/index.js';
3
3
  import { CandleFilterSort } from '../../../../../filter-sort/index.js';
4
+ import { ExcludedTranslationIdOptions } from '../../../../dictionary/index.js';
4
5
  import { CandlesPageServerData } from '../type.js';
5
- export type ComposeCandlesPageServerData = (props: {
6
+ export type ComposeCandlesPageServerData = (language: Language, options?: {
7
+ excludedTranslationIdOptions?: ExcludedTranslationIdOptions;
6
8
  filterSort?: Partial<CandleFilterSort>;
7
- language: Language;
8
9
  }) => Promise<{
9
10
  data: CandlesPageServerData;
10
11
  } | {
@@ -1,18 +1,18 @@
1
- import { DICTIONARY_CONFIG } from '../../../../../dictionary/index.js';
2
- import { getTranslationsAsDictionary } from '../../../../database/index.js';
1
+ import { composeDictionary } from '../../../../dictionary/index.js';
3
2
  import { composeHomePageData } from '../../../../page/index.js';
4
- export const composeHomePageServerData = async ({ language }) => {
3
+ export const composeHomePageServerData = async (language, options) => {
4
+ const excludedTranslationIdOptions = options?.excludedTranslationIdOptions;
5
5
  let resp;
6
- resp = await getTranslationsAsDictionary(language, DICTIONARY_CONFIG['home-page'].translationIds);
6
+ resp = await composeHomePageData();
7
7
  if ('customError' in resp) {
8
8
  return resp;
9
9
  }
10
- const dictionary = resp.data;
11
- resp = await composeHomePageData();
10
+ const pageData = resp.data;
11
+ resp = await composeDictionary('home-page', language, { excludedTranslationIdOptions });
12
12
  if ('customError' in resp) {
13
13
  return resp;
14
14
  }
15
- const pageData = resp.data;
15
+ const dictionary = resp.data;
16
16
  return {
17
17
  data: {
18
18
  dictionary,
@@ -1,8 +1,9 @@
1
1
  import { Language } from '../../../../../dictionary/index.js';
2
2
  import { CustomError } from '../../../../../error/index.js';
3
+ import { ExcludedTranslationIdOptions } from '../../../../dictionary/index.js';
3
4
  import { HomePageServerData } from '../type.js';
4
- export type ComposeHomePageServerData = (props: {
5
- language: Language;
5
+ export type ComposeHomePageServerData = (language: Language, options?: {
6
+ excludedTranslationIdOptions?: ExcludedTranslationIdOptions;
6
7
  }) => Promise<{
7
8
  data: HomePageServerData;
8
9
  } | {
@@ -1,2 +1,2 @@
1
- export * from './compose-candles-page-server-data/index.js';
1
+ export * from './compose-home-page-server-data/index.js';
2
2
  export * from './type.js';
@@ -1,2 +1,2 @@
1
- export * from './compose-candles-page-server-data/index.js';
1
+ export * from './compose-home-page-server-data/index.js';
2
2
  export * from './type.js';
@@ -2,4 +2,5 @@ export * from './candles/index.js';
2
2
  export * from './edit-candle/index.js';
3
3
  export * from './home/index.js';
4
4
  export * from './light-candle/index.js';
5
+ export * from './person-candles/index.js';
5
6
  export * from './persons-map/index.js';
@@ -2,4 +2,5 @@ export * from './candles/index.js';
2
2
  export * from './edit-candle/index.js';
3
3
  export * from './home/index.js';
4
4
  export * from './light-candle/index.js';
5
+ export * from './person-candles/index.js';
5
6
  export * from './persons-map/index.js';
@@ -0,0 +1,2 @@
1
+ import { ComposePersonCandlesPageServerData } from './type.js';
2
+ export declare const composePersonCandlesPageServerData: ComposePersonCandlesPageServerData;
@@ -0,0 +1,28 @@
1
+ import { DEFAULT_CANDLE_FILTER_SORT } from '../../../../../filter-sort/index.js';
2
+ import { composeDictionary } from '../../../../dictionary/index.js';
3
+ import { composePersonCandlesPageData } from '../../../../page/index.js';
4
+ export const composePersonCandlesPageServerData = async (language, personId, options) => {
5
+ const excludedTranslationIdOptions = options?.excludedTranslationIdOptions;
6
+ const initFilterSort = options?.filterSort;
7
+ const filterSort = {
8
+ ...DEFAULT_CANDLE_FILTER_SORT,
9
+ ...initFilterSort,
10
+ };
11
+ let resp;
12
+ resp = await composePersonCandlesPageData(personId, filterSort);
13
+ if ('customError' in resp) {
14
+ return resp;
15
+ }
16
+ const pageData = resp.data;
17
+ resp = await composeDictionary('person-candles-page', language, { excludedTranslationIdOptions });
18
+ if ('customError' in resp) {
19
+ return resp;
20
+ }
21
+ const dictionary = resp.data;
22
+ return {
23
+ data: {
24
+ dictionary,
25
+ pageData,
26
+ },
27
+ };
28
+ };
@@ -0,0 +1,13 @@
1
+ import { Language } from '../../../../../dictionary/index.js';
2
+ import { CustomError } from '../../../../../error/index.js';
3
+ import { CandleFilterSort } from '../../../../../filter-sort/index.js';
4
+ import { ExcludedTranslationIdOptions } from '../../../../dictionary/index.js';
5
+ import { PersonCandlesPageServerData } from '../type.js';
6
+ export type ComposePersonCandlesPageServerData = (language: Language, personId: string, options?: {
7
+ excludedTranslationIdOptions?: ExcludedTranslationIdOptions;
8
+ filterSort?: Partial<CandleFilterSort>;
9
+ }) => Promise<{
10
+ data: PersonCandlesPageServerData;
11
+ } | {
12
+ customError: CustomError;
13
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './compose-person-candles-page-server-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-person-candles-page-server-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,6 @@
1
+ import { Dictionary } from '../../../../dictionary/index.js';
2
+ import { PersonCandlesPageData } from '../../../page/index.js';
3
+ export interface PersonCandlesPageServerData {
4
+ dictionary: Dictionary;
5
+ pageData: PersonCandlesPageData;
6
+ }