@opengis/fcore 0.0.1-beta.1 → 0.0.1-beta.10

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 (243) hide show
  1. package/dist/config.d.ts +2 -10
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +1 -1
  4. package/dist/context.js +1 -1
  5. package/dist/errors.js +1 -1
  6. package/dist/fastify.d.ts +5 -5
  7. package/dist/fastify.d.ts.map +1 -1
  8. package/dist/fastify.js +1 -1
  9. package/dist/fcore.js +1 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/migrations/cli.js +1 -1
  14. package/dist/migrations/runner.js +1 -1
  15. package/dist/modules/auth/adduser-cli.d.ts +3 -0
  16. package/dist/modules/auth/adduser-cli.d.ts.map +1 -0
  17. package/dist/modules/auth/adduser-cli.js +2 -0
  18. package/dist/modules/auth/passwd-cli.d.ts +3 -0
  19. package/dist/modules/auth/passwd-cli.d.ts.map +1 -0
  20. package/dist/modules/auth/passwd-cli.js +2 -0
  21. package/dist/modules/auth/permission-cli.d.ts +3 -0
  22. package/dist/modules/auth/permission-cli.d.ts.map +1 -0
  23. package/dist/modules/auth/permission-cli.js +2 -0
  24. package/dist/modules/auth/route.d.ts.map +1 -1
  25. package/dist/modules/auth/route.js +1 -1
  26. package/dist/modules/auth/schema.d.ts +10 -1
  27. package/dist/modules/auth/schema.d.ts.map +1 -1
  28. package/dist/modules/auth/schema.js +1 -1
  29. package/dist/modules/auth/services/change-password.d.ts +9 -0
  30. package/dist/modules/auth/services/change-password.d.ts.map +1 -0
  31. package/dist/modules/auth/services/change-password.js +1 -0
  32. package/dist/modules/auth/services/get-current-user.d.ts +1 -0
  33. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  34. package/dist/modules/auth/services/get-current-user.js +1 -1
  35. package/dist/modules/auth/services/registration.d.ts +14 -0
  36. package/dist/modules/auth/services/registration.d.ts.map +1 -0
  37. package/dist/modules/auth/services/registration.js +1 -0
  38. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  39. package/dist/modules/file/mime.d.ts +3 -0
  40. package/dist/modules/file/mime.d.ts.map +1 -0
  41. package/dist/modules/file/mime.js +1 -0
  42. package/dist/modules/file/route.d.ts.map +1 -1
  43. package/dist/modules/file/route.js +1 -1
  44. package/dist/modules/file/schema.d.ts +3 -0
  45. package/dist/modules/file/schema.d.ts.map +1 -1
  46. package/dist/modules/file/schema.js +1 -1
  47. package/dist/modules/file/services/get-file.js +1 -1
  48. package/dist/modules/file/services/resize-file.d.ts.map +1 -1
  49. package/dist/modules/file/services/resize-file.js +1 -1
  50. package/dist/modules/file/services/upload-file.d.ts +4 -6
  51. package/dist/modules/file/services/upload-file.d.ts.map +1 -1
  52. package/dist/modules/file/services/upload-file.js +1 -1
  53. package/dist/modules/resource/route.d.ts +0 -3
  54. package/dist/modules/resource/route.d.ts.map +1 -1
  55. package/dist/modules/resource/route.js +1 -1
  56. package/dist/modules/resource/schema.d.ts +3 -0
  57. package/dist/modules/resource/schema.d.ts.map +1 -1
  58. package/dist/modules/resource/schema.js +1 -1
  59. package/dist/modules/resource/services/add-note.js +1 -1
  60. package/dist/modules/resource/services/add-resource-file.js +1 -1
  61. package/dist/modules/resource/services/create-resource-relation.d.ts +8 -2
  62. package/dist/modules/resource/services/create-resource-relation.d.ts.map +1 -1
  63. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  64. package/dist/modules/resource/services/create-resource.js +1 -1
  65. package/dist/modules/resource/services/delete-resource-relation.d.ts +8 -1
  66. package/dist/modules/resource/services/delete-resource-relation.d.ts.map +1 -1
  67. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  68. package/dist/modules/resource/services/delete-resource.js +1 -1
  69. package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
  70. package/dist/modules/resource/services/export-resource.js +1 -1
  71. package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
  72. package/dist/modules/resource/services/get-resource.js +1 -1
  73. package/dist/modules/resource/services/list-resource-relation.d.ts +9 -2
  74. package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
  75. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  76. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  77. package/dist/modules/resource/services/list-resources.js +1 -1
  78. package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
  79. package/dist/modules/resource/services/search-resource.js +1 -1
  80. package/dist/modules/resource/services/suggest-resource.d.ts +10 -4
  81. package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
  82. package/dist/modules/resource/services/suggest-resource.js +1 -1
  83. package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
  84. package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
  85. package/dist/modules/resource/services/update-resource-relation.js +1 -0
  86. package/dist/modules/resource/services/update-resource.js +1 -1
  87. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  88. package/dist/modules/system/route.d.ts +2 -1
  89. package/dist/modules/system/route.d.ts.map +1 -1
  90. package/dist/modules/system/route.js +1 -1
  91. package/dist/modules/system/schema.d.ts +22 -1
  92. package/dist/modules/system/schema.d.ts.map +1 -1
  93. package/dist/modules/system/schema.js +1 -1
  94. package/dist/modules/system/services/check-system.d.ts.map +1 -1
  95. package/dist/modules/system/services/check-system.js +1 -1
  96. package/dist/modules/system/services/get-access.d.ts +14 -0
  97. package/dist/modules/system/services/get-access.d.ts.map +1 -0
  98. package/dist/modules/system/services/get-access.js +1 -0
  99. package/dist/modules/system/services/get-api-list.d.ts +4 -1
  100. package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
  101. package/dist/modules/system/services/get-api-list.js +1 -1
  102. package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
  103. package/dist/modules/system/services/get-audit-log.js +1 -1
  104. package/dist/modules/system/services/get-dictionary.js +1 -1
  105. package/dist/modules/system/services/get-system-log.d.ts +9 -5
  106. package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
  107. package/dist/modules/system/services/get-system-log.js +1 -1
  108. package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
  109. package/dist/modules/system/services/get-system-settings.js +1 -1
  110. package/dist/modules/system/services/list-dictionaries.js +1 -1
  111. package/dist/modules/system/services/set-access.d.ts +16 -0
  112. package/dist/modules/system/services/set-access.d.ts.map +1 -0
  113. package/dist/modules/system/services/set-access.js +1 -0
  114. package/dist/modules/system/services/update-dictionary.d.ts +13 -0
  115. package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
  116. package/dist/modules/system/services/update-dictionary.js +1 -0
  117. package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
  118. package/dist/modules/system/services/update-system-settings.js +1 -1
  119. package/dist/modules/utils/require-admin.js +1 -1
  120. package/dist/modules/utils/safe-user.js +1 -1
  121. package/dist/modules/utils/unsupported.js +1 -1
  122. package/dist/plugins/audit/audit.js +1 -1
  123. package/dist/plugins/audit/index.js +1 -1
  124. package/dist/plugins/audit/services/write-audit.js +1 -1
  125. package/dist/plugins/auth/get-user-permissions.d.ts +3 -0
  126. package/dist/plugins/auth/get-user-permissions.d.ts.map +1 -0
  127. package/dist/plugins/auth/get-user-permissions.js +1 -0
  128. package/dist/plugins/auth/index.d.ts +4 -0
  129. package/dist/plugins/auth/index.d.ts.map +1 -1
  130. package/dist/plugins/auth/index.js +1 -1
  131. package/dist/plugins/auth/verifyUser.d.ts +9 -0
  132. package/dist/plugins/auth/verifyUser.d.ts.map +1 -0
  133. package/dist/plugins/auth/verifyUser.js +1 -0
  134. package/dist/plugins/dictionary.d.ts +3 -0
  135. package/dist/plugins/dictionary.d.ts.map +1 -1
  136. package/dist/plugins/dictionary.js +1 -1
  137. package/dist/plugins/file.d.ts +3 -6
  138. package/dist/plugins/file.d.ts.map +1 -1
  139. package/dist/plugins/file.js +1 -1
  140. package/dist/plugins/index.d.ts +2 -0
  141. package/dist/plugins/index.d.ts.map +1 -1
  142. package/dist/plugins/index.js +1 -1
  143. package/dist/plugins/jwt.d.ts +4 -0
  144. package/dist/plugins/jwt.d.ts.map +1 -0
  145. package/dist/plugins/jwt.js +1 -0
  146. package/dist/plugins/logger/index.js +1 -1
  147. package/dist/plugins/logger/transport.d.ts +3 -0
  148. package/dist/plugins/logger/transport.d.ts.map +1 -0
  149. package/dist/plugins/logger/transport.js +1 -0
  150. package/dist/plugins/pg.d.ts +4 -2
  151. package/dist/plugins/pg.d.ts.map +1 -1
  152. package/dist/plugins/pg.js +1 -1
  153. package/dist/plugins/redis.js +1 -1
  154. package/dist/plugins/resource/index.js +1 -1
  155. package/dist/plugins/resource/resource.d.ts.map +1 -1
  156. package/dist/plugins/resource/resource.js +1 -1
  157. package/dist/plugins/resource/resource.registry.js +1 -1
  158. package/dist/plugins/resource/resource.types.d.ts +60 -6
  159. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  160. package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
  161. package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
  162. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
  163. package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
  164. package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
  165. package/dist/plugins/resource/services/add-file-token.js +1 -0
  166. package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
  167. package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
  168. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
  169. package/dist/plugins/resource/services/create-relation.d.ts +16 -0
  170. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
  171. package/dist/plugins/resource/services/create-relation.js +1 -0
  172. package/dist/plugins/resource/services/create.d.ts +5 -2
  173. package/dist/plugins/resource/services/create.d.ts.map +1 -1
  174. package/dist/plugins/resource/services/create.js +1 -1
  175. package/dist/plugins/resource/services/delete-relation.d.ts +18 -0
  176. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
  177. package/dist/plugins/resource/services/delete-relation.js +1 -0
  178. package/dist/plugins/resource/services/delete.d.ts +5 -2
  179. package/dist/plugins/resource/services/delete.d.ts.map +1 -1
  180. package/dist/plugins/resource/services/delete.js +1 -1
  181. package/dist/plugins/resource/services/find-one.d.ts +3 -2
  182. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  183. package/dist/plugins/resource/services/find-one.js +1 -1
  184. package/dist/plugins/resource/services/find-relation.d.ts +13 -0
  185. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
  186. package/dist/plugins/resource/services/find-relation.js +1 -0
  187. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  188. package/dist/plugins/resource/services/find.js +1 -1
  189. package/dist/plugins/resource/services/update-relation.d.ts +14 -0
  190. package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
  191. package/dist/plugins/resource/services/update-relation.js +1 -0
  192. package/dist/plugins/resource/services/update.d.ts +5 -2
  193. package/dist/plugins/resource/services/update.d.ts.map +1 -1
  194. package/dist/plugins/resource/services/update.js +1 -1
  195. package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
  196. package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
  197. package/dist/plugins/resource/utils/auto-index.js +1 -0
  198. package/dist/plugins/resource/utils/fields.d.ts +8 -1
  199. package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
  200. package/dist/plugins/resource/utils/fields.js +1 -1
  201. package/dist/plugins/resource/utils/filters.d.ts +3 -2
  202. package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
  203. package/dist/plugins/resource/utils/filters.js +1 -1
  204. package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
  205. package/dist/plugins/resource/utils/permissions.js +1 -1
  206. package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
  207. package/dist/plugins/resource/utils/sort.js +1 -1
  208. package/dist/plugins/resource/utils/sql.js +1 -1
  209. package/dist/shared/getIP.js +1 -1
  210. package/dist/type.d.ts +37 -0
  211. package/dist/type.d.ts.map +1 -0
  212. package/dist/type.js +1 -0
  213. package/migrations/20260903120000_core_schema.sql +22 -19
  214. package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
  215. package/migrations/20260907090000_core_schema.sql +32 -0
  216. package/package.json +13 -8
  217. package/dist/modules/auth/index.d.ts +0 -9
  218. package/dist/modules/auth/index.d.ts.map +0 -1
  219. package/dist/modules/auth/index.js +0 -1
  220. package/dist/modules/auth/services/login.d.ts +0 -10
  221. package/dist/modules/auth/services/login.d.ts.map +0 -1
  222. package/dist/modules/auth/services/login.js +0 -1
  223. package/dist/modules/auth/services/logout.d.ts +0 -9
  224. package/dist/modules/auth/services/logout.d.ts.map +0 -1
  225. package/dist/modules/auth/services/logout.js +0 -1
  226. package/dist/modules/auth/services/verifyPassword.d.ts +0 -11
  227. package/dist/modules/auth/services/verifyPassword.d.ts.map +0 -1
  228. package/dist/modules/auth/services/verifyPassword.js +0 -1
  229. package/dist/modules/file/index.d.ts +0 -8
  230. package/dist/modules/file/index.d.ts.map +0 -1
  231. package/dist/modules/file/index.js +0 -1
  232. package/dist/modules/resource/index.d.ts +0 -20
  233. package/dist/modules/resource/index.d.ts.map +0 -1
  234. package/dist/modules/resource/index.js +0 -1
  235. package/dist/modules/resource/services/list-children.d.ts +0 -6
  236. package/dist/modules/resource/services/list-children.d.ts.map +0 -1
  237. package/dist/modules/resource/services/list-children.js +0 -1
  238. package/dist/modules/system/index.d.ts +0 -13
  239. package/dist/modules/system/index.d.ts.map +0 -1
  240. package/dist/modules/system/index.js +0 -1
  241. package/dist/modules/utils/get-user-permissions.d.ts +0 -3
  242. package/dist/modules/utils/get-user-permissions.d.ts.map +0 -1
  243. package/dist/modules/utils/get-user-permissions.js +0 -1
