@miguelmorales13/nestkit 0.1.0 → 0.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.
Files changed (76) hide show
  1. package/README.md +305 -1
  2. package/dist/auth/auth-user.entity.d.ts +8 -0
  3. package/dist/auth/auth-user.port.d.ts +16 -0
  4. package/dist/auth/auth.controller.d.ts +25 -0
  5. package/dist/auth/auth.dto.d.ts +13 -0
  6. package/dist/auth/auth.service.d.ts +24 -0
  7. package/dist/auth/authenticated-user.d.ts +7 -0
  8. package/dist/auth/current-tenant.decorator.d.ts +2 -0
  9. package/dist/auth/current-user.decorator.d.ts +1 -0
  10. package/dist/auth/hash.util.d.ts +2 -0
  11. package/dist/auth/index.cjs +265 -0
  12. package/dist/auth/index.d.ts +16 -0
  13. package/dist/auth/index.js +265 -0
  14. package/dist/auth/jwt-auth.guard.d.ts +5 -0
  15. package/dist/auth/require-tenant.guard.d.ts +9 -0
  16. package/dist/auth/roles.decorator.d.ts +3 -0
  17. package/dist/auth/roles.guard.d.ts +11 -0
  18. package/dist/auth/token.service.d.ts +7 -0
  19. package/dist/bootstrap/index.cjs +11 -0
  20. package/dist/bootstrap/index.js +3 -2
  21. package/dist/chunk-2REOCMUD.cjs +16 -0
  22. package/dist/chunk-3CLYZC3T.cjs +104 -0
  23. package/dist/chunk-7FQQDWOZ.cjs +73 -0
  24. package/dist/chunk-7SOM7EZP.cjs +1 -0
  25. package/dist/chunk-DQYAIQQ5.js +0 -0
  26. package/dist/chunk-FDNGAYTZ.cjs +39 -0
  27. package/dist/chunk-KVBQBT3D.cjs +1 -0
  28. package/dist/chunk-M3EL5O6T.cjs +36 -0
  29. package/dist/chunk-MR2IFCZE.cjs +1 -0
  30. package/dist/chunk-O2ZMI3EK.cjs +32 -0
  31. package/dist/{chunk-HGJX2GPE.js → chunk-ORWJ7LES.js} +1 -1
  32. package/dist/{chunk-EQXYK6AL.js → chunk-Q45IEPWU.js} +5 -13
  33. package/dist/chunk-QS2W5XCQ.cjs +12 -0
  34. package/dist/chunk-R7BVS6CI.cjs +13 -0
  35. package/dist/chunk-RF75KC63.cjs +50 -0
  36. package/dist/{chunk-KP7GRCZW.js → chunk-RHNQGTAT.js} +3 -3
  37. package/dist/chunk-SPTDXUED.cjs +39 -0
  38. package/dist/chunk-TJHRABML.cjs +29 -0
  39. package/dist/chunk-V2M75FN3.cjs +40 -0
  40. package/dist/chunk-YFYHLYHN.js +13 -0
  41. package/dist/chunk-ZA56XBCK.cjs +20 -0
  42. package/dist/crud/index.cjs +9 -0
  43. package/dist/database/mongo/index.cjs +1 -0
  44. package/dist/database/postgres/index.cjs +11 -0
  45. package/dist/database/supabase/index.cjs +11 -0
  46. package/dist/email/nodemailer/index.cjs +40 -0
  47. package/dist/email/nodemailer/index.d.ts +1 -0
  48. package/dist/email/nodemailer/index.js +40 -0
  49. package/dist/email/nodemailer/nodemailer.module.d.ts +4 -0
  50. package/dist/email/resend/index.cjs +31 -0
  51. package/dist/email/resend/index.d.ts +1 -0
  52. package/dist/email/resend/index.js +31 -0
  53. package/dist/email/resend/resend.module.d.ts +4 -0
  54. package/dist/entities/index.cjs +7 -0
  55. package/dist/errors/index.cjs +25 -0
  56. package/dist/errors/index.js +6 -3
  57. package/dist/i18n/index.cjs +9 -0
  58. package/dist/index.cjs +78 -0
  59. package/dist/index.js +26 -23
  60. package/dist/response/index.cjs +9 -0
  61. package/dist/stripe/index.cjs +78 -0
  62. package/dist/stripe/index.d.ts +3 -0
  63. package/dist/stripe/index.js +78 -0
  64. package/dist/stripe/stripe-webhook.controller.d.ts +20 -0
  65. package/dist/stripe/stripe.module.d.ts +4 -0
  66. package/dist/telegram/index.cjs +31 -0
  67. package/dist/telegram/index.d.ts +1 -0
  68. package/dist/telegram/index.js +31 -0
  69. package/dist/telegram/telegram.module.d.ts +8 -0
  70. package/dist/tracking/index.cjs +15 -0
  71. package/dist/whatsapp/index.cjs +68 -0
  72. package/dist/whatsapp/index.d.ts +3 -0
  73. package/dist/whatsapp/index.js +68 -0
  74. package/dist/whatsapp/whatsapp-client.d.ts +21 -0
  75. package/dist/whatsapp/whatsapp.module.d.ts +4 -0
  76. package/package.json +96 -21
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkV2M75FN3cjs = require('../chunk-V2M75FN3.cjs');
6
+
7
+
8
+ var _chunkZA56XBCKcjs = require('../chunk-ZA56XBCK.cjs');
9
+ require('../chunk-2REOCMUD.cjs');
10
+
11
+
12
+
13
+
14
+
15
+ exports.REQUEST_ID_HEADER = _chunkV2M75FN3cjs.REQUEST_ID_HEADER; exports.RequestContext = _chunkZA56XBCKcjs.RequestContext; exports.RequestIdMiddleware = _chunkV2M75FN3cjs.RequestIdMiddleware; exports.TrackingModule = _chunkV2M75FN3cjs.TrackingModule;
@@ -0,0 +1,68 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+ var _chunk2REOCMUDcjs = require('../chunk-2REOCMUD.cjs');
4
+
5
+ // src/whatsapp/whatsapp.module.ts
6
+ var _common = require('@nestjs/common');
7
+
8
+ // src/whatsapp/whatsapp-client.ts
9
+ var DEFAULT_API_VERSION = "v21.0";
10
+ var WhatsAppClient = class {
11
+ constructor(options) {
12
+ this.options = options;
13
+ const version = _nullishCoalesce(options.apiVersion, () => ( DEFAULT_API_VERSION));
14
+ this.baseUrl = `https://graph.facebook.com/${version}/${options.phoneNumberId}/messages`;
15
+ }
16
+ async sendTextMessage(to, body) {
17
+ const response = await fetch(this.baseUrl, {
18
+ method: "POST",
19
+ headers: {
20
+ Authorization: `Bearer ${this.options.accessToken}`,
21
+ "Content-Type": "application/json"
22
+ },
23
+ body: JSON.stringify({
24
+ messaging_product: "whatsapp",
25
+ to,
26
+ type: "text",
27
+ text: { body }
28
+ })
29
+ });
30
+ if (!response.ok) {
31
+ const errorBody = await response.text();
32
+ throw new Error(`WhatsAppClient: send failed (${response.status}): ${errorBody}`);
33
+ }
34
+ return await response.json();
35
+ }
36
+ };
37
+
38
+ // src/whatsapp/whatsapp.module.ts
39
+ var WHATSAPP_CLIENT = /* @__PURE__ */ Symbol("WHATSAPP_CLIENT");
40
+ function requireEnv(name) {
41
+ const value = process.env[name];
42
+ if (!value) {
43
+ throw new Error(`WhatsAppModule: ${name} environment variable is not set`);
44
+ }
45
+ return value;
46
+ }
47
+ var WhatsAppModule = class {
48
+ };
49
+ WhatsAppModule = exports.WhatsAppModule = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
50
+ _common.Module.call(void 0, {
51
+ providers: [
52
+ {
53
+ provide: WHATSAPP_CLIENT,
54
+ useFactory: () => new WhatsAppClient({
55
+ accessToken: requireEnv("WHATSAPP_ACCESS_TOKEN"),
56
+ phoneNumberId: requireEnv("WHATSAPP_PHONE_NUMBER_ID"),
57
+ apiVersion: process.env.WHATSAPP_API_VERSION
58
+ })
59
+ }
60
+ ],
61
+ exports: [WHATSAPP_CLIENT]
62
+ })
63
+ ], WhatsAppModule);
64
+
65
+
66
+
67
+
68
+ exports.WHATSAPP_CLIENT = WHATSAPP_CLIENT; exports.WhatsAppClient = WhatsAppClient; exports.WhatsAppModule = WhatsAppModule;
@@ -0,0 +1,3 @@
1
+ export { WhatsAppModule, WHATSAPP_CLIENT } from './whatsapp.module.js';
2
+ export { WhatsAppClient } from './whatsapp-client.js';
3
+ export type { WhatsAppClientOptions, WhatsAppSendResult } from './whatsapp-client.js';
@@ -0,0 +1,68 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../chunk-4MGIQFAJ.js";
4
+
5
+ // src/whatsapp/whatsapp.module.ts
6
+ import { Module } from "@nestjs/common";
7
+
8
+ // src/whatsapp/whatsapp-client.ts
9
+ var DEFAULT_API_VERSION = "v21.0";
10
+ var WhatsAppClient = class {
11
+ constructor(options) {
12
+ this.options = options;
13
+ const version = options.apiVersion ?? DEFAULT_API_VERSION;
14
+ this.baseUrl = `https://graph.facebook.com/${version}/${options.phoneNumberId}/messages`;
15
+ }
16
+ async sendTextMessage(to, body) {
17
+ const response = await fetch(this.baseUrl, {
18
+ method: "POST",
19
+ headers: {
20
+ Authorization: `Bearer ${this.options.accessToken}`,
21
+ "Content-Type": "application/json"
22
+ },
23
+ body: JSON.stringify({
24
+ messaging_product: "whatsapp",
25
+ to,
26
+ type: "text",
27
+ text: { body }
28
+ })
29
+ });
30
+ if (!response.ok) {
31
+ const errorBody = await response.text();
32
+ throw new Error(`WhatsAppClient: send failed (${response.status}): ${errorBody}`);
33
+ }
34
+ return await response.json();
35
+ }
36
+ };
37
+
38
+ // src/whatsapp/whatsapp.module.ts
39
+ var WHATSAPP_CLIENT = /* @__PURE__ */ Symbol("WHATSAPP_CLIENT");
40
+ function requireEnv(name) {
41
+ const value = process.env[name];
42
+ if (!value) {
43
+ throw new Error(`WhatsAppModule: ${name} environment variable is not set`);
44
+ }
45
+ return value;
46
+ }
47
+ var WhatsAppModule = class {
48
+ };
49
+ WhatsAppModule = __decorateClass([
50
+ Module({
51
+ providers: [
52
+ {
53
+ provide: WHATSAPP_CLIENT,
54
+ useFactory: () => new WhatsAppClient({
55
+ accessToken: requireEnv("WHATSAPP_ACCESS_TOKEN"),
56
+ phoneNumberId: requireEnv("WHATSAPP_PHONE_NUMBER_ID"),
57
+ apiVersion: process.env.WHATSAPP_API_VERSION
58
+ })
59
+ }
60
+ ],
61
+ exports: [WHATSAPP_CLIENT]
62
+ })
63
+ ], WhatsAppModule);
64
+ export {
65
+ WHATSAPP_CLIENT,
66
+ WhatsAppClient,
67
+ WhatsAppModule
68
+ };
@@ -0,0 +1,21 @@
1
+ export interface WhatsAppClientOptions {
2
+ accessToken: string;
3
+ phoneNumberId: string;
4
+ apiVersion?: string;
5
+ }
6
+ export interface WhatsAppSendResult {
7
+ messagingProduct: 'whatsapp';
8
+ messages: Array<{
9
+ id: string;
10
+ }>;
11
+ }
12
+ /**
13
+ * Minimal outbound client for the WhatsApp Cloud API (Meta Graph API).
14
+ * No SDK dependency — built on Node's global `fetch` (18+).
15
+ */
16
+ export declare class WhatsAppClient {
17
+ private readonly options;
18
+ private readonly baseUrl;
19
+ constructor(options: WhatsAppClientOptions);
20
+ sendTextMessage(to: string, body: string): Promise<WhatsAppSendResult>;
21
+ }
@@ -0,0 +1,4 @@
1
+ /** DI token for the WhatsApp Cloud API client. Inject with `@Inject(WHATSAPP_CLIENT)`. */
2
+ export declare const WHATSAPP_CLIENT: unique symbol;
3
+ export declare class WhatsAppModule {
4
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@miguelmorales13/nestkit",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "description": "Reusable NestJS building blocks: i18n, error handling, standardized responses, request tracking, base entities, generic CRUD, and Postgres/Supabase connection helpers.",
7
+ "description": "Reusable NestJS building blocks: i18n, error handling, standardized responses, request tracking, base entities, generic CRUD, Postgres/Supabase connection helpers, outbound Telegram/WhatsApp/Stripe clients, batteries-included auth, Stripe webhooks, and Resend/Nodemailer email.",
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
@@ -18,47 +18,88 @@
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js"
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.cjs"
22
23
  },
