@opengis/fcore 0.0.1-beta.14 → 0.0.1-beta.16

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 (91) hide show
  1. package/dist/config.js +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/errors.js +1 -1
  4. package/dist/fastify.d.ts.map +1 -1
  5. package/dist/fastify.js +1 -1
  6. package/dist/fcore.js +1 -1
  7. package/dist/migrations/cli.js +1 -1
  8. package/dist/migrations/runner.js +1 -1
  9. package/dist/modules/auth/adduser-cli.js +1 -1
  10. package/dist/modules/auth/passwd-cli.js +1 -1
  11. package/dist/modules/auth/permission-cli.js +1 -1
  12. package/dist/modules/auth/route.js +1 -1
  13. package/dist/modules/auth/schema.js +1 -1
  14. package/dist/modules/auth/services/change-password.js +1 -1
  15. package/dist/modules/auth/services/get-current-user.js +1 -1
  16. package/dist/modules/auth/services/registration.js +1 -1
  17. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  18. package/dist/modules/file/mime.js +1 -1
  19. package/dist/modules/file/route.js +1 -1
  20. package/dist/modules/file/schema.js +1 -1
  21. package/dist/modules/file/services/get-file.js +1 -1
  22. package/dist/modules/file/services/resize-file.js +1 -1
  23. package/dist/modules/file/services/upload-file.js +1 -1
  24. package/dist/modules/resource/route.js +1 -1
  25. package/dist/modules/resource/schema.js +1 -1
  26. package/dist/modules/resource/services/add-note.js +1 -1
  27. package/dist/modules/resource/services/add-resource-file.js +1 -1
  28. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  29. package/dist/modules/resource/services/create-resource.js +1 -1
  30. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  31. package/dist/modules/resource/services/delete-resource.js +1 -1
  32. package/dist/modules/resource/services/export-resource.js +1 -1
  33. package/dist/modules/resource/services/get-resource.js +1 -1
  34. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  35. package/dist/modules/resource/services/list-resources.js +1 -1
  36. package/dist/modules/resource/services/search-resource.js +1 -1
  37. package/dist/modules/resource/services/suggest-resource.js +1 -1
  38. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  39. package/dist/modules/resource/services/update-resource.js +1 -1
  40. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  41. package/dist/modules/system/route.js +1 -1
  42. package/dist/modules/system/schema.js +1 -1
  43. package/dist/modules/system/services/check-system.js +1 -1
  44. package/dist/modules/system/services/get-access.js +1 -1
  45. package/dist/modules/system/services/get-api-list.js +1 -1
  46. package/dist/modules/system/services/get-audit-log.js +1 -1
  47. package/dist/modules/system/services/get-dictionary.js +1 -1
  48. package/dist/modules/system/services/get-system-log.js +1 -1
  49. package/dist/modules/system/services/get-system-settings.js +1 -1
  50. package/dist/modules/system/services/list-dictionaries.js +1 -1
  51. package/dist/modules/system/services/set-access.js +1 -1
  52. package/dist/modules/system/services/update-dictionary.js +1 -1
  53. package/dist/modules/system/services/update-system-settings.js +1 -1
  54. package/dist/modules/utils/require-admin.js +1 -1
  55. package/dist/modules/utils/safe-user.js +1 -1
  56. package/dist/modules/utils/unsupported.js +1 -1
  57. package/dist/plugins/audit/audit.js +1 -1
  58. package/dist/plugins/audit/services/write-audit.js +1 -1
  59. package/dist/plugins/auth/get-user-permissions.js +1 -1
  60. package/dist/plugins/auth/index.js +1 -1
  61. package/dist/plugins/auth/verifyUser.js +1 -1
  62. package/dist/plugins/dictionary.js +1 -1
  63. package/dist/plugins/file.js +1 -1
  64. package/dist/plugins/jwt.js +1 -1
  65. package/dist/plugins/logger/index.js +1 -1
  66. package/dist/plugins/logger/transport.js +1 -1
  67. package/dist/plugins/pg.js +1 -1
  68. package/dist/plugins/redis.js +1 -1
  69. package/dist/plugins/resource/resource.js +1 -1
  70. package/dist/plugins/resource/resource.registry.js +1 -1
  71. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  72. package/dist/plugins/resource/services/add-file-token.js +1 -1
  73. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  74. package/dist/plugins/resource/services/create-relation.js +1 -1
  75. package/dist/plugins/resource/services/create.js +1 -1
  76. package/dist/plugins/resource/services/delete-relation.js +1 -1
  77. package/dist/plugins/resource/services/delete.js +1 -1
  78. package/dist/plugins/resource/services/find-one.js +1 -1
  79. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
  80. package/dist/plugins/resource/services/find-relation.js +1 -1
  81. package/dist/plugins/resource/services/find.js +1 -1
  82. package/dist/plugins/resource/services/update-relation.js +1 -1
  83. package/dist/plugins/resource/services/update.js +1 -1
  84. package/dist/plugins/resource/utils/auto-index.js +1 -1
  85. package/dist/plugins/resource/utils/fields.js +1 -1
  86. package/dist/plugins/resource/utils/filters.js +1 -1
  87. package/dist/plugins/resource/utils/permissions.js +1 -1
  88. package/dist/plugins/resource/utils/sort.js +1 -1
  89. package/dist/plugins/resource/utils/sql.js +1 -1
  90. package/dist/shared/getIP.js +1 -1
  91. package/package.json +1 -1
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function F(){const l=['type','Invalid\x20id:\x20','query','SELECT\x20','=$1\x20LIMIT\x201','dictionary','isArray','include','split','resource','table','key','join','\x20FROM\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','rows','fields'];F=function(){return l;};return F();}import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';function y(k,f){k=k-0x85;const C=F();let p=C[k];return p;}export function createFindOne(k,f){return async function C({name:p,id:a,query:query={},user:N}){const Q=y,W=Date['now'](),n=f['get'](p);assertOperation(n,'read',N);if(n['fields'][n['key']]?.[Q(0x85)]==='integer'&&!Number['isInteger'](Number(a)))throw new ValidationError(Q(0x86)+a+'\x20name:'+p);const A=n['joins']?.['map'](d=>d['sql']+'\x20')['join']('\x20')||'',H=await k['pg'][Q(0x87)](Q(0x88)+readableFields(n)['join'](',\x20')+'\x20FROM\x20'+qt(n['table'])+'\x20t\x20'+A+'\x20WHERE\x20'+qi(n['key'])+Q(0x89),[a]),R=H['rows'][0x0];if(!R)return null;await addDictionaryLookupData([R],n['fields'],k[Q(0x8a)]),await addTableLookupData([R],n['fields'],k['pg']),addFileToken([R],n['fields'],k['file']);const u=Array[Q(0x8b)](query[Q(0x8c)])?query['include']:query['include']?.[Q(0x8d)](',')??[];for(const d of u){const j=n['relations']?.[d];if(!j?.['foreignKey']||!j['resource']&&!j['table'])throw new ValidationError('Unknown\x20relation:\x20'+d);const z=j[Q(0x8e)]?f['get'](j['resource']):undefined,T=j[Q(0x8f)]??z['table'],S=z?.[Q(0x90)]??'id',i=z?readableFields(z)[Q(0x91)](',\x20'):'*',b='SELECT\x20'+i+'\x20FROM\x20'+qt(T)+'\x20WHERE\x20'+qi(S)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(j['foreignKey'])+Q(0x92)+qt(n['table'])+Q(0x93)+qi(n['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',P=(await k['pg']['query'](b,[a]))[Q(0x94)];z&&(await addDictionaryLookupData(P,z[Q(0x95)],k[Q(0x8a)]),await addTableLookupData(P,z['fields'],k['pg']),addFileToken(P,z['fields'],k['file'])),R[d]=P;}return R['time']=Date['now']()-W,R;};}
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function F(){const G=['get','fields','integer','joins','sql','query','SELECT\x20','join','\x20WHERE\x20','=$1\x20LIMIT\x201','file','include','relations','foreignKey','resource','key','\x20FROM\x20','\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20','table','dictionary','time','now'];F=function(){return G;};return F();}function S(c,N){c=c-0x89;const H=F();let d=H[c];return d;}import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(c,N){return async function H({name:d,id:U,query:query={},user:e}){const Y=S,K=Date['now'](),m=N[Y(0x89)](d);assertOperation(m,'read',e);if(m[Y(0x8a)][m['key']]?.['type']===Y(0x8b)&&!Number['isInteger'](Number(U)))throw new ValidationError('Invalid\x20id:\x20'+U+'\x20name:'+d);const D=m[Y(0x8c)]?.['map'](I=>I[Y(0x8d)]+'\x20')['join']('\x20')||'',W=await c['pg'][Y(0x8e)](Y(0x8f)+readableFields(m)[Y(0x90)](',\x20')+'\x20FROM\x20'+qt(m['table'])+'\x20t\x20'+D+Y(0x91)+qi(m['key'])+Y(0x92),[U]),p=W['rows'][0x0];if(!p)return null;await addDictionaryLookupData([p],m['fields'],c['dictionary']),await addTableLookupData([p],m['fields'],c['pg']),addFileToken([p],m[Y(0x8a)],c[Y(0x93)]);const a=Array['isArray'](query[Y(0x94)])?query['include']:query['include']?.['split'](',')??[];for(const I of a){const r=m[Y(0x95)]?.[I];if(!r?.[Y(0x96)]||!r['resource']&&!r['table'])throw new ValidationError('Unknown\x20relation:\x20'+I);const w=r['resource']?N['get'](r[Y(0x97)]):undefined,x=r['table']??w['table'],V=w?.[Y(0x98)]??'id',T=w?readableFields(w)[Y(0x90)](',\x20'):'*',M='SELECT\x20'+T+Y(0x99)+qt(x)+Y(0x91)+qi(V)+Y(0x9a)+qi(r['foreignKey'])+'\x20FROM\x20'+qt(m[Y(0x9b)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(m[Y(0x98)])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',q=(await c['pg'][Y(0x8e)](M,[U]))['rows'];w&&(await addDictionaryLookupData(q,w[Y(0x8a)],c[Y(0x9c)]),await addTableLookupData(q,w['fields'],c['pg']),addFileToken(q,w['fields'],c['file'])),p[I]=q;}return p[Y(0x9d)]=Date[Y(0x9e)]()-K,p;};}
@@ -1 +1 @@
1
- {"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAoGjB"}
1
+ {"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAyGjB"}
@@ -1 +1 @@
1
- import{UnsupportedError,ValidationError}from'../../../errors.js';function y(k,f){k=k-0x91;const C=F();let p=C[k];return p;}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(k,f){return async function C({name:p,id:a,relation:N,query:query={}}){const l=y,W=Date['now'](),n=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),A=Math[l(0x91)](query['offset']??0x0,0x0);if(!Number['isFinite'](n)||!Number['isFinite'](A))throw new ValidationError('Invalid\x20pagination');const H=f['get'](p),R=H[l(0x92)]?.[N];if(['notes','files']['includes'](N)&&!H['capabilities']?.['includes'](N))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+N+l(0x93)+N+'\x22');if(N===l(0x94)){const b=await k['pg'][l(0x95)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[p,String(a)]);return{'total':b[l(0x96)]['length'],'time':Date['now']()-W,'rows':b[l(0x96)]};}if(N==='files'){const P=await k['pg'][l(0x95)]('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[p,String(a)]);return addFileToken(P['rows'],{'file_path':{'type':'file'}},k[l(0x97)]),{'total':P[l(0x96)]['length'],'time':Date[l(0x98)]()-W,'rows':P['rows']};}const u=!!(R?.['junctionTable']&&R['junctionLocalKey']&&R[l(0x99)]);if(!R||!u&&!R['foreignKey']||!R['resource']&&!R['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+N+l(0x9a));const d=R[l(0x9b)]?f['get'](R['resource']):undefined,j=R['table']??d[l(0x9c)],z=d?.['key']??'id',T=R['fields']?.['length']?R['fields'][l(0x9d)](Q=>u?'t.'+qi(Q):qi(Q))['join'](',\x20'):u?l(0x9e):'*';R['foreignKey']&&autoIndex(j,R[l(0x9f)],'btree',k['pg']);const S=u?l(0xa0)+T+'\x20FROM\x20'+qt(j)+l(0xa1)+qt(R['junctionTable'])+'\x20j\x20ON\x20j.'+qi(R[l(0x99)])+'\x20=\x20t.'+qi(z)+'\x0a\x20\x20\x20\x20WHERE\x20j.'+qi(R[l(0xa2)])+'\x20=\x20$1\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3':l(0xa0)+T+'\x20FROM\x20'+qt(j)+l(0xa3)+qi(R[l(0x9f)])+'\x20=\x20$1\x20LIMIT\x20$2\x20OFFSET\x20$3',i=await k['pg'][l(0x95)](S,[a,n,A]);return d&&(await addDictionaryLookupData(i[l(0x96)],d['fields'],k['dictionary']),await addTableLookupData(i['rows'],d['fields'],k['pg']),addFileToken(i['rows'],d['fields'],k['file'])),{'limit':n,'offset':A,'total':i['rows']['length'],'time':Date['now']()-W,'rows':i['rows']??null};};}function F(){const I=['max','relations','\x22\x20requires\x20a\x20capabilities\x20\x22','notes','query','rows','file','now','junctionForeignKey','\x22\x20requires\x20a\x20project/provider\x20implementation','resource','table','map','t.*','foreignKey','SELECT\x20','\x20t\x0a\x20\x20\x20\x20JOIN\x20','junctionLocalKey','\x20WHERE\x20'];F=function(){return I;};return F();}
1
+ function S(c,N){c=c-0x67;const H=F();let d=H[c];return d;}import{UnsupportedError,ValidationError}from'../../../errors.js';function F(){const v=['max','offset','files','capabilities','includes','length','rows','query','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','Generic\x20Resource\x20relation\x20\x22','map','fields','t.*','joins','filter','SELECT\x20','\x20t\x20','\x0a\x20\x20\x20\x20JOIN\x20','junctionTable','foreignKey','\x20FROM\x20','localKey','file','now'];F=function(){return v;};return F();}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(c,N){return async function H({name:d,id:U,relation:e,query:query={}}){const B=S,K=Date['now'](),m=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),D=Math[B(0x67)](query[B(0x68)]??0x0,0x0);if(!Number['isFinite'](m)||!Number['isFinite'](D))throw new ValidationError('Invalid\x20pagination');const W=N['get'](d),p=W['relations']?.[e];if(['notes',B(0x69)]['includes'](e)&&!W[B(0x6a)]?.[B(0x6b)](e))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+e+'\x22\x20requires\x20a\x20capabilities\x20\x22'+e+'\x22');if(e==='notes'){const Y=await c['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[d,String(U)]);return{'total':Y['rows'][B(0x6c)],'time':Date['now']()-K,'rows':Y[B(0x6d)]};}if(e==='files'){const G=await c['pg'][B(0x6e)](B(0x6f),[d,String(U)]);return addFileToken(G['rows'],{'file_path':{'type':'file'}},c['file']),{'total':G['rows']['length'],'time':Date['now']()-K,'rows':G['rows']};}const a=!!(p?.['junctionTable']&&p['junctionLocalKey']&&p['junctionForeignKey']);if(!p||!a&&!p['foreignKey']&&!p['localKey']||!p['resource']&&!p['table'])throw new UnsupportedError(B(0x70)+e+'\x22\x20requires\x20a\x20project/provider\x20implementation');const I=p['resource']?N['get'](p['resource']):undefined,r=p['table']??I['table'],w=I?.['key']??'id',x=Object['keys'](I?.['fields']??{})['filter'](P=>I?.['fields'][P]?.['read'])[B(0x71)](qi)['join'](',\x20'),V=p[B(0x72)]?.['length']?p['fields']['map'](P=>a?'t.'+qi(P):qi(P))['join'](',\x20'):x||B(0x73);p['foreignKey']&&autoIndex(r,p['foreignKey'],'btree',c['pg']);const T=I?.[B(0x74)]?.[B(0x75)](P=>P['scope']!=='item')['map'](P=>P['sql']+'\x20')['join']('\x20')||'',M=(a?B(0x76)+V+'\x20FROM\x20'+qt(r)+B(0x77)+T+B(0x78)+qt(p[B(0x79)])+'\x20j\x20ON\x20j.'+qi(p['junctionForeignKey'])+'\x20=\x20t.'+qi(w)+'\x0a\x20\x20\x20\x20WHERE\x20j.'+qi(p['junctionLocalKey'])+'\x20=\x20$1\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3':'')||(p[B(0x7a)]?'SELECT\x20'+V+B(0x7b)+qt(r)+'\x20t\x20'+T+'\x20WHERE\x20t.'+qi(p['foreignKey'])+'\x20=\x20$1\x20LIMIT\x20$2\x20OFFSET\x20$3':'SELECT\x20'+V+'\x20FROM\x20'+qt(r)+B(0x77)+T+'\x20WHERE\x20t.'+qi(p['foreignKey']||w)+'\x20=\x20(select\x20'+qi(p[B(0x7c)])+'\x20FROM\x20'+qt(W['table'])+'\x20where\x20'+qi(W['key'])+'\x20=\x20$1\x20limit\x201)\x20LIMIT\x20$2\x20OFFSET\x20$3'),q=await c['pg']['query'](M,[U,m,D]);return I&&(await addDictionaryLookupData(q['rows'],I['fields'],c['dictionary']),await addTableLookupData(q['rows'],I['fields'],c['pg']),addFileToken(q['rows'],I[B(0x72)],c[B(0x7d)])),{'limit':m,'offset':D,'total':q['rows']['length'],'time':Date[B(0x7e)]()-K,'rows':q['rows']??null};};}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';function y(k,f){k=k-0xb5;const C=F();let p=C[k];return p;}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 F(){const b=['now','limit','filter','isFinite','keys','searchable','search','table','push','toLowerCase','sql','values','item','join','OFFSET\x20$','length','rows'];F=function(){return b;};return F();}export function createFind(k,f){return async function C({name:p,query:query={},user:a}){const i=y,N=Date[i(0xb5)](),W=f['get'](p);assertOperation(W,'read',a);const n=Math['min'](Math['max'](query[i(0xb6)]??0x14,0x1),0xc8),A=Math['max'](query['offset']??0x0,0x0),H=buildFilters(W,query[i(0xb7)],0x1,k['pg']),R=buildSort(W,query['sort']);if(!Number[i(0xb8)](n)||!Number[i(0xb8)](A))throw new ValidationError('Invalid\x20pagination');const u=W['searchable']||Object[i(0xb9)](W['fields'])[i(0xb7)](S=>W['fields'][S]?.[i(0xba)]);query[i(0xbb)]&&u['length']&&(u['map'](S=>autoIndex(W[i(0xbc)],S,'text',k['pg'])),H['values'][i(0xbd)](query['search'][i(0xbe)]()+'%'),H['sql']+=(H[i(0xbf)]?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+u?.['map'](S=>'lower('+qt(S)+')\x20LIKE\x20$'+H[i(0xc0)]['length'])['join']('\x20OR\x20')+')'));const d=W['joins']?.['filter'](S=>S['scope']!==i(0xc1))['map'](S=>S['sql']+'\x20')[i(0xc2)]('\x20')||'',j='SELECT\x20'+readableFields(W,'all')['join'](',\x20')+'\x20'+('FROM\x20'+qt(W['table'])+'\x20t\x20')+(d+'\x20'+H['sql']+'\x20'+R+'\x20')+('LIMIT\x20$'+(H['values']['length']+0x1)+'\x20')+(i(0xc3)+(H['values'][i(0xc4)]+0x2)),z=await k['pg']['query'](j,[...H['values'],n,A]),T=z[i(0xc5)];return await addDictionaryLookupData(T,W['fields'],k['dictionary']),await addTableLookupData(T,W['fields'],k['pg']),addFileToken(T,W['fields'],k['file']),{'limit':n,'offset':A,'total':z['rowCount'],'time':Date[i(0xb5)]()-N,'rows':T};};}
1
+ import{ValidationError}from'../../../errors.js';function F(){const M=['min','limit','max','filter','sort','search','length','map','table','values','toLowerCase','lower(',')\x20LIKE\x20$','item','join','FROM\x20','\x20t\x20','query','fields','file','now'];F=function(){return M;};return F();}import{buildFilters}from'../utils/filters.js';function S(c,N){c=c-0xdc;const H=F();let d=H[c];return d;}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';export function createFind(c,N){return async function H({name:d,query:query={},user:U}){const T=S,e=Date['now'](),K=N['get'](d);assertOperation(K,'read',U);const m=Math[T(0xdc)](Math['max'](query[T(0xdd)]??0x14,0x1),0xc8),D=Math[T(0xde)](query['offset']??0x0,0x0),W=buildFilters(K,query[T(0xdf)],0x1,c['pg']),p=buildSort(K,query[T(0xe0)]);if(!Number['isFinite'](m)||!Number['isFinite'](D))throw new ValidationError('Invalid\x20pagination');const a=K['searchable']||Object['keys'](K['fields'])['filter'](V=>K['fields'][V]?.['searchable']);query[T(0xe1)]&&a[T(0xe2)]&&(a[T(0xe3)](V=>autoIndex(K[T(0xe4)],V,'text',c['pg'])),W[T(0xe5)]['push'](query['search'][T(0xe6)]()+'%'),W['sql']+=(W['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+a?.['map'](V=>T(0xe7)+qt(V)+T(0xe8)+W['values'][T(0xe2)])['join']('\x20OR\x20')+')'));const I=K['joins']?.['filter'](V=>V['scope']!==T(0xe9))['map'](V=>V['sql']+'\x20')[T(0xea)]('\x20')||'',r='SELECT\x20'+readableFields(K,'all')['join'](',\x20')+'\x20'+(T(0xeb)+qt(K['table'])+T(0xec))+(I+'\x20'+W['sql']+'\x20'+p+'\x20')+('LIMIT\x20$'+(W[T(0xe5)]['length']+0x1)+'\x20')+('OFFSET\x20$'+(W['values']['length']+0x2)),w=await c['pg'][T(0xed)](r,[...W['values'],m,D]),x=w['rows'];return await addDictionaryLookupData(x,K[T(0xee)],c['dictionary']),await addTableLookupData(x,K[T(0xee)],c['pg']),addFileToken(x,K['fields'],c[T(0xef)]),{'limit':m,'offset':D,'total':w['rowCount'],'time':Date[T(0xf0)]()-e,'rows':x};};}
@@ -1 +1 @@
1
- import{UnsupportedError,ValidationError}from'../../../errors.js';function F(){const z=['foreignKey'];F=function(){return z;};return F();}import{createUpdate}from'./update.js';function y(k,f){k=k-0xa7;const C=F();let p=C[k];return p;}export function createUpdateRelation(k,f){const C=createUpdate(k,f);return async function p({name:a,id:N,relation:W,relationId:n,data:A,user:H},R){const j=y,u=f['get'](a),d=u['relations']?.[W];if(!d?.['resource']||!d['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+W);if(Object['hasOwn'](A,d[j(0xa7)])&&A[d[j(0xa7)]]!==N)throw new ValidationError('Cannot\x20change\x20relation:\x20'+d['foreignKey']);return C({'name':d['resource'],'id':n,'data':A,'user':H,'where':{'column':d['foreignKey'],'value':N}},R);};}
1
+ function S(c,N){c=c-0x1a7;const H=F();let d=H[c];return d;}function F(){const w=['foreignKey','Relation\x20update\x20is\x20not\x20configured:\x20','hasOwn'];F=function(){return w;};return F();}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(c,N){const H=createUpdate(c,N);return async function d({name:U,id:e,relation:K,relationId:m,data:D,user:W},p){const r=S,a=N['get'](U),I=a['relations']?.[K];if(!I?.['resource']||!I[r(0x1a7)])throw new UnsupportedError(r(0x1a8)+K);if(Object[r(0x1a9)](D,I['foreignKey'])&&D[I[r(0x1a7)]]!==e)throw new ValidationError('Cannot\x20change\x20relation:\x20'+I['foreignKey']);return H({'name':I['resource'],'id':m,'data':D,'user':W,'where':{'column':I['foreignKey'],'value':e}},p);};}
@@ -1 +1 @@
1
- function F(){const Q=['update','updated_at','updated_by','\x20=\x20$','WHERE\x20','value','SET\x20','keys','module'];F=function(){return Q;};return F();}function y(k,f){k=k-0x113;const C=F();let p=C[k];return p;}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';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(k,f){return async function C({name:p,id:a,data:N,user:W,where:n},A){const P=y,H=f['get'](p);assertOperation(H,P(0x113),W);const R=writableData(H,N);if(!R['length'])throw new ValidationError('No\x20writable\x20fields');const u=A?.['pg']??k['pg'];validateInputData({'resource':H,'data':N,'update':!![]});H['fields'][P(0x114)]&&R['push']([P(0x114),new Date()]);H['fields'][P(0x115)]&&R['push']([P(0x115),W?.['id']]);delete N['user_type'];const d=R['map'](([i],b)=>qi(i)+P(0x116)+(b+0x1)),j=[...R['map'](([,i])=>i),a];let z=P(0x117)+qi(H['key'])+P(0x116)+j['length'];n&&(j['push'](n[P(0x118)]),z+='\x20AND\x20'+qi(n['column'])+'\x20=\x20$'+j['length']);const T=await u['query']('UPDATE\x20'+qt(H['table'])+'\x20'+(P(0x119)+d['join'](',\x20')+'\x20')+(z+'\x20')+('RETURNING\x20'+Object[P(0x11a)](N)['map'](qi)['join'](',\x20')),j),S=T['rows'][0x0];if(!S)throw new NotFoundError(p+':'+a);return clearTableLookupCache(H['table'],u),await(A?.['audit']??k['audit'])?.['write']({'userId':W?.['id'],'module':H[P(0x11b)],'resource':H['name'],'resourceId':a,'action':'update','fields':Object['keys'](N)}),S;};}
1
+ import{NotFoundError,ValidationError}from'../../../errors.js';function S(c,N){c=c-0x13d;const H=F();let d=H[c];return d;}import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(c,N){return async function H({name:d,id:U,data:e,user:K,where:m},D){const q=S,W=N['get'](d);assertOperation(W,q(0x13d),K);const p=writableData(W,e);if(!p['length'])throw new ValidationError('No\x20writable\x20fields');const a=D?.['pg']??c['pg'];validateInputData({'resource':W,'data':e,'update':!![]});W['fields']['updated_at']&&p[q(0x13e)](['updated_at',new Date()]);W['fields'][q(0x13f)]&&p[q(0x13e)](['updated_by',K?.['id']]);delete e['user_type'];const I=p['map'](([T],M)=>qi(T)+'\x20=\x20$'+(M+0x1)),r=[...p[q(0x140)](([,T])=>T),U];let w='WHERE\x20'+qi(W['key'])+'\x20=\x20$'+r[q(0x141)];m&&(r['push'](m['value']),w+=q(0x142)+qi(m[q(0x143)])+'\x20=\x20$'+r[q(0x141)]);const x=await a[q(0x144)](q(0x145)+qt(W['table'])+'\x20'+(q(0x146)+I['join'](',\x20')+'\x20')+(w+'\x20')+('RETURNING\x20'+Object[q(0x147)](e)['map'](qi)['join'](',\x20')),r),V=x[q(0x148)][0x0];if(!V)throw new NotFoundError(d+':'+U);return clearTableLookupCache(W[q(0x149)],a),await(D?.[q(0x14a)]??c[q(0x14a)])?.['write']({'userId':K?.['id'],'module':W['module'],'resource':W['name'],'resourceId':U,'action':'update','fields':Object[q(0x147)](e)}),V;};}function F(){const Y=['update','push','updated_by','map','length','\x20AND\x20','column','query','UPDATE\x20','SET\x20','keys','rows','table','audit'];F=function(){return Y;};return F();}
@@ -1 +1 @@
1
- import{qi,qt}from'./sql.js';function F(){const R=['add','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','query','\x20ON\x20',')\x20text_pattern_ops)','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20','\x20USING\x20'];F=function(){return R;};return F();}function y(k,f){k=k-0x181;const C=F();let p=C[k];return p;}const requestedIndexes=new WeakMap();export function autoIndex(k,f,C='btree',p){const A=y,a=requestedIndexes['get'](p)??new Set();requestedIndexes['set'](p,a);const N=k+':'+f+':'+C;if(a['has'](N))return;a[A(0x181)](N),void ensureIndex(k,f,C,p)['catch'](()=>{a['delete'](N);});}async function ensureIndex(k,f,C,p){const H=y,a=k['split']('.'),N=a['length']===0x2?a[0x0]:'public',W=(k+'_'+f+'_'+C+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),n=await p['query'](H(0x182),[N,W]);if(n['rowCount'])return;if(C==='text'){await p[H(0x183)]('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await p['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(W+'_l')+H(0x184)+qt(k)+'\x20USING\x20btree\x20(lower('+qi(f)+H(0x185)),await p['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(W)+'\x20ON\x20'+qt(k)+'\x20USING\x20gin\x20(lower('+qi(f)+')\x20gin_trgm_ops)');return;}await p['query'](H(0x186)+qi(W)+'\x20ON\x20'+qt(k)+H(0x187)+C+'\x20('+qi(f)+')');}
1
+ function F(){const a=['btree','add','CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20','\x20ON\x20',')\x20text_pattern_ops)','\x20USING\x20gin\x20(lower(',')\x20gin_trgm_ops)'];F=function(){return a;};return F();}const D=S;import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(c,N,H=D(0x1dc),d){const W=D,U=requestedIndexes['get'](d)??new Set();requestedIndexes['set'](d,U);const e=c+':'+N+':'+H;if(U['has'](e))return;U[W(0x1dd)](e),void ensureIndex(c,N,H,d)['catch'](()=>{U['delete'](e);});}function S(c,N){c=c-0x1dc;const H=F();let d=H[c];return d;}async function ensureIndex(c,N,H,d){const p=D,U=c['split']('.'),e=U['length']===0x2?U[0x0]:'public',K=(c+'_'+N+'_'+H+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),m=await d['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[e,K]);if(m['rowCount'])return;if(H==='text'){await d['query'](p(0x1de)),await d['query'](p(0x1df)+qi(K+'_l')+p(0x1e0)+qt(c)+'\x20USING\x20btree\x20(lower('+qi(N)+p(0x1e1)),await d['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(K)+p(0x1e0)+qt(c)+p(0x1e2)+qi(N)+p(0x1e3));return;}await d['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(K)+'\x20ON\x20'+qt(c)+'\x20USING\x20'+H+'\x20('+qi(N)+')');}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:k,data:f,update:update=![]})=>{const a=y;for(const [C,p]of Object['entries'](k[a(0xd7)])){if(p['required']&&p[a(0xd8)]!==![]&&(f[C]===undefined||f[C]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+C);if(p['required']&&p['writable']!==![]&&Object['hasOwn'](f,C)&&(f[C]===undefined||f[C]===null)&&update)throw new ValidationError(a(0xd9)+C);if(p[a(0xda)]&&typeof f[C]==='string'&&f[C][a(0xdb)]<p['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+C);if(p[a(0xdc)]&&typeof f[C]==='string'&&f[C]['length']>p['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+C);if(p['minimum']&&typeof f[C]==='number'&&f[C]<p['minimum'])throw new ValidationError(C+'\x20should\x20be\x20>=\x20'+p['minimum']);if(p['maximum']&&typeof f[C]==='number'&&f[C]>p[a(0xdd)])throw new ValidationError(C+a(0xde)+p['maximum']);if(p['enum']&&f[C]&&!p[a(0xdf)][a(0xe0)](f[C]))throw new ValidationError(C+'\x20should\x20be\x20one\x20of\x20('+p['enum'][a(0xe1)](',\x20')+')');if(p['pattern']&&typeof f[C]===a(0xe2)&&!new RegExp(p['pattern'])['test'](f[C]))throw new ValidationError(C+'\x20should\x20match\x20regular\x20expression\x20('+p[a(0xe3)]+')');}};function y(k,f){k=k-0xd7;const C=F();let p=C[k];return p;}export{validateInputData};function F(){const N=['fields','writable','Required\x20field:\x20','minLength','length','maxLength','maximum','\x20should\x20be\x20<=\x20','enum','includes','join','string','pattern'];F=function(){return N;};return F();}
1
+ function F(){const e=['required','writable','hasOwn','minLength','number','maximum','\x20should\x20be\x20<=\x20','enum','join','pattern','string','test'];F=function(){return e;};return F();}function S(c,N){c=c-0xbc;const H=F();let d=H[c];return d;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:c,data:N,update:update=![]})=>{const U=S;for(const [H,d]of Object['entries'](c['fields'])){if(d[U(0xbc)]&&d[U(0xbd)]!==![]&&(N[H]===undefined||N[H]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+H);if(d['required']&&d['writable']!==![]&&Object[U(0xbe)](N,H)&&(N[H]===undefined||N[H]===null)&&update)throw new ValidationError('Required\x20field:\x20'+H);if(d[U(0xbf)]&&typeof N[H]==='string'&&N[H]['length']<d['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+H);if(d['maxLength']&&typeof N[H]==='string'&&N[H]['length']>d['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+H);if(d['minimum']&&typeof N[H]==='number'&&N[H]<d['minimum'])throw new ValidationError(H+'\x20should\x20be\x20>=\x20'+d['minimum']);if(d['maximum']&&typeof N[H]===U(0xc0)&&N[H]>d[U(0xc1)])throw new ValidationError(H+U(0xc2)+d['maximum']);if(d[U(0xc3)]&&N[H]&&!d['enum']['includes'](N[H]))throw new ValidationError(H+'\x20should\x20be\x20one\x20of\x20('+d['enum'][U(0xc4)](',\x20')+')');if(d[U(0xc5)]&&typeof N[H]===U(0xc6)&&!new RegExp(d['pattern'])[U(0xc7)](N[H]))throw new ValidationError(H+'\x20should\x20match\x20regular\x20expression\x20('+d['pattern']+')');}};export{validateInputData};
@@ -1 +1 @@
1
- const S=y;import{fieldColumn,qi}from'./sql.js';function y(k,f){k=k-0x149;const C=F();let p=C[k];return p;}import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt',S(0x149),'in','nin','like','ilike',S(0x14a)]);export function parseFilterQuery(k){const i=S,f={...isRecord(k['filter'])?k[i(0x14b)]:{}};for(const [C,p]of Object['entries'](k)){const a=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](C);if(!a)continue;const [,N,W]=a;if(!N)continue;if(!W){f[N]=p;continue;}if(!filterOperators[i(0x14c)](W))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+W);const n=isRecord(f[N])?f[N]:{};n[W]=(W==='in'||W==='nin')&&typeof p==='string'?p['split'](','):p,f[N]=n;}return Object['keys'](f)[i(0x14d)]?f:undefined;}function F(){const Q=['lte','null','filter','has','length','entries','like','type','string','Operator\x20','table','NOT\x20','nin','push','=\x20ANY','\x20WHERE\x20','join','ilike','text','geom','btree'];F=function(){return Q;};return F();}export function buildFilters(k,f,C=0x1,p){const b=S,a=[],N=[];for(const [W,n]of Object[b(0x14e)](f??{})){const A=k['fields'][W];if(!A||A['filter']!==!![]&&A['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+W);const H=qi(fieldColumn(k,W)),R=isRecord(n)?n:{'eq':n};for(const [u,d]of Object['entries'](R)){if(!filterOperators['has'](u))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+u);if((u===b(0x14f)||u==='ilike')&&A[b(0x150)]!==b(0x151)&&A['type']!=='text')throw new ValidationError(b(0x152)+u+'\x20requires\x20a\x20text\x20field:\x20'+W);p&&autoIndex(k[b(0x153)],fieldColumn(k,W),indexTypeFor(A['type'],u),p);if(u==='null'){a['push'](H+'\x20IS\x20'+(isTruthy(d)?'':b(0x154))+'NULL');continue;}if(u==='in'||u===b(0x155)){const T=Array['isArray'](d)?d:[d];if(T['length']===0x0){a[b(0x156)](u==='in'?'FALSE':'TRUE');continue;}N['push'](T),a['push'](H+'\x20'+(u==='in'?b(0x157):'<>\x20ALL')+'($'+(C+N['length']-0x1)+')');continue;}const j={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},z='$'+(C+N['length']);if(u==='like'){N[b(0x156)](d+'%'),a['push']('lower('+H+')\x20like\x20lower('+z+')');continue;}N['push'](d),a['push'](H+'\x20'+j[u]+'\x20'+z);}}return{'sql':a[b(0x14d)]?b(0x158)+a[b(0x159)]('\x20AND\x20'):'','values':N};}function isRecord(k){return typeof k==='object'&&k!==null&&!Array['isArray'](k);}function isTruthy(k){return k===!![]||k==='true'||k==='1'||k===0x1;}function indexTypeFor(k,f){const P=S;if(f==='like'||f===P(0x15a))return P(0x15b);if(k===P(0x15c)||k==='geometry')return'gist';return P(0x15d);}
1
+ const V=S;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function F(){const q=['gte','filter','Unsupported\x20filter\x20operator:\x20','nin','fields','filterable','text','Operator\x20','table','type','null','NULL','push','=\x20ANY','length','like',')\x20like\x20lower('];F=function(){return q;};return F();}import{autoIndex}from'./auto-index.js';function S(c,N){c=c-0x1e2;const H=F();let d=H[c];return d;}const filterOperators=new Set(['eq','ne','gt',V(0x1e2),'lt','lte','in','nin','like','ilike','null']);export function parseFilterQuery(c){const T=V,N={...isRecord(c['filter'])?c[T(0x1e3)]:{}};for(const [H,d]of Object['entries'](c)){const U=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](H);if(!U)continue;const [,e,K]=U;if(!e)continue;if(!K){N[e]=d;continue;}if(!filterOperators['has'](K))throw new ValidationError(T(0x1e4)+K);const m=isRecord(N[e])?N[e]:{};m[K]=(K==='in'||K===T(0x1e5))&&typeof d==='string'?d['split'](','):d,N[e]=m;}return Object['keys'](N)['length']?N:undefined;}export function buildFilters(c,N,H=0x1,d){const M=V,U=[],e=[];for(const [K,m]of Object['entries'](N??{})){const D=c[M(0x1e6)][K];if(!D||D['filter']!==!![]&&D[M(0x1e7)]!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+K);const W=qi(fieldColumn(c,K)),p=isRecord(m)?m:{'eq':m};for(const [a,I]of Object['entries'](p)){if(!filterOperators['has'](a))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+a);if((a==='like'||a==='ilike')&&D['type']!=='string'&&D['type']!==M(0x1e8))throw new ValidationError(M(0x1e9)+a+'\x20requires\x20a\x20text\x20field:\x20'+K);d&&autoIndex(c[M(0x1ea)],fieldColumn(c,K),indexTypeFor(D[M(0x1eb)],a),d);if(a===M(0x1ec)){U['push'](W+'\x20IS\x20'+(isTruthy(I)?'':'NOT\x20')+M(0x1ed));continue;}if(a==='in'||a==='nin'){const x=Array['isArray'](I)?I:[I];if(x['length']===0x0){U[M(0x1ee)](a==='in'?'FALSE':'TRUE');continue;}e['push'](x),U['push'](W+'\x20'+(a==='in'?M(0x1ef):'<>\x20ALL')+'($'+(H+e[M(0x1f0)]-0x1)+')');continue;}const r={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':M(0x1f1)},w='$'+(H+e['length']);if(a==='like'){e['push'](I+'%'),U[M(0x1ee)]('lower('+W+M(0x1f2)+w+')');continue;}e['push'](I),U[M(0x1ee)](W+'\x20'+r[a]+'\x20'+w);}}return{'sql':U[M(0x1f0)]?'\x20WHERE\x20'+U['join']('\x20AND\x20'):'','values':e};}function isRecord(c){return typeof c==='object'&&c!==null&&!Array['isArray'](c);}function isTruthy(c){return c===!![]||c==='true'||c==='1'||c===0x1;}function indexTypeFor(c,N){if(N==='like'||N==='ilike')return'text';if(c==='geom'||c==='geometry')return'gist';return'btree';}
@@ -1 +1 @@
1
- function y(k,f){k=k-0xae;const C=F();let p=C[k];return p;}function F(){const W=['config','operations','name','access','admin','Admin\x20access\x20required'];F=function(){return W;};return F();}import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';export function assertOperation(k,f,C){const N=y,p=getContext()[N(0xae)];if(p['debug'])return;if(!k[N(0xaf)]['includes'](f))throw new ForbiddenError(k[N(0xb0)]+'.'+f+'\x20is\x20disabled');if(k[N(0xb1)]!=='public'&&C===undefined)throw new ForbiddenError('Authentication\x20required');if(k['access']==='admin'&&C?.['type']!==N(0xb2))throw new ForbiddenError(N(0xb3));if(C?.['type']!==N(0xb2)){const a=(k['permission']??k['name'])+':'+f;if(!C?.['permissions']?.['includes'](a))throw new ForbiddenError('Missing\x20permission:\x20'+a);}}
1
+ function S(c,N){c=c-0xca;const H=F();let d=H[c];return d;}import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';export function assertOperation(c,N,H){const e=S,d=getContext()['config'];if(d['debug'])return;if(!c['operations']['includes'](N))throw new ForbiddenError(c[e(0xca)]+'.'+N+'\x20is\x20disabled');if(c[e(0xcb)]!=='public'&&H===undefined)throw new ForbiddenError('Authentication\x20required');if(c['access']==='admin'&&H?.['type']!==e(0xcc))throw new ForbiddenError('Admin\x20access\x20required');if(H?.['type']!=='admin'){const U=(c['permission']??c[e(0xca)])+':'+N;if(!H?.['permissions']?.[e(0xcd)](U))throw new ForbiddenError('Missing\x20permission:\x20'+U);}}function F(){const K=['name','access','admin','includes'];F=function(){return K;};return F();}
@@ -1 +1 @@
1
- import{fieldColumn,qi}from'./sql.js';function F(){const A=['join'];F=function(){return A;};return F();}function y(k,f){k=k-0x113;const C=F();let p=C[k];return p;}import{ValidationError}from'../../../errors.js';export function buildSort(k,f){const n=y;if(!f?.['length'])return'';typeof f==='string'&&(f=[f]);const C=f['map'](p=>{const a=p['startsWith']('-'),N=a?p['slice'](0x1):p,W=k['fields'][N];if(!W||W['sort']!==!![]&&W['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+N);return qi(fieldColumn(k,N))+'\x20'+(a?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+C[n(0x113)](',\x20');}
1
+ import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(c,N){if(!N?.['length'])return'';typeof N==='string'&&(N=[N]);const H=N['map'](d=>{const U=d['startsWith']('-'),e=U?d['slice'](0x1):d,K=c['fields'][e];if(!K||K['sort']!==!![]&&K['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+e);return qi(fieldColumn(c,e))+'\x20'+(U?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+H['join'](',\x20');}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';function F(){const H=['key','fields','entries','read','all','map','column','unshift','writable','type','push'];F=function(){return H;};return F();}export const quoteIdentifier=k=>'\x22'+k['replace'](/"/g,'\x22\x22')+'\x22';function y(k,f){k=k-0x1d9;const C=F();let p=C[k];return p;}export const quoteTable=k=>k['split']('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(k,f){const W=y;if(f===k[W(0x1d9)])return k['key'];const C=k[W(0x1da)][f];if(!C)throw new ValidationError('Unknown\x20field:\x20'+f);return C['column']??f;}export function readableFields(k,f){const n=y,C=Object[n(0x1db)](k[n(0x1da)])['filter'](([,p])=>p[n(0x1dc)]!==![]&&p['readable']!==![]&&(f?(p['scope']??n(0x1dd))===f:!![]))[n(0x1de)](([p,a])=>quoteIdentifier(a[n(0x1df)]??p)+'\x20AS\x20'+quoteIdentifier(p));return!k['fields'][k[n(0x1d9)]]&&C[n(0x1e0)](quoteIdentifier(k[n(0x1d9)])),C;}export function writableData(k,f){const A=y,C=[];for(const [p,a]of Object['entries'](f)){const N=k[A(0x1da)][p];if(!N||N['write']===![]||N[A(0x1e1)]===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+p);if((N['write']??N['writable'])!==!![])continue;if(N[A(0x1e2)]==='date'&&!f[p])continue;C[A(0x1e3)]([N['column']??p,a]);}return C;}export const qi=quoteIdentifier;export const qt=quoteTable;
1
+ const K=S;import{ValidationError}from'../../../errors.js';function S(c,N){c=c-0xcd;const H=F();let d=H[c];return d;}function F(){const p=['replace','key','column','read','fields','entries','write'];F=function(){return p;};return F();}export const quoteIdentifier=c=>'\x22'+c[K(0xcd)](/"/g,'\x22\x22')+'\x22';export const quoteTable=c=>c['split']('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(c,N){const m=K;if(N===c['key'])return c[m(0xce)];const H=c['fields'][N];if(!H)throw new ValidationError('Unknown\x20field:\x20'+N);return H[m(0xcf)]??N;}export function readableFields(c,N){const D=K,H=Object['entries'](c['fields'])['filter'](([,d])=>d[D(0xd0)]!==![]&&d['readable']!==![]&&(N?(d['scope']??'all')===N:!![]))['map'](([d,U])=>quoteIdentifier(U['column']??d)+'\x20AS\x20'+quoteIdentifier(d));return!c[D(0xd1)][c['key']]&&H['unshift'](quoteIdentifier(c['key'])),H;}export function writableData(c,N){const W=K,H=[];for(const [d,U]of Object[W(0xd2)](N)){const e=c[W(0xd1)][d];if(!e||e['write']===![]||e['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+d);if((e[W(0xd3)]??e['writable'])!==!![])continue;if(e['type']==='date'&&!N[d])continue;H['push']([e[W(0xcf)]??d,U]);}return H;}export const qi=quoteIdentifier;export const qt=quoteTable;
@@ -1 +1 @@
1
- function y(k,f){k=k-0x1d5;const C=F();let p=C[k];return p;}function F(){const C=['x-real-ip','connection','pop'];F=function(){return C;};return F();}const f=y,getIP=k=>(k['headers']?.[f(0x1d5)]||k['headers']?.['x-forwarded-for']||k['ip']||k[f(0x1d6)]?.['remoteAddress']||'')['split'](':')[f(0x1d7)]();export default getIP;
1
+ const N=S,getIP=c=>(c[N(0x18f)]?.['x-real-ip']||c['headers']?.[N(0x190)]||c['ip']||c['connection']?.[N(0x191)]||'')['split'](':')['pop']();function F(){const H=['headers','x-forwarded-for','remoteAddress'];F=function(){return H;};return F();}function S(c,N){c=c-0x18f;const H=F();let d=H[c];return d;}export default getIP;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fcore",
3
- "version": "0.0.1-beta.14",
3
+ "version": "0.0.1-beta.16",
4
4
  "description": "Reusable backend foundation for OpenGIS Node.js applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",