@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.
Files changed (76) hide show
  1. package/package.json +1 -1
  2. package/src/backend/cache/cache/config.d.ts +2 -0
  3. package/src/backend/cache/cache/config.js +2 -0
  4. package/src/backend/cache/cache/type.d.ts +2 -1
  5. package/src/backend/database/model/candle/candle-db-schema.d.ts +3 -3
  6. package/src/backend/database/mutation/count/count-candles/index.d.ts +2 -0
  7. package/src/backend/database/mutation/count/count-candles/index.js +24 -0
  8. package/src/backend/database/mutation/count/count-candles/types.d.ts +9 -0
  9. package/src/backend/database/mutation/count/count-persons/index.d.ts +2 -0
  10. package/src/backend/database/mutation/count/count-persons/index.js +15 -0
  11. package/src/backend/database/mutation/count/count-persons/types.d.ts +6 -0
  12. package/src/backend/database/mutation/count/index.d.ts +2 -0
  13. package/src/backend/database/mutation/count/index.js +2 -0
  14. package/src/backend/database/mutation/index.d.ts +1 -0
  15. package/src/backend/database/mutation/index.js +1 -0
  16. package/src/backend/database/mutation/person/get-random/index.d.ts +2 -0
  17. package/src/backend/database/mutation/person/get-random/index.js +36 -0
  18. package/src/backend/database/mutation/person/get-random/type.d.ts +20 -0
  19. package/src/backend/database/mutation/person/get-random/type.js +1 -0
  20. package/src/backend/database/mutation/person/gets/index.d.ts +2 -0
  21. package/src/backend/database/mutation/person/gets/index.js +84 -0
  22. package/src/backend/database/mutation/person/gets/type.d.ts +30 -0
  23. package/src/backend/database/mutation/person/gets/type.js +1 -0
  24. package/src/backend/database/mutation/person/index.d.ts +2 -0
  25. package/src/backend/database/mutation/person/index.js +2 -0
  26. package/src/backend/message-broker/message-broker-refresh-cache/type.d.ts +1 -1
  27. package/src/backend/page/page-data/home/compose-home-page-data/index.d.ts +2 -0
  28. package/src/backend/page/page-data/home/compose-home-page-data/index.js +77 -0
  29. package/src/backend/page/page-data/home/compose-home-page-data/type.d.ts +7 -0
  30. package/src/backend/page/page-data/home/compose-home-page-data/type.js +1 -0
  31. package/src/backend/page/page-data/home/index.d.ts +2 -0
  32. package/src/backend/page/page-data/home/index.js +2 -0
  33. package/src/backend/page/page-data/home/type.d.ts +28 -0
  34. package/src/backend/page/page-data/home/type.js +1 -0
  35. package/src/backend/page/page-data/index.d.ts +1 -0
  36. package/src/backend/page/page-data/index.js +1 -0
  37. package/src/backend/server/server-data/candles/compose-candles-page-server-data/index.js +8 -7
  38. package/src/backend/server/server-data/candles/compose-candles-page-server-data/type.d.ts +3 -2
  39. package/src/backend/server/server-data/edit-candle/compose-edit-candle-page-server-data/type.js +1 -0
  40. package/src/backend/server/server-data/edit-candle/type.js +1 -0
  41. package/src/backend/server/server-data/home/compose-home-page-server-data/index.d.ts +2 -0
  42. package/src/backend/server/server-data/home/compose-home-page-server-data/index.js +22 -0
  43. package/src/backend/server/server-data/home/compose-home-page-server-data/type.d.ts +11 -0
  44. package/src/backend/server/server-data/home/compose-home-page-server-data/type.js +1 -0
  45. package/src/backend/server/server-data/home/index.d.ts +2 -0
  46. package/src/backend/server/server-data/home/index.js +2 -0
  47. package/src/backend/server/server-data/home/type.d.ts +6 -0
  48. package/src/backend/server/server-data/home/type.js +1 -0
  49. package/src/backend/server/server-data/index.d.ts +2 -1
  50. package/src/backend/server/server-data/index.js +2 -1
  51. package/src/filter-sort/index.d.ts +1 -0
  52. package/src/filter-sort/index.js +1 -0
  53. package/src/filter-sort/person-filter-sort/default.d.ts +2 -0
  54. package/src/filter-sort/person-filter-sort/default.js +5 -0
  55. package/src/filter-sort/person-filter-sort/index.d.ts +2 -0
  56. package/src/filter-sort/person-filter-sort/index.js +2 -0
  57. package/src/filter-sort/person-filter-sort/type.d.ts +14 -0
  58. package/src/filter-sort/person-filter-sort/type.js +1 -0
  59. package/src/filter-sort/sort-name/index.d.ts +1 -0
  60. package/src/filter-sort/sort-name/index.js +1 -0
  61. package/src/filter-sort/sort-name/person-sort-name/config.d.ts +1 -0
  62. package/src/filter-sort/sort-name/person-sort-name/config.js +1 -0
  63. package/src/filter-sort/sort-name/person-sort-name/index.d.ts +3 -0
  64. package/src/filter-sort/sort-name/person-sort-name/index.js +3 -0
  65. package/src/filter-sort/sort-name/person-sort-name/type-guard.d.ts +2 -0
  66. package/src/filter-sort/sort-name/person-sort-name/type-guard.js +4 -0
  67. package/src/filter-sort/sort-name/person-sort-name/type.d.ts +2 -0
  68. package/src/filter-sort/sort-name/person-sort-name/type.js +1 -0
  69. /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
  70. /package/src/backend/{server/server-data/edit-canlde/type.js → database/mutation/count/count-persons/types.js} +0 -0
  71. /package/src/backend/server/server-data/{edit-canlde → edit-candle}/compose-edit-candle-page-server-data/index.d.ts +0 -0
  72. /package/src/backend/server/server-data/{edit-canlde → edit-candle}/compose-edit-candle-page-server-data/index.js +0 -0
  73. /package/src/backend/server/server-data/{edit-canlde → edit-candle}/compose-edit-candle-page-server-data/type.d.ts +0 -0
  74. /package/src/backend/server/server-data/{edit-canlde → edit-candle}/index.d.ts +0 -0
  75. /package/src/backend/server/server-data/{edit-canlde → edit-candle}/index.js +0 -0
  76. /package/src/backend/server/server-data/{edit-canlde → edit-candle}/type.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.167",
