@cyberskill/shared 3.2.0 → 3.3.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.
- package/dist/config/commitlint/index.js +8 -9
- package/dist/config/commitlint/index.js.map +1 -1
- package/dist/config/config.type.js +8 -5
- package/dist/config/config.type.js.map +1 -1
- package/dist/config/config.util.js +33 -42
- package/dist/config/config.util.js.map +1 -1
- package/dist/config/env/env.constant.js +6 -5
- package/dist/config/env/env.constant.js.map +1 -1
- package/dist/config/env/env.util.js +26 -27
- package/dist/config/env/env.util.js.map +1 -1
- package/dist/config/env/index.js +2 -7
- package/dist/config/eslint/index.js +23 -19
- package/dist/config/eslint/index.js.map +1 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.js +30 -38
- package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -1
- package/dist/config/graphql-codegen/index.js +2 -5
- package/dist/config/index.js +3 -7
- package/dist/config/lint-staged/index.js +8 -7
- package/dist/config/lint-staged/index.js.map +1 -1
- package/dist/config/storybook/index.js +2 -6
- package/dist/config/storybook/storybook.main.js +19 -18
- package/dist/config/storybook/storybook.main.js.map +1 -1
- package/dist/config/storybook/storybook.preview.js +31 -37
- package/dist/config/storybook/storybook.preview.js.map +1 -1
- package/dist/config/vitest/index.js +3 -7
- package/dist/config/vitest/vitest.e2e.js +14 -17
- package/dist/config/vitest/vitest.e2e.js.map +1 -1
- package/dist/config/vitest/vitest.unit.js +31 -32
- package/dist/config/vitest/vitest.unit.js.map +1 -1
- package/dist/constant/common.js +6 -5
- package/dist/constant/common.js.map +1 -1
- package/dist/constant/index.js +3 -7
- package/dist/constant/response-status.d.ts +186 -186
- package/dist/constant/response-status.js +254 -253
- package/dist/constant/response-status.js.map +1 -1
- package/dist/node/apollo-server/apollo-server.util.js +27 -29
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -1
- package/dist/node/apollo-server/index.js +2 -7
- package/dist/node/cli/index.js +112 -113
- package/dist/node/cli/index.js.map +1 -1
- package/dist/node/command/command.type.js +8 -5
- package/dist/node/command/command.type.js.map +1 -1
- package/dist/node/command/command.util.js +136 -149
- package/dist/node/command/command.util.js.map +1 -1
- package/dist/node/command/index.js +3 -12
- package/dist/node/express/express.type.d.ts +11 -0
- package/dist/node/express/express.type.js +2 -0
- package/dist/node/express/express.util.js +74 -65
- package/dist/node/express/express.util.js.map +1 -1
- package/dist/node/express/index.js +3 -14
- package/dist/node/fs/fs.util.js +27 -51
- package/dist/node/fs/fs.util.js.map +1 -1
- package/dist/node/fs/index.js +2 -19
- package/dist/node/log/index.js +2 -8
- package/dist/node/log/log.type.js +8 -5
- package/dist/node/log/log.type.js.map +1 -1
- package/dist/node/log/log.util.js +51 -68
- package/dist/node/log/log.util.js.map +1 -1
- package/dist/node/mongo/index.js +8 -26
- package/dist/node/mongo/mongo.constant.js +6 -6
- package/dist/node/mongo/mongo.constant.js.map +1 -1
- package/dist/node/mongo/mongo.controller.mongoose.d.ts +6 -1
- package/dist/node/mongo/mongo.controller.mongoose.js +333 -467
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -1
- package/dist/node/mongo/mongo.controller.native.js +153 -212
- package/dist/node/mongo/mongo.controller.native.js.map +1 -1
- package/dist/node/mongo/mongo.dynamic-populate.js +164 -192
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -1
- package/dist/node/mongo/mongo.populate.js +229 -262
- package/dist/node/mongo/mongo.populate.js.map +1 -1
- package/dist/node/mongo/mongo.type.js +8 -17
- package/dist/node/mongo/mongo.type.js.map +1 -1
- package/dist/node/mongo/mongo.util.js +134 -293
- package/dist/node/mongo/mongo.util.js.map +1 -1
- package/dist/node/package/index.js +3 -11
- package/dist/node/package/package.type.js +8 -5
- package/dist/node/package/package.type.js.map +1 -1
- package/dist/node/package/package.util.js +216 -225
- package/dist/node/package/package.util.js.map +1 -1
- package/dist/node/path/index.js +3 -58
- package/dist/node/path/path.constant.js +211 -298
- package/dist/node/path/path.constant.js.map +1 -1
- package/dist/node/path/path.util.js +13 -16
- package/dist/node/path/path.util.js.map +1 -1
- package/dist/node/storage/index.js +3 -10
- package/dist/node/storage/storage.constant.js +6 -8
- package/dist/node/storage/storage.constant.js.map +1 -1
- package/dist/node/storage/storage.util.js +127 -178
- package/dist/node/storage/storage.util.js.map +1 -1
- package/dist/node/upload/index.js +4 -16
- package/dist/node/upload/upload.constant.js +58 -32
- package/dist/node/upload/upload.constant.js.map +1 -1
- package/dist/node/upload/upload.type.js +8 -5
- package/dist/node/upload/upload.type.js.map +1 -1
- package/dist/node/upload/upload.util.js +125 -137
- package/dist/node/upload/upload.util.js.map +1 -1
- package/dist/node/ws/index.js +2 -6
- package/dist/node/ws/ws.type.d.ts +7 -8
- package/dist/node/ws/ws.util.js +46 -44
- package/dist/node/ws/ws.util.js.map +1 -1
- package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.0_@noble_hashes@1.8.0__vite@8.0.0_@types_nod_53aa4254f295b3c40bb8f17b6ab226b5/node_modules/vitest/dist/config.js +8 -0
- package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.0_@noble_hashes@1.8.0__vite@8.0.0_@types_nod_53aa4254f295b3c40bb8f17b6ab226b5/node_modules/vitest/dist/config.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.component.js +16 -18
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.constant.js +6 -5
- package/dist/react/apollo-client/apollo-client.constant.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.context.js +10 -13
- package/dist/react/apollo-client/apollo-client.context.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.module.scss.js +8 -7
- package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.util.js +57 -75
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -1
- package/dist/react/apollo-client/index.js +7 -30
- package/dist/react/apollo-client/links/index.js +2 -5
- package/dist/react/apollo-client/links/upload.js +63 -107
- package/dist/react/apollo-client/links/upload.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +14 -16
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +8 -7
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +14 -14
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -1
- package/dist/react/apollo-client-nextjs/index.js +3 -7
- package/dist/react/apollo-error/apollo-error.component.js +57 -69
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.context.js +7 -6
- package/dist/react/apollo-error/apollo-error.context.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.hook.js +10 -10
- package/dist/react/apollo-error/apollo-error.hook.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.module.scss.js +15 -11
- package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.provider.js +31 -25
- package/dist/react/apollo-error/apollo-error.provider.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.util.js +14 -16
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -1
- package/dist/react/apollo-error/index.js +5 -15
- package/dist/react/i18next/i18next.hook.js +7 -6
- package/dist/react/i18next/i18next.hook.js.map +1 -1
- package/dist/react/i18next/i18next.util.js +9 -8
- package/dist/react/i18next/i18next.util.js.map +1 -1
- package/dist/react/i18next/index.js +3 -7
- package/dist/react/loading/index.js +3 -9
- package/dist/react/loading/loading.component.js +47 -48
- package/dist/react/loading/loading.component.js.map +1 -1
- package/dist/react/loading/loading.context.js +7 -6
- package/dist/react/loading/loading.context.js.map +1 -1
- package/dist/react/loading/loading.hook.js +11 -11
- package/dist/react/loading/loading.hook.js.map +1 -1
- package/dist/react/loading/loading.module.scss.js +18 -15
- package/dist/react/loading/loading.module.scss.js.map +1 -1
- package/dist/react/loading/loading.provider.js +26 -18
- package/dist/react/loading/loading.provider.js.map +1 -1
- package/dist/react/log/index.js +2 -6
- package/dist/react/log/log.util.d.ts +8 -0
- package/dist/react/log/log.util.js +33 -29
- package/dist/react/log/log.util.js.map +1 -1
- package/dist/react/next-intl/index.js +6 -14
- package/dist/react/next-intl/next-intl.constant.js +16 -15
- package/dist/react/next-intl/next-intl.constant.js.map +1 -1
- package/dist/react/next-intl/next-intl.context.js +7 -6
- package/dist/react/next-intl/next-intl.context.js.map +1 -1
- package/dist/react/next-intl/next-intl.hoc.js +20 -23
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -1
- package/dist/react/next-intl/next-intl.hook.js +13 -14
- package/dist/react/next-intl/next-intl.hook.js.map +1 -1
- package/dist/react/next-intl/next-intl.provider.js +28 -23
- package/dist/react/next-intl/next-intl.provider.js.map +1 -1
- package/dist/react/storage/index.js +3 -7
- package/dist/react/storage/storage.hook.js +61 -58
- package/dist/react/storage/storage.hook.js.map +1 -1
- package/dist/react/storage/storage.util.js +36 -68
- package/dist/react/storage/storage.util.js.map +1 -1
- package/dist/react/toast/index.js +2 -6
- package/dist/react/userback/index.js +2 -5
- package/dist/react/userback/userback.component.js +27 -27
- package/dist/react/userback/userback.component.js.map +1 -1
- package/dist/style.css +2 -1
- package/dist/typescript/common.type.js +8 -5
- package/dist/typescript/common.type.js.map +1 -1
- package/dist/typescript/index.js +2 -5
- package/dist/util/common/common.util.js +119 -48
- package/dist/util/common/common.util.js.map +1 -1
- package/dist/util/common/index.js +2 -9
- package/dist/util/index.js +6 -27
- package/dist/util/object/index.d.ts +3 -0
- package/dist/util/object/index.js +2 -10
- package/dist/util/object/object.util.js +94 -128
- package/dist/util/object/object.util.js.map +1 -1
- package/dist/util/serializer/index.js +2 -5
- package/dist/util/serializer/serializer.util.js +73 -78
- package/dist/util/serializer/serializer.util.js.map +1 -1
- package/dist/util/string/index.d.ts +3 -0
- package/dist/util/string/index.js +2 -10
- package/dist/util/string/string.util.js +59 -71
- package/dist/util/string/string.util.js.map +1 -1
- package/dist/util/validate/index.d.ts +3 -0
- package/dist/util/validate/index.js +2 -5
- package/dist/util/validate/validate.util.js +13 -39
- package/dist/util/validate/validate.util.js.map +1 -1
- package/package.json +29 -27
- package/dist/config/env/index.js.map +0 -1
- package/dist/config/graphql-codegen/index.js.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/config/storybook/index.js.map +0 -1
- package/dist/config/vitest/index.js.map +0 -1
- package/dist/constant/index.js.map +0 -1
- package/dist/node/apollo-server/index.js.map +0 -1
- package/dist/node/command/index.js.map +0 -1
- package/dist/node/express/index.js.map +0 -1
- package/dist/node/fs/index.js.map +0 -1
- package/dist/node/log/index.js.map +0 -1
- package/dist/node/mongo/index.js.map +0 -1
- package/dist/node/package/index.js.map +0 -1
- package/dist/node/path/index.js.map +0 -1
- package/dist/node/storage/index.js.map +0 -1
- package/dist/node/upload/index.js.map +0 -1
- package/dist/node/ws/index.js.map +0 -1
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js +0 -7
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js.map +0 -1
- package/dist/react/apollo-client/index.js.map +0 -1
- package/dist/react/apollo-client/links/index.js.map +0 -1
- package/dist/react/apollo-client-nextjs/index.js.map +0 -1
- package/dist/react/apollo-error/index.js.map +0 -1
- package/dist/react/i18next/index.js.map +0 -1
- package/dist/react/loading/index.js.map +0 -1
- package/dist/react/log/index.js.map +0 -1
- package/dist/react/next-intl/index.js.map +0 -1
- package/dist/react/storage/index.js.map +0 -1
- package/dist/react/toast/index.js.map +0 -1
- package/dist/react/userback/index.js.map +0 -1
- package/dist/typescript/index.js.map +0 -1
- package/dist/util/common/index.js.map +0 -1
- package/dist/util/index.js.map +0 -1
- package/dist/util/object/index.js.map +0 -1
- package/dist/util/serializer/index.js.map +0 -1
- package/dist/util/string/index.js.map +0 -1
- package/dist/util/validate/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.util.js","sources":["../../../src/node/express/express.util.ts"],"sourcesContent":["import type { INestApplication } from '@nestjs/common';\nimport type { Application, RequestHandler } from 'express';\nimport type { SessionOptions } from 'express-session';\n\nimport { NestFactory } from '@nestjs/core';\nimport bodyParser from 'body-parser';\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport cors from 'cors';\nimport express from 'express';\nimport session from 'express-session';\nimport { express as useragent } from 'express-useragent';\nimport graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs';\nimport helmet from 'helmet';\nimport process from 'node:process';\n\nimport type { I_ExpressOptions, I_NestOptions, T_CorsOptions, T_CorsType } from './express.type.js';\n\n/**\n * Creates CORS options with environment-specific configuration.\n * This function generates CORS options based on the development environment,\n * including whitelist configuration for allowed origins.\n *\n * @param options - CORS configuration options.\n * @param options.isDev - Whether the application is running in development mode.\n * @param options.whiteList - Array of allowed origins for CORS requests.\n * @returns CORS options object configured for the specified environment.\n */\nexport function createCorsOptions<T extends T_CorsType>({ isDev, whiteList, ...rest }: T_CorsOptions<T>) {\n return {\n origin: (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => {\n if (isDev || !origin || whiteList?.includes(origin ?? '')) {\n callback(null, true);\n }\n else {\n callback(new Error('Not allowed by CORS'), false);\n }\n },\n credentials: true,\n ...rest,\n };\n}\n\n/**\n * Creates a CORS middleware function with the specified configuration.\n * This function creates a CORS middleware that can be used with both Express and NestJS applications,\n * applying the configured CORS options for origin validation and credential handling.\n *\n * @param options - CORS configuration options to apply to the middleware.\n * @returns A CORS middleware function ready to be used in Express or NestJS applications.\n */\nexport function createCors<T extends T_CorsType>(options: T_CorsOptions<T>) {\n return cors<cors.CorsRequest>(createCorsOptions(options));\n}\n\n/**\n * Creates a session middleware function with the specified configuration.\n * This function creates an Express session middleware that can be used to handle user sessions\n * with the provided session options including secret, cookie settings, and storage configuration.\n *\n * @param options - Session configuration options including secret, cookie settings, and storage.\n * @returns A session middleware function ready to be used in Express applications.\n */\nexport function createSession(options: SessionOptions): RequestHandler {\n const secureDefaults: Partial<SessionOptions> = {\n resave: false,\n saveUninitialized: false,\n cookie: {\n httpOnly: true,\n sameSite: 'lax',\n secure: process.env['NODE_ENV'] === 'production',\n },\n };\n\n return session({\n ...secureDefaults,\n ...options,\n cookie: { ...secureDefaults.cookie, ...options.cookie },\n });\n}\n\n/**\n * Sets up common middleware for Express applications.\n * This function configures essential middleware including:\n * - Trust proxy settings for proper IP handling\n * - Cookie parsing for request cookies\n * - URL-encoded body parsing for form data\n * - Compression for response optimization\n * - User agent parsing for device/browser detection\n *\n * @param app - The Express application instance to configure with middleware.\n */\nfunction setupMiddleware(app: Application, isDev = false, jsonLimit = '1mb') {\n app.set('trust proxy', 1);\n app.use(\n helmet({\n crossOriginEmbedderPolicy: isDev ? false : undefined,\n contentSecurityPolicy: isDev ? false : undefined,\n }),\n );\n app.use(cookieParser());\n app.use(express.json({ limit: jsonLimit }));\n app.use(express.urlencoded({ extended: true, limit: jsonLimit }));\n app.use(compression());\n app.use(useragent());\n}\n\n/**\n * Sets up static file serving for Express applications.\n * This function configures static file serving for the specified folders,\n * making files in those directories accessible via HTTP requests.\n *\n * @param app - The Express application instance to configure with static file serving.\n * @param staticFolders - A string or array of strings representing the paths to serve statically.\n */\nfunction setupStaticFolders(app: Application, staticFolders?: string | string[]) {\n if (staticFolders) {\n const statics = Array.isArray(staticFolders) ? staticFolders : [staticFolders];\n statics.forEach((folder) => {\n app.use(`/${folder}`, express.static(folder));\n });\n }\n}\n\n/**\n * Creates and configures an Express application with common middleware and settings.\n * This function sets up a complete Express application with:\n * - Essential middleware (cookies, body parsing, compression, user agent)\n * - Static file serving for specified folders\n * - GraphQL upload support for file uploads\n *\n * @param options - Optional configuration for the Express application including static folder paths.\n * @returns A configured Express application instance ready for use.\n */\nexport function createExpress(options?: I_ExpressOptions): Application {\n const app = express();\n\n setupMiddleware(app, options?.isDev, options?.jsonLimit);\n setupStaticFolders(app, options?.static);\n app.use(graphqlUploadExpress({\n maxFileSize: options?.maxFileSize ?? 10_000_000,\n maxFiles: options?.maxFiles ?? 10,\n }));\n\n return app;\n}\n\n/**\n * Creates and configures a NestJS application with Express integration.\n * This function sets up a NestJS application with:\n * - Express HTTP adapter configuration\n * - Common middleware (cookies, body parsing, compression, user agent)\n * - Static file serving for specified folders\n * - Global filters and pipes if provided\n *\n * @param options - Configuration options for the NestJS application including module, static folders, filters, and pipes.\n * @returns A promise that resolves to a configured NestJS application instance.\n */\nexport async function createNest(options: I_NestOptions): Promise<INestApplication> {\n const app = await NestFactory.create(options.module);\n\n setupMiddleware(app.getHttpAdapter().getInstance(), options.isDev, options.jsonLimit);\n setupStaticFolders(app.getHttpAdapter().getInstance(), options.static);\n\n if (options.filters) {\n app.useGlobalFilters(...options.filters);\n }\n\n if (options.pipes) {\n app.useGlobalPipes(...options.pipes);\n }\n\n return app;\n}\n\nexport { bodyParser, express };\n"],"names":["createCorsOptions","isDev","whiteList","rest","origin","callback","createCors","options","cors","createSession","secureDefaults","process","session","setupMiddleware","app","jsonLimit","helmet","cookieParser","express","compression","useragent","setupStaticFolders","staticFolders","folder","createExpress","graphqlUploadExpress","createNest","NestFactory"],"mappings":";;;;;;;;;;;AA4BO,SAASA,EAAwC,EAAE,OAAAC,GAAO,WAAAC,GAAW,GAAGC,KAA0B;AACrG,SAAO;AAAA,IACH,QAAQ,CAACC,GAA4BC,MAA2D;AAC5F,MAAIJ,KAAS,CAACG,KAAUF,GAAW,SAASE,KAAU,EAAE,IACpDC,EAAS,MAAM,EAAI,IAGnBA,EAAS,IAAI,MAAM,qBAAqB,GAAG,EAAK;AAAA,IAExD;AAAA,IACA,aAAa;AAAA,IACb,GAAGF;AAAA,EAAA;AAEX;AAUO,SAASG,EAAiCC,GAA2B;AACxE,SAAOC,EAAuBR,EAAkBO,CAAO,CAAC;AAC5D;AAUO,SAASE,EAAcF,GAAyC;AACnE,QAAMG,IAA0C;AAAA,IAC5C,QAAQ;AAAA,IACR,mBAAmB;AAAA,IACnB,QAAQ;AAAA,MACJ,UAAU;AAAA,MACV,UAAU;AAAA,MACV,QAAQC,EAAQ,IAAI,aAAgB;AAAA,IAAA;AAAA,EACxC;AAGJ,SAAOC,EAAQ;AAAA,IACX,GAAGF;AAAA,IACH,GAAGH;AAAA,IACH,QAAQ,EAAE,GAAGG,EAAe,QAAQ,GAAGH,EAAQ,OAAA;AAAA,EAAO,CACzD;AACL;AAaA,SAASM,EAAgBC,GAAkBb,IAAQ,IAAOc,IAAY,OAAO;AACzE,EAAAD,EAAI,IAAI,eAAe,CAAC,GACxBA,EAAI;AAAA,IACAE,EAAO;AAAA,MACH,2BAA2Bf,IAAQ,KAAQ;AAAA,MAC3C,uBAAuBA,IAAQ,KAAQ;AAAA,IAAA,CAC1C;AAAA,EAAA,GAELa,EAAI,IAAIG,GAAc,GACtBH,EAAI,IAAII,EAAQ,KAAK,EAAE,OAAOH,EAAA,CAAW,CAAC,GAC1CD,EAAI,IAAII,EAAQ,WAAW,EAAE,UAAU,IAAM,OAAOH,EAAA,CAAW,CAAC,GAChED,EAAI,IAAIK,GAAa,GACrBL,EAAI,IAAIM,GAAW;AACvB;AAUA,SAASC,EAAmBP,GAAkBQ,GAAmC;AAC7E,EAAIA,MACgB,MAAM,QAAQA,CAAa,IAAIA,IAAgB,CAACA,CAAa,GACrE,QAAQ,CAACC,MAAW;AACxB,IAAAT,EAAI,IAAI,IAAIS,CAAM,IAAIL,EAAQ,OAAOK,CAAM,CAAC;AAAA,EAChD,CAAC;AAET;AAYO,SAASC,EAAcjB,GAAyC;AACnE,QAAMO,IAAMI,EAAA;AAEZ,SAAAL,EAAgBC,GAAKP,GAAS,OAAOA,GAAS,SAAS,GACvDc,EAAmBP,GAAKP,GAAS,MAAM,GACvCO,EAAI,IAAIW,EAAqB;AAAA,IACzB,aAAalB,GAAS,eAAe;AAAA,IACrC,UAAUA,GAAS,YAAY;AAAA,EAAA,CAClC,CAAC,GAEKO;AACX;AAaA,eAAsBY,EAAWnB,GAAmD;AAChF,QAAMO,IAAM,MAAMa,EAAY,OAAOpB,EAAQ,MAAM;AAEnD,SAAAM,EAAgBC,EAAI,iBAAiB,YAAA,GAAeP,EAAQ,OAAOA,EAAQ,SAAS,GACpFc,EAAmBP,EAAI,eAAA,EAAiB,YAAA,GAAeP,EAAQ,MAAM,GAEjEA,EAAQ,WACRO,EAAI,iBAAiB,GAAGP,EAAQ,OAAO,GAGvCA,EAAQ,SACRO,EAAI,eAAe,GAAGP,EAAQ,KAAK,GAGhCO;AACX;"}
|
|
1
|
+
{"version":3,"file":"express.util.js","names":[],"sources":["../../../src/node/express/express.util.ts"],"sourcesContent":["import type { INestApplication } from '@nestjs/common';\nimport type { Application, RequestHandler } from 'express';\nimport type { SessionOptions } from 'express-session';\n\nimport { NestFactory } from '@nestjs/core';\nimport bodyParser from 'body-parser';\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport cors from 'cors';\nimport express from 'express';\nimport rateLimit from 'express-rate-limit';\nimport session from 'express-session';\nimport { express as useragent } from 'express-useragent';\nimport graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs';\nimport helmet from 'helmet';\nimport process from 'node:process';\n\nimport type { I_ExpressOptions, I_NestOptions, T_CorsOptions, T_CorsType } from './express.type.js';\n\n/**\n * Creates CORS options with environment-specific configuration.\n * This function generates CORS options based on the development environment,\n * including whitelist configuration for allowed origins.\n *\n * @param options - CORS configuration options.\n * @param options.isDev - Whether the application is running in development mode.\n * @param options.whiteList - Array of allowed origins for CORS requests.\n * @returns CORS options object configured for the specified environment.\n */\nexport function createCorsOptions<T extends T_CorsType>({ isDev, whiteList, ...rest }: T_CorsOptions<T>) {\n return {\n origin: (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => {\n if (isDev || !origin || whiteList?.includes(origin ?? '')) {\n callback(null, true);\n }\n else {\n callback(new Error('Not allowed by CORS'), false);\n }\n },\n credentials: true,\n ...rest,\n };\n}\n\n/**\n * Creates a CORS middleware function with the specified configuration.\n * This function creates a CORS middleware that can be used with both Express and NestJS applications,\n * applying the configured CORS options for origin validation and credential handling.\n *\n * @param options - CORS configuration options to apply to the middleware.\n * @returns A CORS middleware function ready to be used in Express or NestJS applications.\n */\nexport function createCors<T extends T_CorsType>(options: T_CorsOptions<T>) {\n return cors<cors.CorsRequest>(createCorsOptions(options));\n}\n\n/**\n * Creates a session middleware function with the specified configuration.\n * This function creates an Express session middleware that can be used to handle user sessions\n * with the provided session options including secret, cookie settings, and storage configuration.\n *\n * @param options - Session configuration options including secret, cookie settings, and storage.\n * @returns A session middleware function ready to be used in Express applications.\n */\nexport function createSession(options: SessionOptions): RequestHandler {\n if (!options.secret) {\n throw new Error('Session secret is required. Provide a strong secret string.');\n }\n\n const secureDefaults: Partial<SessionOptions> = {\n resave: false,\n saveUninitialized: false,\n cookie: {\n httpOnly: true,\n sameSite: 'lax',\n secure: process.env['NODE_ENV'] === 'production',\n },\n };\n\n return session({\n ...secureDefaults,\n ...options,\n cookie: { ...secureDefaults.cookie, ...options.cookie },\n });\n}\n\n/**\n * Sets up common middleware for Express applications.\n * This function configures essential middleware including:\n * - Trust proxy settings for proper IP handling\n * - Cookie parsing for request cookies\n * - URL-encoded body parsing for form data\n * - Compression for response optimization\n * - User agent parsing for device/browser detection\n *\n * @param app - The Express application instance to configure with middleware.\n * @param isDev - Whether the application is running in development mode.\n * @param jsonLimit - Maximum request body size for JSON payloads.\n * @param trustProxy - Trust proxy setting; pass a truthy value to enable.\n * @param rateLimitOptions - Rate limit configuration, or `false` to disable.\n */\nfunction setupMiddleware(\n app: Application,\n isDev = false,\n jsonLimit = '1mb',\n trustProxy: boolean | number | string | string[] = false,\n rateLimitOptions: false | import('./express.type.js').I_RateLimitOptions = {},\n) {\n if (trustProxy !== false) {\n app.set('trust proxy', trustProxy);\n }\n app.use(\n helmet({\n crossOriginEmbedderPolicy: isDev ? false : undefined,\n contentSecurityPolicy: isDev ? false : undefined,\n }),\n );\n if (rateLimitOptions !== false) {\n app.use(\n rateLimit({\n windowMs: rateLimitOptions.windowMs ?? 15 * 60 * 1000,\n limit: rateLimitOptions.limit ?? 1000,\n standardHeaders: true,\n legacyHeaders: false,\n ...(rateLimitOptions.store !== undefined && { store: rateLimitOptions.store }),\n ...(rateLimitOptions.skip !== undefined && { skip: rateLimitOptions.skip }),\n }),\n );\n }\n app.use(cookieParser());\n app.use(express.json({ limit: jsonLimit }));\n app.use(express.urlencoded({ extended: true, limit: jsonLimit }));\n app.use(compression());\n app.use(useragent());\n}\n\n/**\n * Sets up static file serving for Express applications.\n * This function configures static file serving for the specified folders,\n * making files in those directories accessible via HTTP requests.\n *\n * @param app - The Express application instance to configure with static file serving.\n * @param staticFolders - A string or array of strings representing the paths to serve statically.\n */\nfunction setupStaticFolders(app: Application, staticFolders?: string | string[]) {\n if (staticFolders) {\n const statics = Array.isArray(staticFolders) ? staticFolders : [staticFolders];\n statics.forEach((folder) => {\n app.use(`/${folder}`, express.static(folder));\n });\n }\n}\n\n/**\n * Creates and configures an Express application with common middleware and settings.\n * This function sets up a complete Express application with:\n * - Essential middleware (cookies, body parsing, compression, user agent)\n * - Static file serving for specified folders\n * - GraphQL upload support for file uploads\n *\n * @param options - Optional configuration for the Express application including static folder paths.\n * @returns A configured Express application instance ready for use.\n */\nexport function createExpress(options?: I_ExpressOptions): Application {\n const app = express();\n\n setupMiddleware(app, options?.isDev, options?.jsonLimit, options?.trustProxy, options?.rateLimit);\n setupStaticFolders(app, options?.static);\n app.use(graphqlUploadExpress({\n maxFileSize: options?.maxFileSize ?? 10_000_000,\n maxFiles: options?.maxFiles ?? 10,\n }));\n\n return app;\n}\n\n/**\n * Creates and configures a NestJS application with Express integration.\n * This function sets up a NestJS application with:\n * - Express HTTP adapter configuration\n * - Common middleware (cookies, body parsing, compression, user agent)\n * - Static file serving for specified folders\n * - Global filters and pipes if provided\n *\n * @param options - Configuration options for the NestJS application including module, static folders, filters, and pipes.\n * @returns A promise that resolves to a configured NestJS application instance.\n */\nexport async function createNest(options: I_NestOptions): Promise<INestApplication> {\n const app = await NestFactory.create(options.module);\n\n setupMiddleware(app.getHttpAdapter().getInstance(), options.isDev, options.jsonLimit, options.trustProxy, options.rateLimit);\n setupStaticFolders(app.getHttpAdapter().getInstance(), options.static);\n\n if (options.filters) {\n app.useGlobalFilters(...options.filters);\n }\n\n if (options.pipes) {\n app.useGlobalPipes(...options.pipes);\n }\n\n return app;\n}\n\nexport { bodyParser, express };\n"],"mappings":";;;;;;;;;;;;;AA6BA,SAAgB,EAAwC,EAAE,UAAO,cAAW,GAAG,KAA0B;AACrG,QAAO;EACH,SAAS,GAA4B,MAA2D;AAC5F,GAAI,KAAS,CAAC,KAAU,GAAW,SAAS,KAAU,GAAG,GACrD,EAAS,MAAM,GAAK,GAGpB,EAAS,gBAAI,MAAM,sBAAsB,EAAE,GAAM;;EAGzD,aAAa;EACb,GAAG;EACN;;AAWL,SAAgB,EAAiC,GAA2B;AACxE,QAAO,EAAuB,EAAkB,EAAQ,CAAC;;AAW7D,SAAgB,EAAc,GAAyC;AACnE,KAAI,CAAC,EAAQ,OACT,OAAU,MAAM,8DAA8D;CAGlF,IAAM,IAA0C;EAC5C,QAAQ;EACR,mBAAmB;EACnB,QAAQ;GACJ,UAAU;GACV,UAAU;GACV,QAAQ,EAAQ,IAAI,aAAgB;GACvC;EACJ;AAED,QAAO,EAAQ;EACX,GAAG;EACH,GAAG;EACH,QAAQ;GAAE,GAAG,EAAe;GAAQ,GAAG,EAAQ;GAAQ;EAC1D,CAAC;;AAkBN,SAAS,EACL,GACA,IAAQ,IACR,IAAY,OACZ,IAAmD,IACnD,IAA2E,EAAE,EAC/E;AA0BE,CAzBI,MAAe,MACf,EAAI,IAAI,eAAe,EAAW,EAEtC,EAAI,IACA,EAAO;EACH,2BAA2B,IAAQ,KAAQ,KAAA;EAC3C,uBAAuB,IAAQ,KAAQ,KAAA;EAC1C,CAAC,CACL,EACG,MAAqB,MACrB,EAAI,IACA,EAAU;EACN,UAAU,EAAiB,YAAY,MAAU;EACjD,OAAO,EAAiB,SAAS;EACjC,iBAAiB;EACjB,eAAe;EACf,GAAI,EAAiB,UAAU,KAAA,KAAa,EAAE,OAAO,EAAiB,OAAO;EAC7E,GAAI,EAAiB,SAAS,KAAA,KAAa,EAAE,MAAM,EAAiB,MAAM;EAC7E,CAAC,CACL,EAEL,EAAI,IAAI,GAAc,CAAC,EACvB,EAAI,IAAI,EAAQ,KAAK,EAAE,OAAO,GAAW,CAAC,CAAC,EAC3C,EAAI,IAAI,EAAQ,WAAW;EAAE,UAAU;EAAM,OAAO;EAAW,CAAC,CAAC,EACjE,EAAI,IAAI,GAAa,CAAC,EACtB,EAAI,IAAI,GAAW,CAAC;;AAWxB,SAAS,EAAmB,GAAkB,GAAmC;AAC7E,CAAI,MACgB,MAAM,QAAQ,EAAc,GAAG,IAAgB,CAAC,EAAc,EACtE,SAAS,MAAW;AACxB,IAAI,IAAI,IAAI,KAAU,EAAQ,OAAO,EAAO,CAAC;GAC/C;;AAcV,SAAgB,EAAc,GAAyC;CACnE,IAAM,IAAM,GAAS;AASrB,QAPA,EAAgB,GAAK,GAAS,OAAO,GAAS,WAAW,GAAS,YAAY,GAAS,UAAU,EACjG,EAAmB,GAAK,GAAS,OAAO,EACxC,EAAI,IAAI,EAAqB;EACzB,aAAa,GAAS,eAAe;EACrC,UAAU,GAAS,YAAY;EAClC,CAAC,CAAC,EAEI;;AAcX,eAAsB,EAAW,GAAmD;CAChF,IAAM,IAAM,MAAM,EAAY,OAAO,EAAQ,OAAO;AAapD,QAXA,EAAgB,EAAI,gBAAgB,CAAC,aAAa,EAAE,EAAQ,OAAO,EAAQ,WAAW,EAAQ,YAAY,EAAQ,UAAU,EAC5H,EAAmB,EAAI,gBAAgB,CAAC,aAAa,EAAE,EAAQ,OAAO,EAElE,EAAQ,WACR,EAAI,iBAAiB,GAAG,EAAQ,QAAQ,EAGxC,EAAQ,SACR,EAAI,eAAe,GAAG,EAAQ,MAAM,EAGjC"}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
f as Router,
|
|
6
|
-
m as bodyParser,
|
|
7
|
-
s as createCors,
|
|
8
|
-
t as createCorsOptions,
|
|
9
|
-
o as createExpress,
|
|
10
|
-
a as createNest,
|
|
11
|
-
p as createSession,
|
|
12
|
-
x as express
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { Router as e } from "./express.type.js";
|
|
2
|
+
import { bodyParser as t, createCors as n, createCorsOptions as r, createExpress as i, createNest as a, createSession as o, express as s } from "./express.util.js";
|
|
3
|
+
export { e as Router, t as bodyParser, n as createCors, r as createCorsOptions, i as createExpress, a as createNest, o as createSession, s as express };
|
package/dist/node/fs/fs.util.js
CHANGED
|
@@ -1,57 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readFileSync: f,
|
|
8
|
-
unlinkSync: F,
|
|
9
|
-
statSync: S,
|
|
10
|
-
createWriteStream: v
|
|
11
|
-
} = c, g = c.readJsonSync;
|
|
12
|
-
function u(n, t, e) {
|
|
13
|
-
c.writeFileSync(n, t, e ?? "utf-8");
|
|
1
|
+
import e from "fs-extra";
|
|
2
|
+
import t from "node:path";
|
|
3
|
+
//#region src/node/fs/fs.util.ts
|
|
4
|
+
var n = e, { lstatSync: r, readdirSync: i, mkdirSync: a, readFileSync: o, unlinkSync: s, statSync: c, createWriteStream: l } = e, u = e.readJsonSync;
|
|
5
|
+
function d(t, n, r) {
|
|
6
|
+
e.writeFileSync(t, n, r ?? "utf-8");
|
|
14
7
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
8
|
+
function f(t, n, r) {
|
|
9
|
+
e.appendFileSync(t, n, r ?? "utf-8");
|
|
17
10
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
11
|
+
function p(...t) {
|
|
12
|
+
return t.every((t) => e.pathExistsSync(t));
|
|
20
13
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
function m(...t) {
|
|
15
|
+
t.forEach((t) => {
|
|
16
|
+
p(t) && e.removeSync(t);
|
|
17
|
+
});
|
|
25
18
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
function h(n, r, i = {}) {
|
|
20
|
+
let { extensions: a, ...o } = i;
|
|
21
|
+
e.copySync(n, r, {
|
|
22
|
+
filter: (e) => c(e).isDirectory() || !a || a.length === 0 ? !0 : a.includes(t.extname(e)),
|
|
23
|
+
...o
|
|
24
|
+
});
|
|
32
25
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
`;
|
|
37
|
-
o(n) ? f(n, "utf-8").split(`
|
|
38
|
-
`).includes(t) || p(n, e) : u(n, e);
|
|
26
|
+
function g(e, t) {
|
|
27
|
+
let n = `\n${t}\n`;
|
|
28
|
+
p(e) ? o(e, "utf-8").split("\n").includes(t) || f(e, n) : d(e, n);
|
|
39
29
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
v as createWriteStream,
|
|
45
|
-
l as fs,
|
|
46
|
-
m as lstatSync,
|
|
47
|
-
E as mkdirSync,
|
|
48
|
-
o as pathExistsSync,
|
|
49
|
-
f as readFileSync,
|
|
50
|
-
g as readJsonSync,
|
|
51
|
-
x as readdirSync,
|
|
52
|
-
k as removeSync,
|
|
53
|
-
S as statSync,
|
|
54
|
-
F as unlinkSync,
|
|
55
|
-
u as writeFileSync
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=fs.util.js.map
|
|
30
|
+
//#endregion
|
|
31
|
+
export { g as addGitIgnoreEntry, f as appendFileSync, h as copySync, l as createWriteStream, n as fs, r as lstatSync, a as mkdirSync, p as pathExistsSync, o as readFileSync, u as readJsonSync, i as readdirSync, m as removeSync, c as statSync, s as unlinkSync, d as writeFileSync };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=fs.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.util.js","sources":["../../../src/node/fs/fs.util.ts"],"sourcesContent":["import fsExtra from 'fs-extra';\nimport path from 'node:path';\n\nimport type { I_CopySyncOptions } from './fs.type.js';\n\n/**\n * Re-export of the fs-extra module for file system operations.\n */\nexport const fs = fsExtra;\n\nexport const {\n lstatSync,\n readdirSync,\n mkdirSync,\n readFileSync,\n unlinkSync,\n statSync,\n createWriteStream,\n} = fsExtra;\n\nexport const readJsonSync: typeof fsExtra.readJsonSync = fsExtra.readJsonSync;\n\n/**\n * Writes data to a file synchronously with UTF-8 encoding as default.\n * This function provides a simplified interface for writing files with automatic UTF-8 encoding\n * when no specific options are provided.\n *\n * @param file - The file path or file descriptor to write to.\n * @param data - The data to write to the file (string or Uint8Array).\n * @param options - Optional write file options (defaults to UTF-8 encoding).\n */\nexport function writeFileSync(file: fsExtra.PathOrFileDescriptor, data: string | Uint8Array, options?: fsExtra.WriteFileOptions): void {\n fsExtra.writeFileSync(file, data, options ?? 'utf-8');\n}\n\n/**\n * Appends data to a file synchronously with UTF-8 encoding as default.\n * This function provides a simplified interface for appending to files with automatic UTF-8 encoding\n * when no specific options are provided.\n *\n * @param path - The file path or file descriptor to append to.\n * @param data - The data to append to the file (string or Uint8Array).\n * @param options - Optional write file options (defaults to UTF-8 encoding).\n */\nexport function appendFileSync(path: fsExtra.PathOrFileDescriptor, data: string | Uint8Array, options?: fsExtra.WriteFileOptions): void {\n fsExtra.appendFileSync(path, data, options ?? 'utf-8');\n}\n\n/**\n * Checks if all specified paths exist synchronously.\n * This function verifies that every path in the provided array exists in the file system.\n * Returns true only if all paths exist, false if any path is missing.\n *\n * @param paths - An array of file or directory paths to check for existence.\n * @returns True if all paths exist, false if any path is missing.\n */\nexport function pathExistsSync(...paths: string[]) {\n return paths.every(path => fsExtra.pathExistsSync(path));\n}\n\n/**\n * Removes files or directories synchronously if they exist.\n * This function safely removes multiple files or directories by checking for existence\n * before attempting removal, preventing errors for non-existent paths.\n *\n * @param paths - An array of file or directory paths to remove.\n */\nexport function removeSync(...paths: string[]) {\n paths.forEach((filePath) => {\n if (pathExistsSync(filePath)) {\n fsExtra.removeSync(filePath);\n }\n });\n}\n\n/**\n * Copies files and directories synchronously with optional filtering.\n * This function copies files from source to destination with support for:\n * - Extension-based filtering (only copy files with specified extensions)\n * - Directory preservation (always copy directories regardless of extension filter)\n * - Additional copy options from fs-extra\n *\n * @param src - The source path to copy from.\n * @param dest - The destination path to copy to.\n * @param options - Optional copy configuration including extensions filter and other fs-extra options.\n */\nexport function copySync(src: string, dest: string, options: I_CopySyncOptions = {}): void {\n const { extensions, ...rest } = options;\n\n fsExtra.copySync(src, dest, {\n filter: (srcPath: string) => {\n if (statSync(srcPath).isDirectory()) {\n return true;\n }\n\n if (!extensions || extensions.length === 0) {\n return true;\n }\n\n return extensions.includes(path.extname(srcPath));\n },\n ...rest,\n });\n}\n\n/**\n * Adds an entry to the .gitignore file if it doesn't already exist.\n * Creates the .gitignore file if it doesn't exist.\n *\n * @param gitIgnorePath - The absolute path to the .gitignore file.\n * @param entry - The entry name to add (e.g. '.agent', '.simple-git-hooks.json').\n */\nexport function addGitIgnoreEntry(gitIgnorePath: string, entry: string): void {\n const gitIgnoreContent = `\\n${entry}\\n`;\n\n if (pathExistsSync(gitIgnorePath)) {\n const gitignore = readFileSync(gitIgnorePath, 'utf-8').split('\\n');\n\n if (!gitignore.includes(entry)) {\n appendFileSync(gitIgnorePath, gitIgnoreContent);\n }\n }\n else {\n writeFileSync(gitIgnorePath, gitIgnoreContent);\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"fs.util.js","names":[],"sources":["../../../src/node/fs/fs.util.ts"],"sourcesContent":["import fsExtra from 'fs-extra';\nimport path from 'node:path';\n\nimport type { I_CopySyncOptions } from './fs.type.js';\n\n/**\n * Re-export of the fs-extra module for file system operations.\n */\nexport const fs = fsExtra;\n\nexport const {\n lstatSync,\n readdirSync,\n mkdirSync,\n readFileSync,\n unlinkSync,\n statSync,\n createWriteStream,\n} = fsExtra;\n\nexport const readJsonSync: typeof fsExtra.readJsonSync = fsExtra.readJsonSync;\n\n/**\n * Writes data to a file synchronously with UTF-8 encoding as default.\n * This function provides a simplified interface for writing files with automatic UTF-8 encoding\n * when no specific options are provided.\n *\n * @param file - The file path or file descriptor to write to.\n * @param data - The data to write to the file (string or Uint8Array).\n * @param options - Optional write file options (defaults to UTF-8 encoding).\n */\nexport function writeFileSync(file: fsExtra.PathOrFileDescriptor, data: string | Uint8Array, options?: fsExtra.WriteFileOptions): void {\n fsExtra.writeFileSync(file, data, options ?? 'utf-8');\n}\n\n/**\n * Appends data to a file synchronously with UTF-8 encoding as default.\n * This function provides a simplified interface for appending to files with automatic UTF-8 encoding\n * when no specific options are provided.\n *\n * @param path - The file path or file descriptor to append to.\n * @param data - The data to append to the file (string or Uint8Array).\n * @param options - Optional write file options (defaults to UTF-8 encoding).\n */\nexport function appendFileSync(path: fsExtra.PathOrFileDescriptor, data: string | Uint8Array, options?: fsExtra.WriteFileOptions): void {\n fsExtra.appendFileSync(path, data, options ?? 'utf-8');\n}\n\n/**\n * Checks if all specified paths exist synchronously.\n * This function verifies that every path in the provided array exists in the file system.\n * Returns true only if all paths exist, false if any path is missing.\n *\n * @param paths - An array of file or directory paths to check for existence.\n * @returns True if all paths exist, false if any path is missing.\n */\nexport function pathExistsSync(...paths: string[]) {\n return paths.every(path => fsExtra.pathExistsSync(path));\n}\n\n/**\n * Removes files or directories synchronously if they exist.\n * This function safely removes multiple files or directories by checking for existence\n * before attempting removal, preventing errors for non-existent paths.\n *\n * @param paths - An array of file or directory paths to remove.\n */\nexport function removeSync(...paths: string[]) {\n paths.forEach((filePath) => {\n if (pathExistsSync(filePath)) {\n fsExtra.removeSync(filePath);\n }\n });\n}\n\n/**\n * Copies files and directories synchronously with optional filtering.\n * This function copies files from source to destination with support for:\n * - Extension-based filtering (only copy files with specified extensions)\n * - Directory preservation (always copy directories regardless of extension filter)\n * - Additional copy options from fs-extra\n *\n * @param src - The source path to copy from.\n * @param dest - The destination path to copy to.\n * @param options - Optional copy configuration including extensions filter and other fs-extra options.\n */\nexport function copySync(src: string, dest: string, options: I_CopySyncOptions = {}): void {\n const { extensions, ...rest } = options;\n\n fsExtra.copySync(src, dest, {\n filter: (srcPath: string) => {\n if (statSync(srcPath).isDirectory()) {\n return true;\n }\n\n if (!extensions || extensions.length === 0) {\n return true;\n }\n\n return extensions.includes(path.extname(srcPath));\n },\n ...rest,\n });\n}\n\n/**\n * Adds an entry to the .gitignore file if it doesn't already exist.\n * Creates the .gitignore file if it doesn't exist.\n *\n * @param gitIgnorePath - The absolute path to the .gitignore file.\n * @param entry - The entry name to add (e.g. '.agent', '.simple-git-hooks.json').\n */\nexport function addGitIgnoreEntry(gitIgnorePath: string, entry: string): void {\n const gitIgnoreContent = `\\n${entry}\\n`;\n\n if (pathExistsSync(gitIgnorePath)) {\n const gitignore = readFileSync(gitIgnorePath, 'utf-8').split('\\n');\n\n if (!gitignore.includes(entry)) {\n appendFileSync(gitIgnorePath, gitIgnoreContent);\n }\n }\n else {\n writeFileSync(gitIgnorePath, gitIgnoreContent);\n }\n}\n"],"mappings":";;;AAQA,IAAa,IAAK,GAEL,EACT,cACA,gBACA,cACA,iBACA,eACA,aACA,yBACA,GAES,IAA4C,EAAQ;AAWjE,SAAgB,EAAc,GAAoC,GAA2B,GAA0C;AACnI,GAAQ,cAAc,GAAM,GAAM,KAAW,QAAQ;;AAYzD,SAAgB,EAAe,GAAoC,GAA2B,GAA0C;AACpI,GAAQ,eAAe,GAAM,GAAM,KAAW,QAAQ;;AAW1D,SAAgB,EAAe,GAAG,GAAiB;AAC/C,QAAO,EAAM,OAAM,MAAQ,EAAQ,eAAe,EAAK,CAAC;;AAU5D,SAAgB,EAAW,GAAG,GAAiB;AAC3C,GAAM,SAAS,MAAa;AACxB,EAAI,EAAe,EAAS,IACxB,EAAQ,WAAW,EAAS;GAElC;;AAcN,SAAgB,EAAS,GAAa,GAAc,IAA6B,EAAE,EAAQ;CACvF,IAAM,EAAE,eAAY,GAAG,MAAS;AAEhC,GAAQ,SAAS,GAAK,GAAM;EACxB,SAAS,MACD,EAAS,EAAQ,CAAC,aAAa,IAI/B,CAAC,KAAc,EAAW,WAAW,IAC9B,KAGJ,EAAW,SAAS,EAAK,QAAQ,EAAQ,CAAC;EAErD,GAAG;EACN,CAAC;;AAUN,SAAgB,EAAkB,GAAuB,GAAqB;CAC1E,IAAM,IAAmB,KAAK,EAAM;AAEpC,CAAI,EAAe,EAAc,GACX,EAAa,GAAe,QAAQ,CAAC,MAAM,KAAK,CAEnD,SAAS,EAAM,IAC1B,EAAe,GAAe,EAAiB,GAInD,EAAc,GAAe,EAAiB"}
|
package/dist/node/fs/index.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
import { addGitIgnoreEntry as
|
|
2
|
-
export {
|
|
3
|
-
c as addGitIgnoreEntry,
|
|
4
|
-
r as appendFileSync,
|
|
5
|
-
y as copySync,
|
|
6
|
-
t as createWriteStream,
|
|
7
|
-
S as fs,
|
|
8
|
-
a as lstatSync,
|
|
9
|
-
i as mkdirSync,
|
|
10
|
-
d as pathExistsSync,
|
|
11
|
-
o as readFileSync,
|
|
12
|
-
s as readJsonSync,
|
|
13
|
-
l as readdirSync,
|
|
14
|
-
p as removeSync,
|
|
15
|
-
m as statSync,
|
|
16
|
-
F as unlinkSync,
|
|
17
|
-
f as writeFileSync
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { addGitIgnoreEntry as e, appendFileSync as t, copySync as n, createWriteStream as r, fs as i, lstatSync as a, mkdirSync as o, pathExistsSync as s, readFileSync as c, readJsonSync as l, readdirSync as u, removeSync as d, statSync as f, unlinkSync as p, writeFileSync as m } from "./fs.util.js";
|
|
2
|
+
export { e as addGitIgnoreEntry, t as appendFileSync, n as copySync, r as createWriteStream, i as fs, a as lstatSync, o as mkdirSync, s as pathExistsSync, c as readFileSync, l as readJsonSync, u as readdirSync, d as removeSync, f as statSync, p as unlinkSync, m as writeFileSync };
|
package/dist/node/log/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import { E_IssueType as e } from "./log.type.js";
|
|
2
|
-
import { catchError as
|
|
3
|
-
export {
|
|
4
|
-
e as E_IssueType,
|
|
5
|
-
p as catchError,
|
|
6
|
-
E as log,
|
|
7
|
-
c as throwError
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
import { catchError as t, log as n, throwError as r } from "./log.util.js";
|
|
3
|
+
export { e as E_IssueType, t as catchError, n as log, r as throwError };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
//#
|
|
1
|
+
//#region src/node/log/log.type.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.Error = "error", e.Warning = "warning", e;
|
|
4
|
+
}({});
|
|
5
|
+
//#endregion
|
|
6
|
+
export { e as E_IssueType };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=log.type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.type.js","sources":["../../../src/node/log/log.type.ts"],"sourcesContent":["import type { I_Log as I_LogCommon } from '#typescript/index.js';\n\n/**\n * Enum representing the type of issues for logging and error handling.\n * - Error: Represents an error issue.\n * - Warning: Represents a warning issue.\n */\nexport enum E_IssueType {\n Error = 'error',\n Warning = 'warning',\n}\n\nexport interface I_IssueEntry {\n type: E_IssueType;\n file: string;\n message: string;\n position?: string;\n rule?: string;\n}\n\nexport interface I_ThrowError {\n message?: string;\n status?: {\n CODE: string | number;\n MESSAGE: string;\n };\n type?: 'graphql' | 'rest';\n}\n\nexport interface I_Log extends I_LogCommon {\n printBoxedLog: (\n title: string,\n issues: I_IssueEntry[],\n color?: string,\n ) => void;\n}\n\nexport interface I_CatchErrorOptions {\n shouldLog?: boolean;\n returnValue?: unknown;\n callback?: (error: Error) => void;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"log.type.js","names":[],"sources":["../../../src/node/log/log.type.ts"],"sourcesContent":["import type { I_Log as I_LogCommon } from '#typescript/index.js';\n\n/**\n * Enum representing the type of issues for logging and error handling.\n * - Error: Represents an error issue.\n * - Warning: Represents a warning issue.\n */\nexport enum E_IssueType {\n Error = 'error',\n Warning = 'warning',\n}\n\nexport interface I_IssueEntry {\n type: E_IssueType;\n file: string;\n message: string;\n position?: string;\n rule?: string;\n}\n\nexport interface I_ThrowError {\n message?: string;\n status?: {\n CODE: string | number;\n MESSAGE: string;\n };\n type?: 'graphql' | 'rest';\n}\n\nexport interface I_Log extends I_LogCommon {\n printBoxedLog: (\n title: string,\n issues: I_IssueEntry[],\n color?: string,\n ) => void;\n}\n\nexport interface I_CatchErrorOptions {\n shouldLog?: boolean;\n returnValue?: unknown;\n callback?: (error: Error) => void;\n}\n"],"mappings":";AAOA,IAAY,IAAL,yBAAA,GAAA;QACH,EAAA,QAAA,SACA,EAAA,UAAA;KACH"}
|
|
@@ -1,73 +1,56 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { GraphQLError as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
extensions: { code: o.CODE }
|
|
15
|
-
}) : new Error(t);
|
|
1
|
+
import { RESPONSE_STATUS as e } from "../../constant/response-status.js";
|
|
2
|
+
import { getEnv as t } from "../../config/env/env.util.js";
|
|
3
|
+
import { GraphQLError as n } from "graphql";
|
|
4
|
+
import r from "chalk";
|
|
5
|
+
import i from "consola";
|
|
6
|
+
//#region src/node/log/log.util.ts
|
|
7
|
+
var a = !1;
|
|
8
|
+
function o() {
|
|
9
|
+
a || (a = !0, t().DEBUG || (i.level = 4));
|
|
10
|
+
}
|
|
11
|
+
function s({ message: t, status: r = e.INTERNAL_SERVER_ERROR, type: i = "graphql" }) {
|
|
12
|
+
let a = t ?? r.MESSAGE ?? "Internal server error";
|
|
13
|
+
throw i === "graphql" ? new n(a, { extensions: { code: r.CODE } }) : Error(a);
|
|
16
14
|
}
|
|
17
|
-
R.DEBUG || (r.level = 4);
|
|
18
15
|
function c(e) {
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
let t = r[e];
|
|
17
|
+
return typeof t == "function" ? t : r.green;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* @param color - The color to use for highlighting (defaults to 'red').
|
|
48
|
-
*/
|
|
49
|
-
printBoxedLog(e, o, n = "red") {
|
|
50
|
-
if (!o?.length) {
|
|
51
|
-
r.box(l.green(e));
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
o.forEach(({ file: t, position: s, rule: a, message: g }) => {
|
|
55
|
-
const i = s ? `:${s}` : "", E = `${t}${i}`;
|
|
56
|
-
r.log(`${l.gray("File:")} ${l.blue(E)}`), a && r.log(` ${c(n)("Rule:")} ${a}`), r.log(` ${c(n)("Message:")} ${g}`);
|
|
57
|
-
}), r.box(c(n)(`${e} : ${o.length}`)), r.log(l.gray("─".repeat(40)));
|
|
58
|
-
}
|
|
19
|
+
var l = {
|
|
20
|
+
silent: i.silent,
|
|
21
|
+
level: i.level,
|
|
22
|
+
fatal: i.fatal,
|
|
23
|
+
error: i.error,
|
|
24
|
+
warn: i.warn,
|
|
25
|
+
log: i.log,
|
|
26
|
+
info: i.info,
|
|
27
|
+
success: i.success,
|
|
28
|
+
ready: i.ready,
|
|
29
|
+
start: i.start,
|
|
30
|
+
box: i.box,
|
|
31
|
+
debug: i.debug,
|
|
32
|
+
trace: i.trace,
|
|
33
|
+
verbose: i.verbose,
|
|
34
|
+
printBoxedLog(e, t, n = "red") {
|
|
35
|
+
if (!t?.length) {
|
|
36
|
+
i.box(r.green(e));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
t.forEach(({ file: e, position: t, rule: a, message: o }) => {
|
|
40
|
+
let s = `${e}${t ? `:${t}` : ""}`;
|
|
41
|
+
i.log(`${r.gray("File:")} ${r.blue(s)}`), a && i.log(` ${c(n)("Rule:")} ${a}`), i.log(` ${c(n)("Message:")} ${o}`);
|
|
42
|
+
}), i.box(c(n)(`${e} : ${t.length}`)), i.log(r.gray("─".repeat(40)));
|
|
43
|
+
}
|
|
59
44
|
};
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
function u(t, n) {
|
|
46
|
+
let { shouldLog: r = !0, returnValue: i, callback: a } = n ?? {}, s = t instanceof Error ? t : Error(typeof t == "string" ? t : "Unknown error");
|
|
47
|
+
return r && (o(), l.error(s.message)), a && typeof a == "function" && a(s), i === void 0 ? {
|
|
48
|
+
success: !1,
|
|
49
|
+
message: s.message,
|
|
50
|
+
code: e.INTERNAL_SERVER_ERROR.CODE
|
|
51
|
+
} : i;
|
|
67
52
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=log.util.js.map
|
|
53
|
+
//#endregion
|
|
54
|
+
export { u as catchError, l as log, s as throwError };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=log.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.util.js","sources":["../../../src/node/log/log.util.ts"],"sourcesContent":["import type { ChalkInstance } from 'chalk';\n\nimport chalk from 'chalk';\nimport consola from 'consola';\nimport { GraphQLError } from 'graphql';\n\nimport type { I_Return } from '#typescript/index.js';\n\nimport { getEnv } from '#config/env/index.js';\nimport { RESPONSE_STATUS } from '#constant/index.js';\n\nimport type { I_CatchErrorOptions, I_IssueEntry, I_Log, I_ThrowError } from './log.type.js';\n\
|
|
1
|
+
{"version":3,"file":"log.util.js","names":[],"sources":["../../../src/node/log/log.util.ts"],"sourcesContent":["import type { ChalkInstance } from 'chalk';\n\nimport chalk from 'chalk';\nimport consola from 'consola';\nimport { GraphQLError } from 'graphql';\n\nimport type { I_Return } from '#typescript/index.js';\n\nimport { getEnv } from '#config/env/index.js';\nimport { RESPONSE_STATUS } from '#constant/index.js';\n\nimport type { I_CatchErrorOptions, I_IssueEntry, I_Log, I_ThrowError } from './log.type.js';\n\nlet _logLevelConfigured = false;\n\n/**\n * Lazily configures the consola log level based on the DEBUG environment variable.\n * Only runs once on first invocation to avoid repeated env loading.\n */\nfunction ensureLogLevel() {\n if (!_logLevelConfigured) {\n _logLevelConfigured = true;\n const env = getEnv();\n\n if (!env.DEBUG) {\n consola.level = 4;\n }\n }\n}\n\n/**\n * Throws a standardized error with optional status information and type specification.\n * This function creates and throws errors that can be either GraphQL errors (with extensions)\n * or standard JavaScript errors, depending on the specified type.\n *\n * @param options - Error configuration including message, status information, and error type.\n * @param options.message - The error message to display.\n * @param options.status - The response status information (defaults to INTERNAL_SERVER_ERROR).\n * @param options.type - The type of error to throw ('graphql' or 'rest', defaults to 'graphql').\n * @throws {GraphQLError} When type is 'graphql', throws a GraphQL error with extensions.\n * @throws {Error} When type is 'rest' or unspecified, throws a standard JavaScript error.\n */\nexport function throwError({\n message,\n status = RESPONSE_STATUS.INTERNAL_SERVER_ERROR,\n type = 'graphql',\n}: I_ThrowError): never {\n const responseMessage\n = message ?? status.MESSAGE ?? 'Internal server error';\n\n if (type === 'graphql') {\n throw new GraphQLError(responseMessage, {\n extensions: { code: status.CODE },\n });\n }\n\n else {\n throw new Error(responseMessage);\n }\n}\n\n/**\n * Gets a chalk color instance by keyword name.\n * This function safely retrieves a chalk color function by name, falling back to green\n * if the specified color is not available or invalid.\n *\n * @param color - The color keyword to get the chalk instance for.\n * @returns A chalk instance for the specified color, or green as fallback.\n */\nfunction chalkKeyword(color: string): ChalkInstance {\n const chalkColor = chalk[color as keyof typeof chalk];\n\n return typeof chalkColor === 'function' ? (chalkColor as ChalkInstance) : chalk.green;\n}\n\n/**\n * Enhanced logging interface that extends consola with custom functionality.\n * This object provides all standard consola logging methods plus additional features\n * like boxed log printing for structured error/warning display.\n */\nexport const log: I_Log = {\n silent: consola.silent,\n level: consola.level,\n fatal: consola.fatal,\n error: consola.error,\n warn: consola.warn,\n log: consola.log,\n info: consola.info,\n success: consola.success,\n ready: consola.ready,\n start: consola.start,\n box: consola.box,\n debug: consola.debug,\n trace: consola.trace,\n verbose: consola.verbose,\n /**\n * Prints a boxed log with structured issue information.\n * This method displays issues (errors or warnings) in a formatted box with:\n * - File paths and line/column positions\n * - Rule violations (if applicable)\n * - Error/warning messages\n * - Color-coded output based on issue type\n *\n * @param title - The title to display in the box header.\n * @param issues - An array of issue entries to display.\n * @param color - The color to use for highlighting (defaults to 'red').\n */\n printBoxedLog(title: string, issues: I_IssueEntry[], color = 'red') {\n if (!issues?.length) {\n consola.box(chalk.green(title));\n return;\n }\n\n issues.forEach(({ file, position, rule, message }) => {\n const positionSuffix = position ? `:${position}` : '';\n const filePath = `${file}${positionSuffix}`;\n consola.log(`${chalk.gray('File:')} ${chalk.blue(filePath)}`);\n\n if (rule) {\n consola.log(` ${chalkKeyword(color)('Rule:')} ${rule}`);\n }\n\n consola.log(` ${chalkKeyword(color)('Message:')} ${message}`);\n });\n\n consola.box(chalkKeyword(color)(`${title} : ${issues.length}`));\n\n consola.log(chalk.gray('─'.repeat(40)));\n },\n};\n\n/**\n * Catches and handles errors with configurable behavior.\n * This function provides a standardized way to handle errors with options for:\n * - Logging control (whether to log the error)\n * - Return value specification (what to return on error)\n * - Custom callback execution (additional error handling)\n *\n * @param errorInput - The error to catch and handle.\n * @param options - Configuration options for error handling behavior.\n * @returns Either the specified return value or a standardized error response object.\n */\nexport function catchError<T = unknown>(errorInput: unknown, options: I_CatchErrorOptions & { returnValue: T }): T;\nexport function catchError<T = unknown>(errorInput: unknown, options?: I_CatchErrorOptions): I_Return<T>;\nexport function catchError<T = unknown>(errorInput: unknown, options?: I_CatchErrorOptions): I_Return<T> | T {\n const { shouldLog = true, returnValue, callback } = options ?? {};\n\n const error = errorInput instanceof Error\n ? errorInput\n : new Error(typeof errorInput === 'string' ? errorInput : 'Unknown error');\n\n if (shouldLog) {\n ensureLogLevel();\n log.error(error.message);\n }\n\n if (callback && typeof callback === 'function') {\n callback(error);\n }\n\n if (returnValue !== undefined) {\n return returnValue as T;\n }\n\n return {\n success: false,\n message: error.message,\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n}\n"],"mappings":";;;;;;AAaA,IAAI,IAAsB;AAM1B,SAAS,IAAiB;AACtB,CAAK,MACD,IAAsB,IACV,GAAQ,CAEX,UACL,EAAQ,QAAQ;;AAiB5B,SAAgB,EAAW,EACvB,YACA,YAAS,EAAgB,uBACzB,UAAO,aACa;CACpB,IAAM,IACA,KAAW,EAAO,WAAW;AAS/B,OAPA,MAAS,YACH,IAAI,EAAa,GAAiB,EACpC,YAAY,EAAE,MAAM,EAAO,MAAM,EACpC,CAAC,GAIQ,MAAM,EAAgB;;AAYxC,SAAS,EAAa,GAA8B;CAChD,IAAM,IAAa,EAAM;AAEzB,QAAO,OAAO,KAAe,aAAc,IAA+B,EAAM;;AAQpF,IAAa,IAAa;CACtB,QAAQ,EAAQ;CAChB,OAAO,EAAQ;CACf,OAAO,EAAQ;CACf,OAAO,EAAQ;CACf,MAAM,EAAQ;CACd,KAAK,EAAQ;CACb,MAAM,EAAQ;CACd,SAAS,EAAQ;CACjB,OAAO,EAAQ;CACf,OAAO,EAAQ;CACf,KAAK,EAAQ;CACb,OAAO,EAAQ;CACf,OAAO,EAAQ;CACf,SAAS,EAAQ;CAajB,cAAc,GAAe,GAAwB,IAAQ,OAAO;AAChE,MAAI,CAAC,GAAQ,QAAQ;AACjB,KAAQ,IAAI,EAAM,MAAM,EAAM,CAAC;AAC/B;;AAiBJ,EAdA,EAAO,SAAS,EAAE,SAAM,aAAU,SAAM,iBAAc;GAElD,IAAM,IAAW,GAAG,IADG,IAAW,IAAI,MAAa;AAQnD,GANA,EAAQ,IAAI,GAAG,EAAM,KAAK,QAAQ,CAAC,GAAG,EAAM,KAAK,EAAS,GAAG,EAEzD,KACA,EAAQ,IAAI,MAAM,EAAa,EAAM,CAAC,QAAQ,CAAC,GAAG,IAAO,EAG7D,EAAQ,IAAI,MAAM,EAAa,EAAM,CAAC,WAAW,CAAC,GAAG,IAAU;IACjE,EAEF,EAAQ,IAAI,EAAa,EAAM,CAAC,GAAG,EAAM,KAAK,EAAO,SAAS,CAAC,EAE/D,EAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,GAAG,CAAC,CAAC;;CAE9C;AAeD,SAAgB,EAAwB,GAAqB,GAAgD;CACzG,IAAM,EAAE,eAAY,IAAM,gBAAa,gBAAa,KAAW,EAAE,EAE3D,IAAQ,aAAsB,QAC9B,IACI,MAAM,OAAO,KAAe,WAAW,IAAa,gBAAgB;AAe9E,QAbI,MACA,GAAgB,EAChB,EAAI,MAAM,EAAM,QAAQ,GAGxB,KAAY,OAAO,KAAa,cAChC,EAAS,EAAM,EAGf,MAAgB,KAAA,IAIb;EACH,SAAS;EACT,SAAS,EAAM;EACf,MAAM,EAAgB,sBAAsB;EAC/C,GAPU"}
|
package/dist/node/mongo/index.js
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import { MONGO_MIGRATE_OPTIONS as
|
|
2
|
-
import {
|
|
3
|
-
import { applyNestedPopulate as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { MongoController as
|
|
7
|
-
import {
|
|
8
|
-
export {
|
|
9
|
-
f as C_Collection,
|
|
10
|
-
u as C_Db,
|
|
11
|
-
s as C_Document,
|
|
12
|
-
x as C_Model,
|
|
13
|
-
r as MONGO_MIGRATE_OPTIONS,
|
|
14
|
-
t as MONGO_SLUG_MAX_ATTEMPTS,
|
|
15
|
-
N as MongoController,
|
|
16
|
-
g as MongooseController,
|
|
17
|
-
_ as applyNestedPopulate,
|
|
18
|
-
O as convertEnumToModelName,
|
|
19
|
-
m as filterDynamicVirtualsFromPopulate,
|
|
20
|
-
p as isMongooseDoc,
|
|
21
|
-
n as isObject,
|
|
22
|
-
D as mongo,
|
|
23
|
-
a as populateDynamicVirtuals,
|
|
24
|
-
M as remapDynamicPopulate
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { MONGO_MIGRATE_OPTIONS as e, MONGO_SLUG_MAX_ATTEMPTS as t } from "./mongo.constant.js";
|
|
2
|
+
import { convertEnumToModelName as n, mongo as r } from "./mongo.util.js";
|
|
3
|
+
import { applyNestedPopulate as i } from "./mongo.populate.js";
|
|
4
|
+
import { filterDynamicVirtualsFromPopulate as a, isMongooseDoc as o, isObject as s, populateDynamicVirtuals as c, remapDynamicPopulate as l } from "./mongo.dynamic-populate.js";
|
|
5
|
+
import { MongooseController as u } from "./mongo.controller.mongoose.js";
|
|
6
|
+
import { MongoController as d } from "./mongo.controller.native.js";
|
|
7
|
+
import { C_Collection as f, C_Db as p, C_Document as m, C_Model as h } from "./mongo.type.js";
|
|
8
|
+
export { f as C_Collection, p as C_Db, m as C_Document, h as C_Model, e as MONGO_MIGRATE_OPTIONS, t as MONGO_SLUG_MAX_ATTEMPTS, d as MongoController, u as MongooseController, i as applyNestedPopulate, n as convertEnumToModelName, a as filterDynamicVirtualsFromPopulate, o as isMongooseDoc, s as isObject, r as mongo, c as populateDynamicVirtuals, l as remapDynamicPopulate };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=mongo.constant.js.map
|
|
1
|
+
//#region src/node/mongo/mongo.constant.ts
|
|
2
|
+
var e = "MONGO_MIGRATE_OPTIONS", t = 100;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as MONGO_MIGRATE_OPTIONS, t as MONGO_SLUG_MAX_ATTEMPTS };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=mongo.constant.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.constant.js","sources":["../../../src/node/mongo/mongo.constant.ts"],"sourcesContent":["/**\n * Environment variable key for MongoDB migration options.\n * This constant defines the environment variable name that can be used to configure\n * MongoDB migration settings and options for database schema management.\n */\nexport const MONGO_MIGRATE_OPTIONS = 'MONGO_MIGRATE_OPTIONS';\n\n/**\n * Maximum number of attempts to generate a unique slug.\n * This constant defines the maximum number of attempts to generate a unique slug\n * before giving up and returning a fallback slug.\n */\nexport const MONGO_SLUG_MAX_ATTEMPTS = 100;\n"],"
|
|
1
|
+
{"version":3,"file":"mongo.constant.js","names":[],"sources":["../../../src/node/mongo/mongo.constant.ts"],"sourcesContent":["/**\n * Environment variable key for MongoDB migration options.\n * This constant defines the environment variable name that can be used to configure\n * MongoDB migration settings and options for database schema management.\n */\nexport const MONGO_MIGRATE_OPTIONS = 'MONGO_MIGRATE_OPTIONS';\n\n/**\n * Maximum number of attempts to generate a unique slug.\n * This constant defines the maximum number of attempts to generate a unique slug\n * before giving up and returning a fallback slug.\n */\nexport const MONGO_SLUG_MAX_ATTEMPTS = 100;\n"],"mappings":";AAKA,IAAa,IAAwB,yBAOxB,IAA0B"}
|
|
@@ -7,12 +7,17 @@ import { C_Document, I_DeleteOptionsExtended, I_ExtendedModel, I_Input_CheckSlug
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class MongooseController<T extends Partial<C_Document>> {
|
|
9
9
|
private model;
|
|
10
|
+
private defaultLimit;
|
|
10
11
|
/**
|
|
11
12
|
* Creates a new Mongoose controller instance.
|
|
12
13
|
*
|
|
13
14
|
* @param model - The Mongoose model to operate on.
|
|
15
|
+
* @param options - Optional configuration for the controller.
|
|
16
|
+
* @param options.defaultLimit - Maximum documents returned by findAll when no limit is specified (default: 10,000).
|
|
14
17
|
*/
|
|
15
|
-
constructor(model: I_ExtendedModel<T
|
|
18
|
+
constructor(model: I_ExtendedModel<T>, options?: {
|
|
19
|
+
defaultLimit?: number;
|
|
20
|
+
});
|
|
16
21
|
/**
|
|
17
22
|
* Gets the model name for logging and error messages.
|
|
18
23
|
*
|