@@ -1 +1 @@
1
- const R=p;(function(M,u){const q=p,o=M();while(!![]){try{const r=parseInt(q(0xfa))/0x1*(parseInt(q(0xef))/0x2)+-parseInt(q(0xf5))/0x3+-parseInt(q(0xf7))/0x4*(-parseInt(q(0xfc))/0x5)+parseInt(q(0xfb))/0x6*(parseInt(q(0xf0))/0x7)+parseInt(q(0xf1))/0x8+parseInt(q(0xf9))/0x9+-parseInt(q(0xf2))/0xa;if(r===u)break;else o['push'](o['shift']());}catch(i){o['push'](o['shift']());}}}(m,0xf3355));import{Type}from'@sinclair/typebox';const D={};D[R(0x100)]=0x1,D[R(0xf4)]=0x80,D[R(0xee)]=R(0xfd);export const identifier=Type[R(0xf3)](D);const L={};L[R(0xf6)]=identifier;function m(){const B=['245ReWIFw','10012792WxShgn','44799170BeoCAi','String','maxLength','2667543LsbgLi','name','52616raNfyV','Record','17576208JviwiB','433lCaKBL','212124vrdKFM','475SLGoGr','^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Unknown','Object','minLength','Optional','pattern','3112wKhEnw'];m=function(){return B;};return m();}const s={};s[R(0x100)]=0x1;const X={};function p(D,L){D=D-0xee;const s=m();let X=s[D];return X;}X[R(0x100)]=0x1;export const systemSchemas={'dictionaryName':Type[R(0xff)](L),'settingsEntity':Type[R(0xff)]({'entity':Type[R(0x101)](identifier)}),'settings':Type[R(0xf8)](Type[R(0xf3)](s),Type[R(0xfe)]()),'logger':Type[R(0xff)]({'*':Type[R(0x101)](Type[R(0xf3)](X))})};
1
+ const d=S;import{Type}from'@sinclair/typebox';export const identifier=Type[d(0x1aa)]({'minLength':0x1,'maxLength':0x80,'pattern':d(0x1ab)});function S(d,h){d=d-0x1aa;const p=v();let Z=p[d];return Z;}export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type['Object']({'id':Type['Optional'](Type[d(0x1ac)]([Type['String'](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type[d(0x1ac)]([Type['String'](),Type['Number'](),Type[d(0x1ad)]()]))},{'additionalProperties':!![]}))}),'accessTarget':Type[d(0x1ae)]({'type':Type['Union']([Type['Literal']('user'),Type['Literal']('role')]),'id':identifier}),'access':Type['Object']({'access':Type[d(0x1af)](Type['Object']({'resource':Type[d(0x1aa)]({'minLength':0x1,'maxLength':0x80}),'actions':Type[d(0x1af)](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})}))}),'apiListQuery':Type['Object']({'format':Type[d(0x1b0)](Type['Union']([Type['Literal'](d(0x1b1)),Type['Literal']('extended')]))}),'settingsEntity':Type['Object']({'entity':Type[d(0x1b0)](identifier)}),'settings':Type['Record'](Type['String']({'minLength':0x1}),Type[d(0x1b2)]()),'logger':Type['Object']({'path':Type[d(0x1b0)](Type['String']({'maxLength':0x100,'pattern':d(0x1b3)}))})};function v(){const h=['String','^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Union','Null','Object','Array','Optional','short','Unknown','^[A-Za-z0-9_.\x5c-/]*$'];v=function(){return h;};return v();}
@@ -1 +1 @@
1
- {"version":3,"file":"check-system.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/check-system.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAiBd"}
1
+ {"version":3,"file":"check-system.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/check-system.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAcd"}
@@ -1 +1 @@
1
- function p(D,L){D=D-0x143;const s=m();let X=s[D];return X;}(function(D,L){const q=p,s=D();while(!![]){try{const X=parseInt(q(0x14f))/0x1+parseInt(q(0x145))/0x2*(parseInt(q(0x154))/0x3)+parseInt(q(0x14d))/0x4*(-parseInt(q(0x152))/0x5)+parseInt(q(0x144))/0x6+-parseInt(q(0x146))/0x7+parseInt(q(0x153))/0x8+-parseInt(q(0x158))/0x9*(parseInt(q(0x14c))/0xa);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x5baa2));import{requireAdmin}from'../../utils/require-admin.js';export async function checkSystem(L,s){const R=p,X={};X[R(0x159)]=R(0x143),X[R(0x15a)]=function(r,i){return r===i;},X[R(0x14b)]=R(0x150),X[R(0x14e)]=R(0x147);const M=X;requireAdmin(L[R(0x148)],M[R(0x159)]);const [u,o]=await Promise[R(0x14a)]([s['pg'][R(0x151)](R(0x156)),s[R(0x155)][R(0x157)]()]);return{'status':M[R(0x15a)](u[R(0x149)],M[R(0x14b)])&&o[R(0x149)]===M[R(0x14b)]?'ok':M[R(0x14e)],'pg':u[R(0x149)],'redis':o[R(0x149)]};}function m(){const B=['12MiZLlg','QyqVt','45281jBaxmn','fulfilled','query','280230gpHfIk','852952QBWxHa','72753rjaxkx','redis','SELECT\x201','ping','1790658SvgKIS','ETTcf','NkODC','system:check','1039092jDgtbq','36sQUIvG','133294TfunjG','degraded','user','status','allSettled','yFZtW','10FyBWlV'];m=function(){return B;};return m();}
1
+ function S(d,h){d=d-0xd4;const p=v();let Z=p[d];return Z;}export async function checkSystem(d,h){const D=S,[p,Z]=await Promise['allSettled']([h['pg']['query']('SELECT\x201'),h['redis'][D(0xd4)]()]);return{'status':p[D(0xd5)]===D(0xd6)&&Z['status']==='fulfilled'?'ok':'degraded','pg':p['status'],'redis':Z['status']};}function v(){const u=['ping','status','fulfilled'];v=function(){return u;};return v();}
@@ -0,0 +1,14 @@
1
+ import type { AppContext, User } from "../../../context.js";
2
+ export interface AccessRecord {
3
+ resource: string | null;
4
+ actions: string[] | null;
5
+ role: string | null;
6
+ }
7
+ export declare function getAccess(params: {
8
+ type: "user" | "role";
9
+ id: string;
10
+ user: User;
11
+ }, ctx: AppContext): Promise<{
12
+ access: AccessRecord[];
13
+ }>;
14
+ //# sourceMappingURL=get-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACzD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAkBrC"}
@@ -0,0 +1 @@
1
+ export async function getAccess(d,h){const p=d['type']==='user'?'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20ur.role_id\x20=\x20ra.role_id\x20AND\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20':'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20',Z=await h['pg']['query'](p,[d['id']]);return{'access':Z['rows']};}
@@ -2,7 +2,10 @@
2
2
  * Implements the get API list application service for the System module.
3
3
  */
4
4
  import type { AppContext, User } from "../../../context.js";
5
+ import type { ApiRoute } from "../../../type.js";
5
6
  export declare function getApiList(params: {
6
7
  user: User;
7
- }, ctx: AppContext): Promise<string[]>;
8
+ apiRoutes: ReadonlyMap<string, ApiRoute>;
9
+ format?: "short" | "extended";
10
+ }, ctx: AppContext): Promise<ApiRoute[] | string[]>;
8
11
  //# sourceMappingURL=get-api-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-api-list.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-api-list.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,UAAU,CAC9B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAcnB"}
