@opengis/fcore 0.0.1-beta.6 → 0.0.1-beta.8

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 (163) hide show
  1. package/dist/config.js +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/errors.js +1 -1
  4. package/dist/fastify.d.ts +2 -1
  5. package/dist/fastify.d.ts.map +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.d.ts.map +1 -1
  14. package/dist/modules/auth/route.js +1 -1
  15. package/dist/modules/auth/schema.d.ts +3 -0
  16. package/dist/modules/auth/schema.d.ts.map +1 -1
  17. package/dist/modules/auth/schema.js +1 -1
  18. package/dist/modules/auth/services/change-password.js +1 -1
  19. package/dist/modules/auth/services/get-current-user.d.ts +1 -0
  20. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  21. package/dist/modules/auth/services/get-current-user.js +1 -1
  22. package/dist/modules/auth/services/registration.js +1 -1
  23. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  24. package/dist/modules/file/mime.d.ts +3 -0
  25. package/dist/modules/file/mime.d.ts.map +1 -0
  26. package/dist/modules/file/mime.js +1 -0
  27. package/dist/modules/file/route.d.ts.map +1 -1
  28. package/dist/modules/file/route.js +1 -1
  29. package/dist/modules/file/schema.d.ts +3 -0
  30. package/dist/modules/file/schema.d.ts.map +1 -1
  31. package/dist/modules/file/schema.js +1 -1
  32. package/dist/modules/file/services/get-file.js +1 -1
  33. package/dist/modules/file/services/resize-file.d.ts.map +1 -1
  34. package/dist/modules/file/services/resize-file.js +1 -1
  35. package/dist/modules/file/services/upload-file.d.ts +4 -6
  36. package/dist/modules/file/services/upload-file.d.ts.map +1 -1
  37. package/dist/modules/file/services/upload-file.js +1 -1
  38. package/dist/modules/resource/route.d.ts +0 -3
  39. package/dist/modules/resource/route.d.ts.map +1 -1
  40. package/dist/modules/resource/route.js +1 -1
  41. package/dist/modules/resource/schema.d.ts +3 -0
  42. package/dist/modules/resource/schema.d.ts.map +1 -1
  43. package/dist/modules/resource/schema.js +1 -1
  44. package/dist/modules/resource/services/add-note.js +1 -1
  45. package/dist/modules/resource/services/add-resource-file.js +1 -1
  46. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  47. package/dist/modules/resource/services/create-resource.js +1 -1
  48. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  49. package/dist/modules/resource/services/delete-resource.js +1 -1
  50. package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
  51. package/dist/modules/resource/services/export-resource.js +1 -1
  52. package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
  53. package/dist/modules/resource/services/get-resource.js +1 -1
  54. package/dist/modules/resource/services/list-resource-relation.d.ts +2 -0
  55. package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
  56. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  57. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  58. package/dist/modules/resource/services/list-resources.js +1 -1
  59. package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
  60. package/dist/modules/resource/services/search-resource.js +1 -1
  61. package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
  62. package/dist/modules/resource/services/suggest-resource.js +1 -1
  63. package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
  64. package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
  65. package/dist/modules/resource/services/update-resource-relation.js +1 -0
  66. package/dist/modules/resource/services/update-resource.js +1 -1
  67. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  68. package/dist/modules/system/route.d.ts.map +1 -1
  69. package/dist/modules/system/route.js +1 -1
  70. package/dist/modules/system/schema.js +1 -1
  71. package/dist/modules/system/services/check-system.d.ts.map +1 -1
  72. package/dist/modules/system/services/check-system.js +1 -1
  73. package/dist/modules/system/services/get-access.d.ts.map +1 -1
  74. package/dist/modules/system/services/get-access.js +1 -1
  75. package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
  76. package/dist/modules/system/services/get-api-list.js +1 -1
  77. package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
  78. package/dist/modules/system/services/get-audit-log.js +1 -1
  79. package/dist/modules/system/services/get-dictionary.js +1 -1
  80. package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
  81. package/dist/modules/system/services/get-system-log.js +1 -1
  82. package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
  83. package/dist/modules/system/services/get-system-settings.js +1 -1
  84. package/dist/modules/system/services/list-dictionaries.js +1 -1
  85. package/dist/modules/system/services/set-access.d.ts.map +1 -1
  86. package/dist/modules/system/services/set-access.js +1 -1
  87. package/dist/modules/system/services/update-dictionary.d.ts.map +1 -1
  88. package/dist/modules/system/services/update-dictionary.js +1 -1
  89. package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
  90. package/dist/modules/system/services/update-system-settings.js +1 -1
  91. package/dist/modules/utils/require-admin.js +1 -1
  92. package/dist/modules/utils/safe-user.js +1 -1
  93. package/dist/modules/utils/unsupported.js +1 -1
  94. package/dist/plugins/audit/audit.js +1 -1
  95. package/dist/plugins/audit/services/write-audit.js +1 -1
  96. package/dist/plugins/auth/get-user-permissions.js +1 -1
  97. package/dist/plugins/auth/index.d.ts.map +1 -1
  98. package/dist/plugins/auth/index.js +1 -1
  99. package/dist/plugins/auth/verifyUser.js +1 -1
  100. package/dist/plugins/dictionary.d.ts +3 -0
  101. package/dist/plugins/dictionary.d.ts.map +1 -1
  102. package/dist/plugins/dictionary.js +1 -1
  103. package/dist/plugins/file.d.ts +3 -6
  104. package/dist/plugins/file.d.ts.map +1 -1
  105. package/dist/plugins/file.js +1 -1
  106. package/dist/plugins/index.d.ts +1 -0
  107. package/dist/plugins/index.d.ts.map +1 -1
  108. package/dist/plugins/index.js +1 -1
  109. package/dist/plugins/jwt.d.ts +4 -0
  110. package/dist/plugins/jwt.d.ts.map +1 -0
  111. package/dist/plugins/jwt.js +1 -0
  112. package/dist/plugins/logger/index.js +1 -1
  113. package/dist/plugins/logger/transport.js +1 -1
  114. package/dist/plugins/pg.d.ts.map +1 -1
  115. package/dist/plugins/pg.js +1 -1
  116. package/dist/plugins/redis.js +1 -1
  117. package/dist/plugins/resource/resource.d.ts.map +1 -1
  118. package/dist/plugins/resource/resource.js +1 -1
  119. package/dist/plugins/resource/resource.registry.js +1 -1
  120. package/dist/plugins/resource/resource.types.d.ts +18 -3
  121. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  122. package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
  123. package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
  124. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
  125. package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
  126. package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
  127. package/dist/plugins/resource/services/add-file-token.js +1 -0
  128. package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
  129. package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
  130. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
  131. package/dist/plugins/resource/services/create-relation.js +1 -1
  132. package/dist/plugins/resource/services/create.d.ts.map +1 -1
  133. package/dist/plugins/resource/services/create.js +1 -1
  134. package/dist/plugins/resource/services/delete-relation.js +1 -1
  135. package/dist/plugins/resource/services/delete.d.ts.map +1 -1
  136. package/dist/plugins/resource/services/delete.js +1 -1
  137. package/dist/plugins/resource/services/find-one.d.ts +3 -2
  138. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  139. package/dist/plugins/resource/services/find-one.js +1 -1
  140. package/dist/plugins/resource/services/find-relation.d.ts +3 -2
  141. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
  142. package/dist/plugins/resource/services/find-relation.js +1 -1
  143. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  144. package/dist/plugins/resource/services/find.js +1 -1
  145. package/dist/plugins/resource/services/update-relation.d.ts +11 -0
  146. package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
  147. package/dist/plugins/resource/services/update-relation.js +1 -0
  148. package/dist/plugins/resource/services/update.d.ts.map +1 -1
  149. package/dist/plugins/resource/services/update.js +1 -1
  150. package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
  151. package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
  152. package/dist/plugins/resource/utils/auto-index.js +1 -0
  153. package/dist/plugins/resource/utils/fields.js +1 -1
  154. package/dist/plugins/resource/utils/filters.d.ts +3 -2
  155. package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
  156. package/dist/plugins/resource/utils/filters.js +1 -1
  157. package/dist/plugins/resource/utils/permissions.js +1 -1
  158. package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
  159. package/dist/plugins/resource/utils/sort.js +1 -1
  160. package/dist/plugins/resource/utils/sql.js +1 -1
  161. package/dist/shared/getIP.js +1 -1
  162. package/migrations/20260907090000_core_schema.sql +2 -0
  163. package/package.json +93 -92
