paymongo-cli 1.4.4 → 1.4.6

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 (142) hide show
  1. package/.github/copilot-instructions.md +95 -95
  2. package/CHANGELOG.md +27 -0
  3. package/LICENSE +20 -20
  4. package/dist/.tsbuildinfo +1 -1
  5. package/dist/commands/config.js +14 -0
  6. package/dist/commands/dev.js +2 -1
  7. package/dist/commands/generate/templates/checkout-page/index.js +520 -520
  8. package/dist/commands/generate/templates/payment-intent/javascript.js +68 -68
  9. package/dist/commands/generate/templates/payment-intent/typescript.js +92 -92
  10. package/dist/commands/generate/templates/webhook-handler/javascript.js +192 -147
  11. package/dist/commands/generate/templates/webhook-handler/typescript.js +147 -117
  12. package/dist/commands/generate.js +43 -37
  13. package/dist/commands/init.js +22 -5
  14. package/dist/commands/login.js +53 -16
  15. package/dist/commands/team/index.js +4 -3
  16. package/dist/commands/trigger.js +40 -2
  17. package/dist/commands/webhooks.js +1 -1
  18. package/dist/services/analytics/service.js +5 -1
  19. package/dist/services/api/client.js +1 -1
  20. package/dist/services/config/manager.js +6 -8
  21. package/dist/services/team/service.js +4 -1
  22. package/dist/types/schemas.js +38 -9
  23. package/eslint.config.ts +70 -70
  24. package/package.json +2 -2
  25. package/coverage/base.css +0 -224
  26. package/coverage/block-navigation.js +0 -87
  27. package/coverage/favicon.png +0 -0
  28. package/coverage/index.html +0 -281
  29. package/coverage/lcov-report/base.css +0 -224
  30. package/coverage/lcov-report/block-navigation.js +0 -87
  31. package/coverage/lcov-report/favicon.png +0 -0
  32. package/coverage/lcov-report/index.html +0 -281
  33. package/coverage/lcov-report/prettify.css +0 -1
  34. package/coverage/lcov-report/prettify.js +0 -2
  35. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  36. package/coverage/lcov-report/sorter.js +0 -210
  37. package/coverage/lcov.info +0 -5053
  38. package/coverage/prettify.css +0 -1
  39. package/coverage/prettify.js +0 -2
  40. package/coverage/sort-arrow-sprite.png +0 -0
  41. package/coverage/sorter.js +0 -210
  42. package/dist/commands/config.d.ts +0 -21
  43. package/dist/commands/config.d.ts.map +0 -1
  44. package/dist/commands/config.js.map +0 -1
  45. package/dist/commands/dev.d.ts +0 -16
  46. package/dist/commands/dev.d.ts.map +0 -1
  47. package/dist/commands/dev.js.map +0 -1
  48. package/dist/commands/env.d.ts +0 -4
  49. package/dist/commands/env.d.ts.map +0 -1
  50. package/dist/commands/env.js.map +0 -1
  51. package/dist/commands/init.d.ts +0 -15
  52. package/dist/commands/init.d.ts.map +0 -1
  53. package/dist/commands/init.js.map +0 -1
  54. package/dist/commands/login.d.ts +0 -20
  55. package/dist/commands/login.d.ts.map +0 -1
  56. package/dist/commands/login.js.map +0 -1
  57. package/dist/commands/payments.d.ts +0 -41
  58. package/dist/commands/payments.d.ts.map +0 -1
  59. package/dist/commands/payments.js.map +0 -1
  60. package/dist/commands/team/index.d.ts +0 -4
  61. package/dist/commands/team/index.d.ts.map +0 -1
  62. package/dist/commands/team/index.js.map +0 -1
  63. package/dist/commands/trigger.d.ts +0 -4
  64. package/dist/commands/trigger.d.ts.map +0 -1
  65. package/dist/commands/trigger.js.map +0 -1
  66. package/dist/commands/webhooks.d.ts +0 -23
  67. package/dist/commands/webhooks.d.ts.map +0 -1
  68. package/dist/commands/webhooks.js.map +0 -1
  69. package/dist/index.d.ts +0 -3
  70. package/dist/index.d.ts.map +0 -1
  71. package/dist/index.js.map +0 -1
  72. package/dist/services/analytics/service.d.ts +0 -35
  73. package/dist/services/analytics/service.d.ts.map +0 -1
  74. package/dist/services/analytics/service.js.map +0 -1
  75. package/dist/services/api/client.d.ts +0 -26
  76. package/dist/services/api/client.d.ts.map +0 -1
  77. package/dist/services/api/client.js.map +0 -1
  78. package/dist/services/api/rate-limiter.d.ts +0 -64
  79. package/dist/services/api/rate-limiter.d.ts.map +0 -1
  80. package/dist/services/api/rate-limiter.js.map +0 -1
  81. package/dist/services/api/undici-client.d.ts +0 -39
  82. package/dist/services/api/undici-client.d.ts.map +0 -1
  83. package/dist/services/api/undici-client.js +0 -288
  84. package/dist/services/api/undici-client.js.map +0 -1
  85. package/dist/services/config/manager.d.ts +0 -16
  86. package/dist/services/config/manager.d.ts.map +0 -1
  87. package/dist/services/config/manager.js.map +0 -1
  88. package/dist/services/dev/process-manager.d.ts +0 -50
  89. package/dist/services/dev/process-manager.d.ts.map +0 -1
  90. package/dist/services/dev/process-manager.js.map +0 -1
  91. package/dist/services/github/auth.d.ts +0 -15
  92. package/dist/services/github/auth.d.ts.map +0 -1
  93. package/dist/services/github/auth.js +0 -79
  94. package/dist/services/github/auth.js.map +0 -1
  95. package/dist/services/github/client.d.ts +0 -95
  96. package/dist/services/github/client.d.ts.map +0 -1
  97. package/dist/services/github/client.js +0 -130
  98. package/dist/services/github/client.js.map +0 -1
  99. package/dist/services/github/sync.d.ts +0 -26
  100. package/dist/services/github/sync.d.ts.map +0 -1
  101. package/dist/services/github/sync.js +0 -203
  102. package/dist/services/github/sync.js.map +0 -1
  103. package/dist/services/payments/simulator.d.ts +0 -28
  104. package/dist/services/payments/simulator.d.ts.map +0 -1
  105. package/dist/services/payments/simulator.js.map +0 -1
  106. package/dist/services/team/service.d.ts +0 -44
  107. package/dist/services/team/service.d.ts.map +0 -1
  108. package/dist/services/team/service.js.map +0 -1
  109. package/dist/services/web/server.d.ts +0 -31
  110. package/dist/services/web/server.d.ts.map +0 -1
  111. package/dist/services/web/server.js +0 -206
  112. package/dist/services/web/server.js.map +0 -1
  113. package/dist/types/paymongo.d.ts +0 -204
  114. package/dist/types/paymongo.d.ts.map +0 -1
  115. package/dist/types/paymongo.js.map +0 -1
  116. package/dist/types/schemas.d.ts +0 -80
  117. package/dist/types/schemas.d.ts.map +0 -1
  118. package/dist/types/schemas.js.map +0 -1
  119. package/dist/utils/bulk.d.ts +0 -62
  120. package/dist/utils/bulk.d.ts.map +0 -1
  121. package/dist/utils/bulk.js.map +0 -1
  122. package/dist/utils/cache.d.ts +0 -22
  123. package/dist/utils/cache.d.ts.map +0 -1
  124. package/dist/utils/cache.js.map +0 -1
  125. package/dist/utils/constants.d.ts +0 -32
  126. package/dist/utils/constants.d.ts.map +0 -1
  127. package/dist/utils/constants.js.map +0 -1
  128. package/dist/utils/errors.d.ts +0 -34
  129. package/dist/utils/errors.d.ts.map +0 -1
  130. package/dist/utils/errors.js.map +0 -1
  131. package/dist/utils/logger.d.ts +0 -20
  132. package/dist/utils/logger.d.ts.map +0 -1
  133. package/dist/utils/logger.js.map +0 -1
  134. package/dist/utils/spinner.d.ts +0 -17
  135. package/dist/utils/spinner.d.ts.map +0 -1
  136. package/dist/utils/spinner.js.map +0 -1
  137. package/dist/utils/validator.d.ts +0 -10
  138. package/dist/utils/validator.d.ts.map +0 -1
  139. package/dist/utils/validator.js.map +0 -1
  140. package/dist/utils/webhook-store.d.ts +0 -22
  141. package/dist/utils/webhook-store.d.ts.map +0 -1
  142. package/dist/utils/webhook-store.js.map +0 -1
