@opengis/fcore 0.0.1-beta.15 → 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 (90) 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.js +1 -1
  5. package/dist/fcore.js +1 -1
  6. package/dist/migrations/cli.js +1 -1
  7. package/dist/migrations/runner.js +1 -1
  8. package/dist/modules/auth/adduser-cli.js +1 -1
  9. package/dist/modules/auth/passwd-cli.js +1 -1
  10. package/dist/modules/auth/permission-cli.js +1 -1
  11. package/dist/modules/auth/route.js +1 -1
  12. package/dist/modules/auth/schema.js +1 -1
  13. package/dist/modules/auth/services/change-password.js +1 -1
  14. package/dist/modules/auth/services/get-current-user.js +1 -1
  15. package/dist/modules/auth/services/registration.js +1 -1
  16. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  17. package/dist/modules/file/mime.js +1 -1
  18. package/dist/modules/file/route.js +1 -1
  19. package/dist/modules/file/schema.js +1 -1
  20. package/dist/modules/file/services/get-file.js +1 -1
  21. package/dist/modules/file/services/resize-file.js +1 -1
  22. package/dist/modules/file/services/upload-file.js +1 -1
  23. package/dist/modules/resource/route.js +1 -1
  24. package/dist/modules/resource/schema.js +1 -1
  25. package/dist/modules/resource/services/add-note.js +1 -1
  26. package/dist/modules/resource/services/add-resource-file.js +1 -1
  27. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  28. package/dist/modules/resource/services/create-resource.js +1 -1
  29. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  30. package/dist/modules/resource/services/delete-resource.js +1 -1
  31. package/dist/modules/resource/services/export-resource.js +1 -1
  32. package/dist/modules/resource/services/get-resource.js +1 -1
  33. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  34. package/dist/modules/resource/services/list-resources.js +1 -1
  35. package/dist/modules/resource/services/search-resource.js +1 -1
  36. package/dist/modules/resource/services/suggest-resource.js +1 -1
  37. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  38. package/dist/modules/resource/services/update-resource.js +1 -1
  39. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  40. package/dist/modules/system/route.js +1 -1
  41. package/dist/modules/system/schema.js +1 -1
  42. package/dist/modules/system/services/check-system.js +1 -1
  43. package/dist/modules/system/services/get-access.js +1 -1
  44. package/dist/modules/system/services/get-api-list.js +1 -1
  45. package/dist/modules/system/services/get-audit-log.js +1 -1
  46. package/dist/modules/system/services/get-dictionary.js +1 -1
  47. package/dist/modules/system/services/get-system-log.js +1 -1
  48. package/dist/modules/system/services/get-system-settings.js +1 -1
  49. package/dist/modules/system/services/list-dictionaries.js +1 -1
  50. package/dist/modules/system/services/set-access.js +1 -1
  51. package/dist/modules/system/services/update-dictionary.js +1 -1
  52. package/dist/modules/system/services/update-system-settings.js +1 -1
  53. package/dist/modules/utils/require-admin.js +1 -1
  54. package/dist/modules/utils/safe-user.js +1 -1
  55. package/dist/modules/utils/unsupported.js +1 -1
  56. package/dist/plugins/audit/audit.js +1 -1
  57. package/dist/plugins/audit/services/write-audit.js +1 -1
  58. package/dist/plugins/auth/get-user-permissions.js +1 -1
  59. package/dist/plugins/auth/index.js +1 -1
  60. package/dist/plugins/auth/verifyUser.js +1 -1
  61. package/dist/plugins/dictionary.js +1 -1
  62. package/dist/plugins/file.js +1 -1
  63. package/dist/plugins/jwt.js +1 -1
  64. package/dist/plugins/logger/index.js +1 -1
  65. package/dist/plugins/logger/transport.js +1 -1
  66. package/dist/plugins/pg.js +1 -1
  67. package/dist/plugins/redis.js +1 -1
  68. package/dist/plugins/resource/resource.js +1 -1
  69. package/dist/plugins/resource/resource.registry.js +1 -1
  70. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  71. package/dist/plugins/resource/services/add-file-token.js +1 -1
  72. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  73. package/dist/plugins/resource/services/create-relation.js +1 -1
  74. package/dist/plugins/resource/services/create.js +1 -1
  75. package/dist/plugins/resource/services/delete-relation.js +1 -1
  76. package/dist/plugins/resource/services/delete.js +1 -1
  77. package/dist/plugins/resource/services/find-one.js +1 -1
  78. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
  79. package/dist/plugins/resource/services/find-relation.js +1 -1
  80. package/dist/plugins/resource/services/find.js +1 -1
  81. package/dist/plugins/resource/services/update-relation.js +1 -1
  82. package/dist/plugins/resource/services/update.js +1 -1
  83. package/dist/plugins/resource/utils/auto-index.js +1 -1
  84. package/dist/plugins/resource/utils/fields.js +1 -1
  85. package/dist/plugins/resource/utils/filters.js +1 -1
  86. package/dist/plugins/resource/utils/permissions.js +1 -1
  87. package/dist/plugins/resource/utils/sort.js +1 -1
  88. package/dist/plugins/resource/utils/sql.js +1 -1
  89. package/dist/shared/getIP.js +1 -1
  90. package/package.json +1 -1
