@goplusvn/core 0.1.1 → 0.1.2

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 (223) hide show
  1. package/package.json +30 -175
  2. package/dist/audit/index.d.mts +0 -115
  3. package/dist/audit/index.d.ts +0 -115
  4. package/dist/audit/index.js +0 -204
  5. package/dist/audit/index.js.map +0 -1
  6. package/dist/audit/index.mjs +0 -200
  7. package/dist/audit/index.mjs.map +0 -1
  8. package/dist/auth/index.d.mts +0 -86
  9. package/dist/auth/index.d.ts +0 -86
  10. package/dist/auth/index.js +0 -210
  11. package/dist/auth/index.js.map +0 -1
  12. package/dist/auth/index.mjs +0 -198
  13. package/dist/auth/index.mjs.map +0 -1
  14. package/dist/button-1dWvP9Ib.d.mts +0 -30
  15. package/dist/button-1dWvP9Ib.d.ts +0 -30
  16. package/dist/calendar-2QzdEo1z.d.mts +0 -20
  17. package/dist/calendar-2QzdEo1z.d.ts +0 -20
  18. package/dist/code-generation/index.d.mts +0 -30
  19. package/dist/code-generation/index.d.ts +0 -30
  20. package/dist/code-generation/index.js +0 -31
  21. package/dist/code-generation/index.js.map +0 -1
  22. package/dist/code-generation/index.mjs +0 -28
  23. package/dist/code-generation/index.mjs.map +0 -1
  24. package/dist/configs/index.d.mts +0 -175
  25. package/dist/configs/index.d.ts +0 -175
  26. package/dist/configs/index.js +0 -254
  27. package/dist/configs/index.js.map +0 -1
  28. package/dist/configs/index.mjs +0 -233
  29. package/dist/configs/index.mjs.map +0 -1
  30. package/dist/crud/index.d.mts +0 -646
  31. package/dist/crud/index.d.ts +0 -646
  32. package/dist/crud/index.js +0 -11772
  33. package/dist/crud/index.js.map +0 -1
  34. package/dist/crud/index.mjs +0 -11665
  35. package/dist/crud/index.mjs.map +0 -1
  36. package/dist/crud/server.d.mts +0 -20
  37. package/dist/crud/server.d.ts +0 -20
  38. package/dist/crud/server.js +0 -123
  39. package/dist/crud/server.js.map +0 -1
  40. package/dist/crud/server.mjs +0 -120
  41. package/dist/crud/server.mjs.map +0 -1
  42. package/dist/data-table-skeleton-12NA8Mjx.d.mts +0 -39
  43. package/dist/data-table-skeleton-12NA8Mjx.d.ts +0 -39
  44. package/dist/dialog-bKfjZMTd.d.mts +0 -22
  45. package/dist/dialog-bKfjZMTd.d.ts +0 -22
  46. package/dist/dynamic-icon-DrGIiu2N.d.mts +0 -10
  47. package/dist/dynamic-icon-DrGIiu2N.d.ts +0 -10
  48. package/dist/home/index.d.mts +0 -269
  49. package/dist/home/index.d.ts +0 -269
  50. package/dist/home/index.js +0 -1678
  51. package/dist/home/index.js.map +0 -1
  52. package/dist/home/index.mjs +0 -1635
  53. package/dist/home/index.mjs.map +0 -1
  54. package/dist/hooks/index.d.mts +0 -7
  55. package/dist/hooks/index.d.ts +0 -7
  56. package/dist/hooks/index.js +0 -8316
  57. package/dist/hooks/index.js.map +0 -1
  58. package/dist/hooks/index.mjs +0 -8255
  59. package/dist/hooks/index.mjs.map +0 -1
  60. package/dist/index-50hpiPrV.d.ts +0 -116
  61. package/dist/index-B9zQVEVi.d.mts +0 -116
  62. package/dist/index.d.mts +0 -5
  63. package/dist/index.d.ts +0 -5
  64. package/dist/index.js +0 -123
  65. package/dist/index.js.map +0 -1
  66. package/dist/index.mjs +0 -118
  67. package/dist/index.mjs.map +0 -1
  68. package/dist/infrastructure/index.d.mts +0 -423
  69. package/dist/infrastructure/index.d.ts +0 -423
  70. package/dist/infrastructure/index.js +0 -633
  71. package/dist/infrastructure/index.js.map +0 -1
  72. package/dist/infrastructure/index.mjs +0 -619
  73. package/dist/infrastructure/index.mjs.map +0 -1
  74. package/dist/label-DWTEkNPo.d.ts +0 -226
  75. package/dist/label-LPpdcoBx.d.mts +0 -226
  76. package/dist/layout/index.d.mts +0 -48
  77. package/dist/layout/index.d.ts +0 -48
  78. package/dist/layout/index.js +0 -117
  79. package/dist/layout/index.js.map +0 -1
  80. package/dist/layout/index.mjs +0 -90
  81. package/dist/layout/index.mjs.map +0 -1
  82. package/dist/navigation/index.d.mts +0 -16
  83. package/dist/navigation/index.d.ts +0 -16
  84. package/dist/navigation/index.js +0 -53
  85. package/dist/navigation/index.js.map +0 -1
  86. package/dist/navigation/index.mjs +0 -50
  87. package/dist/navigation/index.mjs.map +0 -1
  88. package/dist/notification/index.d.mts +0 -105
  89. package/dist/notification/index.d.ts +0 -105
  90. package/dist/notification/index.js +0 -278
  91. package/dist/notification/index.js.map +0 -1
  92. package/dist/notification/index.mjs +0 -274
  93. package/dist/notification/index.mjs.map +0 -1
  94. package/dist/organization/index.d.mts +0 -99
  95. package/dist/organization/index.d.ts +0 -99
  96. package/dist/organization/index.js +0 -360
  97. package/dist/organization/index.js.map +0 -1
  98. package/dist/organization/index.mjs +0 -352
  99. package/dist/organization/index.mjs.map +0 -1
  100. package/dist/plugin/index.d.mts +0 -83
  101. package/dist/plugin/index.d.ts +0 -83
  102. package/dist/plugin/index.js +0 -86
  103. package/dist/plugin/index.js.map +0 -1
  104. package/dist/plugin/index.mjs +0 -84
  105. package/dist/plugin/index.mjs.map +0 -1
  106. package/dist/providers/index.d.mts +0 -25
  107. package/dist/providers/index.d.ts +0 -25
  108. package/dist/providers/index.js +0 -84
  109. package/dist/providers/index.js.map +0 -1
  110. package/dist/providers/index.mjs +0 -77
  111. package/dist/providers/index.mjs.map +0 -1
  112. package/dist/rbac/index.d.mts +0 -226
  113. package/dist/rbac/index.d.ts +0 -226
  114. package/dist/rbac/index.js +0 -4784
  115. package/dist/rbac/index.js.map +0 -1
  116. package/dist/rbac/index.mjs +0 -4722
  117. package/dist/rbac/index.mjs.map +0 -1
  118. package/dist/rbac/permissions.d.mts +0 -26
  119. package/dist/rbac/permissions.d.ts +0 -26
  120. package/dist/rbac/permissions.js +0 -94
  121. package/dist/rbac/permissions.js.map +0 -1
  122. package/dist/rbac/permissions.mjs +0 -90
  123. package/dist/rbac/permissions.mjs.map +0 -1
  124. package/dist/rbac/server.d.mts +0 -1
  125. package/dist/rbac/server.d.ts +0 -1
  126. package/dist/rbac/server.js +0 -128
  127. package/dist/rbac/server.js.map +0 -1
  128. package/dist/rbac/server.mjs +0 -124
  129. package/dist/rbac/server.mjs.map +0 -1
  130. package/dist/schemas/index.d.mts +0 -1257
  131. package/dist/schemas/index.d.ts +0 -1257
  132. package/dist/schemas/index.js +0 -572
  133. package/dist/schemas/index.js.map +0 -1
  134. package/dist/schemas/index.mjs +0 -523
  135. package/dist/schemas/index.mjs.map +0 -1
  136. package/dist/server-QuYCTa89.d.mts +0 -83
  137. package/dist/server-QuYCTa89.d.ts +0 -83
  138. package/dist/sonner-C74GlRDQ.d.mts +0 -71
  139. package/dist/sonner-C74GlRDQ.d.ts +0 -71
  140. package/dist/status-BOXZgIqX.d.mts +0 -12
  141. package/dist/status-BOXZgIqX.d.ts +0 -12
  142. package/dist/system/index.d.mts +0 -77
  143. package/dist/system/index.d.ts +0 -77
  144. package/dist/system/index.js +0 -102
  145. package/dist/system/index.js.map +0 -1
  146. package/dist/system/index.mjs +0 -100
  147. package/dist/system/index.mjs.map +0 -1
  148. package/dist/tabs-C6FfBwPY.d.mts +0 -18
  149. package/dist/tabs-C6FfBwPY.d.ts +0 -18
  150. package/dist/tenant-provider-B8eC_Wpb.d.mts +0 -27
  151. package/dist/tenant-provider-B8eC_Wpb.d.ts +0 -27
  152. package/dist/types/index.d.mts +0 -469
  153. package/dist/types/index.d.ts +0 -469
  154. package/dist/types/index.js +0 -25
  155. package/dist/types/index.js.map +0 -1
  156. package/dist/types/index.mjs +0 -21
  157. package/dist/types/index.mjs.map +0 -1
  158. package/dist/ui/auth.d.mts +0 -39
  159. package/dist/ui/auth.d.ts +0 -39
  160. package/dist/ui/auth.js +0 -4941
  161. package/dist/ui/auth.js.map +0 -1
  162. package/dist/ui/auth.mjs +0 -4896
  163. package/dist/ui/auth.mjs.map +0 -1
  164. package/dist/ui/crud.d.mts +0 -2
  165. package/dist/ui/crud.d.ts +0 -2
  166. package/dist/ui/crud.js +0 -4
  167. package/dist/ui/crud.js.map +0 -1
  168. package/dist/ui/crud.mjs +0 -3
  169. package/dist/ui/crud.mjs.map +0 -1
  170. package/dist/ui/data-display.d.mts +0 -596
  171. package/dist/ui/data-display.d.ts +0 -596
  172. package/dist/ui/data-display.js +0 -5307
  173. package/dist/ui/data-display.js.map +0 -1
  174. package/dist/ui/data-display.mjs +0 -5212
  175. package/dist/ui/data-display.mjs.map +0 -1
  176. package/dist/ui/feedback.d.mts +0 -55
  177. package/dist/ui/feedback.d.ts +0 -55
  178. package/dist/ui/feedback.js +0 -2608
  179. package/dist/ui/feedback.js.map +0 -1
  180. package/dist/ui/feedback.mjs +0 -2526
  181. package/dist/ui/feedback.mjs.map +0 -1
  182. package/dist/ui/forms.d.mts +0 -309
  183. package/dist/ui/forms.d.ts +0 -309
  184. package/dist/ui/forms.js +0 -4656
  185. package/dist/ui/forms.js.map +0 -1
  186. package/dist/ui/forms.mjs +0 -4571
  187. package/dist/ui/forms.mjs.map +0 -1
  188. package/dist/ui/index.d.mts +0 -331
  189. package/dist/ui/index.d.ts +0 -331
  190. package/dist/ui/index.js +0 -16953
  191. package/dist/ui/index.js.map +0 -1
  192. package/dist/ui/index.mjs +0 -16598
  193. package/dist/ui/index.mjs.map +0 -1
  194. package/dist/ui/primitives/client.d.mts +0 -61
  195. package/dist/ui/primitives/client.d.ts +0 -61
  196. package/dist/ui/primitives/client.js +0 -3408
  197. package/dist/ui/primitives/client.js.map +0 -1
  198. package/dist/ui/primitives/client.mjs +0 -3256
  199. package/dist/ui/primitives/client.mjs.map +0 -1
  200. package/dist/ui/primitives.d.mts +0 -113
  201. package/dist/ui/primitives.d.ts +0 -113
  202. package/dist/ui/primitives.js +0 -3356
  203. package/dist/ui/primitives.js.map +0 -1
  204. package/dist/ui/primitives.mjs +0 -3227
  205. package/dist/ui/primitives.mjs.map +0 -1
  206. package/dist/user/index.d.mts +0 -228
  207. package/dist/user/index.d.ts +0 -228
  208. package/dist/user/index.js +0 -4306
  209. package/dist/user/index.js.map +0 -1
  210. package/dist/user/index.mjs +0 -4260
  211. package/dist/user/index.mjs.map +0 -1
  212. package/dist/utils/index.d.mts +0 -205
  213. package/dist/utils/index.d.ts +0 -205
  214. package/dist/utils/index.js +0 -574
  215. package/dist/utils/index.js.map +0 -1
  216. package/dist/utils/index.mjs +0 -514
  217. package/dist/utils/index.mjs.map +0 -1
  218. package/dist/workflow/index.d.mts +0 -40
  219. package/dist/workflow/index.d.ts +0 -40
  220. package/dist/workflow/index.js +0 -3710
  221. package/dist/workflow/index.js.map +0 -1
  222. package/dist/workflow/index.mjs +0 -3677
  223. package/dist/workflow/index.mjs.map +0 -1
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@goplusvn/core",
3
3
  "description": "GoPlusVN Platform Kit - ERP kernel: layout, RBAC, CRUD, multi-tenant, system pages",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org",
