@autofleet/shtinker 3.9.8 → 3.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fastify.cjs +1 -1
- package/dist/fastify.cjs.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fastify.js.map +1 -1
- package/package.json +1 -1
package/dist/fastify.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./common-CwBlhmOz.cjs`);let t=require(`@autofleet/errors`);const n={name:`Audit`,description:`Audit logs API`};function r({fastify:r,logger:i,entityScopedModelMap:a}){!a||!r||Object.entries(a).forEach(([a,o])=>{r.post(`/api/v1/${a}/:id/audit`,{schema:{tags:[n.name],description:`Query audit logs for ${a} by ID`,params:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./common-CwBlhmOz.cjs`);let t=require(`@autofleet/errors`);const n={name:`Audit`,description:`Audit logs API`};function r({fastify:r,logger:i,entityScopedModelMap:a}){!a||!r||Object.entries(a).forEach(([a,o])=>{r.post(`/api/v1/${a}/:id/audit`,{schema:{tags:[n.name],description:`Query audit logs for ${a} by ID`,params:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}}},async n=>{let{id:r}=n.params;if(!await o.findByPk(r)){let e=new t.ResourceNotFoundError;throw i.error(`Entity ${a} with id ${r} not found`,{err:e}),e}return e.a.queryByEntityId(r,n.body)})})}const i=t=>{let n=e.t(t);if(n)return r(t),n},a=(t,n)=>async(r,i)=>{await e.n(r,i.raw,t,n)};var o=e.o;exports.AUDIT_LOG_CONTEXT_KEY=e.s,exports.AUDIT_LOG_CONTEXT_QUEUE=e.c,exports.AUDIT_LOG_ROWS_QUEUE=e.l,exports.AUTOMATION_ID_HEADER=e.u,exports.Action=e.d,exports.ActionOrigin=e.f,exports.EntityType=e.p,exports.SWAGGER_TAG=n,exports.default=o,exports.enableAuditing=i,exports.setAuditContext=a,exports.setBullMqAuditContext=e.r,exports.setRabbitAuditContext=e.i;
|
|
2
2
|
//# sourceMappingURL=fastify.cjs.map
|
package/dist/fastify.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.cjs","names":["ResourceNotFoundError","auditMs","innerEnableAuditing","innerSetAuditContext","AuditLogger"],"sources":["../src/audit-api/fastify.ts","../src/fastify.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport auditMs, { type QueryRequestBody } 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 function addAuditApi({ fastify, logger, entityScopedModelMap }: AuditLoggerOptions): void {\n if (!entityScopedModelMap || !fastify) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n fastify.post(\n `/api/v1/${entity}/:id/audit`,\n {\n schema: {\n tags: [SWAGGER_TAG.name],\n description: `Query audit logs for ${entity} by ID`,\n params: {\n type: 'object',\n properties: {\n id: { type: 'string' },\n },\n required: ['id'],\n },\n
|
|
1
|
+
{"version":3,"file":"fastify.cjs","names":["ResourceNotFoundError","auditMs","innerEnableAuditing","innerSetAuditContext","AuditLogger"],"sources":["../src/audit-api/fastify.ts","../src/fastify.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport auditMs, { type QueryRequestBody } 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 function addAuditApi({ fastify, logger, entityScopedModelMap }: AuditLoggerOptions): void {\n if (!entityScopedModelMap || !fastify) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n fastify.post(\n `/api/v1/${entity}/:id/audit`,\n {\n schema: {\n tags: [SWAGGER_TAG.name],\n description: `Query 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.queryByEntityId(id, req.body as QueryRequestBody);\n },\n );\n });\n}\n","import type { preHandlerAsyncHookHandler } from 'fastify';\nimport AuditLogger from './audit-logger';\nimport { addAuditApi, SWAGGER_TAG } from './audit-api/fastify';\nimport type { AuditLoggerOptions } from './types';\nimport { innerEnableAuditing, innerSetAuditContext, setRabbitAuditContext, setBullMqAuditContext } from './common';\n\nexport const enableAuditing = (options: AuditLoggerOptions): undefined | AuditLogger => {\n const addApi = innerEnableAuditing(options);\n if (!addApi) {\n return undefined;\n }\n addAuditApi(options);\n\n return addApi;\n};\n\n/**\n * A builder of `preHandler` 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 `preHandler` hook.\n */\nexport const setAuditContext = (entityType: string, action: string): preHandlerAsyncHookHandler => async (request, reply) => {\n await innerSetAuditContext(request, reply.raw, entityType, action);\n};\n\nexport { setRabbitAuditContext, SWAGGER_TAG, setBullMqAuditContext };\n\nexport * from './types';\nexport * from './const';\n\nexport default AuditLogger;\n"],"mappings":"mIAKA,MAAa,EAAc,CAAE,KAAM,QAAS,YAAa,iBAAkB,CAE3E,SAAgB,EAAY,CAAE,UAAS,SAAQ,wBAAkD,CAC3F,CAAC,GAAwB,CAAC,GAG9B,OAAO,QAAQ,EAAqB,CAAC,SAAS,CAAC,EAAQ,KAAiB,CACtE,EAAQ,KACN,WAAW,EAAO,YAClB,CACE,OAAQ,CACN,KAAM,CAAC,EAAY,KAAK,CACxB,YAAa,wBAAwB,EAAO,QAC5C,OAAQ,CACN,KAAM,SACN,WAAY,CACV,GAAI,CAAE,KAAM,SAAU,CACvB,CACD,SAAU,CAAC,KAAK,CACjB,CACF,CACF,CACD,KAAO,IAAQ,CACb,GAAM,CAAE,MAAO,EAAI,OAEnB,GAAI,CADe,MAAM,EAAY,SAAS,EAAG,CAChC,CACf,IAAM,EAAM,IAAIA,EAAAA,sBAEhB,MADA,EAAO,MAAM,UAAU,EAAO,WAAW,EAAG,YAAa,CAAE,MAAK,CAAC,CAC3D,EAER,OAAOC,EAAAA,EAAQ,gBAAgB,EAAI,EAAI,KAAyB,EAEnE,EACD,CChCJ,MAAa,EAAkB,GAAyD,CACtF,IAAM,EAASC,EAAAA,EAAoB,EAAQ,CACtC,KAKL,OAFA,EAAY,EAAQ,CAEb,GASI,GAAmB,EAAoB,IAA+C,MAAO,EAAS,IAAU,CAC3H,MAAMC,EAAAA,EAAqB,EAAS,EAAM,IAAK,EAAY,EAAO,EAQpE,IAAA,EAAeC,EAAAA"}
|
package/dist/fastify.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./common-BILatgXT.js";import{ResourceNotFoundError as p}from"@autofleet/errors";const m={name:`Audit`,description:`Audit logs API`};function h({fastify:t,logger:n,entityScopedModelMap:r}){!r||!t||Object.entries(r).forEach(([r,i])=>{t.post(`/api/v1/${r}/:id/audit`,{schema:{tags:[m.name],description:`Query audit logs for ${r} by ID`,params:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./common-BILatgXT.js";import{ResourceNotFoundError as p}from"@autofleet/errors";const m={name:`Audit`,description:`Audit logs API`};function h({fastify:t,logger:n,entityScopedModelMap:r}){!r||!t||Object.entries(r).forEach(([r,i])=>{t.post(`/api/v1/${r}/:id/audit`,{schema:{tags:[m.name],description:`Query audit logs for ${r} by ID`,params:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}}},async t=>{let{id:a}=t.params;if(!await i.findByPk(a)){let e=new p;throw n.error(`Entity ${r} with id ${a} not found`,{err:e}),e}return e.queryByEntityId(a,t.body)})})}const g=e=>{let t=d(e);if(t)return h(e),t},_=(e,t)=>async(n,r)=>{await o(n,r.raw,e,t)};var v=s;export{u as AUDIT_LOG_CONTEXT_KEY,t as AUDIT_LOG_CONTEXT_QUEUE,a as AUDIT_LOG_ROWS_QUEUE,f as AUTOMATION_ID_HEADER,n as Action,r as ActionOrigin,c as EntityType,m as SWAGGER_TAG,v as default,g as enableAuditing,_ as setAuditContext,l as setBullMqAuditContext,i as setRabbitAuditContext};
|
|
2
2
|
//# sourceMappingURL=fastify.js.map
|
package/dist/fastify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.js","names":["auditMs","AuditLogger"],"sources":["../src/audit-api/fastify.ts","../src/fastify.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport auditMs, { type QueryRequestBody } 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 function addAuditApi({ fastify, logger, entityScopedModelMap }: AuditLoggerOptions): void {\n if (!entityScopedModelMap || !fastify) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n fastify.post(\n `/api/v1/${entity}/:id/audit`,\n {\n schema: {\n tags: [SWAGGER_TAG.name],\n description: `Query audit logs for ${entity} by ID`,\n params: {\n type: 'object',\n properties: {\n id: { type: 'string' },\n },\n required: ['id'],\n },\n
|
|
1
|
+
{"version":3,"file":"fastify.js","names":["auditMs","AuditLogger"],"sources":["../src/audit-api/fastify.ts","../src/fastify.ts"],"sourcesContent":["import { ResourceNotFoundError } from '@autofleet/errors';\nimport auditMs, { type QueryRequestBody } 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 function addAuditApi({ fastify, logger, entityScopedModelMap }: AuditLoggerOptions): void {\n if (!entityScopedModelMap || !fastify) {\n return;\n }\n Object.entries(entityScopedModelMap).forEach(([entity, ScopedModel]) => {\n fastify.post(\n `/api/v1/${entity}/:id/audit`,\n {\n schema: {\n tags: [SWAGGER_TAG.name],\n description: `Query 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.queryByEntityId(id, req.body as QueryRequestBody);\n },\n );\n });\n}\n","import type { preHandlerAsyncHookHandler } from 'fastify';\nimport AuditLogger from './audit-logger';\nimport { addAuditApi, SWAGGER_TAG } from './audit-api/fastify';\nimport type { AuditLoggerOptions } from './types';\nimport { innerEnableAuditing, innerSetAuditContext, setRabbitAuditContext, setBullMqAuditContext } from './common';\n\nexport const enableAuditing = (options: AuditLoggerOptions): undefined | AuditLogger => {\n const addApi = innerEnableAuditing(options);\n if (!addApi) {\n return undefined;\n }\n addAuditApi(options);\n\n return addApi;\n};\n\n/**\n * A builder of `preHandler` 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 `preHandler` hook.\n */\nexport const setAuditContext = (entityType: string, action: string): preHandlerAsyncHookHandler => async (request, reply) => {\n await innerSetAuditContext(request, reply.raw, entityType, action);\n};\n\nexport { setRabbitAuditContext, SWAGGER_TAG, setBullMqAuditContext };\n\nexport * from './types';\nexport * from './const';\n\nexport default AuditLogger;\n"],"mappings":"kLAKA,MAAa,EAAc,CAAE,KAAM,QAAS,YAAa,iBAAkB,CAE3E,SAAgB,EAAY,CAAE,UAAS,SAAQ,wBAAkD,CAC3F,CAAC,GAAwB,CAAC,GAG9B,OAAO,QAAQ,EAAqB,CAAC,SAAS,CAAC,EAAQ,KAAiB,CACtE,EAAQ,KACN,WAAW,EAAO,YAClB,CACE,OAAQ,CACN,KAAM,CAAC,EAAY,KAAK,CACxB,YAAa,wBAAwB,EAAO,QAC5C,OAAQ,CACN,KAAM,SACN,WAAY,CACV,GAAI,CAAE,KAAM,SAAU,CACvB,CACD,SAAU,CAAC,KAAK,CACjB,CACF,CACF,CACD,KAAO,IAAQ,CACb,GAAM,CAAE,MAAO,EAAI,OAEnB,GAAI,CADe,MAAM,EAAY,SAAS,EAAG,CAChC,CACf,IAAM,EAAM,IAAI,EAEhB,MADA,EAAO,MAAM,UAAU,EAAO,WAAW,EAAG,YAAa,CAAE,MAAK,CAAC,CAC3D,EAER,OAAOA,EAAQ,gBAAgB,EAAI,EAAI,KAAyB,EAEnE,EACD,CChCJ,MAAa,EAAkB,GAAyD,CACtF,IAAM,EAAS,EAAoB,EAAQ,CACtC,KAKL,OAFA,EAAY,EAAQ,CAEb,GASI,GAAmB,EAAoB,IAA+C,MAAO,EAAS,IAAU,CAC3H,MAAM,EAAqB,EAAS,EAAM,IAAK,EAAY,EAAO,EAQpE,IAAA,EAAeC"}
|