@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.
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts +2 -1
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.js +1 -1
- package/dist/modules/auth/passwd-cli.js +1 -1
- package/dist/modules/auth/permission-cli.js +1 -1
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.d.ts +3 -0
- package/dist/modules/auth/schema.d.ts.map +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.d.ts +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.js +1 -1
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.d.ts +3 -0
- package/dist/modules/file/mime.d.ts.map +1 -0
- package/dist/modules/file/mime.js +1 -0
- package/dist/modules/file/route.d.ts.map +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.d.ts +3 -0
- package/dist/modules/file/schema.d.ts.map +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.d.ts.map +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.d.ts +4 -6
- package/dist/modules/file/services/upload-file.d.ts.map +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts +0 -3
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +3 -0
- package/dist/modules/resource/schema.d.ts.map +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +2 -0
- package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
- package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
- package/dist/modules/resource/services/update-resource-relation.js +1 -0
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.d.ts.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.d.ts.map +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.d.ts.map +1 -1
- package/dist/modules/system/services/get-access.js +1 -1
- package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts.map +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -1
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +1 -1
- package/dist/plugins/auth/index.d.ts.map +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.js +1 -1
- package/dist/plugins/dictionary.d.ts +3 -0
- package/dist/plugins/dictionary.d.ts.map +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +3 -6
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/jwt.d.ts +4 -0
- package/dist/plugins/jwt.d.ts.map +1 -0
- package/dist/plugins/jwt.js +1 -0
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +18 -3
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
- package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
- package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-file-token.js +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -1
- package/dist/plugins/resource/services/create.d.ts.map +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts +3 -2
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +3 -2
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/update-relation.d.ts +11 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- package/dist/plugins/resource/services/update.d.ts.map +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260907090000_core_schema.sql +2 -0
- package/package.json +93 -92
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ConflictError,NotFoundError,ValidationError}from'../errors.js';const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;function A(z,j){z=z-0x1c6;const c=U();let p=c[z];return p;}function U(){const u=['empty\x20pg','dictionaries','isArray','Invalid\x20dictionary\x20items:\x20','set','code','get','checked','items','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.code,\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20','length','rows','Dictionary\x20not\x20found:\x20','Dictionary\x20table\x20not\x20found','BEGIN','query','fcore','custom','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\x20','static'];U=function(){return u;};return U();}export function createDictionary({pg:z,dictionaries:dictionaries=[]}){const j=new Map(),c=new Map();let p,M;async function H(){const R=A;if(p!==undefined)return p;if(!z)throw new Error(R(0x1c6));return M??=z['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20')['then'](o=>{const D=R,P=o['rows'][0x0]?.['table_name'];p=P===D(0x1c7)?P:null;}),await M,p;}function i(o){if(!dictionaryName['test'](o))throw new ValidationError('Invalid\x20dictionary\x20name:\x20'+o);}function b(o){const C=A;for(const P of Array[C(0x1c8)](o)?o:[o]){i(P['code']);if(!Array['isArray'](P['items']))throw new ValidationError(C(0x1c9)+P['code']);if(j['has'](P['code']))throw new ConflictError('Dictionary\x20already\x20registered:\x20'+P['code']);j[C(0x1ca)](P[C(0x1cb)],{...P,'source':'static'});}}function n(o){return j['has'](o);}async function v(o){const I=A;i(o);const P=j[I(0x1cc)](o);if(P&&P[I(0x1cd)])return P[I(0x1ce)];const t=await H();if(!t)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const g=await z?.['query'](I(0x1cf),[o]);if(g?.['rows']?.[I(0x1d0)]){const y=g?.[I(0x1d1)];return j['set'](o,{'code':o,'name':o,'items':y,'source':'database','checked':!![]}),y;}if(!P?.['items'])throw new NotFoundError(I(0x1d2)+o);return P['checked']=!![],P['items'];}async function r(o,P){const l=A;i(o);if(!Array['isArray'](P))throw new ValidationError('Dictionary\x20items\x20must\x20be\x20an\x20array');const t=await H();if(!t)throw new NotFoundError(l(0x1d3));if(!z)throw new Error('empty\x20pg');const g=await z['connect']();try{await g['query'](l(0x1d4));const y=await g[l(0x1d5)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[o,o,l(0x1d6),l(0x1d7),!![]]),B=y[l(0x1d1)][0x0]['id'];await g[l(0x1d5)](l(0x1d8),[B]);for(const Y of P){await g['query'](l(0x1d9),[B,Y['code'],Y['name'],Y['parentId']??null]);}await g['query']('COMMIT');}catch(s){await g[l(0x1d5)]('ROLLBACK');throw s;}finally{g['release']();}j[l(0x1ca)](o,{'items':P,'code':o,'source':l(0x1da),'checked':!![]}),c[l(0x1ca)](o,(c[l(0x1cc)](o)??0x0)+0x1);}function q(o){const x=A;return i(o),c[x(0x1ca)](o,(c[x(0x1cc)](o)??0x0)+0x1),j['delete'](o);}function Z(o){return c['get'](o)??0x0;}async function e(){const o=[...j['values']()]['map'](({code:g,name:y,source:B})=>({'code':g,'name':y??g,'source':B})),P=await H();if(!P)return o;if(!z)throw new Error('empty\x20pg');const t=await z['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20');for(const g of t['rows']){!j['has'](g['code'])&&o['push'](g);}return o;}return b(dictionaries),{'register':b,'get':v,'put':r,'clear':q,'revision':Z,'list':e,'has':n};}
|
package/dist/plugins/file.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the S3-compatible file storage adapter and its contracts.
|
|
3
3
|
*/
|
|
4
|
+
import type { Readable } from "node:stream";
|
|
4
5
|
export interface FileAdapter {
|
|
5
|
-
put(path: string,
|
|
6
|
+
put(path: string, body: Buffer | Readable): Promise<void>;
|
|
6
7
|
get(path: string): Promise<Buffer>;
|
|
7
8
|
exists(path: string): Promise<boolean>;
|
|
8
9
|
delete(path: string): Promise<void>;
|
|
9
10
|
create(path: string, ttl?: number): string;
|
|
10
|
-
verify(token: string):
|
|
11
|
-
}
|
|
12
|
-
export interface FileTokenPayload {
|
|
13
|
-
p: string;
|
|
14
|
-
exp: number;
|
|
11
|
+
verify(token: string): string;
|
|
15
12
|
}
|
|
16
13
|
export interface FileS3Config {
|
|
17
14
|
endpoint?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAKD,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAgCD,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAiF9D"}
|
package/dist/plugins/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';
|
|
1
|
+
import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';import z from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function A(z,j){z=z-0x13c;const c=U();let p=c[z];return p;}function keyFor(j,c){const q=A;if(!c||c['startsWith']('/')||c['includes']('..'))throw new ValidationError('Invalid\x20file\x20path');const p=c['replace'](/\\/g,'/')[q(0x13c)](/^\/+/,''),M=(j??'')['replace'](/^\/+|\/+$/g,'');return M?M+'/'+p:p;}function U(){const y=['replace','alloc','from','transformToByteArray','accessKeyId','secretKey','bucket','Body','send','tokenTtl','createHmac','update','split','base64url','length'];U=function(){return y;};return U();}async function bodyToBuffer(j){const Z=A;if(!j)return Buffer[Z(0x13d)](0x0);const c=j;if(typeof c['transformToByteArray']==='function')return Buffer[Z(0x13e)](await c[Z(0x13f)]());const p=[];for await(const M of j){p['push'](Buffer['from'](M));}return Buffer['concat'](p);}export function createFileS3(j){const e=A,c=j['tokenSecret']??process.env.FILE_TOKEN_SECRET??z['randomBytes'](0x20)['toString']('hex'),p=new S3Client({'endpoint':j['endpoint'],'region':j['region']??'us-east-1','forcePathStyle':j['forcePathStyle']??!![],'credentials':j[e(0x140)]||j['accessKey']?{'accessKeyId':j['accessKeyId']??j['accessKey'],'secretAccessKey':j['secretAccessKey']??j[e(0x141)]}:undefined}),M=H=>keyFor(j['folder'],H);return{async 'put'(H,i){await p['send'](new PutObjectCommand({'Bucket':j['bucket'],'Key':M(H),'Body':i}));},async 'get'(H){const o=e,i=await p['send'](new GetObjectCommand({'Bucket':j[o(0x142)],'Key':M(H)}));return bodyToBuffer(i[o(0x143)]);},async 'exists'(H){const P=e;try{return await p[P(0x144)](new HeadObjectCommand({'Bucket':j['bucket'],'Key':M(H)})),!![];}catch(i){const b=i;if(b['$metadata']?.['httpStatusCode']===0x194||b['name']==='NotFound')return![];throw i;}},async 'delete'(H){await p['send'](new DeleteObjectCommand({'Bucket':j['bucket'],'Key':M(H)}));},'create'(H,i=j[e(0x145)]??0xe10){const t=e,b=Buffer['from'](H)['toString']('base64url'),n=z[t(0x146)]('sha256',c)[t(0x147)](b)['digest']('base64url');return b+'.'+n;},'verify'(H){const g=e,[i,b]=H[g(0x148)]('.');if(!i||!b)throw new UnauthorizedError('Invalid\x20file\x20token');const n=z['createHmac']('sha256',c)['update'](i)['digest'](),v=Buffer['from'](b,g(0x149));if(n['length']!==v[g(0x14a)]||!z['timingSafeEqual'](n,v))throw new UnauthorizedError('Invalid\x20file\x20token');const r=Buffer['from'](i,'base64url')['toString']('utf8');return r;}};}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from'./logger/index.js';export*from'./redis.js';export*from'./pg.js';export*from'./auth/index.js';export*from'./file.js';export*from'./dictionary.js';export*from'./audit/index.js';export*from'./resource/index.js';
|
|
1
|
+
export*from'./logger/index.js';export*from'./redis.js';export*from'./pg.js';export*from'./auth/index.js';export*from'./file.js';export*from'./dictionary.js';export*from'./audit/index.js';export*from'./resource/index.js';export*from'./jwt.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/plugins/jwt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,+BAY/D;AACD,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,qBAKjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SignJWT,jwtVerify}from'jose';function A(z,j){z=z-0x9c;const c=U();let p=c[z];return p;}const secret=new TextEncoder()['encode'](process.env.AUTH_JWT_SECRET);export async function jwtSignToken(z){const H=A;if(!process.env.AUTH_JWT_SECRET)return;const {id:j,type:c,permissions:p}=z,M=await new SignJWT({'id':j,'type':c,'permissions':p})['setProtectedHeader']({'alg':H(0x9c)})['setIssuedAt']()[H(0x9d)]('1h')[H(0x9e)](secret);return M;}export async function jwtVerifyToken(z){const i=A,j=await jwtVerify(z,secret,{'algorithms':['HS256']})[i(0x9f)](c=>{const b=i;console['log'](c[b(0xa0)]);});return j?.['payload'];}function U(){const n=['HS256','setExpirationTime','sign','catch','message'];U=function(){return n;};return U();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import z from'pino';function U(){const n=['transport','./transport.js','stdTimeFunctions','app','req.headers.authorization','[REDACTED]','info','bind'];U=function(){return n;};return U();}function A(z,j){z=z-0x19e;const c=U();let p=c[z];return p;}export function createLogger(){const b=A,j=z[b(0x19e)]({'target':b(0x19f)}),c=z({'level':'info','timestamp':z[b(0x1a0)]['isoTime'],'base':{'service':b(0x1a1)},'redact':{'paths':[b(0x1a2),'password','token','accessToken','refreshToken'],'censor':b(0x1a3)}},j),p={};function M(H,i){if(H===undefined)return{...p};p[H]=(p[H]??0x0)+(i??0x1);}return Object['assign'](c,{'close':async()=>j['end'](),'metrics':M,'file':()=>c[b(0x1a4)][b(0x1a5)](c)});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const b=A;function A(z,j){z=z-0x1d8;const c=U();let p=c[z];return p;}import z from'node:fs';import j from'node:path';import c from'pino-abstract-transport';const LEVELS={0x1e:b(0x1d8),0x28:'warn',0x32:'error',0x3c:'error'},streams=new Map();function getDate(){return new Date()['toISOString']()['slice'](0x0,0xa);}function createStream(p,M){const n=b,H=j['resolve'](n(0x1d9),p);return z['mkdirSync'](H,{'recursive':!![]}),z[n(0x1da)](j[n(0x1db)](H,M+n(0x1dc)),{'flags':'a'});}function getStream(p){const v=b,M=getDate(),H=streams[v(0x1dd)](p);if(H&&H['date']===M)return H['stream'];H?.[v(0x1de)]['end']();const i=createStream(p,M);return streams['set'](p,{'date':M,'stream':i}),i;}function U(){const Z=['info','logs','createWriteStream','join','.log','get','stream','values','level','write'];U=function(){return Z;};return U();}function closeStreams(){const r=b;for(const {stream:p}of streams[r(0x1df)]()){p['end']();}streams['clear']();}export default async function loggerTransport(){return c(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(p){const q=b;for await(const M of p){const H=LEVELS[M[q(0x1e0)]];if(!H)continue;const i=getStream(M['file']||H);delete M['file'],i[q(0x1e1)](JSON['stringify'](M)+'\x0a');}}
|
package/dist/plugins/pg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/plugins/pg.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/plugins/pg.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,cAAc,CAC1B,MAAM,EAAE,cAAc,qBAuBzB;AACD,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC,IAAI,CAAC"}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import z from'pg';const {Pool}=z;function U(){const Z=['callerStack','stack','query'];U=function(){return Z;};return U();}function A(z,j){z=z-0xaf;const c=U();let p=c[z];return p;}export function createDatabase(j){const q=A,c=new Pool(j),p=c['query']['bind'](c);function M(H,i){const b=new Error();return Error['captureStackTrace']?.(b,M),p(H,i)['catch'](n=>{const r=A,v=n;v['sql']=H,v[r(0xaf)]=b[r(0xb0)];throw v;});}return c[q(0xb1)]=M,c;}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function A(z,j){z=z-0x8e;const c=U();let p=c[z];return p;}import{Redis}from'ioredis';function U(){const b=['set'];U=function(){return b;};return U();}export function createRedis(z){const j=new Redis(z);return{'get':c=>j['get'](c),'set':(c,p,M,H)=>{const i=A;if(H)return j['set'](c,p,'EX',H);if(typeof M==='number')return j['set'](c,p,'EX',M);return j[i(0x8e)](c,p);},'del':c=>j['del'](c),'delete':c=>j['del'](c),'close':()=>j['quit'](),'ping':()=>j['ping'](),'hincrby':(c,p,M)=>j['hincrby'](c,p,M),'incrby':(c,p)=>j['incrby'](c,p)};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUhF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CA2BzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';
|
|
1
|
+
import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';function U(){const Z=['has','bind','list'];U=function(){return Z;};return U();}import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';function A(z,j){z=z-0x15b;const c=U();let p=c[z];return p;}import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(z){const q=A,j=new ResourceRegistry(),c=createFind(z,j),p=createFindOne(z,j),M=createCreate(z,j),H=createUpdate(z,j),i=createRemove(z,j),b=createFindRelation(z,j),n=createCreateRelation(z,j),v=createUpdateRelation(z,j),r=createDeleteRelation(z,j);return{'register':j['register']['bind'](j),'has':j[q(0x15b)][q(0x15c)](j),'get':j['get']['bind'](j),'list':j[q(0x15d)]['bind'](j),'find':c,'findOne':p,'create':M,'update':H,'delete':i,'findRelation':b,'createRelation':n,'updateRelation':v,'deleteRelation':r};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const p=A;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function A(z,j){z=z-0x193;const c=U();let p=c[z];return p;}function validQualified(z){return z['split']('.')['length']<=0x2&&z['split']('.')['every'](j=>ident['test'](j));}export class ResourceRegistry{['resources']=new Map();[p(0x193)](z){const M=p;for(const j of Array[M(0x194)](z)?z:[z]){this[M(0x195)](j);if(this['resources'][M(0x196)](j['name']))throw new ConflictError('Resource\x20already\x20registered:\x20'+j['name']);this['resources']['set'](j['name'],j);}}['has'](z){const H=p;return this['resources'][H(0x196)](z);}['get'](z){const j=this['resources']['get'](z);if(!j)throw new NotFoundError('Resource\x20not\x20registered:\x20'+z);return j;}['list'](){const i=p;return[...this[i(0x197)]['values']()];}['validate'](z){const b=p;if(z['version']!==0x1||!ident[b(0x198)](z['name'])||!validQualified(z['table'])||!ident['test'](z['key']))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+z['name']);for(const [j,c]of Object['entries'](z[b(0x199)])){if(!ident[b(0x198)](j)||!ident[b(0x198)](c['column']??j))throw new ValidationError(b(0x19a)+j);}}}function U(){const n=['register','isArray','validate','has','resources','test','fields','Invalid\x20resource\x20field:\x20'];U=function(){return n;};return U();}
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
import type { DatabaseAdapter } from "../pg.js";
|
|
5
5
|
import type { AppLogger } from "../logger/index.js";
|
|
6
6
|
import type { AuditPlugin } from "../audit/index.js";
|
|
7
|
+
import type { DictionaryPlugin } from "../dictionary.js";
|
|
8
|
+
import type { FileAdapter } from "../file.js";
|
|
7
9
|
import { User } from "../../context.js";
|
|
8
10
|
export type ResourceOperation = "read" | "create" | "update" | "delete";
|
|
9
11
|
export interface ResourceFieldContract {
|
|
10
12
|
column?: string;
|
|
11
|
-
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid";
|
|
13
|
+
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid" | "file" | "geometry" | "geom";
|
|
12
14
|
read?: boolean;
|
|
13
15
|
write?: boolean;
|
|
14
16
|
readable?: boolean;
|
|
@@ -40,6 +42,7 @@ export interface ResourceRelationContract {
|
|
|
40
42
|
sourceField?: string;
|
|
41
43
|
foreignKey?: string;
|
|
42
44
|
targetField?: string;
|
|
45
|
+
type?: "one" | "many";
|
|
43
46
|
fields?: string[];
|
|
44
47
|
}
|
|
45
48
|
export interface ResourceContract {
|
|
@@ -54,11 +57,11 @@ export interface ResourceContract {
|
|
|
54
57
|
permission?: string;
|
|
55
58
|
fields: Record<string, ResourceFieldContract>;
|
|
56
59
|
relations?: Record<string, ResourceRelationContract>;
|
|
57
|
-
children?: Record<string, ResourceRelationContract>;
|
|
58
60
|
access?: "public" | "user" | "admin";
|
|
59
61
|
}
|
|
60
62
|
export interface ResourceQuery {
|
|
61
63
|
filter?: Record<string, unknown>;
|
|
64
|
+
include?: string | string[];
|
|
62
65
|
sort?: string[];
|
|
63
66
|
search?: string;
|
|
64
67
|
limit?: number;
|
|
@@ -74,9 +77,11 @@ export interface ResourceListResult<T = Record<string, unknown>> {
|
|
|
74
77
|
}
|
|
75
78
|
export type ResourceUser = User;
|
|
76
79
|
export interface ResourceDependencies {
|
|
77
|
-
pg: DatabaseAdapter
|
|
80
|
+
pg: DatabaseAdapter;
|
|
78
81
|
logger?: AppLogger;
|
|
79
82
|
audit?: AuditPlugin;
|
|
83
|
+
dictionary?: DictionaryPlugin;
|
|
84
|
+
file?: FileAdapter;
|
|
80
85
|
}
|
|
81
86
|
export interface ResourcePlugin {
|
|
82
87
|
register(input: ResourceContract | ResourceContract[]): void;
|
|
@@ -91,6 +96,7 @@ export interface ResourcePlugin {
|
|
|
91
96
|
findOne(params: {
|
|
92
97
|
name: string;
|
|
93
98
|
id: string | number;
|
|
99
|
+
query?: ResourceQuery;
|
|
94
100
|
user?: ResourceUser;
|
|
95
101
|
}): Promise<Record<string, unknown> | null>;
|
|
96
102
|
create(params: {
|
|
@@ -113,6 +119,7 @@ export interface ResourcePlugin {
|
|
|
113
119
|
name: string;
|
|
114
120
|
id: string | number;
|
|
115
121
|
relation: string;
|
|
122
|
+
query?: ResourceQuery;
|
|
116
123
|
user?: ResourceUser;
|
|
117
124
|
}): Promise<any>;
|
|
118
125
|
createRelation(params: {
|
|
@@ -122,6 +129,14 @@ export interface ResourcePlugin {
|
|
|
122
129
|
data?: Record<string, unknown>;
|
|
123
130
|
user?: ResourceUser;
|
|
124
131
|
}): Promise<any>;
|
|
132
|
+
updateRelation(params: {
|
|
133
|
+
name: string;
|
|
134
|
+
id: string | number;
|
|
135
|
+
relation: string;
|
|
136
|
+
relationId: string;
|
|
137
|
+
data: Record<string, unknown>;
|
|
138
|
+
user?: ResourceUser;
|
|
139
|
+
}): Promise<Record<string, unknown>>;
|
|
125
140
|
deleteRelation(params: {
|
|
126
141
|
name: string;
|
|
127
142
|
id: string | number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function addDictionaryLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], dictionary: ResourceDependencies["dictionary"]): Promise<Record<string, unknown>[]>;
|
|
3
|
+
//# sourceMappingURL=add-dictionary-lookup-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-dictionary-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-dictionary-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAsDnF,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,GAC7C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAuBpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function A(z,j){z=z-0x1b7;const c=U();let p=c[z];return p;}function U(){const o=['set','map','has','get','code','text','color','icon','length'];U=function(){return o;};return U();}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(z,j){const q=A,c=dictionaryIndexesCache['get'](j)??new Map(),p=dictionaryRevisionsCache['get'](j)??new Map();dictionaryIndexesCache['set'](j,c),dictionaryRevisionsCache[q(0x1b7)](j,p);const M=z['filter'](i=>p['get'](i)!==j['revision'](i));if(M['length']===0x0)return c;const H=await Promise['all'](M[q(0x1b8)](async i=>{const Z=q;if(!j[Z(0x1b9)](i))return[i,new Map()];const b=await j[Z(0x1ba)](i),n=new Map();for(const v of b){const r=v[Z(0x1bb)]??v['id'];if(r==null)continue;n[Z(0x1b7)](String(r),{'id':r,'text':v['name']??v[Z(0x1bc)],...v[Z(0x1bd)]!==undefined?{'color':v['color']}:{},...v[Z(0x1be)]!==undefined?{'icon':v['icon']}:{}});}return[i,n];}));for(const [i,b]of H){c[q(0x1b7)](i,b),p[q(0x1b7)](i,j['revision'](i));}return c;}export async function addDictionaryLookupData(z,j,c){const e=A;if(!c||z[e(0x1bf)]===0x0)return z;const p=Object['entries'](j)['flatMap'](([H,i])=>{const b=i['lookup']?.['dictionary'];return b?[{'field':H,'dictionaryName':b}]:[];});if(p['length']===0x0)return z;const M=await getDictionaryIndexes([...new Set(p['map'](({dictionaryName:H})=>H))],c);for(const H of z){for(const {field:i,dictionaryName:b}of p){const n=H[i];H[i+'_data']=n==null?null:M['get'](b)?.['get'](String(n))??null;}}return z;}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function addFileToken(rows: Record<string, unknown>[], fields: ResourceContract["fields"], file: ResourceDependencies["file"]): Record<string, unknown>[];
|
|
3
|
+
//# sourceMappingURL=add-file-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-file-token.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-file-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,wBAAgB,YAAY,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAiB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function A(z,j){z=z-0x83;const c=U();let p=c[z];return p;}export function addFileToken(z,j,c){const b=A;if(!c||z[b(0x83)]===0x0)return z;const p=Object[b(0x84)](j)[b(0x85)](([,M])=>M[b(0x86)]==='file')['map'](([M])=>M);for(const M of z){for(const H of p){const i=M[H];typeof i==='string'&&i['length']>0x0&&(M[H]=c['create'](i));}}return z;}function U(){const n=['length','entries','filter','type'];U=function(){return n;};return U();}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function clearTableLookupCache(table: string, pg: NonNullable<ResourceDependencies["pg"]>): void;
|
|
3
|
+
export declare function addTableLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], pg: ResourceDependencies["pg"]): Promise<Record<string, unknown>[]>;
|
|
4
|
+
//# sourceMappingURL=add-table-lookup-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-table-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-table-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAenF,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAC5C,IAAI,CASN;AAED,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CA8DpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{qi,qt}from'../utils/sql.js';function U(){const B=['entries','name','lookup','set','textField','get','has','query','\x20AS\x20id,\x20','valueField','field'];U=function(){return B;};return U();}function A(z,j){z=z-0x150;const c=U();let p=c[z];return p;}const tableLookupCache=new WeakMap();export function clearTableLookupCache(z,j){const c=tableLookupCache['get'](j);if(!c)return;for(const p of c['keys']()){p['startsWith'](z+':')&&c['delete'](p);}}export async function addTableLookupData(z,j,c){const g=A;if(!c||z['length']===0x0)return z;const p=tableLookupCache['get'](c)??new Map();tableLookupCache['set'](c,p);const M=Object[g(0x150)](j)['flatMap'](([H,i])=>{const y=g,{table:b,valueField:valueField='id',textField:textField=y(0x151)}=i[y(0x152)]??{};return b?[{'field':H,'table':b,'valueField':valueField,'textField':textField}]:[];});for(const H of M){const i=new Map();for(const r of z){const q=r[H['field']];(typeof q==='string'||typeof q==='number')&&i[g(0x153)](String(q),q);}const b=H['table']+':'+H['valueField']+':'+H[g(0x154)],n=p[g(0x155)](b)??new Map();p['set'](b,n);const v=[...i['entries']()]['filter'](([Z])=>!n[g(0x156)](Z))['map'](([,Z])=>Z);if(v['length']>0x0){const Z=await c[g(0x157)]('SELECT\x20'+qi(H['valueField'])+g(0x158)+qi(H['textField'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(H['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(H[g(0x159)])+'\x20=\x20ANY($1)',[v]);for(const e of Z['rows']){n['set'](String(e['id']),e);}for(const o of v){!n['has'](String(o))&&n['set'](String(o),null);}}for(const P of z){const t=P[H[g(0x15a)]];P[H[g(0x15a)]+'_data']=t==null?null:n['get'](String(t))??null;}}return z;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function
|
|
1
|
+
function U(){const C=['body','files','resource','includes','No\x20writable\x20fields','map','query','rows','UPDATE\x20','foreignKey','key'];U=function(){return C;};return U();}import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function A(z,j){z=z-0xb6;const c=U();let p=c[z];return p;}import{createCreate}from'./create.js';export function createCreateRelation(z,j){const c=createCreate(z,j);return async function p({name:M,id:H,relation:i,data:b,user:n}){const D=A;if(!z['pg'])throw new Error('empty\x20pg');if(i==='notes'){const e=await z['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[M,String(H),b?.[D(0xb6)]]);return e['rows'][0x0];}if(i===D(0xb7)){const o=await z['pg']['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(H),b?.['filePath'],b?.['size']??null]);return o['rows'][0x0];}const v=j['get'](M),r=v['relations']?.[i];if(!r?.['foreignKey']||!r[D(0xb8)]&&!r['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+i+'\x22\x20requires\x20a\x20project/provider\x20implementation');let q,Z;if(r['resource'])q=await c({'name':r[D(0xb8)],'data':b??{},'user':n}),Z=q[j['get'](r['resource'])['key']];else{const P=r['fields'];if(!P?.['length'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+i+'\x22\x20requires\x20a\x20project/provider\x20implementation');const t=Object['entries'](b??{})['filter'](([s])=>P[D(0xb9)](s));if(!t['length'])throw new ValidationError(D(0xba));const g=t[D(0xbb)](([s])=>qi(s)),y=t['map']((s,R)=>'$'+(R+0x1)),B=t[D(0xbb)](([,s])=>s),Y=await z['pg'][D(0xbc)]('INSERT\x20INTO\x20'+qt(r['table'])+'\x20('+g['join'](',\x20')+')\x20VALUES\x20('+y['join'](',\x20')+')\x20RETURNING\x20*',B);q=Y[D(0xbd)][0x0],Z=q['id'];}return await z['pg'][D(0xbc)](D(0xbe)+qt(v['table'])+'\x20SET\x20'+qi(r[D(0xbf)])+'\x20=\x20$1\x20WHERE\x20'+qi(v[D(0xc0)])+'\x20=\x20$2',[Z,H]),q;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsCrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';function U(){const t=['map','empty\x20pg','VALUES\x20(','RETURNING\x20','rows','table','audit','name','create'];U=function(){return t;};return U();}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function A(z,j){z=z-0x178;const c=U();let p=c[z];return p;}export function createCreate(z,j){return async function c({name:p,data:M,user:H}){const P=A,i=j['get'](p);assertOperation(i,'create',H),validateInputData({'resource':i,'data':M});const b=writableData(i,M);if(!b['length'])throw new ValidationError('No\x20writable\x20fields');const n=b[P(0x178)](([e])=>qi(e)),v=b['map']((e,o)=>'$'+(o+0x1)),r=b[P(0x178)](([,e])=>e);if(!z['pg'])throw new Error(P(0x179));const q=await z['pg']['query']('INSERT\x20INTO\x20'+qt(i['table'])+'\x20('+n['join'](',\x20')+')\x20'+(P(0x17a)+v['join'](',\x20')+')\x20')+(P(0x17b)+readableFields(i)['join'](',\x20')),r),Z=q[P(0x17c)][0x0];return clearTableLookupCache(i[P(0x17d)],z['pg']),await z[P(0x17e)]?.['write']({'userId':H?.['id'],'module':i['module'],'resource':i[P(0x17f)],'resourceId':Z[i['key']],'action':P(0x180),'fields':Object['keys'](M)}),Z;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function A(z,j){z=z-0x78;var c=U();var p=c[z];return p;}import{UnsupportedError}from'../../../errors.js';export function createDeleteRelation(z,j){return async function c({name:p,id:M,relation:H,relationId:i}){var b=A;if(!z['pg'])throw new Error('empty\x20pg');if(H==='notes')return await z['pg'][b(0x78)]('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[i,p,String(M)]),{'success':!![]};if(H===b(0x79))return await z['pg'][b(0x78)]('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[i,p,String(M)]),{'success':!![]};throw new UnsupportedError(b(0x7a)+H+'\x22\x20requires\x20a\x20project/provider\x20implementation');};}function U(){var n=['query','files','Generic\x20Resource\x20relation\x20\x22'];U=function(){return n;};return U();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,sBA0BF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function U(){const v=['=$1','delete'];U=function(){return v;};return U();}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function A(z,j){z=z-0x79;const c=U();let p=c[z];return p;}export function createRemove(z,j){return async function c({name:p,id:M,user:H}){const n=A,i=j['get'](p);assertOperation(i,'delete',H);if(!z['pg'])throw new Error('empty\x20pg');const b=await z['pg']['query']('DELETE\x20FROM\x20'+qt(i['table'])+'\x20WHERE\x20'+qi(i['key'])+n(0x79),[M]);if((b['rowCount']??0x0)>0x0)clearTableLookupCache(i['table'],z['pg']);if((b['rowCount']??0x0)>0x0)await z['audit']?.['write']({'module':i['module'],'resource':i['name'],'resourceId':M,'action':n(0x7a)});return(b['rowCount']??0x0)>0x0;};}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the find one operation of the generic Resource CRUD engine.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
|
|
6
|
+
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, query, user, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
id: string | number;
|
|
9
|
+
query?: ResourceQuery;
|
|
9
10
|
user?: ResourceUser;
|
|
10
11
|
}) => Promise<Record<string, unknown> | null>;
|
|
11
12
|
//# sourceMappingURL=find-one.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAsDF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';function A(z,j){z=z-0x1c0;const c=U();let p=c[z];return p;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function U(){const Y=['read','query','join','=$1\x20LIMIT\x201','dictionary','file','include','split','relations','table','Unknown\x20relation:\x20','resource','key','SELECT\x20'];U=function(){return Y;};return U();}import{addFileToken}from'./add-file-token.js';export function createFindOne(z,j){return async function c({name:p,id:M,query:query={},user:H}){const B=A,i=Date['now'](),b=j['get'](p);assertOperation(b,B(0x1c0),H);if(!z['pg'])throw new Error('empty\x20pg');const n=await z['pg'][B(0x1c1)]('SELECT\x20'+readableFields(b)[B(0x1c2)](',\x20')+'\x20FROM\x20'+qt(b['table'])+'\x20WHERE\x20'+qi(b['key'])+B(0x1c3),[M]),v=n['rows'][0x0];if(!v)return null;await addDictionaryLookupData([v],b['fields'],z[B(0x1c4)]),await addTableLookupData([v],b['fields'],z['pg']),addFileToken([v],b['fields'],z[B(0x1c5)]);const r=Array['isArray'](query[B(0x1c6)])?query['include']:query[B(0x1c6)]?.[B(0x1c7)](',')??[];for(const q of r){const Z=b[B(0x1c8)]?.[q];if(!Z?.['foreignKey']||!Z['resource']&&!Z[B(0x1c9)])throw new ValidationError(B(0x1ca)+q);const e=Z['resource']?j['get'](Z[B(0x1cb)]):undefined,o=Z['table']??e[B(0x1c9)],P=e?.[B(0x1cc)]??'id',t=e?readableFields(e)['join'](',\x20'):'*',g=B(0x1cd)+t+'\x20FROM\x20'+qt(o)+'\x20WHERE\x20'+qi(P)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(Z['foreignKey'])+'\x20FROM\x20'+qt(b['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(b[B(0x1cc)])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',y=(await z['pg']['query'](g,[M]))['rows'];e&&(await addDictionaryLookupData(y,e['fields'],z['dictionary']),await addTableLookupData(y,e['fields'],z['pg']),addFileToken(y,e['fields'],z['file'])),v[q]=y;}return v['time']=Date['now']()-i,v;};}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the find relation operation of the generic Resource CRUD engine.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, }: {
|
|
6
|
+
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, query, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
id: string | number;
|
|
9
9
|
relation: string;
|
|
10
|
+
query?: ResourceQuery;
|
|
10
11
|
user?: ResourceUser;
|
|
11
12
|
}) => Promise<any>;
|
|
12
13
|
//# sourceMappingURL=find-relation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAyEjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../../errors.js';
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';function U(){const Y=['now','query','rows','file','table','resource','key','length','dictionary','fields'];U=function(){return Y;};return U();}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function A(z,j){z=z-0x16f;const c=U();let p=c[z];return p;}import{addFileToken}from'./add-file-token.js';export function createFindRelation(z,j){return async function c({name:p,id:M,relation:H,query:query={}}){const B=A,i=Date[B(0x16f)](),b=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),n=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](b)||!Number['isFinite'](n))throw new ValidationError('Invalid\x20pagination');if(H==='notes'){const g=await z['pg'][B(0x170)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[p,String(M)]);return{'total':g[B(0x171)]['length'],'time':Date['now']()-i,'rows':g['rows']};}if(H==='files'){const y=await z['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[p,String(M)]);return addFileToken(y[B(0x171)],{'file_path':{'type':B(0x172)}},z['file']),{'total':y['rows']['length'],'time':Date['now']()-i,'rows':y['rows']};}const v=j['get'](p),r=v['relations']?.[H];if(!r?.['foreignKey']||!r['resource']&&!r[B(0x173)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+H+'\x22\x20requires\x20a\x20project/provider\x20implementation');const q=r['resource']?j['get'](r[B(0x174)]):undefined,Z=r['table']??q['table'],e=q?.[B(0x175)]??'id',o=r['fields']?.[B(0x176)]?r['fields']['map'](qi)['join'](',\x20'):'*',P='SELECT\x20'+o+'\x20FROM\x20'+qt(Z)+'\x20WHERE\x20\x0a\x20\x20\x20\x20'+qi(e)+'\x20=\x20(select\x20'+qi(r['foreignKey'])+'\x20FROM\x20'+qt(v[B(0x173)])+'\x20WHERE\x20'+qi(v['key'])+'\x20=\x20$1\x20LIMIT\x201)\x20\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3',t=await z['pg']['query'](P,[M,b,n]);return q&&(await addDictionaryLookupData(t['rows'],q['fields'],z[B(0x177)]),await addTableLookupData(t['rows'],q['fields'],z['pg']),addFileToken(t['rows'],q[B(0x178)],z['file'])),{'limit':b,'offset':n,'total':t[B(0x171)][B(0x176)],'time':Date['now']()-i,'rows':t['rows']??null};};}
|
|
@@ -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;
|
|
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;AAKhE,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,CAsChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';function U(){const P=['now','max','offset','filter','length','OFFSET\x20$','query'];U=function(){return P;};return U();}import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function A(z,j){z=z-0x1d4;const c=U();let p=c[z];return p;}import{addFileToken}from'./add-file-token.js';export function createFind(z,j){return async function c({name:p,query:query={},user:M}){const o=A,H=Date[o(0x1d4)](),i=j['get'](p);assertOperation(i,'read',M);const b=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),n=Math[o(0x1d5)](query[o(0x1d6)]??0x0,0x0),v=buildFilters(i,query[o(0x1d7)],0x1,z['pg']),r=buildSort(i,query['sort']);if(!Number['isFinite'](b)||!Number['isFinite'](n))throw new ValidationError('Invalid\x20pagination');const q='SELECT\x20'+readableFields(i)['join'](',\x20')+'\x20'+('FROM\x20'+qt(i['table']))+(''+v['sql']+r+'\x20')+('LIMIT\x20$'+(v['values'][o(0x1d8)]+0x1)+'\x20')+(o(0x1d9)+(v['values']['length']+0x2)),Z=await z['pg'][o(0x1da)](q,[...v['values'],b,n]),e=Z['rows'];return await addDictionaryLookupData(e,i['fields'],z['dictionary']),await addTableLookupData(e,i['fields'],z['pg']),addFileToken(e,i['fields'],z['file']),{'limit':b,'offset':n,'total':Z['rowCount'],'time':Date[o(0x1d4)]()-H,'rows':e};};}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
+
export declare function createUpdateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, data, user, }: {
|
|
4
|
+
name: string;
|
|
5
|
+
id: string | number;
|
|
6
|
+
relation: string;
|
|
7
|
+
relationId: string | number;
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
user?: ResourceUser;
|
|
10
|
+
}) => Promise<Record<string, unknown>>;
|
|
11
|
+
//# sourceMappingURL=update-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update-relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,qDAWvB;IACC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0BvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(z,j){const c=createUpdate(z,j);return async function p({name:M,id:H,relation:i,relationId:b,data:n,user:v}){if(!z['pg'])throw new Error('empty\x20pg');const r=j['get'](M),q=r['relations']?.[i];if(!q?.['resource']||!q['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+i);return c({'name':q['resource'],'id':b,'data':n,'user':v});};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+BAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA8CrC"}
|