@@ -1,95 +1,95 @@
1
- # PayMongo CLI - AI Agent Instructions
2
-
3
- ## Project Overview
4
- PayMongo CLI is a TypeScript-based developer tool for PayMongo payment integration with local webhook forwarding via ngrok tunneling. It uses **ESM modules** (`"type": "module"`) with Commander.js for CLI commands.
5
-
6
- ## Architecture
7
-
8
- ### Code Structure
9
- ```
10
- src/
11
- ├── commands/ # CLI commands (commander.js) - one file per top-level command
12
- ├── services/ # Core business logic
13
- │ ├── api/ # ApiClient - PayMongo V1 API wrapper with retries & caching
14
- │ ├── config/ # ConfigManager - .paymongo file handling via cosmiconfig
15
- │ └── web/ # Express + Socket.io for GUI dashboard
16
- ├── types/ # TypeScript definitions + Zod schemas
17
- └── utils/ # Shared utilities (errors, logging, cache, validation)
18
- ```
19
-
20
- ### Key Patterns
21
-
22
- **Error Handling** - Always use custom error classes from `src/utils/errors.ts`:
23
- ```typescript
24
- import { PayMongoError, NetworkError, ConfigError, ApiKeyError } from '../utils/errors.js';
25
- throw new PayMongoError('User-friendly message', 'ERROR_CODE', 400);
26
- ```
27
-
28
- **Retry Logic** - Use `withRetry()` for network operations:
29
- ```typescript
30
- import { withRetry } from '../utils/errors.js';
31
- const result = await withRetry(() => apiCall(), { maxRetries: 3, silent: true });
32
- ```
33
-
34
- **Lazy Loading** - Import heavy dependencies inside functions to keep CLI startup fast (<100ms):
35
- ```typescript
36
- // ✓ Correct - lazy load inside action
37
- .action(async () => {
38
- const { confirm } = await import('@inquirer/prompts');
39
- });
40
- // ✗ Wrong - top-level import slows startup
41
- import { confirm } from '@inquirer/prompts';
42
- ```
43
-
44
- **ESM Imports** - Always use `.js` extension for local imports:
45
- ```typescript
46
- import ConfigManager from '../services/config/manager.js';
47
- ```
48
-
49
- ## Configuration
50
- - Project config: `.paymongo` (JSON, managed via `ConfigManager`)
51
- - Global credentials: `~/.paymongo/credentials.enc` (AES-256-CBC encrypted)
52
- - Validation: Zod schemas in `src/types/schemas.ts`
53
-
54
- ## Development Workflow
55
-
56
- ### Commands
57
- ```bash
58
- npm run build # Compile TypeScript
59
- npm run dev # Watch mode compilation
60
- npm link # Test CLI globally as 'paymongo'
61
- npm test # Jest with ESM (--experimental-vm-modules)
62
- npm run lint:fix # ESLint auto-fix
63
- ```
64
-
65
- ### Testing Strategy
66
- - **Mocking ESM**: Use `jest.unstable_mockModule()` before dynamic imports
67
- - Structure: `tests/unit/`, `tests/integration/`
68
- - Mock external services (axios, ngrok, filesystem)
69
-
70
- Example test pattern:
71
- ```typescript
72
- jest.unstable_mockModule('axios', () => ({ default: mockAxios }));
73
- const { ApiClient } = await import('../../src/services/api/client.js');
74
- ```
75
-
76
- ## Code Conventions
77
-
78
- ### TypeScript
79
- - Strict mode enabled with `noImplicitAny`, `noUncheckedIndexedAccess`
80
- - Avoid `any` - use proper types from `src/types/paymongo.ts`
81
- - Config validation via Zod: `validateConfig()` from `src/types/schemas.ts`
82
-
83
- ### Commit Messages
84
- Follow conventional commits: `feat:`, `fix:`, `docs:`, `test:`, `refactor:`
85
-
86
- ### Security
87
- - Never log API keys or sensitive data
88
- - Use `ConfigManager` for credential access
89
- - Keep `.paymongo` and `.env` in `.gitignore`
90
-
91
- ## Key Files Reference
92
- - [src/services/api/client.ts](src/services/api/client.ts) - API wrapper with interceptors
93
- - [src/utils/errors.ts](src/utils/errors.ts) - Error classes + `withRetry()`
94
- - [src/types/schemas.ts](src/types/schemas.ts) - Zod validation schemas
95
- - [src/services/config/manager.ts](src/services/config/manager.ts) - Config file handling
1
+ # PayMongo CLI - AI Agent Instructions
2
+
3
+ ## Project Overview
4
+ PayMongo CLI is a TypeScript-based developer tool for PayMongo payment integration with local webhook forwarding via ngrok tunneling. It uses **ESM modules** (`"type": "module"`) with Commander.js for CLI commands.
5
+
6
+ ## Architecture
7
+
8
+ ### Code Structure
9
+ ```
10
+ src/
11
+ ├── commands/ # CLI commands (commander.js) - one file per top-level command
12
+ ├── services/ # Core business logic
13
+ │ ├── api/ # ApiClient - PayMongo V1 API wrapper with retries & caching
14
+ │ ├── config/ # ConfigManager - .paymongo file handling via cosmiconfig
15
+ │ └── web/ # Express + Socket.io for GUI dashboard
16
+ ├── types/ # TypeScript definitions + Zod schemas
17
+ └── utils/ # Shared utilities (errors, logging, cache, validation)
18
+ ```
19
+
20
+ ### Key Patterns
21
+
22
+ **Error Handling** - Always use custom error classes from `src/utils/errors.ts`:
23
+ ```typescript
24
+ import { PayMongoError, NetworkError, ConfigError, ApiKeyError } from '../utils/errors.js';
25
+ throw new PayMongoError('User-friendly message', 'ERROR_CODE', 400);
26
+ ```
27
+
28
+ **Retry Logic** - Use `withRetry()` for network operations:
29
+ ```typescript
30
+ import { withRetry } from '../utils/errors.js';
31
+ const result = await withRetry(() => apiCall(), { maxRetries: 3, silent: true });
32
+ ```
33
+
34
+ **Lazy Loading** - Import heavy dependencies inside functions to keep CLI startup fast (<100ms):
35
+ ```typescript
36
+ // ✓ Correct - lazy load inside action
37
+ .action(async () => {
38
+ const { confirm } = await import('@inquirer/prompts');
39
+ });
40
+ // ✗ Wrong - top-level import slows startup
41
+ import { confirm } from '@inquirer/prompts';
42
+ ```
43
+
44
+ **ESM Imports** - Always use `.js` extension for local imports:
45
+ ```typescript
46
+ import ConfigManager from '../services/config/manager.js';
47
+ ```
48
+
49
+ ## Configuration
50
+ - Project config: `.paymongo` (JSON, managed via `ConfigManager`)
51
+ - Global credentials: `~/.paymongo/credentials.enc` (AES-256-CBC encrypted)
52
+ - Validation: Zod schemas in `src/types/schemas.ts`
53
+
54
+ ## Development Workflow
55
+
56
+ ### Commands
57
+ ```bash
58
+ npm run build # Compile TypeScript
59
+ npm run dev # Watch mode compilation
60
+ npm link # Test CLI globally as 'paymongo'
61
+ npm test # Jest with ESM (--experimental-vm-modules)
62
+ npm run lint:fix # ESLint auto-fix
63
+ ```
64
+
65
+ ### Testing Strategy
66
+ - **Mocking ESM**: Use `jest.unstable_mockModule()` before dynamic imports
67
+ - Structure: `tests/unit/`, `tests/integration/`
68
+ - Mock external services (axios, ngrok, filesystem)
69
+
70
+ Example test pattern:
71
+ ```typescript
72
+ jest.unstable_mockModule('axios', () => ({ default: mockAxios }));
73
+ const { ApiClient } = await import('../../src/services/api/client.js');
74
+ ```
75
+
76
+ ## Code Conventions
77
+
78
+ ### TypeScript
79
+ - Strict mode enabled with `noImplicitAny`, `noUncheckedIndexedAccess`
80
+ - Avoid `any` - use proper types from `src/types/paymongo.ts`
81
+ - Config validation via Zod: `validateConfig()` from `src/types/schemas.ts`
82
+
83
+ ### Commit Messages
84
+ Follow conventional commits: `feat:`, `fix:`, `docs:`, `test:`, `refactor:`
85
+
86
+ ### Security
87
+ - Never log API keys or sensitive data
88
+ - Use `ConfigManager` for credential access
89
+ - Keep `.paymongo` and `.env` in `.gitignore`
90
+
91
+ ## Key Files Reference
92
+ - [src/services/api/client.ts](src/services/api/client.ts) - API wrapper with interceptors
93
+ - [src/utils/errors.ts](src/utils/errors.ts) - Error classes + `withRetry()`
94
+ - [src/types/schemas.ts](src/types/schemas.ts) - Zod validation schemas
95
+ - [src/services/config/manager.ts](src/services/config/manager.ts) - Config file handling
package/CHANGELOG.md CHANGED
@@ -7,6 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.4.6] - 2026-02-03
11
+
12
+ ### Changed
13
+
14
+ - **Config Validation** - Allowed loading configs without API keys and normalized optional fields to avoid setup lockouts.
15
+ - **Webhook Signatures** - Standardized signature verification format across dev server, trigger, and generated templates.
16
+ - **CLI Startup** - Lazy-loaded prompt dependencies in several commands for faster startup.
17
+
18
+ ### Fixed
19
+
20
+ - **Analytics Persistence** - Stored analytics in a safe user directory with test override support.
21
+ - **Dev Auto-Register** - Respected `dev.autoRegisterWebhook` in the dev command.
22
+ - **Team Import** - Enabled `--force` to overwrite existing keys during team import.
23
+ - **Config Import** - Validated imports with schema and normalized missing optional fields.
24
+
25
+ ## [1.4.5] - 2026-02-01
26
+
27
+ ### Changed
28
+
29
+ - **Credential Encryption** - Migrated stored credentials to AES-256-GCM with scrypt-derived keys and per-machine salt, with automatic legacy AES-256-CBC migration on load.
30
+ - **Init .gitignore Handling** - Made `.env` and `.paymongo` ignore entries idempotent and appended with a consistent header when missing.
31
+
32
+ ### Fixed
33
+
34
+ - **API Key Errors** - Standardized missing secret key handling to throw `ApiKeyError` in the API client.
35
+ - **Test Reliability** - Updated login and template tests for new encryption payloads and added DevServer webhook signature verification coverage.
36
+
10
37
  ## [1.4.4] - 2026-01-27
11
38
 
12
39
  ### Changed
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Leodyver Semilla
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Leodyver Semilla
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.