@opengis/fcore 0.0.1-beta.0 → 0.0.1-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -3
- package/README.md +71 -71
- package/dist/config.d.ts +3 -10
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/context.d.ts +4 -4
- package/dist/context.d.ts.map +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.d.ts.map +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.d.ts.map +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.d.ts.map +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.d.ts.map +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.d.ts +1 -1
- package/dist/modules/utils/require-admin.d.ts.map +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.d.ts +2 -2
- package/dist/plugins/audit/audit.d.ts.map +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.d.ts +2 -2
- package/dist/plugins/audit/services/write-audit.d.ts.map +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 +4 -7
- 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.d.ts +9 -4
- package/dist/plugins/logger/index.d.ts.map +1 -1
- 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 +62 -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 +5 -2
- package/dist/plugins/resource/services/delete.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts +3 -2
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +13 -0
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/find-relation.js +1 -0
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/update-relation.d.ts +14 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- package/dist/plugins/resource/services/update.d.ts +5 -2
- package/dist/plugins/resource/services/update.d.ts.map +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.d.ts +8 -1
- package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/dist/type.d.ts +37 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +1 -0
- package/migrations/20260903120000_core_schema.sql +259 -0
- package/migrations/20260903130000_move_notes_files_to_admin.sql +18 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +19 -0
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/migrations/20260907090000_core_schema.sql +32 -0
- package/package.json +93 -87
- package/dist/modules/auth/index.d.ts +0 -9
- package/dist/modules/auth/index.d.ts.map +0 -1
- package/dist/modules/auth/index.js +0 -1
- package/dist/modules/auth/services/login.d.ts +0 -10
- package/dist/modules/auth/services/login.d.ts.map +0 -1
- package/dist/modules/auth/services/login.js +0 -1
- package/dist/modules/auth/services/logout.d.ts +0 -9
- package/dist/modules/auth/services/logout.d.ts.map +0 -1
- package/dist/modules/auth/services/logout.js +0 -1
- package/dist/modules/auth/services/verifyPassword.d.ts +0 -11
- package/dist/modules/auth/services/verifyPassword.d.ts.map +0 -1
- package/dist/modules/auth/services/verifyPassword.js +0 -1
- package/dist/modules/file/index.d.ts +0 -8
- package/dist/modules/file/index.d.ts.map +0 -1
- package/dist/modules/file/index.js +0 -1
- package/dist/modules/resource/index.d.ts +0 -20
- package/dist/modules/resource/index.d.ts.map +0 -1
- package/dist/modules/resource/index.js +0 -1
- package/dist/modules/resource/services/list-children.d.ts +0 -6
- package/dist/modules/resource/services/list-children.d.ts.map +0 -1
- package/dist/modules/resource/services/list-children.js +0 -1
- package/dist/modules/system/index.d.ts +0 -13
- package/dist/modules/system/index.d.ts.map +0 -1
- package/dist/modules/system/index.js +0 -1
- package/dist/modules/utils/get-user-permissions.d.ts +0 -3
- package/dist/modules/utils/get-user-permissions.d.ts.map +0 -1
- package/dist/modules/utils/get-user-permissions.js +0 -1
- package/dist/plugins/logger/checkUserAccess.d.ts +0 -11
- package/dist/plugins/logger/checkUserAccess.d.ts.map +0 -1
- package/dist/plugins/logger/checkUserAccess.js +0 -1
- package/dist/plugins/logger/createFileStream.d.ts +0 -3
- package/dist/plugins/logger/createFileStream.d.ts.map +0 -1
- package/dist/plugins/logger/createFileStream.js +0 -1
- package/dist/plugins/logger/createLogger.d.ts +0 -9
- package/dist/plugins/logger/createLogger.d.ts.map +0 -1
- package/dist/plugins/logger/createLogger.js +0 -1
- package/dist/plugins/logger/errorStatus.d.ts +0 -2
- package/dist/plugins/logger/errorStatus.d.ts.map +0 -1
- package/dist/plugins/logger/errorStatus.js +0 -1
- package/dist/plugins/logger/getHooks.d.ts +0 -5
- package/dist/plugins/logger/getHooks.d.ts.map +0 -1
- package/dist/plugins/logger/getHooks.js +0 -1
- package/dist/plugins/logger/getRootDir.d.ts +0 -3
- package/dist/plugins/logger/getRootDir.d.ts.map +0 -1
- package/dist/plugins/logger/getRootDir.js +0 -1
- package/dist/plugins/logger/labels.d.ts +0 -3
- package/dist/plugins/logger/labels.d.ts.map +0 -1
- package/dist/plugins/logger/labels.js +0 -1
- package/dist/plugins/logger/serializers.d.ts +0 -14
- package/dist/plugins/logger/serializers.d.ts.map +0 -1
- package/dist/plugins/logger/serializers.js +0 -1
- package/dist/plugins/logger/timestampWithTimeZone.d.ts +0 -2
- package/dist/plugins/logger/timestampWithTimeZone.d.ts.map +0 -1
- package/dist/plugins/logger/timestampWithTimeZone.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-dictionary-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-dictionary-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAsDnF,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,GAC7C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAuBpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(d,h){const Q=S,p=dictionaryIndexesCache['get'](h)??new Map(),Z=dictionaryRevisionsCache['get'](h)??new Map();dictionaryIndexesCache['set'](h,p),dictionaryRevisionsCache['set'](h,Z);const D=d[Q(0x1e6)](n=>Z['get'](n)!==h['revision'](n));if(D['length']===0x0)return p;const u=await Promise['all'](D['map'](async n=>{const F=Q;if(!h[F(0x1e7)](n))return[n,new Map()];const X=await h['get'](n),Y=new Map();for(const w of X){const y=w[F(0x1e8)]??w['id'];if(y==null)continue;Y['set'](String(y),{'id':y,'text':w[F(0x1e9)]??w[F(0x1ea)],...w[F(0x1eb)]!==undefined?{'color':w['color']}:{},...w['icon']!==undefined?{'icon':w['icon']}:{}});}return[n,Y];}));for(const [n,X]of u){p['set'](n,X),Z[Q(0x1ec)](n,h['revision'](n));}return p;}function S(d,h){d=d-0x1e6;const p=v();let Z=p[d];return Z;}function v(){const K=['filter','has','code','name','text','color','set','length','entries','map','get'];v=function(){return K;};return v();}export async function addDictionaryLookupData(d,h,p){const B=S;if(!p||d[B(0x1ed)]===0x0)return d;const Z=Object[B(0x1ee)](h)['flatMap'](([u,n])=>{const X=n['dictionary'];return X?[{'field':u,'dictionaryName':X}]:[];});if(Z['length']===0x0)return d;const D=await getDictionaryIndexes([...new Set(Z[B(0x1ef)](({dictionaryName:u})=>u))],p);for(const u of d){for(const {field:n,dictionaryName:X}of Z){const Y=u[n];u[n+'_data']=Y==null?null:D[B(0x1f0)](X)?.['get'](String(Y))??null;}}return d;}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function addFileToken(rows: Record<string, unknown>[], fields: ResourceContract["fields"], file: ResourceDependencies["file"]): Record<string, unknown>[];
|
|
3
|
+
//# sourceMappingURL=add-file-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-file-token.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-file-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,wBAAgB,YAAY,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAiB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function S(d,h){d=d-0x169;const p=v();let Z=p[d];return Z;}export function addFileToken(d,h,p){const X=S;if(!p||d['length']===0x0)return d;const Z=Object[X(0x169)](h)[X(0x16a)](([,D])=>D['type']===X(0x16b))['map'](([D])=>D);for(const D of d){for(const u of Z){const n=D[u];typeof n==='string'&&n[X(0x16c)]>0x0&&(D[u]=p[X(0x16d)](n));}}return d;}function v(){const Y=['entries','filter','file','length','create'];v=function(){return Y;};return v();}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function clearTableLookupCache(table: string, pg: NonNullable<ResourceDependencies["pg"]>): void;
|
|
3
|
+
export declare function addTableLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], pg: ResourceDependencies["pg"]): Promise<Record<string, unknown>[]>;
|
|
4
|
+
//# sourceMappingURL=add-table-lookup-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-table-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-table-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAQnF,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAC5C,IAAI,CASN;AAED,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CA8DpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{qi,qt}from'../utils/sql.js';function v(){const O=['entries','string','query','SELECT\x20','\x20AS\x20id,\x20','\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20','table','value'];v=function(){return O;};return v();}const tableLookupCache=new WeakMap();function S(d,h){d=d-0x19c;const p=v();let Z=p[d];return Z;}export function clearTableLookupCache(d,h){const p=tableLookupCache['get'](h);if(!p)return;for(const Z of p['keys']()){Z['startsWith'](d+':')&&p['delete'](Z);}}export async function addTableLookupData(d,h,p){const M=S;if(!p||d['length']===0x0)return d;const Z=tableLookupCache['get'](p)??new Map();tableLookupCache['set'](p,Z);const D=Object[M(0x19c)](h)['flatMap'](([u,n])=>{const {table:X,value:value='id',text:text='name'}=n['lookup']??{};return X?[{'field':u,'table':X,'value':value,'text':text}]:[];});for(const u of D){const n=new Map();for(const y of d){const Q=y[u['field']];(typeof Q===M(0x19d)||typeof Q==='number')&&n['set'](String(Q),Q);}const X=u['table']+':'+u['value']+':'+u['text'],Y=Z['get'](X)??new Map();Z['set'](X,Y);const w=[...n[M(0x19c)]()]['filter'](([F])=>!Y['has'](F))['map'](([,F])=>F);if(w['length']>0x0){const F=await p[M(0x19e)](M(0x19f)+qi(u['value'])+M(0x1a0)+qi(u['text'])+M(0x1a1)+qt(u[M(0x1a2)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(u[M(0x1a3)])+'\x20=\x20ANY($1)',[w]);for(const B of F['rows']){Y['set'](String(B['id']),B);}for(const K of w){!Y['has'](String(K))&&Y['set'](String(K),null);}}for(const g of d){const s=g[u['field']];g[u['field']+'_data']=s==null?null:Y['get'](String(s))??null;}}return d;}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the create relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type CreateRelationParams = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
relation: string;
|
|
11
|
+
data?: Record<string, unknown>;
|
|
12
|
+
user?: ResourceUser;
|
|
13
|
+
};
|
|
14
|
+
export declare function createCreateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, data, user, }: CreateRelationParams, ctx?: AppContext) => Promise<any>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=create-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yCAIgD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,GAAG,CAAC,CAqEhI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';import{createCreate}from'./create.js';function S(d,h){d=d-0xb4;const p=v();let Z=p[d];return Z;}function v(){const q=['INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*','get','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','resource','length','No\x20writable\x20fields','map','INSERT\x20INTO\x20','rows','table'];v=function(){return q;};return v();}export function createCreateRelation(d,h){const p=createCreate(d,h);return async function Z({name:D,id:u,relation:n,data:X,user:Y},w){const c=S,y=w?.['pg']??d['pg'];if(n==='notes'){const g=await y['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[D,String(u),X?.['body']]);return g['rows'][0x0];}if(n==='files'){const s=await y['query'](c(0xb4),[D,String(u),X?.['filePath'],X?.['size']??null]);return s['rows'][0x0];}const Q=h[c(0xb5)](D),F=Q['relations']?.[n];if(!F?.['foreignKey']||!F['resource']&&!F['table'])throw new UnsupportedError(c(0xb6)+n+c(0xb7));let B,K;if(F['resource'])B=await p({'name':F['resource'],'data':X??{},'user':Y}),K=B[h['get'](F[c(0xb8)])['key']];else{const M=F['fields'];if(!M?.['length'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+n+'\x22\x20requires\x20a\x20project/provider\x20implementation');const O=Object['entries'](X??{})['filter'](([I])=>M['includes'](I));if(!O[c(0xb9)])throw new ValidationError(c(0xba));const R=O['map'](([I])=>qi(I)),E=O[c(0xbb)]((I,k)=>'$'+(k+0x1)),J=O['map'](([,I])=>I),U=await y['query'](c(0xbc)+qt(F['table'])+'\x20('+R['join'](',\x20')+')\x20VALUES\x20('+E['join'](',\x20')+')\x20RETURNING\x20*',J);B=U[c(0xbd)][0x0],K=B['id'];}return await y['query']('UPDATE\x20'+qt(Q[c(0xbe)])+'\x20SET\x20'+qi(F['foreignKey'])+'\x20=\x20$1\x20WHERE\x20'+qi(Q['key'])+'\x20=\x20$2',[K,u]),B;};}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
2
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
-
|
|
3
|
+
import { AppContext } from "../../../context.js";
|
|
4
|
+
type CreateParams = {
|
|
4
5
|
name: string;
|
|
5
6
|
data: Record<string, unknown>;
|
|
6
7
|
user?: ResourceUser;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function createCreate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, data, user, }: CreateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
10
|
+
export {};
|
|
8
11
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAE0B,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqCtH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(d,h){d=d-0x1ec;const p=v();let Z=p[d];return Z;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(d,h){return async function p({name:Z,data:D,user:u},n){const M=S,X=h['get'](Z);assertOperation(X,'create',u),validateInputData({'resource':X,'data':D});const Y=writableData(X,D);if(!Y[M(0x1ec)])throw new ValidationError('No\x20writable\x20fields');const w=Y['map'](([g])=>qi(g)),y=Y['map']((g,s)=>'$'+(s+0x1)),Q=Y['map'](([,g])=>g),F=n?.['pg']??d['pg'],B=await F['query']('INSERT\x20INTO\x20'+qt(X['table'])+'\x20('+w[M(0x1ed)](',\x20')+')\x20'+('VALUES\x20('+y['join'](',\x20')+')\x20')+(M(0x1ee)+readableFields(X)[M(0x1ed)](',\x20')),Q),K=B['rows'][0x0];return clearTableLookupCache(X[M(0x1ef)],F),await(n?.['audit']??d['audit'])?.[M(0x1f0)]({'userId':u?.['id'],'module':X[M(0x1f1)],'resource':X[M(0x1f2)],'resourceId':K[X['key']],'action':M(0x1f3),'fields':Object['keys'](D)}),K;};}function v(){const O=['length','join','RETURNING\x20','table','write','module','name','create'];v=function(){return O;};return v();}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the delete relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
import type { AppContext } from "../../../context.js";
|
|
7
|
+
type DeleteRelationParams = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
relation: string;
|
|
11
|
+
relationId: string | number;
|
|
12
|
+
user?: ResourceUser;
|
|
13
|
+
};
|
|
14
|
+
export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, user, }: DeleteRelationParams, ctx?: AppContext) => Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=delete-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+CAEsD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAwBvJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function S(d,h){d=d-0x19c;const p=v();let Z=p[d];return Z;}import{UnsupportedError}from'../../../errors.js';function v(){const Q=['DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','files','DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','Generic\x20Resource\x20relation\x20\x22'];v=function(){return Q;};return v();}export function createDeleteRelation(d,h){return async function p({name:Z,id:D,relation:u,relationId:n,user:X},Y){const y=S,w=Y?.['pg']??d['pg'];if(u==='notes')return await w['query'](y(0x19c),[n,Z,String(D)]),{'success':!![]};if(u===y(0x19d))return await w['query'](y(0x19e),[n,Z,String(D)]),{'success':!![]};throw new UnsupportedError(y(0x19f)+u+'\x22\x20requires\x20a\x20project/provider\x20implementation');};}
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type RemoveParams = {
|
|
7
8
|
name: string;
|
|
8
9
|
id: string | number;
|
|
9
10
|
user?: ResourceUser;
|
|
10
|
-
}
|
|
11
|
+
};
|
|
12
|
+
export declare function createRemove(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: RemoveParams, ctx?: AppContext) => Promise<boolean>;
|
|
13
|
+
export {};
|
|
11
14
|
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAEwB,YAAY,QAAQ,UAAU,sBAyBjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function S(d,h){d=d-0x9f;const p=v();let Z=p[d];return Z;}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(d,h){return async function p({name:Z,id:D,user:u},n){const y=S,X=h['get'](Z);assertOperation(X,y(0x9f),u);const Y=n?.['pg']??d['pg'],w=await Y['query']('DELETE\x20FROM\x20'+qt(X[y(0xa0)])+'\x20WHERE\x20'+qi(X['key'])+y(0xa1),[D]);if((w[y(0xa2)]??0x0)>0x0)clearTableLookupCache(X['table'],Y);if((w['rowCount']??0x0)>0x0)await(n?.['audit']??d[y(0xa3)])?.['write']({'module':X['module'],'resource':X['name'],'resourceId':D,'action':'delete'});return(w['rowCount']??0x0)>0x0;};}function v(){const Q=['delete','table','=$1','rowCount','audit'];v=function(){return Q;};return v();}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the find one operation of the generic Resource CRUD engine.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
|
|
6
|
+
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, query, user, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
id: string | number;
|
|
9
|
+
query?: ResourceQuery;
|
|
9
10
|
user?: ResourceUser;
|
|
10
11
|
}) => Promise<Record<string, unknown> | null>;
|
|
11
12
|
//# sourceMappingURL=find-one.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAsDF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(d,h){return async function p({name:Z,id:D,query:query={},user:u}){const R=S,n=Date['now'](),X=h['get'](Z);assertOperation(X,'read',u);if(!d['pg'])throw new Error('empty\x20pg');const Y=await d['pg']['query'](R(0x1cb)+readableFields(X)['join'](',\x20')+R(0x1cc)+qt(X[R(0x1cd)])+'\x20WHERE\x20'+qi(X['key'])+'=$1\x20LIMIT\x201',[D]),w=Y['rows'][0x0];if(!w)return null;await addDictionaryLookupData([w],X['fields'],d[R(0x1ce)]),await addTableLookupData([w],X['fields'],d['pg']),addFileToken([w],X[R(0x1cf)],d['file']);const y=Array['isArray'](query['include'])?query['include']:query['include']?.[R(0x1d0)](',')??[];for(const Q of y){const F=X[R(0x1d1)]?.[Q];if(!F?.['foreignKey']||!F['resource']&&!F[R(0x1cd)])throw new ValidationError('Unknown\x20relation:\x20'+Q);const B=F['resource']?h['get'](F['resource']):undefined,K=F['table']??B[R(0x1cd)],g=B?.['key']??'id',s=B?readableFields(B)['join'](',\x20'):'*',M='SELECT\x20'+s+R(0x1cc)+qt(K)+'\x20WHERE\x20'+qi(g)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(F[R(0x1d2)])+'\x20FROM\x20'+qt(X[R(0x1cd)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(X['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',O=(await d['pg']['query'](M,[D]))['rows'];B&&(await addDictionaryLookupData(O,B['fields'],d[R(0x1ce)]),await addTableLookupData(O,B['fields'],d['pg']),addFileToken(O,B[R(0x1cf)],d['file'])),w[Q]=O;}return w['time']=Date['now']()-n,w;};}function S(d,h){d=d-0x1cb;const p=v();let Z=p[d];return Z;}function v(){const E=['SELECT\x20','\x20FROM\x20','table','dictionary','fields','split','relations','foreignKey'];v=function(){return E;};return v();}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the find relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, query, }: {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string | number;
|
|
9
|
+
relation: string;
|
|
10
|
+
query?: ResourceQuery;
|
|
11
|
+
user?: ResourceUser;
|
|
12
|
+
}) => Promise<any>;
|
|
13
|
+
//# sourceMappingURL=find-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAyEjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';function v(){const E=['max','SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','length','now','rows','file','get','resource','table','key','map','\x20WHERE\x20\x0a\x20\x20\x20\x20','\x20FROM\x20','\x20WHERE\x20','\x20=\x20$1\x20LIMIT\x201)\x20\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3','query','dictionary','fields'];v=function(){return E;};return v();}function S(d,h){d=d-0xe0;const p=v();let Z=p[d];return Z;}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindRelation(d,h){return async function p({name:Z,id:D,relation:u,query:query={}}){const R=S,n=Date['now'](),X=Math['min'](Math[R(0xe0)](query['limit']??0x14,0x1),0xc8),Y=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](X)||!Number['isFinite'](Y))throw new ValidationError('Invalid\x20pagination');if(u==='notes'){const M=await d['pg']['query'](R(0xe1),[Z,String(D)]);return{'total':M['rows'][R(0xe2)],'time':Date[R(0xe3)]()-n,'rows':M[R(0xe4)]};}if(u==='files'){const O=await d['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[Z,String(D)]);return addFileToken(O['rows'],{'file_path':{'type':R(0xe5)}},d['file']),{'total':O[R(0xe4)][R(0xe2)],'time':Date['now']()-n,'rows':O[R(0xe4)]};}const w=h[R(0xe6)](Z),y=w['relations']?.[u];if(!y?.['foreignKey']||!y['resource']&&!y['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+u+'\x22\x20requires\x20a\x20project/provider\x20implementation');const Q=y['resource']?h[R(0xe6)](y[R(0xe7)]):undefined,F=y[R(0xe8)]??Q['table'],B=Q?.[R(0xe9)]??'id',K=y['fields']?.[R(0xe2)]?y['fields'][R(0xea)](qi)['join'](',\x20'):'*',g='SELECT\x20'+K+'\x20FROM\x20'+qt(F)+R(0xeb)+qi(B)+'\x20=\x20(select\x20'+qi(y['foreignKey'])+R(0xec)+qt(w['table'])+R(0xed)+qi(w['key'])+R(0xee),s=await d['pg'][R(0xef)](g,[D,X,Y]);return Q&&(await addDictionaryLookupData(s['rows'],Q['fields'],d[R(0xf0)]),await addTableLookupData(s[R(0xe4)],Q[R(0xf1)],d['pg']),addFileToken(s[R(0xe4)],Q['fields'],d['file'])),{'limit':X,'offset':Y,'total':s[R(0xe4)]['length'],'time':Date['now']()-n,'rows':s['rows']??null};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAsChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function v(){const g=['min','max','filter','isFinite','SELECT\x20','sql','length','query','dictionary','rowCount'];v=function(){return g;};return v();}import{buildFilters}from'../utils/filters.js';function S(d,h){d=d-0x100;const p=v();let Z=p[d];return Z;}import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFind(d,h){return async function p({name:Z,query:query={},user:D}){const K=S,u=Date['now'](),n=h['get'](Z);assertOperation(n,'read',D);const X=Math[K(0x100)](Math['max'](query['limit']??0x14,0x1),0xc8),Y=Math[K(0x101)](query['offset']??0x0,0x0),w=buildFilters(n,query[K(0x102)],0x1,d['pg']),y=buildSort(n,query['sort']);if(!Number[K(0x103)](X)||!Number['isFinite'](Y))throw new ValidationError('Invalid\x20pagination');const Q=K(0x104)+readableFields(n)['join'](',\x20')+'\x20'+('FROM\x20'+qt(n['table']))+(''+w[K(0x105)]+y+'\x20')+('LIMIT\x20$'+(w['values'][K(0x106)]+0x1)+'\x20')+('OFFSET\x20$'+(w['values']['length']+0x2)),F=await d['pg'][K(0x107)](Q,[...w['values'],X,Y]),B=F['rows'];return await addDictionaryLookupData(B,n['fields'],d[K(0x108)]),await addTableLookupData(B,n['fields'],d['pg']),addFileToken(B,n['fields'],d['file']),{'limit':X,'offset':Y,'total':F[K(0x109)],'time':Date['now']()-u,'rows':B};};}
|
|
@@ -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,CAUlK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function v(){const K=['foreignKey','Relation\x20update\x20is\x20not\x20configured:\x20','resource'];v=function(){return K;};return v();}import{UnsupportedError}from'../../../errors.js';function S(d,h){d=d-0x1b5;const p=v();let Z=p[d];return Z;}import{createUpdate}from'./update.js';export function createUpdateRelation(d,h){const p=createUpdate(d,h);return async function Z({name:D,id:u,relation:n,relationId:X,data:Y,user:w},y){const B=S,Q=h['get'](D),F=Q['relations']?.[n];if(!F?.['resource']||!F[B(0x1b5)])throw new UnsupportedError(B(0x1b6)+n);return p({'name':F[B(0x1b7)],'id':X,'data':Y,'user':w},y);};}
|
|
@@ -1,9 +1,12 @@
|
|
|
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
|
+
};
|
|
10
|
+
export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, }: UpdateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
11
|
+
export {};
|
|
9
12
|
//# 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;CACrB,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+BAE8B,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA4C1H"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';function v(){const O=['length','map','SET\x20','RETURNING\x20','rows','table','write','module','name','update'];v=function(){return O;};return v();}function S(d,h){d=d-0x1aa;const p=v();let Z=p[d];return Z;}import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(d,h){return async function p({name:Z,id:D,data:u,user:n},X){const M=S,Y=h['get'](Z);assertOperation(Y,'update',n);const w=writableData(Y,u);if(!w[M(0x1aa)])throw new ValidationError('No\x20writable\x20fields');const y=X?.['pg']??d['pg'];validateInputData({'resource':Y,'data':u,'update':!![]}),delete u['user_type'];const Q=w[M(0x1ab)](([g],s)=>qi(g)+'\x20=\x20$'+(s+0x1)),F=[...w[M(0x1ab)](([,g])=>g),D],B=await y['query']('UPDATE\x20'+qt(Y['table'])+'\x20'+(M(0x1ac)+Q['join'](',\x20')+'\x20')+('WHERE\x20'+qi(Y['key'])+'\x20=\x20$'+(w['length']+0x1)+'\x20')+(M(0x1ad)+readableFields(Y)['join'](',\x20')),F),K=B[M(0x1ae)][0x0];if(!K)throw new NotFoundError(Z+':'+D);return clearTableLookupCache(Y[M(0x1af)],y),await(X?.['audit']??d['audit'])?.[M(0x1b0)]({'userId':n?.['id'],'module':Y[M(0x1b1)],'resource':Y[M(0x1b2)],'resourceId':D,'action':M(0x1b3),'fields':Object['keys'](u)}),K;};}
|
|
@@ -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
|
+
import{qi,qt}from'./sql.js';function S(d,h){d=d-0x11c;const p=v();let Z=p[d];return Z;}const requestedIndexes=new WeakMap();function v(){const y=['get','set','has','split','public','replace','rowCount','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20',')\x20text_pattern_ops)','\x20USING\x20'];v=function(){return y;};return v();}export function autoIndex(d,h,p='btree',Z){const Y=S,D=requestedIndexes[Y(0x11c)](Z)??new Set();requestedIndexes[Y(0x11d)](Z,D);const u=d+':'+h+':'+p;if(D[Y(0x11e)](u))return;D['add'](u),void ensureIndex(d,h,p,Z)['catch'](()=>{D['delete'](u);});}async function ensureIndex(d,h,p,Z){const w=S,D=d[w(0x11f)]('.'),u=D['length']===0x2?D[0x0]:w(0x120),n=(d+'_'+h+'_'+p+'_idx')[w(0x121)](/[^A-Za-z0-9_]/g,'_'),X=await Z['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[u,n]);if(X[w(0x122)])return;if(p==='text'){await Z['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await Z['query'](w(0x123)+qi(n+'_l')+'\x20ON\x20'+qt(d)+'\x20USING\x20btree\x20(lower('+qi(h)+w(0x124)),await Z['query'](w(0x123)+qi(n)+'\x20ON\x20'+qt(d)+'\x20USING\x20gin\x20(lower('+qi(h)+')\x20gin_trgm_ops)');return;}await Z['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(n)+'\x20ON\x20'+qt(d)+w(0x125)+p+'\x20('+qi(h)+')');}
|
|
@@ -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';function S(d,h){d=d-0x163;const p=v();let Z=p[d];return Z;}export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:d,data:h,update:update=![]})=>{const D=S;for(const [p,Z]of Object['entries'](d['fields'])){if(Z['required']&&Z['writable']!==![]&&(h[p]===undefined||h[p]===null)&&!update)throw new ValidationError(D(0x163)+p);if(Z[D(0x164)]&&Z[D(0x165)]!==![]&&Object[D(0x166)](h,p)&&(h[p]===undefined||h[p]===null)&&update)throw new ValidationError('Required\x20field:\x20'+p);if(Z['minLength']&&typeof h[p]==='string'&&h[p][D(0x167)]<Z['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+p);if(Z[D(0x168)]&&typeof h[p]==='string'&&h[p]['length']>Z['maxLength'])throw new ValidationError(D(0x169)+p);if(Z[D(0x16a)]&&typeof h[p]==='number'&&h[p]<Z['minimum'])throw new ValidationError(p+'\x20should\x20be\x20>=\x20'+Z['minimum']);if(Z['maximum']&&typeof h[p]===D(0x16b)&&h[p]>Z[D(0x16c)])throw new ValidationError(p+'\x20should\x20be\x20<=\x20'+Z['maximum']);if(Z['enum']&&h[p]&&!Z['enum'][D(0x16d)](h[p]))throw new ValidationError(p+D(0x16e)+Z['enum']['join'](',\x20')+')');if(Z['pattern']&&typeof h[p]==='string'&&!new RegExp(Z['pattern'])[D(0x16f)](h[p]))throw new ValidationError(p+D(0x170)+Z['pattern']+')');}};function v(){const u=['Required\x20field:\x20','required','writable','hasOwn','length','maxLength','maxLength\x20exceeded:\x20','minimum','number','maximum','includes','\x20should\x20be\x20one\x20of\x20(','test','\x20should\x20match\x20regular\x20expression\x20('];v=function(){return u;};return v();}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
|
-
|
|
1
|
+
const s=S;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';function S(d,h){d=d-0x15d;const p=v();let Z=p[d];return Z;}const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin',s(0x15d),s(0x15e),s(0x15f)]);export function parseFilterQuery(d){const M=s,h={...isRecord(d[M(0x160)])?d['filter']:{}};for(const [p,Z]of Object['entries'](d)){const D=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/[M(0x161)](p);if(!D)continue;const [,u,n]=D;if(!u)continue;if(!n){h[u]=Z;continue;}if(!filterOperators['has'](n))throw new ValidationError(M(0x162)+n);const X=isRecord(h[u])?h[u]:{};X[n]=(n==='in'||n==='nin')&&typeof Z==='string'?Z['split'](','):Z,h[u]=X;}return Object['keys'](h)[M(0x163)]?h:undefined;}export function buildFilters(d,h,p=0x1,Z){const O=s,D=[],u=[];for(const [n,X]of Object['entries'](h??{})){const Y=d['fields'][n];if(!Y||Y['filter']!==!![]&&Y['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+n);const w=qi(fieldColumn(d,n)),y=isRecord(X)?X:{'eq':X};for(const [Q,F]of Object['entries'](y)){if(!filterOperators[O(0x164)](Q))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+Q);if((Q==='like'||Q===O(0x15e))&&Y['type']!==O(0x165)&&Y['type']!==O(0x166))throw new ValidationError('Operator\x20'+Q+'\x20requires\x20a\x20text\x20field:\x20'+n);Z&&autoIndex(d[O(0x167)],fieldColumn(d,n),indexTypeFor(Y[O(0x168)],Q),Z);if(Q==='null'){D['push'](w+'\x20IS\x20'+(isTruthy(F)?'':'NOT\x20')+'NULL');continue;}if(Q==='in'||Q==='nin'){const g=Array[O(0x169)](F)?F:[F];if(g[O(0x163)]===0x0){D['push'](Q==='in'?O(0x16a):O(0x16b));continue;}u[O(0x16c)](g),D[O(0x16c)](w+'\x20'+(Q==='in'?'=\x20ANY':O(0x16d))+'($'+(p+u['length']-0x1)+')');continue;}const B={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':O(0x15d)},K='$'+(p+u[O(0x163)]);if(Q===O(0x15d)){u['push'](F+'%'),D['push']('lower('+w+O(0x16e)+K+')');continue;}u['push'](F),D['push'](w+'\x20'+B[Q]+'\x20'+K);}}return{'sql':D['length']?O(0x16f)+D['join'](O(0x170)):'','values':u};}function v(){const J=['like','ilike','null','filter','exec','Unsupported\x20filter\x20operator:\x20','length','has','string','text','table','type','isArray','FALSE','TRUE','push','<>\x20ALL',')\x20like\x20lower(','\x20WHERE\x20','\x20AND\x20','object','btree'];v=function(){return J;};return v();}function isRecord(d){const R=s;return typeof d===R(0x171)&&d!==null&&!Array[R(0x169)](d);}function isTruthy(d){return d===!![]||d==='true'||d==='1'||d===0x1;}function indexTypeFor(d,h){const E=s;if(h==='like'||h===E(0x15e))return'text';if(d==='geom'||d==='geometry')return'gist';return E(0x172);}
|
|
@@ -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';function v(){const n=['public','admin'];v=function(){return n;};return v();}import{getContext}from'../../../index.js';function S(d,h){d=d-0xff;const p=v();let Z=p[d];return Z;}export function assertOperation(d,h,p){const u=S,Z=getContext()['config'];if(Z['debug'])return;if(!d['operations']['includes'](h))throw new ForbiddenError(d['name']+'.'+h+'\x20is\x20disabled');if(d['access']!==u(0xff)&&p===undefined)throw new ForbiddenError('Authentication\x20required');if(d['access']==='admin'&&p?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p?.['type']!==u(0x100)){const D=(d['permission']??d['name'])+':'+h;if(!p?.['permissions']?.['includes'](D))throw new ForbiddenError('Missing\x20permission:\x20'+D);}}
|
|
@@ -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
|
+
function S(d,h){d=d-0x1bf;const p=v();let Z=p[d];return Z;}function v(){const w=['length','slice','sort','sortable','Field\x20is\x20not\x20sortable:\x20'];v=function(){return w;};return v();}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(d,h){const X=S;if(!h?.[X(0x1bf)])return'';typeof h==='string'&&(h=[h]);const p=h['map'](Z=>{const Y=X,D=Z['startsWith']('-'),u=D?Z[Y(0x1c0)](0x1):Z,n=d['fields'][u];if(!n||n[Y(0x1c1)]!==!![]&&n[Y(0x1c2)]!==!![])throw new ValidationError(Y(0x1c3)+u);return qi(fieldColumn(d,u))+'\x20'+(D?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+p['join'](',\x20');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const n=S;import{ValidationError}from'../../../errors.js';function v(){const y=['replace','Unknown\x20field:\x20','column','fields','\x20AS\x20','writable'];v=function(){return y;};return v();}export const quoteIdentifier=d=>'\x22'+d[n(0x171)](/"/g,'\x22\x22')+'\x22';export const quoteTable=d=>d['split']('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(d,h){const X=n;if(h===d['key'])return d['key'];const p=d['fields'][h];if(!p)throw new ValidationError(X(0x172)+h);return p[X(0x173)]??h;}export function readableFields(d){const Y=n,h=Object['entries'](d[Y(0x174)])['filter'](([,p])=>p['read']!==![]&&p['readable']!==![])['map'](([p,Z])=>quoteIdentifier(Z['column']??p)+Y(0x175)+quoteIdentifier(p));return!d['fields'][d['key']]&&h['unshift'](quoteIdentifier(d['key'])),h;}function S(d,h){d=d-0x171;const p=v();let Z=p[d];return Z;}export function writableData(d,h){const w=n,p=[];for(const [Z,D]of Object['entries'](h)){const u=d[w(0x174)][Z];if(!u||u['write']===![]||u[w(0x176)]===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+Z);p['push']([u[w(0x173)]??Z,D]);}return p;}export const qi=quoteIdentifier;export const qt=quoteTable;
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(d,h){d=d-0x90;const p=v();let Z=p[d];return Z;}const h=S,getIP=d=>(d[h(0x90)]?.['x-real-ip']||d['headers']?.[h(0x91)]||d['ip']||d[h(0x92)]?.['remoteAddress']||'')['split'](':')['pop']();function v(){const p=['headers','x-forwarded-for','connection'];v=function(){return p;};return v();}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{};
|