@@ -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';import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';function f(x,K){x=x-0x1aa;const Z=t();let b=Z[x];return b;}import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';function t(){const O=['Invalid\x20pagination','Generic\x20Resource\x20relation\x20\x22','rows','length','file','junctionForeignKey','foreignKey','table','map','\x20j\x20ON\x20j.','SELECT\x20','\x20WHERE\x20','fields','dictionary'];t=function(){return O;};return t();}export function createFindRelation(x,K){return async function Z({name:b,id:Q,relation:J,query:query={}}){const R=f,a=Date['now'](),U=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),I=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](U)||!Number['isFinite'](I))throw new ValidationError(R(0x1aa));const Y=K['get'](b),w=Y['relations']?.[J];if(['notes','files']['includes'](J)&&!Y['capabilities']?.['includes'](J))throw new UnsupportedError(R(0x1ab)+J+'\x22\x20requires\x20a\x20capabilities\x20\x22'+J+'\x22');if(J==='notes'){const l=await x['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[b,String(Q)]);return{'total':l[R(0x1ac)][R(0x1ad)],'time':Date['now']()-a,'rows':l['rows']};}if(J==='files'){const W=await x['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[b,String(Q)]);return addFileToken(W['rows'],{'file_path':{'type':'file'}},x[R(0x1ae)]),{'total':W['rows']['length'],'time':Date['now']()-a,'rows':W['rows']};}const C=!!(w?.['junctionTable']&&w['junctionLocalKey']&&w[R(0x1af)]);if(!w||!C&&!w[R(0x1b0)]||!w['resource']&&!w[R(0x1b1)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+J+'\x22\x20requires\x20a\x20project/provider\x20implementation');const V=w['resource']?K['get'](w['resource']):undefined,z=w['table']??V[R(0x1b1)],P=V?.['key']??'id',S=w['fields']?.[R(0x1ad)]?w['fields'][R(0x1b2)](h=>C?'t.'+qi(h):qi(h))['join'](',\x20'):C?'t.*':'*';w[R(0x1b0)]&&autoIndex(z,w['foreignKey'],'btree',x['pg']);const k=C?'SELECT\x20'+S+'\x20FROM\x20'+qt(z)+'\x20t\x0a\x20\x20\x20\x20JOIN\x20'+qt(w['junctionTable'])+R(0x1b3)+qi(w['junctionForeignKey'])+'\x20=\x20t.'+qi(P)+'\x0a\x20\x20\x20\x20WHERE\x20j.'+qi(w['junctionLocalKey'])+'\x20=\x20$1\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3':R(0x1b4)+S+'\x20FROM\x20'+qt(z)+R(0x1b5)+qi(w[R(0x1b0)])+'\x20=\x20$1\x20LIMIT\x20$2\x20OFFSET\x20$3',y=await x['pg']['query'](k,[Q,U,I]);return V&&(await addDictionaryLookupData(y['rows'],V[R(0x1b6)],x[R(0x1b7)]),await addTableLookupData(y['rows'],V['fields'],x['pg']),addFileToken(y['rows'],V['fields'],x['file'])),{'limit':U,'offset':I,'total':y[R(0x1ac)]['length'],'time':Date['now']()-a,'rows':y['rows']??null};};}
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';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';function t(){const l=['max','limit','sort','search','push',')\x20LIKE\x20$','values','filter','join','LIMIT\x20$','length','fields'];t=function(){return l;};return t();}import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';function f(x,K){x=x-0xff;const Z=t();let b=Z[x];return b;}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(x,K){return async function Z({name:b,query:query={},user:Q}){const y=f,J=Date['now'](),a=K['get'](b);assertOperation(a,'read',Q);const U=Math['min'](Math[y(0xff)](query[y(0x100)]??0x14,0x1),0xc8),I=Math['max'](query['offset']??0x0,0x0),Y=buildFilters(a,query['filter'],0x1,x['pg']),w=buildSort(a,query[y(0x101)]);if(!Number['isFinite'](U)||!Number['isFinite'](I))throw new ValidationError('Invalid\x20pagination');const C=a['searchable']||Object['keys'](a['fields'])['filter'](k=>a['fields'][k]?.['searchable']);query[y(0x102)]&&C['length']&&(C['map'](k=>autoIndex(a['table'],k,'text',x['pg'])),Y['values'][y(0x103)](query[y(0x102)]['toLowerCase']()+'%'),Y['sql']+=(Y['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+C?.['map'](k=>'lower('+qt(k)+y(0x104)+Y[y(0x105)]['length'])['join']('\x20OR\x20')+')'));const V=a['joins']?.[y(0x106)](k=>k['scope']!=='item')['map'](k=>k['sql']+'\x20')[y(0x107)]('\x20')||'',z='SELECT\x20'+readableFields(a,'all')[y(0x107)](',\x20')+'\x20'+('FROM\x20'+qt(a['table'])+'\x20t\x20')+(V+'\x20'+Y['sql']+'\x20'+w+'\x20')+(y(0x108)+(Y['values'][y(0x109)]+0x1)+'\x20')+('OFFSET\x20$'+(Y['values']['length']+0x2)),P=await x['pg']['query'](z,[...Y['values'],U,I]),S=P['rows'];return await addDictionaryLookupData(S,a['fields'],x['dictionary']),await addTableLookupData(S,a['fields'],x['pg']),addFileToken(S,a[y(0x10a)],x['file']),{'limit':U,'offset':I,'total':P['rowCount'],'time':Date['now']()-J,'rows':S};};}
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 t(){const P=['relations','resource','Relation\x20update\x20is\x20not\x20configured:\x20','hasOwn','foreignKey'];t=function(){return P;};return t();}import{createUpdate}from'./update.js';function f(x,K){x=x-0x1e2;const Z=t();let b=Z[x];return b;}export function createUpdateRelation(x,K){const Z=createUpdate(x,K);return async function b({name:Q,id:J,relation:a,relationId:U,data:I,user:Y},w){const z=f,C=K['get'](Q),V=C[z(0x1e2)]?.[a];if(!V?.[z(0x1e3)]||!V['foreignKey'])throw new UnsupportedError(z(0x1e4)+a);if(Object[z(0x1e5)](I,V['foreignKey'])&&I[V['foreignKey']]!==J)throw new ValidationError('Cannot\x20change\x20relation:\x20'+V['foreignKey']);return Z({'name':V['resource'],'id':U,'data':I,'user':Y,'where':{'column':V[z(0x1e6)],'value':J}},w);};}
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
- import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function f(x,K){x=x-0xf4;const Z=t();let b=Z[x];return b;}function t(){const h=['get','update','fields','value','\x20AND\x20','column','length','query','UPDATE\x20','join','table','name'];t=function(){return h;};return t();}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(x,K){return async function Z({name:b,id:Q,data:J,user:a,where:U},I){const W=f,Y=K[W(0xf4)](b);assertOperation(Y,W(0xf5),a);const w=writableData(Y,J);if(!w['length'])throw new ValidationError('No\x20writable\x20fields');const C=I?.['pg']??x['pg'];validateInputData({'resource':Y,'data':J,'update':!![]});Y['fields']['updated_at']&&w['push'](['updated_at',new Date()]);Y[W(0xf6)]['updated_by']&&w['push'](['updated_by',a?.['id']]);delete J['user_type'];const V=w['map'](([y],l)=>qi(y)+'\x20=\x20$'+(l+0x1)),z=[...w['map'](([,y])=>y),Q];let P='WHERE\x20'+qi(Y['key'])+'\x20=\x20$'+z['length'];U&&(z['push'](U[W(0xf7)]),P+=W(0xf8)+qi(U[W(0xf9)])+'\x20=\x20$'+z[W(0xfa)]);const S=await C[W(0xfb)](W(0xfc)+qt(Y['table'])+'\x20'+('SET\x20'+V['join'](',\x20')+'\x20')+(P+'\x20')+('RETURNING\x20'+Object['keys'](J)['map'](qi)[W(0xfd)](',\x20')),z),k=S['rows'][0x0];if(!k)throw new NotFoundError(b+':'+Q);return clearTableLookupCache(Y[W(0xfe)],C),await(I?.['audit']??x['audit'])?.['write']({'userId':a?.['id'],'module':Y['module'],'resource':Y[W(0xff)],'resourceId':Q,'action':W(0xf5),'fields':Object['keys'](J)}),k;};}
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';const requestedIndexes=new WeakMap();function t(){const w=['set','split','public','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','query','\x20ON\x20','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'];t=function(){return w;};return t();}function f(x,K){x=x-0xe6;const Z=t();let b=Z[x];return b;}export function autoIndex(x,K,Z='btree',b){const I=f,Q=requestedIndexes['get'](b)??new Set();requestedIndexes[I(0xe6)](b,Q);const J=x+':'+K+':'+Z;if(Q['has'](J))return;Q['add'](J),void ensureIndex(x,K,Z,b)['catch'](()=>{Q['delete'](J);});}async function ensureIndex(x,K,Z,b){const Y=f,Q=x[Y(0xe7)]('.'),J=Q['length']===0x2?Q[0x0]:Y(0xe8),a=(x+'_'+K+'_'+Z+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),U=await b['query'](Y(0xe9),[J,a]);if(U['rowCount'])return;if(Z==='text'){await b['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await b['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(a+'_l')+'\x20ON\x20'+qt(x)+'\x20USING\x20btree\x20(lower('+qi(K)+')\x20text_pattern_ops)'),await b[Y(0xea)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(a)+Y(0xeb)+qt(x)+'\x20USING\x20gin\x20(lower('+qi(K)+')\x20gin_trgm_ops)');return;}await b[Y(0xea)](Y(0xec)+qi(a)+'\x20ON\x20'+qt(x)+'\x20USING\x20'+Z+'\x20('+qi(K)+')');}
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
- function t(){const J=['entries','writable','Required\x20field:\x20','minLength','string','length','maxLength','maxLength\x20exceeded:\x20','minimum','number','\x20should\x20be\x20>=\x20','maximum','\x20should\x20be\x20one\x20of\x20(','pattern'];t=function(){return J;};return t();}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function f(x,K){x=x-0xd6;const Z=t();let b=Z[x];return b;}const validateInputData=({resource:x,data:K,update:update=![]})=>{const Q=f;for(const [Z,b]of Object[Q(0xd6)](x['fields'])){if(b['required']&&b[Q(0xd7)]!==![]&&(K[Z]===undefined||K[Z]===null)&&!update)throw new ValidationError(Q(0xd8)+Z);if(b['required']&&b['writable']!==![]&&Object['hasOwn'](K,Z)&&(K[Z]===undefined||K[Z]===null)&&update)throw new ValidationError('Required\x20field:\x20'+Z);if(b[Q(0xd9)]&&typeof K[Z]==='string'&&K[Z]['length']<b[Q(0xd9)])throw new ValidationError('minLength\x20not\x20met:\x20'+Z);if(b['maxLength']&&typeof K[Z]===Q(0xda)&&K[Z][Q(0xdb)]>b[Q(0xdc)])throw new ValidationError(Q(0xdd)+Z);if(b[Q(0xde)]&&typeof K[Z]===Q(0xdf)&&K[Z]<b['minimum'])throw new ValidationError(Z+Q(0xe0)+b[Q(0xde)]);if(b[Q(0xe1)]&&typeof K[Z]===Q(0xdf)&&K[Z]>b['maximum'])throw new ValidationError(Z+'\x20should\x20be\x20<=\x20'+b['maximum']);if(b['enum']&&K[Z]&&!b['enum']['includes'](K[Z]))throw new ValidationError(Z+Q(0xe2)+b['enum']['join'](',\x20')+')');if(b['pattern']&&typeof K[Z]===Q(0xda)&&!new RegExp(b[Q(0xe3)])['test'](K[Z]))throw new ValidationError(Z+'\x20should\x20match\x20regular\x20expression\x20('+b['pattern']+')');}};export{validateInputData};
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
- import{fieldColumn,qi}from'./sql.js';function f(x,K){x=x-0x1d9;const Z=t();let b=Z[x];return b;}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','null']);export function parseFilterQuery(x){const k=f,K={...isRecord(x[k(0x1d9)])?x['filter']:{}};for(const [Z,b]of Object['entries'](x)){const Q=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/[k(0x1da)](Z);if(!Q)continue;const [,J,a]=Q;if(!J)continue;if(!a){K[J]=b;continue;}if(!filterOperators['has'](a))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+a);const U=isRecord(K[J])?K[J]:{};U[a]=(a==='in'||a===k(0x1db))&&typeof b==='string'?b['split'](','):b,K[J]=U;}return Object[k(0x1dc)](K)[k(0x1dd)]?K:undefined;}export function buildFilters(x,K,Z=0x1,b){const y=f,Q=[],J=[];for(const [a,U]of Object['entries'](K??{})){const I=x['fields'][a];if(!I||I['filter']!==!![]&&I[y(0x1de)]!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+a);const Y=qi(fieldColumn(x,a)),w=isRecord(U)?U:{'eq':U};for(const [C,V]of Object['entries'](w)){if(!filterOperators['has'](C))throw new ValidationError(y(0x1df)+C);if((C==='like'||C==='ilike')&&I[y(0x1e0)]!==y(0x1e1)&&I['type']!=='text')throw new ValidationError(y(0x1e2)+C+'\x20requires\x20a\x20text\x20field:\x20'+a);b&&autoIndex(x['table'],fieldColumn(x,a),indexTypeFor(I['type'],C),b);if(C==='null'){Q[y(0x1e3)](Y+y(0x1e4)+(isTruthy(V)?'':'NOT\x20')+y(0x1e5));continue;}if(C==='in'||C===y(0x1db)){const S=Array['isArray'](V)?V:[V];if(S[y(0x1dd)]===0x0){Q['push'](C==='in'?'FALSE':'TRUE');continue;}J[y(0x1e3)](S),Q['push'](Y+'\x20'+(C==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(Z+J['length']-0x1)+')');continue;}const z={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':y(0x1e6)},P='$'+(Z+J['length']);if(C==='like'){J['push'](V+'%'),Q[y(0x1e3)]('lower('+Y+')\x20like\x20lower('+P+')');continue;}J['push'](V),Q[y(0x1e3)](Y+'\x20'+z[C]+'\x20'+P);}}return{'sql':Q['length']?y(0x1e7)+Q[y(0x1e8)]('\x20AND\x20'):'','values':J};}function t(){const W=['filter','exec','nin','keys','length','filterable','Unsupported\x20filter\x20operator:\x20','type','string','Operator\x20','push','\x20IS\x20','NULL','like','\x20WHERE\x20','join','ilike'];t=function(){return W;};return t();}function isRecord(x){return typeof x==='object'&&x!==null&&!Array['isArray'](x);}function isTruthy(x){return x===!![]||x==='true'||x==='1'||x===0x1;}function indexTypeFor(x,K){const l=f;if(K==='like'||K===l(0x1e9))return'text';if(x==='geom'||x==='geometry')return'gist';return'btree';}
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
- import{ForbiddenError}from'../../../errors.js';function f(x,K){x=x-0x18a;const Z=t();let b=Z[x];return b;}import{getContext}from'../../../index.js';function t(){const a=['config','includes','access','public','Authentication\x20required','type','admin','Missing\x20permission:\x20'];t=function(){return a;};return t();}export function assertOperation(x,K,Z){const J=f,b=getContext()[J(0x18a)];if(b['debug'])return;if(!x['operations'][J(0x18b)](K))throw new ForbiddenError(x['name']+'.'+K+'\x20is\x20disabled');if(x[J(0x18c)]!==J(0x18d)&&Z===undefined)throw new ForbiddenError(J(0x18e));if(x['access']==='admin'&&Z?.[J(0x18f)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(Z?.['type']!==J(0x190)){const Q=(x['permission']??x['name'])+':'+K;if(!Z?.['permissions']?.[J(0x18b)](Q))throw new ForbiddenError(J(0x191)+Q);}}
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 t(){const I=['slice','fields'];t=function(){return I;};return t();}import{ValidationError}from'../../../errors.js';function f(x,K){x=x-0x9b;const Z=t();let b=Z[x];return b;}export function buildSort(x,K){if(!K?.['length'])return'';typeof K==='string'&&(K=[K]);const Z=K['map'](b=>{const U=f,Q=b['startsWith']('-'),J=Q?b[U(0x9b)](0x1):b,a=x[U(0x9c)][J];if(!a||a['sort']!==!![]&&a['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+J);return qi(fieldColumn(x,J))+'\x20'+(Q?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+Z['join'](',\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
- const a=f;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=x=>'\x22'+x[a(0x1c9)](/"/g,'\x22\x22')+'\x22';export const quoteTable=x=>x['split']('.')['map'](quoteIdentifier)[a(0x1ca)]('.');export function fieldColumn(x,K){if(K===x['key'])return x['key'];const Z=x['fields'][K];if(!Z)throw new ValidationError('Unknown\x20field:\x20'+K);return Z['column']??K;}export function readableFields(x,K){const U=a,Z=Object['entries'](x['fields'])['filter'](([,b])=>b[U(0x1cb)]!==![]&&b['readable']!==![]&&(K?(b['scope']??'all')===K:!![]))['map'](([b,Q])=>quoteIdentifier(Q['column']??b)+U(0x1cc)+quoteIdentifier(b));return!x[U(0x1cd)][x[U(0x1ce)]]&&Z['unshift'](quoteIdentifier(x[U(0x1ce)])),Z;}export function writableData(x,K){const I=a,Z=[];for(const [b,Q]of Object[I(0x1cf)](K)){const J=x[I(0x1cd)][b];if(!J||J[I(0x1d0)]===![]||J['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+b);if((J['write']??J[I(0x1d1)])!==!![])continue;if(J[I(0x1d2)]==='date'&&!K[b])continue;Z['push']([J[I(0x1d3)]??b,Q]);}return Z;}export const qi=quoteIdentifier;function f(x,K){x=x-0x1c9;const Z=t();let b=Z[x];return b;}export const qt=quoteTable;function t(){const Y=['replace','join','read','\x20AS\x20','fields','key','entries','write','writable','type','column'];t=function(){return Y;};return t();}
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
- const getIP=x=>(x['headers']?.['x-real-ip']||x['headers']?.['x-forwarded-for']||x['ip']||x['connection']?.['remoteAddress']||'')['split'](':')['pop']();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.15",
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",