@candlerip/shared3 0.0.153 → 0.0.155

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/src/backend/api/api-response/index.d.ts +1 -0
  3. package/src/backend/api/api-response/index.js +1 -0
  4. package/src/backend/api/api-response/terms-and-conditions/compose-terms-and-conditions-page-api-response/index.d.ts +2 -0
  5. package/src/backend/api/api-response/terms-and-conditions/compose-terms-and-conditions-page-api-response/index.js +13 -0
  6. package/src/backend/api/api-response/terms-and-conditions/compose-terms-and-conditions-page-api-response/type.d.ts +12 -0
  7. package/src/backend/api/api-response/terms-and-conditions/compose-terms-and-conditions-page-api-response/type.js +1 -0
  8. package/src/backend/api/api-response/terms-and-conditions/index.d.ts +2 -0
  9. package/src/backend/api/api-response/terms-and-conditions/index.js +2 -0
  10. package/src/backend/api/api-response/terms-and-conditions/type.d.ts +4 -0
  11. package/src/backend/api/api-response/terms-and-conditions/type.js +1 -0
  12. package/src/backend/cache/cache/config.d.ts +2 -0
  13. package/src/backend/cache/cache/config.js +2 -0
  14. package/src/backend/cache/cache/type.d.ts +2 -1
  15. package/src/backend/dictionary/compose-dictionary/index.js +8 -1
  16. package/src/backend/dictionary/compose-dictionary/type.d.ts +2 -1
  17. package/src/backend/dictionary/index.d.ts +1 -0
  18. package/src/backend/dictionary/index.js +1 -0
  19. package/src/backend/dictionary/translation-id/excluded/compose-excluded-translation-ids/index.d.ts +2 -0
  20. package/src/backend/dictionary/translation-id/excluded/compose-excluded-translation-ids/index.js +16 -0
  21. package/src/backend/dictionary/translation-id/excluded/compose-excluded-translation-ids/type.d.ts +7 -0
  22. package/src/backend/dictionary/translation-id/excluded/compose-excluded-translation-ids/type.js +1 -0
  23. package/src/backend/dictionary/translation-id/excluded/config.d.ts +2 -0
  24. package/src/backend/dictionary/translation-id/excluded/config.js +3 -0
  25. package/src/backend/dictionary/translation-id/excluded/index.d.ts +2 -0
  26. package/src/backend/dictionary/translation-id/excluded/index.js +2 -0
  27. package/src/backend/dictionary/translation-id/excluded/type.d.ts +4 -0
  28. package/src/backend/dictionary/translation-id/excluded/type.js +1 -0
  29. package/src/backend/dictionary/translation-id/index.d.ts +1 -0
  30. package/src/backend/dictionary/translation-id/index.js +1 -0
  31. package/src/candle/burning-candle-state/type-guard.js +1 -3
  32. package/src/page/index.d.ts +1 -0
  33. package/src/page/index.js +1 -0
  34. package/src/page/page-menu/config.d.ts +1 -0
  35. package/src/page/page-menu/config.js +12 -0
  36. package/src/page/page-menu/index.d.ts +3 -0
  37. package/src/page/page-menu/index.js +3 -0
  38. package/src/page/page-menu/type-guard.d.ts +2 -0
  39. package/src/page/page-menu/type-guard.js +2 -0
  40. package/src/page/page-menu/type.d.ts +2 -0
  41. package/src/page/page-menu/type.js +1 -0
  42. package/src/type/boolean/index.d.ts +1 -0
  43. package/src/type/boolean/index.js +1 -0
  44. package/src/type/boolean/type-guard.d.ts +1 -0
  45. package/src/type/boolean/type-guard.js +1 -0
  46. package/src/type/index.d.ts +1 -0
  47. package/src/type/index.js +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.153",
3
+ "version": "0.0.155",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
@@ -1,2 +1,3 @@
1
1
  export * from './candles/index.js';
2
2
  export * from './persons-map/index.js';
3
+ export * from './terms-and-conditions/index.js';
@@ -1,2 +1,3 @@
1
1
  export * from './candles/index.js';
2
2
  export * from './persons-map/index.js';
