@opengis/fcore 0.0.1-beta.0 → 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 (288) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +71 -71
  3. package/dist/config.d.ts +3 -10
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +1 -1
  6. package/dist/context.d.ts +4 -4
  7. package/dist/context.d.ts.map +1 -1
  8. package/dist/context.js +1 -1
  9. package/dist/errors.js +1 -1
  10. package/dist/fastify.d.ts +5 -5
  11. package/dist/fastify.d.ts.map +1 -1
  12. package/dist/fastify.js +1 -1
  13. package/dist/fcore.js +1 -1
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/migrations/cli.js +1 -1
  18. package/dist/migrations/runner.d.ts.map +1 -1
  19. package/dist/migrations/runner.js +1 -1
  20. package/dist/modules/auth/adduser-cli.d.ts +3 -0
  21. package/dist/modules/auth/adduser-cli.d.ts.map +1 -0
  22. package/dist/modules/auth/adduser-cli.js +2 -0
  23. package/dist/modules/auth/passwd-cli.d.ts +3 -0
  24. package/dist/modules/auth/passwd-cli.d.ts.map +1 -0
  25. package/dist/modules/auth/passwd-cli.js +2 -0
  26. package/dist/modules/auth/permission-cli.d.ts +3 -0
  27. package/dist/modules/auth/permission-cli.d.ts.map +1 -0
  28. package/dist/modules/auth/permission-cli.js +2 -0
  29. package/dist/modules/auth/route.d.ts.map +1 -1
  30. package/dist/modules/auth/route.js +1 -1
  31. package/dist/modules/auth/schema.d.ts +10 -1
  32. package/dist/modules/auth/schema.d.ts.map +1 -1
  33. package/dist/modules/auth/schema.js +1 -1
  34. package/dist/modules/auth/services/change-password.d.ts +9 -0
  35. package/dist/modules/auth/services/change-password.d.ts.map +1 -0
  36. package/dist/modules/auth/services/change-password.js +1 -0
  37. package/dist/modules/auth/services/get-current-user.d.ts +1 -0
  38. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  39. package/dist/modules/auth/services/get-current-user.js +1 -1
  40. package/dist/modules/auth/services/registration.d.ts +14 -0
  41. package/dist/modules/auth/services/registration.d.ts.map +1 -0
  42. package/dist/modules/auth/services/registration.js +1 -0
  43. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  44. package/dist/modules/file/mime.d.ts +3 -0
  45. package/dist/modules/file/mime.d.ts.map +1 -0
  46. package/dist/modules/file/mime.js +1 -0
  47. package/dist/modules/file/route.d.ts.map +1 -1
  48. package/dist/modules/file/route.js +1 -1
  49. package/dist/modules/file/schema.d.ts +3 -0
  50. package/dist/modules/file/schema.d.ts.map +1 -1
  51. package/dist/modules/file/schema.js +1 -1
  52. package/dist/modules/file/services/get-file.js +1 -1
  53. package/dist/modules/file/services/resize-file.d.ts.map +1 -1
  54. package/dist/modules/file/services/resize-file.js +1 -1
  55. package/dist/modules/file/services/upload-file.d.ts +4 -6
  56. package/dist/modules/file/services/upload-file.d.ts.map +1 -1
  57. package/dist/modules/file/services/upload-file.js +1 -1
  58. package/dist/modules/resource/route.d.ts +0 -3
  59. package/dist/modules/resource/route.d.ts.map +1 -1
  60. package/dist/modules/resource/route.js +1 -1
  61. package/dist/modules/resource/schema.d.ts +3 -0
  62. package/dist/modules/resource/schema.d.ts.map +1 -1
  63. package/dist/modules/resource/schema.js +1 -1
  64. package/dist/modules/resource/services/add-note.d.ts.map +1 -1
  65. package/dist/modules/resource/services/add-note.js +1 -1
  66. package/dist/modules/resource/services/add-resource-file.d.ts.map +1 -1
  67. package/dist/modules/resource/services/add-resource-file.js +1 -1
  68. package/dist/modules/resource/services/create-resource-relation.d.ts +8 -2
  69. package/dist/modules/resource/services/create-resource-relation.d.ts.map +1 -1
  70. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  71. package/dist/modules/resource/services/create-resource.js +1 -1
  72. package/dist/modules/resource/services/delete-resource-relation.d.ts +8 -1
  73. package/dist/modules/resource/services/delete-resource-relation.d.ts.map +1 -1
  74. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  75. package/dist/modules/resource/services/delete-resource.js +1 -1
  76. package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
  77. package/dist/modules/resource/services/export-resource.js +1 -1
  78. package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
  79. package/dist/modules/resource/services/get-resource.js +1 -1
  80. package/dist/modules/resource/services/list-resource-relation.d.ts +9 -2
  81. package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
  82. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  83. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  84. package/dist/modules/resource/services/list-resources.js +1 -1
  85. package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
  86. package/dist/modules/resource/services/search-resource.js +1 -1
  87. package/dist/modules/resource/services/suggest-resource.d.ts +10 -4
  88. package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
  89. package/dist/modules/resource/services/suggest-resource.js +1 -1
  90. package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
  91. package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
  92. package/dist/modules/resource/services/update-resource-relation.js +1 -0
  93. package/dist/modules/resource/services/update-resource.js +1 -1
  94. package/dist/modules/resource/services/upload-resource-file.d.ts.map +1 -1
  95. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  96. package/dist/modules/system/route.d.ts +2 -1
  97. package/dist/modules/system/route.d.ts.map +1 -1
  98. package/dist/modules/system/route.js +1 -1
  99. package/dist/modules/system/schema.d.ts +22 -1
  100. package/dist/modules/system/schema.d.ts.map +1 -1
  101. package/dist/modules/system/schema.js +1 -1
  102. package/dist/modules/system/services/check-system.d.ts.map +1 -1
  103. package/dist/modules/system/services/check-system.js +1 -1
  104. package/dist/modules/system/services/get-access.d.ts +14 -0
  105. package/dist/modules/system/services/get-access.d.ts.map +1 -0
  106. package/dist/modules/system/services/get-access.js +1 -0
  107. package/dist/modules/system/services/get-api-list.d.ts +4 -1
  108. package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
  109. package/dist/modules/system/services/get-api-list.js +1 -1
  110. package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
  111. package/dist/modules/system/services/get-audit-log.js +1 -1
  112. package/dist/modules/system/services/get-dictionary.js +1 -1
  113. package/dist/modules/system/services/get-system-log.d.ts +9 -5
  114. package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
  115. package/dist/modules/system/services/get-system-log.js +1 -1
  116. package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
  117. package/dist/modules/system/services/get-system-settings.js +1 -1
  118. package/dist/modules/system/services/list-dictionaries.js +1 -1
  119. package/dist/modules/system/services/set-access.d.ts +16 -0
  120. package/dist/modules/system/services/set-access.d.ts.map +1 -0
  121. package/dist/modules/system/services/set-access.js +1 -0
  122. package/dist/modules/system/services/update-dictionary.d.ts +13 -0
  123. package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
  124. package/dist/modules/system/services/update-dictionary.js +1 -0
  125. package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
  126. package/dist/modules/system/services/update-system-settings.js +1 -1
  127. package/dist/modules/utils/require-admin.d.ts +1 -1
  128. package/dist/modules/utils/require-admin.d.ts.map +1 -1
  129. package/dist/modules/utils/require-admin.js +1 -1
  130. package/dist/modules/utils/safe-user.js +1 -1
  131. package/dist/modules/utils/unsupported.js +1 -1
  132. package/dist/plugins/audit/audit.d.ts +2 -2
  133. package/dist/plugins/audit/audit.d.ts.map +1 -1
  134. package/dist/plugins/audit/audit.js +1 -1
  135. package/dist/plugins/audit/index.js +1 -1
  136. package/dist/plugins/audit/services/write-audit.d.ts +2 -2
  137. package/dist/plugins/audit/services/write-audit.d.ts.map +1 -1
  138. package/dist/plugins/audit/services/write-audit.js +1 -1
  139. package/dist/plugins/auth/get-user-permissions.d.ts +3 -0
  140. package/dist/plugins/auth/get-user-permissions.d.ts.map +1 -0
  141. package/dist/plugins/auth/get-user-permissions.js +1 -0
  142. package/dist/plugins/auth/index.d.ts +4 -0
  143. package/dist/plugins/auth/index.d.ts.map +1 -1
  144. package/dist/plugins/auth/index.js +1 -1
  145. package/dist/plugins/auth/verifyUser.d.ts +9 -0
  146. package/dist/plugins/auth/verifyUser.d.ts.map +1 -0
  147. package/dist/plugins/auth/verifyUser.js +1 -0
  148. package/dist/plugins/dictionary.d.ts +3 -0
  149. package/dist/plugins/dictionary.d.ts.map +1 -1
  150. package/dist/plugins/dictionary.js +1 -1
  151. package/dist/plugins/file.d.ts +4 -7
  152. package/dist/plugins/file.d.ts.map +1 -1
  153. package/dist/plugins/file.js +1 -1
  154. package/dist/plugins/index.d.ts +2 -0
  155. package/dist/plugins/index.d.ts.map +1 -1
  156. package/dist/plugins/index.js +1 -1
  157. package/dist/plugins/jwt.d.ts +4 -0
  158. package/dist/plugins/jwt.d.ts.map +1 -0
  159. package/dist/plugins/jwt.js +1 -0
  160. package/dist/plugins/logger/index.d.ts +9 -4
  161. package/dist/plugins/logger/index.d.ts.map +1 -1
  162. package/dist/plugins/logger/index.js +1 -1
  163. package/dist/plugins/logger/transport.d.ts +3 -0
  164. package/dist/plugins/logger/transport.d.ts.map +1 -0
  165. package/dist/plugins/logger/transport.js +1 -0
  166. package/dist/plugins/pg.d.ts +4 -2
  167. package/dist/plugins/pg.d.ts.map +1 -1
  168. package/dist/plugins/pg.js +1 -1
  169. package/dist/plugins/redis.js +1 -1
  170. package/dist/plugins/resource/index.js +1 -1
  171. package/dist/plugins/resource/resource.d.ts.map +1 -1
  172. package/dist/plugins/resource/resource.js +1 -1
  173. package/dist/plugins/resource/resource.registry.js +1 -1
  174. package/dist/plugins/resource/resource.types.d.ts +62 -8
  175. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  176. package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
  177. package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
  178. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
  179. package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
  180. package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
  181. package/dist/plugins/resource/services/add-file-token.js +1 -0
  182. package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
  183. package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
  184. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
  185. package/dist/plugins/resource/services/create-relation.d.ts +16 -0
  186. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
  187. package/dist/plugins/resource/services/create-relation.js +1 -0
  188. package/dist/plugins/resource/services/create.d.ts +5 -2
  189. package/dist/plugins/resource/services/create.d.ts.map +1 -1
  190. package/dist/plugins/resource/services/create.js +1 -1
  191. package/dist/plugins/resource/services/delete-relation.d.ts +18 -0
  192. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
  193. package/dist/plugins/resource/services/delete-relation.js +1 -0
  194. package/dist/plugins/resource/services/delete.d.ts +5 -2
  195. package/dist/plugins/resource/services/delete.d.ts.map +1 -1
  196. package/dist/plugins/resource/services/delete.js +1 -1
  197. package/dist/plugins/resource/services/find-one.d.ts +3 -2
  198. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  199. package/dist/plugins/resource/services/find-one.js +1 -1
  200. package/dist/plugins/resource/services/find-relation.d.ts +13 -0
  201. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
  202. package/dist/plugins/resource/services/find-relation.js +1 -0
  203. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  204. package/dist/plugins/resource/services/find.js +1 -1
  205. package/dist/plugins/resource/services/update-relation.d.ts +14 -0
  206. package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
  207. package/dist/plugins/resource/services/update-relation.js +1 -0
  208. package/dist/plugins/resource/services/update.d.ts +5 -2
  209. package/dist/plugins/resource/services/update.d.ts.map +1 -1
  210. package/dist/plugins/resource/services/update.js +1 -1
  211. package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
  212. package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
  213. package/dist/plugins/resource/utils/auto-index.js +1 -0
  214. package/dist/plugins/resource/utils/fields.d.ts +8 -1
  215. package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
  216. package/dist/plugins/resource/utils/fields.js +1 -1
  217. package/dist/plugins/resource/utils/filters.d.ts +3 -2
  218. package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
  219. package/dist/plugins/resource/utils/filters.js +1 -1
  220. package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
  221. package/dist/plugins/resource/utils/permissions.js +1 -1
  222. package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
  223. package/dist/plugins/resource/utils/sort.js +1 -1
  224. package/dist/plugins/resource/utils/sql.js +1 -1
  225. package/dist/shared/getIP.js +1 -1
  226. package/dist/type.d.ts +37 -0
  227. package/dist/type.d.ts.map +1 -0
  228. package/dist/type.js +1 -0
  229. package/migrations/20260903120000_core_schema.sql +259 -0
  230. package/migrations/20260903130000_move_notes_files_to_admin.sql +18 -0
  231. package/migrations/20260903140000_settings_nulls_not_distinct.sql +19 -0
  232. package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
  233. package/migrations/20260907090000_core_schema.sql +32 -0
  234. package/package.json +93 -87
  235. package/dist/modules/auth/index.d.ts +0 -9
  236. package/dist/modules/auth/index.d.ts.map +0 -1
  237. package/dist/modules/auth/index.js +0 -1
  238. package/dist/modules/auth/services/login.d.ts +0 -10
  239. package/dist/modules/auth/services/login.d.ts.map +0 -1
  240. package/dist/modules/auth/services/login.js +0 -1
  241. package/dist/modules/auth/services/logout.d.ts +0 -9
  242. package/dist/modules/auth/services/logout.d.ts.map +0 -1
  243. package/dist/modules/auth/services/logout.js +0 -1
  244. package/dist/modules/auth/services/verifyPassword.d.ts +0 -11
  245. package/dist/modules/auth/services/verifyPassword.d.ts.map +0 -1
  246. package/dist/modules/auth/services/verifyPassword.js +0 -1
  247. package/dist/modules/file/index.d.ts +0 -8
  248. package/dist/modules/file/index.d.ts.map +0 -1
  249. package/dist/modules/file/index.js +0 -1
  250. package/dist/modules/resource/index.d.ts +0 -20
  251. package/dist/modules/resource/index.d.ts.map +0 -1
  252. package/dist/modules/resource/index.js +0 -1
  253. package/dist/modules/resource/services/list-children.d.ts +0 -6
  254. package/dist/modules/resource/services/list-children.d.ts.map +0 -1
  255. package/dist/modules/resource/services/list-children.js +0 -1
  256. package/dist/modules/system/index.d.ts +0 -13
  257. package/dist/modules/system/index.d.ts.map +0 -1
  258. package/dist/modules/system/index.js +0 -1
  259. package/dist/modules/utils/get-user-permissions.d.ts +0 -3
  260. package/dist/modules/utils/get-user-permissions.d.ts.map +0 -1
  261. package/dist/modules/utils/get-user-permissions.js +0 -1
  262. package/dist/plugins/logger/checkUserAccess.d.ts +0 -11
  263. package/dist/plugins/logger/checkUserAccess.d.ts.map +0 -1
  264. package/dist/plugins/logger/checkUserAccess.js +0 -1
  265. package/dist/plugins/logger/createFileStream.d.ts +0 -3
  266. package/dist/plugins/logger/createFileStream.d.ts.map +0 -1
  267. package/dist/plugins/logger/createFileStream.js +0 -1
  268. package/dist/plugins/logger/createLogger.d.ts +0 -9
  269. package/dist/plugins/logger/createLogger.d.ts.map +0 -1
  270. package/dist/plugins/logger/createLogger.js +0 -1
  271. package/dist/plugins/logger/errorStatus.d.ts +0 -2
  272. package/dist/plugins/logger/errorStatus.d.ts.map +0 -1
  273. package/dist/plugins/logger/errorStatus.js +0 -1
  274. package/dist/plugins/logger/getHooks.d.ts +0 -5
  275. package/dist/plugins/logger/getHooks.d.ts.map +0 -1
  276. package/dist/plugins/logger/getHooks.js +0 -1
  277. package/dist/plugins/logger/getRootDir.d.ts +0 -3
  278. package/dist/plugins/logger/getRootDir.d.ts.map +0 -1
  279. package/dist/plugins/logger/getRootDir.js +0 -1
  280. package/dist/plugins/logger/labels.d.ts +0 -3
  281. package/dist/plugins/logger/labels.d.ts.map +0 -1
  282. package/dist/plugins/logger/labels.js +0 -1
  283. package/dist/plugins/logger/serializers.d.ts +0 -14
  284. package/dist/plugins/logger/serializers.d.ts.map +0 -1
  285. package/dist/plugins/logger/serializers.js +0 -1
  286. package/dist/plugins/logger/timestampWithTimeZone.d.ts +0 -2
  287. package/dist/plugins/logger/timestampWithTimeZone.d.ts.map +0 -1
  288. package/dist/plugins/logger/timestampWithTimeZone.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-dictionary-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-dictionary-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAsDnF,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,GAC7C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAuBpC"}