23
24
  "./entities": {
24
25
  "types": "./dist/entities/index.d.ts",
25
- "import": "./dist/entities/index.js"
26
+ "import": "./dist/entities/index.js",
27
+ "require": "./dist/entities/index.cjs"
26
28
  },
27
29
  "./response": {
28
30
  "types": "./dist/response/index.d.ts",
29
- "import": "./dist/response/index.js"
31
+ "import": "./dist/response/index.js",
32
+ "require": "./dist/response/index.cjs"
30
33
  },
31
34
  "./errors": {
32
35
  "types": "./dist/errors/index.d.ts",
33
- "import": "./dist/errors/index.js"
36
+ "import": "./dist/errors/index.js",
37
+ "require": "./dist/errors/index.cjs"
34
38
  },
35
39
  "./tracking": {
36
40
  "types": "./dist/tracking/index.d.ts",
37
- "import": "./dist/tracking/index.js"
41
+ "import": "./dist/tracking/index.js",
42
+ "require": "./dist/tracking/index.cjs"
38
43
  },
39
44
  "./crud": {
40
45
  "types": "./dist/crud/index.d.ts",
41
- "import": "./dist/crud/index.js"
46
+ "import": "./dist/crud/index.js",
47
+ "require": "./dist/crud/index.cjs"
42
48
  },
