core-services-sdk 1.3.22 → 1.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/package.json +5 -2
  2. package/src/core/index.js +1 -0
  3. package/src/core/normalize-premitives-types-or-default.js +215 -0
  4. package/src/index.js +1 -0
  5. package/src/util/index.js +12 -0
  6. package/src/util/mask-sensitive.js +78 -0
  7. package/tests/core/normalize-premitives-types-or-default.unit.test.js +72 -0
  8. package/tests/rabbit-mq/rabbit-mq.test.js +1 -0
  9. package/tests/util/mask-sensitive.unit.test.js +79 -0
  10. package/tsconfig.json +9 -0
  11. package/types/core/combine-unique-arrays.d.ts +1 -0
  12. package/types/core/index.d.ts +8 -0
  13. package/types/core/normalize-min-max.d.ts +10 -0
  14. package/types/core/normalize-phone-number.d.ts +48 -0
  15. package/types/core/normalize-premitives-types-or-default.d.ts +172 -0
  16. package/types/core/normalize-to-array.d.ts +1 -0
  17. package/types/core/otp-generators.d.ts +56 -0
  18. package/types/core/regex-utils.d.ts +1 -0
  19. package/types/core/sanitize-objects.d.ts +4 -0
  20. package/types/crypto/crypto.d.ts +18 -0
  21. package/types/crypto/encryption.d.ts +6 -0
  22. package/types/crypto/index.d.ts +2 -0
  23. package/types/fastify/error-codes.d.ts +29 -0
  24. package/types/fastify/error-handlers/with-error-handling.d.ts +15 -0
  25. package/types/fastify/index.d.ts +2 -0
  26. package/types/http/HttpError.d.ts +82 -0
  27. package/types/http/http-method.d.ts +7 -0
  28. package/types/http/http.d.ts +36 -0
  29. package/types/http/index.d.ts +4 -0
  30. package/types/http/responseType.d.ts +20 -0
  31. package/types/ids/generators.d.ts +10 -0
  32. package/types/ids/index.d.ts +2 -0
  33. package/types/ids/prefixes.d.ts +34 -0
  34. package/types/index.d.ts +11 -0
  35. package/types/logger/get-logger.d.ts +23 -0
  36. package/types/logger/index.d.ts +1 -0
  37. package/types/mailer/index.d.ts +2 -0
  38. package/types/mailer/mailer.service.d.ts +21 -0
  39. package/types/mailer/transport.factory.d.ts +48 -0
  40. package/types/mongodb/connect.d.ts +4 -0
  41. package/types/mongodb/index.d.ts +3 -0
  42. package/types/mongodb/initialize-mongodb.d.ts +13 -0
  43. package/types/mongodb/validate-mongo-uri.d.ts +15 -0
  44. package/types/rabbit-mq/index.d.ts +1 -0
  45. package/types/rabbit-mq/rabbit-mq.d.ts +40 -0
  46. package/types/templates/index.d.ts +1 -0
  47. package/types/templates/template-loader.d.ts +3 -0
  48. package/types/util/index.d.ts +7 -0
  49. package/types/util/mask-sensitive.d.ts +2 -0
  50. package/vitest.config.js +13 -3
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Validates whether a given string is a properly formatted MongoDB URI.
3
+ *
4
+ * Supports both standard (`mongodb://`) and SRV (`mongodb+srv://`) protocols.
5
+ *
6
+ * @param {string} uri - The URI string to validate.
7
+ * @returns {boolean} `true` if the URI is a valid MongoDB connection string, otherwise `false`.
8
+ *
9
+ * @example
10
+ * isValidMongoUri('mongodb://localhost:27017/mydb') // true
11
+ * isValidMongoUri('mongodb+srv://cluster.example.com/test') // true
12
+ * isValidMongoUri('http://localhost') // false
13
+ * isValidMongoUri('') // false
14
+ */
15
+ export function isValidMongoUri(uri: string): boolean;
@@ -0,0 +1 @@
1
+ export * from "./rabbit-mq.js";
@@ -0,0 +1,40 @@
1
+ export function connectQueueService({ host, log }: {
2
+ host: string;
3
+ log: import("pino").Logger;
4
+ }): Promise<amqp.Connection>;
5
+ export function createChannel({ host, log }: {
6
+ host: string;
7
+ log: import("pino").Logger;
8
+ }): Promise<amqp.Channel>;
9
+ export function subscribeToQueue({ log, queue, channel, prefetch, onReceive, nackOnError, }: {
10
+ channel: any;
11
+ queue: string;
12
+ onReceive: (data: any, correlationId?: string) => Promise<void>;
13
+ log: import("pino").Logger;
14
+ nackOnError?: boolean;
15
+ prefetch?: number;
16
+ }): Promise<void>;
17
+ export function initializeQueue({ host, log }: {
18
+ host: string;
19
+ log: import("pino").Logger;
20
+ }): Promise<{
21
+ publish: (queue: string, data: any, correlationId?: string) => Promise<boolean>;
22
+ subscribe: (options: {
23
+ queue: string;
24
+ onReceive: (data: any, correlationId?: string) => Promise<void>;
25
+ nackOnError?: boolean;
26
+ }) => Promise<void>;
27
+ channel: amqp.Channel;
28
+ }>;
29
+ export function rabbitUriFromEnv(env: {
30
+ RABBIT_HOST: string;
31
+ RABBIT_PORT: string | number;
32
+ RABBIT_USERNAME: string;
33
+ RABBIT_PASSWORD: string;
34
+ RABBIT_PROTOCOL?: string;
35
+ }): string;
36
+ export type Log = {
37
+ info: (obj: any, msg?: string) => void;
38
+ error: (obj: any, msg?: string) => void;
39
+ debug: (obj: any, msg?: string) => void;
40
+ };
@@ -0,0 +1 @@
1
+ export * from "./template-loader.js";
@@ -0,0 +1,3 @@
1
+ export function isItFile(filePathOrString: string): Promise<boolean>;
2
+ export function getTemplateContent(maybeFilePathOrString: string): Promise<string>;
3
+ export function loadTemplates(templateSet: Record<string, string>): Promise<Record<string, (params: Record<string, any>) => string>>;
@@ -0,0 +1,7 @@
1
+ export namespace util {
2
+ export { mask };
3
+ export { maskSingle };
4
+ }
5
+ import { mask } from './mask-sensitive.js';
6
+ import { maskSingle } from './mask-sensitive.js';
7
+ export { mask, maskSingle };
@@ -0,0 +1,2 @@
1
+ export function maskSingle(value: string | number | boolean | null | undefined, fill?: string, maskLen?: number, left?: number, right?: number): string;
2
+ export function mask(value: string | number | boolean | any[] | any | null | undefined, fill?: string, maskLen?: number, left?: number, right?: number): string | any[] | any;
package/vitest.config.js CHANGED
@@ -1,9 +1,19 @@
1
- export default {
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
2
4
  test: {
3
5
  testTimeout: 30000,
4
6
  hookTimeout: 30000,
7
+ exclude: [
8
+ 'node_modules',
9
+ 'types/**',
10
+ '**/*.d.ts',
11
+ '**/index.js',
12
+ 'vitest.config.js',
13
+ ],
5
14
  coverage: {
6
- exclude: ['**/index.js', 'vitest.config.js'],
15
+ include: ['src/**/*.js'],
16
+ exclude: ['types/**', '**/*.d.ts', '**/index.js', 'vitest.config.js'],
7
17
  },
8
18
  },
9
- }
19
+ })