@@ -0,0 +1 @@
1
+ const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(d,h){const Q=S,p=dictionaryIndexesCache['get'](h)??new Map(),Z=dictionaryRevisionsCache['get'](h)??new Map();dictionaryIndexesCache['set'](h,p),dictionaryRevisionsCache['set'](h,Z);const D=d[Q(0x1e6)](n=>Z['get'](n)!==h['revision'](n));if(D['length']===0x0)return p;const u=await Promise['all'](D['map'](async n=>{const F=Q;if(!h[F(0x1e7)](n))return[n,new Map()];const X=await h['get'](n),Y=new Map();for(const w of X){const y=w[F(0x1e8)]??w['id'];if(y==null)continue;Y['set'](String(y),{'id':y,'text':w[F(0x1e9)]??w[F(0x1ea)],...w[F(0x1eb)]!==undefined?{'color':w['color']}:{},...w['icon']!==undefined?{'icon':w['icon']}:{}});}return[n,Y];}));for(const [n,X]of u){p['set'](n,X),Z[Q(0x1ec)](n,h['revision'](n));}return p;}function S(d,h){d=d-0x1e6;const p=v();let Z=p[d];return Z;}function v(){const K=['filter','has','code','name','text','color','set','length','entries','map','get'];v=function(){return K;};return v();}export async function addDictionaryLookupData(d,h,p){const B=S;if(!p||d[B(0x1ed)]===0x0)return d;const Z=Object[B(0x1ee)](h)['flatMap'](([u,n])=>{const X=n['dictionary'];return X?[{'field':u,'dictionaryName':X}]:[];});if(Z['length']===0x0)return d;const D=await getDictionaryIndexes([...new Set(Z[B(0x1ef)](({dictionaryName:u})=>u))],p);for(const u of d){for(const {field:n,dictionaryName:X}of Z){const Y=u[n];u[n+'_data']=Y==null?null:D[B(0x1f0)](X)?.['get'](String(Y))??null;}}return d;}
@@ -0,0 +1,3 @@
1
+ import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
2
+ export declare function addFileToken(rows: Record<string, unknown>[], fields: ResourceContract["fields"], file: ResourceDependencies["file"]): Record<string, unknown>[];
3
+ //# sourceMappingURL=add-file-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-file-token.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-file-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,wBAAgB,YAAY,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAiB3B"}
@@ -0,0 +1 @@
1
+ function S(d,h){d=d-0x169;const p=v();let Z=p[d];return Z;}export function addFileToken(d,h,p){const X=S;if(!p||d['length']===0x0)return d;const Z=Object[X(0x169)](h)[X(0x16a)](([,D])=>D['type']===X(0x16b))['map'](([D])=>D);for(const D of d){for(const u of Z){const n=D[u];typeof n==='string'&&n[X(0x16c)]>0x0&&(D[u]=p[X(0x16d)](n));}}return d;}function v(){const Y=['entries','filter','file','length','create'];v=function(){return Y;};return v();}
@@ -0,0 +1,4 @@
1
+ import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
2
+ export declare function clearTableLookupCache(table: string, pg: NonNullable<ResourceDependencies["pg"]>): void;
3
+ export declare function addTableLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], pg: ResourceDependencies["pg"]): Promise<Record<string, unknown>[]>;
4
+ //# sourceMappingURL=add-table-lookup-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-table-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-table-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAQnF,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAC5C,IAAI,CASN;AAED,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CA8DpC"}
@@ -0,0 +1 @@
1
+ import{qi,qt}from'../utils/sql.js';function v(){const O=['entries','string','query','SELECT\x20','\x20AS\x20id,\x20','\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20','table','value'];v=function(){return O;};return v();}const tableLookupCache=new WeakMap();function S(d,h){d=d-0x19c;const p=v();let Z=p[d];return Z;}export function clearTableLookupCache(d,h){const p=tableLookupCache['get'](h);if(!p)return;for(const Z of p['keys']()){Z['startsWith'](d+':')&&p['delete'](Z);}}export async function addTableLookupData(d,h,p){const M=S;if(!p||d['length']===0x0)return d;const Z=tableLookupCache['get'](p)??new Map();tableLookupCache['set'](p,Z);const D=Object[M(0x19c)](h)['flatMap'](([u,n])=>{const {table:X,value:value='id',text:text='name'}=n['lookup']??{};return X?[{'field':u,'table':X,'value':value,'text':text}]:[];});for(const u of D){const n=new Map();for(const y of d){const Q=y[u['field']];(typeof Q===M(0x19d)||typeof Q==='number')&&n['set'](String(Q),Q);}const X=u['table']+':'+u['value']+':'+u['text'],Y=Z['get'](X)??new Map();Z['set'](X,Y);const w=[...n[M(0x19c)]()]['filter'](([F])=>!Y['has'](F))['map'](([,F])=>F);if(w['length']>0x0){const F=await p[M(0x19e)](M(0x19f)+qi(u['value'])+M(0x1a0)+qi(u['text'])+M(0x1a1)+qt(u[M(0x1a2)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(u[M(0x1a3)])+'\x20=\x20ANY($1)',[w]);for(const B of F['rows']){Y['set'](String(B['id']),B);}for(const K of w){!Y['has'](String(K))&&Y['set'](String(K),null);}}for(const g of d){const s=g[u['field']];g[u['field']+'_data']=s==null?null:Y['get'](String(s))??null;}}return d;}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Implements the create relation operation of the generic Resource CRUD engine.
3
+ */
4
+ import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
5
+ import type { ResourceRegistry } from "../resource.registry.js";
6
+ import { AppContext } from "../../../context.js";
7
+ type CreateRelationParams = {
8
+ name: string;
9
+ id: string | number;
10
+ relation: string;
11
+ data?: Record<string, unknown>;
12
+ user?: ResourceUser;
13
+ };
14
+ export declare function createCreateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, data, user, }: CreateRelationParams, ctx?: AppContext) => Promise<any>;
15
+ export {};
16
+ //# sourceMappingURL=create-relation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yCAIgD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,GAAG,CAAC,CAqEhI"}
@@ -0,0 +1 @@
1
+ import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';import{createCreate}from'./create.js';function S(d,h){d=d-0xb4;const p=v();let Z=p[d];return Z;}function v(){const q=['INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\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\x20RETURNING\x20*','get','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','resource','length','No\x20writable\x20fields','map','INSERT\x20INTO\x20','rows','table'];v=function(){return q;};return v();}export function createCreateRelation(d,h){const p=createCreate(d,h);return async function Z({name:D,id:u,relation:n,data:X,user:Y},w){const c=S,y=w?.['pg']??d['pg'];if(n==='notes'){const g=await y['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[D,String(u),X?.['body']]);return g['rows'][0x0];}if(n==='files'){const s=await y['query'](c(0xb4),[D,String(u),X?.['filePath'],X?.['size']??null]);return s['rows'][0x0];}const Q=h[c(0xb5)](D),F=Q['relations']?.[n];if(!F?.['foreignKey']||!F['resource']&&!F['table'])throw new UnsupportedError(c(0xb6)+n+c(0xb7));let B,K;if(F['resource'])B=await p({'name':F['resource'],'data':X??{},'user':Y}),K=B[h['get'](F[c(0xb8)])['key']];else{const M=F['fields'];if(!M?.['length'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+n+'\x22\x20requires\x20a\x20project/provider\x20implementation');const O=Object['entries'](X??{})['filter'](([I])=>M['includes'](I));if(!O[c(0xb9)])throw new ValidationError(c(0xba));const R=O['map'](([I])=>qi(I)),E=O[c(0xbb)]((I,k)=>'$'+(k+0x1)),J=O['map'](([,I])=>I),U=await y['query'](c(0xbc)+qt(F['table'])+'\x20('+R['join'](',\x20')+')\x20VALUES\x20('+E['join'](',\x20')+')\x20RETURNING\x20*',J);B=U[c(0xbd)][0x0],K=B['id'];}return await y['query']('UPDATE\x20'+qt(Q[c(0xbe)])+'\x20SET\x20'+qi(F['foreignKey'])+'\x20=\x20$1\x20WHERE\x20'+qi(Q['key'])+'\x20=\x20$2',[K,u]),B;};}
@@ -1,8 +1,11 @@
1
1
  import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
