@cyberskill/shared 2.28.0 → 3.0.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 (91) hide show
  1. package/dist/config/config.util.cjs +1 -1
  2. package/dist/config/config.util.js +24 -33
  3. package/dist/config/eslint/index.cjs +1 -1
  4. package/dist/config/eslint/index.d.ts +4 -0
  5. package/dist/config/eslint/index.js +4 -12
  6. package/dist/config/graphql-codegen/graphql-codegen.util.cjs +1 -1
  7. package/dist/config/graphql-codegen/graphql-codegen.util.js +28 -33
  8. package/dist/config/storybook/storybook.preview.cjs +1 -1
  9. package/dist/config/storybook/storybook.preview.js +10 -13
  10. package/dist/config/vitest/vitest.e2e.cjs +1 -1
  11. package/dist/config/vitest/vitest.e2e.js +1 -1
  12. package/dist/config/vitest/vitest.unit.cjs +1 -1
  13. package/dist/config/vitest/vitest.unit.js +19 -8
  14. package/dist/constant/common.cjs +1 -1
  15. package/dist/constant/common.js +1 -1
  16. package/dist/node/apollo-server/apollo-server.util.cjs +1 -1
  17. package/dist/node/apollo-server/apollo-server.util.js +21 -48
  18. package/dist/node/cli/index.cjs +2 -2
  19. package/dist/node/cli/index.js +109 -165
  20. package/dist/node/command/command.util.cjs +2 -2
  21. package/dist/node/command/command.util.js +135 -170
  22. package/dist/node/express/express.util.cjs +1 -1
  23. package/dist/node/express/express.util.js +39 -72
  24. package/dist/node/fs/fs.util.cjs +3 -3
  25. package/dist/node/fs/fs.util.js +45 -60
  26. package/dist/node/log/log.util.cjs +1 -1
  27. package/dist/node/log/log.util.js +29 -30
  28. package/dist/node/mongo/mongo.controller.cjs +1 -1
  29. package/dist/node/mongo/mongo.controller.js +531 -629
  30. package/dist/node/mongo/mongo.util.cjs +2 -2
  31. package/dist/node/mongo/mongo.util.js +280 -321
  32. package/dist/node/package/package.util.cjs +1 -1
  33. package/dist/node/package/package.util.js +197 -226
  34. package/dist/node/path/index.cjs +1 -1
  35. package/dist/node/path/index.js +26 -25
  36. package/dist/node/path/path.constant.cjs +1 -1
  37. package/dist/node/path/path.constant.d.ts +2 -0
  38. package/dist/node/path/path.constant.js +130 -150
  39. package/dist/node/storage/storage.util.cjs +1 -1
  40. package/dist/node/storage/storage.util.js +110 -158
  41. package/dist/node/upload/upload.util.cjs +1 -1
  42. package/dist/node/upload/upload.util.js +119 -150
  43. package/dist/node/ws/ts.util.cjs +1 -1
  44. package/dist/node/ws/ts.util.js +31 -54
  45. package/dist/react/apollo-client/apollo-client.component.cjs +1 -1
  46. package/dist/react/apollo-client/apollo-client.component.js +4 -4
  47. package/dist/react/apollo-client/apollo-client.util.cjs +1 -1
  48. package/dist/react/apollo-client/apollo-client.util.js +51 -58
  49. package/dist/react/apollo-client/links/upload.cjs +1 -1
  50. package/dist/react/apollo-client/links/upload.js +71 -74
  51. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +1 -1
  52. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +11 -18
  53. package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
  54. package/dist/react/apollo-error/apollo-error.component.js +61 -23
  55. package/dist/react/apollo-error/apollo-error.module.scss.cjs +1 -1
  56. package/dist/react/apollo-error/apollo-error.module.scss.js +6 -6
  57. package/dist/react/apollo-error/apollo-error.test.unit.d.ts +1 -0
  58. package/dist/react/apollo-error/apollo-error.util.cjs +1 -1
  59. package/dist/react/apollo-error/apollo-error.util.js +6 -6
  60. package/dist/react/loading/loading.component.cjs +2 -2
  61. package/dist/react/loading/loading.component.js +30 -46
  62. package/dist/react/log/log.util.cjs +1 -1
  63. package/dist/react/log/log.util.js +4 -4
  64. package/dist/react/next-intl/next-intl.hoc.cjs +1 -1
  65. package/dist/react/next-intl/next-intl.hoc.js +13 -22
  66. package/dist/react/next-intl/next-intl.provider.cjs +1 -1
  67. package/dist/react/next-intl/next-intl.provider.js +7 -7
  68. package/dist/react/storage/storage.hook.cjs +1 -1
  69. package/dist/react/storage/storage.hook.js +43 -59
  70. package/dist/react/storage/storage.util.cjs +1 -1
  71. package/dist/react/storage/storage.util.js +28 -53
  72. package/dist/react/userback/userback.component.cjs +1 -1
  73. package/dist/react/userback/userback.component.js +18 -42
  74. package/dist/style.css +1 -1
  75. package/dist/util/common/common.util.cjs +1 -1
  76. package/dist/util/common/common.util.d.ts +2 -0
  77. package/dist/util/common/common.util.js +29 -37
  78. package/dist/util/index.cjs +1 -1
  79. package/dist/util/index.js +10 -9
  80. package/dist/util/object/object.util.cjs +1 -1
  81. package/dist/util/object/object.util.js +72 -76
  82. package/dist/util/string/index.cjs +1 -1
  83. package/dist/util/string/index.js +4 -3
  84. package/dist/util/string/string.util.cjs +1 -1
  85. package/dist/util/string/string.util.d.ts +12 -0
  86. package/dist/util/string/string.util.js +63 -44
  87. package/package.json +25 -16
  88. package/public/tsconfig.base.json +7 -3
  89. package/README.md +0 -470
  90. /package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.0_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 → vitest@4.0.18_@types_node@25.3.3_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.cjs +0 -0
  91. /package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.0_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 → vitest@4.0.18_@types_node@25.3.3_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 -0