43
49
  "./database/postgres": {
44
50
  "types": "./dist/database/postgres/index.d.ts",
45
- "import": "./dist/database/postgres/index.js"
51
+ "import": "./dist/database/postgres/index.js",
52
+ "require": "./dist/database/postgres/index.cjs"
46
53
  },
47
54
  "./database/supabase": {
48
55
  "types": "./dist/database/supabase/index.d.ts",
49
- "import": "./dist/database/supabase/index.js"
56
+ "import": "./dist/database/supabase/index.js",
57
+ "require": "./dist/database/supabase/index.cjs"
50
58
  },
51
59
  "./database/mongo": {
52
60
  "types": "./dist/database/mongo/index.d.ts",
53
- "import": "./dist/database/mongo/index.js"
61
+ "import": "./dist/database/mongo/index.js",
62
+ "require": "./dist/database/mongo/index.cjs"
63
+ },
64
+ "./telegram": {
65
+ "types": "./dist/telegram/index.d.ts",
66
+ "import": "./dist/telegram/index.js",
67
+ "require": "./dist/telegram/index.cjs"
68
+ },
69
+ "./whatsapp": {
70
+ "types": "./dist/whatsapp/index.d.ts",
71
+ "import": "./dist/whatsapp/index.js",
72
+ "require": "./dist/whatsapp/index.cjs"
73
+ },
74
+ "./stripe": {
75
+ "types": "./dist/stripe/index.d.ts",
76
+ "import": "./dist/stripe/index.js",
77
+ "require": "./dist/stripe/index.cjs"
78
+ },
79
+ "./auth": {
80
+ "types": "./dist/auth/index.d.ts",
81
+ "import": "./dist/auth/index.js",
82
+ "require": "./dist/auth/index.cjs"
83
+ },
84
+ "./email/resend": {
85
+ "types": "./dist/email/resend/index.d.ts",
86
+ "import": "./dist/email/resend/index.js",
87
+ "require": "./dist/email/resend/index.cjs"
88
+ },
89
+ "./email/nodemailer": {
90
+ "types": "./dist/email/nodemailer/index.d.ts",
91
+ "import": "./dist/email/nodemailer/index.js",
92
+ "require": "./dist/email/nodemailer/index.cjs"
54
93
  },
