@candlerip/shared3 0.0.164 → 0.0.166

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. package/package.json +1 -1
  2. package/src/backend/database/model/contact/contact-db-schema.d.ts +42 -0
  3. package/src/backend/database/model/contact/contact-db-schema.js +10 -0
  4. package/src/backend/database/model/contact/get-contact-db-model.d.ts +2 -0
  5. package/src/backend/database/model/contact/get-contact-db-model.js +3 -0
  6. package/src/backend/database/model/contact/index.d.ts +2 -0
  7. package/src/backend/database/model/contact/index.js +2 -0
  8. package/src/backend/database/model/index.d.ts +1 -0
  9. package/src/backend/database/model/index.js +1 -0
  10. package/src/backend/database/mutation/candle/get/index.d.ts +2 -0
  11. package/src/backend/database/mutation/candle/get/index.js +29 -0
  12. package/src/backend/database/mutation/candle/get/type.d.ts +18 -0
  13. package/src/backend/database/mutation/candle/index.d.ts +2 -1
  14. package/src/backend/database/mutation/candle/index.js +2 -1
  15. package/src/backend/database/mutation/contact/create-contact/index.d.ts +2 -0
  16. package/src/backend/database/mutation/contact/create-contact/index.js +17 -0
  17. package/src/backend/database/mutation/contact/create-contact/type.d.ts +6 -0
  18. package/src/backend/database/mutation/contact/create-contact/type.js +1 -0
  19. package/src/backend/database/mutation/contact/index.d.ts +1 -0
  20. package/src/backend/database/mutation/contact/index.js +1 -0
  21. package/src/backend/database/mutation/index.d.ts +1 -0
  22. package/src/backend/database/mutation/index.js +1 -0
  23. package/src/backend/database/mutation/person/get/type.js +1 -0
  24. package/src/backend/database/mutation/person/index.d.ts +1 -1
  25. package/src/backend/database/mutation/person/index.js +1 -1
  26. package/src/backend/dictionary/translation-id/excluded/compose-excluded-translation-ids/index.js +4 -1
  27. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.d.ts +2 -1
  28. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.js +2 -1
  29. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/type.d.ts +2 -2
  30. package/src/backend/message-broker/message-broker-refresh-cache/type.d.ts +4 -1
  31. package/src/backend/page/page-data/edit-candle/compose-edit-candle-page-data/index.d.ts +2 -0
  32. package/src/backend/page/page-data/edit-candle/compose-edit-candle-page-data/index.js +28 -0
  33. package/src/backend/page/page-data/edit-candle/compose-edit-candle-page-data/type.d.ts +9 -0
  34. package/src/backend/page/page-data/edit-candle/compose-edit-candle-page-data/type.js +1 -0
  35. package/src/backend/page/page-data/edit-candle/index.d.ts +2 -0
  36. package/src/backend/page/page-data/edit-candle/index.js +2 -0
  37. package/src/backend/page/page-data/edit-candle/type.d.ts +9 -0
  38. package/src/backend/page/page-data/edit-candle/type.js +1 -0
  39. package/src/backend/page/page-data/index.d.ts +1 -0
  40. package/src/backend/page/page-data/index.js +1 -0
  41. package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/index.d.ts +2 -0
  42. package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/index.js +22 -0
  43. package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/type.d.ts +13 -0
  44. package/src/backend/server/server-data/edit-canlde/compose-edit-candle-page-server-data/type.js +1 -0
  45. package/src/backend/server/server-data/edit-canlde/index.d.ts +2 -0
  46. package/src/backend/server/server-data/edit-canlde/index.js +2 -0
  47. package/src/backend/server/server-data/edit-canlde/type.d.ts +6 -0
  48. package/src/backend/server/server-data/edit-canlde/type.js +1 -0
  49. package/src/backend/server/server-data/persons-map/compose-persons-map-page-server-data/index.js +7 -7
  50. package/src/backend/server/server-data/persons-map/compose-persons-map-page-server-data/type.d.ts +3 -2
  51. package/src/contact/index.d.ts +1 -0
  52. package/src/contact/index.js +1 -0
  53. package/src/contact/type.d.ts +9 -0
  54. package/src/contact/type.js +1 -0
  55. package/src/index.d.ts +1 -0
  56. package/src/index.js +1 -0
  57. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.d.ts +0 -2
  58. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.js +0 -6
  59. /package/src/backend/database/mutation/candle/{get-candles → get}/type.js +0 -0
  60. /package/src/backend/database/mutation/candle/{get-candles → gets}/index.d.ts +0 -0
  61. /package/src/backend/database/mutation/candle/{get-candles → gets}/index.js +0 -0
  62. /package/src/backend/database/mutation/candle/{get-candles → gets}/type.d.ts +0 -0
  63. /package/src/backend/database/mutation/{person/get-person → candle/gets}/type.js +0 -0
  64. /package/src/backend/database/mutation/person/{get-person → get}/index.d.ts +0 -0
  65. /package/src/backend/database/mutation/person/{get-person → get}/index.js +0 -0
  66. /package/src/backend/database/mutation/person/{get-person → get}/type.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.164",
