@opengis/fcore 0.0.1-beta.9 → 0.0.27
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 +1 -0
- 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 +0 -3
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.d.ts.map +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.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.d.ts +2 -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.js +1 -1
- package/dist/modules/file/route.js +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.js +1 -1
- 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.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +19 -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.js +1 -1
- package/dist/modules/resource/services/generate-resource-code.d.ts +16 -0
- package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
- package/dist/modules/resource/services/generate-resource-code.js +1 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
- package/dist/modules/resource/services/get-resource-schema.js +1 -0
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
- package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-as-user.js +1 -0
- package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
- package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-list.js +1 -0
- 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.js +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.js +1 -1
- 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.d.ts +25 -2
- 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.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +1 -0
- 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.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-resource-access.d.ts +23 -0
- package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-access.js +1 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-scopes.js +1 -0
- package/dist/modules/system/services/get-system-log.js +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 +3 -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/set-resource-access.d.ts +18 -0
- package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-access.js +1 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-scopes.js +1 -0
- package/dist/modules/system/services/update-dictionary.js +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/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +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.js +1 -1
- package/dist/plugins/file.d.ts +7 -3
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/jwt.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- 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.d.ts.map +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.d.ts +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.d.ts +3 -2
- package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +66 -14
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
- package/dist/plugins/resource/services/add-file-token.js +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.d.ts +5 -2
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- 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 +6 -3
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.d.ts +9 -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.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- 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/get-table-columns.d.ts +8 -0
- package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
- package/dist/plugins/resource/services/get-table-columns.js +1 -0
- package/dist/plugins/resource/services/update-relation.d.ts +5 -2
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.d.ts +9 -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.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +2 -1
- 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/scope.d.ts +10 -0
- package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
- package/dist/plugins/resource/utils/scope.js +1 -0
- package/dist/plugins/resource/utils/sort.d.ts +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.d.ts +1 -1
- package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.d.ts +7 -0
- package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
- package/dist/plugins/resource/utils/summary.js +1 -0
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260903120000_core_schema.sql +5 -2
- package/migrations/20260903130001_add_file_fields.sql +5 -0
- package/migrations/20260910170000_core_schema.sql +22 -0
- package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
- package/migrations/20260929_role_scope.sql +32 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const b=C;import{getAccess}from'./get-access.js';function m(){const x=['update','create','delete','edit','BEGIN','DELETE\x20FROM\x20admin.user_roles\x20WHERE\x20user_uid\x20=\x20$1','query','permissions','user','actions','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','COMMIT','release'];m=function(){return x;};return m();}const CRUD_ACTIONS=['read',b(0x192),b(0x193),b(0x194)];function C(P,G){P=P-0x192;const j=m();let Z=j[P];return Z;}function permissionsToAccess(P){const E=b,G=new Map();for(const j of P){const [Z,q]=j['split'](':');if(!Z)continue;const p=q===E(0x195)?E(0x192):q,X=G['get'](Z)??new Set();for(const F of p?[p]:CRUD_ACTIONS)X['add'](F);G['set'](Z,X);}return[...G]['map'](([A,H])=>({'resource':A,'actions':[...H]}));}export async function setAccess(P,G){const z=b,j=await G['pg']['connect']();try{await j['query'](z(0x196));if(P['type']==='user'){await j['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[P['id']]);if(P['roles']!==undefined){await j['query'](z(0x197),[P['id']]);for(const q of P['roles']){await j[z(0x198)]('INSERT\x20INTO\x20admin.user_roles\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(user_uid,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)',[P['id'],q,P['user']['id'],P['user']['id']]);}}}else await j[z(0x198)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[P['id']]);const Z=P['permissions']?permissionsToAccess(P[z(0x199)]):P['access']??[];for(const p of Z){P['type']===z(0x19a)?await j['query']('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[p['resource'],p[z(0x19b)],P['id'],P['user']['id'],P['user']['id']]):await j['query'](z(0x19c),[p['resource'],p['actions'],P['id'],P['user']['id'],P['user']['id']]);}await j['query'](z(0x19d));}catch(X){await j['query']('ROLLBACK');throw X;}finally{j[z(0x19e)]();}return getAccess(P,G);}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
import { getResourceAccess } from "./get-resource-access.js";
|
|
3
|
+
interface UserAccessInput {
|
|
4
|
+
uid: string;
|
|
5
|
+
actions: string[];
|
|
6
|
+
}
|
|
7
|
+
interface RoleAccessInput {
|
|
8
|
+
role_id: string;
|
|
9
|
+
actions: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function setResourceAccess(params: {
|
|
12
|
+
resource: string;
|
|
13
|
+
users?: UserAccessInput[];
|
|
14
|
+
roles?: RoleAccessInput[];
|
|
15
|
+
user: User;
|
|
16
|
+
}, ctx: AppContext): ReturnType<typeof getResourceAccess>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=set-resource-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-resource-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-resource-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,UAAU,eAAe;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAsEtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function C(P,G){P=P-0x11c;const j=m();let Z=j[P];return Z;}function m(){const E=['add','has','role_id','connect','query','users','length','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)','resource','roles','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)','release'];m=function(){return E;};return m();}import{ValidationError}from'../../../errors.js';import{getResourceAccess}from'./get-resource-access.js';export async function setResourceAccess(P,G){const b=C;if(P['users']===undefined&&P['roles']===undefined)throw new ValidationError('At\x20least\x20one\x20of\x20users\x20or\x20roles\x20must\x20be\x20provided');const j=new Set();for(const p of P['users']??[]){if(j['has'](p['uid']))throw new ValidationError('Duplicate\x20user\x20in\x20access\x20list:\x20'+p['uid']);j[b(0x11c)](p['uid']);}const Z=new Set();for(const X of P['roles']??[]){if(Z[b(0x11d)](X[b(0x11e)]))throw new ValidationError('Duplicate\x20role\x20in\x20access\x20list:\x20'+X['role_id']);Z[b(0x11c)](X['role_id']);}const q=await G['pg'][b(0x11f)]();try{await q['query']('BEGIN');if(P['users']!==undefined){await q[b(0x120)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL',[P['resource']]);for(const F of P[b(0x121)]){if(F['actions'][b(0x122)]===0x0)continue;await q['query'](b(0x123),[P[b(0x124)],F['actions'],F['uid'],P['user']['id']]);}}if(P[b(0x125)]!==undefined){await q['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20role_id\x20IS\x20NOT\x20NULL\x20AND\x20user_uid\x20IS\x20NULL',[P['resource']]);for(const A of P[b(0x125)]){if(A['actions'][b(0x122)]===0x0)continue;await q[b(0x120)](b(0x126),[P['resource'],A['actions'],A[b(0x11e)],P['user']['id']]);}}await q['query']('COMMIT');}catch(H){await q['query']('ROLLBACK');throw H;}finally{q[b(0x127)]();}return getResourceAccess({'resource':P['resource']},G);}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
import { getResourceScopes } from "./get-resource-scopes.js";
|
|
3
|
+
export declare function setResourceScopes(params: {
|
|
4
|
+
resource: string;
|
|
5
|
+
user_id?: string;
|
|
6
|
+
role_id?: string;
|
|
7
|
+
scopes: Record<string, unknown>;
|
|
8
|
+
user: User;
|
|
9
|
+
}, ctx: AppContext): ReturnType<typeof getResourceScopes>;
|
|
10
|
+
//# sourceMappingURL=set-resource-scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-resource-scopes.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-resource-scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,UAAU,CAAC,OAAO,iBAAiB,CAAC,CA6CtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function m(){const F=['At\x20least\x20one\x20scope\x20must\x20be\x20provided','query','resource','role_id','entries','scopes','user_id','release'];m=function(){return F;};return m();}function C(P,G){P=P-0xd1;const j=m();let Z=j[P];return Z;}import{ValidationError}from'../../../errors.js';import{clearResourceScopeCache}from'../../../plugins/resource/utils/scope.js';import{getResourceScopes}from'./get-resource-scopes.js';export async function setResourceScopes(P,G){const X=C;if(Boolean(P['user_id'])===Boolean(P['role_id']))throw new ValidationError('Provide\x20exactly\x20one\x20of\x20user_id\x20or\x20role_id');if(Object['keys'](P['scopes'])['length']===0x0)throw new ValidationError(X(0xd1));const j=await G['pg']['connect']();try{await j[X(0xd2)]('BEGIN'),await j[X(0xd2)]('DELETE\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20role_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$2\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20user_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$3',[P[X(0xd3)],P[X(0xd4)]??null,P['user_id']??null]);for(const [Z,q]of Object[X(0xd5)](P[X(0xd6)])){await j[X(0xd2)]('INSERT\x20INTO\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20role_id,\x20user_id,\x20scope,\x20value,\x20enabled,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5::jsonb,\x20TRUE,\x20$6,\x20$6)',[P[X(0xd3)],P['role_id']??null,P[X(0xd7)]??null,Z,JSON['stringify'](q),P['user']['id']]);}await j['query']('COMMIT');}catch(p){await j['query']('ROLLBACK');throw p;}finally{j[X(0xd8)]();}return clearResourceScopeCache(),getResourceScopes({'resource':P['resource']},G);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function updateDictionary(
|
|
1
|
+
export async function updateDictionary(P,G){return await G['dictionary']['put'](P['name'],P['items']),{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(P,G){P=P-0x1d4;const j=m();let Z=j[P];return Z;}import{ValidationError}from'../../../errors.js';function m(){const p=['keys','entries','patch','Invalid\x20setting\x20key:\x20','stringify','user'];m=function(){return p;};return m();}export async function updateSystemSettings(P,G){const q=C;if(!Object[q(0x1d4)](P['patch'])['length'])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [j,Z]of Object[q(0x1d5)](P[q(0x1d6)])){if(!j['trim']()||j['includes']('..'))throw new ValidationError(q(0x1d7)+j);await G['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[j,JSON[q(0x1d8)](Z),P[q(0x1d9)]['id']]);}return{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError}from'../../errors.js';function
|
|
1
|
+
function m(){var Z=['User\x20required','Admin\x20access\x20required','includes'];m=function(){return Z;};return m();}import{ForbiddenError}from'../../errors.js';function C(P,G){P=P-0x1a6;var j=m();var Z=j[P];return Z;}export function requireAdmin(P,G){var j=C;if(!P)throw new ForbiddenError(j(0x1a6));if(P['type']!=='admin')throw new ForbiddenError(j(0x1a7));if(P['type']!=='admin'&&G&&!P['permissions']?.[j(0x1a8)](G))throw new ForbiddenError('Missing\x20permission:\x20'+G);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){const p=['entries','filter'];m=function(){return p;};return m();}function C(P,G){P=P-0x96;const j=m();let Z=j[P];return Z;}export const safeUser=P=>{const q=C,G=['password','salt','secret','credentials'];return Object['fromEntries'](Object[q(0x96)](P)[q(0x97)](([j])=>!G['some'](Z=>j['toLowerCase']()['includes'](Z))));};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../errors.js';export function unsupported(
|
|
1
|
+
import{UnsupportedError}from'../../errors.js';export function unsupported(P){throw new UnsupportedError(P+'\x20requires\x20a\x20project/provider\x20implementation');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeAudit}from'./services/write-audit.js';export function createAudit(
|
|
1
|
+
import{writeAudit}from'./services/write-audit.js';export function createAudit(P){const G=writeAudit(P);return{'write':G};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/audit/audit.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,WAAW,UAAU;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC1C,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"audit.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/audit/audit.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,WAAW,UAAU;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AACD,MAAM,WAAW,WAAW;IACxB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const secretPattern=/password|token|secret|credential|salt/i;function clean(P){const H=C;if(Array['isArray'](P))return P['map'](clean);if(P&&typeof P===H(0xc2))return Object[H(0xc3)](Object['entries'](P)['map'](([G,j])=>[G,secretPattern[H(0xc4)](G)?H(0xc5):clean(j)]));return P;}export function writeAudit(P){let G,j;async function Z(){const b=C;if(!P['pg'])return![];if(G!==undefined)return G;return j??=P['pg'][b(0xc6)]('\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\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20')['then'](q=>{const E=b,p=new Set(q['rows']['map'](X=>X[E(0xc7)]));return G=p[E(0xc8)]('audit_log')&&p['has']('audit_log_data'),!G&&P['logger']['warn']({'expectedTables':[E(0xc9),'admin.audit_log_data'],'foundTables':[...p]},'Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled'),G;})['catch'](q=>{const z=b;return G=![],P['logger'][z(0xca)]({'err':q},z(0xcb)),![];}),j;}return async function q(p){const x=C;if(!await Z())return P[x(0xcc)]['info']({'auditFallback':!![],'event':clean({...p,'changes':p[x(0xcd)]?.['map'](A=>({...A,'oldValue':clean(A['oldValue']),'newValue':clean(A['newValue'])}))})},'audit'),0x0;if(!P['pg'])throw new Error('empty\x20pg');const X=await P['pg'][x(0xc6)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5,\x20$6,\x20$7,\x20$8,\x20$9)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20',[p[x(0xce)]??null,p['module'],p['resource'],p['resourceId']==null?null:String(p[x(0xcf)]),p[x(0xd0)]??null,p[x(0xd1)],p['requestId']??null,p['ipAddress']??null,clean(p['metadata']??{})]),F=X['rows'][0x0]['id'];for(const A of p['changes']??[]){if(secretPattern[x(0xc4)](A['field']))continue;await P['pg'][x(0xc6)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log_data\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20audit_log_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20field,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20old_value,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20new_value\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\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',[F,A['field'],JSON['stringify'](clean(A['oldValue'])),JSON['stringify'](clean(A['newValue']))]);}return F;};}function C(P,G){P=P-0xc2;const j=m();let Z=j[P];return Z;}function m(){const o=['object','fromEntries','test','[REDACTED]','query','table_name','has','admin.audit_log','warn','Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled','logger','changes','userId','resourceId','fields','action'];m=function(){return o;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getUserPermissions(
|
|
1
|
+
export async function getUserPermissions(P,G){const q=C,j=await G['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20DISTINCT\x20ra.resource\x20||\x20\x27:\x27\x20||\x20action\x20AS\x20permission\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x20ON\x20ur.role_id\x20=\x20ra.role_id\x0a\x20\x20\x20\x20\x20\x20CROSS\x20JOIN\x20LATERAL\x20unnest(COALESCE(ra.actions,\x20\x27{}\x27::text[]))\x20AS\x20action\x0a\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20',[P]);return j[q(0x1a7)]['map'](Z=>Z['permission']);}function C(P,G){P=P-0x1a7;const j=m();let Z=j[P];return Z;}function m(){const p=['rows'];m=function(){return p;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAYhC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAwD5D,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAE1C,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKpE;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAalB;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,mBAAmB,iBAmDzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from'./auth.types.js';import{randomBytes,scrypt as
|
|
1
|
+
export*from'./auth.types.js';import{randomBytes,scrypt as P,timingSafeEqual}from'node:crypto';function m(){const L=['path','.json','fileFor','parse','code','utf8','catch','hex','test','cookieName','storagePath','register','secret','initialize','permissions'];m=function(){return L;};return m();}import{mkdir,readFile,unlink,writeFile}from'node:fs/promises';import{join,resolve}from'node:path';import{promisify}from'node:util';const scrypt=promisify(P);import G from'@fastify/cookie';import j from'@fastify/session';import{Authenticator}from'@fastify/passport';import Z from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();class FileSessionStore{['path'];constructor(q){const z=C;this['path']=q,void mkdir(this[z(0x146)],{'recursive':!![]});}['fileFor'](q){const x=C;return join(this['path'],q+x(0x147));}async['get'](q,p){const o=C;try{const X=await readFile(this[o(0x148)](q),'utf8');p(null,JSON[o(0x149)](X));}catch(F){const A=F;if(A[o(0x14a)]==='ENOENT'){p(null,undefined);return;}p(A,undefined);}}async['set'](q,p,X){const i=C;try{await mkdir(this[i(0x146)],{'recursive':!![]}),await writeFile(this['fileFor'](q),JSON['stringify'](p),i(0x14b)),X();}catch(F){X(F);}}async['destroy'](q,p){const y=C;try{await unlink(this[y(0x148)](q))[y(0x14c)](X=>{if(X['code']!=='ENOENT')throw X;}),p();}catch(X){p(X);}}}function C(P,G){P=P-0x146;const j=m();let Z=j[P];return Z;}export*from'./verifyUser.js';export*from'./get-user-permissions.js';export async function hashPassword(q){const T=C,p=randomBytes(0x10),X=await scrypt(q,p,0x40);return'scrypt$'+p['toString']('hex')+'$'+X['toString'](T(0x14d));}export async function verifyPassword(q,p){const [X,F,A]=p?.['split']('$')||[];if(X!=='scrypt'||!F||!A)return![];const H=Buffer['from'](F,'hex'),b=Buffer['from'](A,'hex'),E=await scrypt(q,H,b['length']);return timingSafeEqual(E,b);}export async function createSessionStore(q,p){const D=C,{config:X,redis:F}=p;if(!X){console['warn']('Missing\x20config\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV===D(0x14e)||process.env.VITEST)return;await q['register'](G,{'parseOptions':X['auth']['cookieOptions']});const A=X['redis']['host']?new Z({'prefix':X['auth'][D(0x14f)]+':'+(X['pg']?.['database']||'db')+':','client':F}):new FileSessionStore(resolve(X[D(0x150)]??'./storage','sessions'));await q[D(0x151)](j,{'secret':X['auth'][D(0x152)],'cookieName':X['auth']['cookieName'],'cookie':X['auth']['cookieOptions'],'store':A}),await q[D(0x151)](fastifyPassport[D(0x153)]()),await q[D(0x151)](fastifyPassport['secureSession']()),fastifyPassport['registerUserSerializer'](async H=>({'user':H})),fastifyPassport['registerUserDeserializer'](async H=>{const h=D,b=H?.['user']||H;return b?.['id']&&(b[h(0x154)]=await getUserPermissions(b['id'],p)),b;});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{BadRequestError}from'../../errors.js';function C(P,G){P=P-0x144;const j=m();let Z=j[P];return Z;}import{verifyPassword}from'./index.js';export async function verifyUser({user:P,password:G,ip:j},{pg:Z,logger:q}){const b=C;if(!P||P==='')throw new BadRequestError('not\x20enough\x20params:\x20user');if(!G||G==='')throw new BadRequestError('not\x20enough\x20params:\x20password');q[b(0x144)](b(0x145));const p='select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password_hash,\x20twofa,\x20first_name,\x20middle_name,last_name,email,phone,avatar,last_activity_date\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201',X=await Z['query'](p,[P])['then'](A=>A['rows']?.[0x0]);if(!X){const A='user\x20not\x20found';q['info']({'file':'auth/warn','error':A,'user':P,'ip':j});throw new BadRequestError(A);}const F=await verifyPassword(G,X['password_hash']);if(!F){const H=b(0x146);q['info']({'file':b(0x147),'error':H,'user':P,'ip':j});throw new BadRequestError(H);}return Z['query']('update\x20admin.users\x20set\x20last_activity_date\x20=\x20now()\x20where\x20uid\x20=\x20$1',[X['id']]),delete X['password_hash'],X;}function m(){const E=['metrics','user.login','Wrong\x20password','auth/warn'];m=function(){return E;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function C(P,G){P=P-0x1ee;const j=m();let Z=j[P];return Z;}import{ConflictError,NotFoundError,ValidationError}from'../errors.js';const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;function m(){const Q=['empty\x20pg','dictionaries','Invalid\x20dictionary\x20name:\x20','Invalid\x20dictionary\x20items:\x20','query','rows','set','items','Dictionary\x20items\x20must\x20be\x20an\x20array','Dictionary\x20table\x20not\x20found','\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','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','code','parentId','COMMIT','ROLLBACK','static','get','\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','push'];m=function(){return Q;};return m();}export function createDictionary({pg:P,dictionaries:dictionaries=[]}){const G=new Map(),j=new Map();let Z,q;async function p(){const N=C;if(Z!==undefined)return Z;if(!P)throw new Error(N(0x1ee));return q??=P['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 a=N,i=o['rows'][0x0]?.['table_name'];Z=i===a(0x1ef)?i:null;}),await q,Z;}function X(o){const n=C;if(!dictionaryName['test'](o))throw new ValidationError(n(0x1f0)+o);}function F(o){const f=C;for(const i of Array['isArray'](o)?o:[o]){X(i['code']);if(!Array['isArray'](i['items']))throw new ValidationError(f(0x1f1)+i['code']);if(G['has'](i['code']))throw new ConflictError('Dictionary\x20already\x20registered:\x20'+i['code']);G['set'](i['code'],{...i,'source':'static'});}}function A(o){return G['has'](o);}async function H(o){const I=C;X(o);const i=G['get'](o);if(i&&i['checked'])return i['items'];const y=await p();if(!y)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const T=await P?.[I(0x1f2)]('\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',[o]);if(T?.['rows']?.['length']){const D=T?.[I(0x1f3)];return G[I(0x1f4)](o,{'code':o,'name':o,'items':D,'source':'database','checked':!![]}),D;}if(!i?.[I(0x1f5)])throw new NotFoundError('Dictionary\x20not\x20found:\x20'+o);return i['checked']=!![],i['items'];}async function b(o,i){const k=C;X(o);if(!Array['isArray'](i))throw new ValidationError(k(0x1f6));const y=await p();if(!y)throw new NotFoundError(k(0x1f7));if(!P)throw new Error('empty\x20pg');const T=await P['connect']();try{await T['query']('BEGIN');const D=await T['query'](k(0x1f8),[o,o,k(0x1f9),k(0x1fa),!![]]),h=D[k(0x1f3)][0x0]['id'];await T['query'](k(0x1fb),[h]);for(const L of i){await T[k(0x1f2)](k(0x1fc),[h,L[k(0x1fd)],L['name'],L[k(0x1fe)]??null]);}await T[k(0x1f2)](k(0x1ff));}catch(O){await T['query'](k(0x200));throw O;}finally{T['release']();}G[k(0x1f4)](o,{'items':i,'code':o,'source':k(0x201),'checked':!![]}),j[k(0x1f4)](o,(j['get'](o)??0x0)+0x1);}function E(o){return X(o),j['set'](o,(j['get'](o)??0x0)+0x1),G['delete'](o);}function z(o){const M=C;return j[M(0x202)](o)??0x0;}async function x(){const l=C,o=[...G['values']()]['map'](({code:T,name:D,source:h})=>({'code':T,'name':D??T,'source':h})),i=await p();if(!i)return o;if(!P)throw new Error('empty\x20pg');const y=await P['query'](l(0x203));for(const T of y['rows']){!G['has'](T[l(0x1fd)])&&o[l(0x204)](T);}return o;}return F(dictionaries),{'register':F,'get':H,'put':b,'clear':E,'revision':z,'list':x,'has':A};}
|
package/dist/plugins/file.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements the S3-compatible file storage adapter and its contracts.
|
|
3
|
-
*/
|
|
4
1
|
import type { Readable } from "node:stream";
|
|
5
2
|
export interface FileAdapter {
|
|
6
3
|
put(path: string, body: Buffer | Readable): Promise<void>;
|
|
@@ -23,5 +20,12 @@ export interface FileS3Config {
|
|
|
23
20
|
tokenSecret?: string;
|
|
24
21
|
tokenTtl?: number;
|
|
25
22
|
}
|
|
23
|
+
export interface FileLocalConfig {
|
|
24
|
+
storagePath: string;
|
|
25
|
+
folder?: string;
|
|
26
|
+
tokenSecret?: string;
|
|
27
|
+
tokenTtl?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function createFileLocal(config: FileLocalConfig): FileAdapter;
|
|
26
30
|
export declare function createFileS3(config: FileS3Config): FileAdapter;
|
|
27
31
|
//# sourceMappingURL=file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAKA,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;AAED,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAoCD,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAiFpE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAiF9D"}
|
package/dist/plugins/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(P,G){P=P-0xf5;const j=m();let Z=j[P];return Z;}import P from'node:fs/promises';import G from'node:path';import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';import j from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function normalizeRelativePath(Z){const y=C;if(!Z||Z[y(0xf5)]('/')||Z['includes']('..'))throw new ValidationError('Invalid\x20file\x20path');return Z['replace'](/\\/g,'/')[y(0xf6)](/^\/+/,'');}function keyFor(Z,q){const T=C;return''+((Z??'')['replace'](/^\/+|\/+$/g,'')?(Z??'')[T(0xf6)](/^\/+|\/+$/g,'')+'/':'')+normalizeRelativePath(q);}async function bodyToBuffer(Z){const D=C;if(!Z)return Buffer[D(0xf7)](0x0);const q=Z;if(typeof q['transformToByteArray']===D(0xf8))return Buffer['from'](await q['transformToByteArray']());const p=[];for await(const X of Z){p['push'](Buffer['from'](X));}return Buffer['concat'](p);}function m(){const R=['startsWith','replace','alloc','function','storagePath','randomBytes','toString','files','join','resolve','mkdir','writeFile','rename','ENOENT','split','sha256','update','from','timingSafeEqual','base64url','region','send','bucket','name','tokenTtl','digest','Invalid\x20file\x20token','createHmac','length','utf8'];m=function(){return R;};return m();}export function createFileLocal(Z){const h=C,q=G['resolve'](Z[h(0xf9)]||'./storage'),p=G['join'](q,'removed'),X=Z['tokenSecret']??process.env.FILE_TOKEN_SECRET??j[h(0xfa)](0x20)[h(0xfb)]('hex'),F=b=>{const L=h,E=normalizeRelativePath(b),z=(Z['folder']??L(0xfc))[L(0xf6)](/^\/+|\/+$/g,'');return z?G[L(0xfd)](z,E):E;},A=b=>{const E=F(b),z=G['resolve'](q,E),x=G['relative'](q,z);if(x['startsWith']('..')||G['isAbsolute'](x))throw new ValidationError('Invalid\x20file\x20path');return z;},H=b=>{const O=h,E=F(b),z=G[O(0xfe)](p,E),x=G['relative'](p,z);if(x['startsWith']('..')||G['isAbsolute'](x))throw new ValidationError('Invalid\x20file\x20path');return z;};return{async 'put'(b,E){const N=h,z=A(b);await P[N(0xff)](G['dirname'](z),{'recursive':!![]}),await P[N(0x100)](z,E instanceof Buffer?E:await bodyToBuffer(E));},async 'get'(b){return P['readFile'](A(b));},async 'exists'(b){try{return await P['access'](A(b)),!![];}catch{return![];}},async 'delete'(b){const a=h,E=A(b),z=H(b);try{await P['mkdir'](G['dirname'](z),{'recursive':!![]}),await P[a(0x101)](E,z);}catch(x){const o=x;if(o['code']!==a(0x102))throw x;}},'create'(b,E=Z['tokenTtl']??0xe10){const z=Buffer['from'](b)['toString']('base64url'),x=j['createHmac']('sha256',X)['update'](z)['digest']('base64url');return z+'.'+x;},'verify'(b){const n=h,[E,z]=b[n(0x103)]('.');if(!E||!z)throw new UnauthorizedError('Invalid\x20file\x20token');const x=j['createHmac'](n(0x104),X)[n(0x105)](E)['digest'](),o=Buffer[n(0x106)](z,'base64url');if(x['length']!==o['length']||!j[n(0x107)](x,o))throw new UnauthorizedError('Invalid\x20file\x20token');const i=Buffer['from'](E,n(0x108))['toString']('utf8');return i;}};}export function createFileS3(Z){const f=C,q=Z['tokenSecret']??process.env.FILE_TOKEN_SECRET??j['randomBytes'](0x20)[f(0xfb)]('hex'),p=new S3Client({'endpoint':Z['endpoint'],'region':Z[f(0x109)]??'us-east-1','forcePathStyle':Z['forcePathStyle']??!![],'credentials':Z['accessKeyId']||Z['accessKey']?{'accessKeyId':Z['accessKeyId']??Z['accessKey'],'secretAccessKey':Z['secretAccessKey']??Z['secretKey']}:undefined}),X=F=>keyFor(Z['folder'],F);return{async 'put'(F,A){const I=f;await p[I(0x10a)](new PutObjectCommand({'Bucket':Z[I(0x10b)],'Key':X(F),'Body':A}));},async 'get'(F){const A=await p['send'](new GetObjectCommand({'Bucket':Z['bucket'],'Key':X(F)}));return bodyToBuffer(A['Body']);},async 'exists'(F){const k=f;try{return await p['send'](new HeadObjectCommand({'Bucket':Z['bucket'],'Key':X(F)})),!![];}catch(A){const H=A;if(H['$metadata']?.['httpStatusCode']===0x194||H[k(0x10c)]==='NotFound')return![];throw A;}},async 'delete'(F){const M=f;await p[M(0x10a)](new DeleteObjectCommand({'Bucket':Z[M(0x10b)],'Key':X(F)}));},'create'(F,A=Z[f(0x10d)]??0xe10){const l=f,H=Buffer['from'](F)['toString'](l(0x108)),b=j['createHmac']('sha256',q)[l(0x105)](H)[l(0x10e)]('base64url');return H+'.'+b;},'verify'(F){const Q=f,[A,H]=F['split']('.');if(!A||!H)throw new UnauthorizedError(Q(0x10f));const b=j[Q(0x110)]('sha256',q)['update'](A)['digest'](),E=Buffer['from'](H,Q(0x108));if(b[Q(0x111)]!==E[Q(0x111)]||!j[Q(0x107)](b,E))throw new UnauthorizedError('Invalid\x20file\x20token');const z=Buffer['from'](A,'base64url')['toString'](Q(0x112));return z;}};}
|
package/dist/plugins/jwt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const p=C;import{SignJWT,jwtVerify}from'jose';const secret=new TextEncoder()[p(0x1f4)](process.env.AUTH_JWT_SECRET);function m(){const H=['encode','HS256','message'];m=function(){return H;};return m();}export async function jwtSignToken(P){const X=p;if(!process.env.AUTH_JWT_SECRET)return;const {id:G,type:j,permissions:Z}=P,q=await new SignJWT({'id':G,'type':j,'permissions':Z})['setProtectedHeader']({'alg':X(0x1f5)})['setIssuedAt']()['setExpirationTime']('1h')['sign'](secret);return q;}function C(P,G){P=P-0x1f4;const j=m();let Z=j[P];return Z;}export async function jwtVerifyToken(P){const F=p,G=await jwtVerify(P,secret,{'algorithms':[F(0x1f5)]})['catch'](j=>{const A=F;console['log'](j[A(0x1f6)]);});return G?.['payload'];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){const A=['./transport.js','info','token','[REDACTED]'];m=function(){return A;};return m();}import P from'pino';function C(P,G){P=P-0x1d2;const j=m();let Z=j[P];return Z;}export function createLogger(){const F=C,G=P['transport']({'target':F(0x1d2)}),j=P({'level':F(0x1d3),'timestamp':P['stdTimeFunctions']['isoTime'],'base':{'service':'app'},'redact':{'paths':['req.headers.authorization','password',F(0x1d4),'accessToken','refreshToken'],'censor':F(0x1d5)}},G),Z={};function q(p,X){if(p===undefined)return{...Z};Z[p]=(Z[p]??0x0)+(X??0x1);}return Object['assign'](j,{'close':async()=>G['end'](),'metrics':q,'file':()=>j['info']['bind'](j)});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const F=C;import P from'node:fs';function m(){const E=['warn','error','toISOString','createWriteStream','get'];m=function(){return E;};return m();}import G from'node:path';import j from'pino-abstract-transport';const LEVELS={0x1e:'info',0x28:F(0x162),0x32:F(0x163),0x3c:'error'},streams=new Map();function getDate(){const A=F;return new Date()[A(0x164)]()['slice'](0x0,0xa);}function createStream(Z,q){const H=F,p=G['resolve']('logs',Z);return P['mkdirSync'](p,{'recursive':!![]}),P[H(0x165)](G['join'](p,q+'.log'),{'flags':'a'});}function getStream(Z){const b=F,q=getDate(),p=streams[b(0x166)](Z);if(p&&p['date']===q)return p['stream'];p?.['stream']['end']();const X=createStream(Z,q);return streams['set'](Z,{'date':q,'stream':X}),X;}function closeStreams(){for(const {stream:Z}of streams['values']()){Z['end']();}streams['clear']();}export default async function loggerTransport(){return j(writeLogs,{'close':async()=>{closeStreams();}});}function C(P,G){P=P-0x162;const j=m();let Z=j[P];return Z;}async function writeLogs(Z){for await(const q of Z){const p=LEVELS[q['level']];if(!p)continue;const X=getStream(q['file']||p);delete q['file'],X['write'](JSON['stringify'](q)+'\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,CAC1B,MAAM,EAAE,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
|
-
import
|
|
1
|
+
import P from'pg';function m(){const i=['bind','captureStackTrace','catch','callerStack','query','COMMIT'];m=function(){return i;};return m();}const {Pool}=P;function C(P,G){P=P-0x18a;const j=m();let Z=j[P];return Z;}export function createDatabase(G){const E=C,j=new Pool(G),Z=j['query'][E(0x18a)](j);function q(p,X){const z=E,F=new Error();return Error[z(0x18b)]?.(F,q),Z(p,X)[z(0x18c)](A=>{const x=z,H=A;H['sql']=p,H[x(0x18d)]=F['stack'];throw H;});}return j[E(0x18e)]=q,j['transaction']=async function(p){const o=E,X=new Error();Error['captureStackTrace']?.(X,j['transaction']);const F=await j['connect']();try{await F[o(0x18e)]('BEGIN');const A=await p(F);return await F['query'](o(0x18f)),A;}catch(H){await F[o(0x18e)]('ROLLBACK');const b=H;b['callerStack']=X['stack'];throw b;}finally{F['release']();}},j;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/plugins/redis.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/plugins/redis.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW;IAI3C,GAAG,QAAQ,MAAM;IACjB,GAAG,QACI,MAAM,SACJ,MAAM,WACJ,MAAM,GAAG,MAAM,QAClB,MAAM;IAWd,GAAG,QAAQ,MAAM;IACjB,MAAM,QAAQ,MAAM;IACpB,KAAK;IACL,IAAI;IACJ,OAAO,QAAQ,MAAM,SAAS,MAAM,OAAO,MAAM;IAEjD,MAAM,QAAQ,MAAM,OAAO,MAAM;EAEpC;AACD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){const F=['log','Creating\x20Redis\x20client\x20with\x20config:','del','quit','hincrby'];m=function(){return F;};return m();}function C(P,G){P=P-0xc4;const j=m();let Z=j[P];return Z;}import{Redis}from'ioredis';export function createRedis(P){const X=C;console[X(0xc4)](X(0xc5),P);const G=new Redis(P);return{'get':j=>G['get'](j),'set':(j,Z,q,p)=>{if(p)return G['set'](j,Z,'EX',p);if(typeof q==='number')return G['set'](j,Z,'EX',q);return G['set'](j,Z);},'del':j=>G[X(0xc6)](j),'delete':j=>G['del'](j),'close':()=>G[X(0xc7)](),'ping':()=>G['ping'](),'hincrby':(j,Z,q)=>G[X(0xc8)](j,Z,q),'incrby':(j,Z)=>G['incrby'](j,Z)};}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ResourceDependencies, ResourcePlugin } from
|
|
1
|
+
import type { ResourceDependencies, ResourcePlugin } from "./resource.types.js";
|
|
2
2
|
export declare function createResource(deps: ResourceDependencies): ResourcePlugin;
|
|
3
3
|
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -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;AAUhF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,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,CA4BzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ResourceRegistry}from'./resource.registry.js';
|
|
1
|
+
import{ResourceRegistry}from'./resource.registry.js';function C(P,G){P=P-0x1a3;const j=m();let Z=j[P];return Z;}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';import{createCreateRelation}from'./services/create-relation.js';function m(){const z=['bind'];m=function(){return z;};return m();}import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(P){const E=C,G=new ResourceRegistry(),j=createFind(P,G),Z=createFindOne(P,G),q=createCreate(P,G),p=createUpdate(P,G),X=createRemove(P,G),F=createFindRelation(P,G),A=createCreateRelation(P,G),H=createUpdateRelation(P,G),b=createDeleteRelation(P,G);return{'register':G['register']['bind'](G),'unregister':G['unregister']['bind'](G),'has':G['has']['bind'](G),'get':G['get']['bind'](G),'list':G['list'][E(0x1a3)](G),'find':j,'findOne':Z,'create':q,'update':p,'delete':X,'findRelation':F,'createRelation':A,'updateRelation':H,'deleteRelation':b};}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ResourceContract } from
|
|
1
|
+
import type { ResourceContract } from "./resource.types.js";
|
|
2
2
|
export declare class ResourceRegistry {
|
|
3
3
|
private readonly resources;
|
|
4
|
-
|
|
4
|
+
unregister(name: string): void;
|
|
5
|
+
register(input: ResourceContract | ResourceContract[], overwrite?: boolean): void;
|
|
5
6
|
has(name: string): boolean;
|
|
6
7
|
get(name: string): ResourceContract;
|
|
7
8
|
list(): ResourceContract[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"resource.registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuC;IACjE,UAAU,CAAC,IAAI,EAAE,MAAM,QAEtB;IACD,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,EAAE,SAAS,UAAQ,QAUvE;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,WAEf;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,oBAIf;IAED,IAAI,uBAEH;IAED,OAAO,CAAC,QAAQ;CAajB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function C(P,G){P=P-0x10f;const j=m();let Z=j[P];return Z;}function validQualified(P){const Z=C;return P[Z(0x10f)]('.')['length']<=0x2&&P['split']('.')['every'](G=>ident['test'](G));}export class ResourceRegistry{['resources']=new Map();['unregister'](P){const q=C;this[q(0x110)]['delete'](P);}['register'](P,G=![]){const p=C;for(const j of Array['isArray'](P)?P:[P]){this[p(0x111)](j);if(this['resources'][p(0x112)](j['name'])&&!G)throw new ConflictError('Resource\x20already\x20registered:\x20'+j[p(0x113)]);this['resources'][p(0x114)](j[p(0x113)],j);}}['has'](P){return this['resources']['has'](P);}['get'](P){const G=this['resources']['get'](P);if(!G)throw new NotFoundError('Resource\x20not\x20registered:\x20'+P);return G;}['list'](){return[...this['resources']['values']()];}['validate'](P){const X=C;if(P['version']!==0x1||!ident[X(0x115)](P[X(0x113)])||!validQualified(P['table'])||!ident['test'](P[X(0x116)]))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+P[X(0x113)]);for(const [G,j]of Object[X(0x117)](P[X(0x118)])){if(!ident['test'](G)||!ident['test'](j['column']??G))throw new ValidationError(X(0x119)+G);}}}function m(){const F=['split','resources','validate','has','name','set','test','key','entries','fields','Invalid\x20resource\x20field:\x20'];m=function(){return F;};return m();}
|