55
94
  "./i18n": {
56
95
  "types": "./dist/i18n/index.d.ts",
57
- "import": "./dist/i18n/index.js"
96
+ "import": "./dist/i18n/index.js",
97
+ "require": "./dist/i18n/index.cjs"
58
98
  },
59
99
  "./bootstrap": {
60
100
  "types": "./dist/bootstrap/index.d.ts",
61
- "import": "./dist/bootstrap/index.js"
101
+ "import": "./dist/bootstrap/index.js",
102
+ "require": "./dist/bootstrap/index.cjs"
62
103
  }
63
104
  },
64
105
  "scripts": {
@@ -74,7 +115,13 @@
74
115
  "helmet": "^8.0.0",
75
116
  "pg": "^8.11.0",
76
117
  "reflect-metadata": "^0.2.0",
77
- "rxjs": "^7.8.0"
118
+ "rxjs": "^7.8.0",
119
+ "telegraf": "^4.16.0",
120
+ "stripe": "^22.0.0",
121
+ "class-validator": "^0.15.0",
122
+ "class-transformer": "^0.5.1",
123
+ "resend": "^6.20.0",
124
+ "nodemailer": "^9.0.5"
78
125
  },
79
126
  "peerDependenciesMeta": {
80
127
  "pg": {
@@ -88,25 +135,53 @@
88
135
  },
89
136
  "helmet": {
90
137
  "optional": true
138
+ },
139
+ "telegraf": {
140
+ "optional": true
141
+ },
142
+ "stripe": {
143
+ "optional": true
144
+ },
145
+ "class-validator": {
146
+ "optional": true
147
+ },
148
+ "class-transformer": {
149
+ "optional": true
150
+ },
151
+ "resend": {
152
+ "optional": true
153
+ },
154
+ "nodemailer": {
155
+ "optional": true
91
156
  }
92
157
  },