3
+ "version": "0.0.166",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
@@ -0,0 +1,42 @@
1
+ import * as mongoose from 'mongoose';
2
+ export declare const ContactDbSchema: 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
+ email?: string | null | undefined;
10
+ message?: string | null | undefined;
11
+ name?: string | null | undefined;
12
+ subject?: string | null | undefined;
13
+ date?: NativeDate | null | undefined;
14
+ id?: number | null | undefined;
15
+ logId?: string | null | undefined;
16
+ }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
17
+ createdAt: NativeDate;
18
+ updatedAt: NativeDate;
19
+ } & {
20
+ email?: string | null | undefined;
21
+ message?: string | null | undefined;
22
+ name?: string | null | undefined;
23
+ subject?: string | null | undefined;
24
+ date?: NativeDate | null | undefined;
25
+ id?: number | null | undefined;
26
+ logId?: string | null | undefined;
27
+ }>> & mongoose.FlatRecord<{
28
+ createdAt: NativeDate;
29
+ updatedAt: NativeDate;
30
+ } & {
31
+ email?: string | null | undefined;
32
+ message?: string | null | undefined;
33
+ name?: string | null | undefined;
34
+ subject?: string | null | undefined;
35
+ date?: NativeDate | null | undefined;
36
+ id?: number | null | undefined;
37
+ logId?: string | null | undefined;
38
+ }> & {
39
+ _id: mongoose.Types.ObjectId;
40
+ } & {
41
+ __v: number;
42
+ }>;
@@ -0,0 +1,10 @@
1
+ import * as mongoose from 'mongoose';
2
+ export const ContactDbSchema = new mongoose.Schema({
3
+ id: { type: Number },
4
+ email: { type: String },
5
+ message: { type: String },
6
+ date: { type: Date },
7
+ logId: { type: String },
8
+ name: { type: String },
9
+ subject: { type: String },
10
+ }, { timestamps: true, versionKey: false });
@@ -0,0 +1,2 @@
1
+ import * as mongoose from 'mongoose';
2
+ export declare const getContactDbModel: () => mongoose.Model<any, {}, {}, {}, any, any>;
@@ -0,0 +1,3 @@
1
+ import * as mongoose from 'mongoose';
2
+ import { ContactDbSchema } from './contact-db-schema.js';
3
+ export const getContactDbModel = () => mongoose.models?.contacts || mongoose.model('contacts', ContactDbSchema);
@@ -0,0 +1,2 @@
1
+ export * from './contact-db-schema.js';
2
+ export * from './get-contact-db-model.js';
@@ -0,0 +1,2 @@
1
+ export * from './contact-db-schema.js';
2
+ export * from './get-contact-db-model.js';
@@ -1,4 +1,5 @@
1
1
  export * from './candle/index.js';
2
+ export * from './contact/index.js';
2
3
  export * from './country/index.js';
3
4
  export * from './error-log/index.js';
4
5
  export * from './person/index.js';
@@ -1,4 +1,5 @@
1
1
  export * from './candle/index.js';
2
+ export * from './contact/index.js';
2
3
  export * from './country/index.js';
3
4
  export * from './error-log/index.js';
4
5
  export * from './person/index.js';