3
+ export * from './terms-and-conditions/index.js';
@@ -0,0 +1,2 @@
1
+ import { ComposeTermsAndConditionsPageApiResponse } from './type.js';
2
+ export declare const composeTermsAndConditionsPageApiResponse: ComposeTermsAndConditionsPageApiResponse;
@@ -0,0 +1,13 @@
1
+ import { composeDictionary } from '../../../../dictionary/index.js';
2
+ export const composeTermsAndConditionsPageApiResponse = async ({ excludedIdOptions, language }) => {
3
+ const resp = await composeDictionary('terms-and-conditions-page', language, excludedIdOptions);
4
+ if ('customError' in resp) {
5
+ return resp;
6
+ }
7
+ const dictionary = resp.data;
8
+ return {
9
+ data: {
10
+ dictionary,
11
+ },
12
+ };
13
+ };
@@ -0,0 +1,12 @@
1
+ import { Language } from '../../../../../dictionary/index.js';
2
+ import { CustomError } from '../../../../../error/index.js';
3
+ import { ExcludedIdOptions } from '../../../../dictionary/index.js';
4
+ import { TermsAndConditionsPageApiResponse } from '../type.js';
5
+ export type ComposeTermsAndConditionsPageApiResponse = (props: {
6
+ excludedIdOptions: ExcludedIdOptions;
7
+ language: Language;
8
+ }) => Promise<{
9
+ data: TermsAndConditionsPageApiResponse;
10
+ } | {
11
+ customError: CustomError;
12
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './compose-terms-and-conditions-page-api-response/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-terms-and-conditions-page-api-response/index.js';
2
+ export * from './type.js';
@@ -0,0 +1,4 @@
1
+ import { Dictionary } from '../../../../dictionary/index.js';
2
+ export interface TermsAndConditionsPageApiResponse {
3
+ dictionary: Dictionary;
4
+ }
@@ -33,4 +33,6 @@ export declare const CACHE: {
33
33
  readonly 'persons-map-page-dictionary-hu': "Dictionary";
34
34
  readonly 'terms-and-conditions-page-dictionary-en': "Dictionary";
35
35
  readonly 'terms-and-conditions-page-dictionary-hu': "Dictionary";
36
+ readonly 'terms-and-conditions-page-api-response-en': "TermsAndConditionsPageApiResponse";
37
+ readonly 'terms-and-conditions-page-api-response-hu': "TermsAndConditionsPageApiResponse";
36
38
  };
@@ -33,4 +33,6 @@ export const CACHE = {
33
33
  'persons-map-page-dictionary-hu': 'Dictionary',
34
34
  'terms-and-conditions-page-dictionary-en': 'Dictionary',
35
35
  'terms-and-conditions-page-dictionary-hu': 'Dictionary',
36
+ 'terms-and-conditions-page-api-response-en': 'TermsAndConditionsPageApiResponse',
37
+ 'terms-and-conditions-page-api-response-hu': 'TermsAndConditionsPageApiResponse',
36
38
  };
@@ -1,5 +1,5 @@
1
1
  import { Dictionary } from '../../../dictionary/index.js';
2
- import { CandlesPageApiResponse, PersonsMapPageApiResponse } from '../../api/index.js';
2
+ import { CandlesPageApiResponse, PersonsMapPageApiResponse, TermsAndConditionsPageApiResponse } 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]];
@@ -8,5 +8,6 @@ interface TypeMap {
8
8
  CandlesPageApiResponse: CandlesPageApiResponse;
9
9
  Dictionary: Dictionary;
10
10
  PersonsMapPageApiResponse: PersonsMapPageApiResponse;
11
+ TermsAndConditionsPageApiResponse: TermsAndConditionsPageApiResponse;
11
12
  }
12
13
  export {};
@@ -1,3 +1,10 @@
1
1
  import { DICTIONARY_CONFIG } from '../../../dictionary/index.js';
2
2
  import { getTranslationsAsDictionary } from '../../database/mutation/translation/index.js';
3
- export const composeDictionary = async (page, language) => getTranslationsAsDictionary(language, [...DICTIONARY_CONFIG[page].translationIds]);
3
+ import { composeExcludedTranslationIds } from '../translation-id/index.js';
4
+ export const composeDictionary = async (page, language, options) => {
5
+ let translationIds = [...DICTIONARY_CONFIG[page].translationIds];
6
+ const excludedIds = composeExcludedTranslationIds(page, options);
7
+ translationIds = translationIds.filter((it) => !excludedIds.includes(it));
8
+ const resp = await getTranslationsAsDictionary(language, translationIds);
9
+ return resp;
10
+ };
@@ -1,7 +1,8 @@
1
1
  import { Dictionary, Language } from '../../../dictionary/index.js';
2
2
  import { CustomError } from '../../../error/index.js';
3
3
  import { Page } from '../../../page/index.js';
