@cyberskill/shared 1.217.0 → 2.1.0

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 (89) hide show
  1. package/README.md +331 -223
  2. package/dist/config/config.util.d.ts +17 -0
  3. package/dist/config/env/env.util.d.ts +26 -0
  4. package/dist/config/eslint/index.d.ts +4 -0
  5. package/dist/config/graphql-codegen/graphql-codegen.util.d.ts +23 -0
  6. package/dist/config/vitest/vitest.e2e.cjs +1 -1
  7. package/dist/config/vitest/vitest.e2e.d.ts +16 -0
  8. package/dist/config/vitest/vitest.e2e.js +1 -1
  9. package/dist/config/vitest/vitest.unit.cjs +1 -1
  10. package/dist/config/vitest/vitest.unit.d.ts +18 -0
  11. package/dist/config/vitest/vitest.unit.js +1 -1
  12. package/dist/constant/common.d.ts +4 -0
  13. package/dist/constant/index.d.ts +3 -0
  14. package/dist/node/apollo-server/apollo-server.util.d.ts +14 -0
  15. package/dist/node/command/command.type.d.ts +26 -6
  16. package/dist/node/command/command.util.d.ts +50 -0
  17. package/dist/node/express/express.util.d.ts +47 -0
  18. package/dist/node/fs/fs.type.d.ts +6 -0
  19. package/dist/node/fs/fs.util.d.ts +48 -1
  20. package/dist/node/log/log.type.d.ts +6 -1
  21. package/dist/node/log/log.util.cjs +1 -1
  22. package/dist/node/log/log.util.d.ts +30 -2
  23. package/dist/node/log/log.util.js +33 -20
  24. package/dist/node/mongo/index.cjs +1 -1
  25. package/dist/node/mongo/index.js +11 -15
  26. package/dist/node/mongo/mongo.constant.d.ts +5 -0
  27. package/dist/node/mongo/mongo.type.d.ts +30 -10
  28. package/dist/node/mongo/mongo.util.cjs +5 -5
  29. package/dist/node/mongo/mongo.util.d.ts +355 -12
  30. package/dist/node/mongo/mongo.util.js +686 -190
  31. package/dist/node/package/package.type.d.ts +2 -2
  32. package/dist/node/package/package.util.cjs +1 -1
  33. package/dist/node/package/package.util.d.ts +52 -1
  34. package/dist/node/package/package.util.js +97 -92
  35. package/dist/node/path/path.constant.d.ts +9 -0
  36. package/dist/node/path/path.util.d.ts +24 -0
  37. package/dist/node/storage/storage.util.d.ts +44 -0
  38. package/dist/node/storage/storage.util.js +39 -0
  39. package/dist/node/upload/upload.util.d.ts +21 -0
  40. package/dist/node/ws/ts.util.d.ts +16 -0
  41. package/dist/react/apollo-client/apollo-client.component.d.ts +19 -1
  42. package/dist/react/apollo-client/apollo-client.component.js +1 -4
  43. package/dist/react/apollo-client/apollo-client.constant.d.ts +5 -0
  44. package/dist/react/apollo-client/apollo-client.context.d.ts +15 -0
  45. package/dist/react/apollo-client/apollo-client.hook.d.ts +12 -0
  46. package/dist/react/apollo-client/apollo-client.util.d.ts +48 -0
  47. package/dist/react/apollo-client/apollo-client.util.js +9 -0
  48. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.d.ts +19 -1
  49. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +1 -4
  50. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts +10 -0
  51. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.d.ts +10 -0
  52. package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
  53. package/dist/react/apollo-error/apollo-error.component.d.ts +17 -0
  54. package/dist/react/apollo-error/apollo-error.component.js +10 -10
  55. package/dist/react/apollo-error/apollo-error.hook.d.ts +12 -0
  56. package/dist/react/apollo-error/apollo-error.provider.d.ts +15 -0
  57. package/dist/react/apollo-error/apollo-error.util.d.ts +17 -0
  58. package/dist/react/i18next/i18next.hook.d.ts +9 -0
  59. package/dist/react/i18next/i18next.util.d.ts +10 -0
  60. package/dist/react/loading/loading.component.d.ts +21 -0
  61. package/dist/react/loading/loading.hook.d.ts +12 -0
  62. package/dist/react/loading/loading.provider.d.ts +15 -0
  63. package/dist/react/log/log.util.d.ts +17 -0
  64. package/dist/react/next-intl/next-intl.constant.d.ts +9 -0
  65. package/dist/react/next-intl/next-intl.hoc.d.ts +16 -0
  66. package/dist/react/next-intl/next-intl.hook.d.ts +21 -0
  67. package/dist/react/next-intl/next-intl.provider.d.ts +21 -0
  68. package/dist/react/storage/storage.hook.d.ts +19 -0
  69. package/dist/react/storage/storage.hook.js +28 -30
  70. package/dist/react/storage/storage.util.d.ts +39 -0
  71. package/dist/react/storage/storage.util.js +33 -0
  72. package/dist/react/userback/userback.component.d.ts +18 -0
  73. package/dist/typescript/common.type.d.ts +6 -0
  74. package/dist/typescript/index.d.ts +3 -0
  75. package/dist/util/common/common.util.d.ts +19 -7
  76. package/dist/util/common/index.d.ts +3 -0
  77. package/dist/util/index.d.ts +3 -0
  78. package/dist/util/object/object.util.d.ts +25 -12
  79. package/dist/util/serializer/serializer.type.d.ts +1 -1
  80. package/dist/util/serializer/serializer.util.d.ts +8 -0
  81. package/dist/util/serializer/serializer.util.js +4 -4
  82. package/dist/util/string/string.util.cjs +1 -1
  83. package/dist/util/string/string.util.d.ts +30 -17
  84. package/dist/util/string/string.util.js +14 -16
  85. package/dist/util/validate/validate.util.d.ts +9 -3
  86. package/dist/util/validate/validate.util.js +5 -3
  87. package/package.json +12 -10
  88. /package/dist/node_modules/.pnpm/{vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.14_@vitest_browser@3.2.4_jiti@2.4.2_j_5b4f3b6d03b5e1745ce439b75ce4a42f → vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31}/node_modules/vitest/dist/config.cjs +0 -0
  89. /package/dist/node_modules/.pnpm/{vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.14_@vitest_browser@3.2.4_jiti@2.4.2_j_5b4f3b6d03b5e1745ce439b75ce4a42f → vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31}/node_modules/vitest/dist/config.js +0 -0