package/README.md DELETED
@@ -1,470 +0,0 @@
1
- <div align="center">
2
- <img src="https://res.cloudinary.com/cyberskill/image/upload/v1742786793/cyberskill/favicon/favicon-96x96.png" width="96" height="96" alt="CyberSkill Logo">
3
-
4
- # CyberSkill Shared
5
-
6
- **Enterprise-grade utility library for consistent, scalable development across CyberSkill projects**
7
-
8
- [![📦 npm version](https://img.shields.io/npm/v/@cyberskill/shared?style=for-the-badge&logo=npm)](https://npmjs.com/package/@cyberskill/shared)
9
- [![📥 npm downloads](https://img.shields.io/npm/dm/@cyberskill/shared?style=for-the-badge&logo=npm)](https://npmjs.com/package/@cyberskill/shared)
10
- [![📚 JSDoc Documentation](https://img.shields.io/badge/JSDoc-Documentation-blue?style=for-the-badge&logo=javascript)](https://www.jsdocs.io/package/@cyberskill/shared)
11
- [![📄 License: MIT](https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge&logo=opensourceinitiative)](LICENSE)
12
-
13
- </div>
14
-
15
- ---
16
-
17
- ## 📋 Table of Contents
18
-
19
- - [Overview](#-overview)
20
- - [Key Features](#-key-features)
21
- - [Architecture](#️-architecture)
22
- - [Installation](#-installation)
23
- - [Quick Start](#-quick-start)
24
- - [API Reference](#-api-reference)
25
- - [Development](#️-development)
26
- - [Contributing](#-contributing)
27
- - [Support](#-support)
28
- - [License](#-license)
29
-
30
- ---
31
-
32
- ## 🎯 Overview
33
-
34
- CyberSkill Shared is a comprehensive, enterprise-grade utility library designed to standardize development practices across CyberSkill projects. Built with TypeScript-first architecture, it provides a robust foundation of utilities, configurations, and components that ensure consistency, maintainability, and developer productivity at scale.
35
-
36
- ### 🏆 Why Choose CyberSkill Shared?
37
-
38
- | Feature | Benefit |
39
- | ---------------------- | ------------------------------------------------------- |
40
- | **🔄 Consistency** | Standardized patterns and utilities across all projects |
41
- | **⚡ Productivity** | Pre-built solutions for common development tasks |
42
- | **🛡️ Reliability** | Type-safe implementations with comprehensive testing |
43
- | **📈 Scalability** | Modular architecture that grows with your needs |
44
- | **🔧 Maintainability** | Well-documented, clean, and extensible codebase |
45
- | **🚀 Performance** | Optimized for production with minimal bundle impact |
46
- | **🔒 Security** | Built-in security best practices and validation |
47
-
48
- ### 🎯 Target Use Cases
49
-
50
- - **Enterprise Applications**: Large-scale applications requiring consistency and maintainability
51
- - **Microservices**: Distributed systems needing shared utilities and configurations
52
- - **Full-Stack Development**: Projects spanning frontend and backend with shared logic
53
- - **Team Collaboration**: Development teams requiring standardized tooling and patterns
54
- - **Rapid Prototyping**: Quick development with pre-built, tested components
55
-
56
- ---
57
-
58
- ## ✨ Key Features
59
-
60
- ### 🛠️ Core Utilities & Helpers
61
-
62
- <details>
63
- <summary><strong>🔧 Utility Functions</strong></summary>
64
-
65
- - **Type-safe utilities** for common operations
66
- - **Object manipulation** and validation helpers
67
- - **String processing** and formatting functions
68
- - **Serialization** and data transformation tools
69
- - **Validation** frameworks with comprehensive error handling
70
-
71
- </details>
72
-
73
- <details>
74
- <summary><strong>⚙️ Configuration Management</strong></summary>
75
-
76
- - **Environment configuration** with type safety and validation
77
- - **ESLint configurations** for consistent code quality across projects
78
- - **Testing setups** for unit, integration, and e2e tests
79
- - **Build tool configurations** optimized for performance and DX
80
- - **Git hooks** and commit message validation
81
-
82
- </details>
83
-
84
- <details>
85
- <summary><strong>🌐 Node.js Integration</strong></summary>
86
-
87
- - **Express.js utilities** for API development with middleware support
88
- - **MongoDB integration** with advanced query builders and validation
89
- - **WebSocket management** tools for real-time applications
90
- - **File system operations** with enhanced error handling and validation
91
- - **CLI development** utilities for command-line applications
92
- - **Package management** with dependency resolution and updates
93
-
94
- </details>
95
-
96
- <details>
97
- <summary><strong>⚛️ React Ecosystem</strong></summary>
98
-
99
- - **Apollo Client** integration with error handling and caching
100
- - **Internationalization** (i18n) support for multi-language applications
101
- - **Loading states** and user feedback components
102
- - **Storage management** hooks and utilities for client-side persistence
103
- - **Toast notifications** system with customizable themes
104
- - **User feedback** integration for product improvement
105
-
106
- </details>
107
-
108
- <details>
109
- <summary><strong>📝 TypeScript Excellence</strong></summary>
110
-
111
- - **Comprehensive type definitions** for all utilities and components
112
- - **React component types** with proper prop validation
113
- - **Utility type helpers** for advanced TypeScript patterns
114
- - **Style declaration files** for CSS-in-JS solutions
115
- - **Generic type support** for flexible, reusable components
116
-
117
- </details>
118
-
119
- ---
120
-
121
- ## 🏗️ Architecture
122
-
123
- ### 📁 Project Structure
124
-
125
- ```text
126
- shared/
127
- ├── 📁 public/ # Static assets and configuration
128
- │ ├── favicon/ # Application icons and manifest
129
- │ └── tsconfig.base.json # Base TypeScript configuration
130
- ├── 📁 src/
131
- │ ├── 📁 config/ # Application configuration
132
- │ │ ├── commitlint/ # Git commit message validation
133
- │ │ ├── eslint/ # Code quality and style rules
134
- │ │ ├── env/ # Environment variable management
135
- │ │ ├── graphql-codegen/ # GraphQL code generation setup
136
- │ │ ├── lint-staged/ # Pre-commit code quality checks
137
- │ │ └── vitest/ # Testing framework configuration
138
- │ ├── 📁 constant/ # Shared constants and enums
139
- │ ├── 📁 node/ # Node.js utilities and modules
140
- │ │ ├── apollo-server/ # Apollo Server integration helpers
141
- │ │ ├── cli/ # Command-line interface utilities
142
- │ │ ├── command/ # Command execution and management
143
- │ │ ├── express/ # Express.js framework utilities
144
- │ │ ├── fs/ # File system operations
145
- │ │ ├── log/ # Structured logging and error handling
146
- │ │ ├── mongo/ # MongoDB ODM and query builders
147
- │ │ ├── package/ # Package management and dependency resolution
148
- │ │ ├── path/ # Path manipulation and resolution
149
- │ │ ├── storage/ # Data persistence and caching
150
- │ │ ├── upload/ # File upload handling and validation
151
- │ │ └── ws/ # WebSocket connection management
152
- │ ├── 📁 react/ # React utilities and components
153
- │ │ ├── apollo-client/ # Apollo Client setup and configuration
154
- │ │ ├── apollo-error/ # GraphQL error handling and display
155
- │ │ ├── i18next/ # Internationalization framework
156
- │ │ ├── loading/ # Loading state management and UI
157
- │ │ ├── log/ # Client-side logging utilities
158
- │ │ ├── next-intl/ # Next.js internationalization
159
- │ │ ├── storage/ # Browser storage management
160
- │ │ ├── toast/ # Toast notification system
161
- │ │ └── userback/ # User feedback and analytics
162
- │ ├── 📁 typescript/ # TypeScript type definitions
163
- │ └── 📁 util/ # Utility functions and helpers
164
- │ ├── common/ # Common utility types and functions
165
- │ ├── object/ # Object manipulation and transformation
166
- │ ├── serializer/ # Data serialization and deserialization
167
- │ ├── string/ # String processing and formatting
168
- │ └── validate/ # Data validation and sanitization
169
- ├── 📄 package.json # Project manifest and dependencies
170
- ├── 📄 tsconfig.json # TypeScript compiler configuration
171
- ├── 📄 eslint.config.js # ESLint configuration
172
- ├── 📄 vite.config.ts # Vite build tool configuration
173
- └── 📄 README.md # Project documentation
174
- ```
175
-
176
- ---
177
-
178
- ## 🚀 Installation
179
-
180
- ### Prerequisites
181
-
182
- - **Node.js**: 18.0.0 or higher
183
- - **pnpm**: 8.0.0 or higher (recommended)
184
- - **TypeScript**: 5.0.0 or higher
185
-
186
- ### Package Installation
187
-
188
- ```bash
189
- # Using pnpm (recommended)
190
- pnpm add @cyberskill/shared
191
-
192
- # Using npm
193
- npm install @cyberskill/shared
194
-
195
- # Using yarn
196
- yarn add @cyberskill/shared
197
- ```
198
-
199
- ### TypeScript Configuration
200
-
201
- Add to your `tsconfig.json`:
202
-
203
- ```json
204
- {
205
- "compilerOptions": {
206
- "baseUrl": ".",
207
- "paths": {
208
- "@cyberskill/shared/*": ["node_modules/@cyberskill/shared/src/*"]
209
- }
210
- }
211
- }
212
- ```
213
-
214
- ---
215
-
216
- ## 🏃 Quick Start
217
-
218
- ### Basic Usage
219
-
220
- ```typescript
221
- import {
222
- catchError,
223
- formatCurrency,
224
- isEmpty,
225
- validateEmail
226
- } from '@cyberskill/shared';
227
-
228
- // Email validation
229
- const isValidEmail = validateEmail('user@example.com');
230
- console.log(isValidEmail); // true
231
-
232
- // Currency formatting
233
- const formattedPrice = formatCurrency(1234.56, 'USD');
234
- console.log(formattedPrice); // "$1,234.56"
235
-
236
- // Empty value checking
237
- const isEmptyValue = isEmpty(null); // true
238
- const hasValue = isEmpty('hello'); // false
239
-
240
- // Error handling
241
- try {
242
- // Your code here
243
- }
244
- catch (error) {
245
- const handledError = catchError(error);
246
- console.log(handledError.message);
247
- }
248
- ```
249
-
250
- ### React Integration
251
-
252
- ```tsx
253
- import {
254
- ApolloProvider,
255
- LoadingProvider,
256
- useApolloError,
257
- useLoading
258
- } from '@cyberskill/shared';
259
- import * as React from 'react';
260
-
261
- // Main application wrapper
262
- /**
263
- *
264
- */
265
- // eslint-disable-next-line react-refresh/only-export-components
266
- function App() {
267
- return (
268
- <ApolloProvider options={{ uri: 'https://api.example.com/graphql' }}>
269
- <LoadingProvider>
270
- <MyApplication />
271
- </LoadingProvider>
272
- </ApolloProvider>
273
- );
274
- }
275
-
276
- // Component with loading and error handling
277
- /**
278
- *
279
- */
280
- // eslint-disable-next-line react-refresh/only-export-components
281
- function MyComponent() {
282
- const { showLoading, hideLoading } = useLoading();
283
- const { showError } = useApolloError();
284
-
285
- const handleAsyncOperation = async () => {
286
- try {
287
- showLoading();
288
- // Your async operation
289
- await someAsyncTask();
290
- }
291
- catch (error) {
292
- showError(error);
293
- }
294
- finally {
295
- hideLoading();
296
- }
297
- };
298
-
299
- return (
300
- <div>
301
- <button type="button" onClick={handleAsyncOperation}>
302
- Perform Operation
303
- </button>
304
- </div>
305
- );
306
- }
307
- ```
308
-
309
- ### Node.js Integration
310
-
311
- ```typescript
312
- import {
313
- createCorsOptions,
314
- mongo,
315
- RESPONSE_STATUS,
316
- throwError
317
- } from '@cyberskill/shared';
318
- // Express.js setup with CORS
319
- import express from 'express';
320
-
321
- const app = express();
322
-
323
- const corsOptions = createCorsOptions({
324
- isDev: process.env.NODE_ENV === 'development',
325
- whiteList: ['https://example.com', 'https://api.example.com']
326
- });
327
-
328
- app.use(cors(corsOptions));
329
-
330
- // MongoDB integration
331
- const mongoose = await mongo.connect({
332
- uri: process.env.MONGODB_URI,
333
- options: {
334
- maxPoolSize: 10,
335
- serverSelectionTimeoutMS: 5000
336
- }
337
- });
338
-
339
- // Error handling
340
- app.use('/api/users', (req, res, next) => {
341
- try {
342
- // Your route logic
343
- }
344
- catch (error) {
345
- throwError({
346
- message: 'User operation failed',
347
- status: RESPONSE_STATUS.INTERNAL_SERVER_ERROR,
348
- type: 'rest'
349
- });
350
- }
351
- });
352
- ```
353
-
354
- ---
355
-
356
- ## 🛠️ Development
357
-
358
- ### Quick Setup
359
-
360
- ```bash
361
- # Clone the repository
362
- git clone https://github.com/cyberskill-world/shared.git
363
- cd shared
364
-
365
- # Install dependencies
366
- pnpm install
367
-
368
- # Build the project
369
- pnpm run build
370
-
371
- # Start development mode
372
- pnpm run dev
373
- ```
374
-
375
- ### Available Scripts
376
-
377
- | Command | Description | Usage |
378
- | ------------------- | -------------------------------------- | ------------ |
379
- | `pnpm run dev` | Start development mode with hot reload | Development |
380
- | `pnpm run build` | Build for production | Production |
381
- | `pnpm run lint` | Check for linting issues | Code Quality |
382
- | `pnpm run lint:fix` | Fix linting issues automatically | Code Quality |
383
- | `pnpm run test` | Run tests | Testing |
384
- | `pnpm run inspect` | Inspect project dependencies | Analysis |
385
- | `pnpm run reset` | Reset project state | Maintenance |
386
- | `pnpm run ready` | Prepare project for development | Setup |
387
-
388
- For detailed development guidelines, code standards, and contribution workflow, see our [Contributing Guide](CONTRIBUTING.md).
389
-
390
- ---
391
-
392
- ## 🤝 Contributing
393
-
394
- We welcome contributions from the community! Please read our [Contributing Guide](CONTRIBUTING.md) for detailed information about our development process, code standards, and contribution workflow.
395
-
396
- ### Quick Start for Contributors
397
-
398
- 1. **Fork** the repository
399
- 2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
400
- 3. **Make** your changes following our standards
401
- 4. **Test** your changes thoroughly
402
- 5. **Commit** with conventional commit messages
403
- 6. **Push** to your branch and create a Pull Request
404
-
405
- For complete guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
406
-
407
- ---
408
-
409
- ## 🆘 Support
410
-
411
- ### Getting Help
412
-
413
- - **🐛 Issues**: [GitHub Issues](https://github.com/cyberskill-world/shared/issues)
414
- - **💬 Discussions**: [GitHub Discussions](https://github.com/cyberskill-world/shared/discussions)
415
- - **📧 Email**: [support@cyberskill.world](mailto:support@cyberskill.world)
416
-
417
- ### Community Resources
418
-
419
- - **📚 API Reference**: [JSDocs](https://www.jsdocs.io/package/@cyberskill/shared)
420
-
421
- ### Migration Support
422
-
423
- - **📋 Changelog**: [Release Notes](https://github.com/cyberskill-world/shared/releases)
424
-
425
- ---
426
-
427
- ## 📄 License
428
-
429
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
430
-
431
- **MIT License Benefits:**
432
-
433
- - ✅ Commercial use allowed
434
- - ✅ Modification permitted
435
- - ✅ Distribution allowed
436
- - ✅ Private use allowed
437
- - ✅ No warranty provided
438
- - ✅ No liability for damages
439
-
440
- ---
441
-
442
- ## 🏢 About CyberSkill
443
-
444
- CyberSkill JSC is a leading technology company focused on building innovative solutions for the cybersecurity industry. Our shared libraries and tools help developers create secure, scalable, and maintainable applications that meet enterprise-grade standards.
445
-
446
- ### Company Information
447
-
448
- - **🌐 Website**: [https://cyberskill.world](https://cyberskill.world)
449
- - **🐙 GitHub**: [https://github.com/cyberskill-world](https://github.com/cyberskill-world)
450
- - **📧 Contact**: [hello@cyberskill.world](mailto:hello@cyberskill.world)
451
-
452
- ### Our Mission
453
-
454
- To provide developers with the tools and utilities they need to build secure, scalable, and maintainable applications that protect users and organizations in an increasingly complex digital landscape.
455
-
456
- ---
457
-
458
- <div align="center">
459
- <p>Made with ❤️ by the <a href="https://github.com/cyberskill-world">CyberSkill Team</a></p>
460
-
461
- <p>
462
- <a href="https://cyberskill.world">Website</a>
463
- <a href="https://github.com/cyberskill-world/shared/issues">Issues</a>
464
- <a href="https://github.com/cyberskill-world/shared/discussions">Discussions</a>
465
- </p>
466
-
467
- <p>
468
- <sub>If this project helps you, please consider giving us a ⭐ on GitHub!</sub>
469
- </p>
470
- </div>