@candlerip/shared3 0.0.159 → 0.0.161
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/aggregate/index.d.ts +2 -0
- package/src/backend/database/aggregate/index.js +2 -0
- package/src/backend/database/aggregate/person-birth-place-country/config.d.ts +2 -0
- package/src/backend/database/aggregate/person-birth-place-country/config.js +16 -0
- package/src/backend/database/aggregate/person-birth-place-country/index.d.ts +1 -0
- package/src/backend/database/aggregate/person-birth-place-country/index.js +1 -0
- package/src/backend/database/aggregate/person-candles-count/config.d.ts +2 -0
- package/src/backend/database/aggregate/person-candles-count/config.js +47 -0
- package/src/backend/database/aggregate/person-candles-count/index.d.ts +1 -0
- package/src/backend/database/aggregate/person-candles-count/index.js +1 -0
- package/src/backend/database/model/index.d.ts +1 -0
- package/src/backend/database/model/index.js +1 -0
- package/src/backend/database/model/person/get-person-db-model.d.ts +2 -0
- package/src/backend/database/model/person/get-person-db-model.js +3 -0
- package/src/backend/database/model/person/index.d.ts +2 -0
- package/src/backend/database/model/person/index.js +2 -0
- package/src/backend/database/model/person/person-db-schema.d.ts +102 -0
- package/src/backend/database/model/person/person-db-schema.js +71 -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-person/index.d.ts +2 -0
- package/src/backend/database/mutation/person/get-person/index.js +35 -0
- package/src/backend/database/mutation/person/get-person/type.d.ts +25 -0
- package/src/backend/database/mutation/person/get-person/type.js +1 -0
- package/src/backend/database/mutation/person/index.d.ts +1 -0
- package/src/backend/database/mutation/person/index.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/page/page-data/light-candle/compose-light-candle-page-data/index.d.ts +2 -0
- package/src/backend/page/page-data/light-candle/compose-light-candle-page-data/index.js +22 -0
- package/src/backend/page/page-data/light-candle/compose-light-candle-page-data/type.d.ts +8 -0
- package/src/backend/page/page-data/light-candle/compose-light-candle-page-data/type.js +1 -0
- package/src/backend/page/page-data/light-candle/index.d.ts +2 -0
- package/src/backend/page/page-data/light-candle/index.js +2 -0
- package/src/backend/page/page-data/light-candle/type.d.ts +6 -0
- package/src/backend/page/page-data/light-candle/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/light-candle/compose-light-candle-page-server-data/index.d.ts +2 -0
- package/src/backend/server/server-data/light-candle/compose-light-candle-page-server-data/index.js +22 -0
- package/src/backend/server/server-data/light-candle/compose-light-candle-page-server-data/type.d.ts +11 -0
- package/src/backend/server/server-data/light-candle/compose-light-candle-page-server-data/type.js +1 -0
- package/src/backend/server/server-data/light-candle/index.d.ts +2 -0
- package/src/backend/server/server-data/light-candle/index.js +2 -0
- package/src/backend/server/server-data/light-candle/type.d.ts +6 -0
- package/src/backend/server/server-data/light-candle/type.js +1 -0
package/package.json
CHANGED
@@ -21,6 +21,8 @@ export declare const CACHE: {
|
|
21
21
|
readonly 'edit-person-page-dictionary-hu': "Dictionary";
|
22
22
|
readonly 'light-candle-page-dictionary-en': "Dictionary";
|
23
23
|
readonly 'light-candle-page-dictionary-hu': "Dictionary";
|
24
|
+
readonly 'light-candle-page-server-data-en': "LightCandlePageServerData";
|
25
|
+
readonly 'light-candle-page-server-data-hu': "LightCandlePageServerData";
|
24
26
|
readonly 'help-page-dictionary-en': "Dictionary";
|
25
27
|
readonly 'help-page-dictionary-hu': "Dictionary";
|
26
28
|
readonly 'help-page-server-data-en': "HelpPageServerData";
|
@@ -21,6 +21,8 @@ export const CACHE = {
|
|
21
21
|
'edit-person-page-dictionary-hu': 'Dictionary',
|
22
22
|
'light-candle-page-dictionary-en': 'Dictionary',
|
23
23
|
'light-candle-page-dictionary-hu': 'Dictionary',
|
24
|
+
'light-candle-page-server-data-en': 'LightCandlePageServerData',
|
25
|
+
'light-candle-page-server-data-hu': 'LightCandlePageServerData',
|
24
26
|
'help-page-dictionary-en': 'Dictionary',
|
25
27
|
'help-page-dictionary-hu': 'Dictionary',
|
26
28
|
'help-page-server-data-en': 'HelpPageServerData',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Dictionary } from '../../../dictionary/index.js';
|
2
|
-
import { CandlesPageApiResponse, ContactPageServerData, CookiePolicyPageServerData, HelpPageServerData, PersonsMapPageApiResponse, TermsAndConditionsPageServerData } from '../../server/index.js';
|
2
|
+
import { CandlesPageApiResponse, ContactPageServerData, CookiePolicyPageServerData, HelpPageServerData, LightCandlePageServerData, PersonsMapPageApiResponse, TermsAndConditionsPageServerData } 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]];
|
@@ -10,6 +10,7 @@ interface TypeMap {
|
|
10
10
|
CookiePolicyPageServerData: CookiePolicyPageServerData;
|
11
11
|
Dictionary: Dictionary;
|
12
12
|
HelpPageServerData: HelpPageServerData;
|
13
|
+
LightCandlePageServerData: LightCandlePageServerData;
|
13
14
|
PersonsMapPageApiResponse: PersonsMapPageApiResponse;
|
14
15
|
TermsAndConditionsPageServerData: TermsAndConditionsPageServerData;
|
15
16
|
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
export const PERSON_BIRTH_PLACE_COUNTRY_AGGREGATE = [
|
2
|
+
{
|
3
|
+
$lookup: {
|
4
|
+
from: 'countries',
|
5
|
+
localField: 'birth.place.countryCode',
|
6
|
+
foreignField: 'code',
|
7
|
+
as: 'countries',
|
8
|
+
},
|
9
|
+
},
|
10
|
+
{
|
11
|
+
$unwind: {
|
12
|
+
path: '$countries',
|
13
|
+
preserveNullAndEmptyArrays: true,
|
14
|
+
},
|
15
|
+
},
|
16
|
+
];
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './config.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './config.js';
|
@@ -0,0 +1,47 @@
|
|
1
|
+
export const PERSON_CANDLES_COUNT_AGGREGATE = [
|
2
|
+
{
|
3
|
+
$lookup: {
|
4
|
+
from: 'candles',
|
5
|
+
localField: '_id',
|
6
|
+
foreignField: 'personId',
|
7
|
+
as: 'candles',
|
8
|
+
},
|
9
|
+
},
|
10
|
+
{
|
11
|
+
$addFields: {
|
12
|
+
candlesCount: {
|
13
|
+
burning: {
|
14
|
+
$size: {
|
15
|
+
$filter: {
|
16
|
+
input: '$candles',
|
17
|
+
as: 'candles',
|
18
|
+
cond: {
|
19
|
+
$gte: ['$$candles.burningEndsAt', new Date()],
|
20
|
+
},
|
21
|
+
},
|
22
|
+
},
|
23
|
+
},
|
24
|
+
},
|
25
|
+
},
|
26
|
+
},
|
27
|
+
{
|
28
|
+
$addFields: {
|
29
|
+
candlesCount: {
|
30
|
+
burned: {
|
31
|
+
$size: {
|
32
|
+
$filter: {
|
33
|
+
input: '$candles',
|
34
|
+
as: 'candles',
|
35
|
+
cond: {
|
36
|
+
$lte: ['$$candles.burningEndsAt', new Date()],
|
37
|
+
},
|
38
|
+
},
|
39
|
+
},
|
40
|
+
},
|
41
|
+
},
|
42
|
+
},
|
43
|
+
},
|
44
|
+
{
|
45
|
+
$unset: 'candles',
|
46
|
+
},
|
47
|
+
];
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './config.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './config.js';
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import * as mongoose from 'mongoose';
|
2
|
+
export declare const PersonDbSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
3
|
+
timestamps: true;
|
4
|
+
versionKey: false;
|
5
|
+
}, {
|
6
|
+
createdAt: NativeDate;
|
7
|
+
updatedAt: NativeDate;
|
8
|
+
} & {
|
9
|
+
name?: string | null | undefined;
|
10
|
+
images?: mongoose.Types.DocumentArray<{
|
11
|
+
name?: string | null | undefined;
|
12
|
+
dimensions?: {
|
13
|
+
original?: {
|
14
|
+
width?: number | null | undefined;
|
15
|
+
height?: number | null | undefined;
|
16
|
+
} | null | undefined;
|
17
|
+
resized?: mongoose.Types.DocumentArray<{
|
18
|
+
width?: number | null | undefined;
|
19
|
+
height?: number | null | undefined;
|
20
|
+
}> | null | undefined;
|
21
|
+
} | null | undefined;
|
22
|
+
extension?: string | null | undefined;
|
23
|
+
}> | null | undefined;
|
24
|
+
description?: string | null | undefined;
|
25
|
+
userId?: string | null | undefined;
|
26
|
+
birth?: {
|
27
|
+
date?: string | null | undefined;
|
28
|
+
place?: {
|
29
|
+
countryCode?: string | null | undefined;
|
30
|
+
} | null | undefined;
|
31
|
+
} | null | undefined;
|
32
|
+
death?: {
|
33
|
+
date?: string | null | undefined;
|
34
|
+
} | null | undefined;
|
35
|
+
isProposable?: boolean | null | undefined;
|
36
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
37
|
+
createdAt: NativeDate;
|
38
|
+
updatedAt: NativeDate;
|
39
|
+
} & {
|
40
|
+
name?: string | null | undefined;
|
41
|
+
images?: mongoose.Types.DocumentArray<{
|
42
|
+
name?: string | null | undefined;
|
43
|
+
dimensions?: {
|
44
|
+
original?: {
|
45
|
+
width?: number | null | undefined;
|
46
|
+
height?: number | null | undefined;
|
47
|
+
} | null | undefined;
|
48
|
+
resized?: mongoose.Types.DocumentArray<{
|
49
|
+
width?: number | null | undefined;
|
50
|
+
height?: number | null | undefined;
|
51
|
+
}> | null | undefined;
|
52
|
+
} | null | undefined;
|
53
|
+
extension?: string | null | undefined;
|
54
|
+
}> | null | undefined;
|
55
|
+
description?: string | null | undefined;
|
56
|
+
userId?: string | null | undefined;
|
57
|
+
birth?: {
|
58
|
+
date?: string | null | undefined;
|
59
|
+
place?: {
|
60
|
+
countryCode?: string | null | undefined;
|
61
|
+
} | null | undefined;
|
62
|
+
} | null | undefined;
|
63
|
+
death?: {
|
64
|
+
date?: string | null | undefined;
|
65
|
+
} | null | undefined;
|
66
|
+
isProposable?: boolean | null | undefined;
|
67
|
+
}>> & mongoose.FlatRecord<{
|
68
|
+
createdAt: NativeDate;
|
69
|
+
updatedAt: NativeDate;
|
70
|
+
} & {
|
71
|
+
name?: string | null | undefined;
|
72
|
+
images?: mongoose.Types.DocumentArray<{
|
73
|
+
name?: string | null | undefined;
|
74
|
+
dimensions?: {
|
75
|
+
original?: {
|
76
|
+
width?: number | null | undefined;
|
77
|
+
height?: number | null | undefined;
|
78
|
+
} | null | undefined;
|
79
|
+
resized?: mongoose.Types.DocumentArray<{
|
80
|
+
width?: number | null | undefined;
|
81
|
+
height?: number | null | undefined;
|
82
|
+
}> | null | undefined;
|
83
|
+
} | null | undefined;
|
84
|
+
extension?: string | null | undefined;
|
85
|
+
}> | null | undefined;
|
86
|
+
description?: string | null | undefined;
|
87
|
+
userId?: string | null | undefined;
|
88
|
+
birth?: {
|
89
|
+
date?: string | null | undefined;
|
90
|
+
place?: {
|
91
|
+
countryCode?: string | null | undefined;
|
92
|
+
} | null | undefined;
|
93
|
+
} | null | undefined;
|
94
|
+
death?: {
|
95
|
+
date?: string | null | undefined;
|
96
|
+
} | null | undefined;
|
97
|
+
isProposable?: boolean | null | undefined;
|
98
|
+
}> & {
|
99
|
+
_id: mongoose.Types.ObjectId;
|
100
|
+
} & {
|
101
|
+
__v: number;
|
102
|
+
}>;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import * as mongoose from 'mongoose';
|
2
|
+
export const PersonDbSchema = new mongoose.Schema({
|
3
|
+
birth: {
|
4
|
+
date: {
|
5
|
+
type: String,
|
6
|
+
},
|
7
|
+
place: {
|
8
|
+
countryCode: {
|
9
|
+
type: String,
|
10
|
+
},
|
11
|
+
},
|
12
|
+
},
|
13
|
+
death: {
|
14
|
+
date: {
|
15
|
+
type: String,
|
16
|
+
},
|
17
|
+
},
|
18
|
+
description: {
|
19
|
+
type: String,
|
20
|
+
},
|
21
|
+
images: {
|
22
|
+
_id: false,
|
23
|
+
default: undefined,
|
24
|
+
type: [
|
25
|
+
{
|
26
|
+
dimensions: {
|
27
|
+
original: {
|
28
|
+
height: {
|
29
|
+
type: Number,
|
30
|
+
},
|
31
|
+
width: {
|
32
|
+
type: Number,
|
33
|
+
},
|
34
|
+
},
|
35
|
+
resized: {
|
36
|
+
_id: false,
|
37
|
+
default: undefined,
|
38
|
+
type: [
|
39
|
+
{
|
40
|
+
height: {
|
41
|
+
type: Number,
|
42
|
+
},
|
43
|
+
width: {
|
44
|
+
type: Number,
|
45
|
+
},
|
46
|
+
},
|
47
|
+
],
|
48
|
+
},
|
49
|
+
},
|
50
|
+
extension: {
|
51
|
+
type: String,
|
52
|
+
},
|
53
|
+
name: {
|
54
|
+
type: String,
|
55
|
+
},
|
56
|
+
},
|
57
|
+
],
|
58
|
+
},
|
59
|
+
isProposable: {
|
60
|
+
type: Boolean,
|
61
|
+
},
|
62
|
+
name: {
|
63
|
+
type: String,
|
64
|
+
},
|
65
|
+
userId: {
|
66
|
+
type: String,
|
67
|
+
},
|
68
|
+
}, {
|
69
|
+
timestamps: true,
|
70
|
+
versionKey: false,
|
71
|
+
});
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { customErrorWorker } from '@candlerip/shared3';
|
2
|
+
import { Types } from 'mongoose';
|
3
|
+
import { PERSON_BIRTH_PLACE_COUNTRY_AGGREGATE, PERSON_CANDLES_COUNT_AGGREGATE } from '../../../aggregate/index.js';
|
4
|
+
import { getPersonDbModel } from '../../../model/index.js';
|
5
|
+
export const getPerson = async (props) => {
|
6
|
+
const { _id, withCandlesCount, withBirthPlaceCountry } = props;
|
7
|
+
if (!Types.ObjectId.isValid(_id)) {
|
8
|
+
return { data: null };
|
9
|
+
}
|
10
|
+
const aggregates = [{ $match: { _id: new Types.ObjectId(_id) } }];
|
11
|
+
const { composeCustomError } = customErrorWorker(props);
|
12
|
+
if (withCandlesCount) {
|
13
|
+
aggregates.push(...PERSON_CANDLES_COUNT_AGGREGATE);
|
14
|
+
}
|
15
|
+
if (withBirthPlaceCountry) {
|
16
|
+
aggregates.push(...PERSON_BIRTH_PLACE_COUNTRY_AGGREGATE);
|
17
|
+
}
|
18
|
+
let data;
|
19
|
+
try {
|
20
|
+
data = await getPersonDbModel().aggregate(aggregates);
|
21
|
+
}
|
22
|
+
catch (err) {
|
23
|
+
return {
|
24
|
+
customError: composeCustomError('Get person failed', { err }),
|
25
|
+
};
|
26
|
+
}
|
27
|
+
if (!data || data.length === 0) {
|
28
|
+
return {
|
29
|
+
data: null,
|
30
|
+
};
|
31
|
+
}
|
32
|
+
return {
|
33
|
+
data: data[0],
|
34
|
+
};
|
35
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { CustomError } from '../../../../../error/index.js';
|
2
|
+
import { Country } from '../../../../../geographical/index.js';
|
3
|
+
import { Person } from '../../../../../person/index.js';
|
4
|
+
export type GetPerson = <T extends keyof TypeMap = never>(props: {
|
5
|
+
_id: string;
|
6
|
+
withCandlesCount?: boolean;
|
7
|
+
withBirthPlaceCountry?: boolean;
|
8
|
+
}) => Promise<{
|
9
|
+
data: TypeMap[T] | null;
|
10
|
+
} | {
|
11
|
+
customError: CustomError;
|
12
|
+
}>;
|
13
|
+
type TypeMap = {
|
14
|
+
person: Person;
|
15
|
+
personWithCandlesCount: Person & {
|
16
|
+
candlesCount: {
|
17
|
+
burning: number;
|
18
|
+
burned: number;
|
19
|
+
};
|
20
|
+
};
|
21
|
+
personWithBirthPlaceCountry: Person & {
|
22
|
+
birthPlaceCountry: Country;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './get-person/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './get-person/index.js';
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { composeCustomError } from '../../../../../error/index.js';
|
2
|
+
import { getPerson } from '../../../../database/index.js';
|
3
|
+
export const composeLightCandlePageData = async (personId) => {
|
4
|
+
const resp = await getPerson({ _id: personId });
|
5
|
+
if ('customError' in resp) {
|
6
|
+
return resp;
|
7
|
+
}
|
8
|
+
const { data: person } = resp;
|
9
|
+
if (!person) {
|
10
|
+
return {
|
11
|
+
customError: composeCustomError('Person not found'),
|
12
|
+
personNotFoundError: true,
|
13
|
+
};
|
14
|
+
}
|
15
|
+
return {
|
16
|
+
data: {
|
17
|
+
maintenance: {
|
18
|
+
person,
|
19
|
+
},
|
20
|
+
},
|
21
|
+
};
|
22
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { CustomError } from '../../../../../error/index.js';
|
2
|
+
import { LightCandlePageData } from '../type.js';
|
3
|
+
export type ComposeLightCandlePageData = (personId: string) => Promise<{
|
4
|
+
data: LightCandlePageData;
|
5
|
+
} | {
|
6
|
+
customError: CustomError;
|
7
|
+
personNotFoundError?: boolean;
|
8
|
+
}>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -2,5 +2,6 @@ export * from './candles/index.js';
|
|
2
2
|
export * from './contact/index.js';
|
3
3
|
export * from './cookie-policy/index.js';
|
4
4
|
export * from './help/index.js';
|
5
|
+
export * from './light-candle/index.js';
|
5
6
|
export * from './persons-map/index.js';
|
6
7
|
export * from './terms-and-conditions/index.js';
|
@@ -2,5 +2,6 @@ export * from './candles/index.js';
|
|
2
2
|
export * from './contact/index.js';
|
3
3
|
export * from './cookie-policy/index.js';
|
4
4
|
export * from './help/index.js';
|
5
|
+
export * from './light-candle/index.js';
|
5
6
|
export * from './persons-map/index.js';
|
6
7
|
export * from './terms-and-conditions/index.js';
|
package/src/backend/server/server-data/light-candle/compose-light-candle-page-server-data/index.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
import { composeDictionary } from '../../../../dictionary/index.js';
|
2
|
+
import { composeLightCandlePageData } from '../../../../page/index.js';
|
3
|
+
export const composeLightCandlePageServerData = async (language, personId, options) => {
|
4
|
+
const excludedTranslationIdOptions = options?.excludedTranslationIdOptions;
|
5
|
+
let resp;
|
6
|
+
resp = await composeLightCandlePageData(personId);
|
7
|
+
if ('customError' in resp) {
|
8
|
+
return resp;
|
9
|
+
}
|
10
|
+
const pageData = resp.data;
|
11
|
+
resp = await composeDictionary('contact-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
|
+
};
|
package/src/backend/server/server-data/light-candle/compose-light-candle-page-server-data/type.d.ts
ADDED
@@ -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 { LightCandlePageServerData } from '../type.js';
|
5
|
+
export type ComposeLightCandlePageServerData = (language: Language, personId: string, options?: {
|
6
|
+
excludedTranslationIdOptions?: ExcludedTranslationIdOptions;
|
7
|
+
}) => Promise<{
|
8
|
+
data: LightCandlePageServerData;
|
9
|
+
} | {
|
10
|
+
customError: CustomError;
|
11
|
+
}>;
|
package/src/backend/server/server-data/light-candle/compose-light-candle-page-server-data/type.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|