2
2
  import type { ResourceRegistry } from "../resource.registry.js";
3
- export declare function createCreate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, data, user, }: {
3
+ import { AppContext } from "../../../context.js";
4
+ type CreateParams = {
4
5
  name: string;
5
6
  data: Record<string, unknown>;
6
7
  user?: ResourceUser;
7
- }) => Promise<Record<string, unknown>>;
8
+ };
9
+ export declare function createCreate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, data, user, }: CreateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
10
+ export {};
8
11
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA8CrC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAE0B,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqCtH"}
@@ -1 +1 @@
1
- function I(){const P=['1198731zQfWSy','key','ofBzJ','CGvfE','4ZicMnk','2853430CGVIIE','318934AeXLPd','length','module','XspVl','Required\x20field:\x20','INSERT\x20INTO\x20','join','map','query','oCVXv','30MvIBKn','908272iBbJSq','61UqnAZM','961915ftLqRb','NrqLi','create','8546YgUKUE','entries','rows','No\x20writable\x20fields','RETURNING\x20','audit','get','iAMBG','fields','empty\x20pg','kDEDv','jnNXy','table','VALUES\x20(','name','4088337BASlMl','keys','9drxUjj','xVZlf','write','required','writable'];I=function(){return P;};return I();}function b(n,a){n=n-0x69;const E=I();let M=E[n];return M;}(function(n,a){const k=b,E=n();while(!![]){try{const M=parseInt(k(0x6d))/0x1*(-parseInt(k(0x71))/0x2)+parseInt(k(0x87))/0x3+-parseInt(k(0x8b))/0x4*(parseInt(k(0x6e))/0x5)+parseInt(k(0x6b))/0x6*(parseInt(k(0x8d))/0x7)+parseInt(k(0x6c))/0x8+-parseInt(k(0x82))/0x9*(-parseInt(k(0x8c))/0xa)+-parseInt(k(0x80))/0xb;if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0x31359));import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';export function createCreate(n,a){const p=b,E={'CGvfE':function(M,X,G,j){return M(X,G,j);},'ofBzJ':p(0x70),'iAMBG':function(M,X){return M===X;},'jnNXy':function(M,X,G){return M(X,G);},'kDEDv':p(0x74),'xVZlf':p(0x7a),'oCVXv':function(M,X){return M+X;},'XspVl':function(M,X){return M+X;},'NrqLi':function(M,X){return M(X);}};return async function M({name:X,data:G,user:j}){const l=p,u=a[l(0x77)](X);E[l(0x8a)](assertOperation,u,E[l(0x89)],j);for(const [t,B]of Object[l(0x72)](u[l(0x79)])){if(B[l(0x85)]&&B[l(0x86)]!==![]&&E[l(0x78)](G[t],undefined))throw new ValidationError(l(0x91)+t);}const Y=E[l(0x7c)](writableData,u,G);if(!Y[l(0x8e)])throw new ValidationError(E[l(0x7b)]);const g=Y[l(0x94)](([A])=>qi(A)),e=Y[l(0x94)]((A,r)=>'$'+(r+0x1)),h=Y[l(0x94)](([,A])=>A);if(!n['pg'])throw new Error(E[l(0x83)]);const Z=await n['pg'][l(0x69)](E[l(0x6a)](E[l(0x90)](l(0x92)+E[l(0x6f)](qt,u[l(0x7d)])+'\x20('+g[l(0x93)](',\x20')+')\x20',l(0x7e)+e[l(0x93)](',\x20')+')\x20'),l(0x75)+E[l(0x6f)](readableFields,u)[l(0x93)](',\x20')),h),H=Z[l(0x73)][0x0];return await n[l(0x76)]?.[l(0x84)]({'userId':j?.['id'],'module':u[l(0x8f)],'resource':u[l(0x7f)],'resourceId':H[u[l(0x88)]],'action':l(0x70),'fields':Object[l(0x81)](G)}),H;};}
1
+ function S(d,h){d=d-0x1ec;const p=v();let Z=p[d];return Z;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(d,h){return async function p({name:Z,data:D,user:u},n){const M=S,X=h['get'](Z);assertOperation(X,'create',u),validateInputData({'resource':X,'data':D});const Y=writableData(X,D);if(!Y[M(0x1ec)])throw new ValidationError('No\x20writable\x20fields');const w=Y['map'](([g])=>qi(g)),y=Y['map']((g,s)=>'$'+(s+0x1)),Q=Y['map'](([,g])=>g),F=n?.['pg']??d['pg'],B=await F['query']('INSERT\x20INTO\x20'+qt(X['table'])+'\x20('+w[M(0x1ed)](',\x20')+')\x20'+('VALUES\x20('+y['join'](',\x20')+')\x20')+(M(0x1ee)+readableFields(X)[M(0x1ed)](',\x20')),Q),K=B['rows'][0x0];return clearTableLookupCache(X[M(0x1ef)],F),await(n?.['audit']??d['audit'])?.[M(0x1f0)]({'userId':u?.['id'],'module':X[M(0x1f1)],'resource':X[M(0x1f2)],'resourceId':K[X['key']],'action':M(0x1f3),'fields':Object['keys'](D)}),K;};}function v(){const O=['length','join','RETURNING\x20','table','write','module','name','create'];v=function(){return O;};return v();}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Implements the delete relation operation of the generic Resource CRUD engine.
3
+ */
4
+ import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
5
+ import type { ResourceRegistry } from "../resource.registry.js";
6
+ import type { AppContext } from "../../../context.js";
7
+ type DeleteRelationParams = {
8
+ name: string;
9
+ id: string | number;
10
+ relation: string;
11
+ relationId: string | number;
12
+ user?: ResourceUser;
13
+ };
14
+ export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, user, }: DeleteRelationParams, ctx?: AppContext) => Promise<{
15
+ success: boolean;
16
+ }>;
17
+ export {};
18
+ //# sourceMappingURL=delete-relation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+CAEsD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAwBvJ"}
@@ -0,0 +1 @@
1
+ function S(d,h){d=d-0x19c;const p=v();let Z=p[d];return Z;}import{UnsupportedError}from'../../../errors.js';function v(){const Q=['DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','files','DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','Generic\x20Resource\x20relation\x20\x22'];v=function(){return Q;};return v();}export function createDeleteRelation(d,h){return async function p({name:Z,id:D,relation:u,relationId:n,user:X},Y){const y=S,w=Y?.['pg']??d['pg'];if(u==='notes')return await w['query'](y(0x19c),[n,Z,String(D)]),{'success':!![]};if(u===y(0x19d))return await w['query'](y(0x19e),[n,Z,String(D)]),{'success':!![]};throw new UnsupportedError(y(0x19f)+u+'\x22\x20requires\x20a\x20project/provider\x20implementation');};}
@@ -3,9 +3,12 @@
3
3
  */
