@opengis/fcore 0.0.1-beta.2 → 0.0.1-beta.21
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 +73 -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
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function addDictionaryLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], dictionary: ResourceDependencies["dictionary"]): Promise<Record<string, unknown>[]>;
|
|
3
|
+
//# sourceMappingURL=add-dictionary-lookup-data.d.ts.map
|
|
@@ -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();function g(){const I=['get','length','text','icon','revision'];g=function(){return I;};return g();}async function getDictionaryIndexes(n,k){const a=r,Z=dictionaryIndexesCache[a(0xde)](k)??new Map(),K=dictionaryRevisionsCache[a(0xde)](k)??new Map();dictionaryIndexesCache['set'](k,Z),dictionaryRevisionsCache['set'](k,K);const d=n['filter'](B=>K['get'](B)!==k['revision'](B));if(d[a(0xdf)]===0x0)return Z;const J=await Promise['all'](d['map'](async B=>{const H=a;if(!k['has'](B))return[B,new Map()];const l=await k['get'](B),f=new Map();for(const R of l){const Q=R['code']??R['id'];if(Q==null)continue;f['set'](String(Q),{'id':Q,'text':R['name']??R[H(0xe0)],...R['color']!==undefined?{'color':R['color']}:{},...R[H(0xe1)]!==undefined?{'icon':R[H(0xe1)]}:{}});}return[B,f];}));for(const [B,l]of J){Z['set'](B,l),K['set'](B,k[a(0xe2)](B));}return Z;}function r(n,k){n=n-0xde;const Z=g();let K=Z[n];return K;}export async function addDictionaryLookupData(n,k,Z){const A=r;if(!Z||n['length']===0x0)return n;const K=Object['entries'](k)['flatMap'](([J,B])=>{const l=B['dictionary'];return l?[{'field':J,'dictionaryName':l}]:[];});if(K['length']===0x0)return n;const d=await getDictionaryIndexes([...new Set(K['map'](({dictionaryName:J})=>J))],Z);for(const J of n){for(const {field:B,dictionaryName:l}of K){const f=J[B];J[B+'_data']=f==null?null:d['get'](l)?.[A(0xde)](String(f))??null;}}return n;}
|
|
@@ -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
|
+
export function addFileToken(n,k,Z){const l=r;if(!Z||n['length']===0x0)return n;const K=Object[l(0x1b5)](k)['filter'](([,d])=>d['type']==='file')['map'](([d])=>d);for(const d of n){for(const J of K){const B=d[J];typeof B===l(0x1b6)&&B['length']>0x0&&(d[J]=Z['create'](B));}}return n;}function r(n,k){n=n-0x1b5;const Z=g();let K=Z[n];return K;}function g(){const f=['entries','string'];g=function(){return f;};return g();}
|
|
@@ -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';const tableLookupCache=new WeakMap();function g(){const C=['get','flatMap','string','value','text','set','map','length','table','has','_data'];g=function(){return C;};return g();}function r(n,k){n=n-0x1eb;const Z=g();let K=Z[n];return K;}export function clearTableLookupCache(n,k){const Z=tableLookupCache['get'](k);if(!Z)return;for(const K of Z['keys']()){K['startsWith'](n+':')&&Z['delete'](K);}}export async function addTableLookupData(n,k,Z){const p=r;if(!Z||n['length']===0x0)return n;const K=tableLookupCache[p(0x1eb)](Z)??new Map();tableLookupCache['set'](Z,K);const d=Object['entries'](k)[p(0x1ec)](([J,B])=>{const {table:l,value:value='id',text:text='name'}=B['lookup']??{};return l?[{'field':J,'table':l,'value':value,'text':text}]:[];});for(const J of d){const B=new Map();for(const Q of n){const a=Q[J['field']];(typeof a===p(0x1ed)||typeof a==='number')&&B['set'](String(a),a);}const l=J['table']+':'+J[p(0x1ee)]+':'+J[p(0x1ef)],f=K['get'](l)??new Map();K[p(0x1f0)](l,f);const R=[...B['entries']()]['filter'](([H])=>!f['has'](H))[p(0x1f1)](([,H])=>H);if(R[p(0x1f2)]>0x0){const H=await Z['query']('SELECT\x20'+qi(J[p(0x1ee)])+'\x20AS\x20id,\x20'+qi(J[p(0x1ef)])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(J[p(0x1f3)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(J['value'])+'\x20=\x20ANY($1)',[R]);for(const A of H['rows']){f['set'](String(A['id']),A);}for(const I of R){!f[p(0x1f4)](String(I))&&f[p(0x1f0)](String(I),null);}}for(const O of n){const m=O[J['field']];O[J['field']+p(0x1f5)]=m==null?null:f['get'](String(m))??null;}}return n;}
|
|
@@ -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,CA+DhI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';function g(){const p=['notes','files','query','INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*','foreignKey','table','\x22\x20requires\x20a\x20project/provider\x20implementation','Relation\x20update\x20is\x20not\x20configured:\x20'];g=function(){return p;};return g();}import{createCreate}from'./create.js';function r(n,k){n=n-0x1df;const Z=g();let K=Z[n];return K;}export function createCreateRelation(n,k){const Z=createCreate(n,k);return async function K({name:d,id:J,relation:B,data:l,user:f},R){const m=r,Q=R?.['pg']??n['pg'],a=k['get'](d);if(['notes','files']['includes'](B)&&!a['capabilities']?.['includes'](B))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+B+'\x22\x20requires\x20a\x20capabilities\x20\x22'+B+'\x22');if(B===m(0x1df)){const I=await Q['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[d,String(J),l?.['body']]);return I['rows'][0x0];}if(B===m(0x1e0)){const O=await Q[m(0x1e1)](m(0x1e2),[d,String(J),l?.['filePath'],l?.['size']??null]);return O['rows'][0x0];}const H=a['relations']?.[B];if(!H?.[m(0x1e3)]||!H['resource']&&!H[m(0x1e4)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+B+m(0x1e5));if(!l)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+l);if(!H['resource'])throw new UnsupportedError(m(0x1e6)+B);l[H['foreignKey']]=J;const A=await Z({'name':H['resource'],'data':l??{},'user':f});return A;};}
|
|
@@ -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,CA4CtH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function g(){const C=['get','push','No\x20writable\x20fields','join','name','key'];g=function(){return C;};return g();}function r(n,k){n=n-0x64;const Z=g();let K=Z[n];return K;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(n,k){return async function Z({name:K,data:d,user:J},B){const p=r,l=k[p(0x64)](K);assertOperation(l,'create',J),validateInputData({'resource':l,'data':d});const f=writableData(l,d);l['fields']['created_at']&&f['push'](['created_at',new Date()]);l['fields']['created_by']&&f[p(0x65)](['created_by',J?.['id']]);if(!f['length'])throw new ValidationError(p(0x66));const R=f['map'](([O])=>qi(O)),Q=f['map']((O,m)=>'$'+(m+0x1)),a=f['map'](([,O])=>O),H=B?.['pg']??n['pg'],A=await H['query']('INSERT\x20INTO\x20'+qt(l['table'])+'\x20('+R['join'](',\x20')+')\x20'+('VALUES\x20('+Q[p(0x67)](',\x20')+')\x20')+'RETURNING\x20*',a),I=A['rows'][0x0];return clearTableLookupCache(l['table'],H),await(B?.['audit']??n['audit'])?.['write']({'userId':J?.['id'],'module':l['module'],'resource':l[p(0x68)],'resourceId':I[l[p(0x69)]],'action':'create','fields':Object['keys'](d)}),I;};}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the delete relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
import type { AppContext } from "../../../context.js";
|
|
7
|
+
type DeleteRelationParams = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
relation: string;
|
|
11
|
+
relationId: string | number;
|
|
12
|
+
user?: ResourceUser;
|
|
13
|
+
};
|
|
14
|
+
export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, user, }: DeleteRelationParams, ctx?: AppContext) => Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=delete-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+CAIsD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAqCvJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(n,k){n=n-0xca;const Z=g();let K=Z[n];return K;}import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';export function createDeleteRelation(n,k){const Z=createRemove(n,k);return async function K({name:d,id:J,relation:B,relationId:l,user:f},R){const I=r,Q=R?.['pg']??n['pg'],a=k[I(0xca)](d);if(['notes','files']['includes'](B)&&!a['capabilities']?.[I(0xcb)](B))throw new UnsupportedError(I(0xcc)+B+'\x22\x20requires\x20a\x20capabilities\x20\x22'+B+'\x22');if(B===I(0xcd))return await Q['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[l,d,String(J)]),{'success':!![]};if(B===I(0xce))return await Q['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[l,d,String(J)]),{'success':!![]};const H=a['relations']?.[B];if(!H?.['resource']||!H['foreignKey'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+B+'\x22\x20requires\x20a\x20project/provider\x20implementation');const A=await Z({'name':H['resource'],'id':l,'user':f,'where':{'column':H['foreignKey'],'value':J}},R);return{'success':A};};}function g(){const O=['get','includes','Generic\x20Resource\x20relation\x20\x22','notes','files'];g=function(){return O;};return g();}
|
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type RemoveParams = {
|
|
7
8
|
name: string;
|
|
8
9
|
id: string | number;
|
|
9
10
|
user?: ResourceUser;
|
|
10
|
-
|
|
11
|
+
where?: {
|
|
12
|
+
column: string;
|
|
13
|
+
value: string | number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function createRemove(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, where, }: RemoveParams, ctx?: AppContext) => Promise<boolean>;
|
|
17
|
+
export {};
|
|
11
18
|
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAE+B,YAAY,QAAQ,UAAU,sBAoCxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function g(){const I=['get','delete','WHERE\x20','value','column','length','module','name'];g=function(){return I;};return g();}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function r(n,k){n=n-0x1d2;const Z=g();let K=Z[n];return K;}export function createRemove(n,k){return async function Z({name:K,id:d,user:J,where:B},l){const A=r,f=k[A(0x1d2)](K);assertOperation(f,A(0x1d3),J);const R=l?.['pg']??n['pg'],Q=[d];let a=A(0x1d4)+qi(f['key'])+'\x20=\x20$1';B&&(Q['push'](B[A(0x1d5)]),a+='\x20AND\x20'+qi(B[A(0x1d6)])+'\x20=\x20$'+Q[A(0x1d7)]);f['where']&&(a+='\x20AND\x20('+f['where']+')');const H=await R['query']('DELETE\x20FROM\x20'+qt(f['table'])+'\x20'+a,Q);if((H['rowCount']??0x0)>0x0)clearTableLookupCache(f['table'],R);if((H['rowCount']??0x0)>0x0)await(l?.['audit']??n['audit'])?.['write']({'module':f[A(0x1d8)],'resource':f[A(0x1d9)],'resourceId':d,'action':'delete'});return(H['rowCount']??0x0)>0x0;};}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the find one operation of the generic Resource CRUD engine.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
|
|
6
|
+
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, query, user, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
id: string | number;
|
|
9
|
+
query?: ResourceQuery;
|
|
9
10
|
user?: ResourceUser;
|
|
10
11
|
}) => Promise<Record<string, unknown> | null>;
|
|
11
12
|
//# sourceMappingURL=find-one.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,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,6CAsGF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function r(n,k){n=n-0x166;const Z=g();let K=Z[n];return K;}import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';function g(){const z=['key','integer','Invalid\x20id:\x20','where','SELECT\x20','\x20FROM\x20','\x20LIMIT\x201','fields','split','junctionTable','junctionForeignKey','foreignKey','resource','table','targetKey','\x20t\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20','\x20j\x20ON\x20j.','junctionLocalKey','query','dictionary','time','now'];g=function(){return z;};return g();}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(n,k){return async function Z({name:K,id:d,query:query={},user:J}){const q=r,B=Date['now'](),l=k['get'](K);assertOperation(l,'read',J);if(l['fields'][l[q(0x166)]]?.['type']===q(0x167)&&!Number['isInteger'](Number(d)))throw new ValidationError(q(0x168)+d+'\x20name:'+K);const f=l['joins']?.['map'](A=>A['sql']+'\x20')['join']('\x20')||'',R=l[q(0x169)]?'\x20AND\x20('+l['where']+')':'',Q=await n['pg']['query'](q(0x16a)+readableFields(l)['join'](',\x20')+q(0x16b)+qt(l['table'])+'\x20t\x20'+f+'\x20WHERE\x20'+qi(l['key'])+'=$1'+R+q(0x16c),[d]),a=Q['rows'][0x0];if(!a)return null;await addDictionaryLookupData([a],l['fields'],n['dictionary']),await addTableLookupData([a],l['fields'],n['pg']),addFileToken([a],l[q(0x16d)],n['file']);const H=Array['isArray'](query['include'])?query['include']:query['include']?.[q(0x16e)](',')??[];for(const A of H){const I=l['relations']?.[A];if(!I)throw new ValidationError('Unknown\x20relation:\x20'+A);const O=!!(I?.[q(0x16f)]&&I['junctionLocalKey']&&I[q(0x170)]);if(!I?.[q(0x171)]&&!O||!I[q(0x172)]&&!I['table'])throw new ValidationError('Invalid\x20relation:\x20'+A);const m=I['resource']?k['get'](I['resource']):undefined,p=I[q(0x173)]??m['table'],C=m?.['key']??'id',T=m?readableFields(m)['join'](',\x20'):'*',c=I[q(0x171)]?'SELECT\x20'+T+'\x20FROM\x20'+qt(p)+'\x20WHERE\x20'+(I[q(0x174)]||qi(C))+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(I['foreignKey'])+'\x20FROM\x20'+qt(l['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(l[q(0x166)])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)':q(0x16a)+T+q(0x16b)+qt(p)+q(0x175)+qt(I['junctionTable'])+q(0x176)+qi(I['junctionForeignKey'])+'\x20=\x20t.'+(I['junctionTargetKey']||qi(C))+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20j.'+qi(I[q(0x177)])+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(l['key'])+q(0x16b)+qt(l['table'])+'\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(l['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',b=(await n['pg'][q(0x178)](c,[d]))['rows'];m&&(await addDictionaryLookupData(b,m['fields'],n[q(0x179)]),await addTableLookupData(b,m[q(0x16d)],n['pg']),addFileToken(b,m[q(0x16d)],n['file'])),a[A]=b;}return a[q(0x17a)]=Date[q(0x17b)]()-B,a;};}
|
|
@@ -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,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CA6IjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function r(n,k){n=n-0x162;const Z=g();let K=Z[n];return K;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';function g(){const w=['offset','isFinite','get','relations','length','now','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','rows','foreignKey','localKey','table','\x22\x20requires\x20a\x20project/provider\x20implementation','fields','filter','read','item','join','joins','scope','\x20AND\x20(','\x20t\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20','\x20j\x20ON\x20j.','junctionTargetKey','\x20=\x20$1','\x20FROM\x20','\x20LIMIT\x20$2\x20OFFSET\x20$3','\x20=\x20$1\x20limit\x201)'];g=function(){return w;};return g();}export function createFindRelation(n,k){return async function Z({name:K,id:d,relation:J,query:query={}}){const j=r,B=Date['now'](),l=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),f=Math['max'](query[j(0x162)]??0x0,0x0);if(!Number[j(0x163)](l)||!Number['isFinite'](f))throw new ValidationError('Invalid\x20pagination');const R=k[j(0x164)](K),Q=R[j(0x165)]?.[J];if(['notes','files']['includes'](J)&&!R['capabilities']?.['includes'](J))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+J+'\x22\x20requires\x20a\x20capabilities\x20\x22'+J+'\x22');if(J==='notes'){const b=await n['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[K,String(d)]);return{'total':b['rows'][j(0x166)],'time':Date[j(0x167)]()-B,'rows':b['rows']};}if(J==='files'){const q=await n['pg']['query'](j(0x168),[K,String(d)]);return addFileToken(q['rows'],{'file_path':{'type':'file'}},n['file']),{'total':q[j(0x169)]['length'],'time':Date['now']()-B,'rows':q['rows']};}const a=!!(Q?.['junctionTable']&&Q['junctionLocalKey']&&Q['junctionForeignKey']);if(!Q||!a&&!Q[j(0x16a)]&&!Q[j(0x16b)]||!Q['resource']&&!Q[j(0x16c)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+J+j(0x16d));const H=Q['resource']?k['get'](Q['resource']):undefined,A=Q['table']??H[j(0x16c)],I=H?.['key']??'id',O=!a&&Object['keys'](H?.[j(0x16e)]??{})[j(0x16f)](z=>H?.[j(0x16e)][z]?.[j(0x170)]&&H?.['fields'][z]?.['scope']!==j(0x171))['map'](qi)['join'](',\x20'),m=Q['fields']?.[j(0x172)](',\x20')||O||'*';Q['foreignKey']&&autoIndex(A,Q['foreignKey'],'btree',n['pg']);const p=H?.[j(0x173)]?.['filter'](z=>z[j(0x174)]!=='item')['map'](z=>z['sql']+'\x20')['join']('\x20')||'',C=Q['where']?j(0x175)+Q['where']+')':'',T=(a?'SELECT\x20'+m+'\x20FROM\x20'+qt(A)+j(0x176)+p+j(0x177)+qt(Q['junctionTable'])+j(0x178)+qi(Q['junctionForeignKey'])+'\x20=\x20t.'+(Q[j(0x179)]||qi(I))+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20j.'+qi(Q['junctionLocalKey'])+j(0x17a)+C+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3':'')||(Q['foreignKey']?'SELECT\x20'+m+j(0x17b)+qt(A)+'\x20t\x20'+p+'\x20WHERE\x20t.'+qi(Q['foreignKey'])+'\x20=\x20$1'+C+j(0x17c):'SELECT\x20'+m+'\x20FROM\x20'+qt(A)+'\x20t\x20'+p+'\x20WHERE\x20t.'+qi(Q[j(0x16a)]||I)+'\x20=\x20(select\x20'+qi(Q[j(0x16b)])+'\x20FROM\x20'+qt(R['table'])+'\x20where\x20'+qi(R['key'])+j(0x17d)+C+j(0x17c)),c=await n['pg']['query'](T,[d,l,f]);return H&&(await addDictionaryLookupData(c['rows'],H['fields'],n['dictionary']),await addTableLookupData(c['rows'],H['fields'],n['pg']),addFileToken(c[j(0x169)],H['fields'],n['file'])),{'limit':l,'offset':f,'total':c[j(0x169)]['length'],'time':Date[j(0x167)]()-B,'rows':c[j(0x169)]??null};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAmDhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';function r(n,k){n=n-0x9f;const Z=g();let K=Z[n];return K;}function g(){const C=['now','sql','Invalid\x20pagination','fields','search','text','values','toLowerCase','\x20AND\x20','joins','join','table','\x20t\x20','LIMIT\x20$','OFFSET\x20$','query','rows','file','rowCount'];g=function(){return C;};return g();}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';import{autoIndex}from'../utils/auto-index.js';export function createFind(n,k){return async function Z({name:K,query:query={},user:d}){const p=r,J=Date[p(0x9f)](),B=k['get'](K);assertOperation(B,'read',d);const l=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),f=Math['max'](query['offset']??0x0,0x0),R=buildFilters(B,query['filter'],0x1,n['pg']);B['where']&&(R['sql']+=(R[p(0xa0)]?'\x20AND\x20':'\x20WHERE\x20')+('('+B['where']+')'));const Q=buildSort(B,query['sort']);if(!Number['isFinite'](l)||!Number['isFinite'](f))throw new ValidationError(p(0xa1));const a=B['searchable']||Object['keys'](B['fields'])['filter'](m=>B[p(0xa2)][m]?.['searchable']);query[p(0xa3)]&&a['length']&&(a['map'](m=>autoIndex(B['table'],m,p(0xa4),n['pg'])),R[p(0xa5)]['push'](query['search'][p(0xa6)]()+'%'),R[p(0xa0)]+=(R['sql']?p(0xa7):'\x20WHERE\x20')+('\x20('+a?.['map'](m=>'lower('+qt(m)+')\x20LIKE\x20$'+R['values']['length'])['join']('\x20OR\x20')+')'));const H=B[p(0xa8)]?.['filter'](m=>m['scope']!=='item')['map'](m=>m['sql']+'\x20')[p(0xa9)]('\x20')||'',A='SELECT\x20'+readableFields(B,'all')['join'](',\x20')+'\x20'+('FROM\x20'+qt(B[p(0xaa)])+p(0xab))+(H+'\x20'+R['sql']+'\x20'+Q+'\x20')+(p(0xac)+(R[p(0xa5)]['length']+0x1)+'\x20')+(p(0xad)+(R['values']['length']+0x2)),I=await n['pg'][p(0xae)](A,[...R[p(0xa5)],l,f]),O=I[p(0xaf)];return await addDictionaryLookupData(O,B['fields'],n['dictionary']),await addTableLookupData(O,B[p(0xa2)],n['pg']),addFileToken(O,B['fields'],n[p(0xb0)]),{'limit':l,'offset':f,'total':I[p(0xb1)],'time':Date['now']()-J,'rows':O};};}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
+
import type { AppContext } from "../../../context.js";
|
|
4
|
+
type UpdateRelationParams = {
|
|
5
|
+
name: string;
|
|
6
|
+
id: string | number;
|
|
7
|
+
relation: string;
|
|
8
|
+
relationId: string | number;
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
user?: ResourceUser;
|
|
11
|
+
};
|
|
12
|
+
export declare function createUpdateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, data, user, }: UpdateRelationParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=update-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update-relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,qDAI4D,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAclK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(n,k){n=n-0x11b;const Z=g();let K=Z[n];return K;}function g(){const I=['relations'];g=function(){return I;};return g();}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(n,k){const Z=createUpdate(n,k);return async function K({name:d,id:J,relation:B,relationId:l,data:f,user:R},Q){const A=r,a=k['get'](d),H=a[A(0x11b)]?.[B];if(!H?.['resource']||!H['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+B);if(Object['hasOwn'](f,H['foreignKey'])&&f[H['foreignKey']]!==J)throw new ValidationError('Cannot\x20change\x20relation:\x20'+H['foreignKey']);return Z({'name':H['resource'],'id':l,'data':f,'user':R,'where':{'column':H['foreignKey'],'value':J}},Q);};}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
2
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
-
|
|
3
|
+
import { AppContext } from "../../../context.js";
|
|
4
|
+
type UpdateParams = {
|
|
4
5
|
name: string;
|
|
5
6
|
id: string | number;
|
|
6
7
|
data: Record<string, unknown>;
|
|
7
8
|
user?: ResourceUser;
|
|
8
|
-
|
|
9
|
+
where?: {
|
|
10
|
+
column: string;
|
|
11
|
+
value: string | number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, where, }: UpdateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
15
|
+
export {};
|
|
9
16
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,sCAEqC,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2DjI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';function g(){const c=['fields','updated_by','user_type','\x20=\x20$','value','length','keys','join','audit','write'];g=function(){return c;};return g();}function r(n,k){n=n-0x1a6;const Z=g();let K=Z[n];return K;}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(n,k){return async function Z({name:K,id:d,data:J,user:B,where:l},f){const T=r,R=k['get'](K);assertOperation(R,'update',B);const Q=writableData(R,J);if(!Q['length'])throw new ValidationError('No\x20writable\x20fields');const a=f?.['pg']??n['pg'];validateInputData({'resource':R,'data':J,'update':!![]});R['fields']['updated_at']&&Q['push'](['updated_at',new Date()]);R[T(0x1a6)][T(0x1a7)]&&Q['push'](['updated_by',B?.['id']]);delete J[T(0x1a8)];const H=Q['map'](([p],C)=>qi(p)+T(0x1a9)+(C+0x1)),A=[...Q['map'](([,p])=>p),d];let I='WHERE\x20'+qi(R['key'])+'\x20=\x20$'+A['length'];l&&(A['push'](l[T(0x1aa)]),I+='\x20AND\x20'+qi(l['column'])+'\x20=\x20$'+A[T(0x1ab)]);R['where']&&(I+='\x20AND\x20('+R['where']+')');const O=await a['query']('UPDATE\x20'+qt(R['table'])+'\x20'+('SET\x20'+H['join'](',\x20')+'\x20')+(I+'\x20')+('RETURNING\x20'+Object[T(0x1ac)](J)['map'](qi)[T(0x1ad)](',\x20')),A),m=O['rows'][0x0];if(!m)throw new NotFoundError(K+':'+d);return clearTableLookupCache(R['table'],a),await(f?.[T(0x1ae)]??n['audit'])?.[T(0x1af)]({'userId':B?.['id'],'module':R['module'],'resource':R['name'],'resourceId':d,'action':'update','fields':Object['keys'](J)}),m;};}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from "../../pg.js";
|
|
2
|
+
export type AutoIndexType = "text" | "btree" | "gist";
|
|
3
|
+
export declare function autoIndex(table: string, column: string, type: AutoIndexType | undefined, pg: DatabaseAdapter): void;
|
|
4
|
+
//# sourceMappingURL=auto-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/auto-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAItD,wBAAgB,SAAS,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,YAAU,EAC7B,EAAE,EAAE,eAAe,GACpB,IAAI,CAWN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(n,k){n=n-0x102;const Z=g();let K=Z[n];return K;}const f=r;import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(n,k,Z=f(0x102),K){const R=f,d=requestedIndexes['get'](K)??new Set();requestedIndexes['set'](K,d);const J=n+':'+k+':'+Z;if(d['has'](J))return;d['add'](J),void ensureIndex(n,k,Z,K)[R(0x103)](()=>{d['delete'](J);});}async function ensureIndex(n,k,Z,K){const Q=f,d=n['split']('.'),J=d['length']===0x2?d[0x0]:'public',B=(n+'_'+k+'_'+Z+'_idx')[Q(0x104)](/[^A-Za-z0-9_]/g,'_'),l=await K[Q(0x105)](Q(0x106),[J,B]);if(l[Q(0x107)])return;if(Z==='text'){await K['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await K['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(B+'_l')+Q(0x108)+qt(n)+Q(0x109)+qi(k)+')\x20text_pattern_ops)'),await K[Q(0x105)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(B)+'\x20ON\x20'+qt(n)+'\x20USING\x20gin\x20(lower('+qi(k)+')\x20gin_trgm_ops)');return;}await K['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(B)+Q(0x108)+qt(n)+Q(0x10a)+Z+'\x20('+qi(k)+')');}function g(){const a=['btree','catch','replace','query','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','rowCount','\x20ON\x20','\x20USING\x20btree\x20(lower(','\x20USING\x20'];g=function(){return a;};return g();}
|
|
@@ -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 r(n,k){n=n-0x18c;const Z=g();let K=Z[n];return K;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:n,data:k,update:update=![]})=>{const d=r;for(const [Z,K]of Object['entries'](n['fields'])){if(K['required']&&K['writable']!==![]&&(k[Z]===undefined||k[Z]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+Z);if(K['required']&&K[d(0x18c)]!==![]&&Object[d(0x18d)](k,Z)&&(k[Z]===undefined||k[Z]===null)&&update)throw new ValidationError('Required\x20field:\x20'+Z);if(K['minLength']&&typeof k[Z]==='string'&&k[Z]['length']<K[d(0x18e)])throw new ValidationError('minLength\x20not\x20met:\x20'+Z);if(K[d(0x18f)]&&typeof k[Z]===d(0x190)&&k[Z][d(0x191)]>K[d(0x18f)])throw new ValidationError('maxLength\x20exceeded:\x20'+Z);if(K[d(0x192)]&&typeof k[Z]==='number'&&k[Z]<K['minimum'])throw new ValidationError(Z+'\x20should\x20be\x20>=\x20'+K['minimum']);if(K['maximum']&&typeof k[Z]==='number'&&k[Z]>K['maximum'])throw new ValidationError(Z+'\x20should\x20be\x20<=\x20'+K['maximum']);if(K['enum']&&k[Z]&&!K['enum'][d(0x193)](k[Z]))throw new ValidationError(Z+'\x20should\x20be\x20one\x20of\x20('+K['enum']['join'](',\x20')+')');if(K['pattern']&&typeof k[Z]==='string'&&!new RegExp(K[d(0x194)])[d(0x195)](k[Z]))throw new ValidationError(Z+'\x20should\x20match\x20regular\x20expression\x20('+K[d(0x194)]+')');}};function g(){const J=['writable','hasOwn','minLength','maxLength','string','length','minimum','includes','pattern','test'];g=function(){return J;};return g();}export{validateInputData};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provides Resource helpers for filters handling.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceContract } from '../resource.types.js';
|
|
5
|
-
export declare function
|
|
4
|
+
import type { ResourceContract, ResourceDependencies } from '../resource.types.js';
|
|
5
|
+
export declare function parseFilterQuery(query: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
6
|
+
export declare function buildFilters(resource: ResourceContract, filter: Record<string, unknown> | undefined, start?: number, pg?: ResourceDependencies['pg']): {
|
|
6
7
|
sql: string;
|
|
7
8
|
values: unknown[];
|
|
8
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AASnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA2BpG;AAED,wBAAgB,YAAY,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,KAAK,SAAI,EACT,EAAE,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC;;;EAgElC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function r(n,k){n=n-0x122;const Z=g();let K=Z[n];return K;}import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin','like','ilike','null']);export function parseFilterQuery(n){const m=r,k={...isRecord(n['filter'])?n['filter']:{}};for(const [Z,K]of Object['entries'](n)){const d=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](Z);if(!d)continue;const [,J,B]=d;if(!J)continue;if(!B){k[J]=K;continue;}if(!filterOperators['has'](B))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+B);const l=isRecord(k[J])?k[J]:{};l[B]=(B==='in'||B==='nin')&&typeof K==='string'?K['split'](','):K,k[J]=l;}return Object[m(0x122)](k)['length']?k:undefined;}export function buildFilters(n,k,Z=0x1,K){const p=r,d=[],J=[];for(const [B,l]of Object['entries'](k??{})){const f=n['fields'][B];if(!f||f[p(0x123)]!==!![]&&f[p(0x124)]!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+B);const R=qi(fieldColumn(n,B)),Q=isRecord(l)?l:{'eq':l};for(const [a,H]of Object['entries'](Q)){if(!filterOperators['has'](a))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+a);if((a===p(0x125)||a==='ilike')&&f['type']!=='string'&&f[p(0x126)]!=='text')throw new ValidationError('Operator\x20'+a+p(0x127)+B);K&&autoIndex(n[p(0x128)],fieldColumn(n,B),indexTypeFor(f['type'],a),K);if(a==='null'){d['push'](R+'\x20IS\x20'+(isTruthy(H)?'':'NOT\x20')+p(0x129));continue;}if(a==='in'||a===p(0x12a)){const O=Array['isArray'](H)?H:[H];if(O[p(0x12b)]===0x0){d[p(0x12c)](a==='in'?'FALSE':'TRUE');continue;}J[p(0x12c)](O),d['push'](R+'\x20'+(a==='in'?p(0x12d):'<>\x20ALL')+'($'+(Z+J['length']-0x1)+')');continue;}const A={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},I='$'+(Z+J['length']);if(a==='like'){J['push'](H+'%'),d['push']('lower('+R+')\x20like\x20lower('+I+')');continue;}J['push'](H),d['push'](R+'\x20'+A[a]+'\x20'+I);}}return{'sql':d['length']?'\x20WHERE\x20'+d['join']('\x20AND\x20'):'','values':J};}function isRecord(n){const C=r;return typeof n==='object'&&n!==null&&!Array[C(0x12e)](n);}function isTruthy(n){return n===!![]||n==='true'||n==='1'||n===0x1;}function indexTypeFor(n,k){const T=r;if(k==='like'||k==='ilike')return T(0x12f);if(n==='geom'||n==='geometry')return'gist';return'btree';}function g(){const c=['keys','filter','filterable','like','type','\x20requires\x20a\x20text\x20field:\x20','table','NULL','nin','length','push','=\x20ANY','isArray','text'];g=function(){return c;};return g();}
|
|
@@ -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 g(){const B=['config','debug','public','access','admin','permissions','Missing\x20permission:\x20'];g=function(){return B;};return g();}function r(n,k){n=n-0x123;const Z=g();let K=Z[n];return K;}import{getContext}from'../../../index.js';export function assertOperation(n,k,Z){const J=r,K=getContext()[J(0x123)];if(K[J(0x124)])return;if(!n['operations']['includes'](k))throw new ForbiddenError(n['name']+'.'+k+'\x20is\x20disabled');if(n['access']!==J(0x125)&&Z===undefined)throw new ForbiddenError('Authentication\x20required');if(n[J(0x126)]===J(0x127)&&Z?.['type']!==J(0x127))throw new ForbiddenError('Admin\x20access\x20required');if(Z?.['type']!=='admin'){const d=(n['permission']??n['name'])+':'+k;if(!Z?.[J(0x128)]?.['includes'](d))throw new ForbiddenError(J(0x129)+d);}}
|
|
@@ -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
|
+
function g(){const R=['map','DESC','join'];g=function(){return R;};return g();}function r(n,k){n=n-0x6b;const Z=g();let K=Z[n];return K;}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(n,k){const l=r;if(!k?.['length'])return'';typeof k==='string'&&(k=[k]);const Z=k[l(0x6b)](K=>{const f=l,d=K['startsWith']('-'),J=d?K['slice'](0x1):K,B=n['fields'][J];if(!B||B['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+J);return qi(fieldColumn(n,J))+'\x20'+(d?f(0x6c):'ASC');});return'\x20ORDER\x20BY\x20'+Z[l(0x6d)](',\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"}
|