@@ -1,3 +1,20 @@
1
1
  import { T_Object } from '../typescript/index.js';
2
2
  import { T_ConfigType } from './config.type.js';
3
+ /**
4
+ * Merges configurations based on the specified type.
5
+ * This function provides a unified interface for merging different types of
6
+ * configurations using their respective handlers. It supports ESLint, commitlint,
7
+ * lint-staged, and Vitest configurations with appropriate processing for each type.
8
+ *
9
+ * The function automatically:
10
+ * - Selects the appropriate handler for the config type
11
+ * - Merges multiple configuration objects
12
+ * - Handles empty configuration arrays gracefully
13
+ * - Provides error handling for unknown config types
14
+ *
15
+ * @param type - The type of configuration to merge (ESLint, commitlint, lint-staged, or Vitest).
16
+ * @param config - Configuration objects to merge, can be empty for default handling.
17
+ * @returns A merged configuration object processed according to the specified type.
18
+ * @throws {Error} When an unknown configuration type is provided.
19
+ */
3
20
  export declare function mergeConfigs(type: T_ConfigType, ...config: T_Object[]): T_Object;
@@ -1,3 +1,29 @@
1
1
  import { I_Environment } from './env.type.js';
2
+ /**
3
+ * Loads environment variables from .env files.
4
+ * This function loads environment variables from .env files using dotenvx,
5
+ * but only in non-production environments. It includes a safety mechanism
6
+ * to prevent multiple loading of the same environment file.
7
+ *
8
+ * The function:
9
+ * - Checks if the current environment is not production
10
+ * - Loads environment variables from .env files
11
+ * - Prevents duplicate loading with a flag mechanism
12
+ * - Uses dotenvx for enhanced environment file support
13
+ */
2
14
  export declare function loadEnvFile(): void;
15
+ /**
16
+ * Retrieves and validates the application environment configuration.
17
+ * This function loads environment variables, validates them using envalid,
18
+ * and returns a typed environment object with default values for missing
19
+ * variables. It ensures all required environment variables are present
20
+ * and properly typed.
21
+ *
22
+ * The function validates:
23
+ * - CWD: Current working directory (defaults to process.cwd())
24
+ * - DEBUG: Debug mode flag (defaults to false)
25
+ * - CYBERSKILL_STORAGE_DIRECTORY: Storage directory path (defaults to user home directory)
26
+ *
27
+ * @returns A validated environment object with all required configuration values.
28
+ */
3
29
  export declare function getEnv(): I_Environment;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Base ESLint configuration.