@@ -1 +1 @@
1
- import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';function T(r,u){r=r-0x9e;const G=H();let o=G[r];return o;}import{validateInputData}from'../utils/fields.js';export function createUpdate(r,u){return async function G({name:o,id:X,data:w,user:a}){const h=T,q=u['get'](o);assertOperation(q,h(0x9e),a);const p=writableData(q,w);if(!p['length'])throw new ValidationError(h(0x9f));if(!r['pg'])throw new Error('empty\x20pg');validateInputData({'resource':q,'data':w,'update':!![]});const F=p['map'](([I],c)=>qi(I)+h(0xa0)+(c+0x1)),E=[...p[h(0xa1)](([,I])=>I),X],Y=await r['pg'][h(0xa2)]('UPDATE\x20'+qt(q['table'])+'\x20'+(h(0xa3)+F[h(0xa4)](',\x20')+'\x20')+('WHERE\x20'+qi(q[h(0xa5)])+h(0xa0)+(p['length']+0x1)+'\x20')+('RETURNING\x20'+readableFields(q)['join'](',\x20')),E),S=Y[h(0xa6)][0x0];if(!S)throw new NotFoundError(o+':'+X);return await r['audit']?.['write']({'userId':a?.['id'],'module':q[h(0xa7)],'resource':q[h(0xa8)],'resourceId':X,'action':'update','fields':Object[h(0xa9)](w)}),S;};}function H(){const P=['update','No\x20writable\x20fields','\x20=\x20$','map','query','SET\x20','join','key','rows','module','name','keys'];H=function(){return P;};return H();}
1
+ import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';function A(z,j){z=z-0x1d8;const c=U();let p=c[z];return p;}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function U(){const t=['get','length','No\x20writable\x20fields','map','WHERE\x20','write'];U=function(){return t;};return U();}export function createUpdate(z,j){return async function c({name:p,id:M,data:H,user:i}){const P=A,b=j[P(0x1d8)](p);assertOperation(b,'update',i);const n=writableData(b,H);if(!n[P(0x1d9)])throw new ValidationError(P(0x1da));if(!z['pg'])throw new Error('empty\x20pg');validateInputData({'resource':b,'data':H,'update':!![]}),delete H['user_type'];const v=n['map'](([e],o)=>qi(e)+'\x20=\x20$'+(o+0x1)),r=[...n[P(0x1db)](([,e])=>e),M],q=await z['pg']['query']('UPDATE\x20'+qt(b['table'])+'\x20'+('SET\x20'+v['join'](',\x20')+'\x20')+(P(0x1dc)+qi(b['key'])+'\x20=\x20$'+(n['length']+0x1)+'\x20')+('RETURNING\x20'+readableFields(b)['join'](',\x20')),r),Z=q['rows'][0x0];if(!Z)throw new NotFoundError(p+':'+M);return clearTableLookupCache(b['table'],z['pg']),await z['audit']?.[P(0x1dd)]({'userId':i?.['id'],'module':b['module'],'resource':b['name'],'resourceId':M,'action':'update','fields':Object['keys'](H)}),Z;};}
@@ -0,0 +1,4 @@
1
+ import type { DatabaseAdapter } from "../../pg.js";
2
+ export type AutoIndexType = "text" | "btree" | "gist";
3
+ export declare function autoIndex(table: string, column: string, type: AutoIndexType | undefined, pg: DatabaseAdapter): void;
4
+ //# sourceMappingURL=auto-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/auto-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAItD,wBAAgB,SAAS,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,YAAU,EAC7B,EAAE,EAAE,eAAe,GACpB,IAAI,CAWN"}
@@ -0,0 +1 @@
1
+ const n=A;import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();function A(z,j){z=z-0xb8;const c=U();let p=c[z];return p;}export function autoIndex(z,j,c=n(0xb8),p){const v=n,M=requestedIndexes['get'](p)??new Set();requestedIndexes[v(0xb9)](p,M);const H=z+':'+j+':'+c;if(M['has'](H))return;M['add'](H),void ensureIndex(z,j,c,p)['catch'](()=>{M['delete'](H);});}function U(){const q=['btree','set','public','replace','query','text','CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20','\x20ON\x20'];U=function(){return q;};return U();}async function ensureIndex(z,j,c,p){const r=n,M=z['split']('.'),H=M['length']===0x2?M[0x0]:r(0xba),i=(z+'_'+j+'_'+c+'_idx')[r(0xbb)](/[^A-Za-z0-9_]/g,'_'),b=await p[r(0xbc)]('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[H,i]);if(b['rowCount'])return;if(c===r(0xbd)){await p['query'](r(0xbe)),await p['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(i+'_l')+'\x20ON\x20'+qt(z)+'\x20USING\x20btree\x20(lower('+qi(j)+')\x20text_pattern_ops)'),await p['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(i)+'\x20ON\x20'+qt(z)+'\x20USING\x20gin\x20(lower('+qi(j)+')\x20gin_trgm_ops)');return;}await p['query'](r(0xbf)+qi(i)+r(0xc0)+qt(z)+'\x20USING\x20'+c+'\x20('+qi(j)+')');}
@@ -1 +1 @@
1
- function H(){const w=['string','maxLength','minimum','\x20should\x20be\x20>=\x20','number','maximum','enum'];H=function(){return w;};return H();}function T(r,u){r=r-0xfd;const G=H();let o=G[r];return o;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:r,data:u,update:update=![]})=>{const X=T;for(const [G,o]of Object['entries'](r['fields'])){if(o['required']&&o['writable']!==![]&&(u[G]===undefined||u[G]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+G);if(o['required']&&o['writable']!==![]&&Object['hasOwn'](u,G)&&(u[G]===undefined||u[G]===null)&&update)throw new ValidationError('Required\x20field:\x20'+G);if(o['minLength']&&typeof u[G]===X(0xfd)&&u[G]['length']<o['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+G);if(o[X(0xfe)]&&typeof u[G]==='string'&&u[G]['length']>o['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+G);if(o[X(0xff)]&&typeof u[G]==='number'&&u[G]<o[X(0xff)])throw new ValidationError(G+X(0x100)+o['minimum']);if(o['maximum']&&typeof u[G]===X(0x101)&&u[G]>o[X(0x102)])throw new ValidationError(G+'\x20should\x20be\x20<=\x20'+o['maximum']);if(o['enum']&&u[G]&&!o[X(0x103)]['includes'](u[G]))throw new ValidationError(G+'\x20should\x20be\x20one\x20of\x20('+o['enum']['join'](',\x20')+')');if(o['pattern']&&typeof u[G]===X(0xfd)&&!new RegExp(o['pattern'])['test'](u[G]))throw new ValidationError(G+'\x20should\x20match\x20regular\x20expression\x20('+o['pattern']+')');}};export{validateInputData};
1
+ import{ValidationError}from'../../../errors.js';function U(){const H=['entries','fields','required','writable','string','maxLength\x20exceeded:\x20','minimum','maximum','\x20should\x20be\x20<=\x20','\x20should\x20be\x20one\x20of\x20(','enum','pattern'];U=function(){return H;};return U();}function A(z,j){z=z-0x11c;const c=U();let p=c[z];return p;}export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:z,data:j,update:update=![]})=>{const M=A;for(const [c,p]of Object[M(0x11c)](z[M(0x11d)])){if(p[M(0x11e)]&&p['writable']!==![]&&(j[c]===undefined||j[c]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+c);if(p['required']&&p[M(0x11f)]!==![]&&Object['hasOwn'](j,c)&&(j[c]===undefined||j[c]===null)&&update)throw new ValidationError('Required\x20field:\x20'+c);if(p['minLength']&&typeof j[c]===M(0x120)&&j[c]['length']<p['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+c);if(p['maxLength']&&typeof j[c]==='string'&&j[c]['length']>p['maxLength'])throw new ValidationError(M(0x121)+c);if(p[M(0x122)]&&typeof j[c]==='number'&&j[c]<p['minimum'])throw new ValidationError(c+'\x20should\x20be\x20>=\x20'+p['minimum']);if(p[M(0x123)]&&typeof j[c]==='number'&&j[c]>p['maximum'])throw new ValidationError(c+M(0x124)+p['maximum']);if(p['enum']&&j[c]&&!p['enum']['includes'](j[c]))throw new ValidationError(c+M(0x125)+p[M(0x126)]['join'](',\x20')+')');if(p[M(0x127)]&&typeof j[c]===M(0x120)&&!new RegExp(p[M(0x127)])['test'](j[c]))throw new ValidationError(c+'\x20should\x20match\x20regular\x20expression\x20('+p['pattern']+')');}};export{validateInputData};
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Provides Resource helpers for filters handling.
3
3
  */
4
- import type { ResourceContract } from '../resource.types.js';
5
- export declare function buildFilters(resource: ResourceContract, filter: Record<string, unknown> | undefined, start?: number): {
4
+ import type { ResourceContract, ResourceDependencies } from '../resource.types.js';
5
+ export declare function parseFilterQuery(query: Record<string, unknown>): Record<string, unknown> | undefined;
6
+ export declare function buildFilters(resource: ResourceContract, filter: Record<string, unknown> | undefined, start?: number, pg?: ResourceDependencies['pg']): {
6
7
  sql: string;
7
8
  values: unknown[];
8
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAI7D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,KAAK,SAAI;;;EAc9G"}
1
+ {"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AASnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA2BpG;AAED,wBAAgB,YAAY,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,KAAK,SAAI,EACT,EAAE,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC;;;EAgElC"}
@@ -1 +1 @@
1
- import{fieldColumn,qi}from'./sql.js';function T(r,u){r=r-0x1cf;const G=H();let o=G[r];return o;}import{ValidationError}from'../../../errors.js';function H(){const F=['length'];H=function(){return F;};return H();}export function buildFilters(r,u,G=0x1){const p=T,o=[],X=[];for(const [w,a]of Object['entries'](u??{})){const q=r['fields'][w];if(!q||q['filter']!==!![]&&q['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+w);X['push'](a),o['push'](qi(fieldColumn(r,w))+'\x20=\x20$'+(G+X[p(0x1cf)]-0x1));}return{'sql':o[p(0x1cf)]?'\x20WHERE\x20'+o['join']('\x20AND\x20'):'','values':X};}
1
+ const t=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',t(0x72),'lt','lte','in','nin','like','ilike','null']);function U(){const R=['gte','filter','keys','fields','Field\x20is\x20not\x20filterable:\x20','entries','Unsupported\x20filter\x20operator:\x20','like','ilike','\x20requires\x20a\x20text\x20field:\x20','null','push','=\x20ANY','length','isArray','true','text','geom','geometry','btree'];U=function(){return R;};return U();}export function parseFilterQuery(z){const g=t,j={...isRecord(z[g(0x73)])?z[g(0x73)]:{}};for(const [c,p]of Object['entries'](z)){const M=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](c);if(!M)continue;const [,H,i]=M;if(!H)continue;if(!i){j[H]=p;continue;}if(!filterOperators['has'](i))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+i);const b=isRecord(j[H])?j[H]:{};b[i]=(i==='in'||i==='nin')&&typeof p==='string'?p['split'](','):p,j[H]=b;}return Object[g(0x74)](j)['length']?j:undefined;}export function buildFilters(z,j,c=0x1,p){const y=t,M=[],H=[];for(const [i,b]of Object['entries'](j??{})){const n=z[y(0x75)][i];if(!n||n['filter']!==!![]&&n['filterable']!==!![])throw new ValidationError(y(0x76)+i);const v=qi(fieldColumn(z,i)),r=isRecord(b)?b:{'eq':b};for(const [q,Z]of Object[y(0x77)](r)){if(!filterOperators['has'](q))throw new ValidationError(y(0x78)+q);if((q===y(0x79)||q===y(0x7a))&&n['type']!=='string'&&n['type']!=='text')throw new ValidationError('Operator\x20'+q+y(0x7b)+i);p&&autoIndex(z['table'],fieldColumn(z,i),indexTypeFor(n['type'],q),p);if(q===y(0x7c)){M['push'](v+'\x20IS\x20'+(isTruthy(Z)?'':'NOT\x20')+'NULL');continue;}if(q==='in'||q==='nin'){const P=Array['isArray'](Z)?Z:[Z];if(P['length']===0x0){M['push'](q==='in'?'FALSE':'TRUE');continue;}H['push'](P),M[y(0x7d)](v+'\x20'+(q==='in'?y(0x7e):'<>\x20ALL')+'($'+(c+H['length']-0x1)+')');continue;}const e={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':y(0x79)},o='$'+(c+H['length']);if(q==='like'){H[y(0x7d)](Z+'%'),M['push']('lower('+v+')\x20like\x20lower('+o+')');continue;}H['push'](Z),M[y(0x7d)](v+'\x20'+e[q]+'\x20'+o);}}return{'sql':M[y(0x7f)]?'\x20WHERE\x20'+M['join']('\x20AND\x20'):'','values':H};}function isRecord(z){const B=t;return typeof z==='object'&&z!==null&&!Array[B(0x80)](z);}function A(z,j){z=z-0x72;const c=U();let p=c[z];return p;}function isTruthy(z){const Y=t;return z===!![]||z===Y(0x81)||z==='1'||z===0x1;}function indexTypeFor(z,j){const s=t;if(j==='like'||j==='ilike')return s(0x82);if(z===s(0x83)||z===s(0x84))return'gist';return s(0x85);}
@@ -1 +1 @@
1
- import{ForbiddenError}from'../../../errors.js';function T(r,u){r=r-0x160;const G=H();let o=G[r];return o;}function H(){const a=['Authentication\x20required','type'];H=function(){return a;};return H();}import{getContext}from'../../../index.js';export function assertOperation(r,u,G){const w=T,o=getContext()['config'];if(o['debug'])return;if(!r['operations']['includes'](u))throw new ForbiddenError(r['name']+'.'+u+'\x20is\x20disabled');if(r['access']!=='public'&&G===undefined)throw new ForbiddenError(w(0x160));if(r['access']==='admin'&&G?.[w(0x161)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(G?.['type']!=='admin'){const X=(r['permission']??r['name'])+':'+u;if(!G?.['permissions']?.['includes'](X))throw new ForbiddenError('Missing\x20permission:\x20'+X);}}
1
+ import{ForbiddenError}from'../../../errors.js';function A(z,j){z=z-0x1d7;const c=U();let p=c[z];return p;}function U(){const i=['name','public','Authentication\x20required','admin','type','permissions','Missing\x20permission:\x20'];U=function(){return i;};return U();}import{getContext}from'../../../index.js';export function assertOperation(z,j,c){const H=A,p=getContext()['config'];if(p['debug'])return;if(!z['operations']['includes'](j))throw new ForbiddenError(z[H(0x1d7)]+'.'+j+'\x20is\x20disabled');if(z['access']!==H(0x1d8)&&c===undefined)throw new ForbiddenError(H(0x1d9));if(z['access']===H(0x1da)&&c?.[H(0x1db)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(c?.['type']!=='admin'){const M=(z['permission']??z[H(0x1d7)])+':'+j;if(!c?.[H(0x1dc)]?.['includes'](M))throw new ForbiddenError(H(0x1dd)+M);}}
@@ -1 +1 @@
1
- {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,UAYpE"}
1
+ {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,UAgBpE"}
@@ -1 +1 @@
1
- import{fieldColumn,qi}from'./sql.js';function H(){const F=['Field\x20is\x20not\x20sortable:\x20','\x20ORDER\x20BY\x20'];H=function(){return F;};return H();}function T(r,u){r=r-0xa5;const G=H();let o=G[r];return o;}import{ValidationError}from'../../../errors.js';export function buildSort(r,u){const p=T;if(!u?.['length'])return'';const G=u['map'](o=>{const q=T,X=o['startsWith']('-'),w=X?o['slice'](0x1):o,a=r['fields'][w];if(!a||a['sort']!==!![]&&a['sortable']!==!![])throw new ValidationError(q(0xa5)+w);return qi(fieldColumn(r,w))+'\x20'+(X?'DESC':'ASC');});return p(0xa6)+G['join'](',\x20');}
1
+ import{fieldColumn,qi}from'./sql.js';function A(z,j){z=z-0xef;const c=U();let p=c[z];return p;}import{ValidationError}from'../../../errors.js';export function buildSort(z,j){if(!j?.['length'])return'';typeof j==='string'&&(j=[j]);const c=j['map'](p=>{const b=A,M=p['startsWith']('-'),H=M?p['slice'](0x1):p,i=z[b(0xef)][H];if(!i||i['sort']!==!![]&&i[b(0xf0)]!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+H);return qi(fieldColumn(z,H))+'\x20'+(M?'DESC':b(0xf1));});return'\x20ORDER\x20BY\x20'+c['join'](',\x20');}function U(){const n=['fields','sortable','ASC'];U=function(){return n;};return U();}
@@ -1 +1 @@
1
- const a=T;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=r=>'\x22'+r['replace'](/"/g,'\x22\x22')+'\x22';export const quoteTable=r=>r['split']('.')['map'](quoteIdentifier)[a(0x14f)]('.');export function fieldColumn(r,u){const q=a;if(u===r['key'])return r['key'];const G=r['fields'][u];if(!G)throw new ValidationError(q(0x150)+u);return G['column']??u;}export function readableFields(r){const p=a,u=Object['entries'](r['fields'])[p(0x151)](([,G])=>G['read']!==![]&&G['readable']!==![])['map'](([G,o])=>quoteIdentifier(o['column']??G)+'\x20AS\x20'+quoteIdentifier(G));return!r['fields'][r['key']]&&u[p(0x152)](quoteIdentifier(r[p(0x153)])),u;}function T(r,u){r=r-0x14f;const G=H();let o=G[r];return o;}export function writableData(r,u){const F=a,G=[];for(const [o,X]of Object['entries'](u)){const w=r[F(0x154)][o];if(!w||w[F(0x155)]===![]||w['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+o);G[F(0x156)]([w[F(0x157)]??o,X]);}return G;}export const qi=quoteIdentifier;function H(){const E=['join','Unknown\x20field:\x20','filter','unshift','key','fields','write','push','column'];H=function(){return E;};return H();}export const qt=quoteTable;
1
+ const i=A;function U(){const v=['split','join','entries','fields','key','unshift','Field\x20is\x20not\x20writable:\x20'];U=function(){return v;};return U();}import{ValidationError}from'../../../errors.js';export const quoteIdentifier=z=>'\x22'+z['replace'](/"/g,'\x22\x22')+'\x22';export const quoteTable=z=>z[i(0xa5)]('.')['map'](quoteIdentifier)[i(0xa6)]('.');export function fieldColumn(z,j){if(j===z['key'])return z['key'];const c=z['fields'][j];if(!c)throw new ValidationError('Unknown\x20field:\x20'+j);return c['column']??j;}export function readableFields(z){const b=i,j=Object[b(0xa7)](z[b(0xa8)])['filter'](([,c])=>c['read']!==![]&&c['readable']!==![])['map'](([c,p])=>quoteIdentifier(p['column']??c)+'\x20AS\x20'+quoteIdentifier(c));return!z[b(0xa8)][z[b(0xa9)]]&&j[b(0xaa)](quoteIdentifier(z[b(0xa9)])),j;}function A(z,j){z=z-0xa5;const c=U();let p=c[z];return p;}export function writableData(z,j){const n=i,c=[];for(const [p,M]of Object['entries'](j)){const H=z['fields'][p];if(!H||H['write']===![]||H['writable']===![])throw new ValidationError(n(0xab)+p);c['push']([H['column']??p,M]);}return c;}export const qi=quoteIdentifier;export const qt=quoteTable;
@@ -1 +1 @@
1
- function T(r,u){r=r-0x1f3;const G=H();let o=G[r];return o;}const u=T,getIP=r=>(r['headers']?.['x-real-ip']||r['headers']?.['x-forwarded-for']||r['ip']||r['connection']?.[u(0x1f3)]||'')[u(0x1f4)](':')['pop']();function H(){const G=['remoteAddress','split'];H=function(){return G;};return H();}export default getIP;
1
+ function U(){const c=['headers','pop'];U=function(){return c;};return U();}function A(z,j){z=z-0x99;const c=U();let p=c[z];return p;}const j=A,getIP=z=>(z['headers']?.['x-real-ip']||z[j(0x99)]?.['x-forwarded-for']||z['ip']||z['connection']?.['remoteAddress']||'')['split'](':')[j(0x9a)]();export default getIP;
@@ -0,0 +1,2 @@
1
+ alter table admin.users add column if not exists password_hash text;
2
+ alter table admin.users add column if not exists twofa boolean not null default false;
package/package.json CHANGED
@@ -1,92 +1,93 @@
1
- {
2
- "name": "@opengis/fcore",
3
- "version": "0.0.1-beta.6",
4
- "description": "Reusable backend foundation for OpenGIS Node.js applications",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "files": [
9
- "dist",
10
- "migrations",
11
- "README.md",
12
- "LICENSE"
13
- ],
14
- "exports": {
15
- ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
18
- },
19
- "./fastify": {
20
- "types": "./dist/fastify.d.ts",
21
- "import": "./dist/fastify.js"
22
- },
23
- "./migrate": {
24
- "types": "./dist/migrations/runner.d.ts",
25
- "import": "./dist/migrations/runner.js"
26
- }
27
- },
28
- "bin": {
29
- "fcore-migrate": "./dist/migrations/cli.js",
30
- "fcore-adduser": "./dist/modules/auth/adduser-cli.js",
31
- "fcore-passwd": "./dist/modules/auth/passwd-cli.js",
32
- "fcore-permission": "./dist/modules/auth/permission-cli.js"
33
- },
34
- "scripts": {
35
- "clean": "rm -rf dist",
36
- "build": "npm run clean && tsc -p tsconfig.json && node scripts/obfuscate.mjs",
37
- "typecheck": "tsc -p tsconfig.json --noEmit",
38
- "test": "node --test --import tsx test/**/*.test.ts",
39
- "test-env": "node --env-file=.env.test --test --import tsx test/**/env.test.ts",
40
- "dev": "bun ./server.ts",
41
- "adduser": "node --import tsx ./src/modules/auth/adduser-cli.ts",
42
- "passwd": "node --import tsx ./src/modules/auth/passwd-cli.ts",
43
- "permission": "node --import tsx ./src/modules/auth/permission-cli.ts",
44
- "migrate": "node --import tsx src/migrations/cli.ts",
45
- "migration-test": "node --env-file=.env.test --import tsx src/migrations/cli.ts",
46
- "prepublishOnly": "npm run build",
47
- "prepublishOnly1": "npm run build && npm test",
48
- "patch": "npm version patch && git push && npm publish",
49
- "minor": "npm version minor && git push && npm publish",
50
- "major": "npm version major && git push && npm publish"
51
- },
52
- "engines": {
53
- "node": ">=20"
54
- },
55
- "dependencies": {
56
- "@sinclair/typebox": "^0.34.52",
57
- "@aws-sdk/client-s3": "3.1125.0",
58
- "@aws-sdk/lib-storage": "3.1125.0",
59
- "@fastify/cookie": "11.1.2",
60
- "@fastify/multipart": "10.1.1",
61
- "@fastify/passport": "4.0.2",
62
- "@fastify/rate-limit": "11.2.0",
63
- "@fastify/session": "11.1.2",
64
- "apache-crypt": "1.2.6",
65
- "dotenv": "17.4.2",
66
- "fastify-session-redis-store": "7.1.2",
67
- "file-type": "22.0.2",
68
- "ioredis": "6.0.0",
69
- "otplib": "13.5.0",
70
- "pg": "8.23.0",
71
- "pino": "10.3.1",
72
- "pino-abstract-transport": "3.0.0",
73
- "qrcode": "1.5.4",
74
- "sharp": "0.35.4"
75
- },
76
- "peerDependencies": {
77
- "fastify": ">=5.12.1"
78
- },
79
- "devDependencies": {
80
- "@types/node": "22.20.1",
81
- "@types/passport": "1.0.17",
82
- "@types/passport-local": "1.0.38",
83
- "@types/pg": "8.23.1",
84
- "@types/qrcode": "1.5.6",
85
- "fastify": "5.12.1",
86
- "javascript-obfuscator": "5.6.0",
87
- "tsx": "4.23.13",
88
- "typescript": "7.0.2",
89
- "vitest": "4.1.11"
90
- },
91
- "license": "UNLICENSED"
92
- }
1
+ {
2
+ "name": "@opengis/fcore",
3
+ "version": "0.0.1-beta.8",
4
+ "description": "Reusable backend foundation for OpenGIS Node.js applications",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "migrations",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ },
19
+ "./fastify": {
20
+ "types": "./dist/fastify.d.ts",
21
+ "import": "./dist/fastify.js"
22
+ },
23
+ "./migrate": {
24
+ "types": "./dist/migrations/runner.d.ts",
25
+ "import": "./dist/migrations/runner.js"
26
+ }
27
+ },
28
+ "bin": {
29
+ "fcore-migrate": "./dist/migrations/cli.js",
30
+ "fcore-adduser": "./dist/modules/auth/adduser-cli.js",
31
+ "fcore-passwd": "./dist/modules/auth/passwd-cli.js",
32
+ "fcore-permission": "./dist/modules/auth/permission-cli.js"
33
+ },
34
+ "scripts": {
35
+ "clean": "rm -rf dist",
36
+ "build": "npm run clean && tsc -p tsconfig.json && node scripts/obfuscate.mjs",
37
+ "typecheck": "tsc -p tsconfig.json --noEmit",
38
+ "test": "node --test --import tsx test/**/*.test.ts",
39
+ "test-env": "node --env-file=.env.test --test --import tsx test/**/env.test.ts",
40
+ "dev": "bun ./server.ts",
41
+ "adduser": "node --import tsx ./src/modules/auth/adduser-cli.ts",
42
+ "passwd": "node --import tsx ./src/modules/auth/passwd-cli.ts",
43
+ "permission": "node --import tsx ./src/modules/auth/permission-cli.ts",
44
+ "migrate": "node --import tsx src/migrations/cli.ts",
45
+ "migration-test": "node --env-file=.env.test --import tsx src/migrations/cli.ts",
46
+ "prepublishOnly": "npm run build",
47
+ "prepublishOnly1": "npm run build && npm test",
48
+ "patch": "npm version patch && git push && npm publish",
49
+ "minor": "npm version minor && git push && npm publish",
50
+ "major": "npm version major && git push && npm publish"
51
+ },
52
+ "engines": {
53
+ "node": ">=20"
54
+ },
55
+ "dependencies": {
56
+ "@aws-sdk/client-s3": "3.1125.0",
57
+ "@aws-sdk/lib-storage": "3.1125.0",
58
+ "@fastify/cookie": "11.1.2",
59
+ "@fastify/multipart": "10.1.1",
60
+ "@fastify/passport": "4.0.2",
61
+ "@fastify/rate-limit": "11.2.0",
62
+ "@fastify/session": "11.1.2",
63
+ "@sinclair/typebox": "^0.34.52",
64
+ "apache-crypt": "1.2.6",
65
+ "dotenv": "17.4.2",
66
+ "fastify-session-redis-store": "7.1.2",
67
+ "file-type": "22.0.2",
68
+ "ioredis": "6.0.0",
69
+ "jose": "^6.2.12",
70
+ "otplib": "13.5.0",
71
+ "pg": "8.23.0",
72
+ "pino": "10.3.1",
73
+ "pino-abstract-transport": "3.0.0",
74
+ "qrcode": "1.5.4",
75
+ "sharp": "0.35.4"
76
+ },
77
+ "peerDependencies": {
78
+ "fastify": ">=5.12.1"
79
+ },
80
+ "devDependencies": {
81
+ "@types/node": "22.20.1",
82
+ "@types/passport": "1.0.17",
83
+ "@types/passport-local": "1.0.38",
84
+ "@types/pg": "8.23.1",
85
+ "@types/qrcode": "1.5.6",
86
+ "fastify": "5.12.1",
87
+ "javascript-obfuscator": "5.6.0",
88
+ "tsx": "4.23.13",
89
+ "typescript": "7.0.2",
90
+ "vitest": "4.1.11"
91
+ },
92
+ "license": "UNLICENSED"
93
+ }