4
- export type ComposeDictionary = (page: Page, language: Language) => Promise<{
4
+ import { ExcludedIdOptions } from '../translation-id/index.js';
5
+ export type ComposeDictionary = (page: Page, language: Language, options?: ExcludedIdOptions) => Promise<{
5
6
  data: Dictionary;
6
7
  } | {
7
8
  customError: CustomError;
@@ -1 +1,2 @@
1
1
  export * from './compose-dictionary/index.js';
2
+ export * from './translation-id/index.js';
@@ -1 +1,2 @@
1
1
  export * from './compose-dictionary/index.js';
2
+ export * from './translation-id/index.js';
@@ -0,0 +1,2 @@
1
+ import { ComposeExcludedTranslationIds } from './type.js';
2
+ export declare const composeExcludedTranslationIds: ComposeExcludedTranslationIds;
@@ -0,0 +1,16 @@
1
+ import { isPageMenu } from '../../../../../page/index.js';
2
+ import { EXCLUDED_TRANSLATION_IDS } from '../config.js';
3
+ export const composeExcludedTranslationIds = (page, options) => {
4
+ let excludedIds = [];
5
+ if (options) {
6
+ const { isAuthenticated, isCookieConsent } = options;
7
+ excludedIds.push(isAuthenticated ? 'login' : 'logout');
8
+ if (isCookieConsent) {
9
+ excludedIds = excludedIds.concat(EXCLUDED_TRANSLATION_IDS.cookieConsent);
10
+ }
11
+ }
12
+ if (isPageMenu(page)) {
13
+ excludedIds.push(`pageMenu.${page}`);
14
+ }
15
+ return excludedIds;
16
+ };
@@ -0,0 +1,7 @@
1
+ import { TranslationId } from '../../../../../dictionary/index.js';
2
+ import { Page } from '../../../../../page/index.js';
3
+ export type ComposeExcludedTranslationIds = (page: Page, options?: ExcludedIdOptions) => TranslationId[];
4
+ export type ExcludedIdOptions = {
5
+ isAuthenticated: boolean;
6
+ isCookieConsent: boolean;
7
+ };
@@ -0,0 +1,2 @@
1
+ import { ExcludedTranslationIds } from './type.js';
2
+ export declare const EXCLUDED_TRANSLATION_IDS: ExcludedTranslationIds;
@@ -0,0 +1,3 @@
1
+ export const EXCLUDED_TRANSLATION_IDS = {
2
+ cookieConsent: ['cookieConsentForm.description', 'cookieConsentForm.languageFormDescription', 'cookieConsentForm.title'],
3
+ };
@@ -0,0 +1,2 @@
1
+ export * from './compose-excluded-translation-ids/index.js';
2
+ export * from './compose-excluded-translation-ids/type.js';
@@ -0,0 +1,2 @@
1
+ export * from './compose-excluded-translation-ids/index.js';
2
+ export * from './compose-excluded-translation-ids/type.js';
@@ -0,0 +1,4 @@
1
+ import { TranslationId } from '../../../../dictionary/index.js';
2
+ export type ExcludedTranslationIds = {
3
+ [key in 'cookieConsent']: TranslationId[];
4
+ };
@@ -0,0 +1 @@
1
+ export * from './excluded/index.js';
@@ -0,0 +1 @@
1
+ export * from './excluded/index.js';
@@ -1,4 +1,2 @@
1
1
  import { BURNING_CANDLE_STATES } from './config.js';
2
- export const isBurningCandleState = (data) => {
3
- return BURNING_CANDLE_STATES.some((it) => data === it);
4
- };
2
+ export const isBurningCandleState = (data) => BURNING_CANDLE_STATES.some((it) => data === it);
@@ -1,3 +1,4 @@
1
1
  export * from './config.js';
2
+ export * from './page-menu/index.js';
2
3
  export * from './type.js';
3
4
  export * from './type-guard.js';
package/src/page/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './config.js';
2
+ export * from './page-menu/index.js';
2
3
  export * from './type.js';
3
4
  export * from './type-guard.js';
@@ -0,0 +1 @@
1
+ export declare const PAGE_MENUS: readonly ["persons-page", "add-person-page", "persons-map-page", "candles-page", "contact-page", "cookie-policy-page", "help-page", "terms-and-conditions-page"];
@@ -0,0 +1,12 @@
1
+ export const PAGE_MENUS = [
2
+ 'persons-page',
3
+ 'add-person-page',
4
+ 'persons-map-page',
5
+ 'candles-page',
6
+ 'contact-page',
7
+ 'cookie-policy-page',
8
+ 'help-page',
9
+ 'terms-and-conditions-page',
10
+ ];
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ const CHECK = PAGE_MENUS;
@@ -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 { PageMenu } from './type.js';
2
+ export declare const isPageMenu: (data?: unknown) => data is PageMenu;
@@ -0,0 +1,2 @@
1
+ import { PAGE_MENUS } from './config.js';
2
+ export const isPageMenu = (data) => PAGE_MENUS.some((it) => data === it);
@@ -0,0 +1,2 @@
1
+ import { PAGE_MENUS } from './config.js';
2
+ export type PageMenu = (typeof PAGE_MENUS)[number];
@@ -0,0 +1 @@
1
+ export {};
@@ -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 isBoolean: (data?: unknown) => data is boolean;
@@ -0,0 +1 @@
1
+ export const isBoolean = (data) => typeof data === 'boolean';
@@ -1,4 +1,5 @@
1
1
  export * from './array/index.js';
2
+ export * from './boolean/index.js';
2
3
  export * from './number/index.js';
3
4
  export * from './object/index.js';
4
5
  export * from './readonly/index.js';
package/src/type/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './array/index.js';
2
+ export * from './boolean/index.js';
2
3
  export * from './number/index.js';
3
4
  export * from './object/index.js';
4
5
  export * from './readonly/index.js';