8
8
  "access": "public"
9
9
  },
10
- "main": "./dist/index.js",
11
- "module": "./dist/index.mjs",
12
- "types": "./dist/index.d.ts",
10
+ "main": "./src/index.ts",
11
+ "module": "./src/index.ts",
12
+ "types": "./src/index.ts",
13
13
  "sideEffects": false,
14
14
  "files": [
15
- "dist",
16
15
  "src",
17
16
  "README.md",
18
17
  "CHANGELOG.md"
@@ -24,176 +23,32 @@
24
23
  },
25
24
  "exports": {
26
25
  ".": {
27
- "types": "./dist/index.d.ts",
28
- "import": "./dist/index.mjs",
29
- "require": "./dist/index.js"
30
- },
31
- "./system": {
32
- "types": "./dist/system/index.d.ts",
33
- "import": "./dist/system/index.mjs",
34
- "require": "./dist/system/index.js"
35
- },
36
- "./auth": {
37
- "types": "./dist/auth/index.d.ts",
38
- "import": "./dist/auth/index.mjs",
39
- "require": "./dist/auth/index.js"
40
- },
41
- "./types": {
42
- "types": "./dist/types/index.d.ts",
43
- "import": "./dist/types/index.mjs",
44
- "require": "./dist/types/index.js"
45
- },
46
- "./utils": {
47
- "types": "./dist/utils/index.d.ts",
48
- "import": "./dist/utils/index.mjs",
49
- "require": "./dist/utils/index.js"
50
- },
51
- "./layout": {
52
- "types": "./dist/layout/index.d.ts",
53
- "import": "./dist/layout/index.mjs",
54
- "require": "./dist/layout/index.js"
55
- },
56
- "./crud": {
57
- "types": "./dist/crud/index.d.ts",
58
- "import": "./dist/crud/index.mjs",
59
- "require": "./dist/crud/index.js"
60
- },
61
- "./crud/server": {
62
- "types": "./dist/crud/server.d.ts",
63
- "import": "./dist/crud/server.mjs",
64
- "require": "./dist/crud/server.js"
65
- },
66
- "./ui": {
67
- "types": "./dist/ui/index.d.ts",
68
- "import": "./dist/ui/index.mjs",
69
- "require": "./dist/ui/index.js"
70
- },
71
- "./ui/auth": {
72
- "types": "./dist/ui/auth.d.ts",
73
- "import": "./dist/ui/auth.mjs",
74
- "require": "./dist/ui/auth.js"
75
- },
76
- "./ui/primitives": {
77
- "types": "./dist/ui/primitives.d.ts",
78
- "import": "./dist/ui/primitives.mjs",
79
- "require": "./dist/ui/primitives.js"
80
- },
81
- "./ui/primitives/client": {
82
- "types": "./dist/ui/primitives/client.d.ts",
83
- "import": "./dist/ui/primitives/client.mjs",
84
- "require": "./dist/ui/primitives/client.js"
85
- },
86
- "./ui/forms": {
87
- "types": "./dist/ui/forms/index.d.ts",
88
- "import": "./dist/ui/forms/index.mjs",
89
- "require": "./dist/ui/forms/index.js"
90
- },
91
- "./ui/data-display": {
92
- "types": "./dist/ui/data-display/index.d.ts",
93
- "import": "./dist/ui/data-display/index.mjs",
94
- "require": "./dist/ui/data-display/index.js"
95
- },
96
- "./ui/feedback": {
97
- "types": "./dist/ui/feedback.d.ts",
98
- "import": "./dist/ui/feedback.mjs",
99
- "require": "./dist/ui/feedback.js"
100
- },
101
- "./ui/crud": {
102
- "types": "./dist/ui/crud/index.d.ts",
103
- "import": "./dist/ui/crud/index.mjs",
104
- "require": "./dist/ui/crud/index.js"
105
- },
106
- "./hooks": {
107
- "types": "./dist/hooks/index.d.ts",
108
- "import": "./dist/hooks/index.mjs",
109
- "require": "./dist/hooks/index.js"
110
- },
111
- "./configs": {
112
- "types": "./dist/configs/index.d.ts",
113
- "import": "./dist/configs/index.mjs",
114
- "require": "./dist/configs/index.js"
115
- },
116
- "./providers": {
117
- "types": "./dist/providers/index.d.ts",
118
- "import": "./dist/providers/index.mjs",
119
- "require": "./dist/providers/index.js"
120
- },
121
- "./workflow": {
122
- "types": "./dist/workflow/index.d.ts",
123
- "import": "./dist/workflow/index.mjs",
124
- "require": "./dist/workflow/index.js"
125
- },
126
- "./navigation": {
127
- "types": "./dist/navigation/index.d.ts",
128
- "import": "./dist/navigation/index.mjs",
129
- "require": "./dist/navigation/index.js"
130
- },
131
- "./rbac": {
132
- "types": "./dist/rbac/index.d.ts",
133
- "import": "./dist/rbac/index.mjs",
134
- "require": "./dist/rbac/index.js"
135
- },
136
- "./rbac/permissions": {
137
- "types": "./dist/rbac/permissions.d.ts",
138
- "import": "./dist/rbac/permissions.mjs",
139
- "require": "./dist/rbac/permissions.js"
140
- },
141
- "./rbac/server": {
142
- "types": "./dist/rbac/server.d.ts",
143
- "import": "./dist/rbac/server.mjs",
144
- "require": "./dist/rbac/server.js"
145
- },
146
- "./organization": {
147
- "types": "./dist/organization/index.d.ts",
148
- "import": "./dist/organization/index.mjs",
149
- "require": "./dist/organization/index.js"
150
- },
151
- "./assets/erp_wallpaper.png": "./src/assets/erp_wallpaper.png",
152
- "./plugin": {
153
- "types": "./dist/plugin/index.d.ts",
154
- "import": "./dist/plugin/index.mjs",
155
- "require": "./dist/plugin/index.js"
156
- },
157
- "./code-generation": {
158
- "types": "./dist/code-generation/index.d.ts",
159
- "import": "./dist/code-generation/index.mjs",
160
- "require": "./dist/code-generation/index.js"
161
- },
162
- "./schemas": {
163
- "types": "./dist/schemas/index.d.ts",
164
- "import": "./dist/schemas/index.mjs",
165
- "require": "./dist/schemas/index.js"
166
- },
167
- "./infrastructure": {
168
- "types": "./dist/infrastructure/index.d.ts",
169
- "import": "./dist/infrastructure/index.mjs",
170
- "require": "./dist/infrastructure/index.js"
171
- },
172
- "./audit": {
173
- "types": "./dist/audit/index.d.ts",
174
- "import": "./dist/audit/index.mjs",
175
- "require": "./dist/audit/index.js"
176
- },
177
- "./notification": {
178
- "types": "./dist/notification/index.d.ts",
179
- "import": "./dist/notification/index.mjs",
180
- "require": "./dist/notification/index.js"
181
- },
182
- "./home": {
183
- "types": "./dist/home/index.d.ts",
184
- "import": "./dist/home/index.mjs",
185
- "require": "./dist/home/index.js"
186
- },
187
- "./user": {
188
- "types": "./dist/user/index.d.ts",
189
- "import": "./dist/user/index.mjs",
190
- "require": "./dist/user/index.js"
191
- },
192
- "./user/client-page": {
193
- "types": "./src/user/pages/users-client-page.tsx",
194
- "import": "./src/user/pages/users-client-page.tsx",
195
- "require": "./src/user/pages/users-client-page.tsx"
196
- }
26
+ "types": "./src/index.ts",
27
+ "import": "./src/index.ts",
28
+ "default": "./src/index.ts"
29
+ },
30
+ "./*": {
31
+ "types": [
32
+ "./src/*.ts",
33
+ "./src/*.tsx",
34
+ "./src/*/index.ts",
35
+ "./src/*/index.tsx"
36
+ ],
37
+ "import": [
38
+ "./src/*.ts",
39
+ "./src/*.tsx",
40
+ "./src/*/index.ts",
41
+ "./src/*/index.tsx"
42
+ ],
43
+ "default": [
44
+ "./src/*.ts",
45
+ "./src/*.tsx",
46
+ "./src/*/index.ts",
47
+ "./src/*/index.tsx"
48
+ ]
49
+ },
50
+ "./assets/*": "./src/assets/*",
51
+ "./package.json": "./package.json"
197
52
  },
