@candlerip/shared3 0.0.167 → 0.0.169
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/cache/cache/config.d.ts +2 -0
- package/src/backend/cache/cache/config.js +2 -0
- package/src/backend/cache/cache/type.d.ts +2 -1
- package/src/backend/database/model/candle/candle-db-schema.d.ts +3 -3
- package/src/backend/database/mutation/count/count-candles/index.d.ts +2 -0
- package/src/backend/database/mutation/count/count-candles/index.js +24 -0
- package/src/backend/database/mutation/count/count-candles/types.d.ts +9 -0
- package/src/backend/database/mutation/count/count-persons/index.d.ts +2 -0
- package/src/backend/database/mutation/count/count-persons/index.js +15 -0
- package/src/backend/database/mutation/count/count-persons/types.d.ts +6 -0
- package/src/backend/database/mutation/count/index.d.ts +2 -0
- package/src/backend/database/mutation/count/index.js +2 -0
- package/src/backend/database/mutation/index.d.ts +1 -0
- package/src/backend/database/mutation/index.js +1 -0
- package/src/backend/database/mutation/person/get-random/index.d.ts +2 -0
- package/src/backend/database/mutation/person/get-random/index.js +36 -0
- package/src/backend/database/mutation/person/get-random/type.d.ts +20 -0
- package/src/backend/database/mutation/person/get-random/type.js +1 -0
- package/src/backend/database/mutation/person/gets/index.d.ts +2 -0
- package/src/backend/database/mutation/person/gets/index.js +84 -0
- package/src/backend/database/mutation/person/gets/type.d.ts +30 -0
- package/src/backend/database/mutation/person/gets/type.js +1 -0
- package/src/backend/database/mutation/person/index.d.ts +2 -0
- package/src/backend/database/mutation/person/index.js +2 -0
- package/src/backend/message-broker/message-broker-refresh-cache/type.d.ts +1 -1
- package/src/backend/page/page-data/home/compose-home-page-data/index.d.ts +2 -0
- package/src/backend/page/page-data/home/compose-home-page-data/index.js +77 -0
- package/src/backend/page/page-data/home/compose-home-page-data/type.d.ts +7 -0
- package/src/backend/page/page-data/home/compose-home-page-data/type.js +1 -0
- package/src/backend/page/page-data/home/index.d.ts +2 -0
- package/src/backend/page/page-data/home/index.js +2 -0
- package/src/backend/page/page-data/home/type.d.ts +28 -0
- package/src/backend/page/page-data/home/type.js +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/server/server-data/candles/compose-candles-page-server-data/index.js +8 -7
- package/src/backend/server/server-data/candles/compose-candles-page-server-data/type.d.ts +3 -2
- package/src/backend/server/server-data/edit-candle/compose-edit-candle-page-server-data/type.js +1 -0
- package/src/backend/server/server-data/edit-candle/type.js +1 -0
- package/src/backend/server/server-data/home/compose-home-page-server-data/index.d.ts +2 -0
- package/src/backend/server/server-data/home/compose-home-page-server-data/index.js +22 -0
- package/src/backend/server/server-data/home/compose-home-page-server-data/type.d.ts +11 -0
- package/src/backend/server/server-data/home/compose-home-page-server-data/type.js +1 -0
- package/src/backend/server/server-data/home/index.d.ts +2 -0
- package/src/backend/server/server-data/home/index.js +2 -0
- package/src/backend/server/server-data/home/type.d.ts +6 -0
- package/src/backend/server/server-data/home/type.js +1 -0
- package/src/backend/server/server-data/index.d.ts +2 -1
- package/src/backend/server/server-data/index.js +2 -1
- package/src/filter-sort/index.d.ts +1 -0
- package/src/filter-sort/index.js +1 -0
- package/src/filter-sort/person-filter-sort/default.d.ts +2 -0
- package/src/filter-sort/person-filter-sort/default.js +5 -0
- package/src/filter-sort/person-filter-sort/index.d.ts +2 -0
- package/src/filter-sort/person-filter-sort/index.js +2 -0
- package/src/filter-sort/person-filter-sort/type.d.ts +14 -0
- package/src/filter-sort/person-filter-sort/type.js +1 -0
- package/src/filter-sort/sort-name/index.d.ts +1 -0
- package/src/filter-sort/sort-name/index.js +1 -0
- package/src/filter-sort/sort-name/person-sort-name/config.d.ts +1 -0
- package/src/filter-sort/sort-name/person-sort-name/config.js +1 -0
- package/src/filter-sort/sort-name/person-sort-name/index.d.ts +3 -0
- package/src/filter-sort/sort-name/person-sort-name/index.js +3 -0
- package/src/filter-sort/sort-name/person-sort-name/type-guard.d.ts +2 -0
- package/src/filter-sort/sort-name/person-sort-name/type-guard.js +4 -0
- package/src/filter-sort/sort-name/person-sort-name/type.d.ts +2 -0
- package/src/filter-sort/sort-name/person-sort-name/type.js +1 -0
- /package/src/backend/{server/server-data/edit-canlde/compose-edit-candle-page-server-data/type.js → database/mutation/count/count-candles/types.js} +0 -0
- /package/src/backend/{server/server-data/edit-canlde/type.js → database/mutation/count/count-persons/types.js} +0 -0
- /package/src/backend/server/server-data/{edit-canlde → edit-candle}/compose-edit-candle-page-server-data/index.d.ts +0 -0
- /package/src/backend/server/server-data/{edit-canlde → edit-candle}/compose-edit-candle-page-server-data/index.js +0 -0
- /package/src/backend/server/server-data/{edit-canlde → edit-candle}/compose-edit-candle-page-server-data/type.d.ts +0 -0
- /package/src/backend/server/server-data/{edit-canlde → edit-candle}/index.d.ts +0 -0
- /package/src/backend/server/server-data/{edit-canlde → edit-candle}/index.js +0 -0
- /package/src/backend/server/server-data/{edit-canlde → edit-candle}/type.d.ts +0 -0
package/package.json
CHANGED
@@ -21,6 +21,8 @@ export declare const CACHE: {
|
|
21
21
|
readonly 'help-page-dictionary-hu': "Dictionary";
|
22
22
|
readonly 'home-page-dictionary-en': "Dictionary";
|
23
23
|
readonly 'home-page-dictionary-hu': "Dictionary";
|
24
|
+
readonly 'home-page-server-data-en': "HomePageServerData";
|
25
|
+
readonly 'home-page-server-data-hu': "HomePageServerData";
|
24
26
|
readonly 'person-candles-page-dictionary-en': "Dictionary";
|
25
27
|
readonly 'person-candles-page-dictionary-hu': "Dictionary";
|
26
28
|
readonly 'person-details-page-dictionary-en': "Dictionary";
|
@@ -21,6 +21,8 @@ export const CACHE = {
|
|
21
21
|
'help-page-dictionary-hu': 'Dictionary',
|
22
22
|
'home-page-dictionary-en': 'Dictionary',
|
23
23
|
'home-page-dictionary-hu': 'Dictionary',
|
24
|
+
'home-page-server-data-en': 'HomePageServerData',
|
25
|
+
'home-page-server-data-hu': 'HomePageServerData',
|
24
26
|
'person-candles-page-dictionary-en': 'Dictionary',
|
25
27
|
'person-candles-page-dictionary-hu': 'Dictionary',
|
26
28
|
'person-details-page-dictionary-en': 'Dictionary',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Dictionary } from '../../../dictionary/index.js';
|
2
|
-
import { CandlesPageServerData, LightCandlePageServerData, PersonsMapPageServerData } from '../../server/index.js';
|
2
|
+
import { CandlesPageServerData, HomePageServerData, LightCandlePageServerData, PersonsMapPageServerData } from '../../server/index.js';
|
3
3
|
import { CACHE } from './config.js';
|
4
4
|
export type Cache = {
|
5
5
|
[key in keyof typeof CACHE]: TypeMap[(typeof CACHE)[key]];
|
@@ -7,6 +7,7 @@ export type Cache = {
|
|
7
7
|
interface TypeMap {
|
8
8
|
CandlesPageServerData: CandlesPageServerData;
|
9
9
|
Dictionary: Dictionary;
|
10
|
+
HomePageServerData: HomePageServerData;
|
10
11
|
LightCandlePageServerData: LightCandlePageServerData;
|
11
12
|
PersonsMapPageServerData: PersonsMapPageServerData;
|
12
13
|
}
|
@@ -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;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { customErrorWorker } from '../../../../../error/index.js';
|
2
|
+
import { getCandleDbModel } from '../../../model/index.js';
|
3
|
+
export const countCandles = async (props) => {
|
4
|
+
const burningState = props?.burningState;
|
5
|
+
let query;
|
6
|
+
const { composeCustomError } = customErrorWorker(props);
|
7
|
+
if (burningState) {
|
8
|
+
query = {
|
9
|
+
burningEndsAt: burningState === 'burning' ? { $gte: new Date() } : { $lte: new Date() },
|
10
|
+
};
|
11
|
+
}
|
12
|
+
let count;
|
13
|
+
try {
|
14
|
+
count = await getCandleDbModel().countDocuments(query);
|
15
|
+
}
|
16
|
+
catch (err) {
|
17
|
+
return {
|
18
|
+
customError: composeCustomError('Count candles failed', { err }),
|
19
|
+
};
|
20
|
+
}
|
21
|
+
return {
|
22
|
+
count,
|
23
|
+
};
|
24
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { BurningCandleState } from '../../../../../candle/index.js';
|
2
|
+
import { CustomError } from '../../../../../error/index.js';
|
3
|
+
export type CountCandles = (props?: {
|
4
|
+
burningState?: BurningCandleState;
|
5
|
+
}) => Promise<{
|
6
|
+
count: number;
|
7
|
+
} | {
|
8
|
+
customError: CustomError;
|
9
|
+
}>;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { customErrorWorker } from '../../../../../error/index.js';
|
2
|
+
import { getPersonDbModel } from '../../../model/index.js';
|
3
|
+
export const countPersons = async () => {
|
4
|
+
let count;
|
5
|
+
const { composeCustomError } = customErrorWorker();
|
6
|
+
try {
|
7
|
+
count = await getPersonDbModel().countDocuments();
|
8
|
+
}
|
9
|
+
catch (err) {
|
10
|
+
return {
|
11
|
+
customError: composeCustomError('Count persons failed', { err }),
|
12
|
+
};
|
13
|
+
}
|
14
|
+
return { count };
|
15
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { customErrorWorker, isUndefined } from '@candlerip/shared3';
|
2
|
+
import { PERSON_BIRTH_PLACE_COUNTRY_AGGREGATE, PERSON_CANDLES_COUNT_AGGREGATE, getPersonDbModel } from '@candlerip/shared3/backend/database';
|
3
|
+
export const getRandomPerson = async (props) => {
|
4
|
+
const aggregates = [];
|
5
|
+
const { composeCustomError } = customErrorWorker(props);
|
6
|
+
if (props) {
|
7
|
+
const { isProposable, withCandlesCount, withBirthPlaceCountry } = props;
|
8
|
+
if (!isUndefined(isProposable)) {
|
9
|
+
aggregates.push({ $match: { isProposable } });
|
10
|
+
}
|
11
|
+
if (withCandlesCount) {
|
12
|
+
aggregates.push(...PERSON_CANDLES_COUNT_AGGREGATE);
|
13
|
+
}
|
14
|
+
if (withBirthPlaceCountry) {
|
15
|
+
aggregates.push(...PERSON_BIRTH_PLACE_COUNTRY_AGGREGATE);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
aggregates.push({ $sample: { size: 1 } });
|
19
|
+
let data;
|
20
|
+
try {
|
21
|
+
data = await getPersonDbModel().aggregate(aggregates);
|
22
|
+
}
|
23
|
+
catch (err) {
|
24
|
+
return {
|
25
|
+
customError: composeCustomError('Get random person failed', { err }),
|
26
|
+
};
|
27
|
+
}
|
28
|
+
if (!data || data.length === 0) {
|
29
|
+
return {
|
30
|
+
data: null,
|
31
|
+
};
|
32
|
+
}
|
33
|
+
return {
|
34
|
+
data: data[0],
|
35
|
+
};
|
36
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { CustomError, Person } from '@candlerip/shared3';
|
2
|
+
export type GetRandomPerson = <T extends keyof TypeMap = never>(props: {
|
3
|
+
isProposable?: boolean;
|
4
|
+
withCandlesCount?: boolean;
|
5
|
+
withBirthPlaceCountry?: boolean;
|
6
|
+
}) => Promise<{
|
7
|
+
data: TypeMap[T] | null;
|
8
|
+
} | {
|
9
|
+
customError: CustomError;
|
10
|
+
}>;
|
11
|
+
type TypeMap = {
|
12
|
+
person: Person;
|
13
|
+
personWithCandlesCount: Person & {
|
14
|
+
candlesCount: {
|
15
|
+
burning: number;
|
16
|
+
burned: number;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
};
|
20
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import { customErrorWorker, isUndefined } from '@candlerip/shared3';
|
2
|
+
import { PERSON_BIRTH_PLACE_COUNTRY_AGGREGATE, PERSON_CANDLES_COUNT_AGGREGATE, getPersonDbModel } from '@candlerip/shared3/backend/database';
|
3
|
+
export const getPersons = async (props) => {
|
4
|
+
const { filterSort, isProposable, withCandlesCount, withBirthPlaceCountry } = props;
|
5
|
+
const { place_of_births: placeOfBirths, count, name, name_case_sensitive: nameCaseSensitive, skip_count: skipCount, sort_name: sortName, sort_order: sortOrder, user_id: userId, with_photo: withPhoto, } = filterSort;
|
6
|
+
const aggregates = [];
|
7
|
+
const { composeCustomError } = customErrorWorker(props);
|
8
|
+
if (!isUndefined(isProposable)) {
|
9
|
+
aggregates.push({ $match: { isProposable } });
|
10
|
+
}
|
11
|
+
if (userId) {
|
12
|
+
aggregates.push({ $match: { userId } });
|
13
|
+
}
|
14
|
+
if (withCandlesCount) {
|
15
|
+
aggregates.push(...PERSON_CANDLES_COUNT_AGGREGATE);
|
16
|
+
}
|
17
|
+
if (withBirthPlaceCountry) {
|
18
|
+
aggregates.push(...PERSON_BIRTH_PLACE_COUNTRY_AGGREGATE);
|
19
|
+
}
|
20
|
+
if (name) {
|
21
|
+
aggregates.push({
|
22
|
+
$match: {
|
23
|
+
name: { $regex: name, $options: !nameCaseSensitive ? 'i' : '' },
|
24
|
+
},
|
25
|
+
});
|
26
|
+
}
|
27
|
+
if (withPhoto) {
|
28
|
+
aggregates.push({
|
29
|
+
$match: {
|
30
|
+
images: {
|
31
|
+
$ne: null,
|
32
|
+
},
|
33
|
+
},
|
34
|
+
});
|
35
|
+
}
|
36
|
+
if (placeOfBirths) {
|
37
|
+
aggregates.push({
|
38
|
+
$match: {
|
39
|
+
'birth.place.countryCode': {
|
40
|
+
$in: placeOfBirths,
|
41
|
+
},
|
42
|
+
},
|
43
|
+
});
|
44
|
+
}
|
45
|
+
aggregates.push({
|
46
|
+
$sort: {
|
47
|
+
[sortName]: sortOrder === 'asc' ? 1 : -1,
|
48
|
+
},
|
49
|
+
});
|
50
|
+
const dataAggregates = [...aggregates];
|
51
|
+
if (skipCount) {
|
52
|
+
dataAggregates.push({
|
53
|
+
$skip: skipCount,
|
54
|
+
});
|
55
|
+
}
|
56
|
+
const facetAggregates = [
|
57
|
+
{
|
58
|
+
$facet: {
|
59
|
+
data: [
|
60
|
+
...dataAggregates,
|
61
|
+
{
|
62
|
+
$limit: count,
|
63
|
+
},
|
64
|
+
],
|
65
|
+
total: [...aggregates, { $count: 'totalCount' }],
|
66
|
+
},
|
67
|
+
},
|
68
|
+
];
|
69
|
+
let data;
|
70
|
+
try {
|
71
|
+
data = await getPersonDbModel().aggregate(facetAggregates);
|
72
|
+
}
|
73
|
+
catch (err) {
|
74
|
+
return {
|
75
|
+
customError: composeCustomError('Get persons failed', { err }),
|
76
|
+
};
|
77
|
+
}
|
78
|
+
return {
|
79
|
+
data: {
|
80
|
+
persons: data[0].data,
|
81
|
+
personsCount: data[0].total.length > 0 ? data[0].total[0].totalCount : 0,
|
82
|
+
},
|
83
|
+
};
|
84
|
+
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { CustomError } from '../../../../../error/index.js';
|
2
|
+
import { PersonFilterSort } from '../../../../../filter-sort/index.js';
|
3
|
+
import { Country } from '../../../../../geographical/index.js';
|
4
|
+
import { Person } from '../../../../../person/index.js';
|
5
|
+
export type GetPersons = <T extends keyof TypeMap = never>(props: {
|
6
|
+
filterSort: PersonFilterSort;
|
7
|
+
isProposable?: boolean;
|
8
|
+
withCandlesCount?: boolean;
|
9
|
+
withBirthPlaceCountry?: boolean;
|
10
|
+
}) => Promise<{
|
11
|
+
data: {
|
12
|
+
persons: TypeMap[T][];
|
13
|
+
personsCount: number;
|
14
|
+
};
|
15
|
+
} | {
|
16
|
+
customError: CustomError;
|
17
|
+
}>;
|
18
|
+
type TypeMap = {
|
19
|
+
persons: Person;
|
20
|
+
personsWithBirthPlaceCountry: Person & {
|
21
|
+
birthPlaceCountry: Country;
|
22
|
+
};
|
23
|
+
personsWithCandlesCount: Person & {
|
24
|
+
candlesCount: {
|
25
|
+
burning: number;
|
26
|
+
burned: number;
|
27
|
+
};
|
28
|
+
};
|
29
|
+
};
|
30
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -3,5 +3,5 @@ import { CacheKey } from '../../cache/index.js';
|
|
3
3
|
export type MessageBrokerRefreshCache = {
|
4
4
|
cacheKeys?: CacheKey[];
|
5
5
|
pageDictionaries?: Page[];
|
6
|
-
pageServerData?: Array<'candles-page' | 'persons-map-page'>;
|
6
|
+
pageServerData?: Array<'candles-page' | 'home-page' | 'persons-map-page'>;
|
7
7
|
};
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { countCandles, countPersons, getCandles, getPersons, getRandomPerson } from '../../../../database/index.js';
|
2
|
+
export const composeHomePageData = async () => {
|
3
|
+
let resp;
|
4
|
+
resp = await countCandles();
|
5
|
+
if ('customError' in resp) {
|
6
|
+
return resp;
|
7
|
+
}
|
8
|
+
const { count: candlesCount } = resp;
|
9
|
+
resp = await countCandles({ burningState: 'burning' });
|
10
|
+
if ('customError' in resp) {
|
11
|
+
return resp;
|
12
|
+
}
|
13
|
+
const { count: burningCandlesCount } = resp;
|
14
|
+
resp = await countCandles({ burningState: 'burned' });
|
15
|
+
if ('customError' in resp) {
|
16
|
+
return resp;
|
17
|
+
}
|
18
|
+
const { count: burnedCandlesCount } = resp;
|
19
|
+
resp = await countPersons();
|
20
|
+
if ('customError' in resp) {
|
21
|
+
return resp;
|
22
|
+
}
|
23
|
+
const { count: personsCount } = resp;
|
24
|
+
resp = await getCandles({
|
25
|
+
filterSort: {
|
26
|
+
count: 5,
|
27
|
+
burning_states: ['burning'],
|
28
|
+
sort_name: 'litAt',
|
29
|
+
sort_order: 'desc',
|
30
|
+
},
|
31
|
+
withPerson: true,
|
32
|
+
});
|
33
|
+
if ('customError' in resp) {
|
34
|
+
return resp;
|
35
|
+
}
|
36
|
+
const { candles } = resp.data;
|
37
|
+
resp = await getRandomPerson({ isProposable: true });
|
38
|
+
if ('customError' in resp) {
|
39
|
+
return resp;
|
40
|
+
}
|
41
|
+
const { data: person } = resp;
|
42
|
+
resp = await getPersons({
|
43
|
+
filterSort: {
|
44
|
+
count: 5,
|
45
|
+
sort_name: 'createdAt',
|
46
|
+
sort_order: 'desc',
|
47
|
+
},
|
48
|
+
withCandlesCount: true,
|
49
|
+
});
|
50
|
+
if ('customError' in resp) {
|
51
|
+
return resp;
|
52
|
+
}
|
53
|
+
const { persons } = resp.data;
|
54
|
+
return {
|
55
|
+
data: {
|
56
|
+
...(person && {
|
57
|
+
proposal: {
|
58
|
+
person,
|
59
|
+
},
|
60
|
+
}),
|
61
|
+
lastLitCandles: {
|
62
|
+
candles,
|
63
|
+
},
|
64
|
+
lastUploadedPersons: {
|
65
|
+
persons,
|
66
|
+
},
|
67
|
+
statistics: {
|
68
|
+
count: {
|
69
|
+
candles: candlesCount,
|
70
|
+
burnedCandles: burnedCandlesCount,
|
71
|
+
burningCandles: burningCandlesCount,
|
72
|
+
persons: personsCount,
|
73
|
+
},
|
74
|
+
},
|
75
|
+
},
|
76
|
+
};
|
77
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Candle } from '../../../../candle/index.js';
|
2
|
+
import { Person } from '../../../../person/index.js';
|
3
|
+
export interface HomePageData {
|
4
|
+
proposal?: {
|
5
|
+
person: Person;
|
6
|
+
};
|
7
|
+
lastLitCandles: {
|
8
|
+
candles: Array<Candle & {
|
9
|
+
person?: Person;
|
10
|
+
}>;
|
11
|
+
};
|
12
|
+
lastUploadedPersons: {
|
13
|
+
persons: Array<Person & {
|
14
|
+
candlesCount: {
|
15
|
+
burning: number;
|
16
|
+
burned: number;
|
17
|
+
};
|
18
|
+
}>;
|
19
|
+
};
|
20
|
+
statistics: {
|
21
|
+
count: {
|
22
|
+
burnedCandles: number;
|
23
|
+
burningCandles: number;
|
24
|
+
candles: number;
|
25
|
+
persons: number;
|
26
|
+
};
|
27
|
+
};
|
28
|
+
}
|
@@ -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 {
|
2
|
+
import { composeDictionary } from '../../../../dictionary/index.js';
|
4
3
|
import { composeCandlesPageData } from '../../../../page/index.js';
|
5
|
-
export const composeCandlesPageServerData = async (
|
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
|
12
|
+
resp = await composeCandlesPageData({ filterSort });
|
12
13
|
if ('customError' in resp) {
|
13
14
|
return resp;
|
14
15
|
}
|
15
|
-
const
|
16
|
-
resp = await
|
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
|
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 = (
|
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
|
} | {
|
package/src/backend/server/server-data/edit-candle/compose-edit-candle-page-server-data/type.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { composeDictionary } from '../../../../dictionary/index.js';
|
2
|
+
import { composeHomePageData } from '../../../../page/index.js';
|
3
|
+
export const composeHomePageServerData = async (language, options) => {
|
4
|
+
const excludedTranslationIdOptions = options?.excludedTranslationIdOptions;
|
5
|
+
let resp;
|
6
|
+
resp = await composeHomePageData();
|
7
|
+
if ('customError' in resp) {
|
8
|
+
return resp;
|
9
|
+
}
|
10
|
+
const pageData = resp.data;
|
11
|
+
resp = await composeDictionary('home-page', language, { excludedTranslationIdOptions });
|
12
|
+
if ('customError' in resp) {
|
13
|
+
return resp;
|
14
|
+
}
|
15
|
+
const dictionary = resp.data;
|
16
|
+
return {
|
17
|
+
data: {
|
18
|
+
dictionary,
|
19
|
+
pageData,
|
20
|
+
},
|
21
|
+
};
|
22
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Language } from '../../../../../dictionary/index.js';
|
2
|
+
import { CustomError } from '../../../../../error/index.js';
|
3
|
+
import { ExcludedTranslationIdOptions } from '../../../../dictionary/index.js';
|
4
|
+
import { HomePageServerData } from '../type.js';
|
5
|
+
export type ComposeHomePageServerData = (language: Language, options?: {
|
6
|
+
excludedTranslationIdOptions?: ExcludedTranslationIdOptions;
|
7
|
+
}) => Promise<{
|
8
|
+
data: HomePageServerData;
|
9
|
+
} | {
|
10
|
+
customError: CustomError;
|
11
|
+
}>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/src/filter-sort/index.js
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
import { CountryCode } from '../../geographical/index.js';
|
2
|
+
import { PersonSortName } from '../sort-name/index.js';
|
3
|
+
import { SortOrder } from '../sort-order/index.js';
|
4
|
+
export interface PersonFilterSort {
|
5
|
+
count: number;
|
6
|
+
name?: string;
|
7
|
+
name_case_sensitive?: boolean;
|
8
|
+
place_of_births?: CountryCode[];
|
9
|
+
skip_count?: number;
|
10
|
+
sort_name: PersonSortName;
|
11
|
+
sort_order: SortOrder;
|
12
|
+
user_id?: string;
|
13
|
+
with_photo?: boolean;
|
14
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const PERSON_SORT_NAMES: readonly ["createdAt", "name"];
|
@@ -0,0 +1 @@
|
|
1
|
+
export const PERSON_SORT_NAMES = ['createdAt', 'name'];
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|