@opengis/fcore 0.0.1-beta.2 → 0.0.1-beta.20
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 +2 -5
- 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 +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 +23 -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 +15 -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 +17 -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/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +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.js +1 -1
- package/dist/plugins/pg.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.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 +71 -15
- 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 +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.d.ts +1 -1
- package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/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 +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 +93 -88
- 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
|
@@ -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
|
-
function
|
|
1
|
+
function u(I,X){I=I-0x1c8;const o=f();let b=o[I];return b;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:I,data:X,update:update=![]})=>{const A=u;for(const [o,b]of Object['entries'](I['fields'])){if(b['required']&&b['writable']!==![]&&(X[o]===undefined||X[o]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+o);if(b[A(0x1c8)]&&b['writable']!==![]&&Object[A(0x1c9)](X,o)&&(X[o]===undefined||X[o]===null)&&update)throw new ValidationError('Required\x20field:\x20'+o);if(b['minLength']&&typeof X[o]==='string'&&X[o]['length']<b[A(0x1ca)])throw new ValidationError('minLength\x20not\x20met:\x20'+o);if(b[A(0x1cb)]&&typeof X[o]==='string'&&X[o]['length']>b['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+o);if(b[A(0x1cc)]&&typeof X[o]===A(0x1cd)&&X[o]<b[A(0x1cc)])throw new ValidationError(o+'\x20should\x20be\x20>=\x20'+b['minimum']);if(b[A(0x1ce)]&&typeof X[o]===A(0x1cd)&&X[o]>b['maximum'])throw new ValidationError(o+'\x20should\x20be\x20<=\x20'+b['maximum']);if(b[A(0x1cf)]&&X[o]&&!b['enum']['includes'](X[o]))throw new ValidationError(o+'\x20should\x20be\x20one\x20of\x20('+b['enum']['join'](',\x20')+')');if(b[A(0x1d0)]&&typeof X[o]==='string'&&!new RegExp(b['pattern'])['test'](X[o]))throw new ValidationError(o+A(0x1d1)+b['pattern']+')');}};export{validateInputData};function f(){const t=['required','hasOwn','minLength','maxLength','minimum','number','maximum','enum','pattern','\x20should\x20match\x20regular\x20expression\x20('];f=function(){return t;};return f();}
|
|
@@ -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
|
+
const W=u;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';function u(I,X){I=I-0x171;const o=f();let b=o[I];return b;}function f(){const c=['gte','nin','like','ilike','null','Field\x20is\x20not\x20filterable:\x20','text','table','FALSE','TRUE','push','join','geometry'];f=function(){return c;};return f();}const filterOperators=new Set(['eq','ne','gt',W(0x171),'lt','lte','in',W(0x172),W(0x173),W(0x174),W(0x175)]);export function parseFilterQuery(I){const X={...isRecord(I['filter'])?I['filter']:{}};for(const [o,b]of Object['entries'](I)){const A=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](o);if(!A)continue;const [,t,p]=A;if(!t)continue;if(!p){X[t]=b;continue;}if(!filterOperators['has'](p))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+p);const V=isRecord(X[t])?X[t]:{};V[p]=(p==='in'||p==='nin')&&typeof b==='string'?b['split'](','):b,X[t]=V;}return Object['keys'](X)['length']?X:undefined;}export function buildFilters(I,X,o=0x1,b){const K=W,A=[],t=[];for(const [p,V]of Object['entries'](X??{})){const O=I['fields'][p];if(!O||O['filter']!==!![]&&O['filterable']!==!![])throw new ValidationError(K(0x176)+p);const P=qi(fieldColumn(I,p)),M=isRecord(V)?V:{'eq':V};for(const [r,B]of Object['entries'](M)){if(!filterOperators['has'](r))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+r);if((r==='like'||r==='ilike')&&O['type']!=='string'&&O['type']!==K(0x177))throw new ValidationError('Operator\x20'+r+'\x20requires\x20a\x20text\x20field:\x20'+p);b&&autoIndex(I[K(0x178)],fieldColumn(I,p),indexTypeFor(O['type'],r),b);if(r===K(0x175)){A['push'](P+'\x20IS\x20'+(isTruthy(B)?'':'NOT\x20')+'NULL');continue;}if(r==='in'||r==='nin'){const Z=Array['isArray'](B)?B:[B];if(Z['length']===0x0){A['push'](r==='in'?K(0x179):K(0x17a));continue;}t[K(0x17b)](Z),A[K(0x17b)](P+'\x20'+(r==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(o+t['length']-0x1)+')');continue;}const s={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':K(0x173)},F='$'+(o+t['length']);if(r===K(0x173)){t[K(0x17b)](B+'%'),A['push']('lower('+P+')\x20like\x20lower('+F+')');continue;}t['push'](B),A['push'](P+'\x20'+s[r]+'\x20'+F);}}return{'sql':A['length']?'\x20WHERE\x20'+A[K(0x17c)]('\x20AND\x20'):'','values':t};}function isRecord(I){return typeof I==='object'&&I!==null&&!Array['isArray'](I);}function isTruthy(I){return I===!![]||I==='true'||I==='1'||I===0x1;}function indexTypeFor(I,X){const y=W;if(X===y(0x173)||X==='ilike')return'text';if(I==='geom'||I===y(0x17d))return'gist';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
|
+
function f(){const p=['includes','public','Authentication\x20required','type','permissions','Missing\x20permission:\x20'];f=function(){return p;};return f();}function u(I,X){I=I-0x1d1;const o=f();let b=o[I];return b;}import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';export function assertOperation(I,X,o){const t=u,b=getContext()['config'];if(b['debug'])return;if(!I['operations'][t(0x1d1)](X))throw new ForbiddenError(I['name']+'.'+X+'\x20is\x20disabled');if(I['access']!==t(0x1d2)&&o===undefined)throw new ForbiddenError(t(0x1d3));if(I['access']==='admin'&&o?.[t(0x1d4)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(o?.['type']!=='admin'){const A=(I['permission']??I['name'])+':'+X;if(!o?.[t(0x1d5)]?.[t(0x1d1)](A))throw new ForbiddenError(t(0x1d6)+A);}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provides Resource helpers for sort handling.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceContract } from
|
|
4
|
+
import type { ResourceContract } from "../resource.types.js";
|
|
5
5
|
export declare function buildSort(resource: ResourceContract, sort?: string[]): string;
|
|
6
6
|
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -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,UAcpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function u(I,X){I=I-0x12d;const o=f();let b=o[I];return b;}function f(){const O=['startsWith','Field\x20is\x20not\x20sortable:\x20','DESC'];f=function(){return O;};return f();}export function buildSort(I,X){if(!X?.['length'])return'';typeof X==='string'&&(X=[X]);const o=X['map'](b=>{const V=u,A=b[V(0x12d)]('-'),t=A?b['slice'](0x1):b,p=I['fields'][t];if(!p||p['sortable']!==!![])throw new ValidationError(V(0x12e)+t);return qi(fieldColumn(I,t))+'\x20'+(A?V(0x12f):'ASC');});return'\x20ORDER\x20BY\x20'+o['join'](',\x20');}
|
|
@@ -4,7 +4,7 @@ export declare const quoteIdentifier: (value: string) => string;
|
|
|
4
4
|
/** Quote a schema-qualified PostgreSQL table name. */
|
|
5
5
|
export declare const quoteTable: (value: string) => string;
|
|
6
6
|
export declare function fieldColumn(resource: ResourceContract, name: string): string;
|
|
7
|
-
export declare function readableFields(resource: ResourceContract): string[];
|
|
7
|
+
export declare function readableFields(resource: ResourceContract, scope?: string): string[];
|
|
8
8
|
export declare function writableData(resource: ResourceContract, data: Record<string, unknown>): Array<[
|
|
9
9
|
string,
|
|
10
10
|
unknown
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAA0C,CAAC;AAC3F,sDAAsD;AACtD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAyD,CAAC;AACrG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5E;AACD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAA0C,CAAC;AAC3F,sDAAsD;AACtD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAyD,CAAC;AACrG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5E;AACD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAQnF;AACD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IAC3F,MAAM;IACN,OAAO;CACV,CAAC,CAmBD;AAED,eAAO,MAAM,EAAE,wBAAkB,CAAC;AAClC,eAAO,MAAM,EAAE,mBAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const p=u;import{ValidationError}from'../../../errors.js';function f(){const M=['replace','map','join','fields','column','entries','key','writable','write','date'];f=function(){return M;};return f();}export const quoteIdentifier=I=>'\x22'+I[p(0x145)](/"/g,'\x22\x22')+'\x22';export const quoteTable=I=>I['split']('.')[p(0x146)](quoteIdentifier)[p(0x147)]('.');function u(I,X){I=I-0x145;const o=f();let b=o[I];return b;}export function fieldColumn(I,X){const V=p;if(X===I['key'])return I['key'];const o=I[V(0x148)][X];if(!o)throw new ValidationError('Unknown\x20field:\x20'+X);return o[V(0x149)]??X;}export function readableFields(I,X){const O=p,o=Object[O(0x14a)](I['fields'])['filter'](([,b])=>b['read']!==![]&&b['readable']!==![]&&(X?(b['scope']??'all')===X:!![]))[O(0x146)](([b,A])=>quoteIdentifier(A['column']??b)+'\x20AS\x20'+quoteIdentifier(b));return!I['fields'][I['key']]&&o['unshift'](quoteIdentifier(I[O(0x14b)])),o;}export function writableData(I,X){const P=p,o=[];for(const [b,A]of Object['entries'](X)){const t=I[P(0x148)][b];if(!t||t['write']===![]||t[P(0x14c)]===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+b);if((t[P(0x14d)]??t['writable'])!==!![])continue;if(t['type']===P(0x14e)&&!X[b])continue;o['push']([t[P(0x149)]??b,A]);}return o;}export const qi=quoteIdentifier;export const qt=quoteTable;
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const X=u,getIP=I=>(I[X(0x68)]?.['x-real-ip']||I['headers']?.['x-forwarded-for']||I['ip']||I['connection']?.[X(0x69)]||'')[X(0x6a)](':')['pop']();function u(I,X){I=I-0x68;const o=f();let b=o[I];return b;}function f(){const o=['headers','remoteAddress','split'];f=function(){return o;};return f();}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,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"}
|
|
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"}
|
|
@@ -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
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
-
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
IF to_regclass('crm.notes') IS NOT NULL
|
|
6
|
-
AND to_regclass('admin.notes') IS NULL THEN
|
|
7
|
-
ALTER TABLE crm.notes SET SCHEMA admin;
|
|
8
|
-
END IF;
|
|
9
|
-
|
|
10
|
-
IF to_regclass('crm.files') IS NOT NULL
|
|
11
|
-
AND to_regclass('admin.files') IS NULL THEN
|
|
12
|
-
ALTER TABLE crm.files SET SCHEMA admin;
|
|
13
|
-
END IF;
|
|
14
|
-
END
|
|
15
|
-
$$;
|
|
16
|
-
|
|
17
|
-
ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
|
|
1
|
+
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
+
|
|
3
|
+
DO $$
|
|
4
|
+
BEGIN
|
|
5
|
+
IF to_regclass('crm.notes') IS NOT NULL
|
|
6
|
+
AND to_regclass('admin.notes') IS NULL THEN
|
|
7
|
+
ALTER TABLE crm.notes SET SCHEMA admin;
|
|
8
|
+
END IF;
|
|
9
|
+
|
|
10
|
+
IF to_regclass('crm.files') IS NOT NULL
|
|
11
|
+
AND to_regclass('admin.files') IS NULL THEN
|
|
12
|
+
ALTER TABLE crm.files SET SCHEMA admin;
|
|
13
|
+
END IF;
|
|
14
|
+
END
|
|
15
|
+
$$;
|
|
16
|
+
|
|
17
|
+
ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
|
|
18
18
|
ALTER INDEX IF EXISTS crm_notes_uid_idx RENAME TO admin_notes_uid_idx;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
alter table admin.files add column if not exists mime_type text;
|
|
3
|
+
alter table admin.files add column if not exists status text default 'pending';
|
|
4
|
+
alter table admin.files add column if not exists expires_at timestamptz default now() + interval '1 day';
|
|
5
|
+
alter table admin.files add column if not exists field_name text;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
-
|
|
3
|
-
CREATE TABLE IF NOT EXISTS admin.settings (
|
|
4
|
-
id text PRIMARY KEY DEFAULT next_id(),
|
|
5
|
-
resource text NOT NULL DEFAULT 'system',
|
|
6
|
-
resource_id text,
|
|
7
|
-
key text NOT NULL,
|
|
8
|
-
value jsonb,
|
|
9
|
-
updated_by text,
|
|
10
|
-
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
11
|
-
created_by text,
|
|
12
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
DROP INDEX IF EXISTS settings_resource_key_uidx;
|
|
16
|
-
|
|
17
|
-
CREATE UNIQUE INDEX settings_resource_key_uidx
|
|
18
|
-
ON admin.settings (resource, resource_id, key)
|
|
1
|
+
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS admin.settings (
|
|
4
|
+
id text PRIMARY KEY DEFAULT next_id(),
|
|
5
|
+
resource text NOT NULL DEFAULT 'system',
|
|
6
|
+
resource_id text,
|
|
7
|
+
key text NOT NULL,
|
|
8
|
+
value jsonb,
|
|
9
|
+
updated_by text,
|
|
10
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
11
|
+
created_by text,
|
|
12
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
DROP INDEX IF EXISTS settings_resource_key_uidx;
|
|
16
|
+
|
|
17
|
+
CREATE UNIQUE INDEX settings_resource_key_uidx
|
|
18
|
+
ON admin.settings (resource, resource_id, key)
|
|
19
19
|
NULLS NOT DISTINCT;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
ALTER TABLE admin.users
|
|
2
|
+
ADD CONSTRAINT users_created_by_fkey
|
|
3
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
4
|
+
ADD CONSTRAINT users_updated_by_fkey
|
|
5
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
6
|
+
|
|
7
|
+
ALTER TABLE admin.user_roles
|
|
8
|
+
ADD CONSTRAINT user_roles_created_by_fkey
|
|
9
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
10
|
+
ADD CONSTRAINT user_roles_updated_by_fkey
|
|
11
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
12
|
+
|
|
13
|
+
ALTER TABLE admin.role_access
|
|
14
|
+
ADD CONSTRAINT role_access_user_uid_fkey
|
|
15
|
+
FOREIGN KEY (user_uid) REFERENCES admin.users(uid) ON DELETE CASCADE,
|
|
16
|
+
ADD CONSTRAINT role_access_created_by_fkey
|
|
17
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
18
|
+
ADD CONSTRAINT role_access_updated_by_fkey
|
|
19
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
20
|
+
|
|
21
|
+
ALTER TABLE admin.dictionaries
|
|
22
|
+
ADD CONSTRAINT dictionaries_created_by_fkey
|
|
23
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
24
|
+
ADD CONSTRAINT dictionaries_updated_by_fkey
|
|
25
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
26
|
+
|
|
27
|
+
ALTER TABLE admin.notes
|
|
28
|
+
ADD CONSTRAINT notes_created_by_fkey
|
|
29
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
30
|
+
ADD CONSTRAINT notes_updated_by_fkey
|
|
31
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
32
|
+
|
|
33
|
+
ALTER TABLE admin.files
|
|
34
|
+
ADD CONSTRAINT files_created_by_fkey
|
|
35
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
36
|
+
ADD CONSTRAINT files_updated_by_fkey
|
|
37
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
38
|
+
|
|
39
|
+
ALTER TABLE admin.settings
|
|
40
|
+
ADD CONSTRAINT settings_created_by_fkey
|
|
41
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
42
|
+
ADD CONSTRAINT settings_updated_by_fkey
|
|
43
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
DO $$
|
|
2
|
+
declare
|
|
3
|
+
_password_column_exists boolean;
|
|
4
|
+
BEGIN
|
|
5
|
+
IF to_regclass('admin.users') IS NOT NULL then
|
|
6
|
+
|
|
7
|
+
select true from pg_attribute where attrelid::regclass::text='admin.users' and attname='password' into _password_column_exists;
|
|
8
|
+
|
|
9
|
+
IF _password_column_exists is true then
|
|
10
|
+
alter table admin.users add column if not exists password_hash text;
|
|
11
|
+
update admin.users set password_hash = password where password is not null and password_hash is null;
|
|
12
|
+
alter table admin.users drop column if exists password;
|
|
13
|
+
END IF;
|
|
14
|
+
|
|
15
|
+
alter table admin.users add column if not exists twofa boolean not null default false;
|
|
16
|
+
|
|
17
|
+
END IF;
|
|
18
|
+
|
|
19
|
+
END
|
|
20
|
+
$$;
|
|
21
|
+
|
|
22
|
+
CREATE OR REPLACE FUNCTION next_id()
|
|
23
|
+
RETURNS text AS
|
|
24
|
+
$BODY$
|
|
25
|
+
DECLARE
|
|
26
|
+
|
|
27
|
+
BEGIN
|
|
28
|
+
return encode(public.gen_random_bytes(6), 'hex');
|
|
29
|
+
END;
|
|
30
|
+
$BODY$
|
|
31
|
+
LANGUAGE plpgsql VOLATILE
|
|
32
|
+
COST 100;
|