198
53
  "peerDependencies": {
199
54
  "next": ">=14.0.0",
@@ -1,115 +0,0 @@
1
- interface AuditLog {
2
- id: string;
3
- /** Action type: create, update, delete, login, logout, custom */
4
- action: string;
5
- /** Resource/entity name (e.g., 'purchase-order', 'user') */
6
- resource: string;
7
- /** Resource ID */
8
- resourceId?: string;
9
- /** User who performed the action */
10
- userId?: string;
11
- /** User's role at time of action */
12
- roleName?: string;
13
- /** Changes made (for update actions) */
14
- changes?: Record<string, {
15
- old: unknown;
16
- new: unknown;
17
- }>;
18
- /** Additional metadata */
19
- metadata?: Record<string, unknown>;
20
- /** Request IP address */
21
- ip?: string;
22
- /** User agent */
23
- userAgent?: string;
24
- /** HTTP status code */
25
- status?: number;
26
- /** Timestamp */
27
- createdAt: Date;
28
- }
29
- interface CreateAuditInput {
30
- action: string;
31
- resource: string;
32
- resourceId?: string;
33
- userId?: string;
34
- roleName?: string;
35
- changes?: Record<string, {
36
- old: unknown;
37
- new: unknown;
38
- }>;
39
- metadata?: Record<string, unknown>;
40
- ip?: string;
41
- userAgent?: string;
42
- status?: number;
43
- }
44
- interface AuditLogger {
45
- log(entry: AuditLog): Promise<void>;
46
- }
47
- interface AuditManagerOptions {
48
- /** Custom logger implementation */
49
- logger?: AuditLogger;
50
- /** Actions to automatically audit */
51
- actions?: string[];
52
- }
53
-
54
- /**
55
- * Console-based audit logger (default)
56
- * In production, replace with database or external service
57
- */
58
- declare class ConsoleAuditLogger implements AuditLogger {
59
- log(entry: AuditLog): Promise<void>;
60
- }
61
- /**
62
- * AuditManager - tracks actions for compliance and debugging
63
- *
64
- * @example
65
- * ```typescript
66
- * import { auditManager } from '@goerp/core/audit';
67
- *
68
- * // Log an action
69
- * await auditManager.log({
70
- * action: 'update',
71
- * resource: 'purchase-order',
72
- * resourceId: '123',
73
- * userId: session.user.id,
74
- * changes: { status: { old: 'pending', new: 'approved' } }
75
- * });
76
- * ```
77
- */
78
- declare class AuditManagerImpl {
79
- private auditLogger;
80
- private registeredActions;
81
- constructor(options?: AuditManagerOptions);
82
- /** Set custom audit logger */
83
- setLogger(auditLogger: AuditLogger): void;
84
- /** Register action for automatic auditing */
85
- registerAction(action: string): void;
86
- /** Check if action is registered for auditing */
87
- isRegistered(action: string): boolean;
88
- /** Log an audit entry */
89
- log(input: CreateAuditInput): Promise<void>;
90
- /**
91
- * Get logs if the logger supports it (specifically MemoryAuditLogger)
92
- */
93
- getLogs(filter?: any): AuditLog[];
94
- /** Create middleware for automatic API route auditing */
95
- middleware(): (ctx: {
96
- action?: {
97
- actionName: string;
98
- resourceName: string;
99
- };
100
- state?: {
101
- currentUser?: {
102
- id: string;
103
- };
104
- currentRole?: string;
105
- };
106
- request?: {
107
- ip?: string;
108
- header?: Record<string, string>;
109
- };
110
- status?: number;
111
- }, next: () => Promise<void>) => Promise<void>;
112
- }
113
- declare const auditManager: AuditManagerImpl;
114
-
115
- export { type AuditLog, type AuditLogger, AuditManagerImpl, type AuditManagerOptions, ConsoleAuditLogger, type CreateAuditInput, auditManager };
@@ -1,115 +0,0 @@
1
- interface AuditLog {
2
- id: string;
3
- /** Action type: create, update, delete, login, logout, custom */
4
- action: string;
5
- /** Resource/entity name (e.g., 'purchase-order', 'user') */
6
- resource: string;
7
- /** Resource ID */
8
- resourceId?: string;
9
- /** User who performed the action */
10
- userId?: string;
11
- /** User's role at time of action */
12
- roleName?: string;
13
- /** Changes made (for update actions) */
14
- changes?: Record<string, {
15
- old: unknown;
16
- new: unknown;
17
- }>;
18
- /** Additional metadata */
19
- metadata?: Record<string, unknown>;
20
- /** Request IP address */
21
- ip?: string;
22
- /** User agent */
23
- userAgent?: string;
24
- /** HTTP status code */
25
- status?: number;
26
- /** Timestamp */
27
- createdAt: Date;
28
- }
29
- interface CreateAuditInput {
30
- action: string;
31
- resource: string;
32
- resourceId?: string;
33
- userId?: string;
34
- roleName?: string;
35
- changes?: Record<string, {
36
- old: unknown;
37
- new: unknown;
38
- }>;
39
- metadata?: Record<string, unknown>;
40
- ip?: string;
41
- userAgent?: string;
42
- status?: number;
43
- }
44
- interface AuditLogger {
45
- log(entry: AuditLog): Promise<void>;
46
- }
47
- interface AuditManagerOptions {
48
- /** Custom logger implementation */
49
- logger?: AuditLogger;
50
- /** Actions to automatically audit */
51
- actions?: string[];
52
- }
53
-
54
- /**
55
- * Console-based audit logger (default)
56
- * In production, replace with database or external service
57
- */
58
- declare class ConsoleAuditLogger implements AuditLogger {
59
- log(entry: AuditLog): Promise<void>;
60
- }
61
- /**
62
- * AuditManager - tracks actions for compliance and debugging
63
- *
64
- * @example
65
- * ```typescript
66
- * import { auditManager } from '@goerp/core/audit';
67
- *
68
- * // Log an action
69
- * await auditManager.log({
70
- * action: 'update',
71
- * resource: 'purchase-order',
72
- * resourceId: '123',
73
- * userId: session.user.id,
74
- * changes: { status: { old: 'pending', new: 'approved' } }
75
- * });
76
- * ```
77
- */
78
- declare class AuditManagerImpl {
79
- private auditLogger;
80
- private registeredActions;
81
- constructor(options?: AuditManagerOptions);
82
- /** Set custom audit logger */
83
- setLogger(auditLogger: AuditLogger): void;
84
- /** Register action for automatic auditing */
85
- registerAction(action: string): void;
86
- /** Check if action is registered for auditing */
87
- isRegistered(action: string): boolean;
88
- /** Log an audit entry */
89
- log(input: CreateAuditInput): Promise<void>;
90
- /**
91
- * Get logs if the logger supports it (specifically MemoryAuditLogger)
92
- */
93
- getLogs(filter?: any): AuditLog[];
94
- /** Create middleware for automatic API route auditing */
95
- middleware(): (ctx: {
96
- action?: {
97
- actionName: string;
98
- resourceName: string;
99
- };
100
- state?: {
101
- currentUser?: {
102
- id: string;
103
- };
104
- currentRole?: string;
105
- };
106
- request?: {
107
- ip?: string;
108
- header?: Record<string, string>;
109
- };
110
- status?: number;
111
- }, next: () => Promise<void>) => Promise<void>;
112
- }
113
- declare const auditManager: AuditManagerImpl;
114
-
115
- export { type AuditLog, type AuditLogger, AuditManagerImpl, type AuditManagerOptions, ConsoleAuditLogger, type CreateAuditInput, auditManager };
@@ -1,204 +0,0 @@
1
- 'use strict';
2
-
3
- // src/infrastructure/logger/logger.ts
4
- var LOG_LEVELS = {
5
- trace: 0,
6
- debug: 1,
7
- info: 2,
8
- warn: 3,
9
- error: 4
10
- };
11
- function getLogLevel() {
12
- const envLevel = process.env.LOG_LEVEL?.toLowerCase();
13
- if (envLevel && LOG_LEVELS[envLevel] !== void 0) {
14
- return envLevel;
15
- }
16
- return process.env.NODE_ENV === "production" ? "info" : "debug";
17
- }
18
- function formatMessage(level, name, message, context) {
19
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
20
- const contextStr = context ? ` ${JSON.stringify(context)}` : "";
21
- return `${timestamp} [${level.toUpperCase()}] [${name}] ${message}${contextStr}`;
22
- }
23
- function shouldLog(level, minLevel) {
24
- return LOG_LEVELS[level] >= LOG_LEVELS[minLevel];
25
- }
26
- var ConsoleLogger = class {
27
- constructor(options = {}) {
28
- this.name = options.name || "App";
29
- this.level = options.level || getLogLevel();
30
- }
31
- trace(message, context) {
32
- if (shouldLog("trace", this.level)) {
33
- console.log(formatMessage("trace", this.name, message, context));
34
- }
35
- }
36
- debug(message, context) {
37
- if (shouldLog("debug", this.level)) {
38
- console.log(formatMessage("debug", this.name, message, context));
39
- }
40
- }
41
- info(message, context) {
42
- if (shouldLog("info", this.level)) {
43
- console.info(formatMessage("info", this.name, message, context));
44
- }
45
- }
46
- warn(message, context) {
47
- if (shouldLog("warn", this.level)) {
48
- console.warn(formatMessage("warn", this.name, message, context));
49
- }
50
- }
51
- error(message, context) {
52
- if (shouldLog("error", this.level)) {
53
- console.error(formatMessage("error", this.name, message, context));
54
- }
55
- }
56
- };
57
- function createLogger(nameOrOptions = {}) {
58
- const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions;
59
- return new ConsoleLogger(options);
60
- }
61
- createLogger("App");
62
-
63
- // src/audit/memory-audit-logger.ts
64
- var MemoryAuditLogger = class {
65
- constructor(maxLogs = 1e3) {
66
- this.logs = [];
67
- this.maxLogs = maxLogs;
68
- }
69
- async log(entry) {
70
- this.logs.unshift(entry);
71
- if (this.logs.length > this.maxLogs) {
72
- this.logs = this.logs.slice(0, this.maxLogs);
73
- }
74
- }
75
- /**
76
- * Get logs with filtering
77
- */
78
- getLogs(filter = {}) {
79
- let filtered = this.logs;
80
- if (filter.fromDate) {
81
- filtered = filtered.filter((log) => log.createdAt >= filter.fromDate);
82
- }
83
- if (filter.toDate) {
84
- filtered = filtered.filter((log) => log.createdAt <= filter.toDate);
85
- }
86
- if (filter.userId) {
87
- filtered = filtered.filter((log) => log.userId === filter.userId);
88
- }
89
- if (filter.action) {
90
- filtered = filtered.filter((log) => log.action === filter.action);
91
- }
92
- if (filter.resource) {
93
- filtered = filtered.filter((log) => log.resource === filter.resource);
94
- }
95
- if (filter.type) {
96
- filtered = filtered.filter((log) => {
97
- if (filter.type === "error") return (log.status || 200) >= 400;
98
- if (filter.type === "warning")
99
- return (log.status || 200) >= 300 && (log.status || 200) < 400;
100
- return (log.status || 200) < 300;
101
- });
102
- }
103
- const offset = filter.offset || 0;
104
- const limit = filter.limit || 50;
105
- return filtered.slice(offset, offset + limit);
106
- }
107
- /**
108
- * Clear all logs
109
- */
110
- clear() {
111
- this.logs = [];
112
- }
113
- };
114
-
115
- // src/audit/audit-manager.ts
116
- var logger2 = createLogger("AuditManager");
117
- var ConsoleAuditLogger = class {
118
- async log(entry) {
119
- logger2.info(`AUDIT: ${entry.action} ${entry.resource}`, {
120
- id: entry.id,
121
- resourceId: entry.resourceId,
122
- userId: entry.userId,
123
- changes: entry.changes
124
- });
125
- }
126
- };
127
- var AuditManagerImpl = class {
128
- constructor(options = {}) {
129
- this.auditLogger = options.logger || new MemoryAuditLogger();
130
- this.registeredActions = new Set(
131
- options.actions || ["create", "update", "delete", "login", "logout"]
132
- );
133
- }
134
- /** Set custom audit logger */
135
- setLogger(auditLogger) {
136
- this.auditLogger = auditLogger;
137
- }
138
- /** Register action for automatic auditing */
139
- registerAction(action) {
140
- this.registeredActions.add(action);
141
- }
142
- /** Check if action is registered for auditing */
143
- isRegistered(action) {
144
- return this.registeredActions.has(action);
145
- }
146
- /** Log an audit entry */
147
- async log(input) {
148
- const entry = {
149
- id: crypto.randomUUID(),
150
- ...input,
151
- createdAt: /* @__PURE__ */ new Date()
152
- };
153
- try {
154
- await this.auditLogger.log(entry);
155
- } catch (error) {
156
- logger2.error("Failed to log audit entry", { error: String(error) });
157
- }
158
- }
159
- /**
160
- * Get logs if the logger supports it (specifically MemoryAuditLogger)
161
- */
162
- getLogs(filter = {}) {
163
- if ("getLogs" in this.auditLogger) {
164
- return this.auditLogger.getLogs(filter);
165
- }
166
- return [];
167
- }
168
- /** Create middleware for automatic API route auditing */
169
- middleware() {
170
- return async (ctx, next) => {
171
- const startTime = Date.now();
172
- let error = null;
173
- try {
174
- await next();
175
- } catch (e) {
176
- error = e;
177
- throw e;
178
- } finally {
179
- if (ctx.action && this.isRegistered(ctx.action.actionName)) {
180
- await this.log({
181
- action: ctx.action.actionName,
182
- resource: ctx.action.resourceName,
183
- userId: ctx.state?.currentUser?.id,
184
- roleName: ctx.state?.currentRole,
185
- ip: ctx.request?.ip,
186
- userAgent: ctx.request?.header?.["user-agent"],
187
- status: ctx.status || (error ? 500 : 200),
188
- metadata: {
189
- duration: Date.now() - startTime,
190
- ...error && { error: error.message }
191
- }
192
- });
193
- }
194
- }
195
- };
196
- }
197
- };
198
- var auditManager = new AuditManagerImpl();
199
-
200
- exports.AuditManagerImpl = AuditManagerImpl;
201
- exports.ConsoleAuditLogger = ConsoleAuditLogger;
202
- exports.auditManager = auditManager;
203
- //# sourceMappingURL=index.js.map
204
- //# sourceMappingURL=index.js.map