@opengis/fcore 0.0.1-beta.1 → 0.0.1-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -3
- package/README.md +71 -71
- package/dist/config.d.ts +2 -10
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts +5 -5
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.d.ts +3 -0
- package/dist/modules/auth/adduser-cli.d.ts.map +1 -0
- package/dist/modules/auth/adduser-cli.js +2 -0
- package/dist/modules/auth/passwd-cli.d.ts +3 -0
- package/dist/modules/auth/passwd-cli.d.ts.map +1 -0
- package/dist/modules/auth/passwd-cli.js +2 -0
- package/dist/modules/auth/permission-cli.d.ts +3 -0
- package/dist/modules/auth/permission-cli.d.ts.map +1 -0
- package/dist/modules/auth/permission-cli.js +2 -0
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.d.ts +10 -1
- package/dist/modules/auth/schema.d.ts.map +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.d.ts +9 -0
- package/dist/modules/auth/services/change-password.d.ts.map +1 -0
- package/dist/modules/auth/services/change-password.js +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.d.ts +14 -0
- package/dist/modules/auth/services/registration.d.ts.map +1 -0
- package/dist/modules/auth/services/registration.js +1 -0
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.d.ts +3 -0
- package/dist/modules/file/mime.d.ts.map +1 -0
- package/dist/modules/file/mime.js +1 -0
- package/dist/modules/file/route.d.ts.map +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.d.ts +3 -0
- package/dist/modules/file/schema.d.ts.map +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.d.ts.map +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.d.ts +4 -6
- package/dist/modules/file/services/upload-file.d.ts.map +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts +0 -3
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +3 -0
- package/dist/modules/resource/schema.d.ts.map +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.d.ts +8 -2
- package/dist/modules/resource/services/create-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.d.ts +8 -1
- package/dist/modules/resource/services/delete-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +9 -2
- package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts +10 -4
- package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
- package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
- package/dist/modules/resource/services/update-resource-relation.js +1 -0
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.d.ts +2 -1
- package/dist/modules/system/route.d.ts.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +22 -1
- package/dist/modules/system/schema.d.ts.map +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.d.ts.map +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +14 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-access.js +1 -0
- package/dist/modules/system/services/get-api-list.d.ts +4 -1
- package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-system-log.d.ts +9 -5
- package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts +16 -0
- package/dist/modules/system/services/set-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-access.js +1 -0
- package/dist/modules/system/services/update-dictionary.d.ts +13 -0
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -0
- package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/index.js +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.d.ts +3 -0
- package/dist/plugins/auth/get-user-permissions.d.ts.map +1 -0
- package/dist/plugins/auth/get-user-permissions.js +1 -0
- package/dist/plugins/auth/index.d.ts +4 -0
- package/dist/plugins/auth/index.d.ts.map +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.d.ts +9 -0
- package/dist/plugins/auth/verifyUser.d.ts.map +1 -0
- package/dist/plugins/auth/verifyUser.js +1 -0
- package/dist/plugins/dictionary.d.ts +3 -0
- package/dist/plugins/dictionary.d.ts.map +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +3 -6
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/jwt.d.ts +4 -0
- package/dist/plugins/jwt.d.ts.map +1 -0
- package/dist/plugins/jwt.js +1 -0
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.d.ts +3 -0
- package/dist/plugins/logger/transport.d.ts.map +1 -0
- package/dist/plugins/logger/transport.js +1 -0
- package/dist/plugins/pg.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/index.js +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +65 -8
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
- package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
- package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-file-token.js +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
- package/dist/plugins/resource/services/create-relation.d.ts +16 -0
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -0
- package/dist/plugins/resource/services/create.d.ts +5 -2
- package/dist/plugins/resource/services/create.d.ts.map +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +18 -0
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/delete-relation.js +1 -0
- package/dist/plugins/resource/services/delete.d.ts +9 -2
- package/dist/plugins/resource/services/delete.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts +3 -2
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +13 -0
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/find-relation.js +1 -0
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/update-relation.d.ts +14 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- package/dist/plugins/resource/services/update.d.ts +9 -2
- package/dist/plugins/resource/services/update.d.ts.map +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.d.ts +8 -1
- package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/dist/type.d.ts +37 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +1 -0
- package/migrations/20260903120000_core_schema.sql +27 -21
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903130001_add_file_fields.sql +5 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/migrations/20260907090000_core_schema.sql +32 -0
- package/package.json +12 -7
- package/dist/modules/auth/index.d.ts +0 -9
- package/dist/modules/auth/index.d.ts.map +0 -1
- package/dist/modules/auth/index.js +0 -1
- package/dist/modules/auth/services/login.d.ts +0 -10
- package/dist/modules/auth/services/login.d.ts.map +0 -1
- package/dist/modules/auth/services/login.js +0 -1
- package/dist/modules/auth/services/logout.d.ts +0 -9
- package/dist/modules/auth/services/logout.d.ts.map +0 -1
- package/dist/modules/auth/services/logout.js +0 -1
- package/dist/modules/auth/services/verifyPassword.d.ts +0 -11
- package/dist/modules/auth/services/verifyPassword.d.ts.map +0 -1
- package/dist/modules/auth/services/verifyPassword.js +0 -1
- package/dist/modules/file/index.d.ts +0 -8
- package/dist/modules/file/index.d.ts.map +0 -1
- package/dist/modules/file/index.js +0 -1
- package/dist/modules/resource/index.d.ts +0 -20
- package/dist/modules/resource/index.d.ts.map +0 -1
- package/dist/modules/resource/index.js +0 -1
- package/dist/modules/resource/services/list-children.d.ts +0 -6
- package/dist/modules/resource/services/list-children.d.ts.map +0 -1
- package/dist/modules/resource/services/list-children.js +0 -1
- package/dist/modules/system/index.d.ts +0 -13
- package/dist/modules/system/index.d.ts.map +0 -1
- package/dist/modules/system/index.js +0 -1
- package/dist/modules/utils/get-user-permissions.d.ts +0 -3
- package/dist/modules/utils/get-user-permissions.d.ts.map +0 -1
- package/dist/modules/utils/get-user-permissions.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/plugins/dictionary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAMD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EA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AAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,GAAG,IAAI,CAAC;IACrE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,IAAI,OAAO,CACb,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAA;KAAE,CAAC,CACrE,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACvC;AAID,wBAAgB,gBAAgB,CAAC,EAC/B,EAAE,EACF,YAAiB,GAClB,EAAE,sBAAsB,GAAG,gBAAgB,CAkN3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function G(){const K=['empty\x20pg','Invalid\x20dictionary\x20name:\x20','items','Dictionary\x20already\x20registered:\x20','query','rows','length','database','Dictionary\x20not\x20found:\x20','checked','connect','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','custom','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','code','set','static','get','delete','has'];G=function(){return K;};return G();}function q(R,t){R=R-0x1ac;const X=G();let g=X[R];return g;}import{ConflictError,NotFoundError,ValidationError}from'../errors.js';const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;export function createDictionary({pg:R,dictionaries:dictionaries=[]}){const t=new Map(),X=new Map();let g,m;async function Z(){const o=q;if(g!==undefined)return g;if(!R)throw new Error(o(0x1ac));return m??=R['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20')['then'](O=>{const U=O['rows'][0x0]?.['table_name'];g=U==='dictionaries'?U:null;}),await m,g;}function z(O){const a=q;if(!dictionaryName['test'](O))throw new ValidationError(a(0x1ad)+O);}function l(O){const J=q;for(const U of Array['isArray'](O)?O:[O]){z(U['code']);if(!Array['isArray'](U[J(0x1ae)]))throw new ValidationError('Invalid\x20dictionary\x20items:\x20'+U['code']);if(t['has'](U['code']))throw new ConflictError(J(0x1af)+U['code']);t['set'](U['code'],{...U,'source':'static'});}}function y(O){return t['has'](O);}async function h(O){const F=q;z(O);const U=t['get'](O);if(U&&U['checked'])return U['items'];const e=await Z();if(!e)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const H=await R?.[F(0x1b0)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.code,\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[O]);if(H?.[F(0x1b1)]?.[F(0x1b2)]){const n=H?.[F(0x1b1)];return t['set'](O,{'code':O,'name':O,'items':n,'source':F(0x1b3),'checked':!![]}),n;}if(!U?.['items'])throw new NotFoundError(F(0x1b4)+O);return U[F(0x1b5)]=!![],U['items'];}async function P(O,U){const Y=q;z(O);if(!Array['isArray'](U))throw new ValidationError('Dictionary\x20items\x20must\x20be\x20an\x20array');const e=await Z();if(!e)throw new NotFoundError('Dictionary\x20table\x20not\x20found');if(!R)throw new Error('empty\x20pg');const H=await R[Y(0x1b6)]();try{await H['query']('BEGIN');const n=await H['query'](Y(0x1b7),[O,O,'fcore',Y(0x1b8),!![]]),S=n[Y(0x1b1)][0x0]['id'];await H[Y(0x1b0)](Y(0x1b9),[S]);for(const c of U){await H['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\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\x20\x20\x20\x20\x20\x20\x20\x20',[S,c[Y(0x1ba)],c['name'],c['parentId']??null]);}await H['query']('COMMIT');}catch(Q){await H['query']('ROLLBACK');throw Q;}finally{H['release']();}t[Y(0x1bb)](O,{'items':U,'code':O,'source':Y(0x1bc),'checked':!![]}),X['set'](O,(X[Y(0x1bd)](O)??0x0)+0x1);}function E(O){const A=q;return z(O),X['set'](O,(X[A(0x1bd)](O)??0x0)+0x1),t[A(0x1be)](O);}function C(O){const M=q;return X[M(0x1bd)](O)??0x0;}async function L(){const d=q,O=[...t['values']()]['map'](({code:H,name:n,source:S})=>({'code':H,'name':n??H,'source':S})),U=await Z();if(!U)return O;if(!R)throw new Error(d(0x1ac));const e=await R['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20');for(const H of e[d(0x1b1)]){!t[d(0x1bf)](H[d(0x1ba)])&&O['push'](H);}return O;}return l(dictionaries),{'register':l,'get':h,'put':P,'clear':E,'revision':C,'list':L,'has':y};}
|
package/dist/plugins/file.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the S3-compatible file storage adapter and its contracts.
|
|
3
3
|
*/
|
|
4
|
+
import type { Readable } from "node:stream";
|
|
4
5
|
export interface FileAdapter {
|
|
5
|
-
put(path: string,
|
|
6
|
+
put(path: string, body: Buffer | Readable): Promise<void>;
|
|
6
7
|
get(path: string): Promise<Buffer>;
|
|
7
8
|
exists(path: string): Promise<boolean>;
|
|
8
9
|
delete(path: string): Promise<void>;
|
|
9
10
|
create(path: string, ttl?: number): string;
|
|
10
|
-
verify(token: string):
|
|
11
|
-
}
|
|
12
|
-
export interface FileTokenPayload {
|
|
13
|
-
p: string;
|
|
14
|
-
exp: number;
|
|
11
|
+
verify(token: string): string;
|
|
15
12
|
}
|
|
16
13
|
export interface FileS3Config {
|
|
17
14
|
endpoint?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAKD,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAgCD,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAiF9D"}
|
package/dist/plugins/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';function q(R,t){R=R-0x1d4;const X=G();let g=X[R];return g;}import R from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function G(){const c=['startsWith','Invalid\x20file\x20path','replace','function','push','from','randomBytes','us-east-1','accessKey','bucket','Body','name','tokenTtl','Invalid\x20file\x20token','createHmac','length'];G=function(){return c;};return G();}function keyFor(t,X){const E=q;if(!X||X[E(0x1d4)]('/')||X['includes']('..'))throw new ValidationError(E(0x1d5));const g=X['replace'](/\\/g,'/')[E(0x1d6)](/^\/+/,''),m=(t??'')['replace'](/^\/+|\/+$/g,'');return m?m+'/'+g:g;}async function bodyToBuffer(t){const C=q;if(!t)return Buffer['alloc'](0x0);const X=t;if(typeof X['transformToByteArray']===C(0x1d7))return Buffer['from'](await X['transformToByteArray']());const g=[];for await(const m of t){g[C(0x1d8)](Buffer[C(0x1d9)](m));}return Buffer['concat'](g);}export function createFileS3(t){const L=q,X=t['tokenSecret']??process.env.FILE_TOKEN_SECRET??R[L(0x1da)](0x20)['toString']('hex'),g=new S3Client({'endpoint':t['endpoint'],'region':t['region']??L(0x1db),'forcePathStyle':t['forcePathStyle']??!![],'credentials':t['accessKeyId']||t[L(0x1dc)]?{'accessKeyId':t['accessKeyId']??t['accessKey'],'secretAccessKey':t['secretAccessKey']??t['secretKey']}:undefined}),m=Z=>keyFor(t['folder'],Z);return{async 'put'(Z,z){const O=L;await g['send'](new PutObjectCommand({'Bucket':t[O(0x1dd)],'Key':m(Z),'Body':z}));},async 'get'(Z){const U=L,z=await g['send'](new GetObjectCommand({'Bucket':t['bucket'],'Key':m(Z)}));return bodyToBuffer(z[U(0x1de)]);},async 'exists'(Z){const e=L;try{return await g['send'](new HeadObjectCommand({'Bucket':t[e(0x1dd)],'Key':m(Z)})),!![];}catch(z){const l=z;if(l['$metadata']?.['httpStatusCode']===0x194||l[e(0x1df)]==='NotFound')return![];throw z;}},async 'delete'(Z){const H=L;await g['send'](new DeleteObjectCommand({'Bucket':t[H(0x1dd)],'Key':m(Z)}));},'create'(Z,z=t[L(0x1e0)]??0xe10){const n=L,l=Buffer[n(0x1d9)](Z)['toString']('base64url'),y=R['createHmac']('sha256',X)['update'](l)['digest']('base64url');return l+'.'+y;},'verify'(Z){const S=L,[z,l]=Z['split']('.');if(!z||!l)throw new UnauthorizedError(S(0x1e1));const y=R[S(0x1e2)]('sha256',X)['update'](z)['digest'](),h=Buffer['from'](l,'base64url');if(y['length']!==h[S(0x1e3)]||!R['timingSafeEqual'](y,h))throw new UnauthorizedError('Invalid\x20file\x20token');const P=Buffer[S(0x1d9)](z,'base64url')['toString']('utf8');return P;}};}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
export * from "./logger/index.js";
|
|
5
5
|
export * from "./redis.js";
|
|
6
6
|
export * from "./pg.js";
|
|
7
|
+
export * from "./auth/index.js";
|
|
7
8
|
export * from "./file.js";
|
|
8
9
|
export * from "./dictionary.js";
|
|
9
10
|
export * from "./audit/index.js";
|
|
10
11
|
export * from "./resource/index.js";
|
|
12
|
+
export * from './jwt.js';
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from'./logger/index.js';export*from'./redis.js';export*from'./pg.js';export*from'./auth/index.js';export*from'./file.js';export*from'./dictionary.js';export*from'./audit/index.js';export*from'./resource/index.js';export*from'./jwt.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/plugins/jwt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,+BAY/D;AACD,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,qBAKjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function q(R,t){R=R-0x75;const X=G();let g=X[R];return g;}const Z=q;import{SignJWT,jwtVerify}from'jose';const secret=new TextEncoder()[Z(0x75)](process.env.AUTH_JWT_SECRET);function G(){const y=['encode','setProtectedHeader','message'];G=function(){return y;};return G();}export async function jwtSignToken(R){const z=Z;if(!process.env.AUTH_JWT_SECRET)return;const {id:t,type:X,permissions:g}=R,m=await new SignJWT({'id':t,'type':X,'permissions':g})[z(0x76)]({'alg':'HS256'})['setIssuedAt']()['setExpirationTime']('1h')['sign'](secret);return m;}export async function jwtVerifyToken(R){const t=await jwtVerify(R,secret,{'algorithms':['HS256']})['catch'](X=>{const l=q;console['log'](X[l(0x77)]);});return t?.['payload'];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import R from'pino';function q(R,t){R=R-0xe6;const X=G();let g=X[R];return g;}export function createLogger(){const l=q,t=R[l(0xe6)]({'target':'./transport.js'}),X=R({'level':'info','timestamp':R['stdTimeFunctions']['isoTime'],'base':{'service':l(0xe7)},'redact':{'paths':[l(0xe8),'password','token',l(0xe9),'refreshToken'],'censor':'[REDACTED]'}},t),g={};function m(Z,z){if(Z===undefined)return{...g};g[Z]=(g[Z]??0x0)+(z??0x1);}return Object['assign'](X,{'close':async()=>t[l(0xea)](),'metrics':m,'file':()=>X['info']['bind'](X)});}function G(){const y=['transport','app','req.headers.authorization','accessToken','end'];G=function(){return y;};return G();}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/plugins/logger/transport.js"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAuD5C,wBAA8B,eAAe,0DAM5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import R from'node:fs';import t from'node:path';function q(R,t){R=R-0x162;const X=G();let g=X[R];return g;}import X from'pino-abstract-transport';const LEVELS={0x1e:'info',0x28:'warn',0x32:'error',0x3c:'error'},streams=new Map();function getDate(){const l=q;return new Date()['toISOString']()[l(0x162)](0x0,0xa);}function createStream(g,m){const y=q,Z=t['resolve']('logs',g);return R[y(0x163)](Z,{'recursive':!![]}),R['createWriteStream'](t[y(0x164)](Z,m+y(0x165)),{'flags':'a'});}function getStream(g){const h=q,m=getDate(),Z=streams['get'](g);if(Z&&Z[h(0x166)]===m)return Z[h(0x167)];Z?.['stream']['end']();const z=createStream(g,m);return streams['set'](g,{'date':m,'stream':z}),z;}function G(){const C=['slice','mkdirSync','join','.log','date','stream','values','clear','level','file'];G=function(){return C;};return G();}function closeStreams(){const P=q;for(const {stream:g}of streams[P(0x168)]()){g['end']();}streams[P(0x169)]();}export default async function loggerTransport(){return X(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(g){const E=q;for await(const m of g){const Z=LEVELS[m[E(0x16a)]];if(!Z)continue;const z=getStream(m[E(0x16b)]||Z);delete m['file'],z['write'](JSON['stringify'](m)+'\x0a');}}
|
package/dist/plugins/pg.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface DatabaseConfig {
|
|
|
10
10
|
password: string;
|
|
11
11
|
max?: number;
|
|
12
12
|
}
|
|
13
|
-
export declare function createDatabase(config: DatabaseConfig):
|
|
14
|
-
export type DatabaseAdapter = pg.Pool
|
|
13
|
+
export declare function createDatabase(config: DatabaseConfig): DatabaseAdapter;
|
|
14
|
+
export type DatabaseAdapter = pg.Pool & {
|
|
15
|
+
transaction: <T>(callback: (client: pg.PoolClient) => Promise<T>) => Promise<T>;
|
|
16
|
+
};
|
|
15
17
|
//# sourceMappingURL=pg.d.ts.map
|
package/dist/plugins/pg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/plugins/pg.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/plugins/pg.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,cAAc,CAC1B,MAAM,EAAE,cAAc,mBAiDzB;AACD,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC,IAAI,GAAG;IACpC,WAAW,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CACnF,CAAC"}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import R from'pg';function q(R,t){R=R-0xc3;const X=G();let g=X[R];return g;}const {Pool}=R;export function createDatabase(t){const E=q,X=new Pool(t),g=X['query']['bind'](X);function m(Z,z){const l=new Error();return Error['captureStackTrace']?.(l,m),g(Z,z)['catch'](y=>{const h=y;h['sql']=Z,h['callerStack']=l['stack'];throw h;});}return X[E(0xc3)]=m,X['transaction']=async function(Z){const C=E,z=new Error();Error[C(0xc4)]?.(z,X['transaction']);const l=await X['connect']();try{await l[C(0xc3)]('BEGIN');const y=await Z(l);return await l['query']('COMMIT'),y;}catch(h){await l['query']('ROLLBACK');const P=h;P[C(0xc5)]=z['stack'];throw P;}finally{l[C(0xc6)]();}},X;}function G(){const L=['query','captureStackTrace','callerStack','release'];G=function(){return L;};return G();}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function q(R,t){R=R-0x1c0;const X=G();let g=X[R];return g;}import{Redis}from'ioredis';export function createRedis(R){const l=q,t=new Redis(R);return{'get':X=>t['get'](X),'set':(X,g,m,Z)=>{const z=q;if(Z)return t[z(0x1c0)](X,g,'EX',Z);if(typeof m==='number')return t['set'](X,g,'EX',m);return t['set'](X,g);},'del':X=>t['del'](X),'delete':X=>t[l(0x1c1)](X),'close':()=>t[l(0x1c2)](),'ping':()=>t['ping'](),'hincrby':(X,g,m)=>t[l(0x1c3)](X,g,m),'incrby':(X,g)=>t['incrby'](X,g)};}function G(){const y=['set','del','quit','hincrby'];G=function(){return y;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from'./resource.types.js';export*from'./resource.registry.js';export*from'./resource.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUhF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CA2BzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ResourceRegistry}from'./resource.registry.js';function q(R,t){R=R-0x108;const X=G();let g=X[R];return g;}function G(){const C=['get','list','bind'];G=function(){return C;};return G();}import{createFind}from'./services/find.js';import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(R){const E=q,t=new ResourceRegistry(),X=createFind(R,t),g=createFindOne(R,t),m=createCreate(R,t),Z=createUpdate(R,t),z=createRemove(R,t),l=createFindRelation(R,t),y=createCreateRelation(R,t),h=createUpdateRelation(R,t),P=createDeleteRelation(R,t);return{'register':t['register']['bind'](t),'has':t['has']['bind'](t),'get':t[E(0x108)]['bind'](t),'list':t[E(0x109)][E(0x10a)](t),'find':X,'findOne':g,'create':m,'update':Z,'delete':z,'findRelation':l,'createRelation':y,'updateRelation':h,'deleteRelation':P};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function q(R,t){R=R-0x1a4;const X=G();let g=X[R];return g;}const Z=q;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(R){const g=q;return R[g(0x1a4)]('.')['length']<=0x2&&R['split']('.')['every'](t=>ident['test'](t));}export class ResourceRegistry{['resources']=new Map();['register'](R){const m=q;for(const t of Array['isArray'](R)?R:[R]){this['validate'](t);if(this['resources']['has'](t['name']))throw new ConflictError(m(0x1a5)+t[m(0x1a6)]);this['resources']['set'](t['name'],t);}}[Z(0x1a7)](R){return this['resources']['has'](R);}[Z(0x1a8)](R){const t=this['resources']['get'](R);if(!t)throw new NotFoundError('Resource\x20not\x20registered:\x20'+R);return t;}[Z(0x1a9)](){const z=Z;return[...this[z(0x1aa)][z(0x1ab)]()];}['validate'](R){const l=Z;if(R['version']!==0x1||!ident['test'](R['name'])||!validQualified(R['table'])||!ident['test'](R['key']))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+R[l(0x1a6)]);for(const [t,X]of Object[l(0x1ac)](R['fields'])){if(!ident['test'](t)||!ident['test'](X[l(0x1ad)]??t))throw new ValidationError('Invalid\x20resource\x20field:\x20'+t);}}}function G(){const y=['split','Resource\x20already\x20registered:\x20','name','has','get','list','resources','values','entries','column'];G=function(){return y;};return G();}
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
import type { DatabaseAdapter } from "../pg.js";
|
|
5
5
|
import type { AppLogger } from "../logger/index.js";
|
|
6
6
|
import type { AuditPlugin } from "../audit/index.js";
|
|
7
|
+
import type { DictionaryPlugin } from "../dictionary.js";
|
|
8
|
+
import type { FileAdapter } from "../file.js";
|
|
7
9
|
import { User } from "../../context.js";
|
|
10
|
+
import type { AppContext } from "../../context.js";
|
|
8
11
|
export type ResourceOperation = "read" | "create" | "update" | "delete";
|
|
9
12
|
export interface ResourceFieldContract {
|
|
10
13
|
column?: string;
|
|
11
|
-
type?: "string" | "number" | "integer" | "boolean" | "date" | "json";
|
|
14
|
+
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid" | "file" | "geometry" | "geom";
|
|
12
15
|
read?: boolean;
|
|
13
16
|
write?: boolean;
|
|
14
17
|
readable?: boolean;
|
|
@@ -21,15 +24,30 @@ export interface ResourceFieldContract {
|
|
|
21
24
|
filter?: boolean;
|
|
22
25
|
sort?: boolean;
|
|
23
26
|
search?: boolean;
|
|
27
|
+
dictionary?: string;
|
|
24
28
|
lookup?: {
|
|
25
|
-
|
|
29
|
+
table: string;
|
|
30
|
+
value: string;
|
|
31
|
+
text: string;
|
|
32
|
+
fields?: string[];
|
|
26
33
|
};
|
|
34
|
+
enum?: string[] | number[];
|
|
35
|
+
minLength?: number;
|
|
36
|
+
maxLength?: number;
|
|
37
|
+
minimum?: number;
|
|
38
|
+
maximum?: number;
|
|
39
|
+
pattern?: string;
|
|
27
40
|
}
|
|
28
41
|
export interface ResourceRelationContract {
|
|
29
42
|
resource?: string;
|
|
30
43
|
table?: string;
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
localKey?: string;
|
|
45
|
+
foreignKey?: string;
|
|
46
|
+
type?: "one" | "many";
|
|
47
|
+
fields?: string[];
|
|
48
|
+
junctionTable?: string;
|
|
49
|
+
junctionLocalKey?: string;
|
|
50
|
+
junctionForeignKey?: string;
|
|
33
51
|
}
|
|
34
52
|
export interface ResourceContract {
|
|
35
53
|
version: 1;
|
|
@@ -39,6 +57,8 @@ export interface ResourceContract {
|
|
|
39
57
|
table: string;
|
|
40
58
|
key: string;
|
|
41
59
|
operations: ResourceOperation[];
|
|
60
|
+
searchable?: string[];
|
|
61
|
+
capabilities?: string[];
|
|
42
62
|
permission?: string;
|
|
43
63
|
fields: Record<string, ResourceFieldContract>;
|
|
44
64
|
relations?: Record<string, ResourceRelationContract>;
|
|
@@ -46,6 +66,7 @@ export interface ResourceContract {
|
|
|
46
66
|
}
|
|
47
67
|
export interface ResourceQuery {
|
|
48
68
|
filter?: Record<string, unknown>;
|
|
69
|
+
include?: string | string[];
|
|
49
70
|
sort?: string[];
|
|
50
71
|
search?: string;
|
|
51
72
|
limit?: number;
|
|
@@ -55,13 +76,17 @@ export interface ResourceQuery {
|
|
|
55
76
|
export interface ResourceListResult<T = Record<string, unknown>> {
|
|
56
77
|
rows: T[];
|
|
57
78
|
limit: number;
|
|
79
|
+
time: number;
|
|
80
|
+
total: number | null;
|
|
58
81
|
offset: number;
|
|
59
82
|
}
|
|
60
83
|
export type ResourceUser = User;
|
|
61
84
|
export interface ResourceDependencies {
|
|
62
|
-
pg: DatabaseAdapter
|
|
85
|
+
pg: DatabaseAdapter;
|
|
63
86
|
logger?: AppLogger;
|
|
64
87
|
audit?: AuditPlugin;
|
|
88
|
+
dictionary?: DictionaryPlugin;
|
|
89
|
+
file?: FileAdapter;
|
|
65
90
|
}
|
|
66
91
|
export interface ResourcePlugin {
|
|
67
92
|
register(input: ResourceContract | ResourceContract[]): void;
|
|
@@ -76,23 +101,55 @@ export interface ResourcePlugin {
|
|
|
76
101
|
findOne(params: {
|
|
77
102
|
name: string;
|
|
78
103
|
id: string | number;
|
|
104
|
+
query?: ResourceQuery;
|
|
79
105
|
user?: ResourceUser;
|
|
80
106
|
}): Promise<Record<string, unknown> | null>;
|
|
81
107
|
create(params: {
|
|
82
108
|
name: string;
|
|
83
109
|
data: Record<string, unknown>;
|
|
84
110
|
user?: ResourceUser;
|
|
85
|
-
}): Promise<Record<string, unknown>>;
|
|
111
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
86
112
|
update(params: {
|
|
87
113
|
name: string;
|
|
88
114
|
id: string | number;
|
|
89
115
|
data: Record<string, unknown>;
|
|
90
116
|
user?: ResourceUser;
|
|
91
|
-
}): Promise<Record<string, unknown>>;
|
|
117
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
92
118
|
delete(params: {
|
|
93
119
|
name: string;
|
|
94
120
|
id: string | number;
|
|
95
121
|
user?: ResourceUser;
|
|
96
|
-
}): Promise<boolean>;
|
|
122
|
+
}, ctx?: AppContext): Promise<boolean>;
|
|
123
|
+
findRelation(params: {
|
|
124
|
+
name: string;
|
|
125
|
+
id: string | number;
|
|
126
|
+
relation: string;
|
|
127
|
+
query?: ResourceQuery;
|
|
128
|
+
user?: ResourceUser;
|
|
129
|
+
}): Promise<any>;
|
|
130
|
+
createRelation(params: {
|
|
131
|
+
name: string;
|
|
132
|
+
id: string | number;
|
|
133
|
+
relation: string;
|
|
134
|
+
data?: Record<string, unknown>;
|
|
135
|
+
user?: ResourceUser;
|
|
136
|
+
}, ctx?: AppContext): Promise<any>;
|
|
137
|
+
updateRelation(params: {
|
|
138
|
+
name: string;
|
|
139
|
+
id: string | number;
|
|
140
|
+
relation: string;
|
|
141
|
+
relationId: string;
|
|
142
|
+
data: Record<string, unknown>;
|
|
143
|
+
user?: ResourceUser;
|
|
144
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
145
|
+
deleteRelation(params: {
|
|
146
|
+
name: string;
|
|
147
|
+
id: string | number;
|
|
148
|
+
relation: string;
|
|
149
|
+
relationId: string;
|
|
150
|
+
user?: ResourceUser;
|
|
151
|
+
}, ctx?: AppContext): Promise<{
|
|
152
|
+
success: boolean;
|
|
153
|
+
}>;
|
|
97
154
|
}
|
|
98
155
|
//# sourceMappingURL=resource.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,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B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACrD"}
|
|
@@ -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
|
+
function G(){const U=['filter','get','length','map','has','code','icon','entries','dictionary','_data'];G=function(){return U;};return G();}function q(R,t){R=R-0x169;const X=G();let g=X[R];return g;}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(R,t){const E=q,X=dictionaryIndexesCache['get'](t)??new Map(),g=dictionaryRevisionsCache['get'](t)??new Map();dictionaryIndexesCache['set'](t,X),dictionaryRevisionsCache['set'](t,g);const m=R[E(0x169)](z=>g[E(0x16a)](z)!==t['revision'](z));if(m[E(0x16b)]===0x0)return X;const Z=await Promise['all'](m[E(0x16c)](async z=>{const C=E;if(!t[C(0x16d)](z))return[z,new Map()];const l=await t[C(0x16a)](z),y=new Map();for(const h of l){const P=h[C(0x16e)]??h['id'];if(P==null)continue;y['set'](String(P),{'id':P,'text':h['name']??h['text'],...h['color']!==undefined?{'color':h['color']}:{},...h['icon']!==undefined?{'icon':h[C(0x16f)]}:{}});}return[z,y];}));for(const [z,l]of Z){X['set'](z,l),g['set'](z,t['revision'](z));}return X;}export async function addDictionaryLookupData(R,t,X){const L=q;if(!X||R['length']===0x0)return R;const g=Object[L(0x170)](t)['flatMap'](([Z,z])=>{const O=L,l=z[O(0x171)];return l?[{'field':Z,'dictionaryName':l}]:[];});if(g['length']===0x0)return R;const m=await getDictionaryIndexes([...new Set(g['map'](({dictionaryName:Z})=>Z))],X);for(const Z of R){for(const {field:z,dictionaryName:l}of g){const y=Z[z];Z[z+L(0x172)]=y==null?null:m['get'](l)?.[L(0x16a)](String(y))??null;}}return R;}
|
|
@@ -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 q(R,t){R=R-0x1e9;const X=G();let g=X[R];return g;}function G(){const y=['length'];G=function(){return y;};return G();}export function addFileToken(R,t,X){const l=q;if(!X||R[l(0x1e9)]===0x0)return R;const g=Object['entries'](t)['filter'](([,m])=>m['type']==='file')['map'](([m])=>m);for(const m of R){for(const Z of g){const z=m[Z];typeof z==='string'&&z[l(0x1e9)]>0x0&&(m[Z]=X['create'](z));}}return R;}
|
|
@@ -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
|
+
function q(R,t){R=R-0x99;const X=G();let g=X[R];return g;}import{qi,qt}from'../utils/sql.js';const tableLookupCache=new WeakMap();export function clearTableLookupCache(R,t){const H=q,X=tableLookupCache[H(0x99)](t);if(!X)return;for(const g of X[H(0x9a)]()){g[H(0x9b)](R+':')&&X[H(0x9c)](g);}}function G(){const c=['get','keys','startsWith','delete','flatMap','name','has','length','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','\x20=\x20ANY($1)','rows','set'];G=function(){return c;};return G();}export async function addTableLookupData(R,t,X){const n=q;if(!X||R['length']===0x0)return R;const g=tableLookupCache[n(0x99)](X)??new Map();tableLookupCache['set'](X,g);const m=Object['entries'](t)[n(0x9d)](([Z,z])=>{const S=n,{table:l,value:value='id',text:text=S(0x9e)}=z['lookup']??{};return l?[{'field':Z,'table':l,'value':value,'text':text}]:[];});for(const Z of m){const z=new Map();for(const P of R){const E=P[Z['field']];(typeof E==='string'||typeof E==='number')&&z['set'](String(E),E);}const l=Z['table']+':'+Z['value']+':'+Z['text'],y=g[n(0x99)](l)??new Map();g['set'](l,y);const h=[...z['entries']()]['filter'](([C])=>!y[n(0x9f)](C))['map'](([,C])=>C);if(h[n(0xa0)]>0x0){const C=await X['query']('SELECT\x20'+qi(Z['value'])+'\x20AS\x20id,\x20'+qi(Z['text'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(Z['table'])+n(0xa1)+qi(Z['value'])+n(0xa2),[h]);for(const L of C[n(0xa3)]){y[n(0xa4)](String(L['id']),L);}for(const O of h){!y['has'](String(O))&&y['set'](String(O),null);}}for(const U of R){const e=U[Z['field']];U[Z['field']+'_data']=e==null?null:y['get'](String(e))??null;}}return R;}
|
|
@@ -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
|
+
function q(R,t){R=R-0x18e;const X=G();let g=X[R];return g;}function G(){const H=['get','notes','includes','Generic\x20Resource\x20relation\x20\x22','query','filePath','foreignKey'];G=function(){return H;};return G();}import{UnsupportedError}from'../../../errors.js';import{createCreate}from'./create.js';export function createCreateRelation(R,t){const X=createCreate(R,t);return async function g({name:m,id:Z,relation:z,data:l,user:y},h){const e=q,P=h?.['pg']??R['pg'],E=t[e(0x18e)](m);if([e(0x18f),'files']['includes'](z)&&!E['capabilities']?.[e(0x190)](z))throw new UnsupportedError(e(0x191)+z+'\x22\x20requires\x20a\x20capabilities\x20\x22'+z+'\x22');if(z===e(0x18f)){const O=await P[e(0x192)]('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[m,String(Z),l?.['body']]);return O['rows'][0x0];}if(z==='files'){const U=await P['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*',[m,String(Z),l?.[e(0x193)],l?.['size']??null]);return U['rows'][0x0];}const C=E['relations']?.[z];if(!C?.[e(0x194)]||!C['resource']&&!C['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+z+'\x22\x20requires\x20a\x20project/provider\x20implementation');if(!l)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+l);if(!C['resource'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+z);l[C['foreignKey']]=Z;const L=await X({'name':C['resource'],'data':l??{},'user':y});return L;};}
|
|
@@ -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 q(R,t){R=R-0x1d7;const X=G();let g=X[R];return g;}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';function G(){const n=['push','fields','created_by','map','table','VALUES\x20(','audit','write'];G=function(){return n;};return G();}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(R,t){return async function X({name:g,data:m,user:Z},z){const H=q,l=t['get'](g);assertOperation(l,'create',Z),validateInputData({'resource':l,'data':m});const y=writableData(l,m);l['fields']['created_at']&&y[H(0x1d7)](['created_at',new Date()]);l[H(0x1d8)][H(0x1d9)]&&y['push'](['created_by',Z?.['id']]);if(!y['length'])throw new ValidationError('No\x20writable\x20fields');const h=y[H(0x1da)](([U])=>qi(U)),P=y['map']((U,e)=>'$'+(e+0x1)),E=y['map'](([,U])=>U),C=z?.['pg']??R['pg'],L=await C['query']('INSERT\x20INTO\x20'+qt(l[H(0x1db)])+'\x20('+h['join'](',\x20')+')\x20'+(H(0x1dc)+P['join'](',\x20')+')\x20')+('RETURNING\x20'+readableFields(l)['join'](',\x20')),E),O=L['rows'][0x0];return clearTableLookupCache(l['table'],C),await(z?.['audit']??R[H(0x1dd)])?.[H(0x1de)]({'userId':Z?.['id'],'module':l['module'],'resource':l['name'],'resourceId':O[l['key']],'action':'create','fields':Object['keys'](m)}),O;};}
|