@opengis/fcore 0.0.27 → 0.0.29

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 (108) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +71 -71
  3. package/dist/config.js +1 -1
  4. package/dist/context.js +1 -1
  5. package/dist/errors.js +1 -1
  6. package/dist/fastify.js +1 -1
  7. package/dist/fcore.js +1 -1
  8. package/dist/migrations/cli.js +1 -1
  9. package/dist/migrations/runner.js +1 -1
  10. package/dist/modules/auth/adduser-cli.js +1 -1
  11. package/dist/modules/auth/passwd-cli.js +1 -1
  12. package/dist/modules/auth/permission-cli.js +1 -1
  13. package/dist/modules/auth/route.js +1 -1
  14. package/dist/modules/auth/schema.js +1 -1
  15. package/dist/modules/auth/services/change-password.js +1 -1
  16. package/dist/modules/auth/services/get-current-user.js +1 -1
  17. package/dist/modules/auth/services/registration.js +1 -1
  18. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  19. package/dist/modules/file/mime.js +1 -1
  20. package/dist/modules/file/route.js +1 -1
  21. package/dist/modules/file/schema.js +1 -1
  22. package/dist/modules/file/services/get-file.js +1 -1
  23. package/dist/modules/file/services/resize-file.js +1 -1
  24. package/dist/modules/file/services/upload-file.js +1 -1
  25. package/dist/modules/resource/route.js +1 -1
  26. package/dist/modules/resource/schema.js +1 -1
  27. package/dist/modules/resource/services/add-note.js +1 -1
  28. package/dist/modules/resource/services/add-resource-file.js +1 -1
  29. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  30. package/dist/modules/resource/services/create-resource.js +1 -1
  31. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  32. package/dist/modules/resource/services/delete-resource.js +1 -1
  33. package/dist/modules/resource/services/export-resource.js +1 -1
  34. package/dist/modules/resource/services/generate-resource-code.js +1 -1
  35. package/dist/modules/resource/services/get-resource-schema.js +1 -1
  36. package/dist/modules/resource/services/get-resource.js +1 -1
  37. package/dist/modules/resource/services/list-resource-as-user.js +1 -1
  38. package/dist/modules/resource/services/list-resource-list.js +1 -1
  39. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  40. package/dist/modules/resource/services/list-resources.js +1 -1
  41. package/dist/modules/resource/services/search-resource.js +1 -1
  42. package/dist/modules/resource/services/suggest-resource.js +1 -1
  43. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  44. package/dist/modules/resource/services/update-resource.js +1 -1
  45. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  46. package/dist/modules/system/route.js +1 -1
  47. package/dist/modules/system/schema.js +1 -1
  48. package/dist/modules/system/services/check-system.js +1 -1
  49. package/dist/modules/system/services/get-access.js +1 -1
  50. package/dist/modules/system/services/get-api-list.js +1 -1
  51. package/dist/modules/system/services/get-audit-log.js +1 -1
  52. package/dist/modules/system/services/get-dictionary.js +1 -1
  53. package/dist/modules/system/services/get-resource-access.js +1 -1
  54. package/dist/modules/system/services/get-resource-scopes.js +1 -1
  55. package/dist/modules/system/services/get-system-log.js +1 -1
  56. package/dist/modules/system/services/get-system-settings.js +1 -1
  57. package/dist/modules/system/services/list-dictionaries.js +1 -1
  58. package/dist/modules/system/services/set-access.js +1 -1
  59. package/dist/modules/system/services/set-resource-access.js +1 -1
  60. package/dist/modules/system/services/set-resource-scopes.js +1 -1
  61. package/dist/modules/system/services/update-dictionary.js +1 -1
  62. package/dist/modules/system/services/update-system-settings.js +1 -1
  63. package/dist/modules/utils/require-admin.js +1 -1
  64. package/dist/modules/utils/safe-user.js +1 -1
  65. package/dist/modules/utils/unsupported.js +1 -1
  66. package/dist/plugins/audit/audit.js +1 -1
  67. package/dist/plugins/audit/services/write-audit.js +1 -1
  68. package/dist/plugins/auth/get-user-permissions.js +1 -1
  69. package/dist/plugins/auth/index.js +1 -1
  70. package/dist/plugins/auth/verifyUser.js +1 -1
  71. package/dist/plugins/dictionary.js +1 -1
  72. package/dist/plugins/file.js +1 -1
  73. package/dist/plugins/jwt.js +1 -1
  74. package/dist/plugins/logger/index.js +1 -1
  75. package/dist/plugins/logger/transport.js +1 -1
  76. package/dist/plugins/pg.js +1 -1
  77. package/dist/plugins/redis.js +1 -1
  78. package/dist/plugins/resource/resource.js +1 -1
  79. package/dist/plugins/resource/resource.registry.js +1 -1
  80. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  81. package/dist/plugins/resource/services/add-file-token.js +1 -1
  82. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  83. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
  84. package/dist/plugins/resource/services/create-relation.js +1 -1
  85. package/dist/plugins/resource/services/create.js +1 -1
  86. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
  87. package/dist/plugins/resource/services/delete-relation.js +1 -1
  88. package/dist/plugins/resource/services/delete.js +1 -1
  89. package/dist/plugins/resource/services/find-one.js +1 -1
  90. package/dist/plugins/resource/services/find-relation.js +1 -1
  91. package/dist/plugins/resource/services/find.js +1 -1
  92. package/dist/plugins/resource/services/get-table-columns.js +1 -1
  93. package/dist/plugins/resource/services/update-relation.js +1 -1
  94. package/dist/plugins/resource/services/update.js +1 -1
  95. package/dist/plugins/resource/utils/auto-index.js +1 -1
  96. package/dist/plugins/resource/utils/fields.js +1 -1
  97. package/dist/plugins/resource/utils/filters.js +1 -1
  98. package/dist/plugins/resource/utils/permissions.js +1 -1
  99. package/dist/plugins/resource/utils/scope.js +1 -1
  100. package/dist/plugins/resource/utils/sort.js +1 -1
  101. package/dist/plugins/resource/utils/sql.js +1 -1
  102. package/dist/plugins/resource/utils/summary.js +1 -1
  103. package/dist/shared/getIP.js +1 -1
  104. package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
  105. package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
  106. package/migrations/20260905120000_add_user_foreign_keys.sql +15 -0
  107. package/migrations/20260929120000_allow_user_only_role_scopes.sql +1 -1
  108. package/package.json +92 -92
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{buildFilters,buildIndex}from'../utils/filters.js';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';import{autoIndex}from'../utils/auto-index.js';function C(P,G){P=P-0x1bf;const j=m();let Z=j[P];return Z;}function m(){const N=['now','read','min','max','where','table','text','values','push','lower(',')\x20LIKE\x20$','length','scope','scopes','\x20WHERE\x20','true','sql','joins','item','join','\x20t\x20','replace','query','rowCount','fields'];m=function(){return N;};return m();}import{buildSummary}from'../utils/summary.js';import{buildUserResourceScopeFilter}from'../utils/scope.js';export function createFind(P,G){return async function j({name:Z,query:query={},user:q}){const O=C,p=Date[O(0x1bf)](),X=G['get'](Z);assertOperation(X,O(0x1c0),q);const F=Math[O(0x1c1)](Math['max'](query['limit']??0x14,0x1),0xc8),A=Math[O(0x1c2)](query['offset']??0x0,0x0);buildIndex(X,query['filter'],P['pg']);const H=buildFilters(X,query['filter']);X[O(0x1c3)]&&(H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+X[O(0x1c3)]+')'));const b=buildSort(X,query['sort']);if(!Number['isFinite'](F)||!Number['isFinite'](A))throw new ValidationError('Invalid\x20pagination');const E=X['searchable']||Object['keys'](X['fields'])['filter'](L=>X['fields'][L]?.['searchable']);query['search']&&E['length']&&(E['map'](L=>autoIndex(X[O(0x1c4)],L,O(0x1c5),P['pg'])),H[O(0x1c6)][O(0x1c7)](query['search']['toLowerCase']()+'%'),H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+E?.['map'](L=>O(0x1c8)+qt(L)+O(0x1c9)+H[O(0x1c6)][O(0x1ca)])['join']('\x20OR\x20')+')'));if(query[O(0x1cb)]&&X[O(0x1cc)]?.[query[O(0x1cb)]]===undefined)throw new ValidationError('Unknown\x20scope:\x20'+query[O(0x1cb)]);const z=query[O(0x1cb)]||(X[O(0x1cc)]?.['default']?'default':undefined);z&&(H['sql']+=(H['sql']?'\x20AND\x20':O(0x1cd))+('('+(X['scopes']?.[z]||O(0x1ce))+')'));const x=await buildUserResourceScopeFilter(X,q,P['pg'],H['values']['length']+0x1);x['sql']&&(H[O(0x1cf)]+=(H[O(0x1cf)]?'\x20AND\x20':'\x20WHERE\x20')+('('+x['sql']+')'),H[O(0x1c6)][O(0x1c7)](...x[O(0x1c6)]));const o=X[O(0x1d0)]?.['filter'](L=>L[O(0x1cb)]!==O(0x1d1))['map'](L=>L[O(0x1cf)]+'\x20')[O(0x1d2)]('\x20')||'',i='SELECT\x20'+readableFields(X,'all')['join'](',\x20')+'\x20'+('FROM\x20'+qt(X[O(0x1c4)])+O(0x1d3))+(o+'\x20'+H[O(0x1cf)][O(0x1d4)](/:uid/g,'\x27'+(q?.['id']??'NULL')+'\x27')+'\x20'+b+'\x20')+('LIMIT\x20$'+(H['values'][O(0x1ca)]+0x1)+'\x20')+('OFFSET\x20$'+(H['values']['length']+0x2)),y=buildSummary(X,query,q,x),[T,D]=await Promise['all']([P['pg'][O(0x1d5)](i,[...H['values'],F,A]),P['pg']['query'](y['sql'],y['values'])['then'](L=>L['rows'][0x0]??{})]),h=T['rows'];return await addDictionaryLookupData(h,X['fields'],P['dictionary']),await addTableLookupData(h,X['fields'],P['pg']),addFileToken(h,X['fields'],P['file']),{'time':Date[O(0x1bf)]()-p,'limit':F,'offset':A,'count':T[O(0x1d6)],'total':D?.['count']??0x0,'summary':D,'rows':h,...query['include']?.['includes'](O(0x1d7))?{'fields':X[O(0x1d7)]}:{}};};}
1
+ import{ValidationError}from'../../../errors.js';import{buildFilters,buildIndex}from'../utils/filters.js';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';function O(){const k=['get','read','max','limit','sql','\x20AND\x20','Invalid\x20pagination','fields','filter','map','text','values',')\x20LIKE\x20$','scope','\x20WHERE\x20','true','joins','join','NULL','LIMIT\x20$','length','dictionary','rowCount','include'];O=function(){return k;};return O();}import{autoIndex}from'../utils/auto-index.js';function c(S,Z){S=S-0x16c;const h=O();let U=h[S];return U;}import{buildSummary}from'../utils/summary.js';import{buildUserResourceScopeFilter}from'../utils/scope.js';export function createFind(S,Z){return async function h({name:U,query:query={},user:D}){const V=c,u=Date['now'](),e=Z[V(0x16c)](U);assertOperation(e,V(0x16d),D);const q=Math['min'](Math[V(0x16e)](query[V(0x16f)]??0x14,0x1),0xc8),x=Math['max'](query['offset']??0x0,0x0);buildIndex(e,query['filter'],S['pg']);const n=buildFilters(e,query['filter']);e['where']&&(n['sql']+=(n[V(0x170)]?V(0x171):'\x20WHERE\x20')+('('+e['where']+')'));const N=buildSort(e,query['sort']);if(!Number['isFinite'](q)||!Number['isFinite'](x))throw new ValidationError(V(0x172));const o=e['searchable']||Object['keys'](e[V(0x173)])[V(0x174)](L=>e['fields'][L]?.['searchable']);query['search']&&o['length']&&(o[V(0x175)](L=>autoIndex(e['table'],L,V(0x176),S['pg'])),n[V(0x177)]['push'](query['search']['toLowerCase']()+'%'),n['sql']+=(n[V(0x170)]?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+o?.['map'](L=>'lower('+qt(L)+V(0x178)+n[V(0x177)]['length'])['join']('\x20OR\x20')+')'));if(query['scope']&&e['scopes']?.[query['scope']]===undefined)throw new ValidationError('Unknown\x20scope:\x20'+query[V(0x179)]);const j=query['scope']||(e['scopes']?.['default']?'default':undefined);j&&(n['sql']+=(n[V(0x170)]?'\x20AND\x20':V(0x17a))+('('+(e['scopes']?.[j]||V(0x17b))+')'));const X=await buildUserResourceScopeFilter(e,D,S['pg'],n[V(0x177)]['length']+0x1);X['sql']&&(n[V(0x170)]+=(n[V(0x170)]?'\x20AND\x20':'\x20WHERE\x20')+('('+X['sql']+')'),n['values']['push'](...X['values']));const i=e[V(0x17c)]?.['filter'](L=>L[V(0x179)]!=='item')['map'](L=>L['sql']+'\x20')['join']('\x20')||'',l='SELECT\x20'+readableFields(e,'all')[V(0x17d)](',\x20')+'\x20'+('FROM\x20'+qt(e['table'])+'\x20t\x20')+(i+'\x20'+n['sql']['replace'](/:uid/g,'\x27'+(D?.['id']??V(0x17e))+'\x27')+'\x20'+N+'\x20')+(V(0x17f)+(n[V(0x177)][V(0x180)]+0x1)+'\x20')+('OFFSET\x20$'+(n['values']['length']+0x2)),b=buildSummary(e,query,D,X),[Y,r]=await Promise['all']([S['pg']['query'](l,[...n['values'],q,x]),S['pg']['query'](b['sql'],b['values'])['then'](L=>L['rows'][0x0]??{})]),E=Y['rows'];return await addDictionaryLookupData(E,e['fields'],S[V(0x181)]),await addTableLookupData(E,e['fields'],S['pg']),addFileToken(E,e[V(0x173)],S['file']),{'time':Date['now']()-u,'limit':q,'offset':x,'count':Y[V(0x182)],'total':r?.['count']??0x0,'summary':r,'rows':E,...query[V(0x183)]?.['includes']('fields')?{'fields':e['fields']}:{}};};}
@@ -1 +1 @@
1
- function m(){const p=['not\x20enough\x20params:\x20table','then'];m=function(){return p;};return m();}function C(P,G){P=P-0x134;const j=m();let Z=j[P];return Z;}export async function getTableColumns(P,G){const q=C;if(!P)throw new Error(q(0x134));if(!G?.['pg'])return[];const j=await G['pg']['query']('\x0a\x20\x20\x20\x20select\x0a\x20\x20\x20\x20\x20\x20\x20\x20attname\x20as\x20name,\x20pg_catalog.col_description(attrelid,attnum)\x20as\x20title\x0a\x20\x20\x20\x20from\x20pg_catalog.pg_attribute\x20where\x20attrelid=$1::regclass\x20and\x20attnum>0\x20and\x20NOT\x20attisdropped',[P])[q(0x135)](Z=>Z['rows']||[]);return j;}
1
+ function O(){const u=['rows'];O=function(){return u;};return O();}function c(S,Z){S=S-0xab;const h=O();let U=h[S];return U;}export async function getTableColumns(S,Z){const D=c;if(!S)throw new Error('not\x20enough\x20params:\x20table');if(!Z?.['pg'])return[];const h=await Z['pg']['query']('\x0a\x20\x20\x20\x20select\x0a\x20\x20\x20\x20\x20\x20\x20\x20attname\x20as\x20name,\x20pg_catalog.col_description(attrelid,attnum)\x20as\x20title\x0a\x20\x20\x20\x20from\x20pg_catalog.pg_attribute\x20where\x20attrelid=$1::regclass\x20and\x20attnum>0\x20and\x20NOT\x20attisdropped',[S])['then'](U=>U[D(0xab)]||[]);return h;}
@@ -1 +1 @@
1
- function C(P,G){P=P-0x96;const j=m();let Z=j[P];return Z;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function m(){const o=['relations','resource','foreignKey','Relation\x20update\x20is\x20not\x20configured:\x20','hasOwn'];m=function(){return o;};return m();}export function createUpdateRelation(P,G){const j=createUpdate(P,G);return async function Z({name:q,id:p,relation:X,relationId:F,data:A,user:H},b){const x=C,E=G['get'](q),z=E[x(0x96)]?.[X];if(!z?.[x(0x97)]||!z[x(0x98)])throw new UnsupportedError(x(0x99)+X);if(Object[x(0x9a)](A,z['foreignKey'])&&A[z[x(0x98)]]!==p)throw new ValidationError('Cannot\x20change\x20relation:\x20'+z[x(0x98)]);return j({'name':z['resource'],'id':F,'data':A,'user':H,'where':{'column':z[x(0x98)],'value':p}},b);};}
1
+ import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function O(){const i=['foreignKey'];O=function(){return i;};return O();}function c(S,Z){S=S-0x9c;const h=O();let U=h[S];return U;}export function createUpdateRelation(S,Z){const h=createUpdate(S,Z);return async function U({name:D,id:u,relation:e,relationId:q,data:x,user:n},N){const X=c,o=Z['get'](D),j=o['relations']?.[e];if(!j?.['resource']||!j['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+e);if(Object['hasOwn'](x,j['foreignKey'])&&x[j['foreignKey']]!==u)throw new ValidationError('Cannot\x20change\x20relation:\x20'+j['foreignKey']);return h({'name':j['resource'],'id':q,'data':x,'user':n,'where':{'column':j[X(0x9c)],'value':u}},N);};}
@@ -1 +1 @@
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 C(P,G){P=P-0x197;const j=m();let Z=j[P];return Z;}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(P,G){return async function j({name:Z,id:q,data:p,user:X,where:F},A){const h=C,H=G['get'](Z);assertOperation(H,'update',X);const b=writableData(H,p);if(!b['length'])throw new ValidationError('No\x20writable\x20fields');const E=A?.['pg']??P['pg'];validateInputData({'resource':H,'data':p,'update':!![]});H['fields']['updated_at']&&b[h(0x197)]([h(0x198),new Date()]);H[h(0x199)]['updated_by']&&b['push']([h(0x19a),X?.['id']]);delete p[h(0x19b)];const z=b['map'](([T],D)=>qi(T)+'\x20=\x20$'+(D+0x1)),x=[...b['map'](([,T])=>T),q];let o='WHERE\x20'+qi(H['key'])+'\x20=\x20$'+x['length'];F&&(x[h(0x197)](F['value']),o+='\x20AND\x20'+qi(F['column'])+'\x20=\x20$'+x['length']);H[h(0x19c)]&&(o+='\x20AND\x20('+H['where']+')');const i=await E['query']('UPDATE\x20'+qt(H['table'])+'\x20'+('SET\x20'+z['join'](',\x20')+'\x20')+(o+'\x20')+(h(0x19d)+Object['keys'](p)['map'](qi)['join'](',\x20')),x),y=i['rows'][0x0];if(!y)throw new NotFoundError(Z+':'+q);return clearTableLookupCache(H[h(0x19e)],E),await(A?.[h(0x19f)]??P[h(0x19f)])?.['write']({'userId':X?.['id'],'module':H['module'],'resource':H['name'],'resourceId':q,'action':'update','fields':Object[h(0x1a0)](p)}),y;};}function m(){const L=['push','updated_at','fields','updated_by','user_type','where','RETURNING\x20','table','audit','keys'];m=function(){return L;};return m();}
1
+ import{NotFoundError,ValidationError}from'../../../errors.js';function O(){const L=['update','length','No\x20writable\x20fields','fields','updated_by','push','map','\x20=\x20$','where','query','join','table','module'];O=function(){return L;};return O();}import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';function c(S,Z){S=S-0xea;const h=O();let U=h[S];return U;}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(S,Z){return async function h({name:U,id:D,data:u,user:e,where:q},x){const E=c,n=Z['get'](U);assertOperation(n,E(0xea),e);const N=writableData(n,u);if(!N[E(0xeb)])throw new ValidationError(E(0xec));const o=x?.['pg']??S['pg'];validateInputData({'resource':n,'data':u,'update':!![]});n['fields']['updated_at']&&N['push'](['updated_at',new Date()]);n[E(0xed)][E(0xee)]&&N[E(0xef)](['updated_by',e?.['id']]);delete u['user_type'];const j=N[E(0xf0)](([Y],r)=>qi(Y)+E(0xf1)+(r+0x1)),X=[...N[E(0xf0)](([,Y])=>Y),D];let i='WHERE\x20'+qi(n['key'])+'\x20=\x20$'+X['length'];q&&(X['push'](q['value']),i+='\x20AND\x20'+qi(q['column'])+'\x20=\x20$'+X['length']);n[E(0xf2)]&&(i+='\x20AND\x20('+n['where']+')');const l=await o[E(0xf3)]('UPDATE\x20'+qt(n['table'])+'\x20'+('SET\x20'+j['join'](',\x20')+'\x20')+(i+'\x20')+('RETURNING\x20'+Object['keys'](u)['map'](qi)[E(0xf4)](',\x20')),X),b=l['rows'][0x0];if(!b)throw new NotFoundError(U+':'+D);return clearTableLookupCache(n[E(0xf5)],o),await(x?.['audit']??S['audit'])?.['write']({'userId':e?.['id'],'module':n[E(0xf6)],'resource':n['name'],'resourceId':D,'action':E(0xea),'fields':Object['keys'](u)}),b;};}
@@ -1 +1 @@
1
- import{qi,qt}from'./sql.js';function C(P,G){P=P-0x72;const j=m();let Z=j[P];return Z;}const requestedIndexes=new WeakMap();export function autoIndex(P,G,j='btree',Z){const A=C,q=requestedIndexes['get'](Z)??new Set();requestedIndexes['set'](Z,q);const p=P+':'+G+':'+j;if(q[A(0x72)](p))return;q[A(0x73)](p),void ensureIndex(P,G,j,Z)[A(0x74)](()=>{q['delete'](p);});}async function ensureIndex(P,G,j,Z){const H=C,q=P['split']('.'),p=q['length']===0x2?q[0x0]:'public',X=(P+'_'+G+'_'+j+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),F=await Z[H(0x75)]('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[p,X]);if(F[H(0x76)])return;if(j===H(0x77)){await Z['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await Z['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(X+'_l')+'\x20ON\x20'+qt(P)+'\x20USING\x20btree\x20(lower('+qi(G)+')\x20text_pattern_ops)'),await Z['query'](H(0x78)+qi(X)+'\x20ON\x20'+qt(P)+'\x20USING\x20gin\x20(lower('+qi(G)+')\x20gin_trgm_ops)');return;}await Z[H(0x75)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(X)+'\x20ON\x20'+qt(P)+'\x20USING\x20'+j+'\x20('+qi(G)+')');}function m(){const b=['has','add','catch','query','rowCount','text','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'];m=function(){return b;};return m();}
1
+ const x=c;import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(S,Z,h=x(0x152),U){const n=x,D=requestedIndexes['get'](U)??new Set();requestedIndexes['set'](U,D);const u=S+':'+Z+':'+h;if(D['has'](u))return;D['add'](u),void ensureIndex(S,Z,h,U)[n(0x153)](()=>{D['delete'](u);});}function c(S,Z){S=S-0x152;const h=O();let U=h[S];return U;}function O(){const o=['btree','catch','length','query','\x20USING\x20btree\x20(lower(',')\x20text_pattern_ops)','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20','\x20USING\x20gin\x20(lower('];O=function(){return o;};return O();}async function ensureIndex(S,Z,h,U){const N=x,D=S['split']('.'),u=D[N(0x154)]===0x2?D[0x0]:'public',e=(S+'_'+Z+'_'+h+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),q=await U['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[u,e]);if(q['rowCount'])return;if(h==='text'){await U['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await U[N(0x155)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(e+'_l')+'\x20ON\x20'+qt(S)+N(0x156)+qi(Z)+N(0x157)),await U['query'](N(0x158)+qi(e)+'\x20ON\x20'+qt(S)+N(0x159)+qi(Z)+')\x20gin_trgm_ops)');return;}await U['query'](N(0x158)+qi(e)+'\x20ON\x20'+qt(S)+'\x20USING\x20'+h+'\x20('+qi(Z)+')');}
@@ -1 +1 @@
1
- function m(){const p=['entries','fields','writable','length','minLength\x20not\x20met:\x20','\x20should\x20be\x20>=\x20','number','maximum','enum','pattern','\x20should\x20match\x20regular\x20expression\x20('];m=function(){return p;};return m();}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function C(P,G){P=P-0x1ab;const j=m();let Z=j[P];return Z;}const validateInputData=({resource:P,data:G,update:update=![]})=>{const q=C;for(const [j,Z]of Object[q(0x1ab)](P[q(0x1ac)])){if(Z['required']&&Z[q(0x1ad)]!==![]&&(G[j]===undefined||G[j]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+j);if(Z['required']&&Z['writable']!==![]&&Object['hasOwn'](G,j)&&(G[j]===undefined||G[j]===null)&&update)throw new ValidationError('Required\x20field:\x20'+j);if(Z['minLength']&&typeof G[j]==='string'&&G[j][q(0x1ae)]<Z['minLength'])throw new ValidationError(q(0x1af)+j);if(Z['maxLength']&&typeof G[j]==='string'&&G[j][q(0x1ae)]>Z['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+j);if(Z['minimum']&&typeof G[j]==='number'&&G[j]<Z['minimum'])throw new ValidationError(j+q(0x1b0)+Z['minimum']);if(Z['maximum']&&typeof G[j]===q(0x1b1)&&G[j]>Z[q(0x1b2)])throw new ValidationError(j+'\x20should\x20be\x20<=\x20'+Z['maximum']);if(Z['enum']&&G[j]&&!Z[q(0x1b3)]['includes'](G[j]))throw new ValidationError(j+'\x20should\x20be\x20one\x20of\x20('+Z['enum']['join'](',\x20')+')');if(Z['pattern']&&typeof G[j]==='string'&&!new RegExp(Z[q(0x1b4)])['test'](G[j]))throw new ValidationError(j+q(0x1b5)+Z[q(0x1b4)]+')');}};export{validateInputData};
1
+ function O(){const u=['entries','fields','writable','Required\x20field:\x20','minLength','string','minLength\x20not\x20met:\x20','maxLength\x20exceeded:\x20','minimum','\x20should\x20be\x20>=\x20','pattern'];O=function(){return u;};return O();}function c(S,Z){S=S-0x128;const h=O();let U=h[S];return U;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:S,data:Z,update:update=![]})=>{const D=c;for(const [h,U]of Object[D(0x128)](S[D(0x129)])){if(U['required']&&U[D(0x12a)]!==![]&&(Z[h]===undefined||Z[h]===null)&&!update)throw new ValidationError(D(0x12b)+h);if(U['required']&&U[D(0x12a)]!==![]&&Object['hasOwn'](Z,h)&&(Z[h]===undefined||Z[h]===null)&&update)throw new ValidationError('Required\x20field:\x20'+h);if(U[D(0x12c)]&&typeof Z[h]===D(0x12d)&&Z[h]['length']<U['minLength'])throw new ValidationError(D(0x12e)+h);if(U['maxLength']&&typeof Z[h]==='string'&&Z[h]['length']>U['maxLength'])throw new ValidationError(D(0x12f)+h);if(U['minimum']&&typeof Z[h]==='number'&&Z[h]<U[D(0x130)])throw new ValidationError(h+D(0x131)+U[D(0x130)]);if(U['maximum']&&typeof Z[h]==='number'&&Z[h]>U['maximum'])throw new ValidationError(h+'\x20should\x20be\x20<=\x20'+U['maximum']);if(U['enum']&&Z[h]&&!U['enum']['includes'](Z[h]))throw new ValidationError(h+'\x20should\x20be\x20one\x20of\x20('+U['enum']['join'](',\x20')+')');if(U['pattern']&&typeof Z[h]==='string'&&!new RegExp(U[D(0x132)])['test'](Z[h]))throw new ValidationError(h+'\x20should\x20match\x20regular\x20expression\x20('+U['pattern']+')');}};export{validateInputData};
@@ -1 +1 @@
1
- const i=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','lte','in','nin','like','ilike',i(0x17d)]);function C(P,G){P=P-0x17d;const j=m();let Z=j[P];return Z;}export function parseFilterQuery(P){const y=i,G={...isRecord(P['filter'])?P['filter']:{}};for(const [j,Z]of Object['entries'](P)){const q=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/[y(0x17e)](j);if(!q)continue;const [,p,X]=q;if(!p)continue;if(!X){G[p]=Z;continue;}if(!filterOperators[y(0x17f)](X))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+X);const F=isRecord(G[p])?G[p]:{};F[X]=(X==='in'||X===y(0x180))&&typeof Z==='string'?Z['split'](','):Z,G[p]=F;}return Object['keys'](G)['length']?G:undefined;}export function buildIndex(P,G,j){const T=i;for(const [Z,q]of Object['entries'](G??{})){const p=P[T(0x181)][Z];if(!p||p['filter']!==!![]&&p['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+Z);j&&autoIndex(P[T(0x182)],fieldColumn(P,Z),indexTypeFor(p['type'],'eq'),j);}}export function buildFilters(P,G,j=0x1){const D=i,Z=[],q=[];for(const [p,X]of Object['entries'](G??{})){const F=P['fields'][p];if(!F||F[D(0x183)]!==!![]&&F[D(0x184)]!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+p);const A=qi(fieldColumn(P,p)),H=isRecord(X)?X:{'eq':X};for(const [b,E]of Object['entries'](H)){if(!filterOperators['has'](b))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+b);if((b==='like'||b==='ilike')&&F[D(0x185)]!=='string'&&F['type']!=='text')throw new ValidationError('Operator\x20'+b+'\x20requires\x20a\x20text\x20field:\x20'+p);if(b==='null'){Z['push'](A+'\x20IS\x20'+(isTruthy(E)?'':'NOT\x20')+D(0x186));continue;}if(b==='in'||b==='nin'){const o=Array['isArray'](E)?E:[E];if(o[D(0x187)]===0x0){Z[D(0x188)](b==='in'?D(0x189):'TRUE');continue;}q['push'](o),Z[D(0x188)](A+'\x20'+(b==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(j+q['length']-0x1)+')');continue;}const z={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},x='$'+(j+q[D(0x187)]);if(b==='like'){q[D(0x188)](E+'%'),Z['push'](D(0x18a)+A+')\x20like\x20lower('+x+')');continue;}q[D(0x188)](E),Z[D(0x188)](A+'\x20'+z[b]+'\x20'+x);}}return{'sql':Z[D(0x187)]?D(0x18b)+Z[D(0x18c)](D(0x18d)):'','values':q};}function m(){const O=['null','exec','has','nin','fields','table','filter','filterable','type','NULL','length','push','FALSE','lower(','\x20WHERE\x20','join','\x20AND\x20','object','isArray','like','text','geom'];m=function(){return O;};return m();}function isRecord(P){const h=i;return typeof P===h(0x18e)&&P!==null&&!Array[h(0x18f)](P);}function isTruthy(P){return P===!![]||P==='true'||P==='1'||P===0x1;}function indexTypeFor(P,G){const L=i;if(G===L(0x190)||G==='ilike')return L(0x191);if(P===L(0x192)||P==='geometry')return'gist';return'btree';}
1
+ import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';function O(){const L=['exec','Unsupported\x20filter\x20operator:\x20','keys','entries','fields','filter','has','type','text','Operator\x20','\x20IS\x20','isArray','push','\x20WHERE\x20','like','geom'];O=function(){return L;};return O();}const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin','like','ilike','null']);export function parseFilterQuery(S){const l=c,Z={...isRecord(S['filter'])?S['filter']:{}};for(const [h,U]of Object['entries'](S)){const D=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/[l(0x167)](h);if(!D)continue;const [,u,e]=D;if(!u)continue;if(!e){Z[u]=U;continue;}if(!filterOperators['has'](e))throw new ValidationError(l(0x168)+e);const q=isRecord(Z[u])?Z[u]:{};q[e]=(e==='in'||e==='nin')&&typeof U==='string'?U['split'](','):U,Z[u]=q;}return Object[l(0x169)](Z)['length']?Z:undefined;}function c(S,Z){S=S-0x167;const h=O();let U=h[S];return U;}export function buildIndex(S,Z,h){const b=c;for(const [U,D]of Object[b(0x16a)](Z??{})){const u=S[b(0x16b)][U];if(!u||u['filter']!==!![]&&u['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+U);h&&autoIndex(S['table'],fieldColumn(S,U),indexTypeFor(u['type'],'eq'),h);}}export function buildFilters(S,Z,h=0x1){const Y=c,U=[],D=[];for(const [u,e]of Object['entries'](Z??{})){const q=S['fields'][u];if(!q||q[Y(0x16c)]!==!![]&&q['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+u);const x=qi(fieldColumn(S,u)),n=isRecord(e)?e:{'eq':e};for(const [N,o]of Object['entries'](n)){if(!filterOperators[Y(0x16d)](N))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+N);if((N==='like'||N==='ilike')&&q[Y(0x16e)]!=='string'&&q['type']!==Y(0x16f))throw new ValidationError(Y(0x170)+N+'\x20requires\x20a\x20text\x20field:\x20'+u);if(N==='null'){U['push'](x+Y(0x171)+(isTruthy(o)?'':'NOT\x20')+'NULL');continue;}if(N==='in'||N==='nin'){const i=Array[Y(0x172)](o)?o:[o];if(i['length']===0x0){U['push'](N==='in'?'FALSE':'TRUE');continue;}D[Y(0x173)](i),U[Y(0x173)](x+'\x20'+(N==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(h+D['length']-0x1)+')');continue;}const j={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},X='$'+(h+D['length']);if(N==='like'){D[Y(0x173)](o+'%'),U['push']('lower('+x+')\x20like\x20lower('+X+')');continue;}D[Y(0x173)](o),U['push'](x+'\x20'+j[N]+'\x20'+X);}}return{'sql':U['length']?Y(0x174)+U['join']('\x20AND\x20'):'','values':D};}function isRecord(S){const r=c;return typeof S==='object'&&S!==null&&!Array[r(0x172)](S);}function isTruthy(S){return S===!![]||S==='true'||S==='1'||S===0x1;}function indexTypeFor(S,Z){const E=c;if(Z===E(0x175)||Z==='ilike')return E(0x16f);if(S===E(0x176)||S==='geometry')return'gist';return'btree';}
@@ -1 +1 @@
1
- function C(P,G){P=P-0x175;const j=m();let Z=j[P];return Z;}function m(){const X=['public','Authentication\x20required','type','permissions','includes','Missing\x20permission:\x20'];m=function(){return X;};return m();}import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';export function assertOperation(P,G,j){const p=C,Z=getContext()['config'];if(Z['debug'])return;if(!P['operations']['includes'](G))throw new ForbiddenError(P['name']+'.'+G+'\x20is\x20disabled');if(P['access']!==p(0x175)&&j===undefined)throw new ForbiddenError(p(0x176));if(P['access']==='admin'&&j?.[p(0x177)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(j?.['type']!=='admin'){const q=(P['permission']??P['name'])+':'+G;if(!j?.[p(0x178)]?.[p(0x179)](q))throw new ForbiddenError(p(0x17a)+q);}}
1
+ function c(S,Z){S=S-0x75;const h=O();let U=h[S];return U;}import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';export function assertOperation(S,Z,h){const u=c,U=getContext()[u(0x75)];if(U['debug'])return;if(!S['operations']['includes'](Z))throw new ForbiddenError(S['name']+'.'+Z+u(0x76));if(S['access']!=='public'&&h===undefined)throw new ForbiddenError(u(0x77));if(S['access']==='admin'&&h?.[u(0x78)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(h?.['type']!=='admin'){const D=(S['permission']??S['name'])+':'+Z;if(!h?.['permissions']?.[u(0x79)](D))throw new ForbiddenError('Missing\x20permission:\x20'+D);}}function O(){const e=['config','\x20is\x20disabled','Authentication\x20required','type','includes'];O=function(){return e;};return O();}
@@ -1 +1 @@
1
- function C(P,G){P=P-0xe7;const j=m();let Z=j[P];return Z;}import{ValidationError}from'../../../errors.js';import{qi}from'./sql.js';const scopeCache=new Map(),CACHE_TTL_MS=0x7530;export function clearResourceScopeCache(P,G){const E=C;if(P&&G){scopeCache[E(0xe7)](P+':'+G);return;}if(P){for(const j of scopeCache['keys']()){if(j['startsWith'](P+':'))scopeCache['delete'](j);}return;}scopeCache[E(0xe8)]();}function m(){const y=['delete','clear','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)','scope','set','now','key','user_id','user_uid','created_by','name','push','\x20=\x20$','(FALSE)','join'];m=function(){return y;};return m();}async function loadScopeRows(P,G,j){const z=C,Z=P+':'+G,q=scopeCache['get'](Z);if(q&&q['expiresAt']>Date['now']())return q['promise'];const p=j['query'](z(0xe9),[P,G])['then'](({rows:X})=>{const x=z,F=new Map();for(const A of X){const H=F['get'](A['scope'])??[];if(Array['isArray'](A['value']))H['push'](...A['value']);else{if(A['value']!==null&&A['value']!==undefined)H['push'](A['value']);}F['set'](A[x(0xea)],H);}return F;})['catch'](X=>{scopeCache['delete'](Z);throw X;});return scopeCache[z(0xeb)](Z,{'expiresAt':Date[z(0xec)]()+CACHE_TTL_MS,'promise':p}),p;}export async function getUserResourceScopes(P,G,j){const Z=await loadScopeRows(P,G,j);return Object['fromEntries']([...Z]['map'](([q,p])=>[q,q==='me'?P:p]));}function columnForScope(P,G){const o=C;if(G===P['name'])return P[o(0xed)];if(G==='me'){const Z=[o(0xee),o(0xef),'owner_id',o(0xf0)]['find'](q=>P['fields'][q]);if(!Z)throw new ValidationError('Cannot\x20apply\x20\x22me\x22\x20scope\x20to\x20resource\x20without\x20an\x20owner\x20field:\x20'+P[o(0xf1)]);return P['fields'][Z]?.['column']??Z;}const j=P['fields'][G];if(!j)return'';return j['column']??G;}export async function buildUserResourceScopeFilter(P,G,j,Z){const i=C;if(!G||G['type']==='admin')return{'sql':'','values':[]};const q=await loadScopeRows(G['id'],P[i(0xf1)],j),p=[],X=[];for(const [F,A]of q){const H=columnForScope(P,F);if(!H){p['push']('(FALSE)');continue;}const b='t.'+qi(H);if(F==='me'){X['push'](G['id']),p[i(0xf2)]('('+b+i(0xf3)+(Z+X['length']-0x1)+')');continue;}if(A['length']===0x0){p['push'](i(0xf4));continue;}X['push'](A),p['push']('('+b+'\x20=\x20ANY($'+(Z+X['length']-0x1)+'))');}return{'sql':p[i(0xf5)]('\x20AND\x20'),'values':X};}
1
+ import{ValidationError}from'../../../errors.js';import{qi}from'./sql.js';const scopeCache=new Map(),CACHE_TTL_MS=0x7530;export function clearResourceScopeCache(S,Z){const o=c;if(S&&Z){scopeCache[o(0x1e8)](S+':'+Z);return;}if(S){for(const h of scopeCache[o(0x1e9)]()){if(h[o(0x1ea)](S+':'))scopeCache['delete'](h);}return;}scopeCache['clear']();}async function loadScopeRows(S,Z,h){const j=c,U=S+':'+Z,D=scopeCache[j(0x1eb)](U);if(D&&D['expiresAt']>Date[j(0x1ec)]())return D['promise'];const u=h[j(0x1ed)]('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)',[S,Z])['then'](({rows:e})=>{const X=j,q=new Map();for(const x of e){const n=q['get'](x['scope'])??[];if(Array['isArray'](x['value']))n[X(0x1ee)](...x['value']);else{if(x['value']!==null&&x['value']!==undefined)n['push'](x['value']);}q['set'](x[X(0x1ef)],n);}return q;})['catch'](e=>{scopeCache['delete'](U);throw e;});return scopeCache['set'](U,{'expiresAt':Date['now']()+CACHE_TTL_MS,'promise':u}),u;}export async function getUserResourceScopes(S,Z,h){const i=c,U=await loadScopeRows(S,Z,h);return Object['fromEntries']([...U][i(0x1f0)](([D,u])=>[D,D==='me'?S:u]));}function columnForScope(S,Z){const l=c;if(Z===S['name'])return S['key'];if(Z==='me'){const U=['user_id',l(0x1f1),l(0x1f2),'created_by']['find'](D=>S['fields'][D]);if(!U)throw new ValidationError(l(0x1f3)+S[l(0x1f4)]);return S[l(0x1f5)][U]?.['column']??U;}const h=S['fields'][Z];if(!h)return'';return h['column']??Z;}export async function buildUserResourceScopeFilter(S,Z,h,U){const b=c;if(!Z||Z['type']==='admin')return{'sql':'','values':[]};const D=await loadScopeRows(Z['id'],S[b(0x1f4)],h),u=[],e=[];for(const [q,x]of D){const n=columnForScope(S,q);if(!n){u['push'](b(0x1f6));continue;}const N='t.'+qi(n);if(q==='me'){e[b(0x1ee)](Z['id']),u['push']('('+N+b(0x1f7)+(U+e[b(0x1f8)]-0x1)+')');continue;}if(x['length']===0x0){u['push']('(FALSE)');continue;}e['push'](x),u[b(0x1ee)]('('+N+b(0x1f9)+(U+e[b(0x1f8)]-0x1)+'))');}return{'sql':u[b(0x1fa)](b(0x1fb)),'values':e};}function c(S,Z){S=S-0x1e8;const h=O();let U=h[S];return U;}function O(){const Y=['delete','keys','startsWith','get','now','query','push','scope','map','user_uid','owner_id','Cannot\x20apply\x20\x22me\x22\x20scope\x20to\x20resource\x20without\x20an\x20owner\x20field:\x20','name','fields','(FALSE)','\x20=\x20$','length','\x20=\x20ANY($','join','\x20AND\x20'];O=function(){return Y;};return O();}
@@ -1 +1 @@
1
- function m(){const H=['startsWith','slice','sortable','\x20ORDER\x20BY\x20'];m=function(){return H;};return m();}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function C(P,G){P=P-0x105;const j=m();let Z=j[P];return Z;}export function buildSort(P,G){const A=C;if(!G?.['length'])return'';typeof G==='string'&&(G=[G]);const j=G['map'](Z=>{const F=C,q=Z[F(0x105)]('-'),p=q?Z[F(0x106)](0x1):Z,X=P['fields'][p];if(!X||X[F(0x107)]!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+p);return qi(fieldColumn(P,p))+'\x20'+(q?'DESC':'ASC');});return A(0x108)+j['join'](',\x20');}
1
+ function c(S,Z){S=S-0x159;const h=O();let U=h[S];return U;}import{fieldColumn,qi}from'./sql.js';function O(){const n=['string','sortable','Field\x20is\x20not\x20sortable:\x20','DESC','ASC','\x20ORDER\x20BY\x20'];O=function(){return n;};return O();}import{ValidationError}from'../../../errors.js';export function buildSort(S,Z){const q=c;if(!Z?.['length'])return'';typeof Z===q(0x159)&&(Z=[Z]);const h=Z['map'](U=>{const x=q,D=U['startsWith']('-'),u=D?U['slice'](0x1):U,e=S['fields'][u];if(!e||e[x(0x15a)]!==!![])throw new ValidationError(x(0x15b)+u);return qi(fieldColumn(S,u))+'\x20'+(D?x(0x15c):x(0x15d));});return q(0x15e)+h['join'](',\x20');}
@@ -1 +1 @@
1
- const X=C;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=P=>'\x22'+P[X(0x14f)](/"/g,'\x22\x22')+'\x22';export const quoteTable=P=>P['split']('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(P,G){const F=X;if(G===P['key'])return P['key'];const j=P[F(0x150)][G];if(!j)throw new ValidationError('Unknown\x20field:\x20'+G);return j['column']??G;}export function readableFields(P,G){const A=X,j=Object['entries'](P['fields'])['filter'](([,Z])=>Z[A(0x151)]!==![]&&Z[A(0x152)]!==![]&&(G?(Z['scope']??A(0x153))===G:!![]))['map'](([Z,q])=>quoteIdentifier(q['column']??Z)+A(0x154)+quoteIdentifier(Z));return!P['fields'][P[A(0x155)]]&&j['unshift'](quoteIdentifier(P['key'])),j;}function C(P,G){P=P-0x14f;const j=m();let Z=j[P];return Z;}export function writableData(P,G){const H=X,j=[];for(const [Z,q]of Object['entries'](G)){const p=P['fields'][Z];if(!p||p[H(0x156)]===![]||p[H(0x157)]===![])throw new ValidationError(H(0x158)+Z);if((p['write']??p['writable'])!==!![])continue;if(p['type']==='date'&&!G[Z])continue;j['push']([p['column']??Z,q]);}return j;}export const qi=quoteIdentifier;function m(){const b=['replace','fields','read','readable','all','\x20AS\x20','key','write','writable','Field\x20is\x20not\x20writable:\x20'];m=function(){return b;};return m();}export const qt=quoteTable;
1
+ function O(){const N=['split','join','Unknown\x20field:\x20','column','entries','read','all','key','write'];O=function(){return N;};return O();}const e=c;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=S=>'\x22'+S['replace'](/"/g,'\x22\x22')+'\x22';export const quoteTable=S=>S[e(0x113)]('.')['map'](quoteIdentifier)[e(0x114)]('.');export function fieldColumn(S,Z){const q=e;if(Z===S['key'])return S['key'];const h=S['fields'][Z];if(!h)throw new ValidationError(q(0x115)+Z);return h[q(0x116)]??Z;}export function readableFields(S,Z){const x=e,h=Object[x(0x117)](S['fields'])['filter'](([,U])=>U[x(0x118)]!==![]&&U['readable']!==![]&&(Z?(U['scope']??x(0x119))===Z:!![]))['map'](([U,D])=>quoteIdentifier(D['column']??U)+'\x20AS\x20'+quoteIdentifier(U));return!S['fields'][S[x(0x11a)]]&&h['unshift'](quoteIdentifier(S[x(0x11a)])),h;}export function writableData(S,Z){const n=e,h=[];for(const [U,D]of Object['entries'](Z)){const u=S['fields'][U];if(!u||u[n(0x11b)]===![]||u['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+U);if((u['write']??u['writable'])!==!![])continue;if(u['type']==='date'&&!Z[U])continue;h['push']([u['column']??U,D]);}return h;}export const qi=quoteIdentifier;function c(S,Z){S=S-0x113;const h=O();let U=h[S];return U;}export const qt=quoteTable;
@@ -1 +1 @@
1
- function m(){const i=['sql','countDistinct','true','))::int\x20AS\x20\x22','sum','field','avg','where','\x20AND\x20','\x20WHERE\x20','default','scopes','keys','fields','search',')\x20LIKE\x20$','values','scope','map','SELECT\x20','table','replace','NULL'];m=function(){return i;};return m();}function C(P,G){P=P-0x1da;const j=m();let Z=j[P];return Z;}import{buildFilters}from'./filters.js';import{qt}from'./sql.js';const defaultSummary={'count':{'aggregate':'count'}};export function buildSummary(P,G,j,Z){const o=C,q={...defaultSummary,...P['summary']??{}},p=Object['entries'](q)['map'](([E,z])=>{const x=C;if(x(0x1da)in z)return'('+z['sql']+')\x20AS\x20\x22'+E+'\x22';switch(z['aggregate']){case'count':return'(COUNT(*)\x20FILTER\x20(where\x20'+(z['where']??'true')+'))::int\x20AS\x20\x22'+E+'\x22';case x(0x1db):return'(COUNT(DISTINCT\x20t.'+qt(z['field'])+')\x20FILTER\x20(where\x20'+(z['where']??x(0x1dc))+x(0x1dd)+E+'\x22';case x(0x1de):return'SUM('+z[x(0x1df)]+')\x20FILTER\x20(where\x20'+(z['where']??'true')+')\x20AS\x20\x22'+E+'\x22';case x(0x1e0):return'AVG('+z['field']+')\x20FILTER\x20(where\x20'+(z['where']??x(0x1dc))+')\x20AS\x20\x22'+E+'\x22';case'min':return'MIN('+z['field']+')\x20FILTER\x20(where\x20'+(z[x(0x1e1)]??x(0x1dc))+')\x20AS\x20\x22'+E+'\x22';case'max':return'MAX('+z['field']+')\x20FILTER\x20(where\x20'+(z['where']??x(0x1dc))+')\x20AS\x20\x22'+E+'\x22';}}),X=buildFilters(P,G['filter']);P['where']&&(X['sql']+=(X['sql']?o(0x1e2):o(0x1e3))+('('+P[o(0x1e1)]+')'));const F=G['scope']||(P['scopes']?.['default']?o(0x1e4):undefined);F&&(X['sql']+=(X[o(0x1da)]?o(0x1e2):o(0x1e3))+('('+(P[o(0x1e5)]?.[F]||'true')+')'));const A=P['searchable']||Object[o(0x1e6)](P[o(0x1e7)])['filter'](E=>P['fields'][E]?.['searchable']);G[o(0x1e8)]&&A['length']&&(X['values']['push'](G['search']['toLowerCase']()+'%'),X['sql']+=(X['sql']?o(0x1e2):o(0x1e3))+('\x20('+A['map'](E=>'lower('+qt(E)+o(0x1e9)+X[o(0x1ea)]['length'])['join']('\x20OR\x20')+')'));Z?.[o(0x1da)]&&(X['sql']+=(X['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+Z[o(0x1da)]+')'),X['values']['push'](...Z['values']));const H=P['joins']?.['filter'](E=>E[o(0x1eb)]!=='item')[o(0x1ec)](E=>E['sql']+'\x20')['join']('\x20')||'',b=o(0x1ed)+p['join'](',\x20')+'\x20'+('FROM\x20'+qt(P[o(0x1ee)])+'\x20t\x20')+(H+'\x20'+X[o(0x1da)][o(0x1ef)](/:uid/g,'\x27'+(j?.['id']??o(0x1f0))+'\x27'));return{'sql':b,'values':X['values']};}
1
+ import{buildFilters}from'./filters.js';function c(S,Z){S=S-0x16b;const h=O();let U=h[S];return U;}import{qt}from'./sql.js';const defaultSummary={'count':{'aggregate':'count'}};export function buildSummary(S,Z,h,U){const X=c,D={...defaultSummary,...S['summary']??{}},u=Object[X(0x16b)](D)[X(0x16c)](([o,j])=>{const i=X;if('sql'in j)return'('+j['sql']+')\x20AS\x20\x22'+o+'\x22';switch(j['aggregate']){case'count':return'(COUNT(*)\x20FILTER\x20(where\x20'+(j[i(0x16d)]??'true')+'))::int\x20AS\x20\x22'+o+'\x22';case'countDistinct':return'(COUNT(DISTINCT\x20t.'+qt(j[i(0x16e)])+')\x20FILTER\x20(where\x20'+(j['where']??'true')+'))::int\x20AS\x20\x22'+o+'\x22';case'sum':return i(0x16f)+j['field']+')\x20FILTER\x20(where\x20'+(j['where']??i(0x170))+')\x20AS\x20\x22'+o+'\x22';case i(0x171):return i(0x172)+j['field']+')\x20FILTER\x20(where\x20'+(j['where']??'true')+')\x20AS\x20\x22'+o+'\x22';case'min':return'MIN('+j['field']+')\x20FILTER\x20(where\x20'+(j['where']??'true')+')\x20AS\x20\x22'+o+'\x22';case'max':return i(0x173)+j['field']+i(0x174)+(j[i(0x16d)]??'true')+')\x20AS\x20\x22'+o+'\x22';}}),e=buildFilters(S,Z['filter']);S['where']&&(e[X(0x175)]+=(e['sql']?'\x20AND\x20':X(0x176))+('('+S['where']+')'));const q=Z['scope']||(S['scopes']?.[X(0x177)]?'default':undefined);q&&(e[X(0x175)]+=(e['sql']?X(0x178):'\x20WHERE\x20')+('('+(S['scopes']?.[q]||'true')+')'));const x=S['searchable']||Object['keys'](S['fields'])[X(0x179)](o=>S[X(0x17a)][o]?.['searchable']);Z['search']&&x[X(0x17b)]&&(e['values']['push'](Z[X(0x17c)]['toLowerCase']()+'%'),e['sql']+=(e['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+x['map'](o=>X(0x17d)+qt(o)+X(0x17e)+e['values']['length'])['join']('\x20OR\x20')+')'));U?.['sql']&&(e['sql']+=(e['sql']?X(0x178):'\x20WHERE\x20')+('('+U['sql']+')'),e['values']['push'](...U['values']));const n=S['joins']?.['filter'](o=>o[X(0x17f)]!=='item')['map'](o=>o[X(0x175)]+'\x20')['join']('\x20')||'',N='SELECT\x20'+u[X(0x180)](',\x20')+'\x20'+('FROM\x20'+qt(S['table'])+'\x20t\x20')+(n+'\x20'+e['sql']['replace'](/:uid/g,'\x27'+(h?.['id']??'NULL')+'\x27'));return{'sql':N,'values':e['values']};}function O(){const l=['entries','map','where','field','SUM(','true','avg','AVG(','MAX(',')\x20FILTER\x20(where\x20','sql','\x20WHERE\x20','default','\x20AND\x20','filter','fields','length','search','lower(',')\x20LIKE\x20$','scope','join'];O=function(){return l;};return O();}
@@ -1 +1 @@
1
- function C(P,G){P=P-0x1a5;const j=m();let Z=j[P];return Z;}function m(){const j=['headers','connection','pop'];m=function(){return j;};return m();}const G=C,getIP=P=>(P['headers']?.['x-real-ip']||P[G(0x1a5)]?.['x-forwarded-for']||P['ip']||P[G(0x1a6)]?.['remoteAddress']||'')['split'](':')[G(0x1a7)]();export default getIP;
1
+ const Z=c,getIP=S=>(S['headers']?.['x-real-ip']||S['headers']?.['x-forwarded-for']||S['ip']||S[Z(0x1c3)]?.['remoteAddress']||'')['split'](':')[Z(0x1c4)]();function c(S,Z){S=S-0x1c3;const h=O();let U=h[S];return U;}export default getIP;function O(){const h=['connection','pop'];O=function(){return h;};return O();}
@@ -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;
@@ -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 if not exists settings_resource_key_uidx
18
+ ON admin.settings (resource, resource_id, key)
19
19
  NULLS NOT DISTINCT;
@@ -1,16 +1,23 @@
1
1
  ALTER TABLE admin.users
2
+ DROP CONSTRAINT IF EXISTS users_created_by_fkey,
3
+ DROP CONSTRAINT IF EXISTS users_updated_by_fkey,
2
4
  ADD CONSTRAINT users_created_by_fkey
3
5
  FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
4
6
  ADD CONSTRAINT users_updated_by_fkey
5
7
  FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
6
8
 
7
9
  ALTER TABLE admin.user_roles
10
+ DROP CONSTRAINT IF EXISTS user_roles_created_by_fkey,
11
+ DROP CONSTRAINT IF EXISTS user_roles_updated_by_fkey,
8
12
  ADD CONSTRAINT user_roles_created_by_fkey
9
13
  FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
10
14
  ADD CONSTRAINT user_roles_updated_by_fkey
11
15
  FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
12
16
 
13
17
  ALTER TABLE admin.role_access
18
+ DROP CONSTRAINT IF EXISTS role_access_user_uid_fkey,
19
+ DROP CONSTRAINT IF EXISTS role_access_created_by_fkey,
20
+ DROP CONSTRAINT IF EXISTS role_access_updated_by_fkey,
14
21
  ADD CONSTRAINT role_access_user_uid_fkey
15
22
  FOREIGN KEY (user_uid) REFERENCES admin.users(uid) ON DELETE CASCADE,
16
23
  ADD CONSTRAINT role_access_created_by_fkey
@@ -19,24 +26,32 @@ ALTER TABLE admin.role_access
19
26
  FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
20
27
 
21
28
  ALTER TABLE admin.dictionaries
29
+ DROP CONSTRAINT IF EXISTS dictionaries_created_by_fkey,
30
+ DROP CONSTRAINT IF EXISTS dictionaries_updated_by_fkey,
22
31
  ADD CONSTRAINT dictionaries_created_by_fkey
23
32
  FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
24
33
  ADD CONSTRAINT dictionaries_updated_by_fkey
25
34
  FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
26
35
 
27
36
  ALTER TABLE admin.notes
37
+ DROP CONSTRAINT IF EXISTS notes_created_by_fkey,
38
+ DROP CONSTRAINT IF EXISTS notes_updated_by_fkey,
28
39
  ADD CONSTRAINT notes_created_by_fkey
29
40
  FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
30
41
  ADD CONSTRAINT notes_updated_by_fkey
31
42
  FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
32
43
 
33
44
  ALTER TABLE admin.files
45
+ DROP CONSTRAINT IF EXISTS files_created_by_fkey,
46
+ DROP CONSTRAINT IF EXISTS files_updated_by_fkey,
34
47
  ADD CONSTRAINT files_created_by_fkey
35
48
  FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
36
49
  ADD CONSTRAINT files_updated_by_fkey
37
50
  FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
38
51
 
39
52
  ALTER TABLE admin.settings
53
+ DROP CONSTRAINT IF EXISTS settings_created_by_fkey,
54
+ DROP CONSTRAINT IF EXISTS settings_updated_by_fkey,
40
55
  ADD CONSTRAINT settings_created_by_fkey
41
56
  FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
42
57
  ADD CONSTRAINT settings_updated_by_fkey
@@ -1,2 +1,2 @@
1
- ALTER TABLE admin.role_access_scope
1
+ ALTER TABLE admin.role_access_scope
2
2
  ALTER COLUMN role_id DROP NOT NULL;
package/package.json CHANGED
@@ -1,93 +1,93 @@
1
- {
2
- "name": "@opengis/fcore",
3
- "version": "0.0.27",
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"
1
+ {
2
+ "name": "@opengis/fcore",
3
+ "version": "0.0.29",
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
93
  }