@opengis/fcore 0.0.1-beta.9 → 0.0.28

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 (187) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +71 -71
  3. package/dist/config.d.ts +1 -0
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +1 -1
  6. package/dist/context.js +1 -1
  7. package/dist/errors.js +1 -1
  8. package/dist/fastify.d.ts +0 -3
  9. package/dist/fastify.d.ts.map +1 -1
  10. package/dist/fastify.js +1 -1
  11. package/dist/fcore.d.ts.map +1 -1
  12. package/dist/fcore.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.js +1 -1
  16. package/dist/modules/auth/passwd-cli.js +1 -1
  17. package/dist/modules/auth/permission-cli.js +1 -1
  18. package/dist/modules/auth/route.d.ts.map +1 -1
  19. package/dist/modules/auth/route.js +1 -1
  20. package/dist/modules/auth/schema.js +1 -1
  21. package/dist/modules/auth/services/change-password.js +1 -1
  22. package/dist/modules/auth/services/get-current-user.d.ts +2 -0
  23. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  24. package/dist/modules/auth/services/get-current-user.js +1 -1
  25. package/dist/modules/auth/services/registration.js +1 -1
  26. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  27. package/dist/modules/file/mime.js +1 -1
  28. package/dist/modules/file/route.js +1 -1
  29. package/dist/modules/file/schema.js +1 -1
  30. package/dist/modules/file/services/get-file.js +1 -1
  31. package/dist/modules/file/services/resize-file.js +1 -1
  32. package/dist/modules/file/services/upload-file.d.ts.map +1 -1
  33. package/dist/modules/file/services/upload-file.js +1 -1
  34. package/dist/modules/resource/route.d.ts.map +1 -1
  35. package/dist/modules/resource/route.js +1 -1
  36. package/dist/modules/resource/schema.d.ts +19 -0
  37. package/dist/modules/resource/schema.d.ts.map +1 -1
  38. package/dist/modules/resource/schema.js +1 -1
  39. package/dist/modules/resource/services/add-note.js +1 -1
  40. package/dist/modules/resource/services/add-resource-file.js +1 -1
  41. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  42. package/dist/modules/resource/services/create-resource.js +1 -1
  43. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  44. package/dist/modules/resource/services/delete-resource.js +1 -1
  45. package/dist/modules/resource/services/export-resource.js +1 -1
  46. package/dist/modules/resource/services/generate-resource-code.d.ts +16 -0
  47. package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
  48. package/dist/modules/resource/services/generate-resource-code.js +1 -0
  49. package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
  50. package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
  51. package/dist/modules/resource/services/get-resource-schema.js +1 -0
  52. package/dist/modules/resource/services/get-resource.js +1 -1
  53. package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
  54. package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
  55. package/dist/modules/resource/services/list-resource-as-user.js +1 -0
  56. package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
  57. package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
  58. package/dist/modules/resource/services/list-resource-list.js +1 -0
  59. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  60. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  61. package/dist/modules/resource/services/list-resources.js +1 -1
  62. package/dist/modules/resource/services/search-resource.js +1 -1
  63. package/dist/modules/resource/services/suggest-resource.js +1 -1
  64. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  65. package/dist/modules/resource/services/update-resource.js +1 -1
  66. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  67. package/dist/modules/system/route.d.ts.map +1 -1
  68. package/dist/modules/system/route.js +1 -1
  69. package/dist/modules/system/schema.d.ts +25 -2
  70. package/dist/modules/system/schema.d.ts.map +1 -1
  71. package/dist/modules/system/schema.js +1 -1
  72. package/dist/modules/system/services/check-system.js +1 -1
  73. package/dist/modules/system/services/get-access.d.ts +1 -0
  74. package/dist/modules/system/services/get-access.d.ts.map +1 -1
  75. package/dist/modules/system/services/get-access.js +1 -1
  76. package/dist/modules/system/services/get-api-list.js +1 -1
  77. package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
  78. package/dist/modules/system/services/get-audit-log.js +1 -1
  79. package/dist/modules/system/services/get-dictionary.js +1 -1
  80. package/dist/modules/system/services/get-resource-access.d.ts +23 -0
  81. package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
  82. package/dist/modules/system/services/get-resource-access.js +1 -0
  83. package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
  84. package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
  85. package/dist/modules/system/services/get-resource-scopes.js +1 -0
  86. package/dist/modules/system/services/get-system-log.js +1 -1
  87. package/dist/modules/system/services/get-system-settings.js +1 -1
  88. package/dist/modules/system/services/list-dictionaries.js +1 -1
  89. package/dist/modules/system/services/set-access.d.ts +3 -1
  90. package/dist/modules/system/services/set-access.d.ts.map +1 -1
  91. package/dist/modules/system/services/set-access.js +1 -1
  92. package/dist/modules/system/services/set-resource-access.d.ts +18 -0
  93. package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
  94. package/dist/modules/system/services/set-resource-access.js +1 -0
  95. package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
  96. package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
  97. package/dist/modules/system/services/set-resource-scopes.js +1 -0
  98. package/dist/modules/system/services/update-dictionary.js +1 -1
  99. package/dist/modules/system/services/update-system-settings.js +1 -1
  100. package/dist/modules/utils/require-admin.js +1 -1
  101. package/dist/modules/utils/safe-user.js +1 -1
  102. package/dist/modules/utils/unsupported.js +1 -1
  103. package/dist/plugins/audit/audit.js +1 -1
  104. package/dist/plugins/audit/audit.types.d.ts +1 -1
  105. package/dist/plugins/audit/audit.types.d.ts.map +1 -1
  106. package/dist/plugins/audit/services/write-audit.js +1 -1
  107. package/dist/plugins/auth/get-user-permissions.js +1 -1
  108. package/dist/plugins/auth/index.d.ts.map +1 -1
  109. package/dist/plugins/auth/index.js +1 -1
  110. package/dist/plugins/auth/verifyUser.js +1 -1
  111. package/dist/plugins/dictionary.js +1 -1
  112. package/dist/plugins/file.d.ts +7 -3
  113. package/dist/plugins/file.d.ts.map +1 -1
  114. package/dist/plugins/file.js +1 -1
  115. package/dist/plugins/jwt.js +1 -1
  116. package/dist/plugins/logger/index.js +1 -1
  117. package/dist/plugins/logger/transport.js +1 -1
  118. package/dist/plugins/pg.d.ts +4 -2
  119. package/dist/plugins/pg.d.ts.map +1 -1
  120. package/dist/plugins/pg.js +1 -1
  121. package/dist/plugins/redis.d.ts.map +1 -1
  122. package/dist/plugins/redis.js +1 -1
  123. package/dist/plugins/resource/resource.d.ts +1 -1
  124. package/dist/plugins/resource/resource.d.ts.map +1 -1
  125. package/dist/plugins/resource/resource.js +1 -1
  126. package/dist/plugins/resource/resource.registry.d.ts +3 -2
  127. package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
  128. package/dist/plugins/resource/resource.registry.js +1 -1
  129. package/dist/plugins/resource/resource.types.d.ts +66 -14
  130. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  131. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  132. package/dist/plugins/resource/services/add-file-token.js +1 -1
  133. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  134. package/dist/plugins/resource/services/create-relation.d.ts +5 -2
  135. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
  136. package/dist/plugins/resource/services/create-relation.js +1 -1
  137. package/dist/plugins/resource/services/create.d.ts +5 -2
  138. package/dist/plugins/resource/services/create.d.ts.map +1 -1
  139. package/dist/plugins/resource/services/create.js +1 -1
  140. package/dist/plugins/resource/services/delete-relation.d.ts +6 -3
  141. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
  142. package/dist/plugins/resource/services/delete-relation.js +1 -1
  143. package/dist/plugins/resource/services/delete.d.ts +9 -2
  144. package/dist/plugins/resource/services/delete.d.ts.map +1 -1
  145. package/dist/plugins/resource/services/delete.js +1 -1
  146. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  147. package/dist/plugins/resource/services/find-one.js +1 -1
  148. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
  149. package/dist/plugins/resource/services/find-relation.js +1 -1
  150. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  151. package/dist/plugins/resource/services/find.js +1 -1
  152. package/dist/plugins/resource/services/get-table-columns.d.ts +8 -0
  153. package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
  154. package/dist/plugins/resource/services/get-table-columns.js +1 -0
  155. package/dist/plugins/resource/services/update-relation.d.ts +5 -2
  156. package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
  157. package/dist/plugins/resource/services/update-relation.js +1 -1
  158. package/dist/plugins/resource/services/update.d.ts +9 -2
  159. package/dist/plugins/resource/services/update.d.ts.map +1 -1
  160. package/dist/plugins/resource/services/update.js +1 -1
  161. package/dist/plugins/resource/utils/auto-index.js +1 -1
  162. package/dist/plugins/resource/utils/fields.js +1 -1
  163. package/dist/plugins/resource/utils/filters.d.ts +2 -1
  164. package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
  165. package/dist/plugins/resource/utils/filters.js +1 -1
  166. package/dist/plugins/resource/utils/permissions.js +1 -1
  167. package/dist/plugins/resource/utils/scope.d.ts +10 -0
  168. package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
  169. package/dist/plugins/resource/utils/scope.js +1 -0
  170. package/dist/plugins/resource/utils/sort.d.ts +1 -1
  171. package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
  172. package/dist/plugins/resource/utils/sort.js +1 -1
  173. package/dist/plugins/resource/utils/sql.d.ts +1 -1
  174. package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
  175. package/dist/plugins/resource/utils/sql.js +1 -1
  176. package/dist/plugins/resource/utils/summary.d.ts +7 -0
  177. package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
  178. package/dist/plugins/resource/utils/summary.js +1 -0
  179. package/dist/shared/getIP.js +1 -1
  180. package/migrations/20260903120000_core_schema.sql +5 -2
  181. package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
  182. package/migrations/20260903130001_add_file_fields.sql +5 -0
  183. package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
  184. package/migrations/20260910170000_core_schema.sql +22 -0
  185. package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
  186. package/migrations/20260929_role_scope.sql +32 -0
  187. package/package.json +93 -93
