@candlerip/shared3 0.0.169 → 0.0.171

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. package/package.json +1 -1
  2. package/src/backend/page/page-data/candles/compose-candles-page-data/index.js +2 -2
  3. package/src/backend/page/page-data/candles/type.d.ts +2 -2
  4. package/src/backend/page/page-data/home/compose-home-page-data/index.js +1 -0
  5. package/src/backend/page/page-data/home/type.d.ts +1 -0
  6. package/src/backend/page/page-data/index.d.ts +1 -0
  7. package/src/backend/page/page-data/index.js +1 -0
  8. package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/index.d.ts +2 -0
  9. package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/index.js +36 -0
  10. package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/type.d.ts +9 -0
  11. package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/type.js +1 -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 +14 -0
  15. package/src/backend/page/page-data/person-candles/type.js +1 -0
  16. package/src/backend/server/server-data/index.d.ts +1 -0
  17. package/src/backend/server/server-data/index.js +1 -0
  18. package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/index.d.ts +2 -0
  19. package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/index.js +28 -0
  20. package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/type.d.ts +13 -0
  21. package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/type.js +1 -0
  22. package/src/backend/server/server-data/person-candles/index.d.ts +2 -0
  23. package/src/backend/server/server-data/person-candles/index.js +2 -0
  24. package/src/backend/server/server-data/person-candles/type.d.ts +6 -0
  25. package/src/backend/server/server-data/person-candles/type.js +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.169",
3
+ "version": "0.0.171",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
@@ -10,9 +10,9 @@ export const composeCandlesPageData = async ({ filterSort }) => {
10
10
  candlesList: {
11
11
  candles,
12
12
  candlesCount,
13
+ filterSort,
14
+ renderDate: new Date(),
13
15
  },
14
- filterSort,
15
- renderDate: new Date(),
16
16
  },
17
17
  };
18
18
  };
@@ -6,8 +6,8 @@ export interface CandlesPageData {
6
6
  candles: Array<Candle & {
7
7
  person?: Person;
8
8
  }>;
9
+ filterSort: CandleFilterSort;
9
10
  candlesCount: number;
11
+ renderDate: Date;
10
12
  };
11
- 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,36 @@
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
+ filterSort,
32
+ renderDate: new Date(),
33
+ },
34
+ },
35
+ };
36
+ };
@@ -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,14 @@
1
+ import { Candle } from '../../../../candle/index.js';
2
+ import { CandleFilterSort } from '../../../../filter-sort/index.js';
3
+ import { Person } from '../../../../person/index.js';
4
+ export interface PersonCandlesPageData {
5
+ addCandle: {
6
+ person: Person;
7
+ };
8
+ candlesList: {
9
+ candles: Candle[];
10
+ candlesCount: number;
11
+ filterSort: CandleFilterSort;
12
+ renderDate: Date;
13
+ };
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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
+ }