@opengis/fcore 0.0.1-beta.11 → 0.0.1-beta.12

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 (95) 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/get-resource.js +1 -1
  35. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  36. package/dist/modules/resource/services/list-resources.js +1 -1
  37. package/dist/modules/resource/services/search-resource.js +1 -1
  38. package/dist/modules/resource/services/suggest-resource.js +1 -1
  39. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  40. package/dist/modules/resource/services/update-resource.js +1 -1
  41. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  42. package/dist/modules/system/route.js +1 -1
  43. package/dist/modules/system/schema.js +1 -1
  44. package/dist/modules/system/services/check-system.js +1 -1
  45. package/dist/modules/system/services/get-access.js +1 -1
  46. package/dist/modules/system/services/get-api-list.js +1 -1
  47. package/dist/modules/system/services/get-audit-log.js +1 -1
  48. package/dist/modules/system/services/get-dictionary.js +1 -1
  49. package/dist/modules/system/services/get-system-log.js +1 -1
  50. package/dist/modules/system/services/get-system-settings.js +1 -1
  51. package/dist/modules/system/services/list-dictionaries.js +1 -1
  52. package/dist/modules/system/services/set-access.js +1 -1
  53. package/dist/modules/system/services/update-dictionary.js +1 -1
  54. package/dist/modules/system/services/update-system-settings.js +1 -1
  55. package/dist/modules/utils/require-admin.js +1 -1
  56. package/dist/modules/utils/safe-user.js +1 -1
  57. package/dist/modules/utils/unsupported.js +1 -1
  58. package/dist/plugins/audit/audit.js +1 -1
  59. package/dist/plugins/audit/services/write-audit.js +1 -1
  60. package/dist/plugins/auth/get-user-permissions.js +1 -1
  61. package/dist/plugins/auth/index.js +1 -1
  62. package/dist/plugins/auth/verifyUser.js +1 -1
  63. package/dist/plugins/dictionary.js +1 -1
  64. package/dist/plugins/file.js +1 -1
  65. package/dist/plugins/jwt.js +1 -1
  66. package/dist/plugins/logger/index.js +1 -1
  67. package/dist/plugins/logger/transport.js +1 -1
  68. package/dist/plugins/pg.js +1 -1
  69. package/dist/plugins/redis.js +1 -1
  70. package/dist/plugins/resource/resource.js +1 -1
  71. package/dist/plugins/resource/resource.registry.js +1 -1
  72. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  73. package/dist/plugins/resource/services/add-file-token.js +1 -1
  74. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  75. package/dist/plugins/resource/services/create-relation.js +1 -1
  76. package/dist/plugins/resource/services/create.js +1 -1
  77. package/dist/plugins/resource/services/delete-relation.js +1 -1
  78. package/dist/plugins/resource/services/delete.js +1 -1
  79. package/dist/plugins/resource/services/find-one.js +1 -1
  80. package/dist/plugins/resource/services/find-relation.js +1 -1
  81. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  82. package/dist/plugins/resource/services/find.js +1 -1
  83. package/dist/plugins/resource/services/update-relation.js +1 -1
  84. package/dist/plugins/resource/services/update.js +1 -1
  85. package/dist/plugins/resource/utils/auto-index.js +1 -1
  86. package/dist/plugins/resource/utils/fields.js +1 -1
  87. package/dist/plugins/resource/utils/filters.js +1 -1
  88. package/dist/plugins/resource/utils/permissions.js +1 -1
  89. package/dist/plugins/resource/utils/sort.js +1 -1
  90. package/dist/plugins/resource/utils/sql.js +1 -1
  91. package/dist/shared/getIP.js +1 -1
  92. package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
  93. package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
  94. package/migrations/20260905120000_add_user_foreign_keys.sql +42 -42
  95. package/package.json +1 -1
