@autofleet/shtinker 3.2.1-beta-81f8d75f.0 → 3.3.0
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/dist/fastify.cjs +4 -2
- package/dist/fastify.cjs.map +1 -1
- package/dist/fastify.d.cts +10 -1
- package/dist/fastify.d.ts +10 -1
- package/dist/fastify.js +4 -2
- package/dist/fastify.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/fastify.cjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,`__esModule`,{value:!0});
|
|
1
|
+
"use strict";Object.defineProperty(exports,`__esModule`,{value:!0});
|
|
2
|
+
/** Swagger tag for audit logs API. Add this to the `tags` array passed into the options of `fastify-plugin`. */
|
|
3
|
+
const e=require(`./common-BWTPt3jo.cjs`),t=e.__toESM(require(`@autofleet/errors`)),n={name:`audit`,description:`Audit logs API`};async function r({fastify:r,logger:i,entityScopedModelMap:a}){!a||!r||Object.entries(a).forEach(([a,o])=>{r.get(`/api/v1/${a}/:id/audit`,{schema:{tags:[n.name],description:`Get audit logs for ${a} by ID`,params:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}}},async n=>{let{id:r}=n.params,s=await o.findByPk(r);if(!s){let e=new t.ResourceNotFoundError;throw i.error(`Entity ${a} with id ${r} not found`,{err:e}),e}return e.audit_ms_default.getByEntityId(r)})})}
|
|
2
4
|
/**
|
|
3
5
|
* A builder of `onRequest` hook for the request handler, which sets the audit context for the request lifecycle.
|
|
4
6
|
* @param entityType The type of the entity being audited.
|
|
5
7
|
* @param action The action being performed on the entity.
|
|
6
8
|
* @returns A Fastify `onRequest` hook.
|
|
7
9
|
*/
|
|
8
|
-
const
|
|
10
|
+
const i=t=>{let n=e.innerEnableAuditing(t);n&&r(t)},a=(t,n)=>async(r,i)=>{await e.innerSetAuditContext(r,i.raw,t,n)};var o=e.audit_logger_default;exports.AUDIT_LOG_CONTEXT_KEY=e.AUDIT_LOG_CONTEXT_KEY,exports.AUDIT_LOG_CONTEXT_QUEUE=e.AUDIT_LOG_CONTEXT_QUEUE,exports.AUDIT_LOG_ROWS_QUEUE=e.AUDIT_LOG_ROWS_QUEUE,exports.AUTOMATION_ID_HEADER=e.AUTOMATION_ID_HEADER,exports.Action=e.Action,exports.ActionOrigin=e.ActionOrigin,exports.EntityType=e.EntityType,exports.SWAGGER_TAG=n,exports.default=o,exports.enableAuditing=i,exports.setAuditContext=a,exports.setRabbitAuditContext=e.setRabbitAuditContext;
|
|
9
11
|
//# sourceMappingURL=fastify.cjs.map
|
package/dist/fastify.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.cjs","names":["options: AuditLoggerOptions","entityType: string","action: string"],"sources":["../src/audit-api/fastify.ts","../src/fastify.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport auditMs from '../audit-ms';\nimport type { AuditLoggerOptions } from '../types';\n\nexport async function addAuditApi({ fastify, logger, entityScopedModelMap }: AuditLoggerOptions): Promise<void> {\n if (!entityScopedModelMap || !fastify) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n fastify.get(\n `/api/v1/${entity}/:id/audit`,\n {\n schema: {\n tags: [
|
|
1
|
+
{"version":3,"file":"fastify.cjs","names":["options: AuditLoggerOptions","entityType: string","action: string"],"sources":["../src/audit-api/fastify.ts","../src/fastify.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport auditMs from '../audit-ms';\nimport type { AuditLoggerOptions } from '../types';\n\n/** Swagger tag for audit logs API. Add this to the `tags` array passed into the options of `fastify-plugin`. */\nexport const SWAGGER_TAG = { name: 'audit', description: 'Audit logs API' };\n\nexport async function addAuditApi({ fastify, logger, entityScopedModelMap }: AuditLoggerOptions): Promise<void> {\n if (!entityScopedModelMap || !fastify) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n fastify.get(\n `/api/v1/${entity}/:id/audit`,\n {\n schema: {\n tags: [SWAGGER_TAG.name],\n description: `Get audit logs for ${entity} by ID`,\n params: {\n type: 'object',\n properties: {\n id: { type: 'string' },\n },\n required: ['id'],\n },\n },\n },\n async (req) => {\n const { id } = req.params as { id: string; };\n const entityData = await ScopedModel.findByPk(id);\n if (!entityData) {\n const err = new ResourceNotFoundError();\n logger.error(`Entity ${entity} with id ${id} not found`, { err });\n throw err;\n }\n return auditMs.getByEntityId(id);\n },\n );\n });\n}\n","import type { onRequestAsyncHookHandler } from 'fastify';\nimport AuditLogger from './audit-logger';\nimport { addAuditApi, SWAGGER_TAG } from './audit-api/fastify';\nimport type { AuditLoggerOptions } from './types';\nimport { innerEnableAuditing, innerSetAuditContext, setRabbitAuditContext } from './common';\n\nexport const enableAuditing = (options: AuditLoggerOptions): void => {\n const addApi = innerEnableAuditing(options);\n if (!addApi) {\n return;\n }\n addAuditApi(options);\n};\n\n/**\n * A builder of `onRequest` hook for the request handler, which sets the audit context for the request lifecycle.\n * @param entityType The type of the entity being audited.\n * @param action The action being performed on the entity.\n * @returns A Fastify `onRequest` hook.\n */\nexport const setAuditContext = (entityType: string, action: string): onRequestAsyncHookHandler => async (request, reply) => {\n await innerSetAuditContext(request, reply.raw, entityType, action);\n};\n\nexport { setRabbitAuditContext, SWAGGER_TAG };\n\nexport * from './types';\nexport * from './const';\n\nexport default AuditLogger;\n"],"mappings":";;AAKA,mFAAa,EAAc,CAAE,KAAM,QAAS,YAAa,gBAAkB,EAE3E,eAAsB,EAAY,CAAE,UAAS,SAAQ,uBAA0C,CAAiB,CAC9G,CAAK,IAAyB,GAG9B,OAAO,QAAQ,EAAqB,CAAC,QAAQ,CAAC,CAAC,EAAQ,EAAY,GAAK,CACtE,EAAQ,KACL,UAAU,EAAO,YAClB,CACE,OAAQ,CACN,KAAM,CAAC,EAAY,IAAK,EACxB,aAAc,qBAAqB,EAAO,QAC1C,OAAQ,CACN,KAAM,SACN,WAAY,CACV,GAAI,CAAE,KAAM,QAAU,CACvB,EACD,SAAU,CAAC,IAAK,CACjB,CACF,CACF,EACD,MAAO,GAAQ,CAEb,GADM,CAAE,KAAI,CAAG,EAAI,OACb,EAAa,KAAM,GAAY,SAAS,EAAG,CACjD,IAAK,EAAY,CACf,IAAM,EAAM,IAAI,EAAA,sBAEhB,KADA,GAAO,OAAO,SAAS,EAAO,WAAW,EAAG,YAAa,CAAE,KAAK,EAAC,CAC3D,CACP,CACD,MAAO,GAAA,iBAAQ,cAAc,EAAG,AACjC,EACF,AACF,EAAC,AACH;;;;;;;ACnBD,MAda,EAAiB,AAACA,GAAsC,CACnE,IAAM,EAAS,EAAA,oBAAoB,EAAQ,CACtC,GAGL,EAAY,EAAQ,AACrB,EAQY,EAAkB,CAACC,EAAoBC,IAA8C,MAAO,EAAS,IAAU,CAC1H,KAAM,GAAA,qBAAqB,EAAS,EAAM,IAAK,EAAY,EAAO,AACnE,EAOD,IAAA,EAAe,EAAA"}
|
package/dist/fastify.d.cts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { AUDIT_LOG_CONTEXT_KEY, AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE, AUTOMATION_ID_HEADER, Action, ActionOrigin, AuditLogContext, AuditLogPayload, AuditLogRow, AuditLogger, AuditLoggerOptions, EntityType, setRabbitAuditContext } from "./const-CC0vE16d.cjs";
|
|
2
2
|
import { onRequestAsyncHookHandler } from "fastify";
|
|
3
3
|
|
|
4
|
+
//#region src/audit-api/fastify.d.ts
|
|
5
|
+
/** Swagger tag for audit logs API. Add this to the `tags` array passed into the options of `fastify-plugin`. */
|
|
6
|
+
/** Swagger tag for audit logs API. Add this to the `tags` array passed into the options of `fastify-plugin`. */
|
|
7
|
+
declare const SWAGGER_TAG: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
4
13
|
//#region src/fastify.d.ts
|
|
5
14
|
declare const enableAuditing: (options: AuditLoggerOptions) => void;
|
|
6
15
|
/**
|
|
@@ -12,5 +21,5 @@ declare const enableAuditing: (options: AuditLoggerOptions) => void;
|
|
|
12
21
|
declare const setAuditContext: (entityType: string, action: string) => onRequestAsyncHookHandler;
|
|
13
22
|
|
|
14
23
|
//#endregion
|
|
15
|
-
export { AUDIT_LOG_CONTEXT_KEY, AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE, AUTOMATION_ID_HEADER, Action, ActionOrigin, AuditLogContext, AuditLogPayload, AuditLogRow, AuditLoggerOptions, EntityType, AuditLogger as default, enableAuditing, setAuditContext, setRabbitAuditContext };
|
|
24
|
+
export { AUDIT_LOG_CONTEXT_KEY, AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE, AUTOMATION_ID_HEADER, Action, ActionOrigin, AuditLogContext, AuditLogPayload, AuditLogRow, AuditLoggerOptions, EntityType, SWAGGER_TAG, AuditLogger as default, enableAuditing, setAuditContext, setRabbitAuditContext };
|
|
16
25
|
//# sourceMappingURL=fastify.d.cts.map
|
package/dist/fastify.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { AUDIT_LOG_CONTEXT_KEY$1 as AUDIT_LOG_CONTEXT_KEY, AUDIT_LOG_CONTEXT_QUEUE$1 as AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE$1 as AUDIT_LOG_ROWS_QUEUE, AUTOMATION_ID_HEADER$1 as AUTOMATION_ID_HEADER, Action$1 as Action, ActionOrigin$1 as ActionOrigin, AuditLogContext, AuditLogPayload, AuditLogRow, AuditLogger, AuditLoggerOptions, EntityType$1 as EntityType, setRabbitAuditContext$1 as setRabbitAuditContext } from "./const-DrgE261l.js";
|
|
2
2
|
import { onRequestAsyncHookHandler } from "fastify";
|
|
3
3
|
|
|
4
|
+
//#region src/audit-api/fastify.d.ts
|
|
5
|
+
/** Swagger tag for audit logs API. Add this to the `tags` array passed into the options of `fastify-plugin`. */
|
|
6
|
+
/** Swagger tag for audit logs API. Add this to the `tags` array passed into the options of `fastify-plugin`. */
|
|
7
|
+
declare const SWAGGER_TAG: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
4
13
|
//#region src/fastify.d.ts
|
|
5
14
|
declare const enableAuditing: (options: AuditLoggerOptions) => void;
|
|
6
15
|
/**
|
|
@@ -12,5 +21,5 @@ declare const enableAuditing: (options: AuditLoggerOptions) => void;
|
|
|
12
21
|
declare const setAuditContext: (entityType: string, action: string) => onRequestAsyncHookHandler;
|
|
13
22
|
|
|
14
23
|
//#endregion
|
|
15
|
-
export { AUDIT_LOG_CONTEXT_KEY, AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE, AUTOMATION_ID_HEADER, Action, ActionOrigin, AuditLogContext, AuditLogPayload, AuditLogRow, AuditLoggerOptions, EntityType, AuditLogger as default, enableAuditing, setAuditContext, setRabbitAuditContext };
|
|
24
|
+
export { AUDIT_LOG_CONTEXT_KEY, AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE, AUTOMATION_ID_HEADER, Action, ActionOrigin, AuditLogContext, AuditLogPayload, AuditLogRow, AuditLoggerOptions, EntityType, SWAGGER_TAG, AuditLogger as default, enableAuditing, setAuditContext, setRabbitAuditContext };
|
|
16
25
|
//# sourceMappingURL=fastify.d.ts.map
|
package/dist/fastify.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import{AUDIT_LOG_CONTEXT_KEY as e,AUDIT_LOG_CONTEXT_QUEUE as t,AUDIT_LOG_ROWS_QUEUE as n,AUTOMATION_ID_HEADER as r,Action as i,ActionOrigin as a,EntityType as o,audit_logger_default as s,audit_ms_default as c,innerEnableAuditing as l,innerSetAuditContext as u,setRabbitAuditContext as d}from"./common-CJByaCJF.js";import{ResourceNotFoundError as f}from"@autofleet/errors";
|
|
1
|
+
import{AUDIT_LOG_CONTEXT_KEY as e,AUDIT_LOG_CONTEXT_QUEUE as t,AUDIT_LOG_ROWS_QUEUE as n,AUTOMATION_ID_HEADER as r,Action as i,ActionOrigin as a,EntityType as o,audit_logger_default as s,audit_ms_default as c,innerEnableAuditing as l,innerSetAuditContext as u,setRabbitAuditContext as d}from"./common-CJByaCJF.js";import{ResourceNotFoundError as f}from"@autofleet/errors";
|
|
2
|
+
/** Swagger tag for audit logs API. Add this to the `tags` array passed into the options of `fastify-plugin`. */
|
|
3
|
+
const p={name:`audit`,description:`Audit logs API`};async function m({fastify:e,logger:t,entityScopedModelMap:n}){!n||!e||Object.entries(n).forEach(([n,r])=>{e.get(`/api/v1/${n}/:id/audit`,{schema:{tags:[p.name],description:`Get audit logs for ${n} by ID`,params:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}}},async e=>{let{id:i}=e.params,a=await r.findByPk(i);if(!a){let e=new f;throw t.error(`Entity ${n} with id ${i} not found`,{err:e}),e}return c.getByEntityId(i)})})}
|
|
2
4
|
/**
|
|
3
5
|
* A builder of `onRequest` hook for the request handler, which sets the audit context for the request lifecycle.
|
|
4
6
|
* @param entityType The type of the entity being audited.
|
|
5
7
|
* @param action The action being performed on the entity.
|
|
6
8
|
* @returns A Fastify `onRequest` hook.
|
|
7
9
|
*/
|
|
8
|
-
const
|
|
10
|
+
const h=e=>{let t=l(e);t&&m(e)},g=(e,t)=>async(n,r)=>{await u(n,r.raw,e,t)};var _=s;export{e as AUDIT_LOG_CONTEXT_KEY,t as AUDIT_LOG_CONTEXT_QUEUE,n as AUDIT_LOG_ROWS_QUEUE,r as AUTOMATION_ID_HEADER,i as Action,a as ActionOrigin,o as EntityType,p as SWAGGER_TAG,_ as default,h as enableAuditing,g as setAuditContext,d as setRabbitAuditContext};
|
|
9
11
|
//# sourceMappingURL=fastify.js.map
|
package/dist/fastify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.js","names":["options: AuditLoggerOptions","entityType: string","action: string"],"sources":["../src/audit-api/fastify.ts","../src/fastify.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport auditMs from '../audit-ms';\nimport type { AuditLoggerOptions } from '../types';\n\nexport async function addAuditApi({ fastify, logger, entityScopedModelMap }: AuditLoggerOptions): Promise<void> {\n if (!entityScopedModelMap || !fastify) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n fastify.get(\n `/api/v1/${entity}/:id/audit`,\n {\n schema: {\n tags: [
|
|
1
|
+
{"version":3,"file":"fastify.js","names":["options: AuditLoggerOptions","entityType: string","action: string"],"sources":["../src/audit-api/fastify.ts","../src/fastify.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport auditMs from '../audit-ms';\nimport type { AuditLoggerOptions } from '../types';\n\n/** Swagger tag for audit logs API. Add this to the `tags` array passed into the options of `fastify-plugin`. */\nexport const SWAGGER_TAG = { name: 'audit', description: 'Audit logs API' };\n\nexport async function addAuditApi({ fastify, logger, entityScopedModelMap }: AuditLoggerOptions): Promise<void> {\n if (!entityScopedModelMap || !fastify) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n fastify.get(\n `/api/v1/${entity}/:id/audit`,\n {\n schema: {\n tags: [SWAGGER_TAG.name],\n description: `Get audit logs for ${entity} by ID`,\n params: {\n type: 'object',\n properties: {\n id: { type: 'string' },\n },\n required: ['id'],\n },\n },\n },\n async (req) => {\n const { id } = req.params as { id: string; };\n const entityData = await ScopedModel.findByPk(id);\n if (!entityData) {\n const err = new ResourceNotFoundError();\n logger.error(`Entity ${entity} with id ${id} not found`, { err });\n throw err;\n }\n return auditMs.getByEntityId(id);\n },\n );\n });\n}\n","import type { onRequestAsyncHookHandler } from 'fastify';\nimport AuditLogger from './audit-logger';\nimport { addAuditApi, SWAGGER_TAG } from './audit-api/fastify';\nimport type { AuditLoggerOptions } from './types';\nimport { innerEnableAuditing, innerSetAuditContext, setRabbitAuditContext } from './common';\n\nexport const enableAuditing = (options: AuditLoggerOptions): void => {\n const addApi = innerEnableAuditing(options);\n if (!addApi) {\n return;\n }\n addAuditApi(options);\n};\n\n/**\n * A builder of `onRequest` hook for the request handler, which sets the audit context for the request lifecycle.\n * @param entityType The type of the entity being audited.\n * @param action The action being performed on the entity.\n * @returns A Fastify `onRequest` hook.\n */\nexport const setAuditContext = (entityType: string, action: string): onRequestAsyncHookHandler => async (request, reply) => {\n await innerSetAuditContext(request, reply.raw, entityType, action);\n};\n\nexport { setRabbitAuditContext, SWAGGER_TAG };\n\nexport * from './types';\nexport * from './const';\n\nexport default AuditLogger;\n"],"mappings":";;AAKA,MAAa,EAAc,CAAE,KAAM,QAAS,YAAa,gBAAkB,EAE3E,eAAsB,EAAY,CAAE,UAAS,SAAQ,uBAA0C,CAAiB,CAC9G,CAAK,IAAyB,GAG9B,OAAO,QAAQ,EAAqB,CAAC,QAAQ,CAAC,CAAC,EAAQ,EAAY,GAAK,CACtE,EAAQ,KACL,UAAU,EAAO,YAClB,CACE,OAAQ,CACN,KAAM,CAAC,EAAY,IAAK,EACxB,aAAc,qBAAqB,EAAO,QAC1C,OAAQ,CACN,KAAM,SACN,WAAY,CACV,GAAI,CAAE,KAAM,QAAU,CACvB,EACD,SAAU,CAAC,IAAK,CACjB,CACF,CACF,EACD,MAAO,GAAQ,CAEb,GADM,CAAE,KAAI,CAAG,EAAI,OACb,EAAa,KAAM,GAAY,SAAS,EAAG,CACjD,IAAK,EAAY,CACf,IAAM,EAAM,IAAI,EAEhB,KADA,GAAO,OAAO,SAAS,EAAO,WAAW,EAAG,YAAa,CAAE,KAAK,EAAC,CAC3D,CACP,CACD,MAAO,GAAQ,cAAc,EAAG,AACjC,EACF,AACF,EAAC,AACH;;;;;;;ACnBD,MAda,EAAiB,AAACA,GAAsC,CACnE,IAAM,EAAS,EAAoB,EAAQ,CACtC,GAGL,EAAY,EAAQ,AACrB,EAQY,EAAkB,CAACC,EAAoBC,IAA8C,MAAO,EAAS,IAAU,CAC1H,KAAM,GAAqB,EAAS,EAAM,IAAK,EAAY,EAAO,AACnE,EAOD,IAAA,EAAe"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./common-BWTPt3jo.cjs`),t=e.__toESM(require(`@autofleet/errors`));async function n({router:n,logger:r,entityScopedModelMap:i}){!i||!n||Object.entries(i).forEach(([i,a])=>{n.get(`${i}/:id/audit`,async(n,o)=>{try{let{id:s}=n.params,c=await a.findByPk(s);if(!c)return(0,t.handleError)(new t.ResourceNotFoundError,o,{logger:r,message:`Entity ${i} with id ${s} not found`});let l=e.audit_ms_default.getByEntityId(s);return o.json(l)}catch(e){return(0,t.handleError)(new t.UnexpectedError(e),o,{logger:r})}})})}const r=t=>{e.innerEnableAuditing(t)
|
|
1
|
+
"use strict";Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./common-BWTPt3jo.cjs`),t=e.__toESM(require(`@autofleet/errors`));async function n({router:n,logger:r,entityScopedModelMap:i}){!i||!n||Object.entries(i).forEach(([i,a])=>{n.get(`${i}/:id/audit`,async(n,o)=>{try{let{id:s}=n.params,c=await a.findByPk(s);if(!c)return(0,t.handleError)(new t.ResourceNotFoundError,o,{logger:r,message:`Entity ${i} with id ${s} not found`});let l=e.audit_ms_default.getByEntityId(s);return o.json(l)}catch(e){return(0,t.handleError)(new t.UnexpectedError(e),o,{logger:r})}})})}const r=t=>{let r=e.innerEnableAuditing(t);r&&n(t)},i=(t,n)=>async(r,i,a)=>(e.innerSetAuditContext(r,i,t,n),a());var a=e.audit_logger_default;exports.AUDIT_LOG_CONTEXT_KEY=e.AUDIT_LOG_CONTEXT_KEY,exports.AUDIT_LOG_CONTEXT_QUEUE=e.AUDIT_LOG_CONTEXT_QUEUE,exports.AUDIT_LOG_ROWS_QUEUE=e.AUDIT_LOG_ROWS_QUEUE,exports.AUTOMATION_ID_HEADER=e.AUTOMATION_ID_HEADER,exports.Action=e.Action,exports.ActionOrigin=e.ActionOrigin,exports.EntityType=e.EntityType,exports.default=a,exports.enableAuditing=r,exports.setAuditContext=i,exports.setRabbitAuditContext=e.setRabbitAuditContext;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["options: AuditLoggerOptions","entityType: string","action: string","req: Request","res: Response","next: NextFunction"],"sources":["../src/audit-api/express.ts","../src/index.ts"],"sourcesContent":["import { handleError, ResourceNotFoundError, UnexpectedError } from '@autofleet/errors';\nimport auditMs from '../audit-ms';\nimport type { AuditLoggerOptions } from '../types';\n\nexport async function addAuditApi({ router, logger, entityScopedModelMap }: AuditLoggerOptions): Promise<void> {\n if (!entityScopedModelMap || !router) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n router.get(`${entity}/:id/audit`, async (req, res) => {\n try {\n const { id } = req.params;\n const entityData = await ScopedModel.findByPk(id);\n if (!entityData) {\n return handleError(new ResourceNotFoundError(), res, { logger, message: `Entity ${entity} with id ${id} not found` });\n }\n const auditData = auditMs.getByEntityId(id);\n return res.json(auditData);\n } catch (err) {\n return handleError(new UnexpectedError(err as Error), res, { logger });\n }\n });\n });\n}\n","import type { Request, Response, NextFunction } from 'express';\nimport AuditLogger from './audit-logger';\nimport { addAuditApi } from './audit-api/express';\nimport type { AuditLoggerOptions } from './types';\nimport { innerEnableAuditing, innerSetAuditContext, setRabbitAuditContext } from './common';\n\nexport const enableAuditing = (options: AuditLoggerOptions): void => {\n innerEnableAuditing(options);\n addAuditApi(options);\n};\n\nexport const setAuditContext = (entityType: string, action: string) => async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n innerSetAuditContext(req, res, entityType, action);\n return next();\n};\n\nexport { setRabbitAuditContext };\n\nexport * from './types';\nexport * from './const';\n\nexport default AuditLogger;\n"],"mappings":"uJAIA,eAAsB,EAAY,CAAE,SAAQ,SAAQ,uBAA0C,CAAiB,CAC7G,CAAK,IAAyB,GAG9B,OAAO,QAAQ,EAAqB,CAAC,QAAQ,CAAC,CAAC,EAAQ,EAAY,GAAK,CACtE,EAAO,KAAK,EAAE,EAAO,YAAa,MAAO,EAAK,IAAQ,CACpD,GAAI,CAEF,GADM,CAAE,KAAI,CAAG,EAAI,OACb,EAAa,KAAM,GAAY,SAAS,EAAG,CACjD,IAAK,EACH,MAAO,CAAA,EAAA,EAAA,aAAY,IAAI,EAAA,sBAAyB,EAAK,CAAE,SAAQ,SAAU,SAAS,EAAO,WAAW,EAAG,WAAa,EAAC,CAEvH,IAAM,EAAY,EAAA,iBAAQ,cAAc,EAAG,CAC3C,MAAO,GAAI,KAAK,EAAU,AAC3B,OAAQ,EAAK,CACZ,MAAO,CAAA,EAAA,EAAA,aAAY,IAAI,EAAA,gBAAgB,GAAe,EAAK,CAAE,QAAQ,EAAC,AACvE,CACF,EAAC,AACH,EAAC,AACH,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["options: AuditLoggerOptions","entityType: string","action: string","req: Request","res: Response","next: NextFunction"],"sources":["../src/audit-api/express.ts","../src/index.ts"],"sourcesContent":["import { handleError, ResourceNotFoundError, UnexpectedError } from '@autofleet/errors';\nimport auditMs from '../audit-ms';\nimport type { AuditLoggerOptions } from '../types';\n\nexport async function addAuditApi({ router, logger, entityScopedModelMap }: AuditLoggerOptions): Promise<void> {\n if (!entityScopedModelMap || !router) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n router.get(`${entity}/:id/audit`, async (req, res) => {\n try {\n const { id } = req.params;\n const entityData = await ScopedModel.findByPk(id);\n if (!entityData) {\n return handleError(new ResourceNotFoundError(), res, { logger, message: `Entity ${entity} with id ${id} not found` });\n }\n const auditData = auditMs.getByEntityId(id);\n return res.json(auditData);\n } catch (err) {\n return handleError(new UnexpectedError(err as Error), res, { logger });\n }\n });\n });\n}\n","import type { Request, Response, NextFunction } from 'express';\nimport AuditLogger from './audit-logger';\nimport { addAuditApi } from './audit-api/express';\nimport type { AuditLoggerOptions } from './types';\nimport { innerEnableAuditing, innerSetAuditContext, setRabbitAuditContext } from './common';\n\nexport const enableAuditing = (options: AuditLoggerOptions): void => {\n const addApi = innerEnableAuditing(options);\n if (!addApi) {\n return;\n }\n addAuditApi(options);\n};\n\nexport const setAuditContext = (entityType: string, action: string) => async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n innerSetAuditContext(req, res, entityType, action);\n return next();\n};\n\nexport { setRabbitAuditContext };\n\nexport * from './types';\nexport * from './const';\n\nexport default AuditLogger;\n"],"mappings":"uJAIA,eAAsB,EAAY,CAAE,SAAQ,SAAQ,uBAA0C,CAAiB,CAC7G,CAAK,IAAyB,GAG9B,OAAO,QAAQ,EAAqB,CAAC,QAAQ,CAAC,CAAC,EAAQ,EAAY,GAAK,CACtE,EAAO,KAAK,EAAE,EAAO,YAAa,MAAO,EAAK,IAAQ,CACpD,GAAI,CAEF,GADM,CAAE,KAAI,CAAG,EAAI,OACb,EAAa,KAAM,GAAY,SAAS,EAAG,CACjD,IAAK,EACH,MAAO,CAAA,EAAA,EAAA,aAAY,IAAI,EAAA,sBAAyB,EAAK,CAAE,SAAQ,SAAU,SAAS,EAAO,WAAW,EAAG,WAAa,EAAC,CAEvH,IAAM,EAAY,EAAA,iBAAQ,cAAc,EAAG,CAC3C,MAAO,GAAI,KAAK,EAAU,AAC3B,OAAQ,EAAK,CACZ,MAAO,CAAA,EAAA,EAAA,aAAY,IAAI,EAAA,gBAAgB,GAAe,EAAK,CAAE,QAAQ,EAAC,AACvE,CACF,EAAC,AACH,EAAC,AACH,CCTD,MARa,EAAiB,AAACA,GAAsC,CACnE,IAAM,EAAS,EAAA,oBAAoB,EAAQ,CACtC,GAGL,EAAY,EAAQ,AACrB,EAEY,EAAkB,CAACC,EAAoBC,IAAmB,MAAOC,EAAcC,EAAeC,KACzG,EAAA,qBAAqB,EAAK,EAAK,EAAY,EAAO,CAC3C,GAAM,EAQf,IAAA,EAAe,EAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{AUDIT_LOG_CONTEXT_KEY as e,AUDIT_LOG_CONTEXT_QUEUE as t,AUDIT_LOG_ROWS_QUEUE as n,AUTOMATION_ID_HEADER as r,Action as i,ActionOrigin as a,EntityType as o,audit_logger_default as s,audit_ms_default as c,innerEnableAuditing as l,innerSetAuditContext as u,setRabbitAuditContext as d}from"./common-CJByaCJF.js";import{ResourceNotFoundError as f,UnexpectedError as p,handleError as m}from"@autofleet/errors";async function h({router:e,logger:t,entityScopedModelMap:n}){!n||!e||Object.entries(n).forEach(([n,r])=>{e.get(`${n}/:id/audit`,async(e,i)=>{try{let{id:a}=e.params,o=await r.findByPk(a);if(!o)return m(new f,i,{logger:t,message:`Entity ${n} with id ${a} not found`});let s=c.getByEntityId(a);return i.json(s)}catch(e){return m(new p(e),i,{logger:t})}})})}const g=e=>{l(e)
|
|
1
|
+
import{AUDIT_LOG_CONTEXT_KEY as e,AUDIT_LOG_CONTEXT_QUEUE as t,AUDIT_LOG_ROWS_QUEUE as n,AUTOMATION_ID_HEADER as r,Action as i,ActionOrigin as a,EntityType as o,audit_logger_default as s,audit_ms_default as c,innerEnableAuditing as l,innerSetAuditContext as u,setRabbitAuditContext as d}from"./common-CJByaCJF.js";import{ResourceNotFoundError as f,UnexpectedError as p,handleError as m}from"@autofleet/errors";async function h({router:e,logger:t,entityScopedModelMap:n}){!n||!e||Object.entries(n).forEach(([n,r])=>{e.get(`${n}/:id/audit`,async(e,i)=>{try{let{id:a}=e.params,o=await r.findByPk(a);if(!o)return m(new f,i,{logger:t,message:`Entity ${n} with id ${a} not found`});let s=c.getByEntityId(a);return i.json(s)}catch(e){return m(new p(e),i,{logger:t})}})})}const g=e=>{let t=l(e);t&&h(e)},_=(e,t)=>async(n,r,i)=>(u(n,r,e,t),i());var v=s;export{e as AUDIT_LOG_CONTEXT_KEY,t as AUDIT_LOG_CONTEXT_QUEUE,n as AUDIT_LOG_ROWS_QUEUE,r as AUTOMATION_ID_HEADER,i as Action,a as ActionOrigin,o as EntityType,v as default,g as enableAuditing,_ as setAuditContext,d as setRabbitAuditContext};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options: AuditLoggerOptions","entityType: string","action: string","req: Request","res: Response","next: NextFunction"],"sources":["../src/audit-api/express.ts","../src/index.ts"],"sourcesContent":["import { handleError, ResourceNotFoundError, UnexpectedError } from '@autofleet/errors';\nimport auditMs from '../audit-ms';\nimport type { AuditLoggerOptions } from '../types';\n\nexport async function addAuditApi({ router, logger, entityScopedModelMap }: AuditLoggerOptions): Promise<void> {\n if (!entityScopedModelMap || !router) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n router.get(`${entity}/:id/audit`, async (req, res) => {\n try {\n const { id } = req.params;\n const entityData = await ScopedModel.findByPk(id);\n if (!entityData) {\n return handleError(new ResourceNotFoundError(), res, { logger, message: `Entity ${entity} with id ${id} not found` });\n }\n const auditData = auditMs.getByEntityId(id);\n return res.json(auditData);\n } catch (err) {\n return handleError(new UnexpectedError(err as Error), res, { logger });\n }\n });\n });\n}\n","import type { Request, Response, NextFunction } from 'express';\nimport AuditLogger from './audit-logger';\nimport { addAuditApi } from './audit-api/express';\nimport type { AuditLoggerOptions } from './types';\nimport { innerEnableAuditing, innerSetAuditContext, setRabbitAuditContext } from './common';\n\nexport const enableAuditing = (options: AuditLoggerOptions): void => {\n innerEnableAuditing(options);\n addAuditApi(options);\n};\n\nexport const setAuditContext = (entityType: string, action: string) => async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n innerSetAuditContext(req, res, entityType, action);\n return next();\n};\n\nexport { setRabbitAuditContext };\n\nexport * from './types';\nexport * from './const';\n\nexport default AuditLogger;\n"],"mappings":"0ZAIA,eAAsB,EAAY,CAAE,SAAQ,SAAQ,uBAA0C,CAAiB,CAC7G,CAAK,IAAyB,GAG9B,OAAO,QAAQ,EAAqB,CAAC,QAAQ,CAAC,CAAC,EAAQ,EAAY,GAAK,CACtE,EAAO,KAAK,EAAE,EAAO,YAAa,MAAO,EAAK,IAAQ,CACpD,GAAI,CAEF,GADM,CAAE,KAAI,CAAG,EAAI,OACb,EAAa,KAAM,GAAY,SAAS,EAAG,CACjD,IAAK,EACH,MAAO,GAAY,IAAI,EAAyB,EAAK,CAAE,SAAQ,SAAU,SAAS,EAAO,WAAW,EAAG,WAAa,EAAC,CAEvH,IAAM,EAAY,EAAQ,cAAc,EAAG,CAC3C,MAAO,GAAI,KAAK,EAAU,AAC3B,OAAQ,EAAK,CACZ,MAAO,GAAY,IAAI,EAAgB,GAAe,EAAK,CAAE,QAAQ,EAAC,AACvE,CACF,EAAC,AACH,EAAC,AACH,
|
|
1
|
+
{"version":3,"file":"index.js","names":["options: AuditLoggerOptions","entityType: string","action: string","req: Request","res: Response","next: NextFunction"],"sources":["../src/audit-api/express.ts","../src/index.ts"],"sourcesContent":["import { handleError, ResourceNotFoundError, UnexpectedError } from '@autofleet/errors';\nimport auditMs from '../audit-ms';\nimport type { AuditLoggerOptions } from '../types';\n\nexport async function addAuditApi({ router, logger, entityScopedModelMap }: AuditLoggerOptions): Promise<void> {\n if (!entityScopedModelMap || !router) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n router.get(`${entity}/:id/audit`, async (req, res) => {\n try {\n const { id } = req.params;\n const entityData = await ScopedModel.findByPk(id);\n if (!entityData) {\n return handleError(new ResourceNotFoundError(), res, { logger, message: `Entity ${entity} with id ${id} not found` });\n }\n const auditData = auditMs.getByEntityId(id);\n return res.json(auditData);\n } catch (err) {\n return handleError(new UnexpectedError(err as Error), res, { logger });\n }\n });\n });\n}\n","import type { Request, Response, NextFunction } from 'express';\nimport AuditLogger from './audit-logger';\nimport { addAuditApi } from './audit-api/express';\nimport type { AuditLoggerOptions } from './types';\nimport { innerEnableAuditing, innerSetAuditContext, setRabbitAuditContext } from './common';\n\nexport const enableAuditing = (options: AuditLoggerOptions): void => {\n const addApi = innerEnableAuditing(options);\n if (!addApi) {\n return;\n }\n addAuditApi(options);\n};\n\nexport const setAuditContext = (entityType: string, action: string) => async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n innerSetAuditContext(req, res, entityType, action);\n return next();\n};\n\nexport { setRabbitAuditContext };\n\nexport * from './types';\nexport * from './const';\n\nexport default AuditLogger;\n"],"mappings":"0ZAIA,eAAsB,EAAY,CAAE,SAAQ,SAAQ,uBAA0C,CAAiB,CAC7G,CAAK,IAAyB,GAG9B,OAAO,QAAQ,EAAqB,CAAC,QAAQ,CAAC,CAAC,EAAQ,EAAY,GAAK,CACtE,EAAO,KAAK,EAAE,EAAO,YAAa,MAAO,EAAK,IAAQ,CACpD,GAAI,CAEF,GADM,CAAE,KAAI,CAAG,EAAI,OACb,EAAa,KAAM,GAAY,SAAS,EAAG,CACjD,IAAK,EACH,MAAO,GAAY,IAAI,EAAyB,EAAK,CAAE,SAAQ,SAAU,SAAS,EAAO,WAAW,EAAG,WAAa,EAAC,CAEvH,IAAM,EAAY,EAAQ,cAAc,EAAG,CAC3C,MAAO,GAAI,KAAK,EAAU,AAC3B,OAAQ,EAAK,CACZ,MAAO,GAAY,IAAI,EAAgB,GAAe,EAAK,CAAE,QAAQ,EAAC,AACvE,CACF,EAAC,AACH,EAAC,AACH,CCTD,MARa,EAAiB,AAACA,GAAsC,CACnE,IAAM,EAAS,EAAoB,EAAQ,CACtC,GAGL,EAAY,EAAQ,AACrB,EAEY,EAAkB,CAACC,EAAoBC,IAAmB,MAAOC,EAAcC,EAAeC,KACzG,EAAqB,EAAK,EAAK,EAAY,EAAO,CAC3C,GAAM,EAQf,IAAA,EAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/shtinker",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"node": ">=18"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@autofleet/network": "^1.8.1"
|
|
42
|
-
"lodash": "^4.17.21"
|
|
41
|
+
"@autofleet/network": "^1.8.1"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@autofleet/zehut": "^4.2.2",
|