@candlerip/shared3 0.0.63 → 0.0.65

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/src/environment/environment-variable/configs/index.d.ts +1 -0
  3. package/src/environment/environment-variable/configs/index.js +1 -0
  4. package/src/environment/environment-variables/configs/index.d.ts +1 -1
  5. package/src/environment/environment-variables/configs/index.js +1 -1
  6. package/src/error/custom-error/workers/custom-error-worker/index.js +3 -0
  7. package/src/page/page/configs/index.d.ts +1 -1
  8. package/src/page/page/configs/index.js +1 -1
  9. package/src/ssr/server-side-props/domains/help-page-server-side-props/index.d.ts +6 -0
  10. package/src/ssr/server-side-props/domains/help-page-server-side-props/index.js +1 -0
  11. package/src/ssr/server-side-props/domains/index.d.ts +2 -0
  12. package/src/ssr/server-side-props/domains/index.js +2 -0
  13. package/src/ssr/server-side-props/domains/server-side-props/index.d.ts +3 -1
  14. package/src/ssr/server-side-props/domains/terms-and-conditions-page-server-side-props/index.d.ts +6 -0
  15. package/src/ssr/server-side-props/domains/terms-and-conditions-page-server-side-props/index.js +1 -0
  16. package/src/type/index.d.ts +1 -0
  17. package/src/type/index.js +1 -0
  18. package/src/type/object/index.d.ts +1 -0
  19. package/src/type/object/index.js +1 -0
  20. package/src/type/object/utils/add-prefix-to-object-props/index.d.ts +2 -0
  21. package/src/type/object/utils/add-prefix-to-object-props/index.js +1 -0
  22. package/src/type/object/utils/add-prefix-to-object-props/types.d.ts +1 -0
  23. package/src/type/object/utils/add-prefix-to-object-props/types.js +1 -0
  24. package/src/type/object/utils/index.d.ts +1 -0
  25. package/src/type/object/utils/index.js +1 -0
  26. package/src/type/string/index.d.ts +1 -0
  27. package/src/type/string/index.js +1 -0
  28. package/src/type/string/validators/index.d.ts +1 -0
  29. package/src/type/string/validators/index.js +1 -0
  30. package/src/type/string/validators/validate-string/index.d.ts +2 -0
  31. package/src/type/string/validators/validate-string/index.js +19 -0
  32. package/src/type/string/validators/validate-string/types.d.ts +6 -0
  33. package/src/type/string/validators/validate-string/types.js +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -4,6 +4,7 @@ export declare const ENVIRONMENT_VARIABLE: {
4
4
  readonly APP_PORT: "number";
5
5
  readonly AUTHENTICATION_AUDIENCE: "string";
6
6
  readonly AUTHENTICATION_DOMAIN: "string";
7
+ readonly BACKEND_URL: "string";
7
8
  readonly CACHE_ENABLED: "boolean";
8
9
  readonly CACHE_SERVICE_PORT: "number";
9
10
  readonly DATABASE_URL: "string";
@@ -4,6 +4,7 @@ export const ENVIRONMENT_VARIABLE = {
4
4
  APP_PORT: 'number',
5
5
  AUTHENTICATION_AUDIENCE: 'string',
6
6
  AUTHENTICATION_DOMAIN: 'string',
7
+ BACKEND_URL: 'string',
7
8
  CACHE_ENABLED: 'boolean',
8
9
  CACHE_SERVICE_PORT: 'number',
9
10
  DATABASE_URL: 'string',
@@ -1,5 +1,5 @@
1
1
  export declare const ENVIRONMENT_VARIABLES: {
2
- readonly app: readonly ["APP_PORT", "DATABASE_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL", "S3_IMAGES_BUCKET_NAME"];
2
+ readonly app: readonly ["APP_PORT", "BACKEND_URL", "DATABASE_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL", "S3_IMAGES_BUCKET_NAME"];
3
3
  readonly 'cache-service': readonly ["CACHE_ENABLED", "CACHE_SERVICE_PORT", "DATABASE_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL"];
4
4
  readonly images: readonly ["NODE_ENV", "S3_IMAGES_BUCKET_NAME"];
5
5
  readonly 'images-init': readonly ["FRONTEND_URL", "NODE_ENV", "S3_IMAGES_BUCKET_NAME"];
@@ -1,5 +1,5 @@
1
1
  export const ENVIRONMENT_VARIABLES = {
2
- app: ['APP_PORT', 'DATABASE_URL', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL', 'S3_IMAGES_BUCKET_NAME'],
2
+ app: ['APP_PORT', 'BACKEND_URL', 'DATABASE_URL', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL', 'S3_IMAGES_BUCKET_NAME'],
3
3
  'cache-service': ['CACHE_ENABLED', 'CACHE_SERVICE_PORT', 'DATABASE_URL', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL'],
4
4
  images: ['NODE_ENV', 'S3_IMAGES_BUCKET_NAME'],
5
5
  'images-init': ['FRONTEND_URL', 'NODE_ENV', 'S3_IMAGES_BUCKET_NAME'],
@@ -2,6 +2,9 @@ import { ProjectSingleton } from '../../../../project/index.js';
2
2
  export const customErrorWorker = (info) => {
3
3
  let _info = info;
4
4
  const serializeInfo = (info) => {
5
+ if (!info) {
6
+ return;
7
+ }
5
8
  if (info?.err) {
6
9
  info.err = JSON.stringify(info.err);
7
10
  }
@@ -1 +1 @@
1
- export declare const PAGES: readonly ["homePage", "contactPage"];
1
+ export declare const PAGES: readonly ["homePage", "contactPage", "helpPage", "termsAndConditionsPage"];
@@ -1 +1 @@
1
- export const PAGES = ['homePage', 'contactPage'];
1
+ export const PAGES = ['homePage', 'contactPage', 'helpPage', 'termsAndConditionsPage'];
@@ -0,0 +1,6 @@
1
+ import { Language } from '../../../../dictionary/index.js';
2
+ import { HelpPageDictionary } from '../../../../dictionary/dictionary-id/index.js';
3
+ export interface HelpPageServerSideProps {
4
+ dictionary: HelpPageDictionary;
5
+ language: Language;
6
+ }
@@ -1,2 +1,4 @@
1
1
  export * from './contact-page-server-side-props/index.js';
2
+ export * from './help-page-server-side-props/index.js';
2
3
  export * from './server-side-props/index.js';
4
+ export * from './terms-and-conditions-page-server-side-props/index.js';
@@ -1,2 +1,4 @@
1
1
  export * from './contact-page-server-side-props/index.js';
2
+ export * from './help-page-server-side-props/index.js';
2
3
  export * from './server-side-props/index.js';
4
+ export * from './terms-and-conditions-page-server-side-props/index.js';
@@ -1,2 +1,4 @@
1
1
  import { ContactPageServerSideProps } from '../contact-page-server-side-props/index.js';
2
- export type ServerSideProps = ContactPageServerSideProps;
2
+ import { HelpPageServerSideProps } from '../help-page-server-side-props/index.js';
3
+ import { TermsAndConditionsPageServerSideProps } from '../terms-and-conditions-page-server-side-props/index.js';
4
+ export type ServerSideProps = ContactPageServerSideProps | HelpPageServerSideProps | TermsAndConditionsPageServerSideProps;
@@ -0,0 +1,6 @@
1
+ import { Language } from '../../../../dictionary/index.js';
2
+ import { TermsAndConditionsPageDictionary } from '../../../../dictionary/dictionary-id/index.js';
3
+ export interface TermsAndConditionsPageServerSideProps {
4
+ dictionary: TermsAndConditionsPageDictionary;
5
+ language: Language;
6
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './array/index.js';
2
+ export * from './object/index.js';
2
3
  export * from './string/index.js';
3
4
  export * from './type/index.js';
4
5
  export * from './type-guards/index.js';
package/src/type/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './array/index.js';
2
+ export * from './object/index.js';
2
3
  export * from './string/index.js';
3
4
  export * from './type/index.js';
4
5
  export * from './type-guards/index.js';
@@ -0,0 +1 @@
1
+ export * from './utils/index.js';
@@ -0,0 +1 @@
1
+ export * from './utils/index.js';
@@ -0,0 +1,2 @@
1
+ import { AddPrefixToObjectProps } from './types.js';
2
+ export declare const addPrefixToObjectProps: AddPrefixToObjectProps;
@@ -0,0 +1 @@
1
+ export const addPrefixToObjectProps = (obj, prefix) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [`${prefix}-${key}`, value]));
@@ -0,0 +1 @@
1
+ export type AddPrefixToObjectProps = (obj: Record<string, string>, prefix: string) => Record<string, string>;
@@ -0,0 +1 @@
1
+ export * from './add-prefix-to-object-props/index.js';
@@ -0,0 +1 @@
1
+ export * from './add-prefix-to-object-props/index.js';
@@ -1 +1,2 @@
1
1
  export * from './type-guards/index.js';
2
+ export * from './validators/index.js';
@@ -1 +1,2 @@
1
1
  export * from './type-guards/index.js';
2
+ export * from './validators/index.js';
@@ -0,0 +1 @@
1
+ export * from './validate-string/index.js';
@@ -0,0 +1 @@
1
+ export * from './validate-string/index.js';
@@ -0,0 +1,2 @@
1
+ import { ValidateString } from './types.js';
2
+ export declare const validateString: ValidateString;
@@ -0,0 +1,19 @@
1
+ import { customErrorWorker } from '../../../../error/index.js';
2
+ import { isString } from '../../type-guards/index.js';
3
+ export const validateString = (data, name, regexp) => {
4
+ const { composeCustomError } = customErrorWorker({ data, name, regexp: JSON.stringify(regexp) });
5
+ if (!data) {
6
+ return composeCustomError(`Missing ${name}`);
7
+ }
8
+ if (!isString(data)) {
9
+ return composeCustomError(`${name} not string`);
10
+ }
11
+ if (regexp) {
12
+ if (!regexp.test(data)) {
13
+ return composeCustomError(`Invalid ${name}`);
14
+ }
15
+ }
16
+ return {
17
+ data,
18
+ };
19
+ };
@@ -0,0 +1,6 @@
1
+ import { CustomError } from '../../../../error/index.js';
2
+ export type ValidateString = (data: unknown, name: string, regexp?: RegExp) => {
3
+ data: string;
4
+ } | {
5
+ customError: CustomError;
6
+ };