4
4
  import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
5
5
  import type { ResourceRegistry } from "../resource.registry.js";
6
- export declare function createRemove(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
6
+ import { AppContext } from "../../../context.js";
7
+ type RemoveParams = {
7
8
  name: string;
8
9
  id: string | number;
9
10
  user?: ResourceUser;
10
- }) => Promise<boolean>;
11
+ };
12
+ export declare function createRemove(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: RemoveParams, ctx?: AppContext) => Promise<boolean>;
13
+ export {};
11
14
  //# sourceMappingURL=delete.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,sBAuBF"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAEwB,YAAY,QAAQ,UAAU,sBAyBjF"}
@@ -1 +1 @@
1
- (function(n,a){const g=b,E=n();while(!![]){try{const M=-parseInt(g(0xb9))/0x1*(-parseInt(g(0xc1))/0x2)+parseInt(g(0xa8))/0x3+parseInt(g(0xac))/0x4+parseInt(g(0xc0))/0x5*(-parseInt(g(0xad))/0x6)+parseInt(g(0xb0))/0x7+parseInt(g(0xbd))/0x8+-parseInt(g(0xb7))/0x9;if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0x7831b));import{assertOperation}from'../utils/permissions.js';function b(n,a){n=n-0xa7;const E=I();let M=E[n];return M;}import{qt,qi}from'../utils/sql.js';export function createRemove(n,a){const e=b,E={'eOBrT':function(M,X,G,j){return M(X,G,j);},'KPNKG':e(0xba),'BiXtK':function(M,X){return M(X);},'TDIOb':function(M,X){return M>X;},'TGdQc':e(0xae)};return async function M({name:X,id:G,user:j}){const h=e,u=a[h(0xc2)](X);E[h(0xb2)](assertOperation,u,h(0xae),j);if(!n['pg'])throw new Error(E[h(0xaa)]);const Y=await n['pg'][h(0xbf)](h(0xb5)+E[h(0xb1)](qt,u[h(0xaf)])+h(0xbe)+qi(u[h(0xab)])+h(0xbc),[G]);if(E[h(0xb6)](Y[h(0xb3)]??0x0,0x0))await n[h(0xb4)]?.[h(0xa9)]({'module':u[h(0xb8)],'resource':u[h(0xbb)],'resourceId':G,'action':E[h(0xa7)]});return E[h(0xb6)](Y[h(0xb3)]??0x0,0x0);};}function I(){const Z=['5LtkBIu','3880JwLRxM','get','TGdQc','1750053XifZNw','write','KPNKG','key','2806980WCjKqO','1904424sSjVVW','delete','table','1869133QZOpDP','BiXtK','eOBrT','rowCount','audit','DELETE\x20FROM\x20','TDIOb','10023354VJPlsh','module','133idsOoE','empty\x20pg','name','=$1','906320zcGqYT','\x20WHERE\x20','query'];I=function(){return Z;};return I();}
1
+ import{assertOperation}from'../utils/permissions.js';function S(d,h){d=d-0x9f;const p=v();let Z=p[d];return Z;}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(d,h){return async function p({name:Z,id:D,user:u},n){const y=S,X=h['get'](Z);assertOperation(X,y(0x9f),u);const Y=n?.['pg']??d['pg'],w=await Y['query']('DELETE\x20FROM\x20'+qt(X[y(0xa0)])+'\x20WHERE\x20'+qi(X['key'])+y(0xa1),[D]);if((w[y(0xa2)]??0x0)>0x0)clearTableLookupCache(X['table'],Y);if((w['rowCount']??0x0)>0x0)await(n?.['audit']??d[y(0xa3)])?.['write']({'module':X['module'],'resource':X['name'],'resourceId':D,'action':'delete'});return(w['rowCount']??0x0)>0x0;};}function v(){const Q=['delete','table','=$1','rowCount','audit'];v=function(){return Q;};return v();}
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Implements the find one operation of the generic Resource CRUD engine.
3
3
  */
4
- import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
4
+ import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
5
5
  import type { ResourceRegistry } from "../resource.registry.js";
6
- export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
6
+ export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, query, user, }: {
7
7
  name: string;
8
8
  id: string | number;
9
+ query?: ResourceQuery;
9
10
  user?: ResourceUser;
10
11
  }) => Promise<Record<string, unknown> | null>;
11
12
  //# sourceMappingURL=find-one.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAiBF"}