1
+ {"version":3,"file":"get-api-list.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-api-list.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,kBAAkB,CAAC;AAEhE,wBAAsB,UAAU,CAC9B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;CAC/B,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,CAWhC"}
@@ -1 +1 @@
1
- function m(){var i=['XjIvn','2543298wixliX','233284DPUBsi','792gfshWl','/api/dictionaries','2191270EaZKaB','mnkkM','/api/templates','/files/*','45520nZWjJy','hUZaA','/api/user','/api/resource/:resource','system:api:read','KOeJp','wUFVc','apZBY','578716bptMvJ','8525496LDXzAQ','/api/system/check','/api/resource/:resource/:id','111214Mcmocy','/api/login','/api/logout','39OPkuoa','user','cRjnS','hQaSK'];m=function(){return i;};return m();}(function(D,L){var o=p,s=D();while(!![]){try{var X=parseInt(o(0x154))/0x1+-parseInt(o(0x158))/0x2*(parseInt(o(0x15b))/0x3)+parseInt(o(0x145))/0x4+parseInt(o(0x148))/0x5+-parseInt(o(0x160))/0x6+parseInt(o(0x155))/0x7+-parseInt(o(0x14c))/0x8*(parseInt(o(0x146))/0x9);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x9da5d));function p(D,L){D=D-0x145;var s=m();var X=s[D];return X;}import{requireAdmin}from'../../utils/require-admin.js';export async function getApiList(D,L){var r=p,s={'XjIvn':function(X,M,u){return X(M,u);},'KOeJp':r(0x150),'mnkkM':r(0x15a),'apZBY':r(0x14e),'cRjnS':r(0x147),'hUZaA':r(0x14b),'wUFVc':r(0x14a),'hQaSK':r(0x156)};return s[r(0x15f)](requireAdmin,D[r(0x15c)],s[r(0x151)]),[r(0x159),s[r(0x149)],s[r(0x153)],r(0x14f),r(0x157),s[r(0x15d)],s[r(0x14d)],s[r(0x152)],s[r(0x15e)]];}
1
+ function S(d,h){d=d-0x1d1;const p=v();let Z=p[d];return Z;}export async function getApiList(d,h){const X=S,p=[...d['apiRoutes']['values']()][X(0x1d1)]((Z,D)=>(Z['endpoint']+'\x20'+Z[X(0x1d2)])['localeCompare'](D[X(0x1d3)]+'\x20'+D['method']));if(d['format']!==X(0x1d4))return p;return p['map'](({method:Z,endpoint:D,access:u,permissions:n})=>Z+'\x20'+D);}function v(){const Y=['sort','method','endpoint','short'];v=function(){return Y;};return v();}
@@ -1 +1 @@
1
- {"version":3,"file":"get-audit-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-audit-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAgBd"}
1
+ {"version":3,"file":"get-audit-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-audit-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAcd"}
@@ -1 +1 @@
1
- (function(D,L){const O=p,s=D();while(!![]){try{const X=parseInt(O(0x106))/0x1+parseInt(O(0xfd))/0x2*(-parseInt(O(0xfb))/0x3)+parseInt(O(0xfe))/0x4+parseInt(O(0x10d))/0x5*(-parseInt(O(0x104))/0x6)+-parseInt(O(0x107))/0x7+-parseInt(O(0x105))/0x8+parseInt(O(0xfa))/0x9;if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0xe91d0));function p(D,L){D=D-0xf7;const s=m();let X=s[D];return X;}function m(){const g=['query','min','DtzIB','Upsnp','670mLHojG','page','HrnfL','audit:read','8522370WaRalW','27QRyTNY','sUTIM','1340AicGSK','2057280QUOKxz','rows','max','user','limit','KlQuH','348fgqxaT','3355360pCzMQh','1447082UYIDgv','10641946Xeuokd','SELECT\x20*\x20FROM\x20admin.audit_log\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2'];m=function(){return g;};return m();}import{requireAdmin}from'../../utils/require-admin.js';export async function getAuditLog(L,s){const h=p,X={'DtzIB':function(q,R,B){return q(R,B);},'HrnfL':h(0xf9),'KlQuH':function(q,R){return q*R;},'Upsnp':function(q,R){return q-R;},'sUTIM':h(0x108)};X[h(0x10b)](requireAdmin,L[h(0x101)],X[h(0xf8)]);const M=Math[h(0x10a)](Math[h(0x100)](L[h(0x102)]??0x32,0x1),0xc8),u=X[h(0x103)](Math[h(0x100)](X[h(0x10c)](L[h(0xf7)]??0x1,0x1),0x0),M),o=await s['pg'][h(0x109)](X[h(0xfc)],[M,u]),i={};return i[h(0xff)]=o[h(0xff)],i[h(0xf7)]=L[h(0xf7)]??0x1,i[h(0x102)]=M,i;}
1
+ export async function getAuditLog(d,h){const u=S,p=Math['min'](Math['max'](d['limit']??0x32,0x1),0xc8),Z=Math['max']((d['page']??0x1)-0x1,0x0)*p,D=await h['pg'][u(0x122)]('SELECT\x20*\x20FROM\x20admin.audit_log\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[p,Z]);return{'rows':D['rows'],'page':d[u(0x123)]??0x1,'limit':p};}function S(d,h){d=d-0x122;const p=v();let Z=p[d];return Z;}function v(){const n=['query','page'];v=function(){return n;};return v();}
@@ -1 +1 @@
1
- (function(D,L){var u=p,s=D();while(!![]){try{var X=parseInt(u(0xec))/0x1+parseInt(u(0xed))/0x2+parseInt(u(0xe6))/0x3*(parseInt(u(0xe8))/0x4)+-parseInt(u(0xe7))/0x5+parseInt(u(0xeb))/0x6*(parseInt(u(0xf1))/0x7)+-parseInt(u(0xee))/0x8*(-parseInt(u(0xf3))/0x9)+-parseInt(u(0xef))/0xa*(parseInt(u(0xe9))/0xb);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0xdd027));function m(){var r=['name','61416fIUqYB','47493zsOITj','7771510BAAmQQ','456dDcjAT','132AmakgJ','dictionary','3552TWeKil','1635607cARRUB','2512920VbFaYA','2096jmBbGM','3782490dTreSh','get','6076bXlhtt'];m=function(){return r;};return m();}function p(D,L){D=D-0xe6;var s=m();var X=s[D];return X;}export async function getDictionary(D,L){var o=p;return L[o(0xea)][o(0xf0)](D[o(0xf2)]);}
1
+ function v(){var Z=['dictionary'];v=function(){return Z;};return v();}function S(d,h){d=d-0xec;var p=v();var Z=p[d];return Z;}export async function getDictionary(d,h){var p=S;return h[p(0xec)]['get'](d['name']);}
@@ -1,6 +1,10 @@
1
- /**
2
- * Implements the get system log application service for its module.
3
- */
4
- import type { AppContext } from '../../../context.js';
5
- export declare function getSystemLog(params: any, ctx: AppContext): Promise<never>;
1
+ import type { AppContext, User } from "../../../context.js";
2
+ export interface LogResult {
3
+ contentType: string;
4
+ body: string;
5
+ }
6
+ export declare function getSystemLog(params: {
7
+ path?: string;
8
+ user: User;
9
+ }, ctx: AppContext): Promise<LogResult>;
6
10
  //# sourceMappingURL=get-system-log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-system-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-system-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,wBAAsB,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAE/E"}
1
+ {"version":3,"file":"get-system-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-system-log.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAc5D,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACrC,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,SAAS,CAAC,CA0CpB"}
@@ -1 +1 @@
1
- (function(D,L){var u=p,s=D();while(!![]){try{var X=parseInt(u(0x1f0))/0x1+parseInt(u(0x1ed))/0x2*(-parseInt(u(0x1f2))/0x3)+-parseInt(u(0x1f5))/0x4*(parseInt(u(0x1ef))/0x5)+-parseInt(u(0x1e9))/0x6+parseInt(u(0x1ee))/0x7+-parseInt(u(0x1f4))/0x8*(-parseInt(u(0x1f1))/0x9)+-parseInt(u(0x1ea))/0xa;if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x29bba));function p(D,L){D=D-0x1e9;var s=m();var X=s[D];return X;}import{unsupported}from'../../utils/unsupported.js';function m(){var r=['5EHyoyY','91709AvAwpA','9jbkmQb','75jHDVWA','File\x20logger\x20backend','2553064lMGWaK','780672XWLLnk','832038qQEgAT','1099750cBznzS','rPybE','AaBFE','1304gQeeur','1541484WWDpZE'];m=function(){return r;};return m();}export async function getSystemLog(D,L){var o=p,s={'AaBFE':function(X,M){return X(M);},'rPybE':o(0x1f3)};return s[o(0x1ec)](unsupported,s[o(0x1eb)]);}
1
+ const K=S;import d from'node:fs/promises';function v(){const U=['resolve','catch','Log\x20path\x20not\x20found','isDirectory','map','name','localeCompare','slice','join','unshift','?path=','<li><a\x20href=\x22','logs/','</h1>\x0a<ul>\x0a','\x0a</ul>\x0a</body>\x0a</html>','replace','&lt;','Invalid\x20log\x20path','stat','min','toString','filter','length'];v=function(){return U;};return v();}import h from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=h[K(0xfb)](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(p,Z){const g=K,D=normalizePath(p['path']),u=h['resolve'](LOGS_ROOT,D);if(u!==LOGS_ROOT&&!u['startsWith'](LOGS_ROOT+h['sep']))throw new ValidationError('Invalid\x20log\x20path');const n=await d['stat'](u)[g(0xfc)](()=>null);if(!n)throw new NotFoundError(g(0xfd));if(n[g(0xfe)]()){const Y=await d['readdir'](u,{'withFileTypes':!![]}),w=await Promise['all'](Y[g(0xff)](async y=>{const s=g,Q=await d['stat'](h['join'](u,y['name']));return{'name':y[s(0x100)],'path':D?D+'/'+y['name']:y['name'],'type':y['isDirectory']()?'directory':'file','size':y[s(0xfe)]()?undefined:Q['size'],'modified':Q['mtime']['toISOString']()};}));w['sort']((y,Q)=>y[g(0x100)][g(0x101)](Q['name']));if(D){const y=D['split']('/')[g(0x102)](0x0,-0x1)[g(0x103)]('/');w[g(0x104)]({'name':'..','path':y,'type':'directory'});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(D,w)};}const X=await tailFile(u,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':X[g(0x103)]('\x0a')};}function renderDirectory(p,Z){const M=K,D=Z[M(0xff)](n=>{const O=M,X=O(0x105)+encodeURIComponent(n['path']),Y=n['type']==='directory'?n['name']+'/':n['name'];return O(0x106)+X+'\x22>'+escapeHtml(Y)+'</a></li>';})['join']('\x0a'),u=escapeHtml(M(0x107)+p);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+u+'</title></head>\x0a<body>\x0a<h1>'+u+M(0x108)+D+M(0x109);}function escapeHtml(p){const R=K;return p[R(0x10a)](/&/g,'&amp;')['replace'](/</g,R(0x10b))['replace'](/>/g,'&gt;')['replace'](/"/g,'&quot;');}function normalizePath(p){const E=K,Z=(p??'')['replace'](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(Z['split']('/')['some'](D=>D==='..'))throw new ValidationError(E(0x10c));return Z;}async function tailFile(p,Z){const J=K,D=await d['open'](p,'r');try{const {size:u}=await D[J(0x10d)](),n=0x40*0x400;let X=u,Y=Buffer['alloc'](0x0),w=0x0;while(X>0x0&&w<=Z){const Q=Math[J(0x10e)](n,X);X-=Q;const F=Buffer['alloc'](Q);await D['read'](F,0x0,Q,X),Y=Buffer['concat']([F,Y]),w+=countNewlines(F);}const y=Y[J(0x10f)]('utf8')['split']('\x0a')[J(0x110)](B=>B[J(0x111)]>0x0);return y['slice'](-Z)['reverse']();}finally{await D['close']();}}function S(d,h){d=d-0xfb;const p=v();let Z=p[d];return Z;}function countNewlines(p){let Z=0x0;for(const D of p){if(D===0xa)Z++;}return Z;}
@@ -1 +1 @@
1
- {"version":3,"file":"get-system-settings.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-system-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuBlC"}
1
+ {"version":3,"file":"get-system-settings.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-system-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkBlC"}
@@ -1 +1 @@
1
- (function(D,L){const h=p,s=D();while(!![]){try{const X=-parseInt(h(0x19a))/0x1+-parseInt(h(0x1a1))/0x2+parseInt(h(0x19d))/0x3*(parseInt(h(0x1a7))/0x4)+-parseInt(h(0x19f))/0x5+-parseInt(h(0x1a8))/0x6+-parseInt(h(0x196))/0x7+-parseInt(h(0x1a3))/0x8*(-parseInt(h(0x199))/0x9);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x30621));function p(D,L){D=D-0x194;const s=m();let X=s[D];return X;}function m(){const S=['aoRbG','system:settings:read','1127876zixnkk','1270698SBYmxf','rows','IKvyC','633101xNAWDp','value','slice','2961621PyIkVO','85176lQSjnx','user','split','3fyPuzE','query','203380kbcGCu','\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20','627704pvdYrH','key','16EvNegc','reduce'];m=function(){return S;};return m();}import{requireAdmin}from'../../utils/require-admin.js';export async function getSystemSettings(D,L){const g=p,s={'aoRbG':function(M,u){return M(u);},'IKvyC':function(M,u,o){return M(u,o);}};s[g(0x195)](requireAdmin,D[g(0x19b)],g(0x1a6));const X=await L['pg'][g(0x19e)](g(0x1a0));return X[g(0x194)][g(0x1a4)]((M,u)=>{const J=g,o=s[J(0x1a5)](String,u[J(0x1a2)])[J(0x19c)]('.');let r=M;for(const i of o[J(0x198)](0x0,-0x1)){r[i]??={},r=r[i];}return r[o['at'](-0x1)]=u[J(0x197)],M;},{});}
1
+ function S(d,h){d=d-0x19a;const p=v();let Z=p[d];return Z;}function v(){const w=['split','value'];v=function(){return w;};return v();}export async function getSystemSettings(d,h){const p=await h['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20');return p['rows']['reduce']((Z,D)=>{const Y=S,u=String(D['key'])[Y(0x19a)]('.');let n=Z;for(const X of u['slice'](0x0,-0x1)){n[X]??={},n=n[X];}return n[u['at'](-0x1)]=D[Y(0x19b)],Z;},{});}
@@ -1 +1 @@
1
- function p(D,L){D=D-0x1c0;var s=m();var X=s[D];return X;}function m(){var r=['117KqSzWW','dictionary','27sfRkjr','list','510715hziCBk','1AOWAQD','2382023kZRCGn','6XvavOi','3RPmgXV','181994soVeja','65244nScLtI','335380JCuJbP','79016AQFtNk','88SnAMFi','1107804hupVTu'];m=function(){return r;};return m();}(function(D,L){var u=p,s=D();while(!![]){try{var X=-parseInt(u(0x1cd))/0x1*(-parseInt(u(0x1c2))/0x2)+-parseInt(u(0x1c1))/0x3*(-parseInt(u(0x1c7))/0x4)+-parseInt(u(0x1cc))/0x5+parseInt(u(0x1c0))/0x6*(-parseInt(u(0x1ce))/0x7)+-parseInt(u(0x1c5))/0x8*(-parseInt(u(0x1ca))/0x9)+parseInt(u(0x1c4))/0xa*(parseInt(u(0x1c6))/0xb)+-parseInt(u(0x1c3))/0xc*(parseInt(u(0x1c8))/0xd);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x2a9b6));export async function listDictionaries(D,L){var o=p;return L[o(0x1c9)][o(0x1cb)]();}
1
+ export async function listDictionaries(d,h){return h['dictionary']['list']();}
@@ -0,0 +1,16 @@
1
+ import type { AppContext, User } from "../../../context.js";
2
+ import { type AccessRecord } from "./get-access.js";
3
+ type AccessInput = {
4
+ resource: string;
5
+ actions: string[];
6
+ };
7
+ export declare function setAccess(params: {
8
+ type: "user" | "role";
9
+ id: string;
10
+ access: AccessInput[];
11
+ user: User;
12
+ }, ctx: AppContext): Promise<{
13
+ access: AccessRecord[];
14
+ }>;
15
+ export {};
16
+ //# sourceMappingURL=set-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D,KAAK,WAAW,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,wBAAsB,SAAS,CAC3B,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC;CACd,EACD,GAAG,EAAE,UAAU,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CA6CrC"}
@@ -0,0 +1 @@
1
+ import{getAccess}from'./get-access.js';function v(){const n=['query','user','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','ROLLBACK'];v=function(){return n;};return v();}function S(d,h){d=d-0x69;const p=v();let Z=p[d];return Z;}export async function setAccess(d,h){const u=S,p=await h['pg']['connect']();try{await p['query']('BEGIN');d['type']==='user'?await p[u(0x69)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[d['id']]):await p['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[d['id']]);for(const Z of d['access']){d['type']===u(0x6a)?await p['query']('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[Z['resource'],Z['actions'],d['id'],d['user']['id'],d[u(0x6a)]['id']]):await p[u(0x69)](u(0x6b),[Z['resource'],Z['actions'],d['id'],d[u(0x6a)]['id'],d[u(0x6a)]['id']]);}await p[u(0x69)]('COMMIT');}catch(D){await p['query'](u(0x6c));throw D;}finally{p['release']();}return getAccess(d,h);}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Implements the update dictionary application service for the System module.
3
+ */
4
+ import type { AppContext, User } from "../../../context.js";
5
+ import type { DictionaryItem } from "../../../plugins/dictionary.js";
6
+ export declare function updateDictionary(params: {
7
+ name: string;
8
+ items: DictionaryItem[];
9
+ user: User;
10
+ }, ctx: AppContext): Promise<{
11
+ success: boolean;
12
+ }>;
13
+ //# sourceMappingURL=update-dictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-dictionary.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/update-dictionary.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,cAAc,EAAE,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EAC7D,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAI/B"}
@@ -0,0 +1 @@
1
+ function S(d,h){d=d-0x1de;var p=v();var Z=p[d];return Z;}function v(){var Z=['put'];v=function(){return Z;};return v();}export async function updateDictionary(d,h){var p=S;return await h['dictionary'][p(0x1de)](d['name'],d['items']),{'success':!![]};}
@@ -1 +1 @@
1
- {"version":3,"file":"update-system-settings.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/update-system-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,wBAAsB,oBAAoB,CACxC,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC,CAuB5B"}
1
+ {"version":3,"file":"update-system-settings.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/update-system-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,wBAAsB,oBAAoB,CACxC,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC,CAqB5B"}
@@ -1 +1 @@
1
- (function(D,L){const i=p,s=D();while(!![]){try{const X=parseInt(i(0xe2))/0x1*(parseInt(i(0xf5))/0x2)+parseInt(i(0xe0))/0x3*(parseInt(i(0xf7))/0x4)+-parseInt(i(0xf2))/0x5+-parseInt(i(0xe6))/0x6*(parseInt(i(0xf1))/0x7)+parseInt(i(0xe8))/0x8*(parseInt(i(0xdd))/0x9)+-parseInt(i(0xf0))/0xa*(-parseInt(i(0xed))/0xb)+parseInt(i(0xef))/0xc*(-parseInt(i(0xf9))/0xd);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x5e8a8));function p(D,L){D=D-0xdc;const s=m();let X=s[D];return X;}import{requireAdmin}from'../../utils/require-admin.js';import{ValidationError}from'../../../errors.js';export async function updateSystemSettings(L,s){const q=p,X={'sRrfl':function(u,o,r){return u(o,r);},'CPfhT':q(0xec),'IJLIw':q(0xdf)};X[q(0xea)](requireAdmin,L[q(0xeb)],X[q(0xe7)]);if(!Object[q(0xe9)](L[q(0xdc)])[q(0xee)])throw new ValidationError(X[q(0xf6)]);for(const [u,o]of Object[q(0xde)](L[q(0xdc)])){if(!u[q(0xe3)]()||u[q(0xf3)]('..'))throw new ValidationError(q(0xe1)+u);await s['pg'][q(0xf4)](q(0xe5),[u,JSON[q(0xe4)](o),L[q(0xeb)]['id']]);}const M={};return M[q(0xf8)]=!![],M;}function m(){const R=['sRrfl','user','system:settings:update','473mgRcJe','length','72OMoALM','137330LxLdBv','7gnsDjo','2899810hLaGuE','includes','query','980810RLZfil','IJLIw','16WdBayV','success','606437MPNJtL','patch','9yHtOQT','entries','Settings\x20patch\x20is\x20empty','10470umiFts','Invalid\x20setting\x20key:\x20','1wlDUnR','trim','stringify','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20','3006834gxLGyP','CPfhT','5226808lbpzzn','keys'];m=function(){return R;};return m();}
1
+ import{ValidationError}from'../../../errors.js';function v(){const u=['keys','length','patch','Invalid\x20setting\x20key:\x20','stringify','user'];v=function(){return u;};return v();}function S(d,h){d=d-0x159;const p=v();let Z=p[d];return Z;}export async function updateSystemSettings(d,h){const D=S;if(!Object[D(0x159)](d['patch'])[D(0x15a)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [p,Z]of Object['entries'](d[D(0x15b)])){if(!p['trim']()||p['includes']('..'))throw new ValidationError(D(0x15c)+p);await h['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[p,JSON[D(0x15d)](Z),d[D(0x15e)]['id']]);}return{'success':!![]};}
@@ -1 +1 @@
1
- (function(D,L){var R=p,s=D();while(!![]){try{var X=parseInt(R(0x192))/0x1*(-parseInt(R(0x1a2))/0x2)+parseInt(R(0x199))/0x3*(-parseInt(R(0x1a0))/0x4)+-parseInt(R(0x19e))/0x5+parseInt(R(0x193))/0x6+parseInt(R(0x198))/0x7*(-parseInt(R(0x196))/0x8)+parseInt(R(0x19b))/0x9+-parseInt(R(0x19a))/0xa*(-parseInt(R(0x19d))/0xb);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0xc4d83));function m(){var O=['6OIFnnc','3421080yDGzee','ryOev','Admin\x20access\x20required','240184vNmCUz','admin','14kFJZbp','1566111NywNUH','1130MMrlah','4427721hQgyiV','User\x20required','314017lNanIv','6882295DxxoqB','ODZQI','8hRSWnE','type','333702HMjrRA'];m=function(){return O;};return m();}import{ForbiddenError}from'../../errors.js';function p(D,L){D=D-0x192;var s=m();var X=s[D];return X;}export function requireAdmin(L,s){var B=p,X={};X[B(0x19f)]=B(0x19c),X[B(0x194)]=function(u,o){return u!==o;};var M=X;if(!L)throw new ForbiddenError(M[B(0x19f)]);if(M[B(0x194)](L[B(0x1a1)],B(0x197)))throw new ForbiddenError(B(0x195));}
1
+ import{ForbiddenError}from'../../errors.js';function S(d,h){d=d-0xda;var p=v();var Z=p[d];return Z;}export function requireAdmin(d,h){var p=S;if(!d)throw new ForbiddenError(p(0xda));if(d['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(d['type']!=='admin'&&h&&!d[p(0xdb)]?.['includes'](h))throw new ForbiddenError('Missing\x20permission:\x20'+h);}function v(){var Z=['User\x20required','permissions'];v=function(){return Z;};return v();}
@@ -1 +1 @@
1
- function p(D,L){D=D-0x110;const s=m();let X=s[D];return X;}function m(){const B=['filter','some','secret','fromEntries','8517632NLfUqn','includes','FwMYf','password','2650240sTKluQ','salt','6126260ADDwXu','entries','NgoAE','2deWHGo','18kkrIKn','DxSKz','toLowerCase','credentials','7571604PosDlW','JFajj','1065083naqbho','1841721MwrXfL','8975463qEYvoK','token'];m=function(){return B;};return m();}(function(D,L){const q=p,s=D();while(!![]){try{const X=parseInt(q(0x111))/0x1+-parseInt(q(0x122))/0x2*(-parseInt(q(0x112))/0x3)+parseInt(q(0x11d))/0x4+-parseInt(q(0x11f))/0x5+-parseInt(q(0x127))/0x6+-parseInt(q(0x113))/0x7+parseInt(q(0x119))/0x8*(parseInt(q(0x123))/0x9);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0xab47b));export const safeUser=L=>{const R=p,s={};s[R(0x11b)]=R(0x11c),s[R(0x121)]=R(0x11e),s[R(0x110)]=R(0x114),s[R(0x124)]=R(0x117);const X=s,M=[X[R(0x11b)],X[R(0x121)],X[R(0x110)],X[R(0x124)],R(0x126)];return Object[R(0x118)](Object[R(0x120)](L)[R(0x115)](([u])=>!M[R(0x116)](o=>u[R(0x125)]()[R(0x11a)](o))));};
1
+ export const safeUser=d=>{const D=S,h=['password','salt','secret','credentials'];return Object['fromEntries'](Object['entries'](d)['filter'](([p])=>!h[D(0x14d)](Z=>p['toLowerCase']()[D(0x14e)](Z))));};function S(d,h){d=d-0x14d;const p=v();let Z=p[d];return Z;}function v(){const u=['some','includes'];v=function(){return u;};return v();}
@@ -1 +1 @@
1
- function m(){var r=['8530002CEyDTd','1023512tLsSPu','1139610mpvVjC','3670chHOcF','\x20requires\x20a\x20project/provider\x20implementation','668ocAoub','195628duVxMR','4089075mvyHxb','14NVygDu','1432254IMqVtq'];m=function(){return r;};return m();}(function(D,L){var u=p,s=D();while(!![]){try{var X=-parseInt(u(0x13a))/0x1+-parseInt(u(0x13e))/0x2+parseInt(u(0x13f))/0x3+parseInt(u(0x13d))/0x4*(parseInt(u(0x13b))/0x5)+-parseInt(u(0x141))/0x6*(parseInt(u(0x140))/0x7)+parseInt(u(0x139))/0x8+parseInt(u(0x142))/0x9;if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0xcea8e));function p(D,L){D=D-0x139;var s=m();var X=s[D];return X;}import{UnsupportedError}from'../../errors.js';export function unsupported(D){var o=p;throw new UnsupportedError(D+o(0x13c));}
1
+ import{UnsupportedError}from'../../errors.js';export function unsupported(d){throw new UnsupportedError(d+'\x20requires\x20a\x20project/provider\x20implementation');}
@@ -1 +1 @@
1
- (function(D,L){const u=p,s=D();while(!![]){try{const X=parseInt(u(0xc6))/0x1+parseInt(u(0xc5))/0x2*(parseInt(u(0xca))/0x3)+parseInt(u(0xcb))/0x4*(parseInt(u(0xc4))/0x5)+parseInt(u(0xc9))/0x6*(parseInt(u(0xc7))/0x7)+parseInt(u(0xcc))/0x8+-parseInt(u(0xcd))/0x9+-parseInt(u(0xc3))/0xa;if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0xc94f0));import{writeAudit}from'./services/write-audit.js';function m(){const r=['4IYPNGK','9230184jnMtAH','7042356kIMYwh','17044750OcqAMf','4436180dDLVyr','1330tekXFG','39286rjuOtv','301aNFGVW','write','51078ZTUoAd','3903mDNiVN'];m=function(){return r;};return m();}function p(D,L){D=D-0xc3;const s=m();let X=s[D];return X;}export function createAudit(L){const o=p,s=writeAudit(L),X={};return X[o(0xc8)]=s,X;}
1
+ import{writeAudit}from'./services/write-audit.js';export function createAudit(d){const h=writeAudit(d);return{'write':h};}
@@ -1 +1 @@
1
- function p(D,L){D=D-0x8b;var s=m();var X=s[D];return X;}(function(D,L){var u=p,s=D();while(!![]){try{var X=parseInt(u(0x91))/0x1*(-parseInt(u(0x94))/0x2)+-parseInt(u(0x90))/0x3*(parseInt(u(0x8e))/0x4)+parseInt(u(0x95))/0x5*(-parseInt(u(0x8f))/0x6)+-parseInt(u(0x92))/0x7*(-parseInt(u(0x8d))/0x8)+parseInt(u(0x93))/0x9+-parseInt(u(0x8b))/0xa+parseInt(u(0x8c))/0xb;if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x8747c));function m(){var o=['16009UvEMOP','74389pvgirk','3732777XApPWR','18VtGaze','10CiTpsb','10662760xCIuzt','33375672WQaXnC','80zGnEjC','344igqAtu','2841408mNTRDi','29427ahJUQY'];m=function(){return o;};return m();}export*from'./audit.types.js';export*from'./audit.js';
1
+ export*from'./audit.types.js';export*from'./audit.js';
@@ -1 +1 @@
1
- (function(D,L){const b=p,s=D();while(!![]){try{const X=parseInt(b(0x142))/0x1+-parseInt(b(0x15d))/0x2+-parseInt(b(0x158))/0x3+-parseInt(b(0x198))/0x4*(-parseInt(b(0x146))/0x5)+parseInt(b(0x183))/0x6*(parseInt(b(0x14f))/0x7)+-parseInt(b(0x140))/0x8*(-parseInt(b(0x192))/0x9)+parseInt(b(0x14b))/0xa*(parseInt(b(0x149))/0xb);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x2f731));function p(D,L){D=D-0x134;const s=m();let X=s[D];return X;}const secretPattern=/password|token|secret|credential|salt/i;function m(){const j=['gvUTl','vygCI','gDJxe','TidfE','VHgKx','test','HEMSD','fcnGb','xgAEL','342360sMWLwt','Kpxmj','21937yhqFBU','audit_log','foundTables','eIqHt','135090oOGKtp','entries','AGTFQ','387101sWDErQ','LQpzA','50nsvKXg','err','map','module','1166578dImLSg','GNdpt','query','fromEntries','catch','then','NqALm','qzvbk','SFThT','167034pzHgAs','changes','info','WCIOL','Buaoo','530764WARlQu','pWuMy','HgCrR','action','has','isArray','\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5,\x20$6,\x20$7,\x20$8,\x20$9)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20','audit','ipAddress','object','newValue','NsPRU','prOwz','Lrhzx','fields','Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled','PzXKJ','audit_log_data','admin.audit_log','resourceId','Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled','JJVpR','IOgJa','lVACD','warn','table_name','vPkUi','field','requestId','VMyDj','XrHhl','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log_data\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20audit_log_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20field,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20old_value,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20new_value\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20','logger','resource','DPHUf','nUIUZ','kVQoH','waFCQ','6RbwVMq','oMhZy','fehbn','admin.audit_log_data','lpzFj','bkMuA','qbakE','[REDACTED]','qYPLa','gnpfg','Uwaau','sjjSV','rows','ymCCn','metadata','9sJpOII','bwIRP','userId','okdBB','ZZpwB','oldValue','16YucsVn','empty\x20pg','KOSTO','GUIuU','yukig','stringify','dAAxD','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20','qQTFR','expectedTables'];m=function(){return j;};return m();}function clean(D){const f=p;if(Array[f(0x162)](D))return D[f(0x14d)](clean);if(D&&typeof D===f(0x166))return Object[f(0x152)](Object[f(0x147)](D)[f(0x14d)](([L,s])=>[L,secretPattern[f(0x13c)](L)?f(0x18a):clean(s)]));return D;}export function writeAudit(D){const Q=p,L={'Buaoo':function(u,o){return u===o;},'qYPLa':Q(0x172),'qQTFR':Q(0x16e),'xgAEL':Q(0x16f),'WCIOL':Q(0x171),'ZZpwB':function(u,o){return u===o;},'SFThT':Q(0x166),'AGTFQ':Q(0x199),'HEMSD':Q(0x164),'lpzFj':function(u,o){return u===o;},'bkMuA':Q(0x174),'prOwz':Q(0x16c),'NqALm':Q(0x173),'kVQoH':function(u,o){return u===o;},'LQpzA':Q(0x15f),'dAAxD':Q(0x15e),'VMyDj':Q(0x143),'Kpxmj':Q(0x186),'oMhZy':Q(0x19b),'okdBB':function(u){return u();},'fcnGb':function(u,o){return u(o);},'VHgKx':Q(0x139),'KOSTO':Q(0x17b),'NsPRU':function(u,o){return u==o;},'Uwaau':function(u,o){return u(o);},'yukig':Q(0x185),'GNdpt':function(u,o){return u!==o;},'sjjSV':Q(0x138),'DPHUf':function(u,o){return u(o);}};let s,X;async function M(){const T=Q,u={'Lrhzx':function(r,i){const d=p;return L[d(0x196)](r,i);},'waFCQ':L[T(0x157)],'eIqHt':L[T(0x148)],'vPkUi':L[T(0x13d)],'qbakE':function(r,i){const K=T;return L[K(0x187)](r,i);},'nUIUZ':L[T(0x188)],'ymCCn':L[T(0x169)]};if(L[T(0x187)](L[T(0x155)],L[T(0x155)])){if(!D['pg']){if(T(0x13a)!==T(0x13a)){if(O[T(0x162)](h))return A[T(0x14d)](V);if(S&&IiGpaD[T(0x16a)](typeof z,IiGpaD[T(0x182)]))return a[T(0x152)](F[T(0x147)](w)[T(0x14d)](([N,U])=>[N,v[T(0x13c)](N)?T(0x18a):n(U)]));return H;}else return![];}if(s!==undefined){if(L[T(0x181)](L[T(0x14a)],L[T(0x19e)]))throw new L(u[T(0x145)]);else return s;}return X??=D['pg'][T(0x151)](T(0x134))[T(0x154)](r=>{const C=T;if(L[C(0x15c)](L[C(0x18b)],L[C(0x18b)])){const q=new Set(r[C(0x18f)][C(0x14d)](R=>R[C(0x176)]));s=q[C(0x161)](C(0x143))&&q[C(0x161)](L[C(0x135)]);if(!s){const R={};R[C(0x136)]=[L[C(0x13f)],C(0x186)],R[C(0x144)]=[...q],D[C(0x17d)][C(0x175)](R,L[C(0x15b)]);}return s;}else return o[C(0x17d)][C(0x15a)]({'auditFallback':!![],'event':r({...i,'changes':q[C(0x159)]?.[C(0x14d)](J=>({...J,'oldValue':O(J[C(0x197)]),'newValue':h(J[C(0x167)])}))})},u[C(0x177)]),0x0;})[T(0x153)](r=>{const k=T;if(u[k(0x189)](u[k(0x180)],u[k(0x180)])){s=![];const q={};return q[k(0x14c)]=r,D[k(0x17d)][k(0x175)](q,u[k(0x190)]),![];}else return L;}),X;}else return s[T(0x14d)](X);}return async function u(o){const G=Q,r={};r[G(0x18c)]=L[G(0x13f)],r[G(0x193)]=G(0x186),r[G(0x16d)]=L[G(0x15b)],r[G(0x137)]=G(0x16c);const i=r;if(L[G(0x196)](L[G(0x184)],L[G(0x184)])){if(!await L[G(0x195)](M))return D[G(0x17d)][G(0x15a)]({'auditFallback':!![],'event':L[G(0x13e)](clean,{...o,'changes':o[G(0x159)]?.[G(0x14d)](O=>({...O,'oldValue':clean(O[G(0x197)]),'newValue':clean(O[G(0x167)])}))})},L[G(0x13d)]),0x0;if(!D['pg']){if(L[G(0x15c)](L[G(0x13b)],L[G(0x19a)])){const O={};O[G(0x136)]=[JqyTBy[G(0x18c)],JqyTBy[G(0x193)]],O[G(0x144)]=[...X],s[G(0x17d)][G(0x175)](O,JqyTBy[G(0x16d)]);}else throw new Error(L[G(0x148)]);}const R=await D['pg'][G(0x151)](G(0x163),[o[G(0x194)]??null,o[G(0x14e)],o[G(0x17e)],L[G(0x168)](o[G(0x170)],null)?null:L[G(0x18d)](String,o[G(0x170)]),o[G(0x16b)]??null,o[G(0x160)],o[G(0x179)]??null,o[G(0x165)]??null,L[G(0x13e)](clean,o[G(0x191)]??{})]),B=R[G(0x18f)][0x0]['id'];for(const O of o[G(0x159)]??[]){if(L[G(0x196)](G(0x156),L[G(0x19c)]))return u[G(0x152)](o[G(0x147)](r)[G(0x14d)](([g,J])=>[g,R[G(0x13c)](g)?G(0x18a):B(J)]));else{if(secretPattern[G(0x13c)](O[G(0x178)])){if(L[G(0x150)](L[G(0x18e)],G(0x138))){const g=new o(r[G(0x18f)][G(0x14d)](J=>J[G(0x176)]));i=g[G(0x161)](L[G(0x17a)])&&g[G(0x161)](G(0x16e));if(!q){const J={};J[G(0x136)]=[L[G(0x13f)],L[G(0x141)]],J[G(0x144)]=[...g],O[G(0x17d)][G(0x175)](J,L[G(0x15b)]);}return B;}else continue;}await D['pg'][G(0x151)](G(0x17c),[B,O[G(0x178)],JSON[G(0x19d)](L[G(0x13e)](clean,O[G(0x197)])),JSON[G(0x19d)](L[G(0x17f)](clean,O[G(0x167)]))]);}}return B;}else{X=![];const h={};return h[G(0x14c)]=u,M[G(0x17d)][G(0x175)](h,JqyTBy[G(0x137)]),![];}};}
1
+ const secretPattern=/password|token|secret|credential|salt/i;function v(){const B=['fromEntries','[REDACTED]','query','map','table_name','has','audit_log_data','Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled','oldValue','\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5,\x20$6,\x20$7,\x20$8,\x20$9)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20','userId','resourceId','rows','changes','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log_data\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20audit_log_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20field,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20old_value,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20new_value\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20'];v=function(){return B;};return v();}function clean(d){const w=S;if(Array['isArray'](d))return d['map'](clean);if(d&&typeof d==='object')return Object[w(0x170)](Object['entries'](d)['map'](([h,p])=>[h,secretPattern['test'](h)?w(0x171):clean(p)]));return d;}function S(d,h){d=d-0x170;const p=v();let Z=p[d];return Z;}export function writeAudit(d){let h,p;async function Z(){const y=S;if(!d['pg'])return![];if(h!==undefined)return h;return p??=d['pg'][y(0x172)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20')['then'](D=>{const Q=y,u=new Set(D['rows'][Q(0x173)](n=>n[Q(0x174)]));return h=u['has']('audit_log')&&u[Q(0x175)](Q(0x176)),!h&&d['logger']['warn']({'expectedTables':['admin.audit_log','admin.audit_log_data'],'foundTables':[...u]},Q(0x177)),h;})['catch'](D=>{return h=![],d['logger']['warn']({'err':D},'Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled'),![];}),p;}return async function D(u){const F=S;if(!await Z())return d['logger']['info']({'auditFallback':!![],'event':clean({...u,'changes':u['changes']?.[F(0x173)](Y=>({...Y,'oldValue':clean(Y[F(0x178)]),'newValue':clean(Y['newValue'])}))})},'audit'),0x0;if(!d['pg'])throw new Error('empty\x20pg');const n=await d['pg']['query'](F(0x179),[u[F(0x17a)]??null,u['module'],u['resource'],u[F(0x17b)]==null?null:String(u['resourceId']),u['fields']??null,u['action'],u['requestId']??null,u['ipAddress']??null,clean(u['metadata']??{})]),X=n[F(0x17c)][0x0]['id'];for(const Y of u[F(0x17d)]??[]){if(secretPattern['test'](Y['field']))continue;await d['pg']['query'](F(0x17e),[X,Y['field'],JSON['stringify'](clean(Y[F(0x178)])),JSON['stringify'](clean(Y['newValue']))]);}return X;};}
@@ -0,0 +1,3 @@
1
+ import type { ContextDependencies } from "../../context.js";
2
+ export declare function getUserPermissions(userId: string, ctx: Pick<ContextDependencies, "pg">): Promise<string[]>;
3
+ //# sourceMappingURL=get-user-permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-user-permissions.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/get-user-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,GACnC,OAAO,CAAC,MAAM,EAAE,CAAC,CAenB"}
@@ -0,0 +1 @@
1
+ function v(){const u=['query'];v=function(){return u;};return v();}function S(d,h){d=d-0x170;const p=v();let Z=p[d];return Z;}export async function getUserPermissions(d,h){const D=S,p=await h['pg'][D(0x170)]('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20DISTINCT\x20ra.resource\x20||\x20\x27:\x27\x20||\x20action\x20AS\x20permission\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x20ON\x20ur.role_id\x20=\x20ra.role_id\x0a\x20\x20\x20\x20\x20\x20CROSS\x20JOIN\x20LATERAL\x20unnest(COALESCE(ra.actions,\x20\x27{}\x27::text[]))\x20AS\x20action\x0a\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20',[d]);return p['rows']['map'](Z=>Z['permission']);}
@@ -1,5 +1,9 @@
1
1
  export * from "./auth.types.js";
2
2
  import { type FastifyInstance } from "fastify";
3
3
  import { type ContextDependencies } from "../../context.js";
4
+ export * from "./verifyUser.js";
5
+ export * from "./get-user-permissions.js";
6
+ export declare function hashPassword(password: string): Promise<string>;
7
+ export declare function verifyPassword(password: string, stored: string): Promise<boolean>;
4
8
  export declare function createSessionStore(app: FastifyInstance, ctx: ContextDependencies): Promise<void>;
5
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI5D,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,mBAAmB,iBAsCzB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAUhC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI5D,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAE1C,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKpE;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAalB;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,mBAAmB,iBA6CzB"}
@@ -1 +1 @@
1
- (function(D,L){const g=p,u=D();while(!![]){try{const o=-parseInt(g(0x102))/0x1*(parseInt(g(0xff))/0x2)+-parseInt(g(0xf6))/0x3+parseInt(g(0x111))/0x4+parseInt(g(0x10c))/0x5+-parseInt(g(0x108))/0x6*(parseInt(g(0xfa))/0x7)+parseInt(g(0x10d))/0x8*(parseInt(g(0x103))/0x9)+-parseInt(g(0xf7))/0xa;if(o===L)break;else u['push'](u['shift']());}catch(r){u['push'](u['shift']());}}}(m,0x885bd));function m(){const S=['RddXt','database','2UbSRxK','XSRlL','initialize','1086648tMhwbW','14013pBVSTe','secureSession','Missing\x20config\x20or\x20redis\x20-\x20skipping\x20session\x20store\x20creation','registerUserSerializer','parseOptions','24RzPJUf','warn','cookieName','auth','1845595EnvtHQ','5056MdIaFJ','DrwDG','test','registerUserDeserializer','4194136bxliLO','register','640608wLECPP','4776840rAnTcd','IgQcQ','cookieOptions','114247fjUDax','secret','user'];m=function(){return S;};return m();}export*from'./auth.types.js';function p(D,L){D=D-0xf6;const s=m();let X=s[D];return X;}import s from'@fastify/cookie';import X from'@fastify/session';import{Authenticator}from'@fastify/passport';import M from'fastify-session-redis-store';const fastifyPassport=new Authenticator();export async function createSessionStore(u,o){const J=p,r={};r[J(0xf8)]=function(O,h){return O||h;},r[J(0x10e)]=J(0x105),r[J(0x100)]=function(O,h){return O===h;},r[J(0xfd)]=J(0x10f);const i=r,{config:q,redis:R}=o;if(i[J(0xf8)](!q,!R)){console[J(0x109)](i[J(0x10e)]);return;}if(i[J(0x100)](process.env.NODE_ENV,i[J(0xfd)])||process.env.VITEST)return;const B={};B[J(0x107)]=q[J(0x10b)][J(0xf9)],await u[J(0x112)](s,B),await u[J(0x112)](X,{'secret':q[J(0x10b)][J(0xfb)],'cookieName':q[J(0x10b)][J(0x10a)],'cookie':q[J(0x10b)][J(0xf9)],'store':new M({'prefix':q[J(0x10b)][J(0x10a)]+':'+(q['pg']?.[J(0xfe)]||'db')+':','client':R})}),await u[J(0x112)](fastifyPassport[J(0x101)]()),await u[J(0x112)](fastifyPassport[J(0x104)]()),fastifyPassport[J(0x106)](async O=>({'user':O})),fastifyPassport[J(0x110)](async O=>O?.[J(0xfc)]||O);}
1
+ export*from'./auth.types.js';import{randomBytes,scrypt as d,timingSafeEqual}from'node:crypto';import{promisify}from'node:util';const scrypt=promisify(d);import h from'@fastify/cookie';import p from'@fastify/session';function S(d,h){d=d-0x97;const p=v();let Z=p[d];return Z;}import{Authenticator}from'@fastify/passport';import Z from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();export*from'./verifyUser.js';export*from'./get-user-permissions.js';function v(){const g=['hex','split','scrypt','from','length','warn','cookieOptions','register','cookieName','auth','database'];v=function(){return g;};return v();}export async function hashPassword(D){const F=S,u=randomBytes(0x10),n=await scrypt(D,u,0x40);return'scrypt$'+u['toString'](F(0x97))+'$'+n['toString']('hex');}export async function verifyPassword(D,u){const B=S,[n,X,Y]=u?.[B(0x98)]('$')||[];if(n!==B(0x99)||!X||!Y)return![];const w=Buffer['from'](X,'hex'),y=Buffer[B(0x9a)](Y,B(0x97)),Q=await scrypt(D,w,y[B(0x9b)]);return timingSafeEqual(Q,y);}export async function createSessionStore(D,u){const K=S,{config:n,redis:X}=u;if(!n||!X){console[K(0x9c)]('Missing\x20config\x20or\x20redis\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV==='test'||process.env.VITEST)return;await D['register'](h,{'parseOptions':n['auth'][K(0x9d)]}),await D[K(0x9e)](p,{'secret':n['auth']['secret'],'cookieName':n['auth'][K(0x9f)],'cookie':n['auth']['cookieOptions'],'store':new Z({'prefix':n[K(0xa0)]['cookieName']+':'+(n['pg']?.[K(0xa1)]||'db')+':','client':X})}),await D[K(0x9e)](fastifyPassport['initialize']()),await D['register'](fastifyPassport['secureSession']()),fastifyPassport['registerUserSerializer'](async Y=>({'user':Y})),fastifyPassport['registerUserDeserializer'](async Y=>{const w=Y?.['user']||Y;return w?.['id']&&(w['permissions']=await getUserPermissions(w['id'],u)),w;});}
@@ -0,0 +1,9 @@
1
+ import { ContextDependencies } from "../../context.js";
2
+ type params = {
3
+ user: string;
4
+ password: string;
5
+ ip?: string;
6
+ };
7
+ export declare function verifyUser({ user, password, ip, }: params, { pg, logger }: Pick<ContextDependencies, "pg" | "logger">): Promise<import("./auth.types.js").AuthUser>;
8
+ export {};
9
+ //# sourceMappingURL=verifyUser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifyUser.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/verifyUser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAQ,MAAM,kBAAkB,CAAC;AAI7D,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAsB,UAAU,CAC9B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,EAC/B,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,QAAQ,CAAC,+CAgC3D"}
@@ -0,0 +1 @@
1
+ function v(){const Q=['not\x20enough\x20params:\x20user','user.login','select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password_hash,\x20twofa\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201','query','rows','auth/warn','password_hash','Wrong\x20password'];v=function(){return Q;};return v();}import{BadRequestError}from'../../errors.js';import{verifyPassword}from'./index.js';function S(d,h){d=d-0x11f;const p=v();let Z=p[d];return Z;}export async function verifyUser({user:d,password:h,ip:p},{pg:Z,logger:D}){const y=S;if(!d||d==='')throw new BadRequestError(y(0x11f));if(!h||h==='')throw new BadRequestError('not\x20enough\x20params:\x20password');D['metrics'](y(0x120));const u=y(0x121),n=await Z[y(0x122)](u,[d])['then'](Y=>Y[y(0x123)]?.[0x0]);if(!n){const Y='user\x20not\x20found';D['info']({'file':y(0x124),'error':Y,'user':d,'ip':p});throw new BadRequestError(Y);}const X=await verifyPassword(h,n[y(0x125)]);if(!X){const w=y(0x126);D['info']({'file':'auth/warn','error':w,'user':d,'ip':p});throw new BadRequestError(w);}return delete n['password_hash'],n;}
@@ -9,13 +9,16 @@ export interface DictionaryItem {
9
9
  export interface DictionaryDefinition {
10
10
  code: string;
11
11
  name?: string;
12
+ checked?: boolean;
12
13
  items: DictionaryItem[];
13
14
  }
14
15
  export interface DictionaryPlugin {
15
16
  register(input: DictionaryDefinition | DictionaryDefinition[]): void;
17
+ has(name: string): boolean;
16
18
  get(name: string): Promise<DictionaryItem[]>;
17
19
  put(name: string, items: DictionaryItem[]): Promise<void>;
18
20
  clear(name: string): boolean;
21
+ revision(name: string): number;
19
22
  list(): Promise<Array<{
20
23
  code: string;
21
24
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/plugins/dictionary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAMD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,GAAG,IAAI,CAAC;IACrE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,IAAI,IAAI,OAAO,CACb,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAA;KAAE,CAAC,CACrE,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACvC;AAID,wBAAgB,gBAAgB,CAAC,EAC/B,EAAE,EACF,YAAiB,GAClB,EAAE,sBAAsB,GAAG,gBAAgB,CAiM3C"}
1
+ {"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/plugins/dictionary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAMD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,GAAG,IAAI,CAAC;IACrE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,IAAI,OAAO,CACb,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAA;KAAE,CAAC,CACrE,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACvC;AAID,wBAAgB,gBAAgB,CAAC,EAC/B,EAAE,EACF,YAAiB,GAClB,EAAE,sBAAsB,GAAG,gBAAgB,CAkN3C"}
@@ -1 +1 @@
1
- (function(D,L){const Q=p,s=D();while(!![]){try{const X=-parseInt(Q(0x129))/0x1+parseInt(Q(0x132))/0x2*(-parseInt(Q(0x172))/0x3)+-parseInt(Q(0x12c))/0x4+-parseInt(Q(0x17f))/0x5+parseInt(Q(0x162))/0x6*(-parseInt(Q(0x15d))/0x7)+parseInt(Q(0x136))/0x8+parseInt(Q(0x16b))/0x9*(parseInt(Q(0x17b))/0xa);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0xf06b7));import{ConflictError,NotFoundError,ValidationError}from'../errors.js';const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;function p(D,L){D=D-0x118;const s=m();let X=s[D];return X;}function m(){const m0=['empty\x20pg','GzhmR','471yjcMSr','GIwos','CcmrZ','erZWg','static','Dictionary\x20items\x20must\x20be\x20an\x20array','source','LoQmI','mNrHg','90aRhvHu','test','YAjVZ','code','5920575XwkTGp','custom','yUfUD','Dictionary\x20not\x20found:\x20','get','fcore','UMyWA','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.id,\x20di.code,\x20di.name,\x20di.parent_id\x20AS\x20\x22parentId\x22\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20','jExcq','COMMIT','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20','LXtgd','YfcHm','isArray','EVmYh','ceoDd','put','pMfqt','register','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','463590kwYmpj','eVzkl','taocS','692108nQQlBN','Dictionary\x20already\x20registered:\x20','eWilO','name','NUGGt','lWuoY','18134edDibZ','Invalid\x20dictionary\x20items:\x20','rows','kzZRV','10326424oYqWfO','query','dUCMF','then','connect','SbJOe','dictionaries','values','ROLLBACK','eKKBr','VYGKz','set','wCpBy','SPWTC','delete','length','pPflm','table_name','Invalid\x20dictionary\x20name:\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','bpOri','RoCph','cNhJW','BEMNb','database','Iousf','map','list','has','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20','oadEY','buMjx','Utgez','BEGIN','rWOrs','ouxyC','clear','pYiSU','39977HDwPTe','DFpQK','rqJGj','swkNR','push','1248gBQnVv','ywFjM','pGzMz','Dictionary\x20table\x20not\x20found','DCwei','FVmBU','IdJUK','items','parentId','4126095EnCjuN','SwoDy','nnChf','eHUWn','release'];m=function(){return m0;};return m();}export function createDictionary({pg:L,dictionaries:dictionaries=[]}){const d=p,s={'buMjx':d(0x170),'IdJUK':d(0x13c),'LXtgd':d(0x174),'UMyWA':d(0x138),'eVzkl':function(g,J){return g!==J;},'nnChf':function(g,J){return g(J);},'EVmYh':d(0x176),'YfcHm':d(0x146),'oadEY':d(0x124),'GzhmR':d(0x142),'DCwei':d(0x164),'rqJGj':d(0x12b),'eHUWn':d(0x173),'Iousf':function(g){return g();},'ywFjM':d(0x165),'lWuoY':function(g,J){return g!==J;},'FVmBU':d(0x179),'SwoDy':d(0x14e),'jExcq':d(0x177),'rWOrs':d(0x140),'kzZRV':d(0x180),'eKKBr':d(0x11e),'DFpQK':d(0x13e),'BEMNb':d(0x17a),'erZWg':function(g,J){return g(J);},'yUfUD':function(g,J){return g!==J;},'YAjVZ':d(0x13b),'SPWTC':d(0x15a),'RoCph':function(g){return g();},'Utgez':function(g,J){return g===J;},'cNhJW':d(0x15c),'NUGGt':d(0x12e),'swkNR':function(g,J){return g(J);}},X=new Map();let M,u;async function o(){const T=d;if(s[T(0x120)]===s[T(0x11b)])throw new L(s[T(0x156)]);else{if(s[T(0x12a)](M,undefined))return M;if(!L)throw new Error(T(0x170));return u??=L[T(0x137)](T(0x154))[T(0x139)](J=>{const K=T,S=J[K(0x134)][0x0]?.[K(0x147)];M=S===s[K(0x168)]?S:null;}),await u,M;}}function r(g){const C=d;if(!dictionaryName[C(0x17c)](g))throw new ValidationError(C(0x148)+g);}function i(g){const G=d,J={'pMfqt':function(S,z){const k=p;return s[k(0x16d)](S,z);},'bpOri':s[G(0x123)]};if(s[G(0x121)]!==s[G(0x121)])for(const z of y[G(0x122)](E)?c:[H]){J[G(0x126)](P,z[G(0x17e)]);if(!v[G(0x122)](z[G(0x169)]))throw new U(G(0x133)+z[G(0x17e)]);if(Z[G(0x152)](z[G(0x17e)]))throw new b(G(0x12d)+z[G(0x17e)]);N[G(0x141)](z[G(0x17e)],{...z,'source':G(0x176)});}else for(const z of Array[G(0x122)](g)?g:[g]){if(s[G(0x155)]===s[G(0x171)])throw new L(s[G(0x156)]);else{r(z[G(0x17e)]);if(!Array[G(0x122)](z[G(0x169)])){if(s[G(0x166)]===s[G(0x166)])throw new ValidationError(G(0x133)+z[G(0x17e)]);else s[G(0x161)](X);}if(X[G(0x152)](z[G(0x17e)])){if(s[G(0x15f)]!==G(0x12b)){J[G(0x126)](h,g[G(0x17e)]);if(!J[G(0x122)](S[G(0x169)]))throw new a(G(0x133)+F[G(0x17e)]);if(t[G(0x152)](y[G(0x17e)]))throw new w(G(0x12d)+W[G(0x17e)]);const E={...V};E[G(0x178)]=J[G(0x14a)],H[G(0x141)](A[G(0x17e)],E);}else throw new ConflictError(G(0x12d)+z[G(0x17e)]);}X[G(0x141)](z[G(0x17e)],{...z,'source':s[G(0x123)]});}}}async function q(g){const j=d;s[j(0x16d)](r,g);const J=X[j(0x119)](g);if(J){if(s[j(0x12a)](s[j(0x16e)],j(0x173)))throw new s(j(0x133)+X[j(0x17e)]);else return J[j(0x169)];}const S=await s[j(0x14f)](o);if(!S)throw new NotFoundError(s[j(0x163)]);if(!L){if(s[j(0x131)](s[j(0x167)],s[j(0x167)]))return L;else throw new Error(s[j(0x156)]);}const z=await L[j(0x137)](j(0x11c),[g]);if(!z[j(0x134)][j(0x145)])throw new NotFoundError(j(0x118)+g);const l=z[j(0x134)];return X[j(0x141)](g,{'code':g,'name':g,'items':l,'source':s[j(0x16c)]}),l;}async function R(g,J){const e=d;r(g);if(!Array[e(0x122)](J))throw new ValidationError(s[e(0x11d)]);const S=await s[e(0x14f)](o);if(!S)throw new NotFoundError(s[e(0x163)]);if(!L){if(s[e(0x131)](s[e(0x159)],s[e(0x159)]))throw new s(e(0x118)+X);else throw new Error(e(0x170));}const z=await L[e(0x13a)]();try{await z[e(0x137)](e(0x158));const t=await z[e(0x137)](e(0x128),[g,g,e(0x11a),s[e(0x135)],!![]]),y=t[e(0x134)][0x0]['id'];await z[e(0x137)](e(0x153),[y]);for(const E of J){await z[e(0x137)](e(0x149),[y,E[e(0x17e)],E[e(0x12f)],E[e(0x16a)]??null]);}await z[e(0x137)](s[e(0x13f)]);}catch(c){await z[e(0x137)](s[e(0x15e)]);throw c;}finally{if(s[e(0x14d)]===s[e(0x14d)])z[e(0x16f)]();else return L[e(0x169)];}s[e(0x16d)](B,g);}function B(g){const Y=d;return s[Y(0x175)](r,g),X[Y(0x144)](g);}async function O(){const I=d;if(s[I(0x181)](s[I(0x17d)],s[I(0x143)])){const g=[...X[I(0x13d)]()][I(0x150)](({code:z,name:l,source:t})=>({'code':z,'name':l??z,'source':t})),J=await s[I(0x14b)](o);if(!J)return g;if(!L)throw new Error(s[I(0x156)]);const S=await L[I(0x137)](I(0x11f));for(const z of S[I(0x134)]){if(!X[I(0x152)](z[I(0x17e)])){if(s[I(0x157)](s[I(0x14c)],s[I(0x130)])){if(!M[I(0x17c)](u))throw new i(I(0x148)+q);}else g[I(0x161)](z);}}return g;}else{const y=s[I(0x134)][0x0]?.[I(0x147)];X=y===s[I(0x168)]?y:null;}}s[d(0x160)](i,dictionaries);const h={};return h[d(0x127)]=i,h[d(0x119)]=q,h[d(0x125)]=R,h[d(0x15b)]=B,h[d(0x151)]=O,h;}
1
+ import{ConflictError,NotFoundError,ValidationError}from'../errors.js';function S(d,h){d=d-0x8f;const p=v();let Z=p[d];return Z;}const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;export function createDictionary({pg:d,dictionaries:dictionaries=[]}){const h=new Map(),p=new Map();let Z,D;async function u(){const U=S;if(Z!==undefined)return Z;if(!d)throw new Error('empty\x20pg');return D??=d['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20')[U(0x8f)](K=>{const I=U,g=K[I(0x90)][0x0]?.[I(0x91)];Z=g==='dictionaries'?g:null;}),await D,Z;}function n(K){if(!dictionaryName['test'](K))throw new ValidationError('Invalid\x20dictionary\x20name:\x20'+K);}function X(K){const k=S;for(const g of Array[k(0x92)](K)?K:[K]){n(g[k(0x93)]);if(!Array[k(0x92)](g[k(0x94)]))throw new ValidationError('Invalid\x20dictionary\x20items:\x20'+g[k(0x93)]);if(h['has'](g[k(0x93)]))throw new ConflictError(k(0x95)+g[k(0x93)]);h[k(0x96)](g['code'],{...g,'source':'static'});}}function Y(K){const c=S;return h[c(0x97)](K);}async function w(K){const q=S;n(K);const g=h[q(0x98)](K);if(g&&g['checked'])return g['items'];const s=await u();if(!s)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const M=await d?.['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.code,\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[K]);if(M?.['rows']?.['length']){const O=M?.['rows'];return h['set'](K,{'code':K,'name':K,'items':O,'source':q(0x99),'checked':!![]}),O;}if(!g?.[q(0x94)])throw new NotFoundError(q(0x9a)+K);return g[q(0x9b)]=!![],g['items'];}async function y(K,g){const j=S;n(K);if(!Array['isArray'](g))throw new ValidationError('Dictionary\x20items\x20must\x20be\x20an\x20array');const s=await u();if(!s)throw new NotFoundError(j(0x9c));if(!d)throw new Error('empty\x20pg');const M=await d[j(0x9d)]();try{await M['query']('BEGIN');const O=await M[j(0x9e)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[K,K,'fcore','custom',!![]]),R=O['rows'][0x0]['id'];await M['query'](j(0x9f),[R]);for(const E of g){await M[j(0x9e)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[R,E['code'],E[j(0xa0)],E['parentId']??null]);}await M['query']('COMMIT');}catch(J){await M['query'](j(0xa1));throw J;}finally{M['release']();}h['set'](K,{'items':g,'code':K,'source':'static','checked':!![]}),p[j(0x96)](K,(p['get'](K)??0x0)+0x1);}function Q(K){return n(K),p['set'](K,(p['get'](K)??0x0)+0x1),h['delete'](K);}function F(K){return p['get'](K)??0x0;}async function B(){const P=S,K=[...h['values']()][P(0xa2)](({code:M,name:O,source:R})=>({'code':M,'name':O??M,'source':R})),g=await u();if(!g)return K;if(!d)throw new Error(P(0xa3));const s=await d[P(0x9e)](P(0xa4));for(const M of s[P(0x90)]){!h['has'](M['code'])&&K['push'](M);}return K;}return X(dictionaries),{'register':X,'get':w,'put':y,'clear':Q,'revision':F,'list':B,'has':Y};}function v(){const L=['then','rows','table_name','isArray','code','items','Dictionary\x20already\x20registered:\x20','set','has','get','database','Dictionary\x20not\x20found:\x20','checked','Dictionary\x20table\x20not\x20found','connect','query','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','name','ROLLBACK','map','empty\x20pg','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20'];v=function(){return L;};return v();}
@@ -1,17 +1,14 @@
1
1
  /**
2
2
  * Implements the S3-compatible file storage adapter and its contracts.
3
3
  */
4
+ import type { Readable } from "node:stream";
4
5
  export interface FileAdapter {
5
- put(path: string, buffer: Buffer): Promise<void>;
6
+ put(path: string, body: Buffer | Readable): Promise<void>;
6
7
  get(path: string): Promise<Buffer>;
7
8
  exists(path: string): Promise<boolean>;
8
9
  delete(path: string): Promise<void>;
9
10
  create(path: string, ttl?: number): string;
10
- verify(token: string): FileTokenPayload;
11
- }
12
- export interface FileTokenPayload {
13
- p: string;
14
- exp: number;
11
+ verify(token: string): string;
15
12
  }
16
13
  export interface FileS3Config {
17
14
  endpoint?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC3C;AACD,MAAM,WAAW,gBAAgB;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAgCD,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CA4F9D"}
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAKD,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAgCD,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAiF9D"}
@@ -1 +1 @@
1
- (function(D,L){const y=p,s=D();while(!![]){try{const X=parseInt(y(0x249))/0x1*(-parseInt(y(0x231))/0x2)+-parseInt(y(0x1ef))/0x3+parseInt(y(0x219))/0x4+-parseInt(y(0x1e3))/0x5*(-parseInt(y(0x208))/0x6)+parseInt(y(0x24e))/0x7*(-parseInt(y(0x242))/0x8)+parseInt(y(0x216))/0x9+parseInt(y(0x23a))/0xa*(-parseInt(y(0x222))/0xb);if(X===L)break;else s['push'](s['shift']());}catch(M){s['push'](s['shift']());}}}(m,0x270f7));import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';function p(D,L){D=D-0x1df;const s=m();let X=s[D];return X;}import t from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function keyFor(L,s){const E=p,X={};X[E(0x21d)]=function(r,i){return r===i;},X[E(0x21a)]=function(r,i){return r===i;},X[E(0x22c)]=E(0x237),X[E(0x217)]=E(0x1f1),X[E(0x1fe)]=E(0x1f5);const M=X;if(!s||s[E(0x24b)]('/')||s[E(0x248)]('..')){if(M[E(0x217)]===M[E(0x217)])throw new ValidationError(M[E(0x1fe)]);else{const i=s;if(M[E(0x21d)](i[E(0x227)]?.[E(0x1e2)],0x194)||M[E(0x21a)](i[E(0x200)],M[E(0x22c)]))return![];throw X;}}const u=s[E(0x1fd)](/\\/g,'/')[E(0x1fd)](/^\/+/,''),o=(L??'')[E(0x1fd)](/^\/+|\/+$/g,'');return o?o+'/'+u:u;}async function bodyToBuffer(L){const c=p,s={};s[c(0x1f7)]=function(o,r){return o===r;},s[c(0x21e)]=c(0x22b),s[c(0x1e0)]=c(0x20e),s[c(0x1eb)]=function(o,r){return o===r;},s[c(0x236)]=c(0x207);const X=s;if(!L)return X[c(0x1f7)](c(0x22b),X[c(0x21e)])?Buffer[c(0x212)](0x0):L[c(0x212)](0x0);const M=L;if(X[c(0x1f7)](typeof M[c(0x233)],X[c(0x1e0)]))return Buffer[c(0x20f)](await M[c(0x233)]());const u=[];for await(const r of L){if(X[c(0x1eb)](c(0x207),X[c(0x236)]))u[c(0x210)](Buffer[c(0x20f)](r));else throw new L(c(0x1f5));}return Buffer[c(0x245)](u);}function m(){const v=['qXBfN','RycsK','folder','createHmac','send','bucket','replace','rVADi','MEesa','name','vgfdy','accessKeyId','sumMk','RuTOj','credentials','jLswH','qckHy','6hiTOhT','split','USxna','us-east-1','ioFre','BzwwD','function','from','push','ztOGo','alloc','KxJiz','exp','File\x20token\x20expired','973179aAzNzP','Nhwcd','tokenTtl','849380cJVmRu','KjPhH','MsMoD','update','xQLSE','CZISc','INcoG','IVNGn','utf8','993322yIEsht','forcePathStyle','MtmVZ','KyYbG','secretKey','$metadata','GVWmO','NZVGu','secretAccessKey','MVSaX','nmbrv','stringify','uDNjS','PifSW','IKVJI','20846mPUWgr','AgiMq','transformToByteArray','JguGV','endpoint','bmTtb','NotFound','region','toString','10EySOwV','randomBytes','now','vdXPx','aIBTk','Body','aKUwv','HjrAe','8psgbTu','KVvdp','lUHHM','concat','length','HTIQt','includes','16XooFMs','mqTXc','startsWith','isInteger','base64url','992369ygtnqQ','eoMUX','FjZBy','parse','hex','DByXg','YJiRB','rALbX','LJpYY','httpStatusCode','1279085TUuLow','tokenSecret','accessKey','vpEAJ','svIxE','timingSafeEqual','CimkS','floor','FcjtQ','YHBJG','twuIt','OXfAa','52395dHlxWM','feiAD','PSlYy','Invalid\x20file\x20token','sha256','digest','Invalid\x20file\x20path','CECKr'];m=function(){return v;};return m();}export function createFileS3(L){const H=p,s={'YJiRB':function(r,i){return r===i;},'AgiMq':H(0x22f),'MtmVZ':function(r,i){return r(i);},'uDNjS':function(r,i){return r(i);},'sumMk':function(r,i){return r+i;},'NZVGu':H(0x24d),'MsMoD':function(r,i){return r!==i;},'CECKr':H(0x1e7),'BzwwD':function(r,i){return r===i;},'RuTOj':function(r,i){return r===i;},'RycsK':H(0x237),'mqTXc':H(0x1f2),'INcoG':H(0x1ed),'eoMUX':H(0x1ec),'jLswH':function(r,i){return r===i;},'USxna':H(0x225),'KVvdp':function(r,i){return r+i;},'MEesa':function(r,i){return r/ i;},'KxJiz':H(0x1f3),'aIBTk':H(0x1e1),'CimkS':H(0x201),'IVNGn':H(0x221),'aKUwv':H(0x250),'vpEAJ':H(0x241),'feiAD':H(0x230),'ioFre':function(r,i){return r<i;},'OXfAa':H(0x215),'JguGV':H(0x20b)},X=L[H(0x1e4)]??process.env.FILE_TOKEN_SECRET??t[H(0x23b)](0x20)[H(0x239)](H(0x252)),M={};M[H(0x235)]=L[H(0x235)],M[H(0x238)]=L[H(0x238)]??s[H(0x234)],M[H(0x223)]=L[H(0x223)]??!![],M[H(0x205)]=L[H(0x202)]||L[H(0x1e5)]?{'accessKeyId':L[H(0x202)]??L[H(0x1e5)],'secretAccessKey':L[H(0x22a)]??L[H(0x226)]}:undefined;const u=new S3Client(M),o=r=>keyFor(L[H(0x1f9)],r);return{async 'put'(r,i){const A=H;if(s[A(0x1df)](s[A(0x232)],s[A(0x232)]))await u[A(0x1fb)](new PutObjectCommand({'Bucket':L[A(0x1fc)],'Key':s[A(0x224)](o,r),'Body':i}));else return![];},async 'get'(r){const V=H,i=await u[V(0x1fb)](new GetObjectCommand({'Bucket':L[V(0x1fc)],'Key':s[V(0x224)](o,r)}));return s[V(0x22e)](bodyToBuffer,i[V(0x23f)]);},async 'exists'(r){const F=H,i={'GVWmO':function(q,R){const a=p;return s[a(0x203)](q,R);},'vdXPx':s[F(0x229)],'DByXg':F(0x1f3)};if(s[F(0x21b)](s[F(0x1f6)],s[F(0x1f6)])){const R={'p':i,'exp':i[F(0x228)](q[F(0x1ea)](R[F(0x23c)]()/0x3e8),B)},B=O[F(0x20f)](h[F(0x22d)](R))[F(0x239)](i[F(0x23d)]),O=g[F(0x1fa)](i[F(0x253)],J)[F(0x21c)](B)[F(0x1f4)](i[F(0x23d)]);return B+'.'+O;}else try{return await u[F(0x1fb)](new HeadObjectCommand({'Bucket':L[F(0x1fc)],'Key':o(r)})),!![];}catch(R){const B=R;if(s[F(0x20d)](B[F(0x227)]?.[F(0x1e2)],0x194)||s[F(0x204)](B[F(0x200)],s[F(0x1f8)]))return![];throw R;}},async 'delete'(r){const w=H,i={};i[w(0x211)]=s[w(0x24a)];const q=i;if(s[w(0x21b)](s[w(0x21f)],s[w(0x24f)]))await u[w(0x1fb)](new DeleteObjectCommand({'Bucket':L[w(0x1fc)],'Key':o(r)}));else throw new i(q[w(0x211)]);},'create'(r,i=L[H(0x218)]??0xe10){const W=H,q={};q[W(0x244)]=W(0x215);const R=q;if(s[W(0x206)](s[W(0x20a)],s[W(0x20a)])){const B={'p':r,'exp':s[W(0x243)](Math[W(0x1ea)](s[W(0x1ff)](Date[W(0x23c)](),0x3e8)),i)},O=Buffer[W(0x20f)](JSON[W(0x22d)](B))[W(0x239)](W(0x24d)),h=t[W(0x1fa)](s[W(0x213)],X)[W(0x21c)](O)[W(0x1f4)](s[W(0x229)]);return O+'.'+h;}else throw new q(R[W(0x244)]);},'verify'(r){const P=H,i={};i[P(0x247)]=s[P(0x24a)];const q=i,[R,B]=r[P(0x209)]('.');if(!R||!B){if(s[P(0x21b)](s[P(0x23e)],s[P(0x1e9)]))throw new UnauthorizedError(s[P(0x24a)]);else throw new i(P(0x1f2));}const O=t[P(0x1fa)](s[P(0x213)],X)[P(0x21c)](R)[P(0x1f4)](),h=Buffer[P(0x20f)](B,s[P(0x229)]);if(s[P(0x21b)](O[P(0x246)],h[P(0x246)])||!t[P(0x1e8)](O,h))throw new UnauthorizedError(s[P(0x24a)]);let g;try{g=JSON[P(0x251)](Buffer[P(0x20f)](R,s[P(0x229)])[P(0x239)](s[P(0x220)]));}catch{if(s[P(0x240)]===s[P(0x240)])throw new UnauthorizedError(s[P(0x24a)]);else throw new i(q[P(0x247)]);}if(!g['p']||!Number[P(0x24c)](g[P(0x214)])){if(s[P(0x21b)](s[P(0x1e6)],s[P(0x1f0)]))throw new UnauthorizedError(s[P(0x24a)]);else throw new i(s[P(0x24a)]);}if(s[P(0x20c)](g[P(0x214)],Math[P(0x1ea)](Date[P(0x23c)]()/0x3e8)))throw new UnauthorizedError(s[P(0x1ee)]);return g;}};}
1
+ import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';import d from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function keyFor(h,p){const Q=S;if(!p||p['startsWith']('/')||p['includes']('..'))throw new ValidationError(Q(0xcd));const Z=p['replace'](/\\/g,'/')[Q(0xce)](/^\/+/,''),D=(h??'')[Q(0xce)](/^\/+|\/+$/g,'');return D?D+'/'+Z:Z;}function S(d,h){d=d-0xcd;const p=v();let Z=p[d];return Z;}async function bodyToBuffer(h){if(!h)return Buffer['alloc'](0x0);const p=h;if(typeof p['transformToByteArray']==='function')return Buffer['from'](await p['transformToByteArray']());const Z=[];for await(const D of h){Z['push'](Buffer['from'](D));}return Buffer['concat'](Z);}function v(){const R=['Invalid\x20file\x20path','replace','toString','region','us-east-1','forcePathStyle','accessKey','bucket','send','$metadata','from','update','timingSafeEqual','base64url'];v=function(){return R;};return v();}export function createFileS3(h){const F=S,p=h['tokenSecret']??process.env.FILE_TOKEN_SECRET??d['randomBytes'](0x20)[F(0xcf)]('hex'),Z=new S3Client({'endpoint':h['endpoint'],'region':h[F(0xd0)]??F(0xd1),'forcePathStyle':h[F(0xd2)]??!![],'credentials':h['accessKeyId']||h[F(0xd3)]?{'accessKeyId':h['accessKeyId']??h['accessKey'],'secretAccessKey':h['secretAccessKey']??h['secretKey']}:undefined}),D=u=>keyFor(h['folder'],u);return{async 'put'(u,n){const B=F;await Z['send'](new PutObjectCommand({'Bucket':h[B(0xd4)],'Key':D(u),'Body':n}));},async 'get'(u){const K=F,n=await Z[K(0xd5)](new GetObjectCommand({'Bucket':h['bucket'],'Key':D(u)}));return bodyToBuffer(n['Body']);},async 'exists'(u){const g=F;try{return await Z['send'](new HeadObjectCommand({'Bucket':h[g(0xd4)],'Key':D(u)})),!![];}catch(n){const X=n;if(X[g(0xd6)]?.['httpStatusCode']===0x194||X['name']==='NotFound')return![];throw n;}},async 'delete'(u){const s=F;await Z[s(0xd5)](new DeleteObjectCommand({'Bucket':h['bucket'],'Key':D(u)}));},'create'(u,n=h['tokenTtl']??0xe10){const M=F,X=Buffer[M(0xd7)](u)['toString']('base64url'),Y=d['createHmac']('sha256',p)[M(0xd8)](X)['digest']('base64url');return X+'.'+Y;},'verify'(u){const O=F,[n,X]=u['split']('.');if(!n||!X)throw new UnauthorizedError('Invalid\x20file\x20token');const Y=d['createHmac']('sha256',p)['update'](n)['digest'](),w=Buffer['from'](X,'base64url');if(Y['length']!==w['length']||!d[O(0xd9)](Y,w))throw new UnauthorizedError('Invalid\x20file\x20token');const y=Buffer['from'](n,O(0xda))['toString']('utf8');return y;}};}