@opengis/fcore 0.0.1-beta.1 → 0.0.1-beta.11
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 +5 -5
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.d.ts +3 -0
- package/dist/modules/auth/adduser-cli.d.ts.map +1 -0
- package/dist/modules/auth/adduser-cli.js +2 -0
- package/dist/modules/auth/passwd-cli.d.ts +3 -0
- package/dist/modules/auth/passwd-cli.d.ts.map +1 -0
- package/dist/modules/auth/passwd-cli.js +2 -0
- package/dist/modules/auth/permission-cli.d.ts +3 -0
- package/dist/modules/auth/permission-cli.d.ts.map +1 -0
- package/dist/modules/auth/permission-cli.js +2 -0
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.d.ts +10 -1
- package/dist/modules/auth/schema.d.ts.map +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.d.ts +9 -0
- package/dist/modules/auth/services/change-password.d.ts.map +1 -0
- package/dist/modules/auth/services/change-password.js +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.d.ts +14 -0
- package/dist/modules/auth/services/registration.d.ts.map +1 -0
- package/dist/modules/auth/services/registration.js +1 -0
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.d.ts +3 -0
- package/dist/modules/file/mime.d.ts.map +1 -0
- package/dist/modules/file/mime.js +1 -0
- package/dist/modules/file/route.d.ts.map +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.d.ts +3 -0
- package/dist/modules/file/schema.d.ts.map +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.d.ts.map +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.d.ts +4 -6
- package/dist/modules/file/services/upload-file.d.ts.map +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts +0 -3
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +3 -0
- package/dist/modules/resource/schema.d.ts.map +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.d.ts +8 -2
- package/dist/modules/resource/services/create-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.d.ts +8 -1
- package/dist/modules/resource/services/delete-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +9 -2
- package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts +10 -4
- package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
- package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
- package/dist/modules/resource/services/update-resource-relation.js +1 -0
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.d.ts +2 -1
- package/dist/modules/system/route.d.ts.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +22 -1
- package/dist/modules/system/schema.d.ts.map +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.d.ts.map +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +14 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-access.js +1 -0
- package/dist/modules/system/services/get-api-list.d.ts +4 -1
- package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-system-log.d.ts +9 -5
- package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts +16 -0
- package/dist/modules/system/services/set-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-access.js +1 -0
- package/dist/modules/system/services/update-dictionary.d.ts +13 -0
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -0
- package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/index.js +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.d.ts +3 -0
- package/dist/plugins/auth/get-user-permissions.d.ts.map +1 -0
- package/dist/plugins/auth/get-user-permissions.js +1 -0
- package/dist/plugins/auth/index.d.ts +4 -0
- package/dist/plugins/auth/index.d.ts.map +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.d.ts +9 -0
- package/dist/plugins/auth/verifyUser.d.ts.map +1 -0
- package/dist/plugins/auth/verifyUser.js +1 -0
- package/dist/plugins/dictionary.d.ts +3 -0
- package/dist/plugins/dictionary.d.ts.map +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +3 -6
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/jwt.d.ts +4 -0
- package/dist/plugins/jwt.d.ts.map +1 -0
- package/dist/plugins/jwt.js +1 -0
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.d.ts +3 -0
- package/dist/plugins/logger/transport.d.ts.map +1 -0
- package/dist/plugins/logger/transport.js +1 -0
- package/dist/plugins/pg.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/index.js +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +65 -8
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
- package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
- package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-file-token.js +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
- package/dist/plugins/resource/services/create-relation.d.ts +16 -0
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -0
- package/dist/plugins/resource/services/create.d.ts +5 -2
- package/dist/plugins/resource/services/create.d.ts.map +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +18 -0
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/delete-relation.js +1 -0
- package/dist/plugins/resource/services/delete.d.ts +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 +3 -2
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +13 -0
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/find-relation.js +1 -0
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/update-relation.d.ts +14 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- package/dist/plugins/resource/services/update.d.ts +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.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.d.ts +8 -1
- package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/dist/type.d.ts +37 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +1 -0
- package/migrations/20260903120000_core_schema.sql +27 -21
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903130001_add_file_fields.sql +5 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/migrations/20260907090000_core_schema.sql +32 -0
- package/package.json +12 -7
- 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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the delete relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
import type { AppContext } from "../../../context.js";
|
|
7
|
+
type DeleteRelationParams = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
relation: string;
|
|
11
|
+
relationId: string | number;
|
|
12
|
+
user?: ResourceUser;
|
|
13
|
+
};
|
|
14
|
+
export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, user, }: DeleteRelationParams, ctx?: AppContext) => Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=delete-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+CAIsD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAqCvJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function q(R,t){R=R-0x173;const X=G();let g=X[R];return g;}import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';export function createDeleteRelation(R,t){const X=createRemove(R,t);return async function g({name:m,id:Z,relation:z,relationId:l,user:y},h){const O=q,P=h?.['pg']??R['pg'],E=t['get'](m);if([O(0x173),O(0x174)]['includes'](z)&&!E['capabilities']?.['includes'](z))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+z+'\x22\x20requires\x20a\x20capabilities\x20\x22'+z+'\x22');if(z==='notes')return await P['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[l,m,String(Z)]),{'success':!![]};if(z==='files')return await P['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[l,m,String(Z)]),{'success':!![]};const C=E['relations']?.[z];if(!C?.['resource']||!C['foreignKey'])throw new UnsupportedError(O(0x175)+z+O(0x176));const L=await X({'name':C['resource'],'id':l,'user':y,'where':{'column':C[O(0x177)],'value':Z}},h);return{'success':L};};}function G(){const U=['notes','files','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','foreignKey'];G=function(){return U;};return G();}
|
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type RemoveParams = {
|
|
7
8
|
name: string;
|
|
8
9
|
id: string | number;
|
|
9
10
|
user?: ResourceUser;
|
|
10
|
-
|
|
11
|
+
where?: {
|
|
12
|
+
column: string;
|
|
13
|
+
value: string | number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function createRemove(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, where, }: RemoveParams, ctx?: AppContext) => Promise<boolean>;
|
|
17
|
+
export {};
|
|
11
18
|
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAE+B,YAAY,QAAQ,UAAU,sBAiCxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0x181;const X=G();let g=X[R];return g;}function G(){const O=['WHERE\x20','\x20=\x20$','length','rowCount','audit','write','module','name'];G=function(){return O;};return G();}import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(R,t){return async function X({name:g,id:m,user:Z,where:z},l){const L=q,y=t['get'](g);assertOperation(y,'delete',Z);const h=l?.['pg']??R['pg'],P=[m];let E=L(0x181)+qi(y['key'])+'\x20=\x20$1';z&&(P['push'](z['value']),E+='\x20AND\x20'+qi(z['column'])+L(0x182)+P[L(0x183)]);const C=await h['query']('DELETE\x20FROM\x20'+qt(y['table'])+'\x20'+E,P);if((C['rowCount']??0x0)>0x0)clearTableLookupCache(y['table'],h);if((C[L(0x184)]??0x0)>0x0)await(l?.['audit']??R[L(0x185)])?.[L(0x186)]({'module':y[L(0x187)],'resource':y[L(0x188)],'resourceId':m,'action':'delete'});return(C[L(0x184)]??0x0)>0x0;};}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the find one operation of the generic Resource CRUD engine.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
|
|
6
|
+
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, query, user, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
id: string | number;
|
|
9
|
+
query?: ResourceQuery;
|
|
9
10
|
user?: ResourceUser;
|
|
10
11
|
}) => Promise<Record<string, unknown> | null>;
|
|
11
12
|
//# sourceMappingURL=find-one.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAsDF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function G(){const c=['read','fields','key','type','\x20name:','join','\x20WHERE\x20','=$1\x20LIMIT\x201','resource','\x20FROM\x20','foreignKey','query'];G=function(){return c;};return G();}import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';function q(R,t){R=R-0x83;const X=G();let g=X[R];return g;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(R,t){return async function X({name:g,id:m,query:query={},user:Z}){const S=q,z=Date['now'](),l=t['get'](g);assertOperation(l,S(0x83),Z);if(l[S(0x84)][l[S(0x85)]]?.[S(0x86)]==='integer'&&!Number['isInteger'](Number(m)))throw new ValidationError('Invalid\x20id:\x20'+m+S(0x87)+g);const y=await R['pg']['query']('SELECT\x20'+readableFields(l)[S(0x88)](',\x20')+'\x20FROM\x20'+qt(l['table'])+S(0x89)+qi(l['key'])+S(0x8a),[m]),h=y['rows'][0x0];if(!h)return null;await addDictionaryLookupData([h],l['fields'],R['dictionary']),await addTableLookupData([h],l['fields'],R['pg']),addFileToken([h],l['fields'],R['file']);const P=Array['isArray'](query['include'])?query['include']:query['include']?.['split'](',')??[];for(const E of P){const C=l['relations']?.[E];if(!C?.['foreignKey']||!C['resource']&&!C['table'])throw new ValidationError('Unknown\x20relation:\x20'+E);const L=C['resource']?t['get'](C[S(0x8b)]):undefined,O=C['table']??L['table'],U=L?.['key']??'id',e=L?readableFields(L)['join'](',\x20'):'*',H='SELECT\x20'+e+S(0x8c)+qt(O)+'\x20WHERE\x20'+qi(U)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(C[S(0x8d)])+S(0x8c)+qt(l['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(l['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',n=(await R['pg'][S(0x8e)](H,[m]))['rows'];L&&(await addDictionaryLookupData(n,L['fields'],R['dictionary']),await addTableLookupData(n,L['fields'],R['pg']),addFileToken(n,L['fields'],R['file'])),h[E]=n;}return h['time']=Date['now']()-z,h;};}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the find relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, query, }: {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string | number;
|
|
9
|
+
relation: string;
|
|
10
|
+
query?: ResourceQuery;
|
|
11
|
+
user?: ResourceUser;
|
|
12
|
+
}) => Promise<any>;
|
|
13
|
+
//# sourceMappingURL=find-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAoGjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function q(R,t){R=R-0x176;const X=G();let g=X[R];return g;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';function G(){const o=['max','relations','files','\x22\x20requires\x20a\x20capabilities\x20\x22','rows','length','now','junctionTable','junctionLocalKey','foreignKey','key','map','t.*','SELECT\x20','\x0a\x20\x20\x20\x20WHERE\x20j.','file'];G=function(){return o;};return G();}export function createFindRelation(R,t){return async function X({name:g,id:m,relation:Z,query:query={}}){const Q=q,z=Date['now'](),l=Math['min'](Math[Q(0x176)](query['limit']??0x14,0x1),0xc8),y=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](l)||!Number['isFinite'](y))throw new ValidationError('Invalid\x20pagination');const h=t['get'](g),P=h[Q(0x177)]?.[Z];if(['notes',Q(0x178)]['includes'](Z)&&!h['capabilities']?.['includes'](Z))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Z+Q(0x179)+Z+'\x22');if(Z==='notes'){const n=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',[g,String(m)]);return{'total':n[Q(0x17a)][Q(0x17b)],'time':Date[Q(0x17c)]()-z,'rows':n['rows']};}if(Z===Q(0x178)){const S=await R['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[g,String(m)]);return addFileToken(S['rows'],{'file_path':{'type':'file'}},R['file']),{'total':S[Q(0x17a)]['length'],'time':Date['now']()-z,'rows':S['rows']};}const E=!!(P?.[Q(0x17d)]&&P[Q(0x17e)]&&P['junctionForeignKey']);if(!P||!E&&!P[Q(0x17f)]||!P['resource']&&!P['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Z+'\x22\x20requires\x20a\x20project/provider\x20implementation');const C=P['resource']?t['get'](P['resource']):undefined,L=P['table']??C['table'],O=C?.[Q(0x180)]??'id',U=P['fields']?.[Q(0x17b)]?P['fields'][Q(0x181)](c=>E?'t.'+qi(c):qi(c))['join'](',\x20'):E?Q(0x182):'*';P['foreignKey']&&autoIndex(L,P['foreignKey'],'btree',R['pg']);const e=E?Q(0x183)+U+'\x20FROM\x20'+qt(L)+'\x20t\x0a\x20\x20\x20\x20JOIN\x20'+qt(P['junctionTable'])+'\x20j\x20ON\x20j.'+qi(P['junctionForeignKey'])+'\x20=\x20t.'+qi(O)+Q(0x184)+qi(P['junctionLocalKey'])+'\x20=\x20$1\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3':Q(0x183)+U+'\x20FROM\x20'+qt(L)+'\x20WHERE\x20'+qi(P[Q(0x17f)])+'\x20=\x20$1\x20LIMIT\x20$2\x20OFFSET\x20$3',H=await R['pg']['query'](e,[m,l,y]);return C&&(await addDictionaryLookupData(H[Q(0x17a)],C['fields'],R['dictionary']),await addTableLookupData(H['rows'],C['fields'],R['pg']),addFileToken(H['rows'],C['fields'],R[Q(0x185)])),{'limit':l,'offset':y,'total':H['rows']['length'],'time':Date['now']()-z,'rows':H['rows']??null};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAgDhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function G(){const H=['now','min','limit','max','offset','fields','search','map','table','text',')\x20LIKE\x20$','\x20OR\x20','Filters:','FROM\x20','query','file'];G=function(){return H;};return G();}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';function q(R,t){R=R-0x116;const X=G();let g=X[R];return g;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFind(R,t){return async function X({name:g,query:query={},user:m}){const e=q,Z=Date[e(0x116)](),z=t['get'](g);assertOperation(z,'read',m);const l=Math[e(0x117)](Math['max'](query[e(0x118)]??0x14,0x1),0xc8),y=Math[e(0x119)](query[e(0x11a)]??0x0,0x0),h=buildFilters(z,query['filter'],0x1,R['pg']),P=buildSort(z,query['sort']);if(!Number['isFinite'](l)||!Number['isFinite'](y))throw new ValidationError('Invalid\x20pagination');const E=z['searchable']||Object['keys'](z['fields'])['filter'](U=>z[e(0x11b)][U]?.['searchable']);query[e(0x11c)]&&E['length']&&(E[e(0x11d)](U=>autoIndex(z[e(0x11e)],U,e(0x11f),R['pg'])),h['values']['push'](query['search']['toLowerCase']()+'%'),h['sql']+=(h['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+E?.['map'](U=>'lower('+qt(U)+e(0x120)+h['values']['length'])['join'](e(0x121))+')'));console['log'](e(0x122),h);const C='SELECT\x20'+readableFields(z)['join'](',\x20')+'\x20'+(e(0x123)+qt(z['table']))+(''+h['sql']+P+'\x20')+('LIMIT\x20$'+(h['values']['length']+0x1)+'\x20')+('OFFSET\x20$'+(h['values']['length']+0x2)),L=await R['pg'][e(0x124)](C,[...h['values'],l,y]),O=L['rows'];return await addDictionaryLookupData(O,z['fields'],R['dictionary']),await addTableLookupData(O,z[e(0x11b)],R['pg']),addFileToken(O,z['fields'],R[e(0x125)]),{'limit':l,'offset':y,'total':L['rowCount'],'time':Date['now']()-Z,'rows':O};};}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
+
import type { AppContext } from "../../../context.js";
|
|
4
|
+
type UpdateRelationParams = {
|
|
5
|
+
name: string;
|
|
6
|
+
id: string | number;
|
|
7
|
+
relation: string;
|
|
8
|
+
relationId: string | number;
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
user?: ResourceUser;
|
|
11
|
+
};
|
|
12
|
+
export declare function createUpdateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, data, user, }: UpdateRelationParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=update-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update-relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,qDAI4D,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAclK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function q(R,t){R=R-0x163;const X=G();let g=X[R];return g;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(R,t){const X=createUpdate(R,t);return async function g({name:m,id:Z,relation:z,relationId:l,data:y,user:h},P){const L=q,E=t['get'](m),C=E['relations']?.[z];if(!C?.[L(0x163)]||!C['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+z);if(Object['hasOwn'](y,C['foreignKey'])&&y[C['foreignKey']]!==Z)throw new ValidationError('Cannot\x20change\x20relation:\x20'+C['foreignKey']);return X({'name':C[L(0x163)],'id':l,'data':y,'user':h,'where':{'column':C[L(0x164)],'value':Z}},P);};}function G(){const O=['resource','foreignKey'];G=function(){return O;};return G();}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
2
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
-
|
|
3
|
+
import { AppContext } from "../../../context.js";
|
|
4
|
+
type UpdateParams = {
|
|
4
5
|
name: string;
|
|
5
6
|
id: string | number;
|
|
6
7
|
data: Record<string, unknown>;
|
|
7
8
|
user?: ResourceUser;
|
|
8
|
-
|
|
9
|
+
where?: {
|
|
10
|
+
column: string;
|
|
11
|
+
value: string | number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, where, }: UpdateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
15
|
+
export {};
|
|
9
16
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,sCAEqC,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAwDjI"}
|
|
@@ -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';import{validateInputData}from'../utils/fields.js';function G(){const c=['updated_at','push','updated_by','\x20=\x20$','key','length','value','\x20AND\x20','column','query','table','RETURNING\x20','update'];G=function(){return c;};return G();}function q(R,t){R=R-0x1f0;const X=G();let g=X[R];return g;}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(R,t){return async function X({name:g,id:m,data:Z,user:z,where:l},y){const S=q,h=t['get'](g);assertOperation(h,'update',z);const P=writableData(h,Z);if(!P['length'])throw new ValidationError('No\x20writable\x20fields');const E=y?.['pg']??R['pg'];validateInputData({'resource':h,'data':Z,'update':!![]});h['fields'][S(0x1f0)]&&P[S(0x1f1)](['updated_at',new Date()]);h['fields']['updated_by']&&P['push']([S(0x1f2),z?.['id']]);delete Z['user_type'];const C=P['map'](([H],n)=>qi(H)+S(0x1f3)+(n+0x1)),L=[...P['map'](([,H])=>H),m];let O='WHERE\x20'+qi(h[S(0x1f4)])+'\x20=\x20$'+L[S(0x1f5)];l&&(L['push'](l[S(0x1f6)]),O+=S(0x1f7)+qi(l[S(0x1f8)])+'\x20=\x20$'+L['length']);const U=await E[S(0x1f9)]('UPDATE\x20'+qt(h[S(0x1fa)])+'\x20'+('SET\x20'+C['join'](',\x20')+'\x20')+(O+'\x20')+(S(0x1fb)+readableFields(h)['join'](',\x20')),L),e=U['rows'][0x0];if(!e)throw new NotFoundError(g+':'+m);return clearTableLookupCache(h['table'],E),await(y?.['audit']??R['audit'])?.['write']({'userId':z?.['id'],'module':h['module'],'resource':h['name'],'resourceId':m,'action':S(0x1fc),'fields':Object['keys'](Z)}),e;};}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from "../../pg.js";
|
|
2
|
+
export type AutoIndexType = "text" | "btree" | "gist";
|
|
3
|
+
export declare function autoIndex(table: string, column: string, type: AutoIndexType | undefined, pg: DatabaseAdapter): void;
|
|
4
|
+
//# sourceMappingURL=auto-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/auto-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAItD,wBAAgB,SAAS,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,YAAU,EAC7B,EAAE,EAAE,eAAe,GACpB,IAAI,CAWN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function q(R,t){R=R-0x17a;const X=G();let g=X[R];return g;}import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(R,t,X='btree',g){const m=requestedIndexes['get'](g)??new Set();requestedIndexes['set'](g,m);const Z=R+':'+t+':'+X;if(m['has'](Z))return;m['add'](Z),void ensureIndex(R,t,X,g)['catch'](()=>{m['delete'](Z);});}function G(){const h=['split','public','replace','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','\x20USING\x20btree\x20(lower(','query','\x20USING\x20'];G=function(){return h;};return G();}async function ensureIndex(R,t,X,g){const y=q,m=R[y(0x17a)]('.'),Z=m['length']===0x2?m[0x0]:y(0x17b),z=(R+'_'+t+'_'+X+'_idx')[y(0x17c)](/[^A-Za-z0-9_]/g,'_'),l=await g['query'](y(0x17d),[Z,z]);if(l['rowCount'])return;if(X==='text'){await g['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await g['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(z+'_l')+'\x20ON\x20'+qt(R)+y(0x17e)+qi(t)+')\x20text_pattern_ops)'),await g['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(z)+'\x20ON\x20'+qt(R)+'\x20USING\x20gin\x20(lower('+qi(t)+')\x20gin_trgm_ops)');return;}await g[y(0x17f)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(z)+'\x20ON\x20'+qt(R)+y(0x180)+X+'\x20('+qi(t)+')');}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { ResourceContract } from "../resource.types.js";
|
|
1
2
|
/**
|
|
2
3
|
* Provides Resource helpers for fields handling.
|
|
3
4
|
*/
|
|
4
|
-
export { readableFields, writableData, fieldColumn } from
|
|
5
|
+
export { readableFields, writableData, fieldColumn } from "./sql.js";
|
|
6
|
+
declare const validateInputData: ({ resource, data, update, }: {
|
|
7
|
+
resource: ResourceContract;
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
update?: boolean;
|
|
10
|
+
}) => void;
|
|
11
|
+
export { validateInputData };
|
|
5
12
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/fields.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/fields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAErE,QAAA,MAAM,iBAAiB,gCAIpB;IACD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,SA2EA,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function G(){const Z=['fields','required','writable','maxLength','minimum','number','pattern','\x20should\x20match\x20regular\x20expression\x20('];G=function(){return Z;};return G();}const validateInputData=({resource:R,data:t,update:update=![]})=>{const m=q;for(const [X,g]of Object['entries'](R[m(0x140)])){if(g[m(0x141)]&&g[m(0x142)]!==![]&&(t[X]===undefined||t[X]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+X);if(g['required']&&g['writable']!==![]&&Object['hasOwn'](t,X)&&(t[X]===undefined||t[X]===null)&&update)throw new ValidationError('Required\x20field:\x20'+X);if(g['minLength']&&typeof t[X]==='string'&&t[X]['length']<g['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+X);if(g[m(0x143)]&&typeof t[X]==='string'&&t[X]['length']>g['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+X);if(g[m(0x144)]&&typeof t[X]===m(0x145)&&t[X]<g['minimum'])throw new ValidationError(X+'\x20should\x20be\x20>=\x20'+g[m(0x144)]);if(g['maximum']&&typeof t[X]==='number'&&t[X]>g['maximum'])throw new ValidationError(X+'\x20should\x20be\x20<=\x20'+g['maximum']);if(g['enum']&&t[X]&&!g['enum']['includes'](t[X]))throw new ValidationError(X+'\x20should\x20be\x20one\x20of\x20('+g['enum']['join'](',\x20')+')');if(g[m(0x146)]&&typeof t[X]==='string'&&!new RegExp(g['pattern'])['test'](t[X]))throw new ValidationError(X+m(0x147)+g['pattern']+')');}};function q(R,t){R=R-0x140;const X=G();let g=X[R];return g;}export{validateInputData};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provides Resource helpers for filters handling.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceContract } from '../resource.types.js';
|
|
5
|
-
export declare function
|
|
4
|
+
import type { ResourceContract, ResourceDependencies } from '../resource.types.js';
|
|
5
|
+
export declare function parseFilterQuery(query: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
6
|
+
export declare function buildFilters(resource: ResourceContract, filter: Record<string, unknown> | undefined, start?: number, pg?: ResourceDependencies['pg']): {
|
|
6
7
|
sql: string;
|
|
7
8
|
values: unknown[];
|
|
8
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AASnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA2BpG;AAED,wBAAgB,YAAY,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,KAAK,SAAI,EACT,EAAE,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC;;;EAgElC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0xc7;const X=G();let g=X[R];return g;}const e=q;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin','like',e(0xc7),'null']);function G(){const Q=['ilike','entries','has','nin','filter','filterable','type','\x20requires\x20a\x20text\x20field:\x20','push','FALSE','join','\x20AND\x20','object','gist'];G=function(){return Q;};return G();}export function parseFilterQuery(R){const H=e,t={...isRecord(R['filter'])?R['filter']:{}};for(const [X,g]of Object[H(0xc8)](R)){const m=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](X);if(!m)continue;const [,Z,z]=m;if(!Z)continue;if(!z){t[Z]=g;continue;}if(!filterOperators[H(0xc9)](z))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+z);const l=isRecord(t[Z])?t[Z]:{};l[z]=(z==='in'||z===H(0xca))&&typeof g==='string'?g['split'](','):g,t[Z]=l;}return Object['keys'](t)['length']?t:undefined;}export function buildFilters(R,t,X=0x1,g){const n=e,m=[],Z=[];for(const [z,l]of Object['entries'](t??{})){const y=R['fields'][z];if(!y||y[n(0xcb)]!==!![]&&y[n(0xcc)]!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+z);const h=qi(fieldColumn(R,z)),P=isRecord(l)?l:{'eq':l};for(const [E,C]of Object['entries'](P)){if(!filterOperators[n(0xc9)](E))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+E);if((E==='like'||E==='ilike')&&y['type']!=='string'&&y[n(0xcd)]!=='text')throw new ValidationError('Operator\x20'+E+n(0xce)+z);g&&autoIndex(R['table'],fieldColumn(R,z),indexTypeFor(y['type'],E),g);if(E==='null'){m[n(0xcf)](h+'\x20IS\x20'+(isTruthy(C)?'':'NOT\x20')+'NULL');continue;}if(E==='in'||E===n(0xca)){const U=Array['isArray'](C)?C:[C];if(U['length']===0x0){m['push'](E==='in'?n(0xd0):'TRUE');continue;}Z['push'](U),m['push'](h+'\x20'+(E==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(X+Z['length']-0x1)+')');continue;}const L={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},O='$'+(X+Z['length']);if(E==='like'){Z['push'](C+'%'),m[n(0xcf)]('lower('+h+')\x20like\x20lower('+O+')');continue;}Z['push'](C),m[n(0xcf)](h+'\x20'+L[E]+'\x20'+O);}}return{'sql':m['length']?'\x20WHERE\x20'+m[n(0xd1)](n(0xd2)):'','values':Z};}function isRecord(R){const S=e;return typeof R===S(0xd3)&&R!==null&&!Array['isArray'](R);}function isTruthy(R){return R===!![]||R==='true'||R==='1'||R===0x1;}function indexTypeFor(R,t){const c=e;if(t==='like'||t==='ilike')return'text';if(R==='geom'||R==='geometry')return c(0xd4);return'btree';}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/permissions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/permissions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACb,MAAM,sBAAsB,CAAC;AAI9B,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,IAAI,CAAC,EAAE,YAAY,QAqBpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';function q(R,t){R=R-0x1a2;const X=G();let g=X[R];return g;}export function assertOperation(R,t,X){const Z=q,g=getContext()['config'];if(g[Z(0x1a2)])return;if(!R['operations']['includes'](t))throw new ForbiddenError(R[Z(0x1a3)]+'.'+t+'\x20is\x20disabled');if(R[Z(0x1a4)]!==Z(0x1a5)&&X===undefined)throw new ForbiddenError('Authentication\x20required');if(R['access']===Z(0x1a6)&&X?.['type']!==Z(0x1a6))throw new ForbiddenError('Admin\x20access\x20required');if(X?.['type']!=='admin'){const m=(R['permission']??R[Z(0x1a3)])+':'+t;if(!X?.['permissions']?.['includes'](m))throw new ForbiddenError(Z(0x1a7)+m);}}function G(){const z=['debug','name','access','public','admin','Missing\x20permission:\x20'];G=function(){return z;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,UAgBpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function G(){const h=['map','sort','DESC','join'];G=function(){return h;};return G();}function q(R,t){R=R-0x1f1;const X=G();let g=X[R];return g;}export function buildSort(R,t){const l=q;if(!t?.['length'])return'';typeof t==='string'&&(t=[t]);const X=t[l(0x1f1)](g=>{const y=l,m=g['startsWith']('-'),Z=m?g['slice'](0x1):g,z=R['fields'][Z];if(!z||z[y(0x1f2)]!==!![]&&z['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+Z);return qi(fieldColumn(R,Z))+'\x20'+(m?y(0x1f3):'ASC');});return'\x20ORDER\x20BY\x20'+X[l(0x1f4)](',\x20');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const z=q;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=R=>'\x22'+R[z(0x1a9)](/"/g,'\x22\x22')+'\x22';export const quoteTable=R=>R['split']('.')[z(0x1aa)](quoteIdentifier)['join']('.');function q(R,t){R=R-0x1a9;const X=G();let g=X[R];return g;}export function fieldColumn(R,t){if(t===R['key'])return R['key'];const X=R['fields'][t];if(!X)throw new ValidationError('Unknown\x20field:\x20'+t);return X['column']??t;}export function readableFields(R){const l=z,t=Object[l(0x1ab)](R['fields'])['filter'](([,X])=>X['read']!==![]&&X[l(0x1ac)]!==![])['map'](([X,g])=>quoteIdentifier(g['column']??X)+'\x20AS\x20'+quoteIdentifier(X));return!R[l(0x1ad)][R['key']]&&t[l(0x1ae)](quoteIdentifier(R['key'])),t;}export function writableData(R,t){const y=z,X=[];for(const [g,m]of Object['entries'](t)){const Z=R['fields'][g];if(!Z||Z['write']===![]||Z['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+g);X[y(0x1af)]([Z['column']??g,m]);}return X;}function G(){const h=['replace','map','entries','readable','fields','unshift','push'];G=function(){return h;};return G();}export const qi=quoteIdentifier;export const qt=quoteTable;
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const getIP=R=>(R['headers']?.['x-real-ip']||R['headers']?.['x-forwarded-for']||R['ip']||R['connection']?.['remoteAddress']||'')['split'](':')['pop']();export default getIP;
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { FastifySchema } from "fastify";
|
|
2
|
+
/** Рівень доступу до HTTP API-маршруту. */
|
|
3
|
+
export type RouteAccess = "public" | "user" | "admin";
|
|
4
|
+
/** Декларація права у форматі `ресурс:дія`; перевірка прав тимчасово не активна. */
|
|
5
|
+
export type RoutePermission = `${string}:${string}`;
|
|
6
|
+
type AccessMetadata = {
|
|
7
|
+
/** Групи маршруту для OpenAPI/Swagger. */
|
|
8
|
+
tags: string[];
|
|
9
|
+
/** Код пакета, якому належить маршрут. */
|
|
10
|
+
package: string;
|
|
11
|
+
/** Короткий заголовок операції в OpenAPI/Swagger. */
|
|
12
|
+
summary: string;
|
|
13
|
+
/** Розгорнутий опис операції в OpenAPI/Swagger. */
|
|
14
|
+
description: string;
|
|
15
|
+
/** Активний рівень доступу: `public`, `user` або `admin`. */
|
|
16
|
+
access: RouteAccess;
|
|
17
|
+
/** Декларація потрібних прав; їхня runtime-валідація та перевірка тимчасово не активні. */
|
|
18
|
+
permissions: RoutePermission[];
|
|
19
|
+
};
|
|
20
|
+
/** Повна схема Fastify і метадані маршруту API. */
|
|
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
|
+
}
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AACtD,oFAAoF;AACpF,MAAM,MAAM,eAAe,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAGpD,KAAK,cAAc,GAAG;IACpB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,MAAM,EAAE,WAAW,CAAC;IACpB,2FAA2F;IAC3F,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF,mDAAmD;AACnD,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"}
|
package/dist/type.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -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
|
|
|
@@ -179,14 +182,17 @@ CREATE TABLE IF NOT EXISTS admin.files (
|
|
|
179
182
|
file_status numeric,
|
|
180
183
|
file_name text,
|
|
181
184
|
size numeric,
|
|
182
|
-
|
|
185
|
+
mime_type text,
|
|
183
186
|
tags text[],
|
|
184
|
-
file_path text,
|
|
187
|
+
file_path text,
|
|
188
|
+
field_name text,
|
|
189
|
+
status text DEFAULT 'pending', // File processing status, e.g., 'pending', 'attached'
|
|
190
|
+
expires_at timestamptz DEFAULT now() + interval '1 day',
|
|
185
191
|
verified boolean DEFAULT false,
|
|
186
192
|
resized boolean,
|
|
187
|
-
created_by text,
|
|
193
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
188
194
|
created_at timestamptz DEFAULT now(),
|
|
189
|
-
updated_by text,
|
|
195
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
190
196
|
updated_at timestamptz default now()
|
|
191
197
|
);
|
|
192
198
|
|
|
@@ -199,9 +205,9 @@ CREATE TABLE IF NOT EXISTS admin.settings (
|
|
|
199
205
|
key text NOT NULL,
|
|
200
206
|
value jsonb,
|
|
201
207
|
|
|
202
|
-
updated_by text,
|
|
208
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
203
209
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
204
|
-
created_by text,
|
|
210
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
205
211
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
206
212
|
);
|
|
207
213
|
|