@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.
- package/package.json +1 -1
- package/src/backend/page/page-data/candles/compose-candles-page-data/index.js +2 -2
- package/src/backend/page/page-data/candles/type.d.ts +2 -2
- package/src/backend/page/page-data/home/compose-home-page-data/index.js +1 -0
- package/src/backend/page/page-data/home/type.d.ts +1 -0
- package/src/backend/page/page-data/index.d.ts +1 -0
- package/src/backend/page/page-data/index.js +1 -0
- package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/index.d.ts +2 -0
- package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/index.js +36 -0
- package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/type.d.ts +9 -0
- package/src/backend/page/page-data/person-candles/compose-person-candles-page-data/type.js +1 -0
- package/src/backend/page/page-data/person-candles/index.d.ts +2 -0
- package/src/backend/page/page-data/person-candles/index.js +2 -0
- package/src/backend/page/page-data/person-candles/type.d.ts +14 -0
- package/src/backend/page/page-data/person-candles/type.js +1 -0
- package/src/backend/server/server-data/index.d.ts +1 -0
- package/src/backend/server/server-data/index.js +1 -0
- package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/index.d.ts +2 -0
- package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/index.js +28 -0
- package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/type.d.ts +13 -0
- package/src/backend/server/server-data/person-candles/compose-person-candles-page-server-data/type.js +1 -0
- package/src/backend/server/server-data/person-candles/index.d.ts +2 -0
- package/src/backend/server/server-data/person-candles/index.js +2 -0
- package/src/backend/server/server-data/person-candles/type.d.ts +6 -0
- package/src/backend/server/server-data/person-candles/type.js +1 -0
package/package.json
CHANGED
@@ -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 @@
|
|
1
|
+
export {};
|
@@ -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 {};
|
@@ -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 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|