3
+ "version": "0.0.169",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
@@ -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,2 @@
1
+ import { CountCandles } from './types.js';
2
+ export declare const countCandles: CountCandles;
@@ -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,2 @@
1
+ import { CountPersons } from './types.js';
2
+ export declare const countPersons: CountPersons;
@@ -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,6 @@
1
+ import { CustomError } from '../../../../../error/index.js';
2
+ export type CountPersons = () => Promise<{
3
+ count: number;
4
+ } | {
5
+ customError: CustomError;
6
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './count-candles/index.js';
2
+ export * from './count-persons/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './count-candles/index.js';
2
+ export * from './count-persons/index.js';
@@ -1,5 +1,6 @@
1
1
  export * from './candle/index.js';
2
2
  export * from './contact/index.js';
3
+ export * from './count/index.js';
3
4
  export * from './country/index.js';
4
5
  export * from './error-log/index.js';
5
6
  export * from './person/index.js';
@@ -1,5 +1,6 @@
1
1
  export * from './candle/index.js';
2
2
  export * from './contact/index.js';
3
+ export * from './count/index.js';
3
4
  export * from './country/index.js';
4
5
  export * from './error-log/index.js';
5
6
  export * from './person/index.js';
@@ -0,0 +1,2 @@
1
+ import { GetRandomPerson } from './type.js';
2
+ export declare const getRandomPerson: GetRandomPerson;
@@ -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,2 @@
1
+ import { GetPersons } from './type.js';
2
+ export declare const getPersons: GetPersons;
@@ -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 {};
@@ -1 +1,3 @@
1
1
  export * from './get/index.js';
2
+ export * from './get-random/index.js';
3
+ export * from './gets/index.js';
@@ -1 +1,3 @@
1
1
  export * from './get/index.js';
2
+ export * from './get-random/index.js';
3
+ export * from './gets/index.js';
@@ -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,2 @@
1
+ import { ComposeHomePageData } from './type.js';
2
+ export declare const composeHomePageData: ComposeHomePageData;
@@ -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,7 @@
1
+ import { CustomError } from '../../../../../error/index.js';
2
+ import { HomePageData } from '../type.js';
3
+ export type ComposeHomePageData = () => Promise<{
4
+ data: HomePageData;
5
+ } | {
6
+ customError: CustomError;
7
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './compose-home-page-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-home-page-data/index.js';
2
+ export * from './type.js';
@@ -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,4 +1,5 @@
1
1
  export * from './candles/index.js';
2
2
  export * from './edit-candle/index.js';
3
+ export * from './home/index.js';
3
4
  export * from './light-candle/index.js';
4
5
  export * from './persons-map/index.js';
@@ -1,4 +1,5 @@
1
1
  export * from './candles/index.js';
2
2
  export * from './edit-candle/index.js';
3
+ export * from './home/index.js';
3
4
  export * from './light-candle/index.js';
4
5
  export * from './persons-map/index.js';
@@ -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
  } | {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ComposeHomePageServerData } from './type.js';
2
+ export declare const composeHomePageServerData: ComposeHomePageServerData;
@@ -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,2 @@
1
+ export * from './compose-home-page-server-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-home-page-server-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,6 @@
1
+ import { Dictionary } from '../../../../dictionary/index.js';
2
+ import { HomePageData } from '../../../page/index.js';
3
+ export interface HomePageServerData {
4
+ dictionary: Dictionary;
5
+ pageData: HomePageData;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  export * from './candles/index.js';
2
- export * from './edit-canlde/index.js';
2
+ export * from './edit-candle/index.js';
3
+ export * from './home/index.js';
3
4
  export * from './light-candle/index.js';
4
5
  export * from './persons-map/index.js';
@@ -1,4 +1,5 @@
1
1
  export * from './candles/index.js';
2
- export * from './edit-canlde/index.js';
2
+ export * from './edit-candle/index.js';
3
+ export * from './home/index.js';
3
4
  export * from './light-candle/index.js';
4
5
  export * from './persons-map/index.js';
@@ -1,3 +1,4 @@
1
1
  export * from './candle-filter-sort/index.js';
2
+ export * from './person-filter-sort/index.js';
2
3
  export * from './sort-name/index.js';
3
4
  export * from './sort-order/index.js';
@@ -1,3 +1,4 @@
1
1
  export * from './candle-filter-sort/index.js';
2
+ export * from './person-filter-sort/index.js';
2
3
  export * from './sort-name/index.js';
3
4
  export * from './sort-order/index.js';
@@ -0,0 +1,2 @@
1
+ import { PersonFilterSort } from './type.js';
2
+ export declare const DEFAULT_PERSON_FILTER_SORT: PersonFilterSort;
@@ -0,0 +1,5 @@
1
+ export const DEFAULT_PERSON_FILTER_SORT = {
2
+ count: 50,
3
+ sort_name: 'createdAt',
4
+ sort_order: 'desc',
5
+ };
@@ -0,0 +1,2 @@
1
+ export * from './default.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './default.js';
2
+ export * from './type.js';
@@ -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 {};
@@ -1 +1,2 @@
1
1
  export * from './candle-sort-name/index.js';
2
+ export * from './person-sort-name/index.js';
@@ -1 +1,2 @@
1
1
  export * from './candle-sort-name/index.js';
2
+ export * from './person-sort-name/index.js';
@@ -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,3 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
3
+ export * from './type-guard.js';
@@ -0,0 +1,3 @@
1
+ export * from './config.js';
2
+ export * from './type.js';
3
+ export * from './type-guard.js';
@@ -0,0 +1,2 @@
1
+ import { PersonSortName } from './type.js';
2
+ export declare const isPersonSortName: (data?: unknown) => data is PersonSortName;
@@ -0,0 +1,4 @@
1
+ import { PERSON_SORT_NAMES } from './config.js';
2
+ export const isPersonSortName = (data) => {
3
+ return PERSON_SORT_NAMES.some((it) => data === it);
4
+ };
@@ -0,0 +1,2 @@
1
+ import { PERSON_SORT_NAMES } from './config.js';
2
+ export type PersonSortName = (typeof PERSON_SORT_NAMES)[number];
@@ -0,0 +1 @@
1
+ export {};