1
+ {"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAsDF"}
@@ -1 +1 @@
1
- (function(n,a){const g=b,E=n();while(!![]){try{const M=-parseInt(g(0x1c1))/0x1*(-parseInt(g(0x1bd))/0x2)+-parseInt(g(0x1d0))/0x3+-parseInt(g(0x1c6))/0x4+parseInt(g(0x1bf))/0x5*(parseInt(g(0x1be))/0x6)+-parseInt(g(0x1d1))/0x7+-parseInt(g(0x1d2))/0x8*(-parseInt(g(0x1cf))/0x9)+parseInt(g(0x1cb))/0xa;if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0x517db));function b(n,a){n=n-0x1bd;const E=I();let M=E[n];return M;}import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';function I(){const Z=['bCsRw','query','2lIrCNL','6ZTStBV','756685uJHUjn','join','593953EfGxAF','sTMMn','XhRHf','read','empty\x20pg','1730408GSARxG','get','UoIZg','=$1\x20LIMIT\x201','table','1412110hkCvuv','SELECT\x20','rows','key','186453aAdhiS','899505rFozlr','1207262UvmBWj','136aCZUCd','\x20WHERE\x20','KMQPf','\x20FROM\x20'];I=function(){return Z;};return I();}export function createFindOne(n,a){const e=b,E={'UoIZg':function(M,X,G,j){return M(X,G,j);},'KMQPf':e(0x1c4),'sTMMn':e(0x1c5),'XhRHf':function(M,X){return M(X);},'bCsRw':function(M,X){return M(X);}};return async function M({name:X,id:G,user:j}){const h=e,u=a[h(0x1c7)](X);E[h(0x1c8)](assertOperation,u,E[h(0x1d4)],j);if(!n['pg'])throw new Error(E[h(0x1c2)]);const Y=await n['pg'][h(0x1d7)](h(0x1cc)+readableFields(u)[h(0x1c0)](',\x20')+h(0x1d5)+E[h(0x1c3)](qt,u[h(0x1ca)])+h(0x1d3)+E[h(0x1d6)](qi,u[h(0x1ce)])+h(0x1c9),[G]);return Y[h(0x1cd)][0x0]??null;};}
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(d,h){return async function p({name:Z,id:D,query:query={},user:u}){const R=S,n=Date['now'](),X=h['get'](Z);assertOperation(X,'read',u);if(!d['pg'])throw new Error('empty\x20pg');const Y=await d['pg']['query'](R(0x1cb)+readableFields(X)['join'](',\x20')+R(0x1cc)+qt(X[R(0x1cd)])+'\x20WHERE\x20'+qi(X['key'])+'=$1\x20LIMIT\x201',[D]),w=Y['rows'][0x0];if(!w)return null;await addDictionaryLookupData([w],X['fields'],d[R(0x1ce)]),await addTableLookupData([w],X['fields'],d['pg']),addFileToken([w],X[R(0x1cf)],d['file']);const y=Array['isArray'](query['include'])?query['include']:query['include']?.[R(0x1d0)](',')??[];for(const Q of y){const F=X[R(0x1d1)]?.[Q];if(!F?.['foreignKey']||!F['resource']&&!F[R(0x1cd)])throw new ValidationError('Unknown\x20relation:\x20'+Q);const B=F['resource']?h['get'](F['resource']):undefined,K=F['table']??B[R(0x1cd)],g=B?.['key']??'id',s=B?readableFields(B)['join'](',\x20'):'*',M='SELECT\x20'+s+R(0x1cc)+qt(K)+'\x20WHERE\x20'+qi(g)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(F[R(0x1d2)])+'\x20FROM\x20'+qt(X[R(0x1cd)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(X['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',O=(await d['pg']['query'](M,[D]))['rows'];B&&(await addDictionaryLookupData(O,B['fields'],d[R(0x1ce)]),await addTableLookupData(O,B['fields'],d['pg']),addFileToken(O,B[R(0x1cf)],d['file'])),w[Q]=O;}return w['time']=Date['now']()-n,w;};}function S(d,h){d=d-0x1cb;const p=v();let Z=p[d];return Z;}function v(){const E=['SELECT\x20','\x20FROM\x20','table','dictionary','fields','split','relations','foreignKey'];v=function(){return E;};return v();}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Implements the find relation operation of the generic Resource CRUD engine.
3
+ */
4
+ import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
5
+ import type { ResourceRegistry } from "../resource.registry.js";
6
+ export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, query, }: {
7
+ name: string;
8
+ id: string | number;
9
+ relation: string;
10
+ query?: ResourceQuery;
11
+ user?: ResourceUser;
12
+ }) => Promise<any>;
13
+ //# sourceMappingURL=find-relation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAyEjB"}
@@ -0,0 +1 @@
1
+ import{UnsupportedError,ValidationError}from'../../../errors.js';function v(){const E=['max','SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','length','now','rows','file','get','resource','table','key','map','\x20WHERE\x20\x0a\x20\x20\x20\x20','\x20FROM\x20','\x20WHERE\x20','\x20=\x20$1\x20LIMIT\x201)\x20\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3','query','dictionary','fields'];v=function(){return E;};return v();}function S(d,h){d=d-0xe0;const p=v();let Z=p[d];return Z;}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindRelation(d,h){return async function p({name:Z,id:D,relation:u,query:query={}}){const R=S,n=Date['now'](),X=Math['min'](Math[R(0xe0)](query['limit']??0x14,0x1),0xc8),Y=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](X)||!Number['isFinite'](Y))throw new ValidationError('Invalid\x20pagination');if(u==='notes'){const M=await d['pg']['query'](R(0xe1),[Z,String(D)]);return{'total':M['rows'][R(0xe2)],'time':Date[R(0xe3)]()-n,'rows':M[R(0xe4)]};}if(u==='files'){const O=await d['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[Z,String(D)]);return addFileToken(O['rows'],{'file_path':{'type':R(0xe5)}},d['file']),{'total':O[R(0xe4)][R(0xe2)],'time':Date['now']()-n,'rows':O[R(0xe4)]};}const w=h[R(0xe6)](Z),y=w['relations']?.[u];if(!y?.['foreignKey']||!y['resource']&&!y['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+u+'\x22\x20requires\x20a\x20project/provider\x20implementation');const Q=y['resource']?h[R(0xe6)](y[R(0xe7)]):undefined,F=y[R(0xe8)]??Q['table'],B=Q?.[R(0xe9)]??'id',K=y['fields']?.[R(0xe2)]?y['fields'][R(0xea)](qi)['join'](',\x20'):'*',g='SELECT\x20'+K+'\x20FROM\x20'+qt(F)+R(0xeb)+qi(B)+'\x20=\x20(select\x20'+qi(y['foreignKey'])+R(0xec)+qt(w['table'])+R(0xed)+qi(w['key'])+R(0xee),s=await d['pg'][R(0xef)](g,[D,X,Y]);return Q&&(await addDictionaryLookupData(s['rows'],Q['fields'],d[R(0xf0)]),await addTableLookupData(s[R(0xe4)],Q[R(0xf1)],d['pg']),addFileToken(s[R(0xe4)],Q['fields'],d['file'])),{'limit':X,'offset':Y,'total':s[R(0xe4)]['length'],'time':Date['now']()-n,'rows':s['rows']??null};};}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAiChC"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAsChC"}
@@ -1 +1 @@
1
- (function(n,a){const t=b,E=n();while(!![]){try{const M=parseInt(t(0x1c2))/0x1*(-parseInt(t(0x1ca))/0x2)+parseInt(t(0x1a9))/0x3+parseInt(t(0x1bb))/0x4+-parseInt(t(0x1b3))/0x5+parseInt(t(0x1b6))/0x6+-parseInt(t(0x1c5))/0x7*(-parseInt(t(0x1b0))/0x8)+-parseInt(t(0x1bd))/0x9*(parseInt(t(0x1ac))/0xa);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0xa7134));function b(n,a){n=n-0x1a4;const E=I();let M=E[n];return M;}import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';export function createFind(n,a){const B=b,E={'LvWRy':function(M,X,G){return M(X,G);},'QEPGy':B(0x1ba),'RsoxC':function(M,X){return M+X;},'SgBPS':function(M,X){return M+X;},'GCmSu':function(M,X){return M+X;},'mjIxU':function(M,X){return M(X);},'DKHDQ':B(0x1bc)};return async function M({name:X,query:query={},user:G}){const A=B,j=a[A(0x1c0)](X);assertOperation(j,A(0x1aa),G);const u=Math[A(0x1ab)](Math[A(0x1ae)](query[A(0x1a6)]??0x14,0x1),0xc8),Y=Math[A(0x1ae)](query[A(0x1be)]??0x0,0x0),g=E[A(0x1c6)](buildFilters,j,query[A(0x1b7)]),e=E[A(0x1c6)](buildSort,j,query[A(0x1a7)]);if(!Number[A(0x1bf)](u)||!Number[A(0x1bf)](Y))throw new ValidationError(E[A(0x1b5)]);const h=E[A(0x1b9)](E[A(0x1b2)](E[A(0x1af)](A(0x1a5)+E[A(0x1b8)](readableFields,j)[A(0x1a8)](',\x20')+'\x20',A(0x1c4)+E[A(0x1b8)](qt,j[A(0x1ad)])),''+g[A(0x1c9)]+e+'\x20')+(A(0x1b4)+E[A(0x1b2)](g[A(0x1c1)][A(0x1c8)],0x1)+'\x20'),A(0x1b1)+(g[A(0x1c1)][A(0x1c8)]+0x2));if(!n['pg'])throw new Error(E[A(0x1a4)]);const Z=await n['pg'][A(0x1c7)](h,[...g[A(0x1c1)],u,Y]),H={};return H[A(0x1c3)]=Z[A(0x1c3)],H[A(0x1a6)]=u,H[A(0x1be)]=Y,H;};}function I(){const r=['LIMIT\x20$','QEPGy','4088388CQQnDs','filter','mjIxU','RsoxC','Invalid\x20pagination','4330124VtGuMV','empty\x20pg','1363977PTNYAs','offset','isFinite','get','values','25jJNiWP','rows','FROM\x20','24703JmYygX','LvWRy','query','length','sql','55646sxRsZJ','DKHDQ','SELECT\x20','limit','sort','join','2311182smTfwr','read','min','10TaGgcO','table','max','GCmSu','8ACycxr','OFFSET\x20$','SgBPS','5031920DNckjx'];I=function(){return r;};return I();}
1
+ import{ValidationError}from'../../../errors.js';function v(){const g=['min','max','filter','isFinite','SELECT\x20','sql','length','query','dictionary','rowCount'];v=function(){return g;};return v();}import{buildFilters}from'../utils/filters.js';function S(d,h){d=d-0x100;const p=v();let Z=p[d];return Z;}import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFind(d,h){return async function p({name:Z,query:query={},user:D}){const K=S,u=Date['now'](),n=h['get'](Z);assertOperation(n,'read',D);const X=Math[K(0x100)](Math['max'](query['limit']??0x14,0x1),0xc8),Y=Math[K(0x101)](query['offset']??0x0,0x0),w=buildFilters(n,query[K(0x102)],0x1,d['pg']),y=buildSort(n,query['sort']);if(!Number[K(0x103)](X)||!Number['isFinite'](Y))throw new ValidationError('Invalid\x20pagination');const Q=K(0x104)+readableFields(n)['join'](',\x20')+'\x20'+('FROM\x20'+qt(n['table']))+(''+w[K(0x105)]+y+'\x20')+('LIMIT\x20$'+(w['values'][K(0x106)]+0x1)+'\x20')+('OFFSET\x20$'+(w['values']['length']+0x2)),F=await d['pg'][K(0x107)](Q,[...w['values'],X,Y]),B=F['rows'];return await addDictionaryLookupData(B,n['fields'],d[K(0x108)]),await addTableLookupData(B,n['fields'],d['pg']),addFileToken(B,n['fields'],d['file']),{'limit':X,'offset':Y,'total':F[K(0x109)],'time':Date['now']()-u,'rows':B};};}
@@ -0,0 +1,14 @@
1
+ import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
2
+ import type { ResourceRegistry } from "../resource.registry.js";
3
+ import type { AppContext } from "../../../context.js";
4
+ type UpdateRelationParams = {
5
+ name: string;
6
+ id: string | number;
7
+ relation: string;
8
+ relationId: string | number;
9
+ data: Record<string, unknown>;
10
+ user?: ResourceUser;
11
+ };
12
+ export declare function createUpdateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, data, user, }: UpdateRelationParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
13
+ export {};
14
+ //# sourceMappingURL=update-relation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update-relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,qDAI4D,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAUlK"}
@@ -0,0 +1 @@
1
+ function v(){const K=['foreignKey','Relation\x20update\x20is\x20not\x20configured:\x20','resource'];v=function(){return K;};return v();}import{UnsupportedError}from'../../../errors.js';function S(d,h){d=d-0x1b5;const p=v();let Z=p[d];return Z;}import{createUpdate}from'./update.js';export function createUpdateRelation(d,h){const p=createUpdate(d,h);return async function Z({name:D,id:u,relation:n,relationId:X,data:Y,user:w},y){const B=S,Q=h['get'](D),F=Q['relations']?.[n];if(!F?.['resource']||!F[B(0x1b5)])throw new UnsupportedError(B(0x1b6)+n);return p({'name':F[B(0x1b7)],'id':X,'data':Y,'user':w},y);};}
@@ -1,9 +1,12 @@
1
1
  import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
2
2
  import type { ResourceRegistry } from "../resource.registry.js";
3
- export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, }: {
3
+ import { AppContext } from "../../../context.js";
4
+ type UpdateParams = {
4
5
  name: string;
5
6
  id: string | number;
6
7
  data: Record<string, unknown>;
7
8
  user?: ResourceUser;
8
- }) => Promise<Record<string, unknown>>;
9
+ };
10
+ export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, }: UpdateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
11
+ export {};
9
12
  //# sourceMappingURL=update.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+BAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyCrC"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+BAE8B,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA4C1H"}
