@opengis/fcore 0.0.1-beta.1 → 0.0.1-beta.10
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.d.ts +2 -10
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts +5 -5
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.d.ts +3 -0
- package/dist/modules/auth/adduser-cli.d.ts.map +1 -0
- package/dist/modules/auth/adduser-cli.js +2 -0
- package/dist/modules/auth/passwd-cli.d.ts +3 -0
- package/dist/modules/auth/passwd-cli.d.ts.map +1 -0
- package/dist/modules/auth/passwd-cli.js +2 -0
- package/dist/modules/auth/permission-cli.d.ts +3 -0
- package/dist/modules/auth/permission-cli.d.ts.map +1 -0
- package/dist/modules/auth/permission-cli.js +2 -0
- 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 +10 -1
- 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.d.ts +9 -0
- package/dist/modules/auth/services/change-password.d.ts.map +1 -0
- package/dist/modules/auth/services/change-password.js +1 -0
- 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.d.ts +14 -0
- package/dist/modules/auth/services/registration.d.ts.map +1 -0
- package/dist/modules/auth/services/registration.js +1 -0
- 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.d.ts +8 -2
- package/dist/modules/resource/services/create-resource-relation.d.ts.map +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.d.ts +8 -1
- package/dist/modules/resource/services/delete-resource-relation.d.ts.map +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 +9 -2
- 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 +10 -4
- 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 +2 -1
- package/dist/modules/system/route.d.ts.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +22 -1
- package/dist/modules/system/schema.d.ts.map +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 +14 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-access.js +1 -0
- package/dist/modules/system/services/get-api-list.d.ts +4 -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 +9 -5
- 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 +16 -0
- package/dist/modules/system/services/set-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-access.js +1 -0
- package/dist/modules/system/services/update-dictionary.d.ts +13 -0
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -0
- 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/index.js +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.d.ts +3 -0
- package/dist/plugins/auth/get-user-permissions.d.ts.map +1 -0
- package/dist/plugins/auth/get-user-permissions.js +1 -0
- package/dist/plugins/auth/index.d.ts +4 -0
- package/dist/plugins/auth/index.d.ts.map +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.d.ts +9 -0
- package/dist/plugins/auth/verifyUser.d.ts.map +1 -0
- package/dist/plugins/auth/verifyUser.js +1 -0
- 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 +2 -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.d.ts +3 -0
- package/dist/plugins/logger/transport.d.ts.map +1 -0
- package/dist/plugins/logger/transport.js +1 -0
- package/dist/plugins/pg.d.ts +4 -2
- 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/index.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 +60 -6
- 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.d.ts +16 -0
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -0
- package/dist/plugins/resource/services/create.d.ts +5 -2
- 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.d.ts +18 -0
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/delete-relation.js +1 -0
- package/dist/plugins/resource/services/delete.d.ts +5 -2
- 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 +13 -0
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/find-relation.js +1 -0
- 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 +14 -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 +5 -2
- 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.d.ts +8 -1
- package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
- 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.d.ts.map +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/dist/type.d.ts +37 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +1 -0
- package/migrations/20260903120000_core_schema.sql +22 -19
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/migrations/20260907090000_core_schema.sql +32 -0
- package/package.json +13 -8
- package/dist/modules/auth/index.d.ts +0 -9
- package/dist/modules/auth/index.d.ts.map +0 -1
- package/dist/modules/auth/index.js +0 -1
- package/dist/modules/auth/services/login.d.ts +0 -10
- package/dist/modules/auth/services/login.d.ts.map +0 -1
- package/dist/modules/auth/services/login.js +0 -1
- package/dist/modules/auth/services/logout.d.ts +0 -9
- package/dist/modules/auth/services/logout.d.ts.map +0 -1
- package/dist/modules/auth/services/logout.js +0 -1
- package/dist/modules/auth/services/verifyPassword.d.ts +0 -11
- package/dist/modules/auth/services/verifyPassword.d.ts.map +0 -1
- package/dist/modules/auth/services/verifyPassword.js +0 -1
- package/dist/modules/file/index.d.ts +0 -8
- package/dist/modules/file/index.d.ts.map +0 -1
- package/dist/modules/file/index.js +0 -1
- package/dist/modules/resource/index.d.ts +0 -20
- package/dist/modules/resource/index.d.ts.map +0 -1
- package/dist/modules/resource/index.js +0 -1
- package/dist/modules/resource/services/list-children.d.ts +0 -6
- package/dist/modules/resource/services/list-children.d.ts.map +0 -1
- package/dist/modules/resource/services/list-children.js +0 -1
- package/dist/modules/system/index.d.ts +0 -13
- package/dist/modules/system/index.d.ts.map +0 -1
- package/dist/modules/system/index.js +0 -1
- package/dist/modules/utils/get-user-permissions.d.ts +0 -3
- package/dist/modules/utils/get-user-permissions.d.ts.map +0 -1
- package/dist/modules/utils/get-user-permissions.js +0 -1
package/dist/plugins/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
export * from "./logger/index.js";
|
|
5
5
|
export * from "./redis.js";
|
|
6
6
|
export * from "./pg.js";
|
|
7
|
+
export * from "./auth/index.js";
|
|
7
8
|
export * from "./file.js";
|
|
8
9
|
export * from "./dictionary.js";
|
|
9
10
|
export * from "./audit/index.js";
|
|
10
11
|
export * from "./resource/index.js";
|
|
12
|
+
export * from './jwt.js';
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,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
|
-
|
|
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
|
+
function S(d,h){d=d-0x1e7;const p=v();let Z=p[d];return Z;}import{SignJWT,jwtVerify}from'jose';function v(){const Y=['setProtectedHeader','catch','message'];v=function(){return Y;};return v();}const secret=new TextEncoder()['encode'](process.env.AUTH_JWT_SECRET);export async function jwtSignToken(d){const u=S;if(!process.env.AUTH_JWT_SECRET)return;const {id:h,type:p,permissions:Z}=d,D=await new SignJWT({'id':h,'type':p,'permissions':Z})[u(0x1e7)]({'alg':'HS256'})['setIssuedAt']()['setExpirationTime']('1h')['sign'](secret);return D;}export async function jwtVerifyToken(d){const n=S,h=await jwtVerify(d,secret,{'algorithms':['HS256']})[n(0x1e8)](p=>{const X=n;console['log'](p[X(0x1e9)]);});return h?.['payload'];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(d,h){d=d-0x9f;const p=v();let Z=p[d];return Z;}function v(){const Y=['app','accessToken','[REDACTED]','end'];v=function(){return Y;};return v();}import d from'pino';export function createLogger(){const X=S,h=d['transport']({'target':'./transport.js'}),p=d({'level':'info','timestamp':d['stdTimeFunctions']['isoTime'],'base':{'service':X(0x9f)},'redact':{'paths':['req.headers.authorization','password','token',X(0xa0),'refreshToken'],'censor':X(0xa1)}},h),Z={};function D(u,n){if(u===undefined)return{...Z};Z[u]=(Z[u]??0x0)+(n??0x1);}return Object['assign'](p,{'close':async()=>h[X(0xa2)](),'metrics':D,'file':()=>p['info']['bind'](p)});}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/plugins/logger/transport.js"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAuD5C,wBAA8B,eAAe,0DAM5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function S(d,h){d=d-0xcc;const p=v();let Z=p[d];return Z;}const X=S;import d from'node:fs';import h from'node:path';import p from'pino-abstract-transport';const LEVELS={0x1e:X(0xcc),0x28:X(0xcd),0x32:'error',0x3c:'error'},streams=new Map();function getDate(){const Y=X;return new Date()[Y(0xce)]()['slice'](0x0,0xa);}function createStream(Z,D){const w=X,u=h['resolve']('logs',Z);return d['mkdirSync'](u,{'recursive':!![]}),d['createWriteStream'](h[w(0xcf)](u,D+'.log'),{'flags':'a'});}function getStream(Z){const y=X,D=getDate(),u=streams['get'](Z);if(u&&u[y(0xd0)]===D)return u['stream'];u?.['stream']['end']();const n=createStream(Z,D);return streams['set'](Z,{'date':D,'stream':n}),n;}function v(){const B=['info','warn','toISOString','join','date','clear','level','file','stringify'];v=function(){return B;};return v();}function closeStreams(){const Q=X;for(const {stream:Z}of streams['values']()){Z['end']();}streams[Q(0xd1)]();}export default async function loggerTransport(){return p(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(Z){const F=X;for await(const D of Z){const u=LEVELS[D[F(0xd2)]];if(!u)continue;const n=getStream(D[F(0xd3)]||u);delete D['file'],n['write'](JSON[F(0xd4)](D)+'\x0a');}}
|
package/dist/plugins/pg.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface DatabaseConfig {
|
|
|
10
10
|
password: string;
|
|
11
11
|
max?: number;
|
|
12
12
|
}
|
|
13
|
-
export declare function createDatabase(config: DatabaseConfig):
|
|
14
|
-
export type DatabaseAdapter = pg.Pool
|
|
13
|
+
export declare function createDatabase(config: DatabaseConfig): DatabaseAdapter;
|
|
14
|
+
export type DatabaseAdapter = pg.Pool & {
|
|
15
|
+
transaction: <T>(callback: (client: pg.PoolClient) => Promise<T>) => Promise<T>;
|
|
16
|
+
};
|
|
15
17
|
//# sourceMappingURL=pg.d.ts.map
|
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,mBAiDzB;AACD,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC,IAAI,GAAG;IACpC,WAAW,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CACnF,CAAC"}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import d from'pg';function v(){const B=['query','connect','BEGIN','COMMIT'];v=function(){return B;};return v();}const {Pool}=d;function S(d,h){d=d-0x180;const p=v();let Z=p[d];return Z;}export function createDatabase(h){const Q=S,p=new Pool(h),Z=p[Q(0x180)]['bind'](p);function D(u,n){const X=new Error();return Error['captureStackTrace']?.(X,D),Z(u,n)['catch'](Y=>{const w=Y;w['sql']=u,w['callerStack']=X['stack'];throw w;});}return p['query']=D,p['transaction']=async function(u){const F=Q,n=new Error();Error['captureStackTrace']?.(n,p['transaction']);const X=await p[F(0x181)]();try{await X[F(0x180)](F(0x182));const Y=await u(X);return await X[F(0x180)](F(0x183)),Y;}catch(w){await X[F(0x180)]('ROLLBACK');const y=w;y['callerStack']=n['stack'];throw y;}finally{X['release']();}},p;}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function v(){const X=['del','quit','hincrby','incrby'];v=function(){return X;};return v();}import{Redis}from'ioredis';function S(d,h){d=d-0x1ac;const p=v();let Z=p[d];return Z;}export function createRedis(d){const n=S,h=new Redis(d);return{'get':p=>h['get'](p),'set':(p,Z,D,u)=>{if(u)return h['set'](p,Z,'EX',u);if(typeof D==='number')return h['set'](p,Z,'EX',D);return h['set'](p,Z);},'del':p=>h[n(0x1ac)](p),'delete':p=>h['del'](p),'close':()=>h[n(0x1ad)](),'ping':()=>h['ping'](),'hincrby':(p,Z,D)=>h[n(0x1ae)](p,Z,D),'incrby':(p,Z)=>h[n(0x1af)](p,Z)};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from'./resource.types.js';export*from'./resource.registry.js';export*from'./resource.js';
|
|
@@ -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
|
-
|
|
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';function v(){const F=['has'];v=function(){return F;};return v();}import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';function S(d,h){d=d-0x14a;const p=v();let Z=p[d];return Z;}import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(d){const Q=S,h=new ResourceRegistry(),p=createFind(d,h),Z=createFindOne(d,h),D=createCreate(d,h),u=createUpdate(d,h),n=createRemove(d,h),X=createFindRelation(d,h),Y=createCreateRelation(d,h),w=createUpdateRelation(d,h),y=createDeleteRelation(d,h);return{'register':h['register']['bind'](h),'has':h[Q(0x14a)]['bind'](h),'get':h['get']['bind'](h),'list':h['list']['bind'](h),'find':p,'findOne':Z,'create':D,'update':u,'delete':n,'findRelation':X,'createRelation':Y,'updateRelation':w,'deleteRelation':y};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function v(){const Y=['split','has','get','Resource\x20not\x20registered:\x20','validate','version','key','column'];v=function(){return Y;};return v();}const n=S;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(d){const Z=S;return d['split']('.')['length']<=0x2&&d[Z(0x94)]('.')['every'](h=>ident['test'](h));}function S(d,h){d=d-0x94;const p=v();let Z=p[d];return Z;}export class ResourceRegistry{['resources']=new Map();['register'](d){const D=S;for(const h of Array['isArray'](d)?d:[d]){this['validate'](h);if(this['resources'][D(0x95)](h['name']))throw new ConflictError('Resource\x20already\x20registered:\x20'+h['name']);this['resources']['set'](h['name'],h);}}['has'](d){return this['resources']['has'](d);}['get'](d){const u=S,h=this['resources'][u(0x96)](d);if(!h)throw new NotFoundError(u(0x97)+d);return h;}['list'](){return[...this['resources']['values']()];}[n(0x98)](d){const X=n;if(d[X(0x99)]!==0x1||!ident['test'](d['name'])||!validQualified(d['table'])||!ident['test'](d[X(0x9a)]))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+d['name']);for(const [h,p]of Object['entries'](d['fields'])){if(!ident['test'](h)||!ident['test'](p[X(0x9b)]??h))throw new ValidationError('Invalid\x20resource\x20field:\x20'+h);}}}
|
|
@@ -4,11 +4,14 @@
|
|
|
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";
|
|
10
|
+
import type { AppContext } from "../../context.js";
|
|
8
11
|
export type ResourceOperation = "read" | "create" | "update" | "delete";
|
|
9
12
|
export interface ResourceFieldContract {
|
|
10
13
|
column?: string;
|
|
11
|
-
type?: "string" | "number" | "integer" | "boolean" | "date" | "json";
|
|
14
|
+
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid" | "file" | "geometry" | "geom";
|
|
12
15
|
read?: boolean;
|
|
13
16
|
write?: boolean;
|
|
14
17
|
readable?: boolean;
|
|
@@ -21,15 +24,28 @@ export interface ResourceFieldContract {
|
|
|
21
24
|
filter?: boolean;
|
|
22
25
|
sort?: boolean;
|
|
23
26
|
search?: boolean;
|
|
27
|
+
dictionary?: string;
|
|
24
28
|
lookup?: {
|
|
25
|
-
|
|
29
|
+
table: string;
|
|
30
|
+
value: string;
|
|
31
|
+
text: string;
|
|
32
|
+
fields?: string[];
|
|
26
33
|
};
|
|
34
|
+
enum?: string[] | number[];
|
|
35
|
+
minLength?: number;
|
|
36
|
+
maxLength?: number;
|
|
37
|
+
minimum?: number;
|
|
38
|
+
maximum?: number;
|
|
39
|
+
pattern?: string;
|
|
27
40
|
}
|
|
28
41
|
export interface ResourceRelationContract {
|
|
29
42
|
resource?: string;
|
|
30
43
|
table?: string;
|
|
31
44
|
sourceField?: string;
|
|
45
|
+
foreignKey?: string;
|
|
32
46
|
targetField?: string;
|
|
47
|
+
type?: "one" | "many";
|
|
48
|
+
fields?: string[];
|
|
33
49
|
}
|
|
34
50
|
export interface ResourceContract {
|
|
35
51
|
version: 1;
|
|
@@ -39,6 +55,7 @@ export interface ResourceContract {
|
|
|
39
55
|
table: string;
|
|
40
56
|
key: string;
|
|
41
57
|
operations: ResourceOperation[];
|
|
58
|
+
capabilities?: string[];
|
|
42
59
|
permission?: string;
|
|
43
60
|
fields: Record<string, ResourceFieldContract>;
|
|
44
61
|
relations?: Record<string, ResourceRelationContract>;
|
|
@@ -46,6 +63,7 @@ export interface ResourceContract {
|
|
|
46
63
|
}
|
|
47
64
|
export interface ResourceQuery {
|
|
48
65
|
filter?: Record<string, unknown>;
|
|
66
|
+
include?: string | string[];
|
|
49
67
|
sort?: string[];
|
|
50
68
|
search?: string;
|
|
51
69
|
limit?: number;
|
|
@@ -55,13 +73,17 @@ export interface ResourceQuery {
|
|
|
55
73
|
export interface ResourceListResult<T = Record<string, unknown>> {
|
|
56
74
|
rows: T[];
|
|
57
75
|
limit: number;
|
|
76
|
+
time: number;
|
|
77
|
+
total: number | null;
|
|
58
78
|
offset: number;
|
|
59
79
|
}
|
|
60
80
|
export type ResourceUser = User;
|
|
61
81
|
export interface ResourceDependencies {
|
|
62
|
-
pg: DatabaseAdapter
|
|
82
|
+
pg: DatabaseAdapter;
|
|
63
83
|
logger?: AppLogger;
|
|
64
84
|
audit?: AuditPlugin;
|
|
85
|
+
dictionary?: DictionaryPlugin;
|
|
86
|
+
file?: FileAdapter;
|
|
65
87
|
}
|
|
66
88
|
export interface ResourcePlugin {
|
|
67
89
|
register(input: ResourceContract | ResourceContract[]): void;
|
|
@@ -76,23 +98,55 @@ export interface ResourcePlugin {
|
|
|
76
98
|
findOne(params: {
|
|
77
99
|
name: string;
|
|
78
100
|
id: string | number;
|
|
101
|
+
query?: ResourceQuery;
|
|
79
102
|
user?: ResourceUser;
|
|
80
103
|
}): Promise<Record<string, unknown> | null>;
|
|
81
104
|
create(params: {
|
|
82
105
|
name: string;
|
|
83
106
|
data: Record<string, unknown>;
|
|
84
107
|
user?: ResourceUser;
|
|
85
|
-
}): Promise<Record<string, unknown>>;
|
|
108
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
86
109
|
update(params: {
|
|
87
110
|
name: string;
|
|
88
111
|
id: string | number;
|
|
89
112
|
data: Record<string, unknown>;
|
|
90
113
|
user?: ResourceUser;
|
|
91
|
-
}): Promise<Record<string, unknown>>;
|
|
114
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
92
115
|
delete(params: {
|
|
93
116
|
name: string;
|
|
94
117
|
id: string | number;
|
|
95
118
|
user?: ResourceUser;
|
|
96
|
-
}): Promise<boolean>;
|
|
119
|
+
}, ctx?: AppContext): Promise<boolean>;
|
|
120
|
+
findRelation(params: {
|
|
121
|
+
name: string;
|
|
122
|
+
id: string | number;
|
|
123
|
+
relation: string;
|
|
124
|
+
query?: ResourceQuery;
|
|
125
|
+
user?: ResourceUser;
|
|
126
|
+
}): Promise<any>;
|
|
127
|
+
createRelation(params: {
|
|
128
|
+
name: string;
|
|
129
|
+
id: string | number;
|
|
130
|
+
relation: string;
|
|
131
|
+
data?: Record<string, unknown>;
|
|
132
|
+
user?: ResourceUser;
|
|
133
|
+
}, ctx?: AppContext): Promise<any>;
|
|
134
|
+
updateRelation(params: {
|
|
135
|
+
name: string;
|
|
136
|
+
id: string | number;
|
|
137
|
+
relation: string;
|
|
138
|
+
relationId: string;
|
|
139
|
+
data: Record<string, unknown>;
|
|
140
|
+
user?: ResourceUser;
|
|
141
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
142
|
+
deleteRelation(params: {
|
|
143
|
+
name: string;
|
|
144
|
+
id: string | number;
|
|
145
|
+
relation: string;
|
|
146
|
+
relationId: string;
|
|
147
|
+
user?: ResourceUser;
|
|
148
|
+
}, ctx?: AppContext): Promise<{
|
|
149
|
+
success: boolean;
|
|
150
|
+
}>;
|
|
97
151
|
}
|
|
98
152
|
//# sourceMappingURL=resource.types.d.ts.map
|
|
@@ -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":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MA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E,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACrD"}
|
|
@@ -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
|
+
const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(d,h){const Q=S,p=dictionaryIndexesCache['get'](h)??new Map(),Z=dictionaryRevisionsCache['get'](h)??new Map();dictionaryIndexesCache['set'](h,p),dictionaryRevisionsCache['set'](h,Z);const D=d[Q(0x1e6)](n=>Z['get'](n)!==h['revision'](n));if(D['length']===0x0)return p;const u=await Promise['all'](D['map'](async n=>{const F=Q;if(!h[F(0x1e7)](n))return[n,new Map()];const X=await h['get'](n),Y=new Map();for(const w of X){const y=w[F(0x1e8)]??w['id'];if(y==null)continue;Y['set'](String(y),{'id':y,'text':w[F(0x1e9)]??w[F(0x1ea)],...w[F(0x1eb)]!==undefined?{'color':w['color']}:{},...w['icon']!==undefined?{'icon':w['icon']}:{}});}return[n,Y];}));for(const [n,X]of u){p['set'](n,X),Z[Q(0x1ec)](n,h['revision'](n));}return p;}function S(d,h){d=d-0x1e6;const p=v();let Z=p[d];return Z;}function v(){const K=['filter','has','code','name','text','color','set','length','entries','map','get'];v=function(){return K;};return v();}export async function addDictionaryLookupData(d,h,p){const B=S;if(!p||d[B(0x1ed)]===0x0)return d;const Z=Object[B(0x1ee)](h)['flatMap'](([u,n])=>{const X=n['dictionary'];return X?[{'field':u,'dictionaryName':X}]:[];});if(Z['length']===0x0)return d;const D=await getDictionaryIndexes([...new Set(Z[B(0x1ef)](({dictionaryName:u})=>u))],p);for(const u of d){for(const {field:n,dictionaryName:X}of Z){const Y=u[n];u[n+'_data']=Y==null?null:D[B(0x1f0)](X)?.['get'](String(Y))??null;}}return d;}
|
|
@@ -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 S(d,h){d=d-0x169;const p=v();let Z=p[d];return Z;}export function addFileToken(d,h,p){const X=S;if(!p||d['length']===0x0)return d;const Z=Object[X(0x169)](h)[X(0x16a)](([,D])=>D['type']===X(0x16b))['map'](([D])=>D);for(const D of d){for(const u of Z){const n=D[u];typeof n==='string'&&n[X(0x16c)]>0x0&&(D[u]=p[X(0x16d)](n));}}return d;}function v(){const Y=['entries','filter','file','length','create'];v=function(){return Y;};return v();}
|
|
@@ -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;AAQnF,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 v(){const O=['entries','string','query','SELECT\x20','\x20AS\x20id,\x20','\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20','table','value'];v=function(){return O;};return v();}const tableLookupCache=new WeakMap();function S(d,h){d=d-0x19c;const p=v();let Z=p[d];return Z;}export function clearTableLookupCache(d,h){const p=tableLookupCache['get'](h);if(!p)return;for(const Z of p['keys']()){Z['startsWith'](d+':')&&p['delete'](Z);}}export async function addTableLookupData(d,h,p){const M=S;if(!p||d['length']===0x0)return d;const Z=tableLookupCache['get'](p)??new Map();tableLookupCache['set'](p,Z);const D=Object[M(0x19c)](h)['flatMap'](([u,n])=>{const {table:X,value:value='id',text:text='name'}=n['lookup']??{};return X?[{'field':u,'table':X,'value':value,'text':text}]:[];});for(const u of D){const n=new Map();for(const y of d){const Q=y[u['field']];(typeof Q===M(0x19d)||typeof Q==='number')&&n['set'](String(Q),Q);}const X=u['table']+':'+u['value']+':'+u['text'],Y=Z['get'](X)??new Map();Z['set'](X,Y);const w=[...n[M(0x19c)]()]['filter'](([F])=>!Y['has'](F))['map'](([,F])=>F);if(w['length']>0x0){const F=await p[M(0x19e)](M(0x19f)+qi(u['value'])+M(0x1a0)+qi(u['text'])+M(0x1a1)+qt(u[M(0x1a2)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(u[M(0x1a3)])+'\x20=\x20ANY($1)',[w]);for(const B of F['rows']){Y['set'](String(B['id']),B);}for(const K of w){!Y['has'](String(K))&&Y['set'](String(K),null);}}for(const g of d){const s=g[u['field']];g[u['field']+'_data']=s==null?null:Y['get'](String(s))??null;}}return d;}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the create relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type CreateRelationParams = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
relation: string;
|
|
11
|
+
data?: Record<string, unknown>;
|
|
12
|
+
user?: ResourceUser;
|
|
13
|
+
};
|
|
14
|
+
export declare function createCreateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, data, user, }: CreateRelationParams, ctx?: AppContext) => Promise<any>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=create-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yCAIgD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,GAAG,CAAC,CAqEhI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';import{createCreate}from'./create.js';function S(d,h){d=d-0xb4;const p=v();let Z=p[d];return Z;}function v(){const q=['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*','get','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','resource','length','No\x20writable\x20fields','map','INSERT\x20INTO\x20','rows','table'];v=function(){return q;};return v();}export function createCreateRelation(d,h){const p=createCreate(d,h);return async function Z({name:D,id:u,relation:n,data:X,user:Y},w){const c=S,y=w?.['pg']??d['pg'];if(n==='notes'){const g=await y['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[D,String(u),X?.['body']]);return g['rows'][0x0];}if(n==='files'){const s=await y['query'](c(0xb4),[D,String(u),X?.['filePath'],X?.['size']??null]);return s['rows'][0x0];}const Q=h[c(0xb5)](D),F=Q['relations']?.[n];if(!F?.['foreignKey']||!F['resource']&&!F['table'])throw new UnsupportedError(c(0xb6)+n+c(0xb7));let B,K;if(F['resource'])B=await p({'name':F['resource'],'data':X??{},'user':Y}),K=B[h['get'](F[c(0xb8)])['key']];else{const M=F['fields'];if(!M?.['length'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+n+'\x22\x20requires\x20a\x20project/provider\x20implementation');const O=Object['entries'](X??{})['filter'](([I])=>M['includes'](I));if(!O[c(0xb9)])throw new ValidationError(c(0xba));const R=O['map'](([I])=>qi(I)),E=O[c(0xbb)]((I,k)=>'$'+(k+0x1)),J=O['map'](([,I])=>I),U=await y['query'](c(0xbc)+qt(F['table'])+'\x20('+R['join'](',\x20')+')\x20VALUES\x20('+E['join'](',\x20')+')\x20RETURNING\x20*',J);B=U[c(0xbd)][0x0],K=B['id'];}return await y['query']('UPDATE\x20'+qt(Q[c(0xbe)])+'\x20SET\x20'+qi(F['foreignKey'])+'\x20=\x20$1\x20WHERE\x20'+qi(Q['key'])+'\x20=\x20$2',[K,u]),B;};}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
2
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
-
|
|
3
|
+
import { AppContext } from "../../../context.js";
|
|
4
|
+
type CreateParams = {
|
|
4
5
|
name: string;
|
|
5
6
|
data: Record<string, unknown>;
|
|
6
7
|
user?: ResourceUser;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function createCreate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, data, user, }: CreateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
10
|
+
export {};
|
|
8
11
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -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;AAKhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAE0B,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqCtH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function S(d,h){d=d-0x1ec;const p=v();let Z=p[d];return Z;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(d,h){return async function p({name:Z,data:D,user:u},n){const M=S,X=h['get'](Z);assertOperation(X,'create',u),validateInputData({'resource':X,'data':D});const Y=writableData(X,D);if(!Y[M(0x1ec)])throw new ValidationError('No\x20writable\x20fields');const w=Y['map'](([g])=>qi(g)),y=Y['map']((g,s)=>'$'+(s+0x1)),Q=Y['map'](([,g])=>g),F=n?.['pg']??d['pg'],B=await F['query']('INSERT\x20INTO\x20'+qt(X['table'])+'\x20('+w[M(0x1ed)](',\x20')+')\x20'+('VALUES\x20('+y['join'](',\x20')+')\x20')+(M(0x1ee)+readableFields(X)[M(0x1ed)](',\x20')),Q),K=B['rows'][0x0];return clearTableLookupCache(X[M(0x1ef)],F),await(n?.['audit']??d['audit'])?.[M(0x1f0)]({'userId':u?.['id'],'module':X[M(0x1f1)],'resource':X[M(0x1f2)],'resourceId':K[X['key']],'action':M(0x1f3),'fields':Object['keys'](D)}),K;};}function v(){const O=['length','join','RETURNING\x20','table','write','module','name','create'];v=function(){return O;};return v();}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the delete relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
import type { AppContext } from "../../../context.js";
|
|
7
|
+
type DeleteRelationParams = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
relation: string;
|
|
11
|
+
relationId: string | number;
|
|
12
|
+
user?: ResourceUser;
|
|
13
|
+
};
|
|
14
|
+
export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, user, }: DeleteRelationParams, ctx?: AppContext) => Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=delete-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,KAAK,oBAAoB,GAAG;IAC1B,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,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+CAEsD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAwBvJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function S(d,h){d=d-0x19c;const p=v();let Z=p[d];return Z;}import{UnsupportedError}from'../../../errors.js';function v(){const Q=['DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','files','DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','Generic\x20Resource\x20relation\x20\x22'];v=function(){return Q;};return v();}export function createDeleteRelation(d,h){return async function p({name:Z,id:D,relation:u,relationId:n,user:X},Y){const y=S,w=Y?.['pg']??d['pg'];if(u==='notes')return await w['query'](y(0x19c),[n,Z,String(D)]),{'success':!![]};if(u===y(0x19d))return await w['query'](y(0x19e),[n,Z,String(D)]),{'success':!![]};throw new UnsupportedError(y(0x19f)+u+'\x22\x20requires\x20a\x20project/provider\x20implementation');};}
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type RemoveParams = {
|
|
7
8
|
name: string;
|
|
8
9
|
id: string | number;
|
|
9
10
|
user?: ResourceUser;
|
|
10
|
-
}
|
|
11
|
+
};
|
|
12
|
+
export declare function createRemove(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: RemoveParams, ctx?: AppContext) => Promise<boolean>;
|
|
13
|
+
export {};
|
|
11
14
|
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -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;AAEhE,
|
|
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;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAEwB,YAAY,QAAQ,UAAU,sBAyBjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function S(d,h){d=d-0x9f;const p=v();let Z=p[d];return Z;}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(d,h){return async function p({name:Z,id:D,user:u},n){const y=S,X=h['get'](Z);assertOperation(X,y(0x9f),u);const Y=n?.['pg']??d['pg'],w=await Y['query']('DELETE\x20FROM\x20'+qt(X[y(0xa0)])+'\x20WHERE\x20'+qi(X['key'])+y(0xa1),[D]);if((w[y(0xa2)]??0x0)>0x0)clearTableLookupCache(X['table'],Y);if((w['rowCount']??0x0)>0x0)await(n?.['audit']??d[y(0xa3)])?.['write']({'module':X['module'],'resource':X['name'],'resourceId':D,'action':'delete'});return(w['rowCount']??0x0)>0x0;};}function v(){const Q=['delete','table','=$1','rowCount','audit'];v=function(){return Q;};return v();}
|
|
@@ -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
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(d,h){return async function p({name:Z,id:D,query:query={},user:u}){const R=S,n=Date['now'](),X=h['get'](Z);assertOperation(X,'read',u);if(!d['pg'])throw new Error('empty\x20pg');const Y=await d['pg']['query'](R(0x1cb)+readableFields(X)['join'](',\x20')+R(0x1cc)+qt(X[R(0x1cd)])+'\x20WHERE\x20'+qi(X['key'])+'=$1\x20LIMIT\x201',[D]),w=Y['rows'][0x0];if(!w)return null;await addDictionaryLookupData([w],X['fields'],d[R(0x1ce)]),await addTableLookupData([w],X['fields'],d['pg']),addFileToken([w],X[R(0x1cf)],d['file']);const y=Array['isArray'](query['include'])?query['include']:query['include']?.[R(0x1d0)](',')??[];for(const Q of y){const F=X[R(0x1d1)]?.[Q];if(!F?.['foreignKey']||!F['resource']&&!F[R(0x1cd)])throw new ValidationError('Unknown\x20relation:\x20'+Q);const B=F['resource']?h['get'](F['resource']):undefined,K=F['table']??B[R(0x1cd)],g=B?.['key']??'id',s=B?readableFields(B)['join'](',\x20'):'*',M='SELECT\x20'+s+R(0x1cc)+qt(K)+'\x20WHERE\x20'+qi(g)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(F[R(0x1d2)])+'\x20FROM\x20'+qt(X[R(0x1cd)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(X['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',O=(await d['pg']['query'](M,[D]))['rows'];B&&(await addDictionaryLookupData(O,B['fields'],d[R(0x1ce)]),await addTableLookupData(O,B['fields'],d['pg']),addFileToken(O,B[R(0x1cf)],d['file'])),w[Q]=O;}return w['time']=Date['now']()-n,w;};}function S(d,h){d=d-0x1cb;const p=v();let Z=p[d];return Z;}function v(){const E=['SELECT\x20','\x20FROM\x20','table','dictionary','fields','split','relations','foreignKey'];v=function(){return E;};return v();}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the find relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, query, }: {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string | number;
|
|
9
|
+
relation: string;
|
|
10
|
+
query?: ResourceQuery;
|
|
11
|
+
user?: ResourceUser;
|
|
12
|
+
}) => Promise<any>;
|
|
13
|
+
//# sourceMappingURL=find-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';function v(){const E=['max','SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','length','now','rows','file','get','resource','table','key','map','\x20WHERE\x20\x0a\x20\x20\x20\x20','\x20FROM\x20','\x20WHERE\x20','\x20=\x20$1\x20LIMIT\x201)\x20\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3','query','dictionary','fields'];v=function(){return E;};return v();}function S(d,h){d=d-0xe0;const p=v();let Z=p[d];return Z;}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindRelation(d,h){return async function p({name:Z,id:D,relation:u,query:query={}}){const R=S,n=Date['now'](),X=Math['min'](Math[R(0xe0)](query['limit']??0x14,0x1),0xc8),Y=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](X)||!Number['isFinite'](Y))throw new ValidationError('Invalid\x20pagination');if(u==='notes'){const M=await d['pg']['query'](R(0xe1),[Z,String(D)]);return{'total':M['rows'][R(0xe2)],'time':Date[R(0xe3)]()-n,'rows':M[R(0xe4)]};}if(u==='files'){const O=await d['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[Z,String(D)]);return addFileToken(O['rows'],{'file_path':{'type':R(0xe5)}},d['file']),{'total':O[R(0xe4)][R(0xe2)],'time':Date['now']()-n,'rows':O[R(0xe4)]};}const w=h[R(0xe6)](Z),y=w['relations']?.[u];if(!y?.['foreignKey']||!y['resource']&&!y['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+u+'\x22\x20requires\x20a\x20project/provider\x20implementation');const Q=y['resource']?h[R(0xe6)](y[R(0xe7)]):undefined,F=y[R(0xe8)]??Q['table'],B=Q?.[R(0xe9)]??'id',K=y['fields']?.[R(0xe2)]?y['fields'][R(0xea)](qi)['join'](',\x20'):'*',g='SELECT\x20'+K+'\x20FROM\x20'+qt(F)+R(0xeb)+qi(B)+'\x20=\x20(select\x20'+qi(y['foreignKey'])+R(0xec)+qt(w['table'])+R(0xed)+qi(w['key'])+R(0xee),s=await d['pg'][R(0xef)](g,[D,X,Y]);return Q&&(await addDictionaryLookupData(s['rows'],Q['fields'],d[R(0xf0)]),await addTableLookupData(s[R(0xe4)],Q[R(0xf1)],d['pg']),addFileToken(s[R(0xe4)],Q['fields'],d['file'])),{'limit':X,'offset':Y,'total':s[R(0xe4)]['length'],'time':Date['now']()-n,'rows':s['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"}
|