@@ -0,0 +1,2 @@
1
+ import { GetCandle } from './type.js';
2
+ export declare const getCandle: GetCandle;
@@ -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-candles/index.js';
1
+ export * from './get/index.js';
2
+ export * from './gets/index.js';
@@ -1 +1,2 @@
1
- export * from './get-candles/index.js';
1
+ export * from './get/index.js';
2
+ export * from './gets/index.js';
@@ -0,0 +1,2 @@
1
+ import { CreateContact } from './type.js';
2
+ export declare const createContact: CreateContact;
@@ -0,0 +1,17 @@
1
+ import { customErrorWorker } from '@candlerip/shared3';
2
+ import { getContactDbModel } from '../../../model/index.js';
3
+ export const createContact = async (contact) => {
4
+ let data;
5
+ const { composeCustomError } = customErrorWorker({ contact });
6
+ try {
7
+ data = await getContactDbModel().create(contact);
8
+ }
9
+ catch (err) {
10
+ return {
11
+ customError: composeCustomError('Create contact failed', { err }),
12
+ };
13
+ }
14
+ return {
15
+ data,
16
+ };
17
+ };
@@ -0,0 +1,6 @@
1
+ import { Contact, CustomError } from '@candlerip/shared3';
2
+ export type CreateContact = (contact: Omit<Contact, '_id' | 'createdAt' | 'updatedAt'>) => Promise<{
3
+ data: Contact;
4
+ } | {
5
+ customError: CustomError;
6
+ }>;
@@ -0,0 +1 @@
1
+ export * from './create-contact/index.js';
@@ -0,0 +1 @@
1
+ export * from './create-contact/index.js';
@@ -1,4 +1,5 @@
1
1
  export * from './candle/index.js';
2
+ export * from './contact/index.js';
2
3
  export * from './country/index.js';
3
4
  export * from './error-log/index.js';
4
5
  export * from './person/index.js';
@@ -1,4 +1,5 @@
1
1
  export * from './candle/index.js';
2
+ export * from './contact/index.js';
2
3
  export * from './country/index.js';
3
4
  export * from './error-log/index.js';
4
5
  export * from './person/index.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- export * from './get-person/index.js';
1
+ export * from './get/index.js';
@@ -1 +1 @@
1
- export * from './get-person/index.js';
1
+ export * from './get/index.js';
@@ -1,10 +1,13 @@
1
1
  import { isPageMenu } from '../../../../../page/index.js';
2
+ import { isUndefined } from '../../../../../type/index.js';
2
3
  import { EXCLUDED_TRANSLATION_IDS } from '../config.js';
