@candlerip/shared3 0.0.165 → 0.0.166
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/database/mutation/candle/get/index.d.ts +2 -0
- package/src/backend/database/mutation/candle/get/index.js +29 -0
- package/src/backend/database/mutation/candle/get/type.d.ts +18 -0
- package/src/backend/database/mutation/candle/index.d.ts +2 -1
- package/src/backend/database/mutation/candle/index.js +2 -1
- package/src/backend/database/mutation/person/get/type.js +1 -0
- package/src/backend/database/mutation/person/index.d.ts +1 -1
- package/src/backend/database/mutation/person/index.js +1 -1
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.d.ts +2 -1
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.js +2 -1
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/type.d.ts +2 -2
- package/src/backend/message-broker/message-broker-refresh-cache/type.d.ts +4 -1
- package/src/backend/page/page-data/edit-candle/compose-edit-candle-page-data/index.d.ts +2 -0
- package/src/backend/page/page-data/edit-candle/compose-edit-candle-page-data/index.js +28 -0
- package/src/backend/page/page-data/edit-candle/compose-edit-candle-page-data/type.d.ts +9 -0
- package/src/backend/page/page-data/edit-candle/compose-edit-candle-page-data/type.js +1 -0
- package/src/backend/page/page-data/edit-candle/index.d.ts +2 -0
- package/src/backend/page/page-data/edit-candle/index.js +2 -0
- package/src/backend/page/page-data/edit-candle/type.d.ts +9 -0
- package/src/backend/page/page-data/edit-candle/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/edit-canlde/compose-edit-candle-page-server-data/index.d.ts +2 -0
- package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/index.js +22 -0
- package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/type.d.ts +13 -0
- package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/type.js +1 -0
- package/src/backend/server/server-data/edit-canlde/index.d.ts +2 -0
- package/src/backend/server/server-data/edit-canlde/index.js +2 -0
- package/src/backend/server/server-data/edit-canlde/type.d.ts +6 -0
- package/src/backend/server/server-data/edit-canlde/type.js +1 -0
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.d.ts +0 -2
- package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.js +0 -6
- /package/src/backend/database/mutation/candle/{get-candles → get}/type.js +0 -0
- /package/src/backend/database/mutation/candle/{get-candles → gets}/index.d.ts +0 -0
- /package/src/backend/database/mutation/candle/{get-candles → gets}/index.js +0 -0
- /package/src/backend/database/mutation/candle/{get-candles → gets}/type.d.ts +0 -0
- /package/src/backend/database/mutation/{person/get-person → candle/gets}/type.js +0 -0
- /package/src/backend/database/mutation/person/{get-person → get}/index.d.ts +0 -0
- /package/src/backend/database/mutation/person/{get-person → get}/index.js +0 -0
- /package/src/backend/database/mutation/person/{get-person → get}/type.d.ts +0 -0
package/package.json
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
import { customErrorWorker } from '@candlerip/shared3';
|
2
|
+
import { Types } from 'mongoose';
|
3
|
+
import { CANDLE_PERSON_AGGREGATE } from '@candlerip/shared3/backend/database';
|
4
|
+
import { getCandleDbModel } from '@candlerip/shared3/backend/database';
|
5
|
+
export const getCandle = async (props) => {
|
6
|
+
const { _id, withPerson } = props;
|
7
|
+
const { composeCustomError } = customErrorWorker(props);
|
8
|
+
const aggregates = [{ $match: { _id: new Types.ObjectId(_id) } }];
|
9
|
+
if (withPerson) {
|
10
|
+
aggregates.push(...CANDLE_PERSON_AGGREGATE);
|
11
|
+
}
|
12
|
+
let resp;
|
13
|
+
try {
|
14
|
+
resp = await getCandleDbModel().aggregate(aggregates);
|
15
|
+
}
|
16
|
+
catch (err) {
|
17
|
+
return {
|
18
|
+
customError: composeCustomError('Get candle failed', { err }),
|
19
|
+
};
|
20
|
+
}
|
21
|
+
if (!resp || resp.length === 0) {
|
22
|
+
return {
|
23
|
+
data: null,
|
24
|
+
};
|
25
|
+
}
|
26
|
+
return {
|
27
|
+
data: resp[0],
|
28
|
+
};
|
29
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Candle } from '../../../../../candle/index.js';
|
2
|
+
import { CustomError } from '../../../../../error/index.js';
|
3
|
+
import { Person } from '../../../../../person/index.js';
|
4
|
+
export type GetCandle = <T extends keyof TypeMap = never>(props: {
|
5
|
+
_id: string;
|
6
|
+
withPerson?: boolean;
|
7
|
+
}) => Promise<{
|
8
|
+
data: TypeMap[T] | null;
|
9
|
+
} | {
|
10
|
+
customError: CustomError;
|
11
|
+
}>;
|
12
|
+
type TypeMap = {
|
13
|
+
candle: Candle;
|
14
|
+
candleWithPerson: Candle & {
|
15
|
+
person: Person;
|
16
|
+
};
|
17
|
+
};
|
18
|
+
export {};
|
@@ -1 +1,2 @@
|
|
1
|
-
export * from './get
|
1
|
+
export * from './get/index.js';
|
2
|
+
export * from './gets/index.js';
|
@@ -1 +1,2 @@
|
|
1
|
-
export * from './get
|
1
|
+
export * from './get/index.js';
|
2
|
+
export * from './gets/index.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -1 +1 @@
|
|
1
|
-
export * from './get
|
1
|
+
export * from './get/index.js';
|
@@ -1 +1 @@
|
|
1
|
-
export * from './get
|
1
|
+
export * from './get/index.js';
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import { RefreshCache } from './type.js';
|
2
|
+
export declare const refreshCache: RefreshCache;
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import { MessageBrokerSingleton } from '../../message-broker/index.js';
|
2
|
+
export const refreshCache = (props) => MessageBrokerSingleton.sendMessage('cache-service:refresh-cache', props);
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import {
|
2
|
-
export type RefreshCache = (
|
1
|
+
import { MessageBrokerRefreshCache } from '../type.js';
|
2
|
+
export type RefreshCache = (props: MessageBrokerRefreshCache) => Promise<void>;
|
@@ -1,4 +1,7 @@
|
|
1
|
+
import { Page } from '../../../page/index.js';
|
1
2
|
import { CacheKey } from '../../cache/index.js';
|
2
3
|
export type MessageBrokerRefreshCache = {
|
3
|
-
cacheKeys
|
4
|
+
cacheKeys?: CacheKey[];
|
5
|
+
pageDictionaries?: Page[];
|
6
|
+
pageServerData?: Array<'candles-page' | 'persons-map-page'>;
|
4
7
|
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { composeCustomError } from '../../../../../error/index.js';
|
2
|
+
import { getCandle } from '../../../../database/index.js';
|
3
|
+
export const composeEditCandlePageData = async (candleId) => {
|
4
|
+
const resp = await getCandle({ _id: candleId, withPerson: true });
|
5
|
+
if ('customError' in resp) {
|
6
|
+
return resp;
|
7
|
+
}
|
8
|
+
const { data: candle } = resp;
|
9
|
+
if (!candle) {
|
10
|
+
return {
|
11
|
+
customError: composeCustomError('Candle not found'),
|
12
|
+
candleNotFoundError: true,
|
13
|
+
};
|
14
|
+
}
|
15
|
+
if (!candle.person) {
|
16
|
+
return {
|
17
|
+
customError: composeCustomError('Person not found'),
|
18
|
+
personNotFoundError: true,
|
19
|
+
};
|
20
|
+
}
|
21
|
+
return {
|
22
|
+
data: {
|
23
|
+
maintenance: {
|
24
|
+
candle,
|
25
|
+
},
|
26
|
+
},
|
27
|
+
};
|
28
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { CustomError } from '../../../../../error/index.js';
|
2
|
+
import { EditCandlePageData } from '../type.js';
|
3
|
+
export type ComposeEditCandlePageData = (candleId: string) => Promise<{
|
4
|
+
data: EditCandlePageData;
|
5
|
+
} | {
|
6
|
+
customError: CustomError;
|
7
|
+
candleNotFoundError?: boolean;
|
8
|
+
personNotFoundError?: boolean;
|
9
|
+
}>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/index.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
import { composeDictionary } from '../../../../dictionary/index.js';
|
2
|
+
import { composeEditCandlePageData } from '../../../../page/index.js';
|
3
|
+
export const composeEditCandlePageServerData = async (language, candleId, options) => {
|
4
|
+
const excludedTranslationIdOptions = options?.excludedTranslationIdOptions;
|
5
|
+
let resp;
|
6
|
+
resp = await composeEditCandlePageData(candleId);
|
7
|
+
if ('customError' in resp) {
|
8
|
+
return resp;
|
9
|
+
}
|
10
|
+
const pageData = resp.data;
|
11
|
+
resp = await composeDictionary('edit-candle-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/edit-canlde/compose-edit-candle-page-server-data/type.d.ts
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import { Language } from '../../../../../dictionary/index.js';
|
2
|
+
import { CustomError } from '../../../../../error/index.js';
|
3
|
+
import { ExcludedTranslationIdOptions } from '../../../../dictionary/index.js';
|
4
|
+
import { EditCandlePageServerData } from '../type.js';
|
5
|
+
export type ComposeEditCandlePageServerData = (language: Language, personId: string, options?: {
|
6
|
+
excludedTranslationIdOptions?: ExcludedTranslationIdOptions;
|
7
|
+
}) => Promise<{
|
8
|
+
data: EditCandlePageServerData;
|
9
|
+
} | {
|
10
|
+
customError: CustomError;
|
11
|
+
candleNotFoundError?: boolean;
|
12
|
+
personNotFoundError?: boolean;
|
13
|
+
}>;
|
package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/type.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -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
|