@candlerip/shared3 0.0.150 → 0.0.151
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/api/api-response/index.d.ts +1 -0
- package/src/backend/api/api-response/index.js +1 -0
- package/src/backend/api/api-response/persons-map/compose-persons-map-page-api-response/index.d.ts +2 -0
- package/src/backend/api/api-response/persons-map/compose-persons-map-page-api-response/index.js +22 -0
- package/src/backend/api/api-response/persons-map/compose-persons-map-page-api-response/type.d.ts +10 -0
- package/src/backend/api/api-response/persons-map/compose-persons-map-page-api-response/type.js +1 -0
- package/src/backend/api/api-response/persons-map/index.d.ts +2 -0
- package/src/backend/api/api-response/persons-map/index.js +2 -0
- package/src/backend/api/api-response/persons-map/type.d.ts +6 -0
- package/src/backend/api/api-response/persons-map/type.js +1 -0
- 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/country-persons-count-aggregate/index.d.ts +2 -0
- package/src/backend/database/aggregate/country-persons-count-aggregate/index.js +27 -0
- package/src/backend/database/aggregate/index.d.ts +1 -0
- package/src/backend/database/aggregate/index.js +1 -0
- package/src/backend/database/model/country/country-db-schema.d.ts +48 -0
- package/src/backend/database/model/country/country-db-schema.js +31 -0
- package/src/backend/database/model/country/get-country-db-model.d.ts +2 -0
- package/src/backend/database/model/country/get-country-db-model.js +3 -0
- package/src/backend/database/model/country/index.d.ts +2 -0
- package/src/backend/database/model/country/index.js +2 -0
- package/src/backend/database/model/index.d.ts +1 -0
- package/src/backend/database/model/index.js +1 -0
- package/src/backend/database/mutation/candle/get-candles/type.d.ts +9 -4
- package/src/backend/database/mutation/country/get-countries/index.d.ts +2 -0
- package/src/backend/database/mutation/country/get-countries/index.js +30 -0
- package/src/backend/database/mutation/country/get-countries/type.d.ts +16 -0
- package/src/backend/database/mutation/country/get-countries/type.js +1 -0
- package/src/backend/database/mutation/country/get-country/index.d.ts +2 -0
- package/src/backend/database/mutation/country/get-country/index.js +33 -0
- package/src/backend/database/mutation/country/get-country/type.d.ts +17 -0
- package/src/backend/database/mutation/country/get-country/type.js +1 -0
- package/src/backend/database/mutation/country/index.d.ts +2 -0
- package/src/backend/database/mutation/country/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/page/page-data/index.d.ts +1 -0
- package/src/backend/page/page-data/index.js +1 -0
- package/src/backend/page/page-data/persons-map/compose-persons-map-page-data/index.d.ts +2 -0
- package/src/backend/page/page-data/persons-map/compose-persons-map-page-data/index.js +15 -0
- package/src/backend/page/page-data/persons-map/compose-persons-map-page-data/type.d.ts +7 -0
- package/src/backend/page/page-data/persons-map/compose-persons-map-page-data/type.js +1 -0
- package/src/backend/page/page-data/persons-map/index.d.ts +2 -0
- package/src/backend/page/page-data/persons-map/index.js +2 -0
- package/src/backend/page/page-data/persons-map/type.d.ts +8 -0
- package/src/backend/page/page-data/persons-map/type.js +1 -0
- package/src/geographical/country/index.d.ts +1 -0
- package/src/geographical/country/index.js +1 -0
- package/src/geographical/country/type.d.ts +13 -0
- package/src/geographical/country/type.js +1 -0
- package/src/geographical/index.d.ts +1 -0
- package/src/geographical/index.js +1 -0
- package/src/type/index.d.ts +1 -0
- package/src/type/index.js +1 -0
- package/src/type/number/index.d.ts +1 -0
- package/src/type/number/index.js +1 -0
- package/src/type/number/type-guard.d.ts +1 -0
- package/src/type/number/type-guard.js +1 -0
package/package.json
CHANGED
package/src/backend/api/api-response/persons-map/compose-persons-map-page-api-response/index.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
import { DICTIONARY_CONFIG } from '../../../../../dictionary/index.js';
|
2
|
+
import { getTranslationsAsDictionary } from '../../../../database/index.js';
|
3
|
+
import { composePersonsMapPageData } from '../../../../page/index.js';
|
4
|
+
export const composePersonsMapPageApiResponse = async ({ language }) => {
|
5
|
+
let resp;
|
6
|
+
resp = await getTranslationsAsDictionary(language, DICTIONARY_CONFIG['persons-map-page'].translationIds);
|
7
|
+
if ('customError' in resp) {
|
8
|
+
return resp;
|
9
|
+
}
|
10
|
+
const dictionary = resp.data;
|
11
|
+
resp = await composePersonsMapPageData();
|
12
|
+
if ('customError' in resp) {
|
13
|
+
return resp;
|
14
|
+
}
|
15
|
+
const pageData = resp.data;
|
16
|
+
return {
|
17
|
+
data: {
|
18
|
+
dictionary,
|
19
|
+
pageData,
|
20
|
+
},
|
21
|
+
};
|
22
|
+
};
|
package/src/backend/api/api-response/persons-map/compose-persons-map-page-api-response/type.d.ts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Language } from '../../../../../dictionary/index.js';
|
2
|
+
import { CustomError } from '../../../../../error/index.js';
|
3
|
+
import { PersonsMapPageApiResponse } from '../type.js';
|
4
|
+
export type ComposePersonsMapPageApiResponse = (props: {
|
5
|
+
language: Language;
|
6
|
+
}) => Promise<{
|
7
|
+
data: PersonsMapPageApiResponse;
|
8
|
+
} | {
|
9
|
+
customError: CustomError;
|
10
|
+
}>;
|
package/src/backend/api/api-response/persons-map/compose-persons-map-page-api-response/type.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -27,6 +27,8 @@ export declare const CACHE: {
|
|
27
27
|
readonly 'person-details-page-dictionary-hu': "Dictionary";
|
28
28
|
readonly 'persons-page-dictionary-en': "Dictionary";
|
29
29
|
readonly 'persons-page-dictionary-hu': "Dictionary";
|
30
|
+
readonly 'persons-map-page-api-response-en': "PersonsMapPageApiResponse";
|
31
|
+
readonly 'persons-map-page-api-response-hu': "PersonsMapPageApiResponse";
|
30
32
|
readonly 'persons-map-page-dictionary-en': "Dictionary";
|
31
33
|
readonly 'persons-map-page-dictionary-hu': "Dictionary";
|
32
34
|
readonly 'terms-and-conditions-page-dictionary-en': "Dictionary";
|
@@ -27,6 +27,8 @@ export const CACHE = {
|
|
27
27
|
'person-details-page-dictionary-hu': 'Dictionary',
|
28
28
|
'persons-page-dictionary-en': 'Dictionary',
|
29
29
|
'persons-page-dictionary-hu': 'Dictionary',
|
30
|
+
'persons-map-page-api-response-en': 'PersonsMapPageApiResponse',
|
31
|
+
'persons-map-page-api-response-hu': 'PersonsMapPageApiResponse',
|
30
32
|
'persons-map-page-dictionary-en': 'Dictionary',
|
31
33
|
'persons-map-page-dictionary-hu': 'Dictionary',
|
32
34
|
'terms-and-conditions-page-dictionary-en': 'Dictionary',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Dictionary } from '../../../dictionary/index.js';
|
2
|
-
import { CandlesPageApiResponse } from '../../api/index.js';
|
2
|
+
import { CandlesPageApiResponse, PersonsMapPageApiResponse } from '../../api/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,5 +7,6 @@ export type Cache = {
|
|
7
7
|
interface TypeMap {
|
8
8
|
CandlesPageApiResponse: CandlesPageApiResponse;
|
9
9
|
Dictionary: Dictionary;
|
10
|
+
PersonsMapPageApiResponse: PersonsMapPageApiResponse;
|
10
11
|
}
|
11
12
|
export {};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
export const COUNTRY_PERSONS_COUNT_AGGREGATE = [
|
2
|
+
{
|
3
|
+
$lookup: {
|
4
|
+
from: 'persons',
|
5
|
+
localField: 'code',
|
6
|
+
foreignField: 'birth.place.countryCode',
|
7
|
+
as: 'persons',
|
8
|
+
},
|
9
|
+
},
|
10
|
+
{
|
11
|
+
$addFields: {
|
12
|
+
personsCount: {
|
13
|
+
$size: '$persons',
|
14
|
+
},
|
15
|
+
},
|
16
|
+
},
|
17
|
+
{
|
18
|
+
$match: {
|
19
|
+
personsCount: {
|
20
|
+
$ne: 0,
|
21
|
+
},
|
22
|
+
},
|
23
|
+
},
|
24
|
+
{
|
25
|
+
$unset: 'persons',
|
26
|
+
},
|
27
|
+
];
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import * as mongoose from 'mongoose';
|
2
|
+
export declare const CountryDbSchema: 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
|
+
code: string;
|
10
|
+
location?: {
|
11
|
+
type: "Point";
|
12
|
+
coordinates: number[];
|
13
|
+
} | null | undefined;
|
14
|
+
translation?: {
|
15
|
+
en: string;
|
16
|
+
hu: string;
|
17
|
+
} | null | undefined;
|
18
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
19
|
+
createdAt: NativeDate;
|
20
|
+
updatedAt: NativeDate;
|
21
|
+
} & {
|
22
|
+
code: string;
|
23
|
+
location?: {
|
24
|
+
type: "Point";
|
25
|
+
coordinates: number[];
|
26
|
+
} | null | undefined;
|
27
|
+
translation?: {
|
28
|
+
en: string;
|
29
|
+
hu: string;
|
30
|
+
} | null | undefined;
|
31
|
+
}>> & mongoose.FlatRecord<{
|
32
|
+
createdAt: NativeDate;
|
33
|
+
updatedAt: NativeDate;
|
34
|
+
} & {
|
35
|
+
code: string;
|
36
|
+
location?: {
|
37
|
+
type: "Point";
|
38
|
+
coordinates: number[];
|
39
|
+
} | null | undefined;
|
40
|
+
translation?: {
|
41
|
+
en: string;
|
42
|
+
hu: string;
|
43
|
+
} | null | undefined;
|
44
|
+
}> & {
|
45
|
+
_id: mongoose.Types.ObjectId;
|
46
|
+
} & {
|
47
|
+
__v: number;
|
48
|
+
}>;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import * as mongoose from 'mongoose';
|
2
|
+
export const CountryDbSchema = new mongoose.Schema({
|
3
|
+
code: {
|
4
|
+
required: true,
|
5
|
+
type: String,
|
6
|
+
},
|
7
|
+
location: {
|
8
|
+
coordinates: {
|
9
|
+
type: [Number],
|
10
|
+
required: true,
|
11
|
+
},
|
12
|
+
type: {
|
13
|
+
type: String,
|
14
|
+
enum: ['Point'],
|
15
|
+
required: true,
|
16
|
+
},
|
17
|
+
},
|
18
|
+
translation: {
|
19
|
+
en: {
|
20
|
+
required: true,
|
21
|
+
type: String,
|
22
|
+
},
|
23
|
+
hu: {
|
24
|
+
required: true,
|
25
|
+
type: String,
|
26
|
+
},
|
27
|
+
},
|
28
|
+
}, {
|
29
|
+
timestamps: true,
|
30
|
+
versionKey: false,
|
31
|
+
});
|
@@ -2,16 +2,21 @@ import { Candle } from '../../../../../candle/index.js';
|
|
2
2
|
import { CustomError } from '../../../../../error/index.js';
|
3
3
|
import { CandleFilterSort } from '../../../../../filter-sort/index.js';
|
4
4
|
import { Person } from '../../../../../person/index.js';
|
5
|
-
export type GetCandles = <T extends
|
6
|
-
person?: Person;
|
7
|
-
}) = never>(props: {
|
5
|
+
export type GetCandles = <T extends keyof TypeMap = never>(props: {
|
8
6
|
filterSort: CandleFilterSort;
|
9
7
|
withPerson?: boolean;
|
10
8
|
}) => Promise<{
|
11
9
|
data: {
|
12
|
-
candles: T
|
10
|
+
candles: TypeMap[T];
|
13
11
|
candlesCount: number;
|
14
12
|
};
|
15
13
|
} | {
|
16
14
|
customError: CustomError;
|
17
15
|
}>;
|
16
|
+
type TypeMap = {
|
17
|
+
candle: Candle[];
|
18
|
+
candleWithPerson: Array<Candle & {
|
19
|
+
person?: Person;
|
20
|
+
}>;
|
21
|
+
};
|
22
|
+
export {};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { COUNTRY_PERSONS_COUNT_AGGREGATE } from '../../../aggregate/index.js';
|
2
|
+
import { customErrorWorker } from '@candlerip/shared3';
|
3
|
+
import { getCountryDbModel } from '../../../model/index.js';
|
4
|
+
export const getCountries = async (props) => {
|
5
|
+
const { composeCustomError } = customErrorWorker(props);
|
6
|
+
const aggregates = [];
|
7
|
+
if (props) {
|
8
|
+
const { withPersonsCount } = props;
|
9
|
+
if (withPersonsCount) {
|
10
|
+
aggregates.push(...COUNTRY_PERSONS_COUNT_AGGREGATE);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
let data;
|
14
|
+
try {
|
15
|
+
if (aggregates.length > 0) {
|
16
|
+
data = await getCountryDbModel().aggregate(aggregates);
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
data = await getCountryDbModel().find();
|
20
|
+
}
|
21
|
+
}
|
22
|
+
catch (err) {
|
23
|
+
return {
|
24
|
+
customError: composeCustomError('Get countries failed', { err }),
|
25
|
+
};
|
26
|
+
}
|
27
|
+
return {
|
28
|
+
data,
|
29
|
+
};
|
30
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { Country } from '../../../../../geographical/index.js';
|
2
|
+
import { CustomError } from '../../../../../error/index.js';
|
3
|
+
export type GetCountries = <T extends keyof TypeMap = never>(props?: {
|
4
|
+
withPersonsCount?: boolean;
|
5
|
+
}) => Promise<{
|
6
|
+
data: TypeMap[T];
|
7
|
+
} | {
|
8
|
+
customError: CustomError;
|
9
|
+
}>;
|
10
|
+
type TypeMap = {
|
11
|
+
countries: Country[] | null;
|
12
|
+
countriesWithPersonsCount: Array<Country & {
|
13
|
+
personsCount: number;
|
14
|
+
}>;
|
15
|
+
};
|
16
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { COUNTRY_PERSONS_COUNT_AGGREGATE } from '../../../aggregate/index.js';
|
2
|
+
import { getCountryDbModel } from '../../../model/index.js';
|
3
|
+
import { customErrorWorker } from '../../../../../error/index.js';
|
4
|
+
export const getCountry = async (props) => {
|
5
|
+
const aggregates = [];
|
6
|
+
const { code, withPersonsCount } = props;
|
7
|
+
const { composeCustomError } = customErrorWorker(props);
|
8
|
+
aggregates.push({
|
9
|
+
$match: {
|
10
|
+
code,
|
11
|
+
},
|
12
|
+
});
|
13
|
+
if (withPersonsCount) {
|
14
|
+
aggregates.push(...COUNTRY_PERSONS_COUNT_AGGREGATE);
|
15
|
+
}
|
16
|
+
let data;
|
17
|
+
try {
|
18
|
+
data = await getCountryDbModel().aggregate(aggregates);
|
19
|
+
}
|
20
|
+
catch (err) {
|
21
|
+
return {
|
22
|
+
customError: composeCustomError('Get countries failed', { err }),
|
23
|
+
};
|
24
|
+
}
|
25
|
+
if (!data || data.length === 0) {
|
26
|
+
return {
|
27
|
+
data: null,
|
28
|
+
};
|
29
|
+
}
|
30
|
+
return {
|
31
|
+
data: data[0],
|
32
|
+
};
|
33
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { Country, CountryCode } from '../../../../../geographical/index.js';
|
2
|
+
import { CustomError } from '../../../../../error/index.js';
|
3
|
+
export type GetCountry = <T extends keyof TypeMap = never>(props: {
|
4
|
+
code: CountryCode;
|
5
|
+
withPersonsCount?: boolean;
|
6
|
+
}) => Promise<{
|
7
|
+
data: TypeMap[T];
|
8
|
+
} | {
|
9
|
+
customError: CustomError;
|
10
|
+
}>;
|
11
|
+
type TypeMap = {
|
12
|
+
country: Country | null;
|
13
|
+
countryWithPersonsCount: (Country & {
|
14
|
+
personsCount: number;
|
15
|
+
}) | null;
|
16
|
+
};
|
17
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { getCountries } from '../../../../database/index.js';
|
2
|
+
export const composePersonsMapPageData = async () => {
|
3
|
+
const resp = await getCountries({ withPersonsCount: true });
|
4
|
+
if ('customError' in resp) {
|
5
|
+
return resp;
|
6
|
+
}
|
7
|
+
const { data: countries } = resp;
|
8
|
+
return {
|
9
|
+
data: {
|
10
|
+
map: {
|
11
|
+
countries,
|
12
|
+
},
|
13
|
+
},
|
14
|
+
};
|
15
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './type.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './type.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/src/type/index.d.ts
CHANGED
package/src/type/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './type-guard.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './type-guard.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isNumber: (data?: unknown) => data is number;
|
@@ -0,0 +1 @@
|
|
1
|
+
export const isNumber = (data) => typeof data === 'number';
|