3
+ * This config provides the foundation for ESLint rules.
4
+ */
1
5
  declare const _default: {
2
6
  languageOptions: {
3
7
  globals: {
@@ -1,3 +1,26 @@
1
1
  import { CodegenConfig } from '@graphql-codegen/cli';
2
2
  import { I_GraphqlCodegenConfig } from './graphql-codegen.type.js';
3
+ /**
4
+ * Creates a GraphQL Code Generator configuration for client or server code generation.
5
+ * This function generates a complete GraphQL Code Generator configuration based on
6
+ * the specified target (client or server) with appropriate presets and settings.
7
+ *
8
+ * For client targets, it configures:
9
+ * - Client preset with fragment masking disabled
10
+ * - Persisted documents support
11
+ * - Type imports and naming convention settings
12
+ * - Document processing from specified source
13
+ *
14
+ * For server targets, it configures:
15
+ * - TypeScript resolver files generation
16
+ * - Server-side GraphQL type definitions
17
+ * - Resolver function generation
18
+ *
19
+ * @param options - Configuration object containing uri, from, to, and target properties.
20
+ * @param options.uri - The GraphQL schema URI to generate types from.
21
+ * @param options.from - The source path for GraphQL documents (used for client generation).
22
+ * @param options.to - The output path for generated files.
23
+ * @param options.target - The generation target ('client' for frontend, 'server' for backend).
24
+ * @returns A complete GraphQL Code Generator configuration object.
25
+ */
3
26
  export declare function createGraphqlCodegenConfig({ uri, from, to, target, }: I_GraphqlCodegenConfig): CodegenConfig;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("lodash-es"),o=require("../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.14_@vitest_browser@3.2.4_jiti@2.4.2_j_5b4f3b6d03b5e1745ce439b75ce4a42f/node_modules/vitest/dist/config.cjs");function s(e){const r={plugins:[t()],test:{include:["**/*.test.e2e.?(c|m)[jt]s?(x)"],browser:{enabled:!0,provider:"playwright",instances:[{browser:"chromium"},{browser:"firefox"},{browser:"webkit"}]}}};return o.defineConfig(i.merge(r,e))}exports.vitestE2E=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("lodash-es"),o=require("../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31/node_modules/vitest/dist/config.cjs");function s(e){const r={plugins:[t()],test:{include:["**/*.test.e2e.?(c|m)[jt]s?(x)"],browser:{enabled:!0,provider:"playwright",instances:[{browser:"chromium"},{browser:"firefox"},{browser:"webkit"}]}}};return o.defineConfig(i.merge(r,e))}exports.vitestE2E=s;
@@ -1,2 +1,18 @@
1
1
  import { UserConfig } from 'vite';
2
+ /**
3
+ * Creates a Vitest configuration for end-to-end testing with browser automation.
4
+ * This function generates a Vitest configuration specifically designed for E2E testing
5
+ * using Playwright with multiple browser instances. It includes React support and
6
+ * browser automation capabilities for comprehensive end-to-end testing.
7
+ *
8
+ * The configuration includes:
9
+ * - React SWC plugin for fast React compilation
10
+ * - Browser automation with Playwright provider
11
+ * - Multiple browser instances (Chromium, Firefox, WebKit)
12
+ * - E2E test file pattern matching
13
+ * - Configurable options merging
14
+ *
15
+ * @param options - Additional Vite configuration options to merge with the E2E config.
16
+ * @returns A Vitest configuration object optimized for end-to-end testing with browser automation.
17
+ */
2
18
  export declare function vitestE2E(options: UserConfig): UserConfig;
@@ -1,6 +1,6 @@
1
1
  import t from "@vitejs/plugin-react-swc";
2
2
  import { merge as o } from "lodash-es";
3
- import { defineConfig as i } from "../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.14_@vitest_browser@3.2.4_jiti@2.4.2_j_5b4f3b6d03b5e1745ce439b75ce4a42f/node_modules/vitest/dist/config.js";
3
+ import { defineConfig as i } from "../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31/node_modules/vitest/dist/config.js";
4
4
  function f(r) {
5
5
  const e = {
6
6
  plugins: [t()],
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("lodash-es"),s=require("../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.14_@vitest_browser@3.2.4_jiti@2.4.2_j_5b4f3b6d03b5e1745ce439b75ce4a42f/node_modules/vitest/dist/config.cjs");function r(e){const t={plugins:[i()],test:{globals:!0,environment:"jsdom",pool:"vmThreads",include:["**/*.test.unit.?(c|m)[jt]s?(x)"],setupFiles:["./vitest.unit.setup.ts"]}};return s.defineConfig(n.merge(t,e))}exports.vitestUnit=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("lodash-es"),s=require("../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31/node_modules/vitest/dist/config.cjs");function r(e){const t={plugins:[i()],test:{globals:!0,environment:"jsdom",pool:"vmThreads",include:["**/*.test.unit.?(c|m)[jt]s?(x)"],setupFiles:["./vitest.unit.setup.ts"]}};return s.defineConfig(n.merge(t,e))}exports.vitestUnit=r;
@@ -1,2 +1,20 @@
1
1
  import { UserConfig } from 'vite';
2
+ /**
3
+ * Creates a Vitest configuration for unit testing with React support.
4
+ * This function generates a Vitest configuration specifically designed for unit testing
5
+ * React components and JavaScript/TypeScript modules. It includes JSDOM environment
6
+ * for DOM simulation and comprehensive testing setup.
7
+ *
8
+ * The configuration includes:
9
+ * - React SWC plugin for fast React compilation
10
+ * - JSDOM environment for DOM simulation
11
+ * - Global test functions availability
12
+ * - VM threads pool for parallel test execution
13
+ * - Unit test file pattern matching
14
+ * - Setup files for testing library configuration
15
+ * - Configurable options merging
16
+ *
17
+ * @param options - Additional Vite configuration options to merge with the unit test config.
18
+ * @returns A Vitest configuration object optimized for unit testing with React and DOM support.
19
+ */
2
20
  export declare function vitestUnit(options: UserConfig): UserConfig;
@@ -1,6 +1,6 @@
1
1
  import i from "@vitejs/plugin-react-swc";
2
2
  import { merge as o } from "lodash-es";
3
- import { defineConfig as n } from "../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.14_@vitest_browser@3.2.4_jiti@2.4.2_j_5b4f3b6d03b5e1745ce439b75ce4a42f/node_modules/vitest/dist/config.js";
3
+ import { defineConfig as n } from "../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31/node_modules/vitest/dist/config.js";
4
4
  function u(t) {
5
5
  const e = {
6
6
  plugins: [i()],
@@ -1 +1,5 @@
1
+ /**
2
+ * Indicates if the current environment is a browser (as opposed to Node.js).
3
+ * This constant is true if the global `window` object is defined, false otherwise.
4
+ */
1
5
  export declare const IS_BROWSER: boolean;
@@ -1,2 +1,5 @@
1
+ /**
2
+ * Re-exports all common constants for shared usage across the codebase.
3
+ */
1
4
  export * from './common.js';
2
5
  export * from './response-status.js';
@@ -1,5 +1,19 @@
1
1
  import { ApolloServer } from '@apollo/server';
2
2
  import { expressMiddleware } from '@as-integrations/express5';
3
3
  import { I_ApolloServerOptions } from './apollo-server.type.js';
4
+ /**
5
+ * Creates and configures an Apollo Server instance with appropriate plugins and settings.
6
+ * This function sets up an Apollo Server with development or production landing pages,
7
+ * HTTP server draining capabilities, and optional custom drain server hooks.
8
+ *
9
+ * The server is configured with:
10
+ * - Development or production landing page based on the isDev flag
11
+ * - HTTP server draining plugin for graceful shutdowns
12
+ * - Optional custom drain server hook for additional cleanup
13
+ * - Development-specific settings (introspection and stack traces) when isDev is true
14
+ *
15
+ * @param options - Configuration options for the Apollo Server including server instance, schema, and environment settings.
16
+ * @returns A configured Apollo Server instance ready to be started.
17
+ */
4
18
  export declare function createApolloServer(options: I_ApolloServerOptions): ApolloServer;
5
19
  export { expressMiddleware };
@@ -1,24 +1,44 @@
1
+ /**
2
+ * Interface representing an ESLint error structure.
3
+ */
1
4
  export interface I_EslintError {
2
5
  filePath: string;
3
6
  messages: Array<{
4
- line: number;
5
- column: number;
7
+ ruleId: string;
6
8
  severity: number;
7
9
  message: string;
8
- ruleId: string;
10
+ line: number;
11
+ column: number;
9
12
  }>;
10
13
  }
14
+ /**
15
+ * Interface representing the command execution context.
16
+ */
11
17
  export interface I_CommandContext {
12
18
  isCurrentProject: boolean;
13
19
  }
20
+ /**
21
+ * Interface representing a command with raw flag and command string.
22
+ */
14
23
  export interface I_Command {
15
24
  raw: boolean;
16
25
  cmd: string;
17
26
  }
27
+ /**
28
+ * Type for a function that generates a command string based on context.
29
+ */
18
30
  export type T_CommandFunction = (context?: I_CommandContext) => string;
19
- export type T_Command = string | I_Command | T_CommandFunction;
20
- export type T_CommandMap = Record<string, T_Command>;
21
- export type T_CommandMapInput = T_CommandMap | ((ctx: I_CommandContext) => T_CommandMap);
31
+ /**
32
+ * Type for a command, which can be a string, function that returns a string, or a raw command object.
33
+ */
34
+ export type T_Command = string | T_CommandFunction | I_Command;
35
+ /**
36
+ * Type for a command map input, which can be a record or a function returning a record.
37
+ */
38
+ export type T_CommandMapInput = Record<string, T_Command> | ((context: I_CommandContext) => Record<string, T_Command>);
39
+ /**
40
+ * Enum for command types: CLI, STRING, or FUNCTION.
41
+ */
22
42
  export declare enum E_CommandType {
23
43
  CLI = "CLI",
24
44
  STRING = "STRING",
@@ -1,13 +1,63 @@
1
1
  import { I_IssueEntry } from '../log/index.js';
2
2
  import { I_CommandContext, T_Command, T_CommandMapInput } from './command.type.js';
3
+ /**
4
+ * Retrieves all stored error lists from persistent storage.
5
+ * This function fetches error entries that were previously saved using the package name as the key.
6
+ *
7
+ * @returns A promise that resolves to an array of error entries, or an empty array if none are found.
8
+ */
3
9
  export declare function getStoredErrorLists(): Promise<I_IssueEntry[]>;
10
+ /**
11
+ * Clears all stored error lists from persistent storage.
12
+ * This function removes all error entries associated with the current package name.
13
+ *
14
+ * @returns A promise that resolves when the clearing operation is complete.
15
+ */
4
16
  export declare function clearAllErrorLists(): Promise<void>;
17
+ /**
18
+ * Creates a raw command object that bypasses CLI formatting.
19
+ * This function wraps a command string in an object that indicates it should be executed
20
+ * as-is without any additional CLI formatting or path resolution.
21
+ *
22
+ * @param cmd - The raw command string to be executed directly.
23
+ * @returns An object containing the raw command with a flag indicating it should not be formatted.
24
+ */
5
25
  export declare function rawCommand(cmd: string): {
6
26
  raw: boolean;
7
27
  cmd: string;
8
28
  };
29
+ /**
30
+ * Formats a command based on its type and context.
31
+ * This function handles different command types:
32
+ * - Function commands: Executes the function with context and formats the result
33
+ * - Raw commands: Returns the command as-is without formatting
34
+ * - String commands: Formats them as CLI commands
35
+ *
36
+ * @param command - The command to format, which can be a string, function, or raw command object.
37
+ * @param context - Optional context information for command execution.
38
+ * @returns The formatted command string ready for execution.
39
+ */
9
40
  export declare function formatCommand(command: T_Command, context?: I_CommandContext): string | import('./command.type.js').I_Command;
41
+ /**
42
+ * Resolves a map of commands by formatting them based on the current project context.
43
+ * This function takes a command map (either static or dynamic) and formats all commands
44
+ * using the appropriate CLI paths based on whether the current project is the Cyberskill package.
45
+ *
46
+ * @param input - The command map to resolve, which can be static or a function that returns a map.
47
+ * @returns A promise that resolves to an object with formatted command strings, or undefined if package info cannot be retrieved.
48
+ */
10
49
  export declare function resolveCommands(input: T_CommandMapInput): Promise<{
11
50
  [k: string]: string | import('./command.type.js').I_Command;
12
51
  } | undefined>;
52
+ /**
53
+ * Executes a command with proper logging and error handling.
54
+ * This function provides a standardized way to run commands with:
55
+ * - Progress logging with start and success messages
56
+ * - Debug logging of the actual command when DEBUG mode is enabled
57
+ * - Error handling and reporting
58
+ *
59
+ * @param label - A human-readable label describing what the command does.
60
+ * @param command - The command string to execute, or undefined if no command should be run.
61
+ * @returns A promise that resolves when the command execution is complete.
62
+ */
13
63
  export declare function runCommand(label: string, command: string | void): Promise<void>;
@@ -4,16 +4,63 @@ import { SessionOptions } from 'express-session';
4
4
  import { default as bodyParser } from 'body-parser';
5
5
  import { default as cors } from 'cors';
6
6
  import { I_ExpressOptions, I_NestOptions, T_CorsOptions, T_CorsType } from './express.type.js';
7
+ /**
8
+ * Creates CORS options with environment-specific configuration.
9
+ * This function generates CORS options based on the development environment,
10
+ * including whitelist configuration for allowed origins.
11
+ *
12
+ * @param options - CORS configuration options.
13
+ * @param options.isDev - Whether the application is running in development mode.
14
+ * @param options.whiteList - Array of allowed origins for CORS requests.
15
+ * @returns CORS options object configured for the specified environment.
16
+ */
7
17
  export declare function createCorsOptions<T extends T_CorsType>({ isDev, whiteList, ...rest }: T_CorsOptions<T>): {
8
18
  origin: (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void;
9
19
  credentials: boolean;
10
20
  } & Omit<T_CorsOptions<T>, "isDev" | "whiteList">;
21
+ /**
22
+ * Creates a CORS middleware function with the specified configuration.
23
+ * This function creates a CORS middleware that can be used with both Express and NestJS applications,
24
+ * applying the configured CORS options for origin validation and credential handling.
25
+ *
26
+ * @param options - CORS configuration options to apply to the middleware.
27
+ * @returns A CORS middleware function ready to be used in Express or NestJS applications.
28
+ */
11
29
  export declare function createCors<T extends T_CorsType>(options: T_CorsOptions<T>): (req: cors.CorsRequest, res: {
12
30
  statusCode?: number | undefined;
13
31
  setHeader(key: string, value: string): any;
14
32
  end(): any;
15
33
  }, next: (err?: any) => any) => void;
34
+ /**
35
+ * Creates a session middleware function with the specified configuration.
36
+ * This function creates an Express session middleware that can be used to handle user sessions
37
+ * with the provided session options including secret, cookie settings, and storage configuration.
38
+ *
39
+ * @param options - Session configuration options including secret, cookie settings, and storage.
40
+ * @returns A session middleware function ready to be used in Express applications.
41
+ */
16
42
  export declare function createSession(options: SessionOptions): RequestHandler;
43
+ /**
44
+ * Creates and configures an Express application with common middleware and settings.
45
+ * This function sets up a complete Express application with:
46
+ * - Essential middleware (cookies, body parsing, compression, user agent)
47
+ * - Static file serving for specified folders
48
+ * - GraphQL upload support for file uploads
49
+ *
50
+ * @param options - Optional configuration for the Express application including static folder paths.
51
+ * @returns A configured Express application instance ready for use.
52
+ */
17
53
  export declare function createExpress(options?: I_ExpressOptions): Application;
54
+ /**
55
+ * Creates and configures a NestJS application with Express integration.
56
+ * This function sets up a NestJS application with:
57
+ * - Express HTTP adapter configuration
58
+ * - Common middleware (cookies, body parsing, compression, user agent)
59
+ * - Static file serving for specified folders
60
+ * - Global filters and pipes if provided
61
+ *
62
+ * @param options - Configuration options for the NestJS application including module, static folders, filters, and pipes.
63
+ * @returns A promise that resolves to a configured NestJS application instance.
64
+ */
18
65
  export declare function createNest(options: I_NestOptions): Promise<INestApplication>;
19
66
  export { bodyParser, express };
@@ -1,4 +1,10 @@
1
1
  import { CopyOptionsSync } from 'fs-extra';
2
+ /**
3
+ * Options for synchronous copy operations, extending fs-extra's CopyOptionsSync.
4
+ */
2
5
  export interface I_CopySyncOptions extends CopyOptionsSync {
6
+ /**
7
+ * Optional array of file extensions to filter which files are copied.
8
+ */
3
9
  extensions?: string[];
4
10
  }
@@ -1,10 +1,57 @@
1
1
  import { default as fsExtra } from 'fs-extra';
2
2
  import { I_CopySyncOptions } from './fs.type.js';
3
+ /**
4
+ * Re-export of the fs-extra module for file system operations.
5
+ */
3
6
  export declare const fs: typeof fsExtra;
4
7
  export declare const lstatSync: fsExtra.StatSyncFn, readdirSync: typeof fsExtra.readdirSync, mkdirSync: typeof fsExtra.mkdirSync, readFileSync: typeof fsExtra.readFileSync, unlinkSync: typeof fsExtra.unlinkSync, statSync: fsExtra.StatSyncFn, createWriteStream: typeof fsExtra.createWriteStream;
5
8
  export declare const readJsonSync: typeof fsExtra.readJsonSync;
6
- export declare function writeFileSync(file: fsExtra.PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: fsExtra.WriteFileOptions): void;
9
+ /**
10
+ * Writes data to a file synchronously with UTF-8 encoding as default.
11
+ * This function provides a simplified interface for writing files with automatic UTF-8 encoding
12
+ * when no specific options are provided.
13
+ *
14
+ * @param file - The file path or file descriptor to write to.
15
+ * @param data - The data to write to the file (string or Uint8Array).
16
+ * @param options - Optional write file options (defaults to UTF-8 encoding).
17
+ */
18
+ export declare function writeFileSync(file: fsExtra.PathOrFileDescriptor, data: string | Uint8Array, options?: fsExtra.WriteFileOptions): void;
19
+ /**
20
+ * Appends data to a file synchronously with UTF-8 encoding as default.
21
+ * This function provides a simplified interface for appending to files with automatic UTF-8 encoding
22
+ * when no specific options are provided.
23
+ *
24
+ * @param path - The file path or file descriptor to append to.
25
+ * @param data - The data to append to the file (string or Uint8Array).
26
+ * @param options - Optional write file options (defaults to UTF-8 encoding).
27
+ */
7
28
  export declare function appendFileSync(path: fsExtra.PathOrFileDescriptor, data: string | Uint8Array, options?: fsExtra.WriteFileOptions): void;
29
+ /**
30
+ * Checks if all specified paths exist synchronously.
31
+ * This function verifies that every path in the provided array exists in the file system.
32
+ * Returns true only if all paths exist, false if any path is missing.
33
+ *
34
+ * @param paths - An array of file or directory paths to check for existence.
35
+ * @returns True if all paths exist, false if any path is missing.
36
+ */
8
37
  export declare function pathExistsSync(...paths: string[]): boolean;
38
+ /**
39
+ * Removes files or directories synchronously if they exist.
40
+ * This function safely removes multiple files or directories by checking for existence
41
+ * before attempting removal, preventing errors for non-existent paths.
42
+ *
43
+ * @param paths - An array of file or directory paths to remove.
44
+ */
9
45
  export declare function removeSync(...paths: string[]): void;
46
+ /**
47
+ * Copies files and directories synchronously with optional filtering.
48
+ * This function copies files from source to destination with support for:
49
+ * - Extension-based filtering (only copy files with specified extensions)
50
+ * - Directory preservation (always copy directories regardless of extension filter)
51
+ * - Additional copy options from fs-extra
52
+ *
53
+ * @param src - The source path to copy from.
54
+ * @param dest - The destination path to copy to.
55
+ * @param options - Optional copy configuration including extensions filter and other fs-extra options.
56
+ */
10
57
  export declare function copySync(src: string, dest: string, options?: I_CopySyncOptions): void;
@@ -1,4 +1,9 @@
1
1
  import { I_Log as I_LogCommon } from '../../typescript/index.js';
2
+ /**
3
+ * Enum representing the type of issues for logging and error handling.
4
+ * - Error: Represents an error issue.
5
+ * - Warning: Represents a warning issue.
6
+ */
2
7
  export declare enum E_IssueType {
3
8
  Error = "error",
4
9
  Warning = "warning"
@@ -10,7 +15,7 @@ export interface I_IssueEntry {
10
15
  position?: string;
11
16
  rule?: string;
12
17
  }
13
- export interface T_ThrowError {
18
+ export interface I_ThrowError {
14
19
  message?: string;
15
20
  status?: {
16
21
  CODE: string | number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("chalk"),r=require("consola"),i=require("graphql"),f=require("../../config/env/env.util.cjs"),g=require("../../constant/response-status.cjs"),h=f.getEnv();function R({message:o,status:e=g.RESPONSE_STATUS.INTERNAL_SERVER_ERROR,type:l="graphql"}){var t;const n=(t=o!=null?o:e.MESSAGE)!=null?t:"Internal server error";throw l==="graphql"?new i.GraphQLError(n,{extensions:{code:e.CODE}}):new Error(n)}h.DEBUG||(r.level=4);function s(o){const e=c[o];return typeof e=="function"?e:c.green}const E={silent:r.silent,level:r.level,fatal:r.fatal,error:r.error,warn:r.warn,log:r.log,info:r.info,success:r.success,ready:r.ready,start:r.start,box:r.box,debug:r.debug,trace:r.trace,verbose:r.verbose,printBoxedLog(o,e,l="red"){if(!(e!=null&&e.length)){r.box(c.green(o));return}e.forEach(({file:t,position:n,rule:a,message:u})=>{r.log(`${c.gray("File:")} ${c.blue(`${t}${n?`:${n}`:""}`)}`),a&&r.log(` ${s(l)("Rule:")} ${a}`),r.log(` ${s(l)("Message:")} ${u}`)}),r.box(s(l)(`${o} : ${e.length}`)),r.log(c.gray("─".repeat(40)))}};function S(o,e){const{shouldLog:l=!0,returnValue:t,callback:n}=e!=null?e:{},a=o instanceof Error?o:new Error(typeof o=="string"?o:"Unknown error");return l&&E.error(a.message),n&&typeof n=="function"&&n(a),t||{success:!1,message:a.message,code:g.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}exports.catchError=S;exports.log=E;exports.throwError=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("chalk"),e=require("consola"),h=require("graphql"),S=require("../../config/env/env.util.cjs"),g=require("../../constant/response-status.cjs"),R=S.getEnv();function d({message:o,status:r=g.RESPONSE_STATUS.INTERNAL_SERVER_ERROR,type:t="graphql"}){var l;const n=(l=o!=null?o:r.MESSAGE)!=null?l:"Internal server error";throw t==="graphql"?new h.GraphQLError(n,{extensions:{code:r.CODE}}):new Error(n)}R.DEBUG||(e.level=4);function s(o){const r=c[o];return typeof r=="function"?r:c.green}const i={silent:e.silent,level:e.level,fatal:e.fatal,error:e.error,warn:e.warn,log:e.log,info:e.info,success:e.success,ready:e.ready,start:e.start,box:e.box,debug:e.debug,trace:e.trace,verbose:e.verbose,printBoxedLog(o,r,t="red"){if(!(r!=null&&r.length)){e.box(c.green(o));return}r.forEach(({file:l,position:n,rule:a,message:u})=>{const E=n?`:${n}`:"",f=`${l}${E}`;e.log(`${c.gray("File:")} ${c.blue(f)}`),a&&e.log(` ${s(t)("Rule:")} ${a}`),e.log(` ${s(t)("Message:")} ${u}`)}),e.box(s(t)(`${o} : ${r.length}`)),e.log(c.gray("─".repeat(40)))}};function b(o,r){const{shouldLog:t=!0,returnValue:l,callback:n}=r!=null?r:{},a=o instanceof Error?o:new Error(typeof o=="string"?o:"Unknown error");return t&&i.error(a.message),n&&typeof n=="function"&&n(a),l||{success:!1,message:a.message,code:g.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}exports.catchError=b;exports.log=i;exports.throwError=d;
@@ -1,7 +1,35 @@
1
1
  import { I_Return } from '../../typescript/index.js';
2
- import { I_CatchErrorOptions, I_Log, T_ThrowError } from './log.type.js';
3
- export declare function throwError({ message, status, type, }: T_ThrowError): never;
2
+ import { I_CatchErrorOptions, I_Log, I_ThrowError } from './log.type.js';
3
+ /**
4
+ * Throws a standardized error with optional status information and type specification.
5
+ * This function creates and throws errors that can be either GraphQL errors (with extensions)
6
+ * or standard JavaScript errors, depending on the specified type.
7
+ *
8
+ * @param options - Error configuration including message, status information, and error type.
9
+ * @param options.message - The error message to display.
10
+ * @param options.status - The response status information (defaults to INTERNAL_SERVER_ERROR).
11
+ * @param options.type - The type of error to throw ('graphql' or 'rest', defaults to 'graphql').
12
+ * @throws {GraphQLError} When type is 'graphql', throws a GraphQL error with extensions.
13
+ * @throws {Error} When type is 'rest' or unspecified, throws a standard JavaScript error.
14
+ */
15
+ export declare function throwError({ message, status, type, }: I_ThrowError): never;
16
+ /**
17
+ * Enhanced logging interface that extends consola with custom functionality.
18
+ * This object provides all standard consola logging methods plus additional features
19
+ * like boxed log printing for structured error/warning display.
20
+ */
4
21
  export declare const log: I_Log;
22
+ /**
23
+ * Catches and handles errors with configurable behavior.
24
+ * This function provides a standardized way to handle errors with options for:
25
+ * - Logging control (whether to log the error)
26
+ * - Return value specification (what to return on error)
27
+ * - Custom callback execution (additional error handling)
28
+ *
29
+ * @param errorInput - The error to catch and handle.
30
+ * @param options - Configuration options for error handling behavior.
31
+ * @returns Either the specified return value or a standardized error response object.
32
+ */
5
33
  export declare function catchError<T = unknown>(errorInput: unknown, options: I_CatchErrorOptions & {
6
34
  returnValue: T;
7
35
  }): T;
@@ -1,26 +1,26 @@
1
1
  import c from "chalk";
2
2
  import r from "consola";
3
- import { GraphQLError as E } from "graphql";
4
- import { getEnv as i } from "../../config/env/env.util.js";
3
+ import { GraphQLError as u } from "graphql";
4
+ import { getEnv as h } from "../../config/env/env.util.js";
5
5
  import { RESPONSE_STATUS as s } from "../../constant/response-status.js";
6
- const u = i();
7
- function p({
6
+ const R = h();
7
+ function w({
8
8
  message: o,
9
9
  status: e = s.INTERNAL_SERVER_ERROR,
10
- type: l = "graphql"
10
+ type: t = "graphql"
11
11
  }) {
12
- var t;
13
- const n = (t = o != null ? o : e.MESSAGE) != null ? t : "Internal server error";
14
- throw l === "graphql" ? new E(n, {
12
+ var l;
13
+ const n = (l = o != null ? o : e.MESSAGE) != null ? l : "Internal server error";
14
+ throw t === "graphql" ? new u(n, {
15
15
  extensions: { code: e.CODE }
16
16
  }) : new Error(n);
17
17
  }
18
- u.DEBUG || (r.level = 4);
18
+ R.DEBUG || (r.level = 4);
19
19
  function f(o) {
20
20
  const e = c[o];
21
21
  return typeof e == "function" ? e : c.green;
22
22
  }
23
- const h = {
23
+ const m = {
24
24
  silent: r.silent,
25
25
  level: r.level,
26
26
  fatal: r.fatal,
@@ -35,26 +35,39 @@ const h = {
35
35
  debug: r.debug,
36
36
  trace: r.trace,
37
37
  verbose: r.verbose,
38
- printBoxedLog(o, e, l = "red") {
38
+ /**
39
+ * Prints a boxed log with structured issue information.
40
+ * This method displays issues (errors or warnings) in a formatted box with:
41
+ * - File paths and line/column positions
42
+ * - Rule violations (if applicable)
43
+ * - Error/warning messages
44
+ * - Color-coded output based on issue type
45
+ *
46
+ * @param title - The title to display in the box header.
47
+ * @param issues - An array of issue entries to display.
48
+ * @param color - The color to use for highlighting (defaults to 'red').
49
+ */
50
+ printBoxedLog(o, e, t = "red") {
39
51
  if (!(e != null && e.length)) {
40
52
  r.box(c.green(o));
41
53
  return;
42
54
  }
43
- e.forEach(({ file: t, position: n, rule: a, message: g }) => {
44
- r.log(`${c.gray("File:")} ${c.blue(`${t}${n ? `:${n}` : ""}`)}`), a && r.log(` ${f(l)("Rule:")} ${a}`), r.log(` ${f(l)("Message:")} ${g}`);
45
- }), r.box(f(l)(`${o} : ${e.length}`)), r.log(c.gray("".repeat(40)));
55
+ e.forEach(({ file: l, position: n, rule: a, message: g }) => {
56
+ const i = n ? `:${n}` : "", E = `${l}${i}`;
57
+ r.log(`${c.gray("File:")} ${c.blue(E)}`), a && r.log(` ${f(t)("Rule:")} ${a}`), r.log(` ${f(t)("Message:")} ${g}`);
58
+ }), r.box(f(t)(`${o} : ${e.length}`)), r.log(c.gray("─".repeat(40)));
46
59
  }
47
60
  };
48
- function v(o, e) {
49
- const { shouldLog: l = !0, returnValue: t, callback: n } = e != null ? e : {}, a = o instanceof Error ? o : new Error(typeof o == "string" ? o : "Unknown error");
50
- return l && h.error(a.message), n && typeof n == "function" && n(a), t || {
61
+ function S(o, e) {
62
+ const { shouldLog: t = !0, returnValue: l, callback: n } = e != null ? e : {}, a = o instanceof Error ? o : new Error(typeof o == "string" ? o : "Unknown error");
63
+ return t && m.error(a.message), n && typeof n == "function" && n(a), l || {
51
64
  success: !1,
52
65
  message: a.message,
53
66
  code: s.INTERNAL_SERVER_ERROR.CODE
54
67
  };
55
68
  }
56
69
  export {
57
- v as catchError,
58
- h as log,
59
- p as throwError
70
+ S as catchError,
71
+ m as log,
72
+ w as throwError
60
73
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./mongo.constant.cjs"),o=require("./mongo.type.cjs"),e=require("./mongo.util.cjs"),t=require("mongoose-aggregate-paginate-v2"),r=require("mongoose-paginate-v2");exports.MONGO_MIGRATE_OPTIONS=n.MONGO_MIGRATE_OPTIONS;exports.C_Collection=o.C_Collection;exports.C_Db=o.C_Db;exports.C_Document=o.C_Document;exports.C_Model=o.C_Model;exports.MongoController=e.MongoController;exports.MongooseController=e.MongooseController;exports.mongo=e.mongo;exports.aggregatePaginate=t;exports.mongoosePaginate=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./mongo.constant.cjs"),o=require("./mongo.type.cjs"),e=require("./mongo.util.cjs");exports.MONGO_MIGRATE_OPTIONS=n.MONGO_MIGRATE_OPTIONS;exports.C_Collection=o.C_Collection;exports.C_Db=o.C_Db;exports.C_Document=o.C_Document;exports.C_Model=o.C_Model;exports.MongoController=e.MongoController;exports.MongooseController=e.MongooseController;exports.mongo=e.mongo;
@@ -1,17 +1,13 @@
1
- import { MONGO_MIGRATE_OPTIONS as r } from "./mongo.constant.js";
2
- import { C_Collection as a, C_Db as n, C_Document as g, C_Model as l } from "./mongo.type.js";
3
- import { MongoController as f, MongooseController as C, mongo as _ } from "./mongo.util.js";
4
- import { default as x } from "mongoose-aggregate-paginate-v2";
5
- import { default as s } from "mongoose-paginate-v2";
1
+ import { MONGO_MIGRATE_OPTIONS as e } from "./mongo.constant.js";
2
+ import { C_Collection as n, C_Db as t, C_Document as C, C_Model as _ } from "./mongo.type.js";
3
+ import { MongoController as M, MongooseController as O, mongo as f } from "./mongo.util.js";
6
4
  export {
7
- a as C_Collection,
8
- n as C_Db,
9
- g as C_Document,
10
- l as C_Model,
11
- r as MONGO_MIGRATE_OPTIONS,
12
- f as MongoController,
13
- C as MongooseController,
14
- x as aggregatePaginate,
15
- _ as mongo,
16
- s as mongoosePaginate
5
+ n as C_Collection,
6
+ t as C_Db,
7
+ C as C_Document,
8
+ _ as C_Model,
9
+ e as MONGO_MIGRATE_OPTIONS,
10
+ M as MongoController,
11
+ O as MongooseController,
12
+ f as mongo
17
13
  };