3
4
  export const composeExcludedTranslationIds = (page, options) => {
4
5
  let excludedIds = [];
5
6
  if (options) {
6
7
  const { isAuthenticated, isCookieConsent } = options;
7
- excludedIds.push(isAuthenticated ? 'login' : 'logout');
8
+ if (!isUndefined(isAuthenticated)) {
9
+ excludedIds.push(isAuthenticated ? 'login' : 'logout');
10
+ }
8
11
  if (isCookieConsent) {
9
12
  excludedIds = excludedIds.concat(EXCLUDED_TRANSLATION_IDS.cookieConsent);
10
13
  }
@@ -1 +1,2 @@
1
- export * from './util.js';
1
+ import { RefreshCache } from './type.js';
2
+ export declare const refreshCache: RefreshCache;
@@ -1 +1,2 @@
1
- export * from './util.js';
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 { CacheKey } from '../../../cache/index.js';
2
- export type RefreshCache = (cacheKeys?: CacheKey[]) => Promise<void>;
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: CacheKey[];
4
+ cacheKeys?: CacheKey[];
5
+ pageDictionaries?: Page[];
6
+ pageServerData?: Array<'candles-page' | 'persons-map-page'>;
4
7
  };
@@ -0,0 +1,2 @@
1
+ import { ComposeEditCandlePageData } from './type.js';
2
+ export declare const composeEditCandlePageData: ComposeEditCandlePageData;
@@ -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,2 @@
1
+ export * from './compose-edit-candle-page-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-edit-candle-page-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,9 @@
1
+ import { Candle } from '../../../../candle/index.js';
2
+ import { Person } from '../../../../person/index.js';
3
+ export interface EditCandlePageData {
4
+ maintenance: {
5
+ candle: Candle & {
6
+ person: Person;
7
+ };
8
+ };
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
1
  export * from './candles/index.js';
2
+ export * from './edit-candle/index.js';
2
3
  export * from './light-candle/index.js';
3
4
  export * from './persons-map/index.js';
@@ -1,3 +1,4 @@
1
1
  export * from './candles/index.js';
2
+ export * from './edit-candle/index.js';
2
3
  export * from './light-candle/index.js';
3
4
  export * from './persons-map/index.js';
@@ -0,0 +1,2 @@
1
+ import { ComposeEditCandlePageServerData } from './type.js';
2
+ export declare const composeEditCandlePageServerData: ComposeEditCandlePageServerData;
@@ -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
+ };
@@ -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
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './compose-edit-candle-page-server-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-edit-candle-page-server-data/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,6 @@
1
+ import { Dictionary } from '../../../../dictionary/index.js';
2
+ import { EditCandlePageData } from '../../../page/index.js';
3
+ export interface EditCandlePageServerData {
4
+ dictionary: Dictionary;
5
+ pageData: EditCandlePageData;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,18 +1,18 @@
1
- import { DICTIONARY_CONFIG } from '../../../../../dictionary/index.js';
2
- import { getTranslationsAsDictionary } from '../../../../database/index.js';
1
+ import { composeDictionary } from '../../../../dictionary/index.js';
3
2
  import { composePersonsMapPageData } from '../../../../page/index.js';
4
- export const composePersonsMapPageServerData = async ({ language }) => {
3
+ export const composePersonsMapPageServerData = async (language, options) => {
4
+ const excludedTranslationIdOptions = options?.excludedTranslationIdOptions;
5
5
  let resp;
6
- resp = await getTranslationsAsDictionary(language, DICTIONARY_CONFIG['persons-map-page'].translationIds);
6
+ resp = await composePersonsMapPageData();
7
7
  if ('customError' in resp) {
8
8
  return resp;
9
9
  }
10
- const dictionary = resp.data;
11
- resp = await composePersonsMapPageData();
10
+ const pageData = resp.data;
11
+ resp = await composeDictionary('persons-map-page', language, { excludedTranslationIdOptions });
12
12
  if ('customError' in resp) {
13
13
  return resp;
14
14
  }
15
- const pageData = resp.data;
15
+ const dictionary = resp.data;
16
16
  return {
17
17
  data: {
18
18
  dictionary,
@@ -1,8 +1,9 @@
1
1
  import { Language } from '../../../../../dictionary/index.js';
2
2
  import { CustomError } from '../../../../../error/index.js';
3
+ import { ExcludedTranslationIdOptions } from '../../../../dictionary/index.js';
3
4
  import { PersonsMapPageServerData } from '../type.js';
4
- export type ComposePersonsMapPageServerData = (props: {
5
- language: Language;
5
+ export type ComposePersonsMapPageServerData = (language: Language, options?: {
6
+ excludedTranslationIdOptions?: ExcludedTranslationIdOptions;
6
7
  }) => Promise<{
7
8
  data: PersonsMapPageServerData;
8
9
  } | {
@@ -0,0 +1 @@
1
+ export * from './type.js';
@@ -0,0 +1 @@
1
+ export * from './type.js';
@@ -0,0 +1,9 @@
1
+ export interface Contact {
2
+ _id: string;
3
+ email: string;
4
+ message: string;
5
+ name?: string;
6
+ subject?: string;
7
+ createdAt: Date;
8
+ updatedAt: Date;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/src/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './candle/index.js';
2
+ export * from './contact/index.js';
2
3
  export * from './dictionary/index.js';
3
4
  export * from './environment/index.js';
4
5
  export * from './error/index.js';
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './candle/index.js';
2
+ export * from './contact/index.js';
2
3
  export * from './dictionary/index.js';
3
4
  export * from './environment/index.js';
4
5
  export * from './error/index.js';
@@ -1,2 +0,0 @@
1
- import { RefreshCache } from './type.js';
2
- export declare const refreshCache: RefreshCache;
@@ -1,6 +0,0 @@
1
- import { MessageBrokerSingleton } from '../../message-broker/index.js';
2
- export const refreshCache = (cacheKeys) => MessageBrokerSingleton.sendMessage('cache-service:refresh-cache', cacheKeys
3
- ? {
4
- cacheKeys,
5
- }
6
- : null);