@@ -1,9 +1,16 @@
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
+ where?: {
10
+ column: string;
11
+ value: string | number;
12
+ };
13
+ };
14
+ export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, where, }: UpdateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
15
+ export {};
9
16
  //# 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;AAIhE,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,CA8CrC"}
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;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,sCAEqC,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2DjI"}
@@ -1 +1 @@
1
- import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';function c(J,e){J=J-0x13a;const p=L();let b=p[J];return b;}function L(){const l=['get','query','SET\x20','table','module'];L=function(){return l;};return L();}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(J,e){return async function p({name:b,id:F,data:P,user:h}){const T=c,u=e[T(0x13a)](b);assertOperation(u,'update',h);const H=writableData(u,P);if(!H['length'])throw new ValidationError('No\x20writable\x20fields');if(!J['pg'])throw new Error('empty\x20pg');validateInputData({'resource':u,'data':P,'update':!![]}),delete P['user_type'];const D=H['map'](([E],Q)=>qi(E)+'\x20=\x20$'+(Q+0x1)),U=[...H['map'](([,E])=>E),F],w=await J['pg'][T(0x13b)]('UPDATE\x20'+qt(u['table'])+'\x20'+(T(0x13c)+D['join'](',\x20')+'\x20')+('WHERE\x20'+qi(u['key'])+'\x20=\x20$'+(H['length']+0x1)+'\x20')+('RETURNING\x20'+readableFields(u)['join'](',\x20')),U),X=w['rows'][0x0];if(!X)throw new NotFoundError(b+':'+F);return clearTableLookupCache(u[T(0x13d)],J['pg']),await J['audit']?.['write']({'userId':h?.['id'],'module':u[T(0x13e)],'resource':u['name'],'resourceId':F,'action':'update','fields':Object['keys'](P)}),X;};}
1
+ import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';function f(p,Z){p=p-0x113;const A=s();let I=A[p];return I;}import{clearTableLookupCache}from'./add-table-lookup-data.js';function s(){const V=['get','length','updated_at','push','user_type','key','\x20=\x20$','column','query','UPDATE\x20','SET\x20','join','table','audit','update','keys'];s=function(){return V;};return s();}export function createUpdate(p,Z){return async function A({name:I,id:j,data:D,user:o,where:R},B){const G=f,H=Z[G(0x113)](I);assertOperation(H,'update',o);const e=writableData(H,D);if(!e[G(0x114)])throw new ValidationError('No\x20writable\x20fields');const g=B?.['pg']??p['pg'];validateInputData({'resource':H,'data':D,'update':!![]});H['fields']['updated_at']&&e['push']([G(0x115),new Date()]);H['fields']['updated_by']&&e[G(0x116)](['updated_by',o?.['id']]);delete D[G(0x117)];const N=e['map'](([K],Q)=>qi(K)+'\x20=\x20$'+(Q+0x1)),h=[...e['map'](([,K])=>K),j];let E='WHERE\x20'+qi(H[G(0x118)])+G(0x119)+h[G(0x114)];R&&(h['push'](R['value']),E+='\x20AND\x20'+qi(R[G(0x11a)])+'\x20=\x20$'+h[G(0x114)]);H['where']&&(E+='\x20AND\x20('+H['where']+')');const a=await g[G(0x11b)](G(0x11c)+qt(H['table'])+'\x20'+(G(0x11d)+N[G(0x11e)](',\x20')+'\x20')+(E+'\x20')+('RETURNING\x20'+Object['keys'](D)['map'](qi)['join'](',\x20')),h),X=a['rows'][0x0];if(!X)throw new NotFoundError(I+':'+j);return clearTableLookupCache(H[G(0x11f)],g),await(B?.[G(0x120)]??p['audit'])?.['write']({'userId':o?.['id'],'module':H['module'],'resource':H['name'],'resourceId':j,'action':G(0x121),'fields':Object[G(0x122)](D)}),X;};}
@@ -1 +1 @@
1
- import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(J,e,p='btree',b){const H=c,F=requestedIndexes[H(0xf1)](b)??new Set();requestedIndexes[H(0xf2)](b,F);const P=J+':'+e+':'+p;if(F[H(0xf3)](P))return;F[H(0xf4)](P),void ensureIndex(J,e,p,b)[H(0xf5)](()=>{F['delete'](P);});}function c(J,e){J=J-0xf1;const p=L();let b=p[J];return b;}function L(){const U=['get','set','has','add','catch','text','query','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20','\x20USING\x20gin\x20(lower(','\x20ON\x20'];L=function(){return U;};return L();}async function ensureIndex(J,e,p,b){const D=c,F=J['split']('.'),P=F['length']===0x2?F[0x0]:'public',h=(J+'_'+e+'_'+p+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),u=await b['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[P,h]);if(u['rowCount'])return;if(p===D(0xf6)){await b['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await b[D(0xf7)](D(0xf8)+qi(h+'_l')+'\x20ON\x20'+qt(J)+'\x20USING\x20btree\x20(lower('+qi(e)+')\x20text_pattern_ops)'),await b[D(0xf7)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(h)+'\x20ON\x20'+qt(J)+D(0xf9)+qi(e)+')\x20gin_trgm_ops)');return;}await b['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(h)+D(0xfa)+qt(J)+'\x20USING\x20'+p+'\x20('+qi(e)+')');}
1
+ const B=f;import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(p,Z,A=B(0x1b2),I){const H=B,j=requestedIndexes[H(0x1b3)](I)??new Set();requestedIndexes['set'](I,j);const D=p+':'+Z+':'+A;if(j['has'](D))return;j[H(0x1b4)](D),void ensureIndex(p,Z,A,I)['catch'](()=>{j['delete'](D);});}function s(){const g=['btree','get','add','split','query','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'];s=function(){return g;};return s();}function f(p,Z){p=p-0x1b2;const A=s();let I=A[p];return I;}async function ensureIndex(p,Z,A,I){const e=B,j=p[e(0x1b5)]('.'),D=j['length']===0x2?j[0x0]:'public',o=(p+'_'+Z+'_'+A+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),R=await I[e(0x1b6)]('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[D,o]);if(R['rowCount'])return;if(A==='text'){await I['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await I['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(o+'_l')+'\x20ON\x20'+qt(p)+'\x20USING\x20btree\x20(lower('+qi(Z)+')\x20text_pattern_ops)'),await I['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(o)+'\x20ON\x20'+qt(p)+'\x20USING\x20gin\x20(lower('+qi(Z)+')\x20gin_trgm_ops)');return;}await I['query'](e(0x1b7)+qi(o)+'\x20ON\x20'+qt(p)+'\x20USING\x20'+A+'\x20('+qi(Z)+')');}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function L(){const P=['writable','string','minimum','\x20should\x20be\x20>=\x20','number','maximum','\x20should\x20be\x20<=\x20'];L=function(){return P;};return L();}const validateInputData=({resource:J,data:e,update:update=![]})=>{const F=c;for(const [p,b]of Object['entries'](J['fields'])){if(b['required']&&b['writable']!==![]&&(e[p]===undefined||e[p]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+p);if(b['required']&&b[F(0x102)]!==![]&&Object['hasOwn'](e,p)&&(e[p]===undefined||e[p]===null)&&update)throw new ValidationError('Required\x20field:\x20'+p);if(b['minLength']&&typeof e[p]===F(0x103)&&e[p]['length']<b['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+p);if(b['maxLength']&&typeof e[p]==='string'&&e[p]['length']>b['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+p);if(b[F(0x104)]&&typeof e[p]==='number'&&e[p]<b['minimum'])throw new ValidationError(p+F(0x105)+b['minimum']);if(b['maximum']&&typeof e[p]===F(0x106)&&e[p]>b[F(0x107)])throw new ValidationError(p+F(0x108)+b[F(0x107)]);if(b['enum']&&e[p]&&!b['enum']['includes'](e[p]))throw new ValidationError(p+'\x20should\x20be\x20one\x20of\x20('+b['enum']['join'](',\x20')+')');if(b['pattern']&&typeof e[p]==='string'&&!new RegExp(b['pattern'])['test'](e[p]))throw new ValidationError(p+'\x20should\x20match\x20regular\x20expression\x20('+b['pattern']+')');}};function c(J,e){J=J-0x102;const p=L();let b=p[J];return b;}export{validateInputData};
1
+ function s(){const D=['fields','writable','required','hasOwn','string','length','maximum','includes','\x20should\x20be\x20one\x20of\x20(','join','test','\x20should\x20match\x20regular\x20expression\x20('];s=function(){return D;};return s();}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function f(p,Z){p=p-0x15a;const A=s();let I=A[p];return I;}const validateInputData=({resource:p,data:Z,update:update=![]})=>{const j=f;for(const [A,I]of Object['entries'](p[j(0x15a)])){if(I['required']&&I[j(0x15b)]!==![]&&(Z[A]===undefined||Z[A]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+A);if(I[j(0x15c)]&&I['writable']!==![]&&Object[j(0x15d)](Z,A)&&(Z[A]===undefined||Z[A]===null)&&update)throw new ValidationError('Required\x20field:\x20'+A);if(I['minLength']&&typeof Z[A]===j(0x15e)&&Z[A]['length']<I['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+A);if(I['maxLength']&&typeof Z[A]==='string'&&Z[A][j(0x15f)]>I['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+A);if(I['minimum']&&typeof Z[A]==='number'&&Z[A]<I['minimum'])throw new ValidationError(A+'\x20should\x20be\x20>=\x20'+I['minimum']);if(I['maximum']&&typeof Z[A]==='number'&&Z[A]>I[j(0x160)])throw new ValidationError(A+'\x20should\x20be\x20<=\x20'+I['maximum']);if(I['enum']&&Z[A]&&!I['enum'][j(0x161)](Z[A]))throw new ValidationError(A+j(0x162)+I['enum'][j(0x163)](',\x20')+')');if(I['pattern']&&typeof Z[A]==='string'&&!new RegExp(I['pattern'])[j(0x164)](Z[A]))throw new ValidationError(A+j(0x165)+I['pattern']+')');}};export{validateInputData};
@@ -3,7 +3,8 @@
3
3
  */
4
4
  import type { ResourceContract, ResourceDependencies } from '../resource.types.js';
5
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
+ export declare function buildIndex(resource: ResourceContract, filter: Record<string, unknown> | undefined, pg?: ResourceDependencies['pg']): void;
7
+ export declare function buildFilters(resource: ResourceContract, filter: Record<string, unknown> | undefined, start?: number): {
7
8
  sql: string;
8
9
  values: unknown[];
9
10
  };
@@ -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,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
+ {"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;AACD,wBAAgB,UAAU,CACtB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,EAAE,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC,QAgBlC;AAED,wBAAgB,YAAY,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,KAAK,SAAI;;;EAuDZ"}
@@ -1 +1 @@
1
- function c(J,e){J=J-0xa9;const p=L();let b=p[J];return b;}const l=c;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt',l(0xa9),'in','nin','like',l(0xaa),'null']);export function parseFilterQuery(J){const a=l,e={...isRecord(J['filter'])?J[a(0xab)]:{}};for(const [p,b]of Object['entries'](J)){const F=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](p);if(!F)continue;const [,P,h]=F;if(!P)continue;if(!h){e[P]=b;continue;}if(!filterOperators['has'](h))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+h);const u=isRecord(e[P])?e[P]:{};u[h]=(h==='in'||h===a(0xac))&&typeof b==='string'?b[a(0xad)](','):b,e[P]=u;}return Object[a(0xae)](e)[a(0xaf)]?e:undefined;}function L(){const A=['lte','ilike','filter','nin','split','keys','length','fields','filterable','text','NULL','like',')\x20like\x20lower(','\x20AND\x20','geometry','btree'];L=function(){return A;};return L();}export function buildFilters(J,e,p=0x1,b){const M=l,F=[],P=[];for(const [h,u]of Object['entries'](e??{})){const H=J[M(0xb0)][h];if(!H||H['filter']!==!![]&&H[M(0xb1)]!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+h);const D=qi(fieldColumn(J,h)),U=isRecord(u)?u:{'eq':u};for(const [w,X]of Object['entries'](U)){if(!filterOperators['has'](w))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+w);if((w==='like'||w==='ilike')&&H['type']!=='string'&&H['type']!==M(0xb2))throw new ValidationError('Operator\x20'+w+'\x20requires\x20a\x20text\x20field:\x20'+h);b&&autoIndex(J['table'],fieldColumn(J,h),indexTypeFor(H['type'],w),b);if(w==='null'){F['push'](D+'\x20IS\x20'+(isTruthy(X)?'':'NOT\x20')+M(0xb3));continue;}if(w==='in'||w==='nin'){const T=Array['isArray'](X)?X:[X];if(T['length']===0x0){F['push'](w==='in'?'FALSE':'TRUE');continue;}P['push'](T),F['push'](D+'\x20'+(w==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(p+P['length']-0x1)+')');continue;}const E={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},Q='$'+(p+P['length']);if(w===M(0xb4)){P['push'](X+'%'),F['push']('lower('+D+M(0xb5)+Q+')');continue;}P['push'](X),F['push'](D+'\x20'+E[w]+'\x20'+Q);}}return{'sql':F['length']?'\x20WHERE\x20'+F['join'](M(0xb6)):'','values':P};}function isRecord(J){return typeof J==='object'&&J!==null&&!Array['isArray'](J);}function isTruthy(J){return J===!![]||J==='true'||J==='1'||J===0x1;}function indexTypeFor(J,e){const d=l;if(e==='like'||e===d(0xaa))return'text';if(J==='geom'||J===d(0xb7))return'gist';return d(0xb8);}
1
+ const a=f;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt',a(0x1b6),'in','nin',a(0x1b7),a(0x1b8),a(0x1b9)]);export function parseFilterQuery(p){const X=a,Z={...isRecord(p['filter'])?p[X(0x1ba)]:{}};for(const [A,I]of Object['entries'](p)){const j=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](A);if(!j)continue;const [,D,o]=j;if(!D)continue;if(!o){Z[D]=I;continue;}if(!filterOperators[X(0x1bb)](o))throw new ValidationError(X(0x1bc)+o);const R=isRecord(Z[D])?Z[D]:{};R[o]=(o==='in'||o===X(0x1bd))&&typeof I===X(0x1be)?I[X(0x1bf)](','):I,Z[D]=R;}return Object[X(0x1c0)](Z)[X(0x1c1)]?Z:undefined;}export function buildIndex(p,Z,A){for(const [I,j]of Object['entries'](Z??{})){const D=p['fields'][I];if(!D||D['filter']!==!![]&&D['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+I);A&&autoIndex(p['table'],fieldColumn(p,I),indexTypeFor(D['type'],'eq'),A);}}function f(p,Z){p=p-0x1b6;const A=s();let I=A[p];return I;}export function buildFilters(p,Z,A=0x1){const K=a,I=[],j=[];for(const [D,o]of Object[K(0x1c2)](Z??{})){const R=p['fields'][D];if(!R||R[K(0x1ba)]!==!![]&&R['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+D);const B=qi(fieldColumn(p,D)),H=isRecord(o)?o:{'eq':o};for(const [e,g]of Object[K(0x1c2)](H)){if(!filterOperators['has'](e))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+e);if((e==='like'||e===K(0x1b8))&&R['type']!=='string'&&R['type']!=='text')throw new ValidationError(K(0x1c3)+e+'\x20requires\x20a\x20text\x20field:\x20'+D);if(e===K(0x1b9)){I[K(0x1c4)](B+'\x20IS\x20'+(isTruthy(g)?'':K(0x1c5))+'NULL');continue;}if(e==='in'||e==='nin'){const E=Array['isArray'](g)?g:[g];if(E['length']===0x0){I['push'](e==='in'?'FALSE':K(0x1c6));continue;}j[K(0x1c4)](E),I['push'](B+'\x20'+(e==='in'?'=\x20ANY':K(0x1c7))+'($'+(A+j[K(0x1c1)]-0x1)+')');continue;}const N={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':K(0x1b7)},h='$'+(A+j['length']);if(e==='like'){j['push'](g+'%'),I[K(0x1c4)]('lower('+B+K(0x1c8)+h+')');continue;}j['push'](g),I['push'](B+'\x20'+N[e]+'\x20'+h);}}return{'sql':I[K(0x1c1)]?'\x20WHERE\x20'+I['join']('\x20AND\x20'):'','values':j};}function s(){const V=['lte','like','ilike','null','filter','has','Unsupported\x20filter\x20operator:\x20','nin','string','split','keys','length','entries','Operator\x20','push','NOT\x20','TRUE','<>\x20ALL',')\x20like\x20lower(','isArray','geom','gist','btree'];s=function(){return V;};return s();}function isRecord(p){const Q=a;return typeof p==='object'&&p!==null&&!Array[Q(0x1c9)](p);}function isTruthy(p){return p===!![]||p==='true'||p==='1'||p===0x1;}function indexTypeFor(p,Z){const G=a;if(Z==='like'||Z===G(0x1b8))return'text';if(p===G(0x1ca)||p==='geometry')return G(0x1cb);return G(0x1cc);}
@@ -1 +1 @@
1
- function c(J,e){J=J-0x156;const p=L();let b=p[J];return b;}import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';export function assertOperation(J,e,p){const P=c,b=getContext()['config'];if(b['debug'])return;if(!J['operations'][P(0x156)](e))throw new ForbiddenError(J['name']+'.'+e+'\x20is\x20disabled');if(J['access']!=='public'&&p===undefined)throw new ForbiddenError('Authentication\x20required');if(J[P(0x157)]==='admin'&&p?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p?.['type']!=='admin'){const F=(J['permission']??J['name'])+':'+e;if(!p?.[P(0x158)]?.['includes'](F))throw new ForbiddenError('Missing\x20permission:\x20'+F);}}function L(){const h=['includes','access','permissions'];L=function(){return h;};return L();}
1
+ import{ForbiddenError}from'../../../errors.js';function s(){const o=['config','public','admin','type','includes','Missing\x20permission:\x20'];s=function(){return o;};return s();}function f(p,Z){p=p-0x86;const A=s();let I=A[p];return I;}import{getContext}from'../../../index.js';export function assertOperation(p,Z,A){const D=f,I=getContext()[D(0x86)];if(I['debug'])return;if(!p['operations']['includes'](Z))throw new ForbiddenError(p['name']+'.'+Z+'\x20is\x20disabled');if(p['access']!==D(0x87)&&A===undefined)throw new ForbiddenError('Authentication\x20required');if(p['access']===D(0x88)&&A?.[D(0x89)]!==D(0x88))throw new ForbiddenError('Admin\x20access\x20required');if(A?.['type']!==D(0x88)){const j=(p['permission']??p['name'])+':'+Z;if(!A?.['permissions']?.[D(0x8a)](j))throw new ForbiddenError(D(0x8b)+j);}}
@@ -0,0 +1,10 @@
1
+ import type { DatabaseAdapter } from "../../pg.js";
2
+ import type { ResourceContract, ResourceUser } from "../resource.types.js";
3
+ export declare function clearResourceScopeCache(userId?: string, resourceName?: string): void;
4
+ export declare function getUserResourceScopes(userId: string, resourceName: string, pg: DatabaseAdapter): Promise<Record<string, unknown>>;
5
+ export interface UserResourceScopeFilter {
6
+ sql: string;
7
+ values: unknown[];
8
+ }
9
+ export declare function buildUserResourceScopeFilter(resource: ResourceContract, user: ResourceUser | undefined, pg: DatabaseAdapter, startIndex: number): Promise<UserResourceScopeFilter>;
10
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAa3E,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,QAY7E;AA+CD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,eAAe,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAQlC;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAsBD,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,EAAE,EAAE,eAAe,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,uBAAuB,CAAC,CA8BlC"}
@@ -0,0 +1 @@
1
+ import{ValidationError}from'../../../errors.js';import{qi}from'./sql.js';function f(p,Z){p=p-0xe3;const A=s();let I=A[p];return I;}const scopeCache=new Map(),CACHE_TTL_MS=0x7530;export function clearResourceScopeCache(p,Z){const g=f;if(p&&Z){scopeCache['delete'](p+':'+Z);return;}if(p){for(const A of scopeCache['keys']()){if(A['startsWith'](p+':'))scopeCache['delete'](A);}return;}scopeCache[g(0xe3)]();}function s(){const K=['clear','get','promise','query','scope','value','set','fromEntries','name','key','user_uid','created_by','fields','type','admin','\x20=\x20$','push','length','\x20AND\x20'];s=function(){return K;};return s();}async function loadScopeRows(p,Z,A){const N=f,I=p+':'+Z,j=scopeCache[N(0xe4)](I);if(j&&j['expiresAt']>Date['now']())return j[N(0xe5)];const D=A[N(0xe6)]('SELECT\x20DISTINCT\x20ras.scope,\x20ras.value\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x20ras\x0a\x20\x20\x20\x20\x20WHERE\x20ras.resource\x20=\x20$2\x0a\x20\x20\x20\x20\x20\x20\x20AND\x20ras.enabled\x20=\x20TRUE\x0a\x20\x20\x20\x20\x20\x20\x20AND\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20ras.user_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20OR\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ras.user_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20ras.role_id\x20IN\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ur.role_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20(ur.expiration\x20IS\x20NULL\x20OR\x20ur.expiration\x20>=\x20CURRENT_DATE)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20)',[p,Z])['then'](({rows:o})=>{const h=N,R=new Map();for(const B of o){const H=R['get'](B[h(0xe7)])??[];if(Array['isArray'](B['value']))H['push'](...B['value']);else{if(B['value']!==null&&B[h(0xe8)]!==undefined)H['push'](B['value']);}R['set'](B[h(0xe7)],H);}return R;})['catch'](o=>{scopeCache['delete'](I);throw o;});return scopeCache[N(0xe9)](I,{'expiresAt':Date['now']()+CACHE_TTL_MS,'promise':D}),D;}export async function getUserResourceScopes(p,Z,A){const E=f,I=await loadScopeRows(p,Z,A);return Object[E(0xea)]([...I]['map'](([j,D])=>[j,j==='me'?p:D]));}function columnForScope(p,Z){const a=f;if(Z===p[a(0xeb)])return p[a(0xec)];if(Z==='me'){const I=['user_id',a(0xed),'owner_id',a(0xee)]['find'](j=>p[a(0xef)][j]);if(!I)throw new ValidationError('Cannot\x20apply\x20\x22me\x22\x20scope\x20to\x20resource\x20without\x20an\x20owner\x20field:\x20'+p[a(0xeb)]);return p['fields'][I]?.['column']??I;}const A=p['fields'][Z];if(!A)return'';return A['column']??Z;}export async function buildUserResourceScopeFilter(p,Z,A,I){const X=f;if(!Z||Z[X(0xf0)]===X(0xf1))return{'sql':'','values':[]};const j=await loadScopeRows(Z['id'],p[X(0xeb)],A),D=[],o=[];for(const [R,B]of j){const H=columnForScope(p,R);if(!H){D['push']('(FALSE)');continue;}const e='t.'+qi(H);if(R==='me'){o['push'](Z['id']),D['push']('('+e+X(0xf2)+(I+o['length']-0x1)+')');continue;}if(B['length']===0x0){D[X(0xf3)]('(FALSE)');continue;}o[X(0xf3)](B),D['push']('('+e+'\x20=\x20ANY($'+(I+o[X(0xf4)]-0x1)+'))');}return{'sql':D['join'](X(0xf5)),'values':o};}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Provides Resource helpers for sort handling.
3
3
  */
4
- import type { ResourceContract } from '../resource.types.js';
4
+ import type { ResourceContract } from "../resource.types.js";
5
5
  export declare function buildSort(resource: ResourceContract, sort?: string[]): string;
6
6
  //# sourceMappingURL=sort.d.ts.map
@@ -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,UAgBpE"}
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,UAcpE"}
@@ -1 +1 @@
1
- function c(J,e){J=J-0x113;const p=L();let b=p[J];return b;}function L(){const D=['string','startsWith'];L=function(){return D;};return L();}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(J,e){const u=c;if(!e?.['length'])return'';typeof e===u(0x113)&&(e=[e]);const p=e['map'](b=>{const H=u,F=b[H(0x114)]('-'),P=F?b['slice'](0x1):b,h=J['fields'][P];if(!h||h['sort']!==!![]&&h['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+P);return qi(fieldColumn(J,P))+'\x20'+(F?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+p['join'](',\x20');}
1
+ function s(){const H=['string','ASC','join'];s=function(){return H;};return s();}import{fieldColumn,qi}from'./sql.js';function f(p,Z){p=p-0x67;const A=s();let I=A[p];return I;}import{ValidationError}from'../../../errors.js';export function buildSort(p,Z){const R=f;if(!Z?.['length'])return'';typeof Z===R(0x67)&&(Z=[Z]);const A=Z['map'](I=>{const B=R,j=I['startsWith']('-'),D=j?I['slice'](0x1):I,o=p['fields'][D];if(!o||o['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+D);return qi(fieldColumn(p,D))+'\x20'+(j?'DESC':B(0x68));});return'\x20ORDER\x20BY\x20'+A[R(0x69)](',\x20');}
@@ -4,7 +4,7 @@ export declare const quoteIdentifier: (value: string) => string;
4
4
  /** Quote a schema-qualified PostgreSQL table name. */
5
5
  export declare const quoteTable: (value: string) => string;
6
6
  export declare function fieldColumn(resource: ResourceContract, name: string): string;
7
- export declare function readableFields(resource: ResourceContract): string[];
7
+ export declare function readableFields(resource: ResourceContract, scope?: string): string[];
8
8
  export declare function writableData(resource: ResourceContract, data: Record<string, unknown>): Array<[
9
9
  string,
10
10
  unknown
@@ -1 +1 @@
1
- {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAA0C,CAAC;AAC3F,sDAAsD;AACtD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAyD,CAAC;AACrG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5E;AACD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAQnE;AACD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IAC3F,MAAM;IACN,OAAO;CACV,CAAC,CAaD;AAED,eAAO,MAAM,EAAE,wBAAkB,CAAC;AAClC,eAAO,MAAM,EAAE,mBAAa,CAAC"}
1
+ {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAA0C,CAAC;AAC3F,sDAAsD;AACtD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAyD,CAAC;AACrG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5E;AACD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAQnF;AACD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IAC3F,MAAM;IACN,OAAO;CACV,CAAC,CAmBD;AAED,eAAO,MAAM,EAAE,wBAAkB,CAAC;AAClC,eAAO,MAAM,EAAE,mBAAa,CAAC"}
@@ -1 +1 @@
1
- const h=c;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=J=>'\x22'+J['replace'](/"/g,'\x22\x22')+'\x22';function c(J,e){J=J-0x10e;const p=L();let b=p[J];return b;}export const quoteTable=J=>J[h(0x10e)]('.')['map'](quoteIdentifier)[h(0x10f)]('.');export function fieldColumn(J,e){const u=h;if(e===J[u(0x110)])return J['key'];const p=J['fields'][e];if(!p)throw new ValidationError('Unknown\x20field:\x20'+e);return p['column']??e;}export function readableFields(J){const H=h,e=Object['entries'](J[H(0x111)])['filter'](([,p])=>p['read']!==![]&&p['readable']!==![])[H(0x112)](([p,b])=>quoteIdentifier(b['column']??p)+'\x20AS\x20'+quoteIdentifier(p));return!J[H(0x111)][J['key']]&&e[H(0x113)](quoteIdentifier(J['key'])),e;}export function writableData(J,e){const D=h,p=[];for(const [b,F]of Object['entries'](e)){const P=J[D(0x111)][b];if(!P||P['write']===![]||P['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+b);p['push']([P[D(0x114)]??b,F]);}return p;}export const qi=quoteIdentifier;export const qt=quoteTable;function L(){const U=['split','join','key','fields','map','unshift','column'];L=function(){return U;};return L();}
1
+ const o=f;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=p=>'\x22'+p['replace'](/"/g,'\x22\x22')+'\x22';function s(){const e=['split','Unknown\x20field:\x20','fields','read','scope','column','unshift','write'];s=function(){return e;};return s();}export const quoteTable=p=>p[o(0x1cd)]('.')['map'](quoteIdentifier)['join']('.');function f(p,Z){p=p-0x1cd;const A=s();let I=A[p];return I;}export function fieldColumn(p,Z){const R=o;if(Z===p['key'])return p['key'];const A=p['fields'][Z];if(!A)throw new ValidationError(R(0x1ce)+Z);return A['column']??Z;}export function readableFields(p,Z){const B=o,A=Object['entries'](p[B(0x1cf)])['filter'](([,I])=>I[B(0x1d0)]!==![]&&I['readable']!==![]&&(Z?(I[B(0x1d1)]??'all')===Z:!![]))['map'](([I,j])=>quoteIdentifier(j[B(0x1d2)]??I)+'\x20AS\x20'+quoteIdentifier(I));return!p['fields'][p['key']]&&A[B(0x1d3)](quoteIdentifier(p['key'])),A;}export function writableData(p,Z){const H=o,A=[];for(const [I,j]of Object['entries'](Z)){const D=p['fields'][I];if(!D||D[H(0x1d4)]===![]||D['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+I);if((D[H(0x1d4)]??D['writable'])!==!![])continue;if(D['type']==='date'&&!Z[I])continue;A['push']([D[H(0x1d2)]??I,j]);}return A;}export const qi=quoteIdentifier;export const qt=quoteTable;
@@ -0,0 +1,7 @@
1
+ import type { ResourceContract, ResourceQuery, ResourceUser } from "../resource.types.js";
2
+ import type { UserResourceScopeFilter } from "./scope.js";
3
+ export declare function buildSummary(resource: ResourceContract, query: ResourceQuery, user: ResourceUser | undefined, accessScope?: UserResourceScopeFilter): {
4
+ sql: string;
5
+ values: unknown[];
6
+ };
7
+ //# sourceMappingURL=summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/summary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAuB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE/G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAO1D,wBAAgB,YAAY,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,WAAW,CAAC,EAAE,uBAAuB;;;EA2DxC"}
@@ -0,0 +1 @@
1
+ function f(p,Z){p=p-0x1ce;const A=s();let I=A[p];return I;}function s(){const a=['aggregate','where','))::int\x20AS\x20\x22',')\x20AS\x20\x22',')\x20FILTER\x20(where\x20','true','MIN(','max','filter','\x20AND\x20','default','keys','searchable','push','sql','values','item','map','SELECT\x20'];s=function(){return a;};return s();}import{buildFilters}from'./filters.js';import{qt}from'./sql.js';const defaultSummary={'count':{'aggregate':'count'}};export function buildSummary(p,Z,A,I){const E=f,j={...defaultSummary,...p['summary']??{}},D=Object['entries'](j)['map'](([g,N])=>{const h=f;if('sql'in N)return'('+N['sql']+')\x20AS\x20\x22'+g+'\x22';switch(N[h(0x1ce)]){case'count':return'(COUNT(*)\x20FILTER\x20(where\x20'+(N[h(0x1cf)]??'true')+h(0x1d0)+g+'\x22';case'countDistinct':return'(COUNT(DISTINCT\x20t.'+qt(N['field'])+')\x20FILTER\x20(where\x20'+(N['where']??'true')+'))::int\x20AS\x20\x22'+g+'\x22';case'sum':return'SUM('+N['field']+')\x20FILTER\x20(where\x20'+(N['where']??'true')+h(0x1d1)+g+'\x22';case'avg':return'AVG('+N['field']+h(0x1d2)+(N['where']??h(0x1d3))+h(0x1d1)+g+'\x22';case'min':return h(0x1d4)+N['field']+')\x20FILTER\x20(where\x20'+(N['where']??'true')+h(0x1d1)+g+'\x22';case h(0x1d5):return'MAX('+N['field']+')\x20FILTER\x20(where\x20'+(N['where']??'true')+h(0x1d1)+g+'\x22';}}),o=buildFilters(p,Z[E(0x1d6)]);p['where']&&(o['sql']+=(o['sql']?E(0x1d7):'\x20WHERE\x20')+('('+p['where']+')'));const R=Z['scope']||(p['scopes']?.[E(0x1d8)]?'default':undefined);R&&(o['sql']+=(o['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+(p['scopes']?.[R]||'true')+')'));const B=p['searchable']||Object[E(0x1d9)](p['fields'])[E(0x1d6)](g=>p['fields'][g]?.[E(0x1da)]);Z['search']&&B['length']&&(o['values'][E(0x1db)](Z['search']['toLowerCase']()+'%'),o[E(0x1dc)]+=(o[E(0x1dc)]?E(0x1d7):'\x20WHERE\x20')+('\x20('+B['map'](g=>'lower('+qt(g)+')\x20LIKE\x20$'+o[E(0x1dd)]['length'])['join']('\x20OR\x20')+')'));I?.['sql']&&(o['sql']+=(o[E(0x1dc)]?E(0x1d7):'\x20WHERE\x20')+('('+I[E(0x1dc)]+')'),o['values']['push'](...I['values']));const H=p['joins']?.['filter'](g=>g['scope']!==E(0x1de))[E(0x1df)](g=>g['sql']+'\x20')['join']('\x20')||'',e=E(0x1e0)+D['join'](',\x20')+'\x20'+('FROM\x20'+qt(p['table'])+'\x20t\x20')+(H+'\x20'+o[E(0x1dc)]['replace'](/:uid/g,'\x27'+(A?.['id']??'NULL')+'\x27'));return{'sql':e,'values':o['values']};}
@@ -1 +1 @@
1
- const e=c,getIP=J=>(J[e(0x7c)]?.['x-real-ip']||J['headers']?.['x-forwarded-for']||J['ip']||J['connection']?.['remoteAddress']||'')['split'](':')['pop']();function c(J,e){J=J-0x7c;const p=L();let b=p[J];return b;}export default getIP;function L(){const p=['headers'];L=function(){return p;};return L();}
1
+ function f(p,Z){p=p-0xb7;const A=s();let I=A[p];return I;}const Z=f,getIP=p=>(p['headers']?.['x-real-ip']||p[Z(0xb7)]?.[Z(0xb8)]||p['ip']||p[Z(0xb9)]?.[Z(0xba)]||'')['split'](':')['pop']();function s(){const A=['headers','x-forwarded-for','connection','remoteAddress'];s=function(){return A;};return s();}export default getIP;
@@ -182,9 +182,12 @@ CREATE TABLE IF NOT EXISTS admin.files (
182
182
  file_status numeric,
183
183
  file_name text,
184
184
  size numeric,
185
- ext text,
185
+ mime_type text,
186
186
  tags text[],
187
- file_path text,
187
+ file_path text,
188
+ field_name text,
189
+ status text DEFAULT 'pending', -- File processing status, e.g., 'pending', 'attached'
190
+ expires_at timestamptz DEFAULT now() + interval '1 day',
188
191
  verified boolean DEFAULT false,
189
192
  resized boolean,
190
193
  created_by text REFERENCES admin.users(uid) ,
@@ -1,18 +1,18 @@
1
- CREATE SCHEMA IF NOT EXISTS admin;
2
-
3
- DO $$
4
- BEGIN
5
- IF to_regclass('crm.notes') IS NOT NULL
6
- AND to_regclass('admin.notes') IS NULL THEN
7
- ALTER TABLE crm.notes SET SCHEMA admin;
8
- END IF;
9
-
10
- IF to_regclass('crm.files') IS NOT NULL
11
- AND to_regclass('admin.files') IS NULL THEN
12
- ALTER TABLE crm.files SET SCHEMA admin;
13
- END IF;
14
- END
15
- $$;
16
-
17
- ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
1
+ CREATE SCHEMA IF NOT EXISTS admin;
2
+
3
+ DO $$
4
+ BEGIN
5
+ IF to_regclass('crm.notes') IS NOT NULL
6
+ AND to_regclass('admin.notes') IS NULL THEN
7
+ ALTER TABLE crm.notes SET SCHEMA admin;
8
+ END IF;
9
+
10
+ IF to_regclass('crm.files') IS NOT NULL
11
+ AND to_regclass('admin.files') IS NULL THEN
12
+ ALTER TABLE crm.files SET SCHEMA admin;
13
+ END IF;
14
+ END
15
+ $$;
16
+
17
+ ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
18
18
  ALTER INDEX IF EXISTS crm_notes_uid_idx RENAME TO admin_notes_uid_idx;
@@ -0,0 +1,5 @@
1
+
2
+ alter table admin.files add column if not exists mime_type text;
3
+ alter table admin.files add column if not exists status text default 'pending';
4
+ alter table admin.files add column if not exists expires_at timestamptz default now() + interval '1 day';
5
+ alter table admin.files add column if not exists field_name text;
@@ -1,19 +1,19 @@
1
- CREATE SCHEMA IF NOT EXISTS admin;
2
-
3
- CREATE TABLE IF NOT EXISTS admin.settings (
4
- id text PRIMARY KEY DEFAULT next_id(),
5
- resource text NOT NULL DEFAULT 'system',
6
- resource_id text,
7
- key text NOT NULL,
8
- value jsonb,
9
- updated_by text,
10
- updated_at timestamptz NOT NULL DEFAULT now(),
11
- created_by text,
12
- created_at timestamptz NOT NULL DEFAULT now()
13
- );
14
-
15
- DROP INDEX IF EXISTS settings_resource_key_uidx;
16
-
17
- CREATE UNIQUE INDEX settings_resource_key_uidx
18
- ON admin.settings (resource, resource_id, key)
1
+ CREATE SCHEMA IF NOT EXISTS admin;
2
+
3
+ CREATE TABLE IF NOT EXISTS admin.settings (
4
+ id text PRIMARY KEY DEFAULT next_id(),
5
+ resource text NOT NULL DEFAULT 'system',
6
+ resource_id text,
7
+ key text NOT NULL,
8
+ value jsonb,
9
+ updated_by text,
10
+ updated_at timestamptz NOT NULL DEFAULT now(),
11
+ created_by text,
12
+ created_at timestamptz NOT NULL DEFAULT now()
13
+ );
14
+
15
+ DROP INDEX IF EXISTS settings_resource_key_uidx;
16
+
17
+ CREATE UNIQUE INDEX settings_resource_key_uidx
18
+ ON admin.settings (resource, resource_id, key)
19
19
  NULLS NOT DISTINCT;
@@ -0,0 +1,22 @@
1
+ CREATE TABLE IF NOT EXISTS admin.gallery (
2
+ id text PRIMARY KEY DEFAULT next_id(),
3
+ resource text,
4
+ resource_id text,
5
+ uploaded_name text,
6
+ file_type text,
7
+ file_status numeric,
8
+ file_name text,
9
+ size numeric,
10
+ mime_type text check (mime_type = any(array['image/png','image/jpeg','image/webp']) ),
11
+ tags text[],
12
+ file_path text,
13
+ field_name text,
14
+ status text DEFAULT 'pending', -- File processing status, e.g., 'pending', 'attached'
15
+ expires_at timestamptz DEFAULT now() + interval '1 day',
16
+ verified boolean DEFAULT false,
17
+ resized boolean,
18
+ created_by text REFERENCES admin.users(uid) ,
19
+ created_at timestamptz DEFAULT now(),
20
+ updated_by text REFERENCES admin.users(uid) ,
21
+ updated_at timestamptz default now()
22
+ );
@@ -0,0 +1,2 @@
1
+ ALTER TABLE admin.role_access_scope
2
+ ALTER COLUMN role_id DROP NOT NULL;
@@ -0,0 +1,32 @@
1
+ CREATE TABLE IF NOT EXISTS admin.role_access_scope (
2
+ id text PRIMARY KEY DEFAULT next_id(),
3
+
4
+ role_id text ,
5
+
6
+ user_id text,
7
+
8
+ resource text,
9
+
10
+ scope text NOT NULL,
11
+
12
+ value jsonb,
13
+
14
+ enabled boolean NOT NULL DEFAULT true,
15
+
16
+ created_by text,
17
+ created_at timestamptz NOT NULL DEFAULT now(),
18
+ updated_by text,
19
+ updated_at timestamptz NOT NULL DEFAULT now()
20
+ );
21
+
22
+ CREATE INDEX IF NOT EXISTS role_access_scope_role_idx
23
+ ON admin.role_access_scope(role_id);
24
+
25
+ CREATE INDEX IF NOT EXISTS role_access_scope_user_idx
26
+ ON admin.role_access_scope(user_id);
27
+
28
+ CREATE INDEX IF NOT EXISTS role_access_scope_scope_idx
29
+ ON admin.role_access_scope(scope);
30
+
31
+ CREATE INDEX IF NOT EXISTS role_access_scope_resource_idx
32
+ ON admin.role_access_scope(resource);
package/package.json CHANGED
@@ -1,93 +1,93 @@
1
- {
2
- "name": "@opengis/fcore",
3
- "version": "0.0.1-beta.9",
4
- "description": "Reusable backend foundation for OpenGIS Node.js applications",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "files": [
9
- "dist",
10
- "migrations",
11
- "README.md",
12
- "LICENSE"
13
- ],
14
- "exports": {
15
- ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
18
- },
19
- "./fastify": {
20
- "types": "./dist/fastify.d.ts",
21
- "import": "./dist/fastify.js"
22
- },
23
- "./migrate": {
24
- "types": "./dist/migrations/runner.d.ts",
25
- "import": "./dist/migrations/runner.js"
26
- }
27
- },
28
- "bin": {
29
- "fcore-migrate": "./dist/migrations/cli.js",
30
- "fcore-adduser": "./dist/modules/auth/adduser-cli.js",
31
- "fcore-passwd": "./dist/modules/auth/passwd-cli.js",
32
- "fcore-permission": "./dist/modules/auth/permission-cli.js"
33
- },
34
- "scripts": {
35
- "clean": "rm -rf dist",
36
- "build": "npm run clean && tsc -p tsconfig.json && node scripts/obfuscate.mjs",
37
- "typecheck": "tsc -p tsconfig.json --noEmit",
38
- "test": "node --test --import tsx test/**/*.test.ts",
39
- "test-env": "node --env-file=.env.test --test --import tsx test/**/env.test.ts",
40
- "dev": "bun ./server.ts",
41
- "adduser": "node --import tsx ./src/modules/auth/adduser-cli.ts",
42
- "passwd": "node --import tsx ./src/modules/auth/passwd-cli.ts",
43
- "permission": "node --import tsx ./src/modules/auth/permission-cli.ts",
44
- "migrate": "node --import tsx src/migrations/cli.ts",
45
- "migration-test": "node --env-file=.env.test --import tsx src/migrations/cli.ts",
46
- "prepublishOnly": "npm run build",
47
- "prepublishOnly1": "npm run build && npm test",
48
- "patch": "npm version patch && git push && npm publish",
49
- "minor": "npm version minor && git push && npm publish",
50
- "major": "npm version major && git push && npm publish"
51
- },
52
- "engines": {
53
- "node": ">=20"
54
- },
55
- "dependencies": {
56
- "@aws-sdk/client-s3": "3.1125.0",
57
- "@aws-sdk/lib-storage": "3.1125.0",
58
- "@fastify/cookie": "11.1.2",
59
- "@fastify/multipart": "10.1.1",
60
- "@fastify/passport": "4.0.2",
61
- "@fastify/rate-limit": "11.2.0",
62
- "@fastify/session": "11.1.2",
63
- "@sinclair/typebox": "^0.34.52",
64
- "apache-crypt": "1.2.6",
65
- "dotenv": "17.4.2",
66
- "fastify-session-redis-store": "7.1.2",
67
- "file-type": "22.0.2",
68
- "ioredis": "6.0.0",
69
- "jose": "^6.2.12",
70
- "otplib": "13.5.0",
71
- "pg": "8.23.0",
72
- "pino": "10.3.1",
73
- "pino-abstract-transport": "3.0.0",
74
- "qrcode": "1.5.4",
75
- "sharp": "0.35.4"
76
- },
77
- "peerDependencies": {
78
- "fastify": ">=5.12.1"
79
- },
80
- "devDependencies": {
81
- "@types/node": "22.20.1",
82
- "@types/passport": "1.0.17",
83
- "@types/passport-local": "1.0.38",
84
- "@types/pg": "8.23.1",
85
- "@types/qrcode": "1.5.6",
86
- "fastify": "5.12.1",
87
- "javascript-obfuscator": "5.6.0",
88
- "tsx": "4.23.13",
89
- "typescript": "7.0.2",
90
- "vitest": "4.1.11"
91
- },
92
- "license": "UNLICENSED"
93
- }
1
+ {
2
+ "name": "@opengis/fcore",
3
+ "version": "0.0.28",
4
+ "description": "Reusable backend foundation for OpenGIS Node.js applications",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "migrations",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ },
19
+ "./fastify": {
20
+ "types": "./dist/fastify.d.ts",
21
+ "import": "./dist/fastify.js"
22
+ },
23
+ "./migrate": {
24
+ "types": "./dist/migrations/runner.d.ts",
25
+ "import": "./dist/migrations/runner.js"
26
+ }
27
+ },
28
+ "bin": {
29
+ "fcore-migrate": "./dist/migrations/cli.js",
30
+ "fcore-adduser": "./dist/modules/auth/adduser-cli.js",
31
+ "fcore-passwd": "./dist/modules/auth/passwd-cli.js",
32
+ "fcore-permission": "./dist/modules/auth/permission-cli.js"
33
+ },
34
+ "scripts": {
35
+ "clean": "rm -rf dist",
36
+ "build": "npm run clean && tsc -p tsconfig.json && node scripts/obfuscate.mjs",
37
+ "typecheck": "tsc -p tsconfig.json --noEmit",
38
+ "test": "node --test --import tsx test/**/*.test.ts",
39
+ "test-env": "node --env-file=.env.test --test --import tsx test/**/env.test.ts",
40
+ "dev": "bun ./server.ts",
41
+ "adduser": "node --import tsx ./src/modules/auth/adduser-cli.ts",
42
+ "passwd": "node --import tsx ./src/modules/auth/passwd-cli.ts",
43
+ "permission": "node --import tsx ./src/modules/auth/permission-cli.ts",
44
+ "migrate": "node --import tsx src/migrations/cli.ts",
45
+ "migration-test": "node --env-file=.env.test --import tsx src/migrations/cli.ts",
46
+ "prepublishOnly": "npm run build",
47
+ "prepublishOnly1": "npm run build && npm test",
48
+ "patch": "npm version patch && git push && npm publish",
49
+ "minor": "npm version minor && git push && npm publish",
50
+ "major": "npm version major && git push && npm publish"
51
+ },
52
+ "engines": {
53
+ "node": ">=20"
54
+ },
55
+ "dependencies": {
56
+ "@aws-sdk/client-s3": "3.1125.0",
57
+ "@aws-sdk/lib-storage": "3.1125.0",
58
+ "@fastify/cookie": "11.1.2",
59
+ "@fastify/multipart": "10.1.1",
60
+ "@fastify/passport": "4.0.2",
61
+ "@fastify/rate-limit": "11.2.0",
62
+ "@fastify/session": "11.1.2",
63
+ "@sinclair/typebox": "^0.34.52",
64
+ "apache-crypt": "1.2.6",
65
+ "dotenv": "17.4.2",
66
+ "fastify-session-redis-store": "7.1.2",
67
+ "file-type": "22.0.2",
68
+ "ioredis": "6.0.0",
69
+ "jose": "^6.2.12",
70
+ "otplib": "13.5.0",
71
+ "pg": "8.23.0",
72
+ "pino": "10.3.1",
73
+ "pino-abstract-transport": "3.0.0",
74
+ "qrcode": "1.5.4",
75
+ "sharp": "0.35.4"
76
+ },
77
+ "peerDependencies": {
78
+ "fastify": ">=5.12.1"
79
+ },
80
+ "devDependencies": {
81
+ "@types/node": "22.20.1",
82
+ "@types/passport": "1.0.17",
83
+ "@types/passport-local": "1.0.38",
84
+ "@types/pg": "8.23.1",
85
+ "@types/qrcode": "1.5.6",
86
+ "fastify": "5.12.1",
87
+ "javascript-obfuscator": "5.6.0",
88
+ "tsx": "4.23.13",
89
+ "typescript": "7.0.2",
90
+ "vitest": "4.1.11"
91
+ },
92
+ "license": "UNLICENSED"
93
+ }