@opengis/fcore 0.0.1-beta.4 → 0.0.1-beta.6
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/LICENSE +3 -3
- package/README.md +71 -71
- 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.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +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 +7 -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.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/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.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.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.js +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +7 -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.js +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts +3 -0
- 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.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.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.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.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.js +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +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 +23 -0
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/create-relation.d.ts +13 -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.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +15 -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.js +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +12 -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.js +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/dist/type.d.ts +14 -0
- package/dist/type.d.ts.map +1 -1
- package/migrations/20260903120000_core_schema.sql +22 -19
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/package.json +10 -5
- 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/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import r from'pg';const {Pool}=r;export function createDatabase(u){return new Pool(u);}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function T(r,u){r=r-0x138;const G=H();let o=G[r];return o;}import{Redis}from'ioredis';function H(){const p=['get','number','del'];H=function(){return p;};return H();}export function createRedis(r){const a=T,u=new Redis(r);return{'get':G=>u[a(0x138)](G),'set':(G,o,X,w)=>{const q=a;if(w)return u['set'](G,o,'EX',w);if(typeof X===q(0x139))return u['set'](G,o,'EX',X);return u['set'](G,o);},'del':G=>u[a(0x13a)](G),'delete':G=>u['del'](G),'close':()=>u['quit'](),'ping':()=>u['ping'](),'hincrby':(G,o,X)=>u['hincrby'](G,o,X),'incrby':(G,o)=>u['incrby'](G,o)};}
|
|
@@ -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;AAShF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CAyBzE"}
|
|
@@ -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';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';function H(){const Y=['register','has','bind'];H=function(){return Y;};return H();}import{createCreateRelation}from'./services/create-relation.js';function T(r,u){r=r-0x91;const G=H();let o=G[r];return o;}import{createDeleteRelation}from'./services/delete-relation.js';export function createResource(r){const E=T,u=new ResourceRegistry(),G=createFind(r,u),o=createFindOne(r,u),X=createCreate(r,u),w=createUpdate(r,u),a=createRemove(r,u),q=createFindRelation(r,u),p=createCreateRelation(r,u),F=createDeleteRelation(r,u);return{'register':u[E(0x91)]['bind'](u),'has':u[E(0x92)][E(0x93)](u),'get':u['get'][E(0x93)](u),'list':u['list'][E(0x93)](u),'find':G,'findOne':o,'create':X,'update':w,'delete':a,'findRelation':q,'createRelation':p,'deleteRelation':F};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function H(){const p=['length','validate','name','resources','has','get','Resource\x20not\x20registered:\x20','test','Invalid\x20resource\x20contract:\x20','fields','Invalid\x20resource\x20field:\x20'];H=function(){return p;};return H();}function T(r,u){r=r-0x1ca;const G=H();let o=G[r];return o;}import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(r){const o=T;return r['split']('.')[o(0x1ca)]<=0x2&&r['split']('.')['every'](u=>ident['test'](u));}export class ResourceRegistry{['resources']=new Map();['register'](r){const X=T;for(const u of Array['isArray'](r)?r:[r]){this[X(0x1cb)](u);if(this['resources']['has'](u['name']))throw new ConflictError('Resource\x20already\x20registered:\x20'+u[X(0x1cc)]);this[X(0x1cd)]['set'](u['name'],u);}}['has'](r){const w=T;return this['resources'][w(0x1ce)](r);}['get'](r){const a=T,u=this[a(0x1cd)][a(0x1cf)](r);if(!u)throw new NotFoundError(a(0x1d0)+r);return u;}['list'](){return[...this['resources']['values']()];}['validate'](r){const q=T;if(r['version']!==0x1||!ident[q(0x1d1)](r['name'])||!validQualified(r['table'])||!ident['test'](r['key']))throw new ValidationError(q(0x1d2)+r[q(0x1cc)]);for(const [u,G]of Object['entries'](r[q(0x1d3)])){if(!ident['test'](u)||!ident[q(0x1d1)](G['column']??u))throw new ValidationError(q(0x1d4)+u);}}}
|
|
@@ -40,6 +40,7 @@ export interface ResourceRelationContract {
|
|
|
40
40
|
sourceField?: string;
|
|
41
41
|
foreignKey?: string;
|
|
42
42
|
targetField?: string;
|
|
43
|
+
fields?: string[];
|
|
43
44
|
}
|
|
44
45
|
export interface ResourceContract {
|
|
45
46
|
version: 1;
|
|
@@ -108,5 +109,27 @@ export interface ResourcePlugin {
|
|
|
108
109
|
id: string | number;
|
|
109
110
|
user?: ResourceUser;
|
|
110
111
|
}): Promise<boolean>;
|
|
112
|
+
findRelation(params: {
|
|
113
|
+
name: string;
|
|
114
|
+
id: string | number;
|
|
115
|
+
relation: string;
|
|
116
|
+
user?: ResourceUser;
|
|
117
|
+
}): Promise<any>;
|
|
118
|
+
createRelation(params: {
|
|
119
|
+
name: string;
|
|
120
|
+
id: string | number;
|
|
121
|
+
relation: string;
|
|
122
|
+
data?: Record<string, unknown>;
|
|
123
|
+
user?: ResourceUser;
|
|
124
|
+
}): Promise<any>;
|
|
125
|
+
deleteRelation(params: {
|
|
126
|
+
name: string;
|
|
127
|
+
id: string | number;
|
|
128
|
+
relation: string;
|
|
129
|
+
relationId: string;
|
|
130
|
+
user?: ResourceUser;
|
|
131
|
+
}): Promise<{
|
|
132
|
+
success: boolean;
|
|
133
|
+
}>;
|
|
111
134
|
}
|
|
112
135
|
//# 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;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxE,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EACD,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,MAAM,GACN,MAAM,GACN,MAAM,GACN,WAAW,GACX,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,C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G,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,MAAM,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAErB,YAAY,CAAC,MAAM,EAAE;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACjB,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,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,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACjB,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,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
export declare function createCreateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, data, user, }: {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string | number;
|
|
9
|
+
relation: string;
|
|
10
|
+
data?: Record<string, unknown>;
|
|
11
|
+
user?: ResourceUser;
|
|
12
|
+
}) => Promise<any>;
|
|
13
|
+
//# 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;AAKhE,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yCAUvB;IACD,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,KAAG,OAAO,CAAC,GAAG,CAAC,CAuEjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function T(r,u){r=r-0x1f2;const G=H();let o=G[r];return o;}import{createCreate}from'./create.js';export function createCreateRelation(r,u){const G=createCreate(r,u);return async function o({name:X,id:w,relation:a,data:q,user:p}){const L=T;if(!r['pg'])throw new Error('empty\x20pg');if(a==='notes'){const I=await r['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[X,String(w),q?.['body']]);return I['rows'][0x0];}if(a===L(0x1f2)){const c=await r['pg']['query']('INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*',[X,String(w),q?.[L(0x1f3)],q?.[L(0x1f4)]??null]);return c[L(0x1f5)][0x0];}const F=u[L(0x1f6)](X),E=F['relations']?.[a];if(!E?.[L(0x1f7)]||!E['resource']&&!E['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+a+'\x22\x20requires\x20a\x20project/provider\x20implementation');let Y,S;if(E[L(0x1f8)])Y=await G({'name':E['resource'],'data':q??{},'user':p}),S=Y[u['get'](E['resource'])['key']];else{const h=E[L(0x1f9)];if(!h?.[L(0x1fa)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+a+L(0x1fb));const P=Object['entries'](q??{})[L(0x1fc)](([j])=>h['includes'](j));if(!P['length'])throw new ValidationError(L(0x1fd));const l=P['map'](([j])=>qi(j)),Q=P['map']((j,B)=>'$'+(B+0x1)),J=P[L(0x1fe)](([,j])=>j),O=await r['pg']['query']('INSERT\x20INTO\x20'+qt(E['table'])+'\x20('+l['join'](',\x20')+L(0x1ff)+Q['join'](',\x20')+')\x20RETURNING\x20*',J);Y=O['rows'][0x0],S=Y['id'];}return await r['pg']['query']('UPDATE\x20'+qt(F['table'])+L(0x200)+qi(E[L(0x1f7)])+'\x20=\x20$1\x20WHERE\x20'+qi(F['key'])+L(0x201),[S,w]),Y;};}function H(){const b=['files','filePath','size','rows','get','foreignKey','resource','fields','length','\x22\x20requires\x20a\x20project/provider\x20implementation','filter','No\x20writable\x20fields','map',')\x20VALUES\x20(','\x20SET\x20','\x20=\x20$2'];H=function(){return b;};return H();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function H(){const P=['map','query','INSERT\x20INTO\x20','VALUES\x20(','audit','keys'];H=function(){return P;};return H();}import{qi,qt,readableFields,writableData}from'../utils/sql.js';function T(r,u){r=r-0x1e0;const G=H();let o=G[r];return o;}import{validateInputData}from'../utils/fields.js';export function createCreate(r,u){return async function G({name:o,data:X,user:w}){const h=T,a=u['get'](o);assertOperation(a,'create',w),validateInputData({'resource':a,'data':X});const q=writableData(a,X);if(!q['length'])throw new ValidationError('No\x20writable\x20fields');const p=q[h(0x1e0)](([I])=>qi(I)),F=q[h(0x1e0)]((I,c)=>'$'+(c+0x1)),E=q['map'](([,I])=>I);if(!r['pg'])throw new Error('empty\x20pg');const Y=await r['pg'][h(0x1e1)](h(0x1e2)+qt(a['table'])+'\x20('+p['join'](',\x20')+')\x20'+(h(0x1e3)+F['join'](',\x20')+')\x20')+('RETURNING\x20'+readableFields(a)['join'](',\x20')),E),S=Y['rows'][0x0];return await r[h(0x1e4)]?.['write']({'userId':w?.['id'],'module':a['module'],'resource':a['name'],'resourceId':S[a['key']],'action':'create','fields':Object[h(0x1e5)](X)}),S;};}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, }: {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string | number;
|
|
9
|
+
relation: string;
|
|
10
|
+
relationId: string;
|
|
11
|
+
user?: ResourceUser;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
//# 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;AAGhE,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAyBlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function T(r,u){r=r-0x9c;var G=H();var o=G[r];return o;}import{UnsupportedError}from'../../../errors.js';function H(){var p=['empty\x20pg','query','DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3'];H=function(){return p;};return H();}export function createDeleteRelation(r,u){return async function G({name:o,id:X,relation:w,relationId:a}){var q=T;if(!r['pg'])throw new Error(q(0x9c));if(w==='notes')return await r['pg'][q(0x9d)](q(0x9e),[a,o,String(X)]),{'success':!![]};if(w==='files')return await r['pg']['query'](q(0x9f),[a,o,String(X)]),{'success':!![]};throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+w+'\x22\x20requires\x20a\x20project/provider\x20implementation');};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function T(r,u){r=r-0xf1;const G=H();let o=G[r];return o;}function H(){const F=['get','DELETE\x20FROM\x20','table','key','rowCount'];H=function(){return F;};return H();}import{qt,qi}from'../utils/sql.js';export function createRemove(r,u){return async function G({name:o,id:X,user:w}){const p=T,a=u[p(0xf1)](o);assertOperation(a,'delete',w);if(!r['pg'])throw new Error('empty\x20pg');const q=await r['pg']['query'](p(0xf2)+qt(a[p(0xf3)])+'\x20WHERE\x20'+qi(a[p(0xf4)])+'=$1',[X]);if((q[p(0xf5)]??0x0)>0x0)await r['audit']?.['write']({'module':a['module'],'resource':a['name'],'resourceId':X,'action':'delete'});return(q['rowCount']??0x0)>0x0;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function T(r,u){r=r-0xaf;const G=H();let o=G[r];return o;}function H(){const F=['get','key','=$1\x20LIMIT\x201'];H=function(){return F;};return H();}import{qt,qi,readableFields}from'../utils/sql.js';export function createFindOne(r,u){return async function G({name:o,id:X,user:w}){const p=T,a=u[p(0xaf)](o);assertOperation(a,'read',w);if(!r['pg'])throw new Error('empty\x20pg');const q=await r['pg']['query']('SELECT\x20'+readableFields(a)['join'](',\x20')+'\x20FROM\x20'+qt(a['table'])+'\x20WHERE\x20'+qi(a[p(0xb0)])+p(0xb1),[X]);return q['rows'][0x0]??null;};}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the find 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
|
+
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, }: {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string | number;
|
|
9
|
+
relation: string;
|
|
10
|
+
user?: ResourceUser;
|
|
11
|
+
}) => Promise<any>;
|
|
12
|
+
//# 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,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,6BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAqDjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function T(r,u){r=r-0x16a;const G=H();let o=G[r];return o;}function H(){const Q=['notes','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','get','\x20FROM\x20','resource','table','key','SELECT\x20'];H=function(){return Q;};return H();}export function createFindRelation(r,u){return async function G({name:o,id:X,relation:w}){const l=T;if(!r['pg'])throw new Error('empty\x20pg');if(w===l(0x16a)){const h=await r['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[o,String(X)]);return h['rows'];}if(w==='files'){const P=await r['pg']['query'](l(0x16b),[o,String(X)]);return P['rows'];}const a=u[l(0x16c)](o),q=a['relations']?.[w];if(!q?.['foreignKey']||!q['resource']&&!q['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+w+'\x22\x20requires\x20a\x20project/provider\x20implementation');const p=await r['pg']['query']('SELECT\x20'+qi(q['foreignKey'])+l(0x16d)+qt(a['table'])+'\x20WHERE\x20'+qi(a['key'])+'\x20=\x20$1\x20LIMIT\x201',[X]),F=p['rows'][0x0]?.[q['foreignKey']];if(F==null)return null;const E=q[l(0x16e)]?u[l(0x16c)](q[l(0x16e)]):undefined,Y=q['table']??E[l(0x16f)],S=E?.[l(0x170)]??'id',I=q['fields']?.['length']?q['fields']['map'](qi)['join'](',\x20'):'*',c=await r['pg']['query'](l(0x171)+I+'\x20FROM\x20'+qt(Y)+'\x20WHERE\x20'+qi(S)+'\x20=\x20$1\x20LIMIT\x201',[F]);return{'rows':c['rows']??null};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function H(){const c=['get','max','limit','sort','isFinite','LIMIT\x20$','values','empty\x20pg','rows'];H=function(){return c;};return H();}import{ValidationError}from'../../../errors.js';function T(r,u){r=r-0xbd;const G=H();let o=G[r];return o;}import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';export function createFind(r,u){return async function G({name:o,query:query={},user:X}){const I=T,w=Date['now'](),a=u[I(0xbd)](o);assertOperation(a,'read',X);const q=Math['min'](Math[I(0xbe)](query[I(0xbf)]??0x14,0x1),0xc8),p=Math['max'](query['offset']??0x0,0x0),F=buildFilters(a,query['filter']),E=buildSort(a,query[I(0xc0)]);if(!Number[I(0xc1)](q)||!Number['isFinite'](p))throw new ValidationError('Invalid\x20pagination');const Y='SELECT\x20'+readableFields(a)['join'](',\x20')+'\x20'+('FROM\x20'+qt(a['table']))+(''+F['sql']+E+'\x20')+(I(0xc2)+(F['values']['length']+0x1)+'\x20')+('OFFSET\x20$'+(F[I(0xc3)]['length']+0x2));if(!r['pg'])throw new Error(I(0xc4));const S=await r['pg']['query'](Y,[...F['values'],q,p]);return{'limit':q,'offset':p,'total':S['rowCount'],'time':Date['now']()-w,'rows':S[I(0xc5)]};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';function T(r,u){r=r-0x9e;const G=H();let o=G[r];return o;}import{validateInputData}from'../utils/fields.js';export function createUpdate(r,u){return async function G({name:o,id:X,data:w,user:a}){const h=T,q=u['get'](o);assertOperation(q,h(0x9e),a);const p=writableData(q,w);if(!p['length'])throw new ValidationError(h(0x9f));if(!r['pg'])throw new Error('empty\x20pg');validateInputData({'resource':q,'data':w,'update':!![]});const F=p['map'](([I],c)=>qi(I)+h(0xa0)+(c+0x1)),E=[...p[h(0xa1)](([,I])=>I),X],Y=await r['pg'][h(0xa2)]('UPDATE\x20'+qt(q['table'])+'\x20'+(h(0xa3)+F[h(0xa4)](',\x20')+'\x20')+('WHERE\x20'+qi(q[h(0xa5)])+h(0xa0)+(p['length']+0x1)+'\x20')+('RETURNING\x20'+readableFields(q)['join'](',\x20')),E),S=Y[h(0xa6)][0x0];if(!S)throw new NotFoundError(o+':'+X);return await r['audit']?.['write']({'userId':a?.['id'],'module':q[h(0xa7)],'resource':q[h(0xa8)],'resourceId':X,'action':'update','fields':Object[h(0xa9)](w)}),S;};}function H(){const P=['update','No\x20writable\x20fields','\x20=\x20$','map','query','SET\x20','join','key','rows','module','name','keys'];H=function(){return P;};return H();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function H(){const w=['string','maxLength','minimum','\x20should\x20be\x20>=\x20','number','maximum','enum'];H=function(){return w;};return H();}function T(r,u){r=r-0xfd;const G=H();let o=G[r];return o;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:r,data:u,update:update=![]})=>{const X=T;for(const [G,o]of Object['entries'](r['fields'])){if(o['required']&&o['writable']!==![]&&(u[G]===undefined||u[G]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+G);if(o['required']&&o['writable']!==![]&&Object['hasOwn'](u,G)&&(u[G]===undefined||u[G]===null)&&update)throw new ValidationError('Required\x20field:\x20'+G);if(o['minLength']&&typeof u[G]===X(0xfd)&&u[G]['length']<o['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+G);if(o[X(0xfe)]&&typeof u[G]==='string'&&u[G]['length']>o['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+G);if(o[X(0xff)]&&typeof u[G]==='number'&&u[G]<o[X(0xff)])throw new ValidationError(G+X(0x100)+o['minimum']);if(o['maximum']&&typeof u[G]===X(0x101)&&u[G]>o[X(0x102)])throw new ValidationError(G+'\x20should\x20be\x20<=\x20'+o['maximum']);if(o['enum']&&u[G]&&!o[X(0x103)]['includes'](u[G]))throw new ValidationError(G+'\x20should\x20be\x20one\x20of\x20('+o['enum']['join'](',\x20')+')');if(o['pattern']&&typeof u[G]===X(0xfd)&&!new RegExp(o['pattern'])['test'](u[G]))throw new ValidationError(G+'\x20should\x20match\x20regular\x20expression\x20('+o['pattern']+')');}};export{validateInputData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';function T(r,u){r=r-0x1cf;const G=H();let o=G[r];return o;}import{ValidationError}from'../../../errors.js';function H(){const F=['length'];H=function(){return F;};return H();}export function buildFilters(r,u,G=0x1){const p=T,o=[],X=[];for(const [w,a]of Object['entries'](u??{})){const q=r['fields'][w];if(!q||q['filter']!==!![]&&q['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+w);X['push'](a),o['push'](qi(fieldColumn(r,w))+'\x20=\x20$'+(G+X[p(0x1cf)]-0x1));}return{'sql':o[p(0x1cf)]?'\x20WHERE\x20'+o['join']('\x20AND\x20'):'','values':X};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ForbiddenError}from'../../../errors.js';function T(r,u){r=r-0x160;const G=H();let o=G[r];return o;}function H(){const a=['Authentication\x20required','type'];H=function(){return a;};return H();}import{getContext}from'../../../index.js';export function assertOperation(r,u,G){const w=T,o=getContext()['config'];if(o['debug'])return;if(!r['operations']['includes'](u))throw new ForbiddenError(r['name']+'.'+u+'\x20is\x20disabled');if(r['access']!=='public'&&G===undefined)throw new ForbiddenError(w(0x160));if(r['access']==='admin'&&G?.[w(0x161)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(G?.['type']!=='admin'){const X=(r['permission']??r['name'])+':'+u;if(!G?.['permissions']?.['includes'](X))throw new ForbiddenError('Missing\x20permission:\x20'+X);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';function H(){const F=['Field\x20is\x20not\x20sortable:\x20','\x20ORDER\x20BY\x20'];H=function(){return F;};return H();}function T(r,u){r=r-0xa5;const G=H();let o=G[r];return o;}import{ValidationError}from'../../../errors.js';export function buildSort(r,u){const p=T;if(!u?.['length'])return'';const G=u['map'](o=>{const q=T,X=o['startsWith']('-'),w=X?o['slice'](0x1):o,a=r['fields'][w];if(!a||a['sort']!==!![]&&a['sortable']!==!![])throw new ValidationError(q(0xa5)+w);return qi(fieldColumn(r,w))+'\x20'+(X?'DESC':'ASC');});return p(0xa6)+G['join'](',\x20');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a=T;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=r=>'\x22'+r['replace'](/"/g,'\x22\x22')+'\x22';export const quoteTable=r=>r['split']('.')['map'](quoteIdentifier)[a(0x14f)]('.');export function fieldColumn(r,u){const q=a;if(u===r['key'])return r['key'];const G=r['fields'][u];if(!G)throw new ValidationError(q(0x150)+u);return G['column']??u;}export function readableFields(r){const p=a,u=Object['entries'](r['fields'])[p(0x151)](([,G])=>G['read']!==![]&&G['readable']!==![])['map'](([G,o])=>quoteIdentifier(o['column']??G)+'\x20AS\x20'+quoteIdentifier(G));return!r['fields'][r['key']]&&u[p(0x152)](quoteIdentifier(r[p(0x153)])),u;}function T(r,u){r=r-0x14f;const G=H();let o=G[r];return o;}export function writableData(r,u){const F=a,G=[];for(const [o,X]of Object['entries'](u)){const w=r[F(0x154)][o];if(!w||w[F(0x155)]===![]||w['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+o);G[F(0x156)]([w[F(0x157)]??o,X]);}return G;}export const qi=quoteIdentifier;function H(){const E=['join','Unknown\x20field:\x20','filter','unshift','key','fields','write','push','column'];H=function(){return E;};return H();}export const qt=quoteTable;
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function T(r,u){r=r-0x1f3;const G=H();let o=G[r];return o;}const u=T,getIP=r=>(r['headers']?.['x-real-ip']||r['headers']?.['x-forwarded-for']||r['ip']||r['connection']?.[u(0x1f3)]||'')[u(0x1f4)](':')['pop']();function H(){const G=['remoteAddress','split'];H=function(){return G;};return H();}export default getIP;
|
package/dist/type.d.ts
CHANGED
|
@@ -19,5 +19,19 @@ type AccessMetadata = {
|
|
|
19
19
|
};
|
|
20
20
|
/** Повна схема Fastify і метадані маршруту API. */
|
|
21
21
|
export type ApiRouteSchema = FastifySchema & AccessMetadata;
|
|
22
|
+
/** Короткий опис зареєстрованого HTTP API-маршруту. */
|
|
23
|
+
export interface ApiRouteShort {
|
|
24
|
+
method: string;
|
|
25
|
+
endpoint: string;
|
|
26
|
+
package: string;
|
|
27
|
+
}
|
|
28
|
+
/** Розширений опис маршруту з OpenAPI та access metadata. */
|
|
29
|
+
export interface ApiRoute extends ApiRouteShort {
|
|
30
|
+
tags: string[];
|
|
31
|
+
summary: string;
|
|
32
|
+
description: string;
|
|
33
|
+
access: RouteAccess;
|
|
34
|
+
permissions: RoutePermission[];
|
|
35
|
+
}
|
|
22
36
|
export {};
|
|
23
37
|
//# sourceMappingURL=type.d.ts.map
|
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AACA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nD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,cAAc,CAAC;AAE5D,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6DAA6D;AAC7D,MAAM,WAAW,QAAS,SAAQ,aAAa;IAC7C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC"}
|
|
@@ -6,29 +6,29 @@ AS $$
|
|
|
6
6
|
SELECT encode(gen_random_bytes(6), 'hex')::text
|
|
7
7
|
$$;
|
|
8
8
|
|
|
9
|
+
DROP SCHEMA IF EXISTS admin CASCADE;
|
|
9
10
|
CREATE SCHEMA IF NOT EXISTS admin;
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
CREATE TABLE IF NOT EXISTS admin.users (
|
|
13
14
|
uid text PRIMARY KEY DEFAULT next_id(),
|
|
14
15
|
login text,
|
|
15
|
-
|
|
16
|
+
password_hash text,
|
|
16
17
|
first_name text,
|
|
17
18
|
middle_name text,
|
|
18
19
|
last_name text,
|
|
19
20
|
email text,
|
|
20
21
|
phone text,
|
|
21
22
|
avatar text,
|
|
23
|
+
twofa boolean NOT NULL DEFAULT false,
|
|
22
24
|
enabled boolean DEFAULT true,
|
|
23
25
|
user_personal_code text,
|
|
24
26
|
last_activity_date timestamptz,
|
|
25
|
-
user_type text NOT NULL DEFAULT 'regular',
|
|
26
|
-
salt text,
|
|
27
|
+
user_type text NOT NULL DEFAULT 'regular',
|
|
27
28
|
created_by text,
|
|
28
29
|
updated_by text,
|
|
29
30
|
created_at timestamp NOT NULL DEFAULT now(),
|
|
30
|
-
updated_at timestamp NOT NULL DEFAULT now(),
|
|
31
|
-
twofa boolean NOT NULL DEFAULT false,
|
|
31
|
+
updated_at timestamp NOT NULL DEFAULT now(),
|
|
32
32
|
UNIQUE (user_personal_code)
|
|
33
33
|
);
|
|
34
34
|
|
|
@@ -107,18 +107,19 @@ CREATE TABLE IF NOT EXISTS admin.user_roles (
|
|
|
107
107
|
|
|
108
108
|
CREATE TABLE IF NOT EXISTS admin.role_access (
|
|
109
109
|
access_id text PRIMARY KEY DEFAULT next_id(),
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
role_id text REFERENCES admin.roles(role_id),
|
|
112
|
-
user_uid text,
|
|
112
|
+
user_uid text REFERENCES admin.users(uid),
|
|
113
113
|
scope text,
|
|
114
114
|
actions text[],
|
|
115
|
-
|
|
115
|
+
resource text,
|
|
116
116
|
|
|
117
|
-
created_by text,
|
|
118
|
-
updated_by text,
|
|
117
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
118
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
119
119
|
created_at timestamp NOT NULL DEFAULT now(),
|
|
120
120
|
updated_at timestamp NOT NULL DEFAULT now(),
|
|
121
|
-
UNIQUE (
|
|
121
|
+
UNIQUE (resource, user_uid),
|
|
122
|
+
UNIQUE (resource, role_id)
|
|
122
123
|
);
|
|
123
124
|
|
|
124
125
|
|
|
@@ -131,8 +132,8 @@ CREATE TABLE IF NOT EXISTS admin.dictionaries (
|
|
|
131
132
|
source text NOT NULL DEFAULT 'git' CHECK (source IN ('git', 'custom')),
|
|
132
133
|
editable boolean NOT NULL DEFAULT false,
|
|
133
134
|
system boolean NOT NULL DEFAULT false,
|
|
134
|
-
created_by text,
|
|
135
|
-
updated_by text,
|
|
135
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
136
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
136
137
|
created_at timestamp NOT NULL DEFAULT now(),
|
|
137
138
|
updated_at timestamp NOT NULL DEFAULT now()
|
|
138
139
|
);
|
|
@@ -150,6 +151,8 @@ CREATE TABLE IF NOT EXISTS admin.dictionary_items (
|
|
|
150
151
|
active boolean NOT NULL DEFAULT true,
|
|
151
152
|
system boolean NOT NULL DEFAULT false,
|
|
152
153
|
metadata jsonb,
|
|
154
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
155
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
153
156
|
created_at timestamp NOT NULL DEFAULT now(),
|
|
154
157
|
updated_at timestamp NOT NULL DEFAULT now(),
|
|
155
158
|
UNIQUE (dictionary_id, code)
|
|
@@ -161,9 +164,9 @@ CREATE TABLE IF NOT EXISTS admin.notes (
|
|
|
161
164
|
resource text NOT NULL,
|
|
162
165
|
resource_id text NOT NULL,
|
|
163
166
|
body text NOT NULL,
|
|
164
|
-
created_by text,
|
|
167
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
165
168
|
created_at timestamptz DEFAULT now(),
|
|
166
|
-
updated_by text,
|
|
169
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
167
170
|
updated_at timestamptz DEFAULT now()
|
|
168
171
|
);
|
|
169
172
|
|
|
@@ -184,9 +187,9 @@ CREATE TABLE IF NOT EXISTS admin.files (
|
|
|
184
187
|
file_path text,
|
|
185
188
|
verified boolean DEFAULT false,
|
|
186
189
|
resized boolean,
|
|
187
|
-
created_by text,
|
|
190
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
188
191
|
created_at timestamptz DEFAULT now(),
|
|
189
|
-
updated_by text,
|
|
192
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
190
193
|
updated_at timestamptz default now()
|
|
191
194
|
);
|
|
192
195
|
|
|
@@ -199,9 +202,9 @@ CREATE TABLE IF NOT EXISTS admin.settings (
|
|
|
199
202
|
key text NOT NULL,
|
|
200
203
|
value jsonb,
|
|
201
204
|
|
|
202
|
-
updated_by text,
|
|
205
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
203
206
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
204
|
-
created_by text,
|
|
207
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
205
208
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
206
209
|
);
|
|
207
210
|
|