@@ -1 +1 @@
1
- function q(R,t){R=R-0x99;const X=G();let g=X[R];return g;}import{qi,qt}from'../utils/sql.js';const tableLookupCache=new WeakMap();export function clearTableLookupCache(R,t){const H=q,X=tableLookupCache[H(0x99)](t);if(!X)return;for(const g of X[H(0x9a)]()){g[H(0x9b)](R+':')&&X[H(0x9c)](g);}}function G(){const c=['get','keys','startsWith','delete','flatMap','name','has','length','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','\x20=\x20ANY($1)','rows','set'];G=function(){return c;};return G();}export async function addTableLookupData(R,t,X){const n=q;if(!X||R['length']===0x0)return R;const g=tableLookupCache[n(0x99)](X)??new Map();tableLookupCache['set'](X,g);const m=Object['entries'](t)[n(0x9d)](([Z,z])=>{const S=n,{table:l,value:value='id',text:text=S(0x9e)}=z['lookup']??{};return l?[{'field':Z,'table':l,'value':value,'text':text}]:[];});for(const Z of m){const z=new Map();for(const P of R){const E=P[Z['field']];(typeof E==='string'||typeof E==='number')&&z['set'](String(E),E);}const l=Z['table']+':'+Z['value']+':'+Z['text'],y=g[n(0x99)](l)??new Map();g['set'](l,y);const h=[...z['entries']()]['filter'](([C])=>!y[n(0x9f)](C))['map'](([,C])=>C);if(h[n(0xa0)]>0x0){const C=await X['query']('SELECT\x20'+qi(Z['value'])+'\x20AS\x20id,\x20'+qi(Z['text'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(Z['table'])+n(0xa1)+qi(Z['value'])+n(0xa2),[h]);for(const L of C[n(0xa3)]){y[n(0xa4)](String(L['id']),L);}for(const O of h){!y['has'](String(O))&&y['set'](String(O),null);}}for(const U of R){const e=U[Z['field']];U[Z['field']+'_data']=e==null?null:y['get'](String(e))??null;}}return R;}
1
+ function g(){const G=['startsWith','get','flatMap','map','query','SELECT\x20','text','\x20=\x20ANY($1)','_data'];g=function(){return G;};return g();}function A(x,q){x=x-0x134;const C=g();let J=C[x];return J;}import{qi,qt}from'../utils/sql.js';const tableLookupCache=new WeakMap();export function clearTableLookupCache(x,q){const R=A,C=tableLookupCache['get'](q);if(!C)return;for(const J of C['keys']()){J[R(0x134)](x+':')&&C['delete'](J);}}export async function addTableLookupData(x,q,C){const s=A;if(!C||x['length']===0x0)return x;const J=tableLookupCache[s(0x135)](C)??new Map();tableLookupCache['set'](C,J);const K=Object['entries'](q)[s(0x136)](([Z,Y])=>{const {table:b,value:value='id',text:text='name'}=Y['lookup']??{};return b?[{'field':Z,'table':b,'value':value,'text':text}]:[];});for(const Z of K){const Y=new Map();for(const F of x){const y=F[Z['field']];(typeof y==='string'||typeof y==='number')&&Y['set'](String(y),y);}const b=Z['table']+':'+Z['value']+':'+Z['text'],k=J['get'](b)??new Map();J['set'](b,k);const H=[...Y['entries']()]['filter'](([r])=>!k['has'](r))[s(0x137)](([,r])=>r);if(H['length']>0x0){const r=await C[s(0x138)](s(0x139)+qi(Z['value'])+'\x20AS\x20id,\x20'+qi(Z[s(0x13a)])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(Z['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(Z['value'])+s(0x13b),[H]);for(const B of r['rows']){k['set'](String(B['id']),B);}for(const t of H){!k['has'](String(t))&&k['set'](String(t),null);}}for(const p of x){const w=p[Z['field']];p[Z['field']+s(0x13c)]=w==null?null:k['get'](String(w))??null;}}return x;}
@@ -1 +1 @@
1
- function q(R,t){R=R-0x18e;const X=G();let g=X[R];return g;}function G(){const H=['get','notes','includes','Generic\x20Resource\x20relation\x20\x22','query','filePath','foreignKey'];G=function(){return H;};return G();}import{UnsupportedError}from'../../../errors.js';import{createCreate}from'./create.js';export function createCreateRelation(R,t){const X=createCreate(R,t);return async function g({name:m,id:Z,relation:z,data:l,user:y},h){const e=q,P=h?.['pg']??R['pg'],E=t[e(0x18e)](m);if([e(0x18f),'files']['includes'](z)&&!E['capabilities']?.[e(0x190)](z))throw new UnsupportedError(e(0x191)+z+'\x22\x20requires\x20a\x20capabilities\x20\x22'+z+'\x22');if(z===e(0x18f)){const O=await P[e(0x192)]('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[m,String(Z),l?.['body']]);return O['rows'][0x0];}if(z==='files'){const U=await P['query']('INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*',[m,String(Z),l?.[e(0x193)],l?.['size']??null]);return U['rows'][0x0];}const C=E['relations']?.[z];if(!C?.[e(0x194)]||!C['resource']&&!C['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+z+'\x22\x20requires\x20a\x20project/provider\x20implementation');if(!l)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+l);if(!C['resource'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+z);l[C['foreignKey']]=Z;const L=await X({'name':C['resource'],'data':l??{},'user':y});return L;};}
1
+ function g(){const R=['get','includes','Generic\x20Resource\x20relation\x20\x22','body','files','query','INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*','filePath','rows','foreignKey','No\x20data\x20provided\x20for\x20relation:\x20','resource'];g=function(){return R;};return g();}import{UnsupportedError}from'../../../errors.js';function A(x,q){x=x-0x15a;const C=g();let J=C[x];return J;}import{createCreate}from'./create.js';export function createCreateRelation(x,q){const C=createCreate(x,q);return async function J({name:K,id:Z,relation:Y,data:b,user:k},H){const w=A,F=H?.['pg']??x['pg'],y=q[w(0x15a)](K);if(['notes','files'][w(0x15b)](Y)&&!y['capabilities']?.['includes'](Y))throw new UnsupportedError(w(0x15c)+Y+'\x22\x20requires\x20a\x20capabilities\x20\x22'+Y+'\x22');if(Y==='notes'){const t=await F['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[K,String(Z),b?.[w(0x15d)]]);return t['rows'][0x0];}if(Y===w(0x15e)){const p=await F[w(0x15f)](w(0x160),[K,String(Z),b?.[w(0x161)],b?.['size']??null]);return p[w(0x162)][0x0];}const r=y['relations']?.[Y];if(!r?.[w(0x163)]||!r['resource']&&!r['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Y+'\x22\x20requires\x20a\x20project/provider\x20implementation');if(!b)throw new UnsupportedError(w(0x164)+b);if(!r[w(0x165)])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+Y);b[r['foreignKey']]=Z;const B=await C({'name':r['resource'],'data':b??{},'user':k});return B;};}
@@ -1 +1 @@
1
- function q(R,t){R=R-0x1d7;const X=G();let g=X[R];return g;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';function G(){const n=['push','fields','created_by','map','table','VALUES\x20(','audit','write'];G=function(){return n;};return G();}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(R,t){return async function X({name:g,data:m,user:Z},z){const H=q,l=t['get'](g);assertOperation(l,'create',Z),validateInputData({'resource':l,'data':m});const y=writableData(l,m);l['fields']['created_at']&&y[H(0x1d7)](['created_at',new Date()]);l[H(0x1d8)][H(0x1d9)]&&y['push'](['created_by',Z?.['id']]);if(!y['length'])throw new ValidationError('No\x20writable\x20fields');const h=y[H(0x1da)](([U])=>qi(U)),P=y['map']((U,e)=>'$'+(e+0x1)),E=y['map'](([,U])=>U),C=z?.['pg']??R['pg'],L=await C['query']('INSERT\x20INTO\x20'+qt(l[H(0x1db)])+'\x20('+h['join'](',\x20')+')\x20'+(H(0x1dc)+P['join'](',\x20')+')\x20')+('RETURNING\x20'+readableFields(l)['join'](',\x20')),E),O=L['rows'][0x0];return clearTableLookupCache(l['table'],C),await(z?.['audit']??R[H(0x1dd)])?.[H(0x1de)]({'userId':Z?.['id'],'module':l['module'],'resource':l['name'],'resourceId':O[l['key']],'action':'create','fields':Object['keys'](m)}),O;};}
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';function A(x,q){x=x-0x1eb;const C=g();let J=C[x];return J;}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(x,q){return async function C({name:J,data:K,user:Z},Y){const R=A,b=q[R(0x1eb)](J);assertOperation(b,R(0x1ec),Z),validateInputData({'resource':b,'data':K});const k=writableData(b,K);b['fields']['created_at']&&k[R(0x1ed)](['created_at',new Date()]);b[R(0x1ee)]['created_by']&&k['push'](['created_by',Z?.['id']]);if(!k['length'])throw new ValidationError('No\x20writable\x20fields');const H=k['map'](([p])=>qi(p)),F=k['map']((p,w)=>'$'+(w+0x1)),y=k['map'](([,p])=>p),r=Y?.['pg']??x['pg'],B=await r[R(0x1ef)](R(0x1f0)+qt(b['table'])+'\x20('+H['join'](',\x20')+')\x20'+('VALUES\x20('+F[R(0x1f1)](',\x20')+')\x20')+('RETURNING\x20'+readableFields(b)['join'](',\x20')),y),t=B['rows'][0x0];return clearTableLookupCache(b['table'],r),await(Y?.['audit']??x['audit'])?.['write']({'userId':Z?.['id'],'module':b['module'],'resource':b['name'],'resourceId':t[b['key']],'action':R(0x1ec),'fields':Object['keys'](K)}),t;};}function g(){const s=['get','create','push','fields','query','INSERT\x20INTO\x20','join'];g=function(){return s;};return g();}
@@ -1 +1 @@
1
- function q(R,t){R=R-0x173;const X=G();let g=X[R];return g;}import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';export function createDeleteRelation(R,t){const X=createRemove(R,t);return async function g({name:m,id:Z,relation:z,relationId:l,user:y},h){const O=q,P=h?.['pg']??R['pg'],E=t['get'](m);if([O(0x173),O(0x174)]['includes'](z)&&!E['capabilities']?.['includes'](z))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+z+'\x22\x20requires\x20a\x20capabilities\x20\x22'+z+'\x22');if(z==='notes')return await P['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[l,m,String(Z)]),{'success':!![]};if(z==='files')return await P['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[l,m,String(Z)]),{'success':!![]};const C=E['relations']?.[z];if(!C?.['resource']||!C['foreignKey'])throw new UnsupportedError(O(0x175)+z+O(0x176));const L=await X({'name':C['resource'],'id':l,'user':y,'where':{'column':C[O(0x177)],'value':Z}},h);return{'success':L};};}function G(){const U=['notes','files','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','foreignKey'];G=function(){return U;};return G();}
1
+ import{UnsupportedError}from'../../../errors.js';function A(x,q){x=x-0x166;const C=g();let J=C[x];return J;}import{createRemove}from'./delete.js';function g(){const p=['includes','Generic\x20Resource\x20relation\x20\x22','DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','resource','foreignKey'];g=function(){return p;};return g();}export function createDeleteRelation(x,q){const C=createRemove(x,q);return async function J({name:K,id:Z,relation:Y,relationId:b,user:k},H){const t=A,F=H?.['pg']??x['pg'],y=q['get'](K);if(['notes','files'][t(0x166)](Y)&&!y['capabilities']?.[t(0x166)](Y))throw new UnsupportedError(t(0x167)+Y+'\x22\x20requires\x20a\x20capabilities\x20\x22'+Y+'\x22');if(Y==='notes')return await F['query'](t(0x168),[b,K,String(Z)]),{'success':!![]};if(Y==='files')return await F['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[b,K,String(Z)]),{'success':!![]};const r=y['relations']?.[Y];if(!r?.[t(0x169)]||!r[t(0x16a)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Y+'\x22\x20requires\x20a\x20project/provider\x20implementation');const B=await C({'name':r['resource'],'id':b,'user':k,'where':{'column':r['foreignKey'],'value':Z}},H);return{'success':B};};}
@@ -1 +1 @@
1
- function q(R,t){R=R-0x181;const X=G();let g=X[R];return g;}function G(){const O=['WHERE\x20','\x20=\x20$','length','rowCount','audit','write','module','name'];G=function(){return O;};return G();}import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(R,t){return async function X({name:g,id:m,user:Z,where:z},l){const L=q,y=t['get'](g);assertOperation(y,'delete',Z);const h=l?.['pg']??R['pg'],P=[m];let E=L(0x181)+qi(y['key'])+'\x20=\x20$1';z&&(P['push'](z['value']),E+='\x20AND\x20'+qi(z['column'])+L(0x182)+P[L(0x183)]);const C=await h['query']('DELETE\x20FROM\x20'+qt(y['table'])+'\x20'+E,P);if((C['rowCount']??0x0)>0x0)clearTableLookupCache(y['table'],h);if((C[L(0x184)]??0x0)>0x0)await(l?.['audit']??R[L(0x185)])?.[L(0x186)]({'module':y[L(0x187)],'resource':y[L(0x188)],'resourceId':m,'action':'delete'});return(C[L(0x184)]??0x0)>0x0;};}
1
+ import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';function A(x,q){x=x-0xf0;const C=g();let J=C[x];return J;}function g(){const t=['get','key','length','audit','write','name','rowCount'];g=function(){return t;};return g();}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(x,q){return async function C({name:J,id:K,user:Z,where:Y},b){const B=A,k=q[B(0xf0)](J);assertOperation(k,'delete',Z);const H=b?.['pg']??x['pg'],F=[K];let y='WHERE\x20'+qi(k[B(0xf1)])+'\x20=\x20$1';Y&&(F['push'](Y['value']),y+='\x20AND\x20'+qi(Y['column'])+'\x20=\x20$'+F[B(0xf2)]);const r=await H['query']('DELETE\x20FROM\x20'+qt(k['table'])+'\x20'+y,F);if((r['rowCount']??0x0)>0x0)clearTableLookupCache(k['table'],H);if((r['rowCount']??0x0)>0x0)await(b?.[B(0xf3)]??x['audit'])?.[B(0xf4)]({'module':k['module'],'resource':k[B(0xf5)],'resourceId':K,'action':'delete'});return(r[B(0xf6)]??0x0)>0x0;};}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';function G(){const c=['read','fields','key','type','\x20name:','join','\x20WHERE\x20','=$1\x20LIMIT\x201','resource','\x20FROM\x20','foreignKey','query'];G=function(){return c;};return G();}import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';function q(R,t){R=R-0x83;const X=G();let g=X[R];return g;}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(R,t){return async function X({name:g,id:m,query:query={},user:Z}){const S=q,z=Date['now'](),l=t['get'](g);assertOperation(l,S(0x83),Z);if(l[S(0x84)][l[S(0x85)]]?.[S(0x86)]==='integer'&&!Number['isInteger'](Number(m)))throw new ValidationError('Invalid\x20id:\x20'+m+S(0x87)+g);const y=await R['pg']['query']('SELECT\x20'+readableFields(l)[S(0x88)](',\x20')+'\x20FROM\x20'+qt(l['table'])+S(0x89)+qi(l['key'])+S(0x8a),[m]),h=y['rows'][0x0];if(!h)return null;await addDictionaryLookupData([h],l['fields'],R['dictionary']),await addTableLookupData([h],l['fields'],R['pg']),addFileToken([h],l['fields'],R['file']);const P=Array['isArray'](query['include'])?query['include']:query['include']?.['split'](',')??[];for(const E of P){const C=l['relations']?.[E];if(!C?.['foreignKey']||!C['resource']&&!C['table'])throw new ValidationError('Unknown\x20relation:\x20'+E);const L=C['resource']?t['get'](C[S(0x8b)]):undefined,O=C['table']??L['table'],U=L?.['key']??'id',e=L?readableFields(L)['join'](',\x20'):'*',H='SELECT\x20'+e+S(0x8c)+qt(O)+'\x20WHERE\x20'+qi(U)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(C[S(0x8d)])+S(0x8c)+qt(l['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(l['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',n=(await R['pg'][S(0x8e)](H,[m]))['rows'];L&&(await addDictionaryLookupData(n,L['fields'],R['dictionary']),await addTableLookupData(n,L['fields'],R['pg']),addFileToken(n,L['fields'],R['file'])),h[E]=n;}return h['time']=Date['now']()-z,h;};}
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function g(){const h=['read','key','integer','Invalid\x20id:\x20','join','fields','include','resource','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','dictionary','time'];g=function(){return h;};return g();}function A(x,q){x=x-0x10e;const C=g();let J=C[x];return J;}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(x,q){return async function C({name:J,id:K,query:query={},user:Z}){const G=A,Y=Date['now'](),b=q['get'](J);assertOperation(b,G(0x10e),Z);if(b['fields'][b[G(0x10f)]]?.['type']===G(0x110)&&!Number['isInteger'](Number(K)))throw new ValidationError(G(0x111)+K+'\x20name:'+J);const k=await x['pg']['query']('SELECT\x20'+readableFields(b)[G(0x112)](',\x20')+'\x20FROM\x20'+qt(b['table'])+'\x20WHERE\x20'+qi(b['key'])+'=$1\x20LIMIT\x201',[K]),H=k['rows'][0x0];if(!H)return null;await addDictionaryLookupData([H],b['fields'],x['dictionary']),await addTableLookupData([H],b[G(0x113)],x['pg']),addFileToken([H],b['fields'],x['file']);const F=Array['isArray'](query['include'])?query[G(0x114)]:query['include']?.['split'](',')??[];for(const y of F){const r=b['relations']?.[y];if(!r?.['foreignKey']||!r['resource']&&!r['table'])throw new ValidationError('Unknown\x20relation:\x20'+y);const B=r['resource']?q['get'](r[G(0x115)]):undefined,t=r['table']??B['table'],p=B?.[G(0x10f)]??'id',w=B?readableFields(B)['join'](',\x20'):'*',R='SELECT\x20'+w+'\x20FROM\x20'+qt(t)+'\x20WHERE\x20'+qi(p)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(r['foreignKey'])+'\x20FROM\x20'+qt(b['table'])+G(0x116)+qi(b[G(0x10f)])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',s=(await x['pg']['query'](R,[K]))['rows'];B&&(await addDictionaryLookupData(s,B[G(0x113)],x[G(0x117)]),await addTableLookupData(s,B['fields'],x['pg']),addFileToken(s,B[G(0x113)],x['file'])),H[y]=s;}return H[G(0x118)]=Date['now']()-Y,H;};}
@@ -1 +1 @@
1
- function q(R,t){R=R-0x176;const X=G();let g=X[R];return g;}import{UnsupportedError,ValidationError}from'../../../errors.js';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';function G(){const o=['max','relations','files','\x22\x20requires\x20a\x20capabilities\x20\x22','rows','length','now','junctionTable','junctionLocalKey','foreignKey','key','map','t.*','SELECT\x20','\x0a\x20\x20\x20\x20WHERE\x20j.','file'];G=function(){return o;};return G();}export function createFindRelation(R,t){return async function X({name:g,id:m,relation:Z,query:query={}}){const Q=q,z=Date['now'](),l=Math['min'](Math[Q(0x176)](query['limit']??0x14,0x1),0xc8),y=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](l)||!Number['isFinite'](y))throw new ValidationError('Invalid\x20pagination');const h=t['get'](g),P=h[Q(0x177)]?.[Z];if(['notes',Q(0x178)]['includes'](Z)&&!h['capabilities']?.['includes'](Z))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Z+Q(0x179)+Z+'\x22');if(Z==='notes'){const n=await R['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[g,String(m)]);return{'total':n[Q(0x17a)][Q(0x17b)],'time':Date[Q(0x17c)]()-z,'rows':n['rows']};}if(Z===Q(0x178)){const S=await R['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[g,String(m)]);return addFileToken(S['rows'],{'file_path':{'type':'file'}},R['file']),{'total':S[Q(0x17a)]['length'],'time':Date['now']()-z,'rows':S['rows']};}const E=!!(P?.[Q(0x17d)]&&P[Q(0x17e)]&&P['junctionForeignKey']);if(!P||!E&&!P[Q(0x17f)]||!P['resource']&&!P['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Z+'\x22\x20requires\x20a\x20project/provider\x20implementation');const C=P['resource']?t['get'](P['resource']):undefined,L=P['table']??C['table'],O=C?.[Q(0x180)]??'id',U=P['fields']?.[Q(0x17b)]?P['fields'][Q(0x181)](c=>E?'t.'+qi(c):qi(c))['join'](',\x20'):E?Q(0x182):'*';P['foreignKey']&&autoIndex(L,P['foreignKey'],'btree',R['pg']);const e=E?Q(0x183)+U+'\x20FROM\x20'+qt(L)+'\x20t\x0a\x20\x20\x20\x20JOIN\x20'+qt(P['junctionTable'])+'\x20j\x20ON\x20j.'+qi(P['junctionForeignKey'])+'\x20=\x20t.'+qi(O)+Q(0x184)+qi(P['junctionLocalKey'])+'\x20=\x20$1\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3':Q(0x183)+U+'\x20FROM\x20'+qt(L)+'\x20WHERE\x20'+qi(P[Q(0x17f)])+'\x20=\x20$1\x20LIMIT\x20$2\x20OFFSET\x20$3',H=await R['pg']['query'](e,[m,l,y]);return C&&(await addDictionaryLookupData(H[Q(0x17a)],C['fields'],R['dictionary']),await addTableLookupData(H['rows'],C['fields'],R['pg']),addFileToken(H['rows'],C['fields'],R[Q(0x185)])),{'limit':l,'offset':y,'total':H['rows']['length'],'time':Date['now']()-z,'rows':H['rows']??null};};}
1
+ import{UnsupportedError,ValidationError}from'../../../errors.js';function A(x,q){x=x-0x1a7;const C=g();let J=C[x];return J;}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(x,q){return async function C({name:J,id:K,relation:Z,query:query={}}){const a=A,Y=Date['now'](),b=Math['min'](Math[a(0x1a7)](query[a(0x1a8)]??0x14,0x1),0xc8),k=Math[a(0x1a7)](query['offset']??0x0,0x0);if(!Number[a(0x1a9)](b)||!Number['isFinite'](k))throw new ValidationError('Invalid\x20pagination');const H=q['get'](J),F=H['relations']?.[Z];if(['notes',a(0x1aa)][a(0x1ab)](Z)&&!H[a(0x1ac)]?.['includes'](Z))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Z+a(0x1ad)+Z+'\x22');if(Z==='notes'){const s=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',[J,String(K)]);return{'total':s[a(0x1ae)]['length'],'time':Date['now']()-Y,'rows':s['rows']};}if(Z==='files'){const G=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',[J,String(K)]);return addFileToken(G['rows'],{'file_path':{'type':'file'}},x[a(0x1af)]),{'total':G['rows']['length'],'time':Date['now']()-Y,'rows':G['rows']};}const y=!!(F?.[a(0x1b0)]&&F[a(0x1b1)]&&F[a(0x1b2)]);if(!F||!y&&!F['foreignKey']||!F['resource']&&!F['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Z+'\x22\x20requires\x20a\x20project/provider\x20implementation');const r=F['resource']?q['get'](F['resource']):undefined,B=F['table']??r['table'],t=r?.['key']??'id',p=F['fields']?.[a(0x1b3)]?F[a(0x1b4)]['map'](h=>y?'t.'+qi(h):qi(h))['join'](',\x20'):y?'t.*':'*';F['foreignKey']&&autoIndex(B,F['foreignKey'],'btree',x['pg']);const w=y?'SELECT\x20'+p+'\x20FROM\x20'+qt(B)+'\x20t\x0a\x20\x20\x20\x20JOIN\x20'+qt(F['junctionTable'])+'\x20j\x20ON\x20j.'+qi(F[a(0x1b2)])+a(0x1b5)+qi(t)+'\x0a\x20\x20\x20\x20WHERE\x20j.'+qi(F['junctionLocalKey'])+a(0x1b6):'SELECT\x20'+p+'\x20FROM\x20'+qt(B)+'\x20WHERE\x20'+qi(F['foreignKey'])+'\x20=\x20$1\x20LIMIT\x20$2\x20OFFSET\x20$3',R=await x['pg'][a(0x1b7)](w,[K,b,k]);return r&&(await addDictionaryLookupData(R['rows'],r['fields'],x[a(0x1b8)]),await addTableLookupData(R['rows'],r['fields'],x['pg']),addFileToken(R['rows'],r['fields'],x['file'])),{'limit':b,'offset':k,'total':R[a(0x1ae)]['length'],'time':Date['now']()-Y,'rows':R['rows']??null};};}function g(){const m=['max','limit','isFinite','files','includes','capabilities','\x22\x20requires\x20a\x20capabilities\x20\x22','rows','file','junctionTable','junctionLocalKey','junctionForeignKey','length','fields','\x20=\x20t.','\x20=\x20$1\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3','query','dictionary'];g=function(){return m;};return g();}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAgDhC"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CA+ChC"}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';function G(){const H=['now','min','limit','max','offset','fields','search','map','table','text',')\x20LIKE\x20$','\x20OR\x20','Filters:','FROM\x20','query','file'];G=function(){return H;};return G();}import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';function q(R,t){R=R-0x116;const X=G();let g=X[R];return g;}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(R,t){return async function X({name:g,query:query={},user:m}){const e=q,Z=Date[e(0x116)](),z=t['get'](g);assertOperation(z,'read',m);const l=Math[e(0x117)](Math['max'](query[e(0x118)]??0x14,0x1),0xc8),y=Math[e(0x119)](query[e(0x11a)]??0x0,0x0),h=buildFilters(z,query['filter'],0x1,R['pg']),P=buildSort(z,query['sort']);if(!Number['isFinite'](l)||!Number['isFinite'](y))throw new ValidationError('Invalid\x20pagination');const E=z['searchable']||Object['keys'](z['fields'])['filter'](U=>z[e(0x11b)][U]?.['searchable']);query[e(0x11c)]&&E['length']&&(E[e(0x11d)](U=>autoIndex(z[e(0x11e)],U,e(0x11f),R['pg'])),h['values']['push'](query['search']['toLowerCase']()+'%'),h['sql']+=(h['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+E?.['map'](U=>'lower('+qt(U)+e(0x120)+h['values']['length'])['join'](e(0x121))+')'));console['log'](e(0x122),h);const C='SELECT\x20'+readableFields(z)['join'](',\x20')+'\x20'+(e(0x123)+qt(z['table']))+(''+h['sql']+P+'\x20')+('LIMIT\x20$'+(h['values']['length']+0x1)+'\x20')+('OFFSET\x20$'+(h['values']['length']+0x2)),L=await R['pg'][e(0x124)](C,[...h['values'],l,y]),O=L['rows'];return await addDictionaryLookupData(O,z['fields'],R['dictionary']),await addTableLookupData(O,z[e(0x11b)],R['pg']),addFileToken(O,z['fields'],R[e(0x125)]),{'limit':l,'offset':y,'total':L['rowCount'],'time':Date['now']()-Z,'rows':O};};}
1
+ import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';function A(x,q){x=x-0x1ae;const C=g();let J=C[x];return J;}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';function g(){const R=['get','read','min','max','limit','offset','filter','isFinite','Invalid\x20pagination','length','table','toLowerCase','sql','\x20WHERE\x20','map','lower(','values','SELECT\x20','join','OFFSET\x20$','rows','fields'];g=function(){return R;};return g();}import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFind(x,q){return async function C({name:J,query:query={},user:K}){const w=A,Z=Date['now'](),Y=q[w(0x1ae)](J);assertOperation(Y,w(0x1af),K);const b=Math[w(0x1b0)](Math[w(0x1b1)](query[w(0x1b2)]??0x14,0x1),0xc8),k=Math['max'](query[w(0x1b3)]??0x0,0x0),H=buildFilters(Y,query[w(0x1b4)],0x1,x['pg']),F=buildSort(Y,query['sort']);if(!Number['isFinite'](b)||!Number[w(0x1b5)](k))throw new ValidationError(w(0x1b6));const y=Y['searchable']||Object['keys'](Y['fields'])[w(0x1b4)](p=>Y['fields'][p]?.['searchable']);query['search']&&y[w(0x1b7)]&&(y['map'](p=>autoIndex(Y[w(0x1b8)],p,'text',x['pg'])),H['values']['push'](query['search'][w(0x1b9)]()+'%'),H['sql']+=(H[w(0x1ba)]?'\x20AND\x20':w(0x1bb))+('\x20('+y?.[w(0x1bc)](p=>w(0x1bd)+qt(p)+')\x20LIKE\x20$'+H[w(0x1be)][w(0x1b7)])['join']('\x20OR\x20')+')'));const r=w(0x1bf)+readableFields(Y)[w(0x1c0)](',\x20')+'\x20'+('FROM\x20'+qt(Y['table']))+(''+H['sql']+F+'\x20')+('LIMIT\x20$'+(H['values']['length']+0x1)+'\x20')+(w(0x1c1)+(H[w(0x1be)]['length']+0x2)),B=await x['pg']['query'](r,[...H['values'],b,k]),t=B[w(0x1c2)];return await addDictionaryLookupData(t,Y[w(0x1c3)],x['dictionary']),await addTableLookupData(t,Y['fields'],x['pg']),addFileToken(t,Y['fields'],x['file']),{'limit':b,'offset':k,'total':B['rowCount'],'time':Date['now']()-Z,'rows':t};};}
@@ -1 +1 @@
1
- function q(R,t){R=R-0x163;const X=G();let g=X[R];return g;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(R,t){const X=createUpdate(R,t);return async function g({name:m,id:Z,relation:z,relationId:l,data:y,user:h},P){const L=q,E=t['get'](m),C=E['relations']?.[z];if(!C?.[L(0x163)]||!C['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+z);if(Object['hasOwn'](y,C['foreignKey'])&&y[C['foreignKey']]!==Z)throw new ValidationError('Cannot\x20change\x20relation:\x20'+C['foreignKey']);return X({'name':C[L(0x163)],'id':l,'data':y,'user':h,'where':{'column':C[L(0x164)],'value':Z}},P);};}function G(){const O=['resource','foreignKey'];G=function(){return O;};return G();}
1
+ function A(x,q){x=x-0x181;const C=g();let J=C[x];return J;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(x,q){const C=createUpdate(x,q);return async function J({name:K,id:Z,relation:Y,relationId:b,data:k,user:H},F){const B=A,y=q['get'](K),r=y[B(0x181)]?.[Y];if(!r?.[B(0x182)]||!r['foreignKey'])throw new UnsupportedError(B(0x183)+Y);if(Object['hasOwn'](k,r['foreignKey'])&&k[r['foreignKey']]!==Z)throw new ValidationError('Cannot\x20change\x20relation:\x20'+r[B(0x184)]);return C({'name':r['resource'],'id':b,'data':k,'user':H,'where':{'column':r['foreignKey'],'value':Z}},F);};}function g(){const t=['relations','resource','Relation\x20update\x20is\x20not\x20configured:\x20','foreignKey'];g=function(){return t;};return g();}
@@ -1 +1 @@
1
- import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';function G(){const c=['updated_at','push','updated_by','\x20=\x20$','key','length','value','\x20AND\x20','column','query','table','RETURNING\x20','update'];G=function(){return c;};return G();}function q(R,t){R=R-0x1f0;const X=G();let g=X[R];return g;}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(R,t){return async function X({name:g,id:m,data:Z,user:z,where:l},y){const S=q,h=t['get'](g);assertOperation(h,'update',z);const P=writableData(h,Z);if(!P['length'])throw new ValidationError('No\x20writable\x20fields');const E=y?.['pg']??R['pg'];validateInputData({'resource':h,'data':Z,'update':!![]});h['fields'][S(0x1f0)]&&P[S(0x1f1)](['updated_at',new Date()]);h['fields']['updated_by']&&P['push']([S(0x1f2),z?.['id']]);delete Z['user_type'];const C=P['map'](([H],n)=>qi(H)+S(0x1f3)+(n+0x1)),L=[...P['map'](([,H])=>H),m];let O='WHERE\x20'+qi(h[S(0x1f4)])+'\x20=\x20$'+L[S(0x1f5)];l&&(L['push'](l[S(0x1f6)]),O+=S(0x1f7)+qi(l[S(0x1f8)])+'\x20=\x20$'+L['length']);const U=await E[S(0x1f9)]('UPDATE\x20'+qt(h[S(0x1fa)])+'\x20'+('SET\x20'+C['join'](',\x20')+'\x20')+(O+'\x20')+(S(0x1fb)+readableFields(h)['join'](',\x20')),L),e=U['rows'][0x0];if(!e)throw new NotFoundError(g+':'+m);return clearTableLookupCache(h['table'],E),await(y?.['audit']??R['audit'])?.['write']({'userId':z?.['id'],'module':h['module'],'resource':h['name'],'resourceId':m,'action':S(0x1fc),'fields':Object['keys'](Z)}),e;};}
1
+ import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function A(x,q){x=x-0x8b;const C=g();let J=C[x];return J;}export function createUpdate(x,q){return async function C({name:J,id:K,data:Z,user:Y,where:b},k){const G=A,H=q['get'](J);assertOperation(H,'update',Y);const F=writableData(H,Z);if(!F['length'])throw new ValidationError('No\x20writable\x20fields');const y=k?.['pg']??x['pg'];validateInputData({'resource':H,'data':Z,'update':!![]});H['fields']['updated_at']&&F['push'](['updated_at',new Date()]);H[G(0x8b)]['updated_by']&&F['push']([G(0x8c),Y?.['id']]);delete Z[G(0x8d)];const r=F[G(0x8e)](([R],s)=>qi(R)+'\x20=\x20$'+(s+0x1)),B=[...F['map'](([,R])=>R),K];let t='WHERE\x20'+qi(H['key'])+'\x20=\x20$'+B[G(0x8f)];b&&(B['push'](b['value']),t+='\x20AND\x20'+qi(b['column'])+'\x20=\x20$'+B['length']);const p=await y['query']('UPDATE\x20'+qt(H[G(0x90)])+'\x20'+('SET\x20'+r[G(0x91)](',\x20')+'\x20')+(t+'\x20')+('RETURNING\x20'+readableFields(H)[G(0x91)](',\x20')),B),w=p[G(0x92)][0x0];if(!w)throw new NotFoundError(J+':'+K);return clearTableLookupCache(H[G(0x90)],y),await(k?.['audit']??x['audit'])?.['write']({'userId':Y?.['id'],'module':H[G(0x93)],'resource':H['name'],'resourceId':K,'action':'update','fields':Object[G(0x94)](Z)}),w;};}function g(){const h=['fields','updated_by','user_type','map','length','table','join','rows','module','keys'];g=function(){return h;};return g();}
@@ -1 +1 @@
1
- function q(R,t){R=R-0x17a;const X=G();let g=X[R];return g;}import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(R,t,X='btree',g){const m=requestedIndexes['get'](g)??new Set();requestedIndexes['set'](g,m);const Z=R+':'+t+':'+X;if(m['has'](Z))return;m['add'](Z),void ensureIndex(R,t,X,g)['catch'](()=>{m['delete'](Z);});}function G(){const h=['split','public','replace','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','\x20USING\x20btree\x20(lower(','query','\x20USING\x20'];G=function(){return h;};return G();}async function ensureIndex(R,t,X,g){const y=q,m=R[y(0x17a)]('.'),Z=m['length']===0x2?m[0x0]:y(0x17b),z=(R+'_'+t+'_'+X+'_idx')[y(0x17c)](/[^A-Za-z0-9_]/g,'_'),l=await g['query'](y(0x17d),[Z,z]);if(l['rowCount'])return;if(X==='text'){await g['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await g['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(z+'_l')+'\x20ON\x20'+qt(R)+y(0x17e)+qi(t)+')\x20text_pattern_ops)'),await g['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(z)+'\x20ON\x20'+qt(R)+'\x20USING\x20gin\x20(lower('+qi(t)+')\x20gin_trgm_ops)');return;}await g[y(0x17f)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(z)+'\x20ON\x20'+qt(R)+y(0x180)+X+'\x20('+qi(t)+')');}
1
+ function A(x,q){x=x-0x1d7;const C=g();let J=C[x];return J;}import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(x,q,C='btree',J){const k=A,K=requestedIndexes['get'](J)??new Set();requestedIndexes['set'](J,K);const Z=x+':'+q+':'+C;if(K[k(0x1d7)](Z))return;K['add'](Z),void ensureIndex(x,q,C,J)[k(0x1d8)](()=>{K['delete'](Z);});}async function ensureIndex(x,q,C,J){const H=A,K=x['split']('.'),Z=K['length']===0x2?K[0x0]:H(0x1d9),Y=(x+'_'+q+'_'+C+H(0x1da))['replace'](/[^A-Za-z0-9_]/g,'_'),b=await J[H(0x1db)](H(0x1dc),[Z,Y]);if(b['rowCount'])return;if(C===H(0x1dd)){await J[H(0x1db)]('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await J['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(Y+'_l')+'\x20ON\x20'+qt(x)+'\x20USING\x20btree\x20(lower('+qi(q)+H(0x1de)),await J['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(Y)+'\x20ON\x20'+qt(x)+'\x20USING\x20gin\x20(lower('+qi(q)+H(0x1df));return;}await J['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(Y)+H(0x1e0)+qt(x)+'\x20USING\x20'+C+'\x20('+qi(q)+')');}function g(){const F=['has','catch','public','_idx','query','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','text',')\x20text_pattern_ops)',')\x20gin_trgm_ops)','\x20ON\x20'];g=function(){return F;};return g();}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function G(){const Z=['fields','required','writable','maxLength','minimum','number','pattern','\x20should\x20match\x20regular\x20expression\x20('];G=function(){return Z;};return G();}const validateInputData=({resource:R,data:t,update:update=![]})=>{const m=q;for(const [X,g]of Object['entries'](R[m(0x140)])){if(g[m(0x141)]&&g[m(0x142)]!==![]&&(t[X]===undefined||t[X]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+X);if(g['required']&&g['writable']!==![]&&Object['hasOwn'](t,X)&&(t[X]===undefined||t[X]===null)&&update)throw new ValidationError('Required\x20field:\x20'+X);if(g['minLength']&&typeof t[X]==='string'&&t[X]['length']<g['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+X);if(g[m(0x143)]&&typeof t[X]==='string'&&t[X]['length']>g['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+X);if(g[m(0x144)]&&typeof t[X]===m(0x145)&&t[X]<g['minimum'])throw new ValidationError(X+'\x20should\x20be\x20>=\x20'+g[m(0x144)]);if(g['maximum']&&typeof t[X]==='number'&&t[X]>g['maximum'])throw new ValidationError(X+'\x20should\x20be\x20<=\x20'+g['maximum']);if(g['enum']&&t[X]&&!g['enum']['includes'](t[X]))throw new ValidationError(X+'\x20should\x20be\x20one\x20of\x20('+g['enum']['join'](',\x20')+')');if(g[m(0x146)]&&typeof t[X]==='string'&&!new RegExp(g['pattern'])['test'](t[X]))throw new ValidationError(X+m(0x147)+g['pattern']+')');}};function q(R,t){R=R-0x140;const X=G();let g=X[R];return g;}export{validateInputData};
1
+ function g(){const Z=['writable','minLength','maxLength','length','maxLength\x20exceeded:\x20','number','maximum','enum','join','pattern'];g=function(){return Z;};return g();}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function A(x,q){x=x-0x11d;const C=g();let J=C[x];return J;}const validateInputData=({resource:x,data:q,update:update=![]})=>{const K=A;for(const [C,J]of Object['entries'](x['fields'])){if(J['required']&&J['writable']!==![]&&(q[C]===undefined||q[C]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+C);if(J['required']&&J[K(0x11d)]!==![]&&Object['hasOwn'](q,C)&&(q[C]===undefined||q[C]===null)&&update)throw new ValidationError('Required\x20field:\x20'+C);if(J[K(0x11e)]&&typeof q[C]==='string'&&q[C]['length']<J['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+C);if(J[K(0x11f)]&&typeof q[C]==='string'&&q[C][K(0x120)]>J[K(0x11f)])throw new ValidationError(K(0x121)+C);if(J['minimum']&&typeof q[C]==='number'&&q[C]<J['minimum'])throw new ValidationError(C+'\x20should\x20be\x20>=\x20'+J['minimum']);if(J['maximum']&&typeof q[C]===K(0x122)&&q[C]>J[K(0x123)])throw new ValidationError(C+'\x20should\x20be\x20<=\x20'+J['maximum']);if(J['enum']&&q[C]&&!J[K(0x124)]['includes'](q[C]))throw new ValidationError(C+'\x20should\x20be\x20one\x20of\x20('+J['enum'][K(0x125)](',\x20')+')');if(J['pattern']&&typeof q[C]==='string'&&!new RegExp(J[K(0x126)])['test'](q[C]))throw new ValidationError(C+'\x20should\x20match\x20regular\x20expression\x20('+J['pattern']+')');}};export{validateInputData};
@@ -1 +1 @@
1
- function q(R,t){R=R-0xc7;const X=G();let g=X[R];return g;}const e=q;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',e(0xc7),'null']);function G(){const Q=['ilike','entries','has','nin','filter','filterable','type','\x20requires\x20a\x20text\x20field:\x20','push','FALSE','join','\x20AND\x20','object','gist'];G=function(){return Q;};return G();}export function parseFilterQuery(R){const H=e,t={...isRecord(R['filter'])?R['filter']:{}};for(const [X,g]of Object[H(0xc8)](R)){const m=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](X);if(!m)continue;const [,Z,z]=m;if(!Z)continue;if(!z){t[Z]=g;continue;}if(!filterOperators[H(0xc9)](z))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+z);const l=isRecord(t[Z])?t[Z]:{};l[z]=(z==='in'||z===H(0xca))&&typeof g==='string'?g['split'](','):g,t[Z]=l;}return Object['keys'](t)['length']?t:undefined;}export function buildFilters(R,t,X=0x1,g){const n=e,m=[],Z=[];for(const [z,l]of Object['entries'](t??{})){const y=R['fields'][z];if(!y||y[n(0xcb)]!==!![]&&y[n(0xcc)]!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+z);const h=qi(fieldColumn(R,z)),P=isRecord(l)?l:{'eq':l};for(const [E,C]of Object['entries'](P)){if(!filterOperators[n(0xc9)](E))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+E);if((E==='like'||E==='ilike')&&y['type']!=='string'&&y[n(0xcd)]!=='text')throw new ValidationError('Operator\x20'+E+n(0xce)+z);g&&autoIndex(R['table'],fieldColumn(R,z),indexTypeFor(y['type'],E),g);if(E==='null'){m[n(0xcf)](h+'\x20IS\x20'+(isTruthy(C)?'':'NOT\x20')+'NULL');continue;}if(E==='in'||E===n(0xca)){const U=Array['isArray'](C)?C:[C];if(U['length']===0x0){m['push'](E==='in'?n(0xd0):'TRUE');continue;}Z['push'](U),m['push'](h+'\x20'+(E==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(X+Z['length']-0x1)+')');continue;}const L={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},O='$'+(X+Z['length']);if(E==='like'){Z['push'](C+'%'),m[n(0xcf)]('lower('+h+')\x20like\x20lower('+O+')');continue;}Z['push'](C),m[n(0xcf)](h+'\x20'+L[E]+'\x20'+O);}}return{'sql':m['length']?'\x20WHERE\x20'+m[n(0xd1)](n(0xd2)):'','values':Z};}function isRecord(R){const S=e;return typeof R===S(0xd3)&&R!==null&&!Array['isArray'](R);}function isTruthy(R){return R===!![]||R==='true'||R==='1'||R===0x1;}function indexTypeFor(R,t){const c=e;if(t==='like'||t==='ilike')return'text';if(R==='geom'||R==='geometry')return c(0xd4);return'btree';}
1
+ const w=A;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',w(0xe6),'like',w(0xe7),w(0xe8)]);export function parseFilterQuery(x){const R=w,q={...isRecord(x['filter'])?x['filter']:{}};for(const [C,J]of Object['entries'](x)){const K=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](C);if(!K)continue;const [,Z,Y]=K;if(!Z)continue;if(!Y){q[Z]=J;continue;}if(!filterOperators['has'](Y))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+Y);const b=isRecord(q[Z])?q[Z]:{};b[Y]=(Y==='in'||Y==='nin')&&typeof J==='string'?J['split'](','):J,q[Z]=b;}return Object[R(0xe9)](q)['length']?q:undefined;}export function buildFilters(x,q,C=0x1,J){const s=w,K=[],Z=[];for(const [Y,b]of Object['entries'](q??{})){const k=x[s(0xea)][Y];if(!k||k['filter']!==!![]&&k[s(0xeb)]!==!![])throw new ValidationError(s(0xec)+Y);const H=qi(fieldColumn(x,Y)),F=isRecord(b)?b:{'eq':b};for(const [y,r]of Object['entries'](F)){if(!filterOperators[s(0xed)](y))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+y);if((y===s(0xee)||y==='ilike')&&k[s(0xef)]!==s(0xf0)&&k[s(0xef)]!==s(0xf1))throw new ValidationError('Operator\x20'+y+s(0xf2)+Y);J&&autoIndex(x['table'],fieldColumn(x,Y),indexTypeFor(k[s(0xef)],y),J);if(y==='null'){K['push'](H+'\x20IS\x20'+(isTruthy(r)?'':'NOT\x20')+'NULL');continue;}if(y==='in'||y==='nin'){const p=Array['isArray'](r)?r:[r];if(p['length']===0x0){K[s(0xf3)](y==='in'?'FALSE':'TRUE');continue;}Z['push'](p),K[s(0xf3)](H+'\x20'+(y==='in'?'=\x20ANY':s(0xf4))+'($'+(C+Z['length']-0x1)+')');continue;}const B={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},t='$'+(C+Z['length']);if(y==='like'){Z[s(0xf3)](r+'%'),K['push']('lower('+H+s(0xf5)+t+')');continue;}Z[s(0xf3)](r),K['push'](H+'\x20'+B[y]+'\x20'+t);}}return{'sql':K['length']?s(0xf6)+K['join']('\x20AND\x20'):'','values':Z};}function isRecord(x){return typeof x==='object'&&x!==null&&!Array['isArray'](x);}function A(x,q){x=x-0xe6;const C=g();let J=C[x];return J;}function isTruthy(x){return x===!![]||x==='true'||x==='1'||x===0x1;}function indexTypeFor(x,q){const G=w;if(q===G(0xee)||q==='ilike')return G(0xf1);if(x==='geom'||x===G(0xf7))return G(0xf8);return G(0xf9);}function g(){const h=['nin','ilike','null','keys','fields','filterable','Field\x20is\x20not\x20filterable:\x20','has','like','type','string','text','\x20requires\x20a\x20text\x20field:\x20','push','<>\x20ALL',')\x20like\x20lower(','\x20WHERE\x20','geometry','gist','btree'];g=function(){return h;};return g();}
@@ -1 +1 @@
1
- import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';function q(R,t){R=R-0x1a2;const X=G();let g=X[R];return g;}export function assertOperation(R,t,X){const Z=q,g=getContext()['config'];if(g[Z(0x1a2)])return;if(!R['operations']['includes'](t))throw new ForbiddenError(R[Z(0x1a3)]+'.'+t+'\x20is\x20disabled');if(R[Z(0x1a4)]!==Z(0x1a5)&&X===undefined)throw new ForbiddenError('Authentication\x20required');if(R['access']===Z(0x1a6)&&X?.['type']!==Z(0x1a6))throw new ForbiddenError('Admin\x20access\x20required');if(X?.['type']!=='admin'){const m=(R['permission']??R[Z(0x1a3)])+':'+t;if(!X?.['permissions']?.['includes'](m))throw new ForbiddenError(Z(0x1a7)+m);}}function G(){const z=['debug','name','access','public','admin','Missing\x20permission:\x20'];G=function(){return z;};return G();}
1
+ import{ForbiddenError}from'../../../errors.js';function A(x,q){x=x-0x184;const C=g();let J=C[x];return J;}function g(){const Y=['config','access','admin','type'];g=function(){return Y;};return g();}import{getContext}from'../../../index.js';export function assertOperation(x,q,C){const Z=A,J=getContext()[Z(0x184)];if(J['debug'])return;if(!x['operations']['includes'](q))throw new ForbiddenError(x['name']+'.'+q+'\x20is\x20disabled');if(x[Z(0x185)]!=='public'&&C===undefined)throw new ForbiddenError('Authentication\x20required');if(x[Z(0x185)]===Z(0x186)&&C?.['type']!==Z(0x186))throw new ForbiddenError('Admin\x20access\x20required');if(C?.[Z(0x187)]!==Z(0x186)){const K=(x['permission']??x['name'])+':'+q;if(!C?.['permissions']?.['includes'](K))throw new ForbiddenError('Missing\x20permission:\x20'+K);}}
@@ -1 +1 @@
1
- import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function G(){const h=['map','sort','DESC','join'];G=function(){return h;};return G();}function q(R,t){R=R-0x1f1;const X=G();let g=X[R];return g;}export function buildSort(R,t){const l=q;if(!t?.['length'])return'';typeof t==='string'&&(t=[t]);const X=t[l(0x1f1)](g=>{const y=l,m=g['startsWith']('-'),Z=m?g['slice'](0x1):g,z=R['fields'][Z];if(!z||z[y(0x1f2)]!==!![]&&z['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+Z);return qi(fieldColumn(R,Z))+'\x20'+(m?y(0x1f3):'ASC');});return'\x20ORDER\x20BY\x20'+X[l(0x1f4)](',\x20');}
1
+ function A(x,q){x=x-0x10e;const C=g();let J=C[x];return J;}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(x,q){const b=A;if(!q?.['length'])return'';typeof q==='string'&&(q=[q]);const C=q['map'](J=>{const K=J['startsWith']('-'),Z=K?J['slice'](0x1):J,Y=x['fields'][Z];if(!Y||Y['sort']!==!![]&&Y['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+Z);return qi(fieldColumn(x,Z))+'\x20'+(K?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+C[b(0x10e)](',\x20');}function g(){const k=['join'];g=function(){return k;};return g();}
@@ -1 +1 @@
1
- const z=q;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=R=>'\x22'+R[z(0x1a9)](/"/g,'\x22\x22')+'\x22';export const quoteTable=R=>R['split']('.')[z(0x1aa)](quoteIdentifier)['join']('.');function q(R,t){R=R-0x1a9;const X=G();let g=X[R];return g;}export function fieldColumn(R,t){if(t===R['key'])return R['key'];const X=R['fields'][t];if(!X)throw new ValidationError('Unknown\x20field:\x20'+t);return X['column']??t;}export function readableFields(R){const l=z,t=Object[l(0x1ab)](R['fields'])['filter'](([,X])=>X['read']!==![]&&X[l(0x1ac)]!==![])['map'](([X,g])=>quoteIdentifier(g['column']??X)+'\x20AS\x20'+quoteIdentifier(X));return!R[l(0x1ad)][R['key']]&&t[l(0x1ae)](quoteIdentifier(R['key'])),t;}export function writableData(R,t){const y=z,X=[];for(const [g,m]of Object['entries'](t)){const Z=R['fields'][g];if(!Z||Z['write']===![]||Z['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+g);X[y(0x1af)]([Z['column']??g,m]);}return X;}function G(){const h=['replace','map','entries','readable','fields','unshift','push'];G=function(){return h;};return G();}export const qi=quoteIdentifier;export const qt=quoteTable;
1
+ const Y=A;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=x=>'\x22'+x[Y(0x7f)](/"/g,'\x22\x22')+'\x22';export const quoteTable=x=>x[Y(0x80)]('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(x,q){const b=Y;if(q===x['key'])return x['key'];const C=x[b(0x81)][q];if(!C)throw new ValidationError('Unknown\x20field:\x20'+q);return C['column']??q;}export function readableFields(x){const k=Y,q=Object['entries'](x['fields'])['filter'](([,C])=>C['read']!==![]&&C['readable']!==![])['map'](([C,J])=>quoteIdentifier(J['column']??C)+k(0x82)+quoteIdentifier(C));return!x['fields'][x['key']]&&q['unshift'](quoteIdentifier(x[k(0x83)])),q;}function g(){const F=['replace','split','fields','\x20AS\x20','key','write','Field\x20is\x20not\x20writable:\x20','push','column'];g=function(){return F;};return g();}export function writableData(x,q){const H=Y,C=[];for(const [J,K]of Object['entries'](q)){const Z=x['fields'][J];if(!Z||Z[H(0x84)]===![]||Z['writable']===![])throw new ValidationError(H(0x85)+J);C[H(0x86)]([Z[H(0x87)]??J,K]);}return C;}function A(x,q){x=x-0x7f;const C=g();let J=C[x];return J;}export const qi=quoteIdentifier;export const qt=quoteTable;
@@ -1 +1 @@
1
- const getIP=R=>(R['headers']?.['x-real-ip']||R['headers']?.['x-forwarded-for']||R['ip']||R['connection']?.['remoteAddress']||'')['split'](':')['pop']();export default getIP;
1
+ function A(x,q){x=x-0x196;const C=g();let J=C[x];return J;}function g(){const C=['connection'];g=function(){return C;};return g();}const q=A,getIP=x=>(x['headers']?.['x-real-ip']||x['headers']?.['x-forwarded-for']||x['ip']||x[q(0x196)]?.['remoteAddress']||'')['split'](':')['pop']();export default getIP;
@@ -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 settings_resource_key_uidx
18
+ ON admin.settings (resource, resource_id, key)
19
19
  NULLS NOT DISTINCT;
@@ -1,43 +1,43 @@
1
- ALTER TABLE admin.users
2
- ADD CONSTRAINT users_created_by_fkey
3
- FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
4
- ADD CONSTRAINT users_updated_by_fkey
5
- FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
6
-
7
- ALTER TABLE admin.user_roles
8
- ADD CONSTRAINT user_roles_created_by_fkey
9
- FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
10
- ADD CONSTRAINT user_roles_updated_by_fkey
11
- FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
12
-
13
- ALTER TABLE admin.role_access
14
- ADD CONSTRAINT role_access_user_uid_fkey
15
- FOREIGN KEY (user_uid) REFERENCES admin.users(uid) ON DELETE CASCADE,
16
- ADD CONSTRAINT role_access_created_by_fkey
17
- FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
18
- ADD CONSTRAINT role_access_updated_by_fkey
19
- FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
20
-
21
- ALTER TABLE admin.dictionaries
22
- ADD CONSTRAINT dictionaries_created_by_fkey
23
- FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
24
- ADD CONSTRAINT dictionaries_updated_by_fkey
25
- FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
26
-
27
- ALTER TABLE admin.notes
28
- ADD CONSTRAINT notes_created_by_fkey
29
- FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
30
- ADD CONSTRAINT notes_updated_by_fkey
31
- FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
32
-
33
- ALTER TABLE admin.files
34
- ADD CONSTRAINT files_created_by_fkey
35
- FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
36
- ADD CONSTRAINT files_updated_by_fkey
37
- FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
38
-
39
- ALTER TABLE admin.settings
40
- ADD CONSTRAINT settings_created_by_fkey
41
- FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
42
- ADD CONSTRAINT settings_updated_by_fkey
1
+ ALTER TABLE admin.users
2
+ ADD CONSTRAINT users_created_by_fkey
3
+ FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
4
+ ADD CONSTRAINT users_updated_by_fkey
5
+ FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
6
+
7
+ ALTER TABLE admin.user_roles
8
+ ADD CONSTRAINT user_roles_created_by_fkey
9
+ FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
10
+ ADD CONSTRAINT user_roles_updated_by_fkey
11
+ FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
12
+
13
+ ALTER TABLE admin.role_access
14
+ ADD CONSTRAINT role_access_user_uid_fkey
15
+ FOREIGN KEY (user_uid) REFERENCES admin.users(uid) ON DELETE CASCADE,
16
+ ADD CONSTRAINT role_access_created_by_fkey
17
+ FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
18
+ ADD CONSTRAINT role_access_updated_by_fkey
19
+ FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
20
+
21
+ ALTER TABLE admin.dictionaries
22
+ ADD CONSTRAINT dictionaries_created_by_fkey
23
+ FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
24
+ ADD CONSTRAINT dictionaries_updated_by_fkey
25
+ FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
26
+
27
+ ALTER TABLE admin.notes
28
+ ADD CONSTRAINT notes_created_by_fkey
29
+ FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
30
+ ADD CONSTRAINT notes_updated_by_fkey
31
+ FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
32
+
33
+ ALTER TABLE admin.files
34
+ ADD CONSTRAINT files_created_by_fkey
35
+ FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
36
+ ADD CONSTRAINT files_updated_by_fkey
37
+ FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
38
+
39
+ ALTER TABLE admin.settings
40
+ ADD CONSTRAINT settings_created_by_fkey
41
+ FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
42
+ ADD CONSTRAINT settings_updated_by_fkey
43
43
  FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fcore",
3
- "version": "0.0.1-beta.11",
3
+ "version": "0.0.1-beta.12",
4
4
  "description": "Reusable backend foundation for OpenGIS Node.js applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",