93
158
  "dependencies": {
94
- "nestjs-i18n": "^10.4.5"
159
+ "nestjs-i18n": "^10.4.5",
160
+ "bcryptjs": "^3.0.3",
161
+ "jsonwebtoken": "^9.0.3"
95
162
  },
96
163
  "devDependencies": {
97
- "typescript": "^5.6.0",
98
- "tsup": "^8.5.1",
99
- "@types/node": "^22.0.0",
100
164
  "@nestjs/common": "^11.0.0",
101
165
  "@nestjs/core": "^11.0.0",
102
166
  "@nestjs/swagger": "^11.0.0",
103
167
  "@supabase/supabase-js": "^2.45.0",
104
- "pg": "^8.11.0",
168
+ "@types/jsonwebtoken": "^9.0.10",
169
+ "@types/node": "^22.0.0",
170
+ "@types/nodemailer": "^8.0.1",
105
171
  "@types/pg": "^8.11.0",
172
+ "bcryptjs": "^3.0.3",
173
+ "class-transformer": "^0.5.1",
174
+ "class-validator": "^0.15.1",
106
175
  "helmet": "^8.0.0",
176
+ "jsonwebtoken": "^9.0.3",
177
+ "nodemailer": "^9.0.5",
178
+ "pg": "^8.11.0",
107
179
  "reflect-metadata": "^0.2.0",
180
+ "resend": "^6.20.0",
108
181
  "rxjs": "^7.8.0",
109
- "class-validator": "^0.14.0",
110
- "class-transformer": "^0.5.1"
182
+ "stripe": "^22.5.0",
183
+ "telegraf": "^4.16.3",
184
+ "tsup": "^8.5.1",
185
+ "typescript": "^5.6.0"
111
186
  }
112
187
  }