@@ -1 +1 @@
1
- (function(n,a){const A=b,E=n();while(!![]){try{const M=parseInt(A(0x170))/0x1+parseInt(A(0x184))/0x2*(parseInt(A(0x160))/0x3)+-parseInt(A(0x16c))/0x4+-parseInt(A(0x16e))/0x5+parseInt(A(0x185))/0x6*(parseInt(A(0x16b))/0x7)+parseInt(A(0x179))/0x8+parseInt(A(0x172))/0x9*(-parseInt(A(0x178))/0xa);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0xb3a65));function I(){const p=['3962890xZifvc','7382160JVVfQO','name','map','audit','update','SET\x20','BobIx','WHERE\x20','UPDATE\x20','gfWZd','RETURNING\x20','62RoOKdA','6gLtoDZ','67434bRdTdl','key','JLaFV','YBfIw','PpLxI','query','tuuep','write','\x20=\x20$','table','join','6492276lHfVEN','2270248YaNDkX','keys','3348330gQKNME','FMafc','1407462QGCMfn','module','45VLZwsi','empty\x20pg','length','rows','get','No\x20writable\x20fields'];I=function(){return p;};return I();}import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function b(n,a){n=n-0x160;const E=I();let M=E[n];return M;}import{qi,qt,readableFields,writableData}from'../utils/sql.js';export function createUpdate(n,a){const r=b,E={'YBfIw':function(M,X,G,j){return M(X,G,j);},'gfWZd':r(0x17d),'tuuep':function(M,X,G){return M(X,G);},'PpLxI':r(0x177),'FMafc':function(M,X){return M+X;},'BobIx':function(M,X){return M(X);},'JLaFV':function(M,X){return M(X);}};return async function M({name:X,id:G,data:j,user:u}){const k=r,Y=a[k(0x176)](X);E[k(0x163)](assertOperation,Y,E[k(0x182)],u);const g=E[k(0x166)](writableData,Y,j);if(!g[k(0x174)])throw new ValidationError(E[k(0x164)]);if(!n['pg'])throw new Error(k(0x173));const e=g[k(0x17b)](([t],B)=>qi(t)+k(0x168)+(B+0x1)),h=[...g[k(0x17b)](([,t])=>t),G],Z=await n['pg'][k(0x165)](E[k(0x16f)](E[k(0x16f)](E[k(0x16f)](k(0x181)+E[k(0x17f)](qt,Y[k(0x169)])+'\x20',k(0x17e)+e[k(0x16a)](',\x20')+'\x20'),k(0x180)+qi(Y[k(0x161)])+k(0x168)+(g[k(0x174)]+0x1)+'\x20'),k(0x183)+E[k(0x162)](readableFields,Y)[k(0x16a)](',\x20')),h),H=Z[k(0x175)][0x0];if(!H)throw new NotFoundError(X+':'+G);return await n[k(0x17c)]?.[k(0x167)]({'userId':u?.['id'],'module':Y[k(0x171)],'resource':Y[k(0x17a)],'resourceId':G,'action':E[k(0x182)],'fields':Object[k(0x16d)](j)}),H;};}
1
+ import{NotFoundError,ValidationError}from'../../../errors.js';function v(){const O=['length','map','SET\x20','RETURNING\x20','rows','table','write','module','name','update'];v=function(){return O;};return v();}function S(d,h){d=d-0x1aa;const p=v();let Z=p[d];return Z;}import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(d,h){return async function p({name:Z,id:D,data:u,user:n},X){const M=S,Y=h['get'](Z);assertOperation(Y,'update',n);const w=writableData(Y,u);if(!w[M(0x1aa)])throw new ValidationError('No\x20writable\x20fields');const y=X?.['pg']??d['pg'];validateInputData({'resource':Y,'data':u,'update':!![]}),delete u['user_type'];const Q=w[M(0x1ab)](([g],s)=>qi(g)+'\x20=\x20$'+(s+0x1)),F=[...w[M(0x1ab)](([,g])=>g),D],B=await y['query']('UPDATE\x20'+qt(Y['table'])+'\x20'+(M(0x1ac)+Q['join'](',\x20')+'\x20')+('WHERE\x20'+qi(Y['key'])+'\x20=\x20$'+(w['length']+0x1)+'\x20')+(M(0x1ad)+readableFields(Y)['join'](',\x20')),F),K=B[M(0x1ae)][0x0];if(!K)throw new NotFoundError(Z+':'+D);return clearTableLookupCache(Y[M(0x1af)],y),await(X?.['audit']??d['audit'])?.[M(0x1b0)]({'userId':n?.['id'],'module':Y[M(0x1b1)],'resource':Y[M(0x1b2)],'resourceId':D,'action':M(0x1b3),'fields':Object['keys'](u)}),K;};}
@@ -0,0 +1,4 @@
1
+ import type { DatabaseAdapter } from "../../pg.js";
2
+ export type AutoIndexType = "text" | "btree" | "gist";
3
+ export declare function autoIndex(table: string, column: string, type: AutoIndexType | undefined, pg: DatabaseAdapter): void;
4
+ //# sourceMappingURL=auto-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/auto-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAItD,wBAAgB,SAAS,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,YAAU,EAC7B,EAAE,EAAE,eAAe,GACpB,IAAI,CAWN"}
@@ -0,0 +1 @@
1
+ import{qi,qt}from'./sql.js';function S(d,h){d=d-0x11c;const p=v();let Z=p[d];return Z;}const requestedIndexes=new WeakMap();function v(){const y=['get','set','has','split','public','replace','rowCount','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20',')\x20text_pattern_ops)','\x20USING\x20'];v=function(){return y;};return v();}export function autoIndex(d,h,p='btree',Z){const Y=S,D=requestedIndexes[Y(0x11c)](Z)??new Set();requestedIndexes[Y(0x11d)](Z,D);const u=d+':'+h+':'+p;if(D[Y(0x11e)](u))return;D['add'](u),void ensureIndex(d,h,p,Z)['catch'](()=>{D['delete'](u);});}async function ensureIndex(d,h,p,Z){const w=S,D=d[w(0x11f)]('.'),u=D['length']===0x2?D[0x0]:w(0x120),n=(d+'_'+h+'_'+p+'_idx')[w(0x121)](/[^A-Za-z0-9_]/g,'_'),X=await Z['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[u,n]);if(X[w(0x122)])return;if(p==='text'){await Z['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await Z['query'](w(0x123)+qi(n+'_l')+'\x20ON\x20'+qt(d)+'\x20USING\x20btree\x20(lower('+qi(h)+w(0x124)),await Z['query'](w(0x123)+qi(n)+'\x20ON\x20'+qt(d)+'\x20USING\x20gin\x20(lower('+qi(h)+')\x20gin_trgm_ops)');return;}await Z['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(n)+'\x20ON\x20'+qt(d)+w(0x125)+p+'\x20('+qi(h)+')');}
@@ -1,5 +1,12 @@
1
+ import { ResourceContract } from "../resource.types.js";
1
2
  /**
2
3
  * Provides Resource helpers for fields handling.
3
4
  */
4
- export { readableFields, writableData, fieldColumn } from './sql.js';
5
+ export { readableFields, writableData, fieldColumn } from "./sql.js";
6
+ declare const validateInputData: ({ resource, data, update, }: {
7
+ resource: ResourceContract;
8
+ data: Record<string, unknown>;
9
+ update?: boolean;
10
+ }) => void;
11
+ export { validateInputData };
5
12
  //# sourceMappingURL=fields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/fields.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/fields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAErE,QAAA,MAAM,iBAAiB,gCAIpB;IACD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,SA2EA,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1 +1 @@
1
- (function(n,a){var G=b,E=n();while(!![]){try{var M=-parseInt(G(0xe8))/0x1+-parseInt(G(0xe0))/0x2*(parseInt(G(0xe7))/0x3)+-parseInt(G(0xe1))/0x4*(parseInt(G(0xe3))/0x5)+-parseInt(G(0xe5))/0x6*(parseInt(G(0xeb))/0x7)+-parseInt(G(0xe4))/0x8+parseInt(G(0xe6))/0x9*(-parseInt(G(0xea))/0xa)+parseInt(G(0xe2))/0xb*(parseInt(G(0xe9))/0xc);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0x4f879));export{readableFields,writableData,fieldColumn}from'./sql.js';function b(n,a){n=n-0xe0;var E=I();var M=E[n];return M;}function I(){var j=['86379mTdpNP','115036yJyMuk','13632GCDtZp','207880VBICtk','49qQsVqe','20DDhmms','155912iwZPMY','21406gTAdMp','35nQoHIS','4490856EqActx','270108YRWMrW','144WDFlkO'];I=function(){return j;};return I();}
1
+ import{ValidationError}from'../../../errors.js';function S(d,h){d=d-0x163;const p=v();let Z=p[d];return Z;}export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:d,data:h,update:update=![]})=>{const D=S;for(const [p,Z]of Object['entries'](d['fields'])){if(Z['required']&&Z['writable']!==![]&&(h[p]===undefined||h[p]===null)&&!update)throw new ValidationError(D(0x163)+p);if(Z[D(0x164)]&&Z[D(0x165)]!==![]&&Object[D(0x166)](h,p)&&(h[p]===undefined||h[p]===null)&&update)throw new ValidationError('Required\x20field:\x20'+p);if(Z['minLength']&&typeof h[p]==='string'&&h[p][D(0x167)]<Z['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+p);if(Z[D(0x168)]&&typeof h[p]==='string'&&h[p]['length']>Z['maxLength'])throw new ValidationError(D(0x169)+p);if(Z[D(0x16a)]&&typeof h[p]==='number'&&h[p]<Z['minimum'])throw new ValidationError(p+'\x20should\x20be\x20>=\x20'+Z['minimum']);if(Z['maximum']&&typeof h[p]===D(0x16b)&&h[p]>Z[D(0x16c)])throw new ValidationError(p+'\x20should\x20be\x20<=\x20'+Z['maximum']);if(Z['enum']&&h[p]&&!Z['enum'][D(0x16d)](h[p]))throw new ValidationError(p+D(0x16e)+Z['enum']['join'](',\x20')+')');if(Z['pattern']&&typeof h[p]==='string'&&!new RegExp(Z['pattern'])[D(0x16f)](h[p]))throw new ValidationError(p+D(0x170)+Z['pattern']+')');}};function v(){const u=['Required\x20field:\x20','required','writable','hasOwn','length','maxLength','maxLength\x20exceeded:\x20','minimum','number','maximum','includes','\x20should\x20be\x20one\x20of\x20(','test','\x20should\x20match\x20regular\x20expression\x20('];v=function(){return u;};return v();}export{validateInputData};
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Provides Resource helpers for filters handling.
3
3
  */
4
- import type { ResourceContract } from '../resource.types.js';
5
- export declare function buildFilters(resource: ResourceContract, filter: Record<string, unknown> | undefined, start?: number): {
4
+ import type { ResourceContract, ResourceDependencies } from '../resource.types.js';
5
+ export declare function parseFilterQuery(query: Record<string, unknown>): Record<string, unknown> | undefined;
6
+ export declare function buildFilters(resource: ResourceContract, filter: Record<string, unknown> | undefined, start?: number, pg?: ResourceDependencies['pg']): {
6
7
  sql: string;
7
8
  values: unknown[];
8
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAI7D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,KAAK,SAAI;;;EAc9G"}
1
+ {"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AASnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA2BpG;AAED,wBAAgB,YAAY,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,KAAK,SAAI,EACT,EAAE,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC;;;EAgElC"}
@@ -1 +1 @@
1
- (function(n,a){const S=b,E=n();while(!![]){try{const M=-parseInt(S(0x18c))/0x1*(-parseInt(S(0x18b))/0x2)+-parseInt(S(0x175))/0x3*(parseInt(S(0x174))/0x4)+parseInt(S(0x185))/0x5+parseInt(S(0x17b))/0x6*(parseInt(S(0x17d))/0x7)+parseInt(S(0x188))/0x8+parseInt(S(0x18a))/0x9+parseInt(S(0x177))/0xa*(-parseInt(S(0x17e))/0xb);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0xd5aae));import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function b(n,a){n=n-0x173;const E=I();let M=E[n];return M;}export function buildFilters(n,a,E=0x1){const c=b,M={'cDEcv':function(j,u){return j??u;},'YWyuJ':function(j,u){return j!==u;},'jvBoi':function(j,u){return j(u);},'fIsri':function(j,u,Y){return j(u,Y);}},X=[],G=[];for(const [j,u]of Object[c(0x179)](M[c(0x173)](a,{}))){const Y=n[c(0x183)][j];if(!Y||Y[c(0x176)]!==!![]&&M[c(0x186)](Y[c(0x189)],!![]))throw new ValidationError(c(0x178)+j);G[c(0x180)](u),X[c(0x180)](M[c(0x17a)](qi,M[c(0x17c)](fieldColumn,n,j))+c(0x17f)+(E+G[c(0x184)]-0x1));}return{'sql':X[c(0x184)]?c(0x187)+X[c(0x182)](c(0x181)):'','values':G};}function I(){const U=['filter','38583730OFqCQf','Field\x20is\x20not\x20filterable:\x20','entries','jvBoi','18JLUFxH','fIsri','2817003EFnQSn','11XImeTk','\x20=\x20$','push','\x20AND\x20','join','fields','length','4985050yuzaDZ','YWyuJ','\x20WHERE\x20','6785648xJvWCh','filterable','14763132rHYpua','246GniapA','8254lYrshW','cDEcv','216564GlQqfL','54XQnWsB'];I=function(){return U;};return I();}
1
+ const s=S;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';function S(d,h){d=d-0x15d;const p=v();let Z=p[d];return Z;}const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin',s(0x15d),s(0x15e),s(0x15f)]);export function parseFilterQuery(d){const M=s,h={...isRecord(d[M(0x160)])?d['filter']:{}};for(const [p,Z]of Object['entries'](d)){const D=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/[M(0x161)](p);if(!D)continue;const [,u,n]=D;if(!u)continue;if(!n){h[u]=Z;continue;}if(!filterOperators['has'](n))throw new ValidationError(M(0x162)+n);const X=isRecord(h[u])?h[u]:{};X[n]=(n==='in'||n==='nin')&&typeof Z==='string'?Z['split'](','):Z,h[u]=X;}return Object['keys'](h)[M(0x163)]?h:undefined;}export function buildFilters(d,h,p=0x1,Z){const O=s,D=[],u=[];for(const [n,X]of Object['entries'](h??{})){const Y=d['fields'][n];if(!Y||Y['filter']!==!![]&&Y['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+n);const w=qi(fieldColumn(d,n)),y=isRecord(X)?X:{'eq':X};for(const [Q,F]of Object['entries'](y)){if(!filterOperators[O(0x164)](Q))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+Q);if((Q==='like'||Q===O(0x15e))&&Y['type']!==O(0x165)&&Y['type']!==O(0x166))throw new ValidationError('Operator\x20'+Q+'\x20requires\x20a\x20text\x20field:\x20'+n);Z&&autoIndex(d[O(0x167)],fieldColumn(d,n),indexTypeFor(Y[O(0x168)],Q),Z);if(Q==='null'){D['push'](w+'\x20IS\x20'+(isTruthy(F)?'':'NOT\x20')+'NULL');continue;}if(Q==='in'||Q==='nin'){const g=Array[O(0x169)](F)?F:[F];if(g[O(0x163)]===0x0){D['push'](Q==='in'?O(0x16a):O(0x16b));continue;}u[O(0x16c)](g),D[O(0x16c)](w+'\x20'+(Q==='in'?'=\x20ANY':O(0x16d))+'($'+(p+u['length']-0x1)+')');continue;}const B={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':O(0x15d)},K='$'+(p+u[O(0x163)]);if(Q===O(0x15d)){u['push'](F+'%'),D['push']('lower('+w+O(0x16e)+K+')');continue;}u['push'](F),D['push'](w+'\x20'+B[Q]+'\x20'+K);}}return{'sql':D['length']?O(0x16f)+D['join'](O(0x170)):'','values':u};}function v(){const J=['like','ilike','null','filter','exec','Unsupported\x20filter\x20operator:\x20','length','has','string','text','table','type','isArray','FALSE','TRUE','push','<>\x20ALL',')\x20like\x20lower(','\x20WHERE\x20','\x20AND\x20','object','btree'];v=function(){return J;};return v();}function isRecord(d){const R=s;return typeof d===R(0x171)&&d!==null&&!Array[R(0x169)](d);}function isTruthy(d){return d===!![]||d==='true'||d==='1'||d===0x1;}function indexTypeFor(d,h){const E=s;if(h==='like'||h===E(0x15e))return'text';if(d==='geom'||d==='geometry')return'gist';return E(0x172);}
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/permissions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACb,MAAM,sBAAsB,CAAC;AAE9B,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,IAAI,CAAC,EAAE,YAAY,QAiBpB"}
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/permissions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACb,MAAM,sBAAsB,CAAC;AAI9B,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,IAAI,CAAC,EAAE,YAAY,QAqBpB"}
@@ -1 +1 @@
1
- (function(n,a){const O=b,E=n();while(!![]){try{const M=-parseInt(O(0xdc))/0x1+parseInt(O(0xe7))/0x2+parseInt(O(0xeb))/0x3*(parseInt(O(0xe6))/0x4)+parseInt(O(0xf3))/0x5*(-parseInt(O(0xed))/0x6)+parseInt(O(0xdd))/0x7*(-parseInt(O(0xe3))/0x8)+parseInt(O(0xf0))/0x9+-parseInt(O(0xec))/0xa*(-parseInt(O(0xee))/0xb);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0xc724d));function I(){const K=['66190rVpqLZ','access','Authentication\x20required','public','admin','operations','includes','\x20is\x20disabled','664687pJPQHq','2810423CnZRSS','GUKZn','JzMHN','fAWhL','name','klXIa','8pysjRI','Admin\x20access\x20required','type','4NUTxtB','2210316JEDXGJ','permission','KXARt','cHfVv','375042ymQJIl','10vKkNdJ','456bbzdnM','13909874cnaxHH','permissions','3539259qgHpem','Missing\x20permission:\x20','sIyVm'];I=function(){return K;};return I();}function b(n,a){n=n-0xdb;const E=I();let M=E[n];return M;}import{ForbiddenError}from'../../../errors.js';export function assertOperation(a,E,M){const q=b,X={};X[q(0xea)]=function(j,u){return j!==u;},X[q(0xe9)]=q(0xf6),X[q(0xde)]=function(j,u){return j===u;},X[q(0xdf)]=q(0xf5),X[q(0xe0)]=function(j,u){return j===u;},X[q(0xf2)]=q(0xf7),X[q(0xe2)]=q(0xe4);const G=X;if(!a[q(0xf8)][q(0xf9)](E))throw new ForbiddenError(a[q(0xe1)]+'.'+E+q(0xdb));if(G[q(0xea)](a[q(0xf4)],G[q(0xe9)])&&G[q(0xde)](M,undefined))throw new ForbiddenError(G[q(0xdf)]);if(G[q(0xe0)](a[q(0xf4)],G[q(0xf2)])&&M?.[q(0xe5)]!==G[q(0xf2)])throw new ForbiddenError(G[q(0xe2)]);if(G[q(0xea)](M?.[q(0xe5)],q(0xf7))){const j=(a[q(0xe8)]??a[q(0xe1)])+':'+E;if(!M?.[q(0xef)]?.[q(0xf9)](j))throw new ForbiddenError(q(0xf1)+j);}}
1
+ import{ForbiddenError}from'../../../errors.js';function v(){const n=['public','admin'];v=function(){return n;};return v();}import{getContext}from'../../../index.js';function S(d,h){d=d-0xff;const p=v();let Z=p[d];return Z;}export function assertOperation(d,h,p){const u=S,Z=getContext()['config'];if(Z['debug'])return;if(!d['operations']['includes'](h))throw new ForbiddenError(d['name']+'.'+h+'\x20is\x20disabled');if(d['access']!==u(0xff)&&p===undefined)throw new ForbiddenError('Authentication\x20required');if(d['access']==='admin'&&p?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p?.['type']!==u(0x100)){const D=(d['permission']??d['name'])+':'+h;if(!p?.['permissions']?.['includes'](D))throw new ForbiddenError('Missing\x20permission:\x20'+D);}}
@@ -1 +1 @@
1
- {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,UAYpE"}
1
+ {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,UAgBpE"}
@@ -1 +1 @@
1
- (function(n,a){const m=b,E=n();while(!![]){try{const M=parseInt(m(0x14b))/0x1+-parseInt(m(0x147))/0x2+parseInt(m(0x14f))/0x3+-parseInt(m(0x14a))/0x4+parseInt(m(0x144))/0x5+parseInt(m(0x142))/0x6*(parseInt(m(0x14c))/0x7)+parseInt(m(0x158))/0x8*(-parseInt(m(0x156))/0x9);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0x57c8f));function b(n,a){n=n-0x142;const E=I();let M=E[n];return M;}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(n,a){const T=b,E={'qorcx':function(X,G){return X!==G;},'jWQdJ':function(X,G){return X(G);},'dPvwC':function(X,G,j){return X(G,j);}};if(!a?.[T(0x151)])return'';const M=a[T(0x153)](X=>{const y=T,G=X[y(0x14d)]('-'),j=G?X[y(0x159)](0x1):X,u=n[y(0x14e)][j];if(!u||E[y(0x149)](u[y(0x146)],!![])&&E[y(0x149)](u[y(0x148)],!![]))throw new ValidationError(y(0x157)+j);return E[y(0x145)](qi,E[y(0x155)](fieldColumn,n,j))+'\x20'+(G?y(0x150):y(0x154));});return T(0x152)+M[T(0x143)](',\x20');}function I(){const s=['Field\x20is\x20not\x20sortable:\x20','3702328LtQizL','slice','201642EGMwSw','join','3160545CipAaz','jWQdJ','sort','234568kvNKlI','sortable','qorcx','1642072cHnsGs','279974INTucW','14vQADyf','startsWith','fields','1112589iWDbKg','DESC','length','\x20ORDER\x20BY\x20','map','ASC','dPvwC','9JTPRoC'];I=function(){return s;};return I();}
1
+ function S(d,h){d=d-0x1bf;const p=v();let Z=p[d];return Z;}function v(){const w=['length','slice','sort','sortable','Field\x20is\x20not\x20sortable:\x20'];v=function(){return w;};return v();}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(d,h){const X=S;if(!h?.[X(0x1bf)])return'';typeof h==='string'&&(h=[h]);const p=h['map'](Z=>{const Y=X,D=Z['startsWith']('-'),u=D?Z[Y(0x1c0)](0x1):Z,n=d['fields'][u];if(!n||n[Y(0x1c1)]!==!![]&&n[Y(0x1c2)]!==!![])throw new ValidationError(Y(0x1c3)+u);return qi(fieldColumn(d,u))+'\x20'+(D?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+p['join'](',\x20');}
@@ -1 +1 @@
1
- function b(n,a){n=n-0x15a;const E=I();let M=E[n];return M;}const J=b;function I(){const s=['LOuDA','fields','column','4610646TQyizb','filter','read','write','unshift','entries','1784466VxWwng','writable','1777800AOSVYW','74714IiaMMQ','30797jnFmVr','Field\x20is\x20not\x20writable:\x20','39rslQNA','Dvoda','RSGFm','2305264CDcwma','readable','replace','Unknown\x20field:\x20','push','split','11975JoFMff','join','key','\x20AS\x20','7QSQmts','map','400eWkyHZ'];I=function(){return s;};return I();}(function(n,a){const P=b,E=n();while(!![]){try{const M=-parseInt(P(0x162))/0x1+-parseInt(P(0x161))/0x2*(parseInt(P(0x164))/0x3)+-parseInt(P(0x173))/0x4*(-parseInt(P(0x16d))/0x5)+parseInt(P(0x177))/0x6+parseInt(P(0x171))/0x7*(parseInt(P(0x167))/0x8)+-parseInt(P(0x15e))/0x9+-parseInt(P(0x160))/0xa;if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0x62897));import{ValidationError}from'../../../errors.js';export const quoteIdentifier=n=>'\x22'+n[J(0x169)](/"/g,'\x22\x22')+'\x22';export const quoteTable=n=>n[J(0x16c)]('.')[J(0x172)](quoteIdentifier)[J(0x16e)]('.');export function fieldColumn(n,a){const m=J;if(a===n[m(0x16f)])return n[m(0x16f)];const E=n[m(0x175)][a];if(!E)throw new ValidationError(m(0x16a)+a);return E[m(0x176)]??a;}export function readableFields(n){const T=J,a={'LOuDA':function(M,X){return M(X);}},E=Object[T(0x15d)](n[T(0x175)])[T(0x178)](([,M])=>M[T(0x15a)]!==![]&&M[T(0x168)]!==![])[T(0x172)](([M,X])=>quoteIdentifier(X[T(0x176)]??M)+T(0x170)+quoteIdentifier(M));return!n[T(0x175)][n[T(0x16f)]]&&E[T(0x15c)](a[T(0x174)](quoteIdentifier,n[T(0x16f)])),E;}export function writableData(a,E){const y=J,M={};M[y(0x165)]=function(j,u){return j===u;},M[y(0x166)]=function(j,u){return j===u;};const X=M,G=[];for(const [j,u]of Object[y(0x15d)](E)){const Y=a[y(0x175)][j];if(!Y||X[y(0x165)](Y[y(0x15b)],![])||X[y(0x166)](Y[y(0x15f)],![]))throw new ValidationError(y(0x163)+j);G[y(0x16b)]([Y[y(0x176)]??j,u]);}return G;}export const qi=quoteIdentifier;export const qt=quoteTable;
1
+ const n=S;import{ValidationError}from'../../../errors.js';function v(){const y=['replace','Unknown\x20field:\x20','column','fields','\x20AS\x20','writable'];v=function(){return y;};return v();}export const quoteIdentifier=d=>'\x22'+d[n(0x171)](/"/g,'\x22\x22')+'\x22';export const quoteTable=d=>d['split']('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(d,h){const X=n;if(h===d['key'])return d['key'];const p=d['fields'][h];if(!p)throw new ValidationError(X(0x172)+h);return p[X(0x173)]??h;}export function readableFields(d){const Y=n,h=Object['entries'](d[Y(0x174)])['filter'](([,p])=>p['read']!==![]&&p['readable']!==![])['map'](([p,Z])=>quoteIdentifier(Z['column']??p)+Y(0x175)+quoteIdentifier(p));return!d['fields'][d['key']]&&h['unshift'](quoteIdentifier(d['key'])),h;}function S(d,h){d=d-0x171;const p=v();let Z=p[d];return Z;}export function writableData(d,h){const w=n,p=[];for(const [Z,D]of Object['entries'](h)){const u=d[w(0x174)][Z];if(!u||u['write']===![]||u[w(0x176)]===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+Z);p['push']([u[w(0x173)]??Z,D]);}return p;}export const qi=quoteIdentifier;export const qt=quoteTable;
@@ -1 +1 @@
1
- function b(n,a){n=n-0x95;const E=I();let M=E[n];return M;}const j=b;(function(n,a){const G=b,E=n();while(!![]){try{const M=parseInt(G(0xa3))/0x1+-parseInt(G(0xa1))/0x2*(-parseInt(G(0xa5))/0x3)+parseInt(G(0xa0))/0x4*(-parseInt(G(0x99))/0x5)+-parseInt(G(0x95))/0x6*(parseInt(G(0x98))/0x7)+parseInt(G(0x9d))/0x8*(parseInt(G(0xa6))/0x9)+parseInt(G(0x9a))/0xa*(parseInt(G(0x9b))/0xb)+-parseInt(G(0xa8))/0xc*(parseInt(G(0xa4))/0xd);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0xc62fd));function I(){const u=['pop','x-forwarded-for','82047QABZUF','134565epUFPD','10IbdDak','601931fXMUwG','x-real-ip','21448TIvyvH','headers','remoteAddress','12YxDIvk','2uUqBWK','connection','1544730gJigSQ','17074759XCMocw','642822xSYLIS','5094murhGY','split','12UfZfOq','576YvslMw'];I=function(){return u;};return I();}const getIP=n=>(n[j(0x9e)]?.[j(0x9c)]||n[j(0x9e)]?.[j(0x97)]||n['ip']||n[j(0xa2)]?.[j(0x9f)]||'')[j(0xa7)](':')[j(0x96)]();export default getIP;
1
+ function S(d,h){d=d-0x90;const p=v();let Z=p[d];return Z;}const h=S,getIP=d=>(d[h(0x90)]?.['x-real-ip']||d['headers']?.[h(0x91)]||d['ip']||d[h(0x92)]?.['remoteAddress']||'')['split'](':')['pop']();function v(){const p=['headers','x-forwarded-for','connection'];v=function(){return p;};return v();}export default getIP;
package/dist/type.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { FastifySchema } from "fastify";
2
+ /** Рівень доступу до HTTP API-маршруту. */
3
+ export type RouteAccess = "public" | "user" | "admin";
4
+ /** Декларація права у форматі `ресурс:дія`; перевірка прав тимчасово не активна. */
5
+ export type RoutePermission = `${string}:${string}`;
6
+ type AccessMetadata = {
7
+ /** Групи маршруту для OpenAPI/Swagger. */
8
+ tags: string[];
9
+ /** Код пакета, якому належить маршрут. */
10
+ package: string;
11
+ /** Короткий заголовок операції в OpenAPI/Swagger. */
12
+ summary: string;
13
+ /** Розгорнутий опис операції в OpenAPI/Swagger. */
14
+ description: string;
15
+ /** Активний рівень доступу: `public`, `user` або `admin`. */
16
+ access: RouteAccess;
17
+ /** Декларація потрібних прав; їхня runtime-валідація та перевірка тимчасово не активні. */
18
+ permissions: RoutePermission[];
19
+ };
20
+ /** Повна схема Fastify і метадані маршруту API. */
21
+ export type ApiRouteSchema = FastifySchema & AccessMetadata;
22
+ /** Короткий опис зареєстрованого HTTP API-маршруту. */
23
+ export interface ApiRouteShort {
24
+ method: string;
25
+ endpoint: string;
26
+ package: string;
27
+ }
28
+ /** Розширений опис маршруту з OpenAPI та access metadata. */
29
+ export interface ApiRoute extends ApiRouteShort {
30
+ tags: string[];
31
+ summary: string;
32
+ description: string;
33
+ access: RouteAccess;
34
+ permissions: RoutePermission[];
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AACtD,oFAAoF;AACpF,MAAM,MAAM,eAAe,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAGpD,KAAK,cAAc,GAAG;IACpB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,MAAM,EAAE,WAAW,CAAC;IACpB,2FAA2F;IAC3F,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,cAAc,CAAC;AAE5D,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6DAA6D;AAC7D,MAAM,WAAW,QAAS,SAAQ,aAAa;IAC7C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC"}
package/dist/type.js ADDED
@